Beispiel #1
0
        static void Main(string[] args)
        {
            var    connector = new EltraMasterConnector();
            string filePath  = "TEST_0200h_0000h_0000h_0000h.xdd";

            Console.WriteLine($"Hello Test Eltra Unit Tests Master!");

            MsgLogger.LogLevels  = "Error;Exception;Timing;Workflow";
            MsgLogger.LogOutputs = "Console";

            var runner = Task.Run(async() =>
            {
                connector.Host = "https://eltra.ch";

                if (args.Length > 0)
                {
                    connector.Host = args[0];
                }

                Console.WriteLine("Sign-in ...");

                if (await connector.SignIn(new UserIdentity()
                {
                    Login = $"*****@*****.**", Name = "Test", Password = "******", Role = "developer"
                }, true))
                {
                    var predefinedAlias = new UserIdentity()
                    {
                        Login = "******", Password = "******", Name = "Tester", Role = "engineer"
                    };

                    if (await connector.CreateAlias(predefinedAlias))
                    {
                        Console.WriteLine($"User-defined alias, login='******', password='******'");
                    }
                    else
                    {
                        Console.WriteLine("ERROR: user defined alias not created!");
                    }

                    connector.StatusChanged              += OnConnectorStatusChanged;
                    connector.ChannelStatusChanged       += OnChannelStatusChanged;
                    connector.RemoteChannelStatusChanged += OnRemotePartyChannelStatusChanged;

                    Console.WriteLine("Signed in - Start service");

                    connector.StartService("TEST", new TestDeviceManager(filePath));
                }
                else
                {
                    Console.WriteLine("error: cannot sign-in!");
                }
            });

            Console.ReadKey();

            connector.StopService("TEST");

            runner.Wait();
        }
Beispiel #2
0
        private static void RunOptionsAndReturnExitCode(MasterOptions opts)
        {
            var    appName  = AppDomain.CurrentDomain.FriendlyName;
            var    settings = new MasterSettings();
            var    host     = settings.Host;
            string login    = settings.Identity.AuthData.Login;
            string password = settings.Identity.AuthData.Password;

            if (!string.IsNullOrEmpty(opts.Host))
            {
                host = opts.Host;
            }

            if (!string.IsNullOrEmpty(opts.Login))
            {
                login = opts.Login;
            }

            if (!string.IsNullOrEmpty(opts.Password))
            {
                password = opts.Password;
            }

            var master = new EltraMasterConnector();

            master.Host = host;
            master.ConnectionSettings = new ConnectionSettings()
            {
                UpdateInterval = settings.UpdateInterval, Timeout = settings.Timeout
            };

            var t = Task.Run(async() => {
                Console.WriteLine($"Sign-in login={login}, passwd={password}");

                var di = new UserIdentity()
                {
                    Login = login, Name = settings.Identity.Name, Password = password, Role = settings.Identity.Role
                };

                if (await master.SignIn(di, true))
                {
                    if (!master.StartService(appName, new EposDeviceManager(settings)))
                    {
                        MsgLogger.WriteError(appName, "starting master service failed!");
                    }
                }
            });

            t.Wait();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            string serviceName = "STREEMA";

            var connector = new EltraMasterConnector();
            var settings  = new StreemaSettings();

            MsgLogger.LogLevels  = "Error;Exception;Workflow";
            MsgLogger.LogOutputs = "Console;File";

            Console.WriteLine($"Hello Streema Eltra Master - {serviceName}!");

            var runner = Task.Run(async() =>
            {
                connector.Host = settings.Host;

                Console.WriteLine("Sign-in ...");

                if (await connector.SignIn(new UserIdentity()
                {
                    Login = settings.Login, Name = "Streema", Password = settings.LoginPasswd, Role = "developer"
                }, true))
                {
                    var predefinedAlias = new UserIdentity()
                    {
                        Login = settings.Alias, Password = settings.AliasPasswd, Name = "Streema client", Role = "engineer"
                    };

                    if (await connector.CreateAlias(predefinedAlias))
                    {
                        Console.WriteLine($"User-defined alias, login='******', password='******'");
                    }
                    else
                    {
                        Console.WriteLine("ERROR: user defined alias not created!");
                    }

                    connector.StatusChanged              += OnConnectorStatusChanged;
                    connector.ChannelStatusChanged       += OnChannelStatusChanged;
                    connector.RemoteChannelStatusChanged += OnRemotePartyChannelStatusChanged;

                    Console.WriteLine("Signed in - Start service");

                    //heartbeat every 3 min, timeout device after 9 min
                    connector.ConnectionSettings = new ConnectionSettings()
                    {
                        UpdateInterval = 180, Timeout = 540
                    };

                    connector.StartService(serviceName, new StreemaDeviceManager(settings.XddFile, settings));
                }
                else
                {
                    Console.WriteLine("error: cannot sign-in!");
                }
            });

            /*if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
             * {
             *  Console.ReadKey();
             *
             *  connector.StopService(serviceName);
             * }*/

            runner.Wait();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var    connector   = new EltraMasterConnector();
            int    serviceId   = 1;
            string serviceName = "DUMMY#1";

            if (args.Length > 0)
            {
                if (int.TryParse(args[0], out int si))
                {
                    serviceId = si;
                }
            }

            serviceName = $"DUMMY#{serviceId}";

            string filePath = "DUMMY_0100h_0000h_0000h_0000h.xdd";

            Console.WriteLine($"Hello Dummy Eltra Master - {serviceName}!");

            var runner = Task.Run(async() =>
            {
                //connector.Host = "https://eltra.ch";
                connector.Host = "http://*****:*****@eltra.ch", Name = "Dummy", Password = "******", Role = "developer"
                }, true))
                {
                    var predefinedAlias = new UserIdentity()
                    {
                        Login = "******", Password = "******", Name = "dummy", Role = "engineer"
                    };

                    if (await connector.CreateAlias(predefinedAlias))
                    {
                        Console.WriteLine($"User-defined alias, login='******', password='******'");
                    }
                    else
                    {
                        Console.WriteLine("ERROR: user defined alias not created!");
                    }

                    var alias = await connector.CreateAlias("operator");

                    if (alias != null)
                    {
                        Console.WriteLine($"Alias, login='******', password='******'");
                    }
                    else
                    {
                        Console.WriteLine("ERROR: alias not created!");
                    }

                    connector.StatusChanged              += OnConnectorStatusChanged;
                    connector.ChannelStatusChanged       += OnChannelStatusChanged;
                    connector.RemoteChannelStatusChanged += OnRemotePartyChannelStatusChanged;

                    Console.WriteLine("Signed in - Start service");

                    connector.StartService(serviceName, new DummyDeviceManager(filePath));
                }
                else
                {
                    Console.WriteLine("error: cannot sign-in!");
                }
            });

            Console.ReadKey();

            connector.StopService(serviceName);

            runner.Wait();
        }