/// <summary> /// Builds the MQTT device configuration. /// </summary> private static void BuildMqttDeviceConfig(DeviceConfigEntry entry, ControlModel controlModel) { // subscription to control value entry.MqttDeviceConfig.Subscriptions.Add(new SubscriptionConfig { Topic = controlModel.Topic, DisplayName = controlModel.Meta.Name, TagCode = controlModel.Code }); // subscription to control error entry.MqttDeviceConfig.Subscriptions.Add(new SubscriptionConfig { Topic = controlModel.Topic + "/meta/error", DisplayName = controlModel.Meta.Name + " Error", TagCode = controlModel.Code + "_error", JsEnabled = true, JsFileName = "wb_error.js" }); // command if (!controlModel.Meta.ReadOnly) { entry.MqttDeviceConfig.Commands.Add(new CommandConfig { Topic = controlModel.Topic + "/on", DisplayName = controlModel.Meta.Name, CmdCode = controlModel.Code }); } }
/// <summary> /// Builds the channels. /// </summary> private void BuildCnls(DeviceConfigEntry entry, ControlModel controlModel, ChannelNumberingOptions options, int?objNum, int deviceNum, ref int cnlNum) { string namePrefix = options.PrependDeviceName ? entry.DeviceEntity.Name + " - " : ""; ControlMeta controlMeta = controlModel.Meta; int? formatID = GetFormatID(controlMeta); int? quantityID = GetQuantityID(controlMeta); int? unitID = GetUnitID(controlMeta); // control value entry.Cnls.Add(new Cnl { CnlNum = cnlNum++, Active = true, Name = namePrefix + controlMeta.Name + " Last", CnlTypeID = CnlTypeID.Input, ObjNum = objNum, DeviceNum = deviceNum, TagCode = controlModel.Code, FormatID = formatID, QuantityID = quantityID, UnitID = unitID }); // control error entry.Cnls.Add(new Cnl { CnlNum = cnlNum++, Active = true, Name = namePrefix + controlMeta.Name + " Error", CnlTypeID = CnlTypeID.Input, ObjNum = objNum, DeviceNum = deviceNum, TagCode = controlModel.Code + "_error" }); // calculated channel entry.Cnls.Add(new Cnl { CnlNum = cnlNum++, Active = true, Name = namePrefix + controlMeta.Name, CnlTypeID = controlMeta.ReadOnly ? CnlTypeID.Calculated : CnlTypeID.CalculatedOutput, ObjNum = objNum, DeviceNum = deviceNum, TagCode = controlModel.Code, FormulaEnabled = true, InFormula = "WB_CalcControl()", FormatID = formatID, QuantityID = quantityID, UnitID = unitID, EventMask = ControlEventMask }); }
/// <summary> /// Builds the MQTT device configuration. /// </summary> private static void BuildMqttDeviceConfig(DeviceConfigEntry entry, DeviceModel deviceModel) { // subscription to device error entry.MqttDeviceConfig.Subscriptions.Add(new SubscriptionConfig { Topic = deviceModel.Topic + "/meta/error", DisplayName = deviceModel.Meta.Name + " Error", TagCode = deviceModel.Code + "_error", JsEnabled = true, JsFileName = "wb_error.js" }); }
/// <summary> /// Builds the channels. /// </summary> private static void BuildCnls(DeviceConfigEntry entry, DeviceModel deviceModel, int?objNum, int deviceNum, ref int cnlNum) { // device error entry.Cnls.Add(new Cnl { CnlNum = cnlNum++, Active = true, Name = deviceModel.Meta.Name + " Error", CnlTypeID = CnlTypeID.Input, ObjNum = objNum, DeviceNum = deviceNum, TagCode = deviceModel.Code + "_error" }); }