//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)}"); }
public override async Task ReadAllValuesAsync(ComfoBoxClient client) { foreach (var child in Children) { await child.ReadAllValuesAsync(client); } }
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"); } }
public override async Task ReadAllValuesAsync(ComfoBoxClient client) { await Item.ReadValueAsync(client); }
public abstract Task ReadAllValuesAsync(ComfoBoxClient client);
public async Task ReadAsync(ComfoBoxClient comfoBoxClient) { await ItemValue.ReadValueAsync(comfoBoxClient); }