/// <summary> /// When the user selects a row, need to pass values to the info form so /// that it can sync data with the grid view /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void scadaDeviceView_RowEnter(object sender, DataGridViewCellEventArgs e) { List <CIMData.SCADAInfo> list = (List <CIMData.SCADAInfo>)ScadaBindingSource.DataSource; CIMData.SCADAInfo row = list.ElementAt(e.RowIndex); scadaInfoControl1.bindScadaRecord(row, scadaDeviceView); dnP3Control1.bindDataSource(row.Dnp); testScadaControl1.bindDataSource(row); }
public void bindScadaRecord(CIMData.SCADAInfo row, DataGridView view) { this.scada = row; this.scadaDeviceView = view; mridText.Text = scada.Mrid; nameText.Text = scada.Name; substationText.Text = scada.Substation; feederText.Text = scada.Feeder; typeCombo.Text = scada.DeviceType; protocolCombo.Text = scada.Protocol; descriptionText.Text = scada.Description; logLevelCombo.Text = scada.LogLevel; this.Enabled = true; }
public static void OperateDevice(string mrid, string operation, ushort point_index) { CIMData.SCADAInfo dv = findDevice(mrid); if (dv == null) { Console.WriteLine("Error - device: " + mrid + " is not in the list of devices. Be sure to start polling before controls are issued!"); } else if (dv.Connected != true) { Console.WriteLine("Error - cannot operate device until while it is not connected"); } else { var crob = new ControlRelayOutputBlock(DetermineOperationCode(operation), 1, 100, 100); var single = dv.Master.SelectAndOperate(crob, point_index, TaskConfig.Default); single.ContinueWith((result) => Console.WriteLine("Result: " + result.Result)); } }
private static string ReadDevice(string mrid) { CIMData.SCADAInfo dv = findDevice(mrid); if (dv == null) { Console.WriteLine("Error - device: " + mrid + " is not in the list of devices. Be sure to start polling before controls are issued!"); } else if (dv.Connected != true) { Console.WriteLine("Error - cannot operate device until while it is not connected"); } else { System.IO.StringWriter s = new System.IO.StringWriter(); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(CIMData.SCADAInfo)); writer.Serialize(s, dv); return(s.ToString()); } return(null); }
public static void InitDeviceConnection(CIMData.SCADAInfo scadaDev) { IDNP3Manager mgr = DNP3ManagerFactory.CreateManager(1); //mgr.AddLogHandler(PrintingLogAdapter.Instance); //this is optional UInt16 sport = Convert.ToUInt16(scadaDev.Dnp.Port); scadaDev.Channel = mgr.AddTCPClient(scadaDev.Name, LogLevels.ALL, ChannelRetry.Default, scadaDev.Dnp.IPAddress, sport); //optionally, add a listener for the channel state scadaDev.Channel.AddStateListener(state => Console.WriteLine("channel state: " + state + " for dev: " + scadaDev.Name + " addr: " + scadaDev.Dnp.IPAddress)); var config = new MasterStackConfig(); //setup your stack configuration here. UInt16 laddr = Convert.ToUInt16(scadaDev.Dnp.LocalAddress); UInt16 raddr = Convert.ToUInt16(scadaDev.Dnp.RemoteAddress); config.link.localAddr = laddr; config.link.remoteAddr = raddr; var key = new byte[16]; for (int i = 0; i < key.Length; ++i) { key[i] = 0xFF; } HandleSOEData hse = new HandleSOEData(scadaDev); scadaDev.Master = scadaDev.Channel.AddMaster("master", hse.getInstance(), DefaultMasterApplication.Instance, config); // you a can optionally add various kinds of polls var integrityPoll = scadaDev.Master.AddClassScan(ClassField.AllClasses, TimeSpan.FromMinutes(1), TaskConfig.Default); scadaDev.Master.Enable(); scadaDev.Connected = true; }
public static void TestDevice(CIMData.SCADAInfo scadaDev) { _cim.Scada.Add(scadaDev); // add to structure for testing InitDeviceConnection(scadaDev); }
public void bindDataSource(CIMData.SCADAInfo scada) { this.scada = scada; changeGroupControls(); }
public void reset() { CIMData.SCADAInfo scada = new CIMData.SCADAInfo(); this.Enabled = false; clear(); }
public PollHelper(CIMData.SCADAInfo dev, TestScadaControl tcontrol) { myDev = dev; th = tcontrol; }
public void bindDataSource(CIMData.SCADAInfo scada) { this.scada = scada; changeGroupControls(); // clear listbox updateListView(scada.Mrid); PollHelper ph = findPollingHelper(scada.Mrid); // clear state if (ph != null) { ph.logConnectionStatus(scada.Mrid, ph.ChannelState); } else { updateState("current state: CLOSED"); } }