private void HandleNamedPropertiesResponse(clsOmniLinkMessageQueueItem M, byte[] B, bool Timeout) { if (Timeout) { return; } // does it look like a valid response if ((B.Length > 3) && (B[0] == 0x21)) { switch ((enuOmniLink2MessageType)B[2]) { case enuOmniLink2MessageType.EOD: nameWait.Set(); break; case enuOmniLink2MessageType.Properties: clsOL2MsgProperties MSG = new clsOL2MsgProperties(Controller.Connection, B); switch (MSG.ObjectType) { case enuObjectType.Area: Controller.Areas.CopyProperties(MSG); break; case enuObjectType.Zone: Controller.Zones.CopyProperties(MSG); if (Controller.Zones[MSG.ObjectNumber].IsTemperatureZone() || Controller.Zones[MSG.ObjectNumber].IsHumidityZone()) { Controller.Connection.Send(new clsOL2MsgRequestExtendedStatus(Controller.Connection, enuObjectType.Auxillary, MSG.ObjectNumber, MSG.ObjectNumber), HandleRequestAuxillaryStatus); } break; case enuObjectType.Thermostat: Controller.Thermostats.CopyProperties(MSG); if (!tstats.ContainsKey(MSG.ObjectNumber)) { tstats.Add(MSG.ObjectNumber, DateTime.MinValue); } else { tstats[MSG.ObjectNumber] = DateTime.MinValue; } Controller.Connection.Send(new clsOL2MsgRequestExtendedStatus(Controller.Connection, enuObjectType.Thermostat, MSG.ObjectNumber, MSG.ObjectNumber), HandleRequestThermostatStatus); log.Debug("Added thermostat to watch list " + Controller.Thermostats[MSG.ObjectNumber].Name); break; case enuObjectType.Unit: Controller.Units.CopyProperties(MSG); break; case enuObjectType.Message: Controller.Messages.CopyProperties(MSG); break; case enuObjectType.Button: Controller.Buttons.CopyProperties(MSG); break; default: break; } GetNextNamed(MSG.ObjectType, MSG.ObjectNumber); break; default: break; } } }
private void HandleNamedPropertiesResponse(clsOmniLinkMessageQueueItem M, byte[] B, bool Timeout) { if (Timeout) { return; } // does it look like a valid response if ((B.Length > 3) && (B[0] == 0x21)) { switch ((enuOmniLink2MessageType)B[2]) { case enuOmniLink2MessageType.EOD: nameWait.Set(); break; case enuOmniLink2MessageType.SystemFormats: var systemFormats = new clsOL2MsgSystemFormats(Controller.Connection, B); Controller.DateFormat = systemFormats.Date; Controller.TimeFormat = systemFormats.Time; Controller.TempFormat = systemFormats.Temp; using (LogContext.PushProperty("Telemetry", "TemperatureFormat")) log.Debug("Temperature format is {TemperatureFormat}", (Controller.TempFormat == enuTempFormat.Fahrenheit ? "Fahrenheit" : "Celsius")); nameWait.Set(); break; case enuOmniLink2MessageType.SystemTroubles: var systemTroubles = new clsOL2MsgSystemTroubles(Controller.Connection, B); TroublePhone = systemTroubles.Contains(enuTroubles.PhoneLine); TroubleAC = systemTroubles.Contains(enuTroubles.AC); TroubleBattery = systemTroubles.Contains(enuTroubles.BatteryLow); TroubleDCM = systemTroubles.Contains(enuTroubles.DCM); nameWait.Set(); break; case enuOmniLink2MessageType.Properties: clsOL2MsgProperties MSG = new clsOL2MsgProperties(Controller.Connection, B); switch (MSG.ObjectType) { case enuObjectType.Area: Controller.Areas.CopyProperties(MSG); break; case enuObjectType.Zone: Controller.Zones.CopyProperties(MSG); if (Controller.Zones[MSG.ObjectNumber].IsTemperatureZone() || Controller.Zones[MSG.ObjectNumber].IsHumidityZone()) { Controller.Connection.Send(new clsOL2MsgRequestExtendedStatus(Controller.Connection, enuObjectType.Auxillary, MSG.ObjectNumber, MSG.ObjectNumber), HandleRequestAuxillaryStatus); } break; case enuObjectType.Thermostat: Controller.Thermostats.CopyProperties(MSG); if (!tstats.ContainsKey(MSG.ObjectNumber)) { tstats.Add(MSG.ObjectNumber, DateTime.MinValue); } else { tstats[MSG.ObjectNumber] = DateTime.MinValue; } Controller.Connection.Send(new clsOL2MsgRequestExtendedStatus(Controller.Connection, enuObjectType.Thermostat, MSG.ObjectNumber, MSG.ObjectNumber), HandleRequestThermostatStatus); log.Debug("Added thermostat to watch list {thermostatName}", Controller.Thermostats[MSG.ObjectNumber].Name); break; case enuObjectType.Unit: Controller.Units.CopyProperties(MSG); break; case enuObjectType.Message: Controller.Messages.CopyProperties(MSG); break; case enuObjectType.Button: Controller.Buttons.CopyProperties(MSG); break; default: break; } GetNextNamed(MSG.ObjectType, MSG.ObjectNumber); break; default: break; } } }