All example servers are using same objects.
Наследование: Gurux.DLMS.GXDLMSNotify
Пример #1
0
        static void Main(string[] args)
        {
            try
            {
                int   port  = 4059;
                GXNet media = new GXNet(NetworkType.Tcp, "localhost", port);
                GXDLMSSecureNotify notify = new GXDLMSSecureNotify(true, 16, 1, InterfaceType.WRAPPER);
                // Un-comment this if you want to send encrypted push messages.
                // notify.Ciphering.Security = Security.AuthenticationEncryption;
                GXDLMSPushSetup p     = new GXDLMSPushSetup();
                GXDLMSClock     clock = new GXDLMSClock();
                p.PushObjectList.Add(new KeyValuePair <GXDLMSObject, GXDLMSCaptureObject>(p, new GXDLMSCaptureObject(2, 0)));
                p.PushObjectList.Add(new KeyValuePair <GXDLMSObject, GXDLMSCaptureObject>(clock, new GXDLMSCaptureObject(2, 0)));

                ///////////////////////////////////////////////////////////////////////
                //Create Gurux DLMS server component for Short Name and start listen events.
                GXDLMSPushListener pushListener = new GXDLMSPushListener(port);
                Console.WriteLine("Listening DLMS Push IEC 62056-47 messages on port " + port + ".");
                Console.WriteLine("Press X to close and Enter to send a Push message.");
                ConsoleKey key;
                while ((key = Console.ReadKey().Key) != ConsoleKey.X)
                {
                    if (key == ConsoleKey.Enter)
                    {
                        Console.WriteLine("Sending Push message.");
                        media.Open();
                        clock.Time = DateTime.Now;
                        foreach (byte[] it in notify.GeneratePushSetupMessages(DateTime.MinValue, p))
                        {
                            media.Send(it, null);
                        }
                        Thread.Sleep(100);
                        media.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            try
            {
                int port = 4059;
                GXNet media = new GXNet(NetworkType.Tcp, "localhost", port);
                GXDLMSNotify cl = new GXDLMSNotify(true, 1, 1, InterfaceType.WRAPPER);
                GXDLMSPushSetup p = new GXDLMSPushSetup();
                GXDLMSClock clock = new GXDLMSClock();
                p.PushObjectList.Add(new KeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(p, new GXDLMSCaptureObject(2, 0)));
                p.PushObjectList.Add(new KeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(clock, new GXDLMSCaptureObject(2, 0)));

                ///////////////////////////////////////////////////////////////////////
                //Create Gurux DLMS server component for Short Name and start listen events.
                GXDLMSPushListener pushListener = new GXDLMSPushListener(port);
                Console.WriteLine("Listening DLMS Push IEC 62056-47 messages on port " + port + ".");
                Console.WriteLine("Press X to close and Enter to send a Push message.");
                ConsoleKey key;
                while ((key = Console.ReadKey().Key) != ConsoleKey.X)
                {
                    if (key == ConsoleKey.Enter)
                    {
                        Console.WriteLine("Sending Push message.");
                        media.Open();
                        clock.Time = DateTime.Now;
                        foreach (byte[] it in cl.GeneratePushSetupMessages(DateTime.MinValue, p))
                        {
                            media.Send(it, null);
                        }
                        Thread.Sleep(100);
                        media.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }