public object ReadElementContentAsObject(string name, object defaultValue, GXDLMSObject obj, byte index) { GetNext(); if (string.Compare(name, reader.Name, true) == 0) { object ret; DataType uiType; DataType dt = (DataType)Enum.Parse(typeof(DataType), reader.GetAttribute(0)); if (obj != null) { obj.SetDataType(index, dt); } if (reader.AttributeCount > 1) { uiType = (DataType)Enum.Parse(typeof(DataType), reader.GetAttribute(1)); } else { uiType = dt; } if (obj != null && obj.GetUIDataType(index) == DataType.None) { obj.SetUIDataType(index, uiType); } if (dt == DataType.Array || dt == DataType.Structure) { reader.Read(); GetNext(); ret = ReadArray(); ReadEndElement(name); return(ret); } else { string str = reader.ReadElementContentAsString(); ret = GXDLMSConverter.ChangeType(str, uiType, CultureInfo.InvariantCulture); } while (!(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement)) { reader.Read(); } return(ret); } return(defaultValue); }
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; } } }