Пример #1
0
 /// <summary>
 /// whenever a new row from the datagrid view (scada) is selected, this re-binds
 /// this form to the current row
 /// </summary>
 /// <param name="dnp"></param>
 public void bindDataSource(CIMData.DNP dnp)
 {
     // todo : For all numerics (timeouts, etc...), is there a default value, use 0, or null if not set?
     this._dnp = dnp;
     ipAddressText.Text = dnp.IPAddress;
     remoteAddressText.Text = dnp.RemoteAddress;
     localAddressText.Text = dnp.LocalAddress;
     portText.Text = dnp.Port;
     integrityScanText.Text = dnp.IntegrityScanRate;
     saveIntervalText.Text = dnp.SaveInterval;
     UnsolicitedCheck.Checked = dnp.IsUnsolictedOnStartup;
     EnableUnsolCheck.Checked = dnp.IsEnableUnsolicited;
     timeSyncCheck.Checked = dnp.IsTimeSync;
     useConfirmsCheck.Checked = dnp.IsUseConfirms;
     tcpRadio.Checked = (dnp.Transport == CIMData.DNP.transportEnum.TCP) ? true : false;
     udpRadio.Checked = (dnp.Transport == CIMData.DNP.transportEnum.UDP) ? true : false;
     localRadio.Checked = (dnp.Initiation == CIMData.DNP.initiationEnum.Local) ? true : false;
     remoteRadio.Checked = (dnp.Initiation == CIMData.DNP.initiationEnum.Remote) ? true : false;
     SBORadio.Checked = (dnp.Dnpfunction == CIMData.DNP.DNPFunctionEnum.SB0) ? true : false;
     DORadio.Checked = (dnp.Dnpfunction == CIMData.DNP.DNPFunctionEnum.D0 ? true : false);
     doNoAckRadio.Checked = (dnp.Dnpfunction == CIMData.DNP.DNPFunctionEnum.DO_NOACK) ? true : false;
     class0Check.Checked = dnp.Class0;
     Class1Check.Checked = dnp.Class1;
     class2Check.Checked = dnp.Class2;
     class3Check.Checked = dnp.Class3;
     this.Enabled = true;
 }
Пример #2
0
        public static void loadScadaConfigFile([MarshalAs(UnmanagedType.LPTStr)] String path)
        {
            Console.WriteLine("loading config file : " + path);

            _cim = DERMSInterface.CIMData.read(path);

            // SCADAIFace._config_file_loaded = true;
        }
Пример #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;
 }
Пример #4
0
        /// <summary>
        /// whenever a new row from the datagrid view (scada) is selected, this re-binds
        /// this form to the current row
        /// </summary>
        /// <param name="dnp"></param>
        public void bindDataSource(CIMData.DNP dnp)
        {
            // todo : For all numerics (timeouts, etc...), is there a default value, use 0, or null if not set?
            this._dnp = dnp;

            maxFragSizeText.Text = dnp.MaxFragSize;
            frameRetriesText.Text = dnp.FrameRetries;
            ResponseTimeoutText.Text = dnp.ResponseTimeout;
            fragSizeText.Text = dnp.FragSize;
            taskRetryRateText.Text = dnp.TaskRetryRate;
            linkRetriesText.Text = dnp.NumRetries;
            confirmTimeoutText.Text = dnp.ConfirmationTimeout;
            taskRetryRateText.Text = dnp.RetryTimeout;
            this.Enabled = true;
        }
Пример #5
0
        static bool FindControlPointDefinition(CIMData.SCADAInfo dv, string pointname,  out ushort pindex)
        {
            pindex = 0;
            foreach (var cp in dv.Dnp.Control_points)
            {
                if (cp.Name.Equals(pointname))
                {
                    pindex =  cp.Pindex;
                    return true;
                }
            }

            Console.WriteLine("No matching control point found for " + pointname);

            return false;
        }
Пример #6
0
 public static void TestDevice(CIMData.SCADAInfo scadaDev)
 {
     _cim.Scada.Add(scadaDev);   // add to structure for testing
     InitDeviceConnection(scadaDev);
 }
Пример #7
0
        public static void loadScadaConfigFile([MarshalAs(UnmanagedType.LPTStr)] String path)
        {
            Console.WriteLine("loading config file : " + path);

            _cim = DERMSInterface.CIMData.read(path);

            SCADAIFace._config_file_loaded = true;
        }
Пример #8
0
        public static void InitDeviceConnection(CIMData.SCADAInfo scadaDev)
        {
            try
            {
                Console.WriteLine("init dev 0");

                IDNP3Manager mgr = DNP3ManagerFactory.CreateManager(1);
                //mgr.AddLogHandler(PrintingLogAdapter.Instance); //this is optional
                UInt16 sport = Convert.ToUInt16(scadaDev.Dnp.Port);

                Console.WriteLine("init dev 1");
                scadaDev.Channel = mgr.AddTCPClient(scadaDev.Name, LogLevels.ALL, ChannelRetry.Default, scadaDev.Dnp.IPAddress, sport);

                Console.WriteLine("init dev 2");

                //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));

                Console.WriteLine("init dev 3");

                var config = new MasterStackConfig();

                Console.WriteLine("init dev 4");

                //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);

                double intscan;
                if ((!Double.TryParse(scadaDev.Dnp.IntegrityScanRate, out intscan)) || (intscan <= 0)) {
                    intscan = 60000;
                    Console.WriteLine("Invalid integrity scan - defaulting to 1 minute");
                }
                var integrityPoll = scadaDev.Master.AddClassScan(ClassField.AllClasses, TimeSpan.FromMilliseconds(intscan), TaskConfig.Default);

                scadaDev.Master.Enable();
            } catch (Exception e)
            {
                Console.WriteLine("error on initialization :{0} " + e);
            }

            scadaDev.Connected = true;
        }
Пример #9
0
 public void bindDataSource(CIMData.DNP dnp)
 {
     this.dnp = dnp;
     dnP3BasicControl1.bindDataSource(dnp);
     dnP3Advanced1.bindDataSource(dnp);
 }
Пример #10
0
 public PollHelper(CIMData.SCADAInfo dev, TestScadaControl tcontrol)
 {
     myDev = dev;
     th = tcontrol;
 }
Пример #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");
            }
        }