コード例 #1
0
        //public ComfoBoxMqttClient(string brokerHostName, int brokerPort, ComfoBoxClient comfoBoxClient)
        //{
        //    _comfoBoxClient = comfoBoxClient;
        //    var client = new MqttClient(brokerHostName, brokerPort, false, MqttSslProtocols.None, null, null);
        //    client.Connect($"ComfoBox{DateTime.Now.Ticks}");
        //    _mqttClients = new[] { client };
        //}

        //public ComfoBoxMqttClient(string brokerHostName, ComfoBoxClient comfoBoxClient) 
        //{
        //    _comfoBoxClient = comfoBoxClient;
        //    var client = new MqttClient(brokerHostName);
        //    client.Connect($"ComfoBox{DateTime.Now.Ticks}");
        //    _mqttClients = new[] { client };
        //}

        public ComfoBoxMqttClient(string[] brokerHostNames, ComfoBoxClient comfoBoxClient)
        {
            _comfoBoxClient = comfoBoxClient;

            _mqttClients = brokerHostNames.Select(i => new MqttClient(i)).ToArray();
            Logger.Info($"MQTT Brokers: {string.Join(", ", brokerHostNames)}");
        }
コード例 #2
0
ファイル: GroupViewModel.cs プロジェクト: RF77/comfobox-mqtt
 public override async Task ReadAllValuesAsync(ComfoBoxClient client)
 {
     foreach (var child in Children)
     {
         await child.ReadAllValuesAsync(client);
     }
 }
コード例 #3
0
ファイル: MainViewModel.cs プロジェクト: RF77/comfobox-mqtt
 public async void Connect()
 {
     try
     {
         if (_client != null)
         {
             //Disconnect
             _client.Stop();
             _client = null;
             ConnectButtonText = "Connect";
             CurrentState = "Disconnected";
             Logger.Info("Disconnected");
         }
         else
         {
             //Connect
             _client = new ComfoBoxClient(Port, Baudrate, Settings.Default.BacnetClientId);
             Logger.Info($"Connecting to Port={Port} with Baudrate={Baudrate}");
             ConnectButtonText = "Disconnect";
             CurrentState = "Connecting...";
             await _client.StartAsync();
             Logger.Info("Connected! Reading All Values...");
             CurrentState = "Connected! Reading All Values...";
             await ReadAllValuesAsync();
             Logger.Info("Connected! All values read.");
             CurrentState = "Connected! All values read.";
         }
     }
     catch (Exception ex)
     {
         Logger.Error($"Connect() has thrown an exception: {ex.Message}");
         MessageBox.Show(ex.Message, "Error");
     }
 }
コード例 #4
0
ファイル: ItemViewModel.cs プロジェクト: RF77/comfobox-mqtt
 public override async Task ReadAllValuesAsync(ComfoBoxClient client)
 {
     await Item.ReadValueAsync(client);
 }
コード例 #5
0
 public abstract Task ReadAllValuesAsync(ComfoBoxClient client);
コード例 #6
0
ファイル: MqttItem.cs プロジェクト: RF77/comfobox-mqtt
 public async Task ReadAsync(ComfoBoxClient comfoBoxClient)
 {
     await ItemValue.ReadValueAsync(comfoBoxClient);
 }