/// <summary> /// Define Output section of Equipment Type xml template (digital variables) /// </summary> /// <param name="prefix"></param> /// <param name="suffix"></param> /// <param name="outputType"></param> /// <param name="comment"></param> /// <returns></returns> public static templateOutput GetEquipmentType_VarDiscreteOutputs(EquipmentTypeOutputParam fieldParam) { templateOutput templateOutput = new templateOutput { name = "Var." + fieldParam.Suffix.TrimStart(new char[] { ',', '_', '.' }), file = "variable.dbf", filter = @"'{equipment.type}={type.name}'" }; var tagaddressvalue = "{equipment.BaseAddr[" + fieldParam.BaseAddressParam.ToString() + "]} + " + fieldParam.AddressOffset.ToString(); var templateOutputCalculator = new templateOutputCalculator { name = "TagAddress", Value = tagaddressvalue }; var outputFields = new List <templateOutputField> { new templateOutputField { name = "name", key = true, Value = string.Format("{0}_{{equipment.tagprefix}}{1}", fieldParam.Prefix, fieldParam.Suffix), keySpecified = true }, new templateOutputField { name = "type", Value = fieldParam.DataType }, new templateOutputField { name = "unit", Value = fieldParam.DeviceIO }, new templateOutputField { name = "comment", Value = "{equipment.tagprefix} " + fieldParam.Comment }, new templateOutputField { name = "cluster", key = true, Value = fieldParam.Cluster, keySpecified = true }, new templateOutputField { name = "equip", Value = fieldParam.Equipment }, new templateOutputField { name = "addr", Value = "%M{TagAddress}" }, new templateOutputField { name = "item", Value = CapsFirstLetter(fieldParam.Suffix.TrimStart(new char[] { ',', '_', '.' }).ToLower()) }, new templateOutputField { name = "taggenlink", load = true, Value = fieldParam.TagGenLink, loadSpecified = true }, new templateOutputField { name = "linked", Value = "1" }, new templateOutputField { name = "editcode", Value = editcode }, }; templateOutput.calculator = templateOutputCalculator; templateOutput.field = outputFields.ToArray(); return(templateOutput); }
/// <summary> /// Define Output section of Equipment Type xml template (analog variables) /// </summary> /// <param name="prefix"></param> /// <param name="suffix"></param> /// <param name="outputType"></param> /// <param name="comment"></param> /// <returns></returns> public static templateOutput GetEquipmentType_VarAnalogOutputs(EquipmentTypeOutputParam fieldParam) { templateOutput templateOutput = new templateOutput { name = "Var." + fieldParam.Suffix.TrimStart(new char[] { ',', '_', '.' }), file = "variable.dbf", filter = @"'{equipment.type}={type.name}'" }; if (fieldParam.DeviceIO.Contains("IODEVICE") && fieldParam.AddressOffset >= 0) { var tagaddressvalue = "{equipment.BaseAddr[" + fieldParam.BaseAddressParam.ToString() + "]} + " + fieldParam.AddressOffset.ToString(); var templateOutputCalculator = new templateOutputCalculator { name = "TagAddress", Value = tagaddressvalue }; var outputFields = new List <templateOutputField> { new templateOutputField { name = "name", key = true, Value = string.Format("{0}_{{equipment.tagprefix}}{1}", fieldParam.Prefix, fieldParam.Suffix), keySpecified = true }, new templateOutputField { name = "type", Value = fieldParam.DataType }, new templateOutputField { name = "unit", Value = fieldParam.DeviceIO }, new templateOutputField { name = "eng_zero", Value = fieldParam.EngZero }, new templateOutputField { name = "eng_full", Value = fieldParam.EngFull }, new templateOutputField { name = "comment", Value = "{equipment.tagprefix} " + fieldParam.Comment }, new templateOutputField { name = "cluster", key = true, Value = fieldParam.Cluster, keySpecified = true }, new templateOutputField { name = "equip", Value = fieldParam.Equipment }, new templateOutputField { name = "addr", Value = "%MW{TagAddress}" }, new templateOutputField { name = "raw_zero", Value = fieldParam.RawZero }, new templateOutputField { name = "raw_full", Value = fieldParam.RawFull }, new templateOutputField { name = "eng_units", Value = fieldParam.Units }, new templateOutputField { name = "format", Value = fieldParam.Format }, new templateOutputField { name = "item", Value = CapsFirstLetter(fieldParam.Suffix.TrimStart(new char[] { ',', '_', '.' }).ToLower()) }, new templateOutputField { name = "taggenlink", load = true, Value = fieldParam.TagGenLink, loadSpecified = true }, new templateOutputField { name = "linked", Value = "1" }, new templateOutputField { name = "editcode", Value = editcode }, }; templateOutput.calculator = templateOutputCalculator; templateOutput.field = outputFields.ToArray(); } else //without address calculation { var outputFields = new List <templateOutputField> { new templateOutputField { name = "name", key = true, Value = string.Format("{0}_{{equipment.tagprefix}}{1}", fieldParam.Prefix, fieldParam.Suffix), keySpecified = true }, new templateOutputField { name = "type", Value = fieldParam.DataType }, new templateOutputField { name = "unit", Value = fieldParam.DeviceIO }, new templateOutputField { name = "comment", Value = "{equipment.tagprefix} " + fieldParam.Comment }, new templateOutputField { name = "cluster", key = true, Value = fieldParam.Cluster, keySpecified = true }, new templateOutputField { name = "equip", Value = fieldParam.Equipment }, new templateOutputField { name = "eng_units", Value = fieldParam.Units }, new templateOutputField { name = "format", Value = fieldParam.Format }, new templateOutputField { name = "item", Value = CapsFirstLetter(fieldParam.Suffix.TrimStart(new char[] { ',', '_', '.' }).ToLower()) }, new templateOutputField { name = "taggenlink", load = true, Value = fieldParam.TagGenLink, loadSpecified = true }, new templateOutputField { name = "linked", Value = "1" }, new templateOutputField { name = "editcode", Value = editcode }, }; templateOutput.field = outputFields.ToArray(); } return(templateOutput); }