public async Task <SessionsHandle> CreateHandleFromConfiguration(ModuleConfig config)
        {
            SessionsHandle sessionsHandle = null;

            foreach (var config_pair in config.SlaveConfigs)
            {
                ModbusSlaveConfig slaveConfig = config_pair.Value;

                switch (slaveConfig.GetConnectionType())
                {
                case ConnectionType.ModbusTCP:
                {
                    if (sessionsHandle == null)
                    {
                        sessionsHandle = new SessionsHandle();
                    }

                    ModbusSlaveSession slave = new ModbusTCPSlaveSession(slaveConfig);
                    await slave.InitSession();

                    sessionsHandle.ModbusSessionList.Add(slave);
                    break;
                }

                case ConnectionType.ModbusRTU:
                {
                    if (sessionsHandle == null)
                    {
                        sessionsHandle = new SessionsHandle();
                    }

                    ModbusSlaveSession slave = new ModbusRTUSlaveSession(slaveConfig);
                    await slave.InitSession();

                    sessionsHandle.ModbusSessionList.Add(slave);
                    break;
                }

                case ConnectionType.ModbusASCII:
                {
                    break;
                }

                case ConnectionType.Unknown:
                {
                    break;
                }
                }
            }
            return(sessionsHandle);
        }
 public ModuleTwinProperties(int?publishInterval, ModuleConfig moduleConfig)
 {
     this.PublishInterval = publishInterval;
     this.SlaveConfigs    = moduleConfig?.SlaveConfigs.ToDictionary(pair => pair.Key, pair => pair.Value.AsBase());
 }