private void ConnectOPCServer() { Status = new NetworkVariableSubscriber <bool>(networkVariableDataSource1.Bindings[0].Location); S1Status = new NetworkVariableWriter <bool>(networkVariableDataSource1.Bindings[10].Location); S2Status = new NetworkVariableWriter <bool>(networkVariableDataSource1.Bindings[11].Location); S3Status = new NetworkVariableWriter <bool>(networkVariableDataSource1.Bindings[12].Location); S4Status = new NetworkVariableWriter <bool>(networkVariableDataSource1.Bindings[13].Location); Emergency = new NetworkVariableSubscriber <bool>(networkVariableDataSource1.Bindings[1].Location); Input1 = new NetworkVariableSubscriber <UInt16>(networkVariableDataSource1.Bindings[3].Location); Output1 = new NetworkVariableWriter <UInt16>(networkVariableDataSource1.Bindings[2].Location); Input2 = new NetworkVariableSubscriber <UInt16>(networkVariableDataSource1.Bindings[5].Location); Output2 = new NetworkVariableWriter <UInt16>(networkVariableDataSource1.Bindings[4].Location); Input3 = new NetworkVariableSubscriber <UInt16>(networkVariableDataSource1.Bindings[7].Location); Output3 = new NetworkVariableWriter <UInt16>(networkVariableDataSource1.Bindings[6].Location); Input4 = new NetworkVariableSubscriber <UInt16>(networkVariableDataSource1.Bindings[9].Location); Output4 = new NetworkVariableWriter <UInt16>(networkVariableDataSource1.Bindings[8].Location); //Configuring Handlers Status.DataUpdated += new EventHandler <DataUpdatedEventArgs <bool> >(NeoStat); Emergency.DataUpdated += new EventHandler <DataUpdatedEventArgs <bool> >(EmergencyStop); Input1.DataUpdated += new EventHandler <DataUpdatedEventArgs <UInt16> >(Input1New); Input2.DataUpdated += new EventHandler <DataUpdatedEventArgs <UInt16> >(Input2New); Input3.DataUpdated += new EventHandler <DataUpdatedEventArgs <UInt16> >(Input3New); Input4.DataUpdated += new EventHandler <DataUpdatedEventArgs <UInt16> >(Input4New); //Custom Handlers for Queues and positions //Connecting Status.Connect(); Emergency.Connect(); Input1.Connect(); Input2.Connect(); Input3.Connect(); Input4.Connect(); S1Status.Connect(); S2Status.Connect(); S3Status.Connect(); S4Status.Connect(); }
private void NewValue() { inputsub = new NetworkVariableSubscriber <UInt16>(networkVariableDataSource1.Bindings[0].Location); inputsub.DataUpdated += new EventHandler <DataUpdatedEventArgs <UInt16> >(DataUp); inputsub.Connect(); }
private void ConnectOPCServer() { Overall_Status = new NetworkVariableReader <bool>(networkVariableDataSource1.Bindings[0].Location); EmergencyStop = new NetworkVariableWriter <bool>(networkVariableDataSource1.Bindings[1].Location); Station1Status = new NetworkVariableReader <bool>(networkVariableDataSource1.Bindings[2].Location); Station2Status = new NetworkVariableReader <bool>(networkVariableDataSource1.Bindings[3].Location); Station3Status = new NetworkVariableReader <bool>(networkVariableDataSource1.Bindings[4].Location); Station4Status = new NetworkVariableReader <bool>(networkVariableDataSource1.Bindings[5].Location); Station1_Status = new NetworkVariableSubscriber <bool>(networkVariableDataSource1.Bindings[2].Location); Station2_Status = new NetworkVariableSubscriber <bool>(networkVariableDataSource1.Bindings[3].Location); Station3_Status = new NetworkVariableSubscriber <bool>(networkVariableDataSource1.Bindings[4].Location); Station4_Status = new NetworkVariableSubscriber <bool>(networkVariableDataSource1.Bindings[5].Location); //Handles Station1_Status.DataUpdated += new EventHandler <DataUpdatedEventArgs <bool> >(S1S); Station2_Status.DataUpdated += new EventHandler <DataUpdatedEventArgs <bool> >(S2S); Station3_Status.DataUpdated += new EventHandler <DataUpdatedEventArgs <bool> >(S3S); Station4_Status.DataUpdated += new EventHandler <DataUpdatedEventArgs <bool> >(S4S); //Connects Overall_Status.Connect(); Station1Status.Connect(); Station2Status.Connect(); Station3Status.Connect(); Station4Status.Connect(); EmergencyStop.Connect(); Station1_Status.Connect(); Station2_Status.Connect(); Station3_Status.Connect(); Station4_Status.Connect(); //System Sys_Status.Value = Convert.ToBoolean(Overall_Status.ReadData().GetValue()); switch (Sys_Status.Value) { case true: label7.Text = "Operational"; break; case false: label7.Text = "Not Operational"; break; } //Station 1 bool data = Station1Status.ReadData().GetValue(); Station_1.Value = data; switch (Station_1.Value) { case true: label8.Text = "Operational"; break; case false: label8.Text = "Not Operational"; break; } //Station 2 data = Station2Status.ReadData().GetValue(); Station_2.Value = data; switch (Station_2.Value) { case true: label9.Text = "Operational"; break; case false: label9.Text = "Not Operational"; break; } //Station 3 data = Station3Status.ReadData().GetValue(); Station_3.Value = data; switch (Station_3.Value) { case true: label10.Text = "Operational"; break; case false: label10.Text = "Not Operational"; break; } //Station 4 data = Station4Status.ReadData().GetValue(); Station_4.Value = data; switch (Station_4.Value) { case true: label11.Text = "Operational"; break; case false: label11.Text = "Not Operational"; break; } Station1Status.Disconnect(); Station2Status.Disconnect(); Station3Status.Disconnect(); Station4Status.Disconnect(); }