Esempio n. 1
0
        ISimulatorNode CreateOutstation(ISimulatorNodeCallbacks callbacks, IOutstationModule module)
        {
            using (var dialog = new Components.OutstationDialog(config, module))
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    var outstationConfig = dialog.Configuration;
                    var alias            = dialog.SelectedAlias;
                    var factory          = module.CreateFactory();

                    var outstation = channel.AddOutstation(alias, factory.CommandHandler, factory.Application, outstationConfig);

                    if (outstation == null)
                    {
                        return(null);
                    }
                    else
                    {
                        var instance = factory.CreateInstance(outstation, alias, outstationConfig);
                        outstation.Enable();

                        if (instance.ShowFormOnCreation)
                        {
                            instance.ShowForm();
                        }

                        return(new OutstationNode(outstation, instance, callbacks));
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 2
0
        ISimulatorNode CreateOutstation(ISimulatorNodeCallbacks callbacks)
        {
            using (var dialog = new Components.OutstationDialog(config))
            {
                dialog.ShowDialog();
                if (dialog.DialogResult == DialogResult.OK)
                {
                    var outstationConfig = dialog.Configuration;
                    var alias            = dialog.SelectedAlias;
                    var cache            = new MeasurementCache(outstationConfig.databaseTemplate);
                    var handler          = new ProxyCommandHandler();
                    var application      = new EventedOutstationApplication();
                    var outstation       = channel.AddOutstation(alias, handler, application, outstationConfig);

                    if (outstation == null)
                    {
                        return(null);
                    }
                    else
                    {
                        outstation.Enable();
                        return(new OutstationNode(cache, handler, application, config, outstation, callbacks, alias));
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 3
0
        public Rtu(string name, IPEndpoint hostAddres, ushort localDNP3Addres, ushort remoteDNP3Address)
        {
            //Considerando uma RTU por Canal
            Channel = Core.DNP3Manager.AddTCPServer(name, LogLevels.ALL, ServerAcceptMode.CloseExisting, hostAddres.address, hostAddres.port, ChannelListener.Print());
            Config  = new OutstationStackConfig();
            Config.databaseTemplate = new DatabaseTemplate(4, 0, 1, 1, 1, 1, 1, 0, 0);
            Config.databaseTemplate.analogs[0].clazz  = PointClass.Class2;
            Config.outstation.config.allowUnsolicited = false;
            Config.link.remoteAddr = remoteDNP3Address;
            Config.link.localAddr  = localDNP3Addres;

            Outstation = Channel.AddOutstation(name, RejectingCommandHandler.Instance, DefaultOutstationApplication.Instance, Config);
            Outstation.Enable();
        }
        private void ConfigureOutstation()
        {
            var outstationConfig = new OutstationStackConfig();

            // configure the various measurements in our database
            //outstationConfig.databaseTemplate = new DatabaseTemplate(4, 1, 1, 1, 1, 1, 1, 0);
            outstationConfig.databaseTemplate = new DatabaseTemplate(
                (ushort)0,
                (ushort)0,
                (ushort)255,
                (ushort)0,
                (ushort)0,
                (ushort)0,
                (ushort)0,
                (ushort)0);

            var template = outstationConfig.databaseTemplate;


            outstationConfig.outstation.config.allowUnsolicited = true;

            outstationConfig.link.localAddr  = 10;
            outstationConfig.link.remoteAddr = 1;
            outstationConfig.outstation.buffer.maxAnalogEvents             = (uint)random.Next();
            outstationConfig.outstation.buffer.maxAnalogOutputStatusEvents = (uint)random.Next();
            outstationConfig.outstation.buffer.maxBinaryEvents             = (uint)random.Next();
            outstationConfig.outstation.buffer.maxBinaryOutputStatusEvents = (uint)random.Next();
            outstationConfig.outstation.buffer.maxCounterEvents            = (uint)random.Next();
            outstationConfig.outstation.buffer.maxDoubleBinaryEvents       = (uint)random.Next();
            outstationConfig.outstation.buffer.maxFrozenCounterEvents      = (uint)random.Next();

            outstation = channel.AddOutstation("outstation", RejectingCommandHandler.Instance, DefaultOutstationApplication.Instance, outstationConfig);
            if (outstation != null)
            {
                outstation.Enable(); // enable communications
            }
        }