I try to read data from datablock (DB60), but I get only ?5
. So in data block should be 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>