Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
        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));
            }
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
 public static void TestDevice(CIMData.SCADAInfo scadaDev)
 {
     _cim.Scada.Add(scadaDev);   // add to structure for testing
     InitDeviceConnection(scadaDev);
 }
Esempio n. 8
0
        public void bindDataSource(CIMData.SCADAInfo scada)
        {
            this.scada = scada;

            changeGroupControls();
        }
Esempio n. 9
0
 public void reset()
 {
     CIMData.SCADAInfo scada = new CIMData.SCADAInfo();
     this.Enabled = false;
     clear();
 }
Esempio n. 10
0
 public PollHelper(CIMData.SCADAInfo dev, TestScadaControl tcontrol)
 {
     myDev = dev;
     th = tcontrol;
 }
Esempio n. 11
0
        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");
            }
        }
Esempio n. 12
0
 public void reset()
 {
     CIMData.SCADAInfo scada = new CIMData.SCADAInfo();
     this.Enabled = false;
     clear();
 }