我尝试从数据块(DB60)读取数据,但我只得到?5
. 所以在数据块中应该是JAMES17
。
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "Connect PLC")
{
button1.Text = "Disconnect PLC";
ClassPLCS7Client.PLCClientConnect_Result ConnectResult = new
ClassPLCS7Client.PLCClientConnect_Result();
ConnectResult = PLCClient.Connect(("192.168.0.2"), 0, 1);
if (ConnectResult.State == ClassPLCS7Client.PLCClientConnectState.Connected)
{
this.label1.Text = "Connected PLC1 " + ConnectResult.ReSultString;
label1.ForeColor = Color.Green;
ClassPLCS7Client.ReadDataBlockString_Result read = new ClassPLCS7Client.ReadDataBlockString_Result();
read = PLCClient.ReadDataBlockString(60, 0, 7);
this.textBox1.Text = read.DataValue[0];
//this.textBox1.Text = arr4[];// read.ReSultString;
}
else
{
this.label1.Text = "Fail " + ConnectResult.ReSultString;
label1.ForeColor = Color.Red;
}
}
else
{
button1.Text = "Connect PLC";
disconnect_plc();
this.label1.Text = "Disconnect";
label1.ForeColor = Color.Black;
}
}<code>