Exemple #1
0
        static void Main(string[] args)
        {
            IDNP3Manager mgr = DNP3ManagerFactory.CreateManager();
            mgr.AddLogHandler(PrintingLogAdapter.Instance); //this is optional
            var channel = mgr.AddTCPClient("server", LogLevel.Interpret, TimeSpan.FromSeconds(5), "127.0.0.1", 8888);

            //optionally, add a listener for the channel state
            channel.AddStateListener(state => Console.WriteLine("Server state: " + state));

            var config = new SlaveStackConfig();
            config.link.localAddr = 555;
            config.link.remoteAddr = 30001;

            //Func<CommandStatus> cs = ()

            var outstation = channel.AddOutstation("outstation", LogLevel.Info,  new SimpleCommandHandler(new Func<CommandStatus>(() => CommandStatus.SUCCESS)), PrintingTimeWriteHandler.Instance, config);

            //optionally, add a listener for the stack state
            outstation.AddStateListener(state => Console.WriteLine("Outstation state: " + state));

            outstation.Enable(); // enable communications

            Console.WriteLine("Press <Enter> to randomly change a value");
            var publisher = outstation.GetDataObserver();
            Random r = new Random();
            while (true)
            {
                Console.ReadLine();
                int value = r.Next(UInt16.MaxValue);
                System.Console.WriteLine("Change Analog 0 to: " + value);
                publisher.Start();
                publisher.Update(new Analog(value, 1, DateTime.Now), 0);
                publisher.End();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            IDNP3Manager mgr = DNP3ManagerFactory.CreateManager();
            mgr.AddLogHandler(PrintingLogAdapter.Instance); //this is optional
            var channel = mgr.AddTCPServer("server", LogLevel.INFO, 5000, "127.0.0.1", 20000);

            //optionally, add a listener for the channel state
            channel.AddStateListener(state => Console.WriteLine("Server state: " + state));

            var config = new SlaveStackConfig();
            var outstation = channel.AddOutstation("outstation", LogLevel.INFO, RejectingCommandHandler.Instance, config);

            //optionally, add a listener for the stack state
            outstation.AddStateListener(state => Console.WriteLine("Outstation state: " + state));

            Console.WriteLine("Press <Enter> to randomly change a value");
            var publisher = outstation.GetDataObserver();
            Random r = new Random();
            while (true)
            {
                Console.ReadLine();
                int value = r.Next(UInt16.MaxValue);
                System.Console.WriteLine("Change Analog 0 to: " + value);
                publisher.Start();
                publisher.Update(new Analog(value, 1, DateTime.Now), 0);
                publisher.End();
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var sm = new StackManager();
            sm.AddTCPServer("server", FilterLevel.LEV_INFO, 5000, "127.0.0.1", 20000);
            var config = new SlaveStackConfig();
            var publisher = sm.AddSlave("server", "slave", FilterLevel.LEV_INFO, new RejectingCommandAcceptor(), config);

            Console.WriteLine("Press <Enter> to randomly change a value");

            Random r = new Random();
            while (true)
            {
                Console.ReadLine();
                int value = r.Next(UInt16.MaxValue);
                System.Console.WriteLine("Change Analog 0 to: " + value);
                publisher.Start();
                publisher.Update(new Analog(value, 1, DateTime.Now), 0);
                publisher.End();
            }
        }
 public void TestXmlSerializationOfMasterConfig()
 {
     var mc = new SlaveStackConfig();
     var ser = new System.Xml.Serialization.XmlSerializer(mc.GetType());
     ser.Serialize(Console.Out, mc);
 }