예제 #1
0
파일: TestSetForm.cs 프로젝트: meaw/dnp3
        public TestSetForm()
        {
            InitializeComponent();

            this.sm  = new DNP3.Adapter.StackManager();
            this.lca = new LogControlAdapter(this.logControl);
            sm.AddLogHandler(lca);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var sm = new DNP3.Adapter.StackManager();

            sm.AddTCPServer("server", FilterLevel.LEV_INFO, 5000, "192.168.1.201", 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();
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            var sm = new DNP3.Adapter.StackManager();

            sm.AddLogHandler(new PrintingLogAdapter()); //this is optional
            sm.AddTCPClient("client", FilterLevel.LEV_INFO, 5000, "192.168.1.201", 20000);
            var config = new MasterStackConfig();

            config.link.useConfirms = true; //setup your stack configuration here.
            var commandAcceptor = sm.AddMaster("client", "master", FilterLevel.LEV_INFO, new PrintingDataObserver(), config);

            Console.WriteLine("Enter an index to send a command");

            while (true)
            {
                System.UInt32 index    = System.UInt32.Parse(Console.ReadLine());
                DateTime      start    = DateTime.Now;
                var           future   = commandAcceptor.AcceptCommand(new BinaryOutput(ControlCode.CC_PULSE, 1, 100, 100), index);
                CommandStatus result   = future.Await();
                DateTime      end      = DateTime.Now;
                TimeSpan      duration = end - start;
                Console.WriteLine("Result: " + result + " and took " + duration.Ticks + " Ticks");
            }
        }