public void Initialize(Dictionary <string, object> settings) { string[] fieldNames = new string[] { "IotHubConfigFile", "TagStateManager", "TagToIotHubMessageConverter" }; FieldValidator.CheckMissingFields(settings, fieldNames); string iotHubConfigFile = settings.GetValueOrNull("IotHubConfigFile") as string; _iotHubConfig = ConfigUtility.ReadConfig <IotHubConfig>(iotHubConfigFile); _dataConverter = settings.GetValueOrNull("TagToIotHubMessageConverter") as IConverter <Tag, object>; _tagStateManager = settings.GetValueOrNull("TagStateManager") as TagStateManager; _deviceClienPool = new DeviceClientPool(); _deviceClienPool.Initialize(_iotHubConfig.IotHubHostName, _iotHubConfig.TelemetryDevicePool); }
/// <summary> /// All the following fields are mandatory; the data type of all the fields are string type /// settings.ServiceBusNameSpace, settings.EventHubName, settings.EventHubConnectionString /// </summary> /// <param name="settings"></param> public void Initialize(Dictionary <string, object> settings) { string[] fieldNames = new string[] { "EventHubConfigFile", "MessageExchange", "TagToEventDataConverter" }; //validates missing fields and throws ValidationException in case of errors. Let us not catch it here so as to avoid //passing it through multiple layers FieldValidator.CheckMissingFields(settings, fieldNames); string eventHubConfigFile = settings.GetValueOrNull("EventHubConfigFile") as string; _eventHubConfig = ConfigUtility.ReadConfig <Dictionary <string, string> >(eventHubConfigFile); _messageExchange = settings.GetValueOrNull("MessageExchange") as IMessageExchnage <TMsg>; _dataConverter = settings.GetValueOrNull("TagToEventDataConverter") as IConverter <TMsg, object>; }
public void Initialize(Dictionary <string, object> settings) { string[] fieldNames = new string[] { "IotHubConfigFile", "MessageConverter.OpcUa", "MessageExchange.Messaging", "MessageConverter.IotHub", "Logger" }; FieldValidator.CheckMissingFields(settings, fieldNames); string iotHubConfigFile = settings.GetValueOrNull("IotHubConfigFile") as string; _iotHubConfig = ConfigUtility.ReadConfig <IotHubConfig>(iotHubConfigFile); _toIotHubDataConverter = settings.GetValueOrNull("MessageConverter.IotHub") as IConverter <TExchangeMsg, object>; _alarmMessageExchange = settings.GetValueOrNull("MessageExchange.Messaging") as IMessageExchange <TExchangeMsg>; _logger = settings.GetValueOrNull("Logger") as ILogger; _deviceClienPool = new DeviceClientPool(); _deviceClienPool.Initialize(_iotHubConfig.IotHubHostName, _iotHubConfig.AlarmDevicePool); }
public void Initialize(Dictionary <string, object> settings) { //ConfigureSettings(settings); string[] fieldNames = new string[] { "IotHubConfigFile", "Logger", "CmdExecutor", "CmdConverter" }; FieldValidator.CheckMissingFields(settings, fieldNames); string iotHubConfigFile = settings.GetValueOrNull("IotHubConfigFile") as string; _iotHubConfig = ConfigUtility.ReadConfig <IotHubConfig>(iotHubConfigFile); _cmdConverter = settings.GetValueOrNull("CmdConverter") as IConverter <string, TCmd>; _cmdExecutor = settings.GetValueOrNull("CmdExecutor") as ICommandExecutor <TCmd>; _logger = settings.GetValueOrNull("Logger") as ILogger; _deviceClientPool = new DeviceClientPool(); _deviceClientPool.Initialize(_iotHubConfig.IotHubHostName, _iotHubConfig.CommandDevicePool); }
/// <summary> /// settings requires the following fields: /// settings.EventHubConfig = "EventHubConfig.json", /// settings.OpcServerConfig = "OpcServerConfig.json", /// settings.OpcNodeSubscriptionConfig = "OpcNodeSubscriptionConfig.json" /// For the format of the json files, check the SDK documentation /// </summary> /// <param name="settings"></param> public void Initialize(Dictionary <string, object> settings) { //ConfigureSettings(settings); //add new entry to fieldNames if a mandatory field is sent through settings string[] fieldNames = new string[] { "OpcServerConfigFile", "OpcTagConfigFile", "Logger", "OpcTagConverter", "TagStateManager" }; //validates missing fields and throws ValidationException in case of errors. Let us not catch it here so as to avoid //passing it through multiple layers FieldValidator.CheckMissingFields(settings, fieldNames); //convert json fields into configuraiton dictionaries string opcServerConfigFile = settings.GetValueOrNull <string, object>("OpcServerConfigFile") as string; _opcServerConfig = ConfigUtility.ReadConfig <Dictionary <string, string> >(opcServerConfigFile); string opcTagConfigFile = settings.GetValueOrNull <string, object>("OpcTagConfigFile") as string; _opcNodeSubscriptionConfig = ConfigUtility.ReadConfig <List <OpcNode> >(opcTagConfigFile); _tagStateManager = settings.GetValueOrNull <string, object>("TagStateManager") as TagStateManager; _opcTagConverter = settings.GetValueOrNull <string, object>("OpcTagConverter") as IConverter <object, Tag>; _logger = settings.GetValueOrNull <string, object>("Logger") as ILogger; }