예제 #1
0
        public override void Initialize(Dictionary <string, object> settings)
        {
            string pluginNamespace = GetContainerNamespace();
            //load types specific to this host into TypeContainer
            TagConfigDatabase tagConfigDatabase = TagConfigDatabase.Instance;

            tagConfigDatabase.Load(ConfigUtility.ReadFile(settings.GetValueOrNull("OpcTagConfigFile") as string));
            TagStateManager tagStateManager = new TagStateManager(tagConfigDatabase);

            settings["TagStateManager"]   = tagStateManager;
            settings["TagConfigDatabase"] = tagConfigDatabase;

            //configure receiver
            TypeContainer            tc           = TypeContainer.Instance;
            IProcessor               opcReceiver  = tc.GetInstance <IReceiver>(pluginNamespace) as IProcessor;
            IConverter <object, Tag> opcConverter = tc.GetInstance <IConverter <object, Tag> >(pluginNamespace);

            settings["Logger"]          = tc.GetInstance <ILogger>();
            settings["OpcTagConverter"] = opcConverter;
            if (opcReceiver != null)
            {
                this.AddReceiver("OpcReceiver", opcReceiver);
            }

            //configure IotHub Sender: need "IotHubConfigFile", "TagStateManager", "TagToIotHubMessageConverter" in settings
            settings["TagToIotHubMessageConverter"] = tc.GetInstance <IConverter <Tag, object> >(pluginNamespace);
            IProcessor iotHubSender = tc.GetInstance <ISender>(pluginNamespace) as IProcessor;

            if (iotHubSender != null)
            {
                this.AddSender("IotHubSender", iotHubSender);
            }

            base.Initialize(settings);
        }
예제 #2
0
 private static void Initialize(TypeContainer tc)
 {
     _settings = new DynamicDictionary();
     _settings.OpenTsdbConfigFile = "OpenTsdbConfig.json";
     _settings.EventHubConfigFile = "EventHubConfig.json";
     _settings.Logger = tc.GetInstance<ILogger>();
     _settings.TsdbConverter = tc.GetInstance<IConverter<EventData, DataPoint>>("OpenTSDB");
     _settings.Debug = true;
 }
예제 #3
0
        public override void Initialize(Dictionary <string, object> settings)
        {
            string pluginNamespace = GetContainerNamespace();

            Debug.Assert(pluginNamespace != null);
            //load types specific to this host into TypeContainer
            TypeContainer tc = TypeContainer.Instance;
            IProcessor    commandReceiver = tc.GetInstance <IReceiver>(pluginNamespace) as IProcessor;

            //configure reqired settings: "Logger", "CmdExecutor", "CmdConverter"
            //"IotHubConfigFile" is already part of the settings by this time
            settings["Logger"]       = tc.GetInstance <ILogger>();
            settings["CmdExecutor"]  = tc.GetInstance <ICommandExecutor <Command> >(pluginNamespace);
            settings["CmdConverter"] = tc.GetInstance <IConverter <string, Command> >(pluginNamespace);
            this._receivers.Add("CommandReceiver", commandReceiver);
            base.Initialize(settings);
        }
예제 #4
0
        public override void Initialize(Dictionary <string, object> settings)
        {
            string pluginNamespace = GetContainerNamespace();

            Debug.Assert(pluginNamespace != null);
            TypeContainer tc = TypeContainer.Instance;
            //"IotHubConfigFile", "MessageExchange", "ExchangeToIotHubMessageConverter", "Logger"
            //configure receiver
            IProcessor messageReceiver = tc.GetInstance <IReceiver>(pluginNamespace) as IProcessor;
            IConverter <object, Msg> receivedMessageConverter = tc.GetInstance <IConverter <object, Msg> >(pluginNamespace);

            settings["MessageConverter.OpcUa"] = receivedMessageConverter;
            if (messageReceiver != null)
            {
                this.AddReceiver("MessageReceiver", messageReceiver);
            }

            //configure sender
            IProcessor messageSender = tc.GetInstance <ISender>(pluginNamespace) as IProcessor;
            IConverter <object, Msg> messageConverter = tc.GetInstance <IConverter <object, Msg> >(pluginNamespace);
            IMessageExchange <Msg>   messageExchange  = tc.GetInstance <IMessageExchange <Msg> >(pluginNamespace);

            settings["MessageExchange.Messaging"] = messageExchange;
            settings["MessageConverter.IotHub"]   = messageConverter;
            settings["Logger"] = tc.GetInstance <ILogger>();

            if (messageSender != null)
            {
                this.AddSender("MessageSender", messageSender);
            }

            base.Initialize(settings);
        }
예제 #5
0
        private static void Run(TypeContainer tc)
        {
            Dictionary <string, object> settings = new Dictionary <string, object>();

            settings["IotHubConfigFile"]    = "IotHubConfig.json";
            settings["OpcServerConfigFile"] = "OpcServerConfig.json";
            settings["OpcTagConfigFile"]    = "TagConfig.json";

            //Configure TelemetryHost
            IServiceHost telemetryHost = tc.GetInstance <IServiceHost>(TELEMETRY_NAMESPACE);

            //until we have constructor support in TypeContainer, we will need to initialize the namespace separately
            telemetryHost.SetContainerNamespace(TELEMETRY_NAMESPACE);
            IProcessor telemetryHostProcessor = (IProcessor)telemetryHost;

            telemetryHostProcessor.Initialize(settings);

            //Configure ControlHost
            IServiceHost commandHost = tc.GetInstance <IServiceHost>(COMMAND_NAMESPACE);

            commandHost.SetContainerNamespace(COMMAND_NAMESPACE);
            IProcessor commandHostProcessor = (IProcessor)commandHost;

            commandHostProcessor.Initialize(settings);


            System.Console.WriteLine("Press ENTER to Start IoT Gateway");
            System.Console.ReadLine();

            telemetryHost.Start();
            commandHost.Start();

            //wait for the user to exit

            System.Console.WriteLine("Press ENTER to exit");
            System.Console.ReadLine();
        }