void IGXDLMSBase.Load(GXXmlReader reader)
 {
     Buffer = GXCommon.HexToBytes(reader.ReadElementContentAsString("Buffer"));
     CaptureObjects.Clear();
     if (reader.IsStartElement("CaptureObjects", true))
     {
         while (reader.IsStartElement("Item", true))
         {
             ObjectType          ot  = (ObjectType)reader.ReadElementContentAsInt("ObjectType");
             string              ln  = reader.ReadElementContentAsString("LN");
             int                 ai  = reader.ReadElementContentAsInt("Attribute");
             int                 di  = reader.ReadElementContentAsInt("Data");
             GXDLMSCaptureObject co  = new GXDLMSCaptureObject(ai, di);
             GXDLMSObject        obj = reader.Objects.FindByLN(ot, ln);
             if (obj == null)
             {
                 obj             = GXDLMSClient.CreateObject(ot);
                 obj.LogicalName = ln;
             }
             CaptureObjects.Add(new GXKeyValuePair <GXDLMSObject, GXDLMSCaptureObject>(obj, co));
         }
         reader.ReadEndElement("CaptureObjects");
     }
     TemplateId          = (byte)reader.ReadElementContentAsInt("TemplateId");
     TemplateDescription = GXCommon.HexToBytes(reader.ReadElementContentAsString("TemplateDescription"));
     CaptureMethod       = (CaptureMethod)reader.ReadElementContentAsInt("CaptureMethod");
 }
 void IGXDLMSBase.Load(GXXmlReader reader)
 {
     Buffer.Clear();
     if (reader.IsStartElement("Buffer", true))
     {
         while (reader.IsStartElement("Row", true))
         {
             List <object> row = new List <object>();
             while (reader.IsStartElement("Cell", false))
             {
                 row.Add(reader.ReadElementContentAsObject("Cell", null));
             }
             Buffer.Add(row.ToArray());
         }
         reader.ReadEndElement("Buffer");
     }
     CaptureObjects.Clear();
     if (reader.IsStartElement("CaptureObjects", true))
     {
         while (reader.IsStartElement("Item", true))
         {
             ObjectType          ot  = (ObjectType)reader.ReadElementContentAsInt("ObjectType");
             string              ln  = reader.ReadElementContentAsString("LN");
             int                 ai  = reader.ReadElementContentAsInt("Attribute");
             int                 di  = reader.ReadElementContentAsInt("Data");
             GXDLMSCaptureObject co  = new GXDLMSCaptureObject(ai, di);
             GXDLMSObject        obj = reader.Objects.FindByLN(ot, ln);
             if (obj == null)
             {
                 obj             = GXDLMSClient.CreateObject(ot);
                 obj.LogicalName = ln;
             }
             CaptureObjects.Add(new GXKeyValuePair <GXDLMSObject, GXDLMSCaptureObject>(obj, co));
         }
         reader.ReadEndElement("CaptureObjects");
     }
     CapturePeriod = reader.ReadElementContentAsInt("CapturePeriod");
     SortMethod    = (SortMethod)reader.ReadElementContentAsInt("SortMethod");
     if (reader.IsStartElement("SortObject", true))
     {
         CapturePeriod = reader.ReadElementContentAsInt("CapturePeriod");
         ObjectType ot = (ObjectType)reader.ReadElementContentAsInt("ObjectType");
         string     ln = reader.ReadElementContentAsString("LN");
         SortObject = reader.Objects.FindByLN(ot, ln);
         reader.ReadEndElement("SortObject");
     }
     EntriesInUse   = reader.ReadElementContentAsInt("EntriesInUse");
     ProfileEntries = reader.ReadElementContentAsInt("ProfileEntries");
 }
        void IGXDLMSBase.Load(GXXmlReader reader)
        {
            PushObjectList.Clear();
            if (reader.IsStartElement("ObjectList", true))
            {
                while (reader.IsStartElement("Item", true))
                {
                    ObjectType ot = (ObjectType)reader.ReadElementContentAsInt("ObjectType");
                    string     ln = reader.ReadElementContentAsString("LN");
                    int        ai = reader.ReadElementContentAsInt("AI");
                    int        di = reader.ReadElementContentAsInt("DI");
                    reader.ReadEndElement("Item");
                    GXDLMSCaptureObject co  = new GXDLMSCaptureObject(ai, di);
                    GXDLMSObject        obj = reader.Objects.FindByLN(ot, ln);
                    if (obj == null)
                    {
                        obj             = GXDLMSClient.CreateObject(ot);
                        obj.LogicalName = ln;
                    }
                    PushObjectList.Add(new KeyValuePair <Objects.GXDLMSObject, Objects.GXDLMSCaptureObject>(obj, co));
                }
                reader.ReadEndElement("ObjectList");
            }

            Service     = (ServiceType)reader.ReadElementContentAsInt("Service");
            Destination = reader.ReadElementContentAsString("Destination");
            Message     = (MessageType)reader.ReadElementContentAsInt("Message");
            CommunicationWindow.Clear();
            if (reader.IsStartElement("CommunicationWindow", true))
            {
                while (reader.IsStartElement("Item", true))
                {
                    GXDateTime start = new GXDateTime(reader.ReadElementContentAsString("Start"), CultureInfo.InvariantCulture);
                    GXDateTime end   = new GXDateTime(reader.ReadElementContentAsString("End"), CultureInfo.InvariantCulture);
                    CommunicationWindow.Add(new KeyValuePair <DLMS.GXDateTime, DLMS.GXDateTime>(start, end));
                }
                reader.ReadEndElement("CommunicationWindow");
            }
            RandomisationStartInterval = (ushort)reader.ReadElementContentAsInt("RandomisationStartInterval");
            NumberOfRetries            = (byte)reader.ReadElementContentAsInt("NumberOfRetries");
            RepetitionDelay            = (ushort)reader.ReadElementContentAsInt("RepetitionDelay");
        }
Esempio n. 4
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, settings.UseUtc2NormalTime).ToString();
         }
     }
     else if (e.Index == 2)
     {
         PushObjectList.Clear();
         if (e.Value is Object[])
         {
             foreach (object it in e.Value as Object[])
             {
                 Object[]     tmp  = it as Object[];
                 ObjectType   type = (ObjectType)Convert.ToUInt16(tmp[0]);
                 String       ln   = GXDLMSClient.ChangeType((byte[])tmp[1], DataType.OctetString, settings.UseUtc2NormalTime).ToString();
                 GXDLMSObject obj  = settings.Objects.FindByLN(type, ln);
                 if (obj == null)
                 {
                     obj             = GXDLMSClient.CreateObject(type);
                     obj.LogicalName = ln;
                 }
                 GXDLMSCaptureObject co = new GXDLMSCaptureObject(Convert.ToInt32(tmp[2]), Convert.ToInt32(tmp[3]));
                 PushObjectList.Add(new KeyValuePair <GXDLMSObject, GXDLMSCaptureObject>(obj, co));
             }
         }
     }
     else if (e.Index == 3)
     {
         object[] tmp = e.Value as object[];
         if (tmp != null)
         {
             Service     = (ServiceType)Convert.ToInt32(tmp[0]);
             Destination = (string)GXDLMSClient.ChangeType((byte[])tmp[1], DataType.String, settings.UseUtc2NormalTime);
             Message     = (MessageType)Convert.ToInt32(tmp[2]);
         }
     }
     else if (e.Index == 4)
     {
         CommunicationWindow.Clear();
         if (e.Value is Object[])
         {
             foreach (object it in e.Value as Object[])
             {
                 Object[]   tmp   = it as Object[];
                 GXDateTime start = GXDLMSClient.ChangeType((byte[])tmp[0], DataType.DateTime, settings.UseUtc2NormalTime) as GXDateTime;
                 GXDateTime end   = GXDLMSClient.ChangeType((byte[])tmp[1], DataType.DateTime, settings.UseUtc2NormalTime) as GXDateTime;
                 CommunicationWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end));
             }
         }
     }
     else if (e.Index == 5)
     {
         RandomisationStartInterval = (UInt16)e.Value;
     }
     else if (e.Index == 6)
     {
         NumberOfRetries = (byte)e.Value;
     }
     else if (e.Index == 7)
     {
         RepetitionDelay = (UInt16)e.Value;
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
 void IGXDLMSBase.SetValue(GXDLMSSettings settings, ValueEventArgs e)
 {
     if (e.Index == 1)
     {
         LogicalName = GXCommon.ToLogicalName(e.Value);
     }
     else if (e.Index == 2)
     {
         PushObjectList.Clear();
         List <object> it;
         if (e.Value != null)
         {
             foreach (object t in (IEnumerable <object>)e.Value)
             {
                 if (t is List <object> )
                 {
                     it = (List <object>)t;
                 }
                 else
                 {
                     it = new List <object>((object[])t);
                 }
                 ObjectType   type = (ObjectType)Convert.ToUInt16(it[0]);
                 String       ln   = GXCommon.ToLogicalName(it[1]);
                 GXDLMSObject obj  = settings.Objects.FindByLN(type, ln);
                 if (obj == null)
                 {
                     obj             = GXDLMSClient.CreateObject(type);
                     obj.LogicalName = ln;
                 }
                 GXDLMSCaptureObject co = new GXDLMSCaptureObject(Convert.ToInt32(it[2]), Convert.ToInt32(it[3]));
                 PushObjectList.Add(new KeyValuePair <GXDLMSObject, GXDLMSCaptureObject>(obj, co));
             }
         }
     }
     else if (e.Index == 3)
     {
         List <object> tmp = null;
         if (e.Value is List <object> )
         {
             tmp = (List <object>)e.Value;
         }
         else
         {
             tmp = new List <object>((object[])e.Value);
         }
         if (tmp != null)
         {
             Service = (ServiceType)Convert.ToInt32(tmp[0]);
             //LN can be used with HDLC
             if (Service == ServiceType.Hdlc && ((byte[])tmp[1]).Length == 6 && ((byte[])tmp[1])[5] == 0xFF)
             {
                 Destination = GXCommon.ToLogicalName((byte[])tmp[1]);
             }
             else
             {
                 object str = GXDLMSClient.ChangeType((byte[])tmp[1], DataType.String, settings.UseUtc2NormalTime);
                 if (str is string)
                 {
                     Destination = (string)str;
                 }
                 else
                 {
                     Destination = GXCommon.ToHex((byte[])tmp[1], true);
                 }
             }
             Message = (MessageType)Convert.ToInt32(tmp[2]);
         }
     }
     else if (e.Index == 4)
     {
         CommunicationWindow.Clear();
         if (e.Value is List <object> )
         {
             foreach (List <object> it in e.Value as List <object> )
             {
                 GXDateTime start = GXDLMSClient.ChangeType((byte[])it[0], DataType.DateTime, settings.UseUtc2NormalTime) as GXDateTime;
                 GXDateTime end   = GXDLMSClient.ChangeType((byte[])it[1], DataType.DateTime, settings.UseUtc2NormalTime) as GXDateTime;
                 CommunicationWindow.Add(new KeyValuePair <GXDateTime, GXDateTime>(start, end));
             }
         }
     }
     else if (e.Index == 5)
     {
         RandomisationStartInterval = (UInt16)e.Value;
     }
     else if (e.Index == 6)
     {
         NumberOfRetries = (byte)e.Value;
     }
     else if (e.Index == 7)
     {
         RepetitionDelay = (UInt16)e.Value;
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }
Esempio n. 6
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)
     {
         PushObjectList.Clear();
         if (e.Value is Object[])
         {
             foreach (object it in e.Value as Object[])
             {
                 Object[] tmp = it as Object[];
                 ObjectType type = (ObjectType)Convert.ToUInt16(tmp[0]);
                 String ln = GXDLMSClient.ChangeType((byte[])tmp[1], DataType.OctetString).ToString();
                 GXDLMSObject obj = settings.Objects.FindByLN(type, ln);
                 if (obj == null)
                 {
                     obj = GXDLMSClient.CreateObject(type);
                     obj.LogicalName = ln;
                 }
                 GXDLMSCaptureObject co = new GXDLMSCaptureObject(Convert.ToInt32(tmp[2]), Convert.ToInt32(tmp[3]));
                 PushObjectList.Add(new KeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(obj, co));
             }
         }
     }
     else if (e.Index == 3)
     {
         object[] tmp = e.Value as object[];
         if (tmp != null)
         {
             Service = (ServiceType)Convert.ToInt32(tmp[0]);
             Destination = (string)GXDLMSClient.ChangeType((byte[])tmp[1], DataType.OctetString);
             Message = (MessageType)Convert.ToInt32(tmp[2]);
         }
     }
     else if (e.Index == 4)
     {
         CommunicationWindow.Clear();
         if (e.Value is Object[])
         {
             foreach (object it in e.Value as Object[])
             {
                 Object[] tmp = it as Object[];
                 GXDateTime start = GXDLMSClient.ChangeType((byte[])tmp[0], DataType.DateTime) as GXDateTime;
                 GXDateTime end = GXDLMSClient.ChangeType((byte[])tmp[1], DataType.DateTime) as GXDateTime;
                 CommunicationWindow.Add(new KeyValuePair<GXDateTime, GXDateTime>(start, end));
             }
         }
     }
     else if (e.Index == 5)
     {
         RandomisationStartInterval = (UInt16)e.Value;
     }
     else if (e.Index == 6)
     {
         NumberOfRetries = (byte)e.Value;
     }
     else if (e.Index == 7)
     {
         RepetitionDelay = (UInt16)e.Value;
     }
     else
     {
         e.Error = ErrorCode.ReadWriteDenied;
     }
 }