void IGXDLMSBase.Load(GXXmlReader reader)
        {
            MBusPortReference = reader.ReadElementContentAsString("MBusPortReference");
            CaptureDefinition.Clear();
            if (reader.IsStartElement("CaptureDefinition", true))
            {
                while (reader.IsStartElement("Item", true))
                {
                    string d = reader.ReadElementContentAsString("Data");
                    string v = reader.ReadElementContentAsString("Value");
                    CaptureDefinition.Add(new KeyValuePair <string, string>(d, v));
                }
                reader.ReadEndElement("CaptureDefinition");
            }
            CapturePeriod        = (UInt16)reader.ReadElementContentAsInt("CapturePeriod");
            PrimaryAddress       = reader.ReadElementContentAsInt("PrimaryAddress");
            IdentificationNumber = (UInt16)reader.ReadElementContentAsInt("IdentificationNumber");
            ManufacturerID       = (UInt16)reader.ReadElementContentAsInt("ManufacturerID");
            DataHeaderVersion    = reader.ReadElementContentAsInt("DataHeaderVersion");
            DeviceType           = reader.ReadElementContentAsInt("DeviceType");
            AccessNumber         = reader.ReadElementContentAsInt("AccessNumber");

            Status = reader.ReadElementContentAsInt("Status");
            Alarm  = reader.ReadElementContentAsInt("Alarm");
            if (Version > 0)
            {
                Configuration       = (UInt16)reader.ReadElementContentAsInt("Configuration");
                EncryptionKeyStatus = (MBusEncryptionKeyStatus)reader.ReadElementContentAsInt("EncryptionKeyStatus");
            }
        }
Ejemplo n.º 2
0
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         if (e.Value is string)
         {
             LogicalName = e.Value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 2)
     {
         if (e.Value is string)
         {
             MBusPortReference = e.Value.ToString();
         }
         else
         {
             MBusPortReference = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 3)
     {
         CaptureDefinition.Clear();
         if (e.Value != null)
         {
             foreach (object[] it in (object[])e.Value)
             {
                 CaptureDefinition.Add(new KeyValuePair <string, string>(GXDLMSClient.ChangeType((byte[])it[0], DataType.OctetString).ToString(),
                                                                         GXDLMSClient.ChangeType((byte[])it[1], DataType.OctetString).ToString()));
             }
         }
     }
     else if (e.Index == 4)
     {
         CapturePeriod = Convert.ToUInt32(e.Value);
     }
     else if (e.Index == 5)
     {
         PrimaryAddress = Convert.ToByte(e.Value);
     }
     else if (e.Index == 6)
     {
         IdentificationNumber = Convert.ToUInt32(e.Value);
     }
     else if (e.Index == 7)
     {
         ManufacturerID = Convert.ToUInt16(e.Value);
     }
     else if (e.Index == 8)
     {
         DataHeaderVersion = Convert.ToByte(e.Value);
     }
     else if (e.Index == 9)
     {
         DeviceType = Convert.ToByte(e.Value);
     }
     else if (e.Index == 10)
     {
         AccessNumber = Convert.ToByte(e.Value);
     }
     else if (e.Index == 11)
     {
         Status = Convert.ToByte(e.Value);
     }
     else if (e.Index == 12)
     {
         Alarm = Convert.ToByte(e.Value);
     }
     else if (Version > 0)
     {
         if (e.Index == 13)
         {
             Configuration = Convert.ToUInt16(e.Value);
         }
         else if (e.Index == 14)
         {
             EncryptionKeyStatus = (MBusEncryptionKeyStatus)Convert.ToInt32(e.Value);
         }
         else
         {
             e.Error = ErrorCode.ReadWriteDenied;
         }
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
Ejemplo n.º 3
0
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         if (e.Value is string)
         {
             LogicalName = e.Value.ToString();
         }
         else
         {
             LogicalName = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 2)
     {
         if (e.Value is string)
         {
             MBusPortReference = e.Value.ToString();
         }
         else
         {
             MBusPortReference = GXDLMSClient.ChangeType((byte[])e.Value, DataType.OctetString).ToString();
         }
     }
     else if (e.Index == 3)
     {
         CaptureDefinition.Clear();
         if (e.Value != null)
         {
             foreach (object[] it in (object[])e.Value)
             {
                 CaptureDefinition.Add(new KeyValuePair<string, string>(GXDLMSClient.ChangeType((byte[])it[0], DataType.OctetString).ToString(),
                                       GXDLMSClient.ChangeType((byte[])it[1], DataType.OctetString).ToString()));
             }
         }
     }
     else if (e.Index == 4)
     {
         CapturePeriod = Convert.ToUInt32(e.Value);
     }
     else if (e.Index == 5)
     {
         PrimaryAddress = Convert.ToByte(e.Value);
     }
     else if (e.Index == 6)
     {
         IdentificationNumber = Convert.ToUInt32(e.Value);
     }
     else if (e.Index == 7)
     {
         ManufacturerID = Convert.ToUInt16(e.Value);
     }
     else if (e.Index == 8)
     {
         DataHeaderVersion = Convert.ToByte(e.Value);
     }
     else if (e.Index == 9)
     {
         DeviceType = Convert.ToByte(e.Value);
     }
     else if (e.Index == 10)
     {
         AccessNumber = Convert.ToByte(e.Value);
     }
     else if (e.Index == 11)
     {
         Status = Convert.ToByte(e.Value);
     }
     else if (e.Index == 12)
     {
         Alarm = Convert.ToByte(e.Value);
     }
     else if (Version > 0)
     {
         if (e.Index == 13)
         {
             Configuration = Convert.ToUInt16(e.Value);
         }
         else if (e.Index == 14)
         {
             EncryptionKeyStatus = (MBusEncryptionKeyStatus)Convert.ToInt32(e.Value);
         }
         else
         {
             e.Error = ErrorCode.ReadWriteDenied;
         }
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }