Пример #1
0
        public SgetUniversalIotConnector(
            UicConfiguartion uicConfiguartion,
            CommunicationAgent communicationAgent,
            ProjectAgent projectAgent,
            ISerializer serializer,
            ILoggerFactory loggerFactory)
        {
            _uicConfiguartion   = uicConfiguartion;
            _communicationAgent = communicationAgent;
            _projectAgent       = projectAgent;
            _serializer         = serializer;
            _loggerFactory      = loggerFactory;

            _logger = _loggerFactory.GetLoggerFor(GetType());
        }
Пример #2
0
        static void Main()
        {
            UniversalIotConnector uic = null;

            try
            {
                ILoggerFactory loggerFactory = new NlogLoggerFactory();
                _logger = loggerFactory.GetLoggerFor(typeof(Launcher));
                _logger.Information("Let's go");
                ISerializer                 serializer            = new UicSerializer();
                UicConfiguartion            uicConfiguartion      = GetConfiguration(serializer);
                List <EmbeddedDriverModule> embeddedDriverModules = GetEdms(loggerFactory);

                CommunicationAgent communicationAgent = null;
                ProjectAgent       projectAgent       = null;
                if (uicConfiguartion.CommunicationAgent.Equals("M2MGO"))
                {
                    communicationAgent = new M2mgoCommunicationAgentImpl(serializer, loggerFactory);
                    _logger.Information("Used M2MGO Communication Agent as default");
                    projectAgent = new M2mgoProjectAgent(serializer, loggerFactory);
                }
                else if (uicConfiguartion.CommunicationAgent.Equals("AWS"))
                {
                    communicationAgent = new HAWCommunicationAgent(serializer, loggerFactory);
                    _logger.Information("Used HAW Communication Agent");
                    projectAgent = new M2mgoProjectAgent(serializer, loggerFactory);
                }
                else if (uicConfiguartion.CommunicationAgent.Equals("AZURE"))
                {
                    communicationAgent = new AzureCommunicationAgentImpl(serializer, loggerFactory);
                    projectAgent       = new AzureProjectAgent(serializer, loggerFactory);
                    _logger.Information("Used AZURE Communication Agent");
                }
                else
                {
                    _logger.Information("no agent used");
                }

                uic = new SgetUniversalIotConnector(uicConfiguartion, communicationAgent, projectAgent, serializer, loggerFactory);

                uic.Initialize(embeddedDriverModules.ToArray());

                _logger.Information("Enter to Dispose ....");
                Console.ReadLine();
            }
            catch (Exception e)
            {
                _logger.Error(e);
            }
            finally
            {
                if (uic != null)
                {
                    _logger.Information("Dipose uic ");
                    try
                    {
                        uic.Dispose();
                    }
                    catch (Exception e)
                    {
                        _logger.Error(e);
                    }
                }
            }

            _logger.Information("Enter to end ....");
            Console.ReadLine();
        }