/// <summary> /// Get OBIS code description. /// </summary> /// <param name="logicalName">Logical name (OBIS code).</param> /// <param name="type">Object type.</param> /// <param name="description">Description filter.</param> /// <returns>Array of descriptions that match given OBIS code.</returns> public String[] GetDescription(String logicalName, ObjectType type, String description) { lock (codes) { if (codes.Count == 0) { ReadStandardObisInfo(Standard, codes); } } List <String> list = new List <String>(); bool all = string.IsNullOrEmpty(logicalName); foreach (GXStandardObisCode it in codes.Find(logicalName, type)) { if (!string.IsNullOrEmpty(description) && !it.Description.ToLower().Contains(description.ToLower())) { continue; } if (all) { list.Add("A=" + it.OBIS[0] + ", B=" + it.OBIS[1] + ", C=" + it.OBIS[2] + ", D=" + it.OBIS[3] + ", E=" + it.OBIS[4] + ", F=" + it.OBIS[5] + "\r\n" + it.Description); } else { list.Add(it.Description); } } return(list.ToArray()); }
private static void UpdateOBISCodeInfo(GXStandardObisCodeCollection codes, GXDLMSObject it, Standard standard) { GXStandardObisCode[] list = codes.Find(it.LogicalName, it.ObjectType, standard); GXStandardObisCode code = list[0]; if (string.IsNullOrEmpty(it.Description)) { it.Description = code.Description; if (standard == Standard.SaudiArabia) { it.Description = it.Description.Replace("U(", "V("); } } //Update data type from DLMecS standard. if (standard != Standard.DLMS) { GXStandardObisCode d = list[list.Length - 1]; code.DataType = d.DataType; } //If string is used string datatype = code.DataType; if (datatype == null) { datatype = ""; } if (string.IsNullOrEmpty(code.UIDataType)) { if (datatype.Contains("10")) { code.UIDataType = "10"; } //If date time is used. else if (datatype.Contains("25") || datatype.Contains("26")) { code.UIDataType = "25"; } //Time stamps of the billing periods objects (first scheme if there are two) else if (datatype.Contains("9")) { if ((GXStandardObisCodeCollection.EqualsMask("0.0-64.96.7.10-14.255", it.LogicalName) || //Time stamps of the billing periods objects (second scheme) GXStandardObisCodeCollection.EqualsMask("0.0-64.0.1.5.0-99,255", it.LogicalName) || //Time of power failure GXStandardObisCodeCollection.EqualsMask("0.0-64.0.1.2.0-99,255", it.LogicalName) || //Time stamps of the billing periods objects (first scheme if there are two) GXStandardObisCodeCollection.EqualsMask("1.0-64.0.1.2.0-99,255", it.LogicalName) || //Time stamps of the billing periods objects (second scheme) GXStandardObisCodeCollection.EqualsMask("1.0-64.0.1.5.0-99,255", it.LogicalName) || //Time expired since last end of billing period GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.0.255", it.LogicalName) || //Time of last reset GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.6.255", it.LogicalName) || //Date of last reset GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.7.255", it.LogicalName) || //Time expired since last end of billing period (Second billing period scheme) GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.13.255", it.LogicalName) || //Time of last reset (Second billing period scheme) GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.14.255", it.LogicalName) || //Date of last reset (Second billing period scheme) GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.15.255", it.LogicalName))) { code.UIDataType = "25"; } //Local time else if (GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.1.255", it.LogicalName)) { code.UIDataType = "27"; } //Local date else if (GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.2.255", it.LogicalName)) { code.UIDataType = "26"; } //Active firmware identifier else if (GXStandardObisCodeCollection.EqualsMask("1.0.0.2.0.255", it.LogicalName)) { code.UIDataType = "10"; } } //Unix time else if (it.ObjectType == ObjectType.Data && GXStandardObisCodeCollection.EqualsMask("0.0.1.1.0.255", it.LogicalName)) { code.UIDataType = "25"; } } if (code.DataType != "*" && !string.IsNullOrEmpty(code.DataType) && !code.DataType.Contains(",")) { DataType type = (DataType)int.Parse(code.DataType); switch (it.ObjectType) { case ObjectType.Data: case ObjectType.Register: case ObjectType.RegisterActivation: case ObjectType.ExtendedRegister: it.SetDataType(2, type); break; default: break; } } if (!string.IsNullOrEmpty(code.UIDataType)) { DataType uiType = (DataType)int.Parse(code.UIDataType); switch (it.ObjectType) { case ObjectType.Data: case ObjectType.Register: case ObjectType.RegisterActivation: case ObjectType.ExtendedRegister: it.SetUIDataType(2, uiType); break; default: break; } } }
private static void UpdateOBISCodeInfo(GXStandardObisCodeCollection codes, GXDLMSObject it) { if (!string.IsNullOrEmpty(it.Description)) { return; } GXStandardObisCode code = codes.Find(it.LogicalName, it.ObjectType)[0]; it.Description = code.Description; //If string is used if (code.DataType.Contains("10")) { code.UIDataType = "10"; } //If date time is used. else if (code.DataType.Contains("25") || code.DataType.Contains("26")) { code.UIDataType = code.DataType = "25"; } //Time stamps of the billing periods objects (first scheme if there are two) else if (code.DataType.Contains("9")) { if ((GXStandardObisCodeCollection.EqualsMask("0.0-64.96.7.10-14.255", it.LogicalName) || //Time stamps of the billing periods objects (second scheme) GXStandardObisCodeCollection.EqualsMask("0.0-64.0.1.5.0-99,255", it.LogicalName) || //Time of power failure GXStandardObisCodeCollection.EqualsMask("0.0-64.0.1.2.0-99,255", it.LogicalName) || //Time stamps of the billing periods objects (first scheme if there are two) GXStandardObisCodeCollection.EqualsMask("1.0-64.0.1.2.0-99,255", it.LogicalName) || //Time stamps of the billing periods objects (second scheme) GXStandardObisCodeCollection.EqualsMask("1.0-64.0.1.5.0-99,255", it.LogicalName) || //Time expired since last end of billing period GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.0.255", it.LogicalName) || //Time of last reset GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.6.255", it.LogicalName) || //Date of last reset GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.7.255", it.LogicalName) || //Time expired since last end of billing period (Second billing period scheme) GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.13.255", it.LogicalName) || //Time of last reset (Second billing period scheme) GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.14.255", it.LogicalName) || //Date of last reset (Second billing period scheme) GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.15.255", it.LogicalName))) { code.UIDataType = "25"; } //Local time else if (GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.1.255", it.LogicalName)) { code.UIDataType = "27"; } //Local date else if (GXStandardObisCodeCollection.EqualsMask("1.0-64.0.9.2.255", it.LogicalName)) { code.UIDataType = "26"; } //Active firmware identifier else if (GXStandardObisCodeCollection.EqualsMask("1.0.0.2.0.255", it.LogicalName)) { code.UIDataType = "10"; } } if (code.DataType != "*" && code.DataType != string.Empty && !code.DataType.Contains(",")) { DataType type = (DataType)int.Parse(code.DataType); switch (it.ObjectType) { case ObjectType.Data: case ObjectType.Register: case ObjectType.RegisterActivation: case ObjectType.ExtendedRegister: it.SetDataType(2, type); break; default: break; } } if (!string.IsNullOrEmpty(code.UIDataType)) { DataType uiType = (DataType)int.Parse(code.UIDataType); switch (it.ObjectType) { case ObjectType.Data: case ObjectType.Register: case ObjectType.RegisterActivation: case ObjectType.ExtendedRegister: it.SetUIDataType(2, uiType); break; default: break; } } }