/// <summary>
 /// Constructor.
 /// </summary>
 public GXDLMSDevice(Gurux.Common.IGXMedia media) : base()
 {
     communicator             = new GXDLMSCommunicator(this, media);
     Objects                  = communicator.client.Objects;
     Objects.Tag              = this;
     communicator.OnProgress += new ProgressEventHandler(this.NotifyProgress);
     this.KeepAlive           = new System.Timers.Timer();
     this.KeepAlive.Interval  = 40000;
     this.KeepAlive.Elapsed  += new System.Timers.ElapsedEventHandler(KeepAlive_Elapsed);
     m_Status                 = DeviceState.Initialized;
 }
Beispiel #2
0
 /// <summary>
 /// Returns collection of manufacturer Obis codes to implement custom read.
 /// </summary>
 /// <param name="name">Short or Logical Name.</param>
 /// <param name="type">Interface type.</param>        
 /// <returns>True, if data read is handled.</returns>
 public bool Read(object sender, GXDLMSObject item, GXDLMSObjectCollection columns, int attribute, GXDLMSCommunicator comm)
 {
     MainForm = sender as System.Windows.Forms.Form;
     if (!(item is GXDLMSProfileGeneric))
     {
         return false;
     }
     //Actaris do not support other than index 2.
     if (attribute != 0 && attribute != 2)
     {
         return true;
     }
     if (comm.OnBeforeRead != null)
     {
         comm.OnBeforeRead(item, attribute);
     }
     CurrentProfileGeneric = item as GXDLMSProfileGeneric;
     if (item is GXDLMSProfileGeneric)
     {
         GXDLMSProfileGeneric pg = item as GXDLMSProfileGeneric;
         GXReplyData reply = new GXReplyData();
         byte[][] data;
         try
         {
             comm.OnDataReceived += new GXDLMSCommunicator.DataReceivedEventHandler(this.OnProfileGenericDataReceived);
             //Read profile generic columns.
             if (pg.AccessSelector == AccessRange.Range ||
                 pg.AccessSelector == AccessRange.Last)
             {
                 data = comm.client.ReadRowsByRange(pg, Convert.ToDateTime(pg.From).Date, Convert.ToDateTime(pg.To).Date);
                 comm.ReadDataBlock(data[0], "Reading profile generic data", 1, reply);
             }
             else if (pg.AccessSelector == AccessRange.Entry)
             {
                 data = comm.client.ReadRowsByEntry(pg, Convert.ToInt32(pg.From), Convert.ToInt32(pg.To));
                 comm.ReadDataBlock(data[0], "Reading profile generic data " + pg.Name, 1, reply);
             }
             else //Read All.
             {
                 data = comm.client.Read(pg, 2);
                 comm.ReadDataBlock(data[0], "Reading profile generic data " + pg.Name, 1, reply);
             }
         }
         finally
         {
             CurrentProfileGeneric = null;
             comm.OnDataReceived -= new GXDLMSCommunicator.DataReceivedEventHandler(this.OnProfileGenericDataReceived);
         }
         return true;
     }
     return false;
 }
Beispiel #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public GXDLMSDevice(Gurux.Common.IGXMedia media)
 {
     StartProtocol              = StartProtocolType.IEC;
     ClientID                   = 0x10; // Public client (lowest security level).
     PhysicalAddress            = 1;
     Password                   = "";
     Authentication             = Authentication.None;
     m_Communicator             = new GXDLMSCommunicator(this, media);
     m_Objects                  = m_Communicator.m_Cosem.Objects;
     m_Objects.Tag              = this;
     m_Communicator.OnProgress += new ProgressEventHandler(this.NotifyProgress);
     this.KeepAlive             = new System.Timers.Timer();
     this.KeepAlive.Interval    = 40000;
     this.KeepAlive.Elapsed    += new System.Timers.ElapsedEventHandler(KeepAlive_Elapsed);
     m_Status                   = DeviceState.Initialized;
     WaitTime                   = 5;
 }
Beispiel #4
0
 /// <summary>
 /// Returns collection of manufacturer Obis codes to implement custom read.
 /// </summary>
 /// <param name="name">Short or Logical Name.</param>
 /// <param name="type">Interface type.</param>        
 /// <returns>True, if data read is handled.</returns>
 public bool Read(object sender, GXDLMSObject item, GXDLMSObjectCollection columns, int attribute, GXDLMSCommunicator comm)
 {
     MainForm = sender as System.Windows.Forms.Form;
     if (!(item is GXDLMSProfileGeneric))
     {
         return false;
     }
     //Actaris do not support other than index 2.
     if (attribute != 0 && attribute != 2)
     {
         return true;
     }
     if (comm.OnBeforeRead != null)
     {
         comm.OnBeforeRead(item, attribute);
     }
     CurrentProfileGeneric = item as GXDLMSProfileGeneric;
     if (item is GXDLMSProfileGeneric)
     {
         GXDLMSProfileGeneric pg = item as GXDLMSProfileGeneric;
         byte[] data;
         try
         {
             comm.OnDataReceived += new GXDLMSCommunicator.DataReceivedEventHandler(this.OnProfileGenericDataReceived);
             //Read profile generic columns.
             if (pg.AccessSelector != AccessRange.Entry)
             {
                 data = comm.m_Cosem.ReadRowsByRange(pg.Name, pg.CaptureObjects[0].Key.LogicalName,
                                 pg.CaptureObjects[0].Key.ObjectType, pg.CaptureObjects[0].Key.Version, Convert.ToDateTime(pg.From).Date, Convert.ToDateTime(pg.To).Date);
                 data = comm.ReadDataBlock(data, "Reading profile generic data", 1);
             }
             else
             {
                 data = comm.m_Cosem.ReadRowsByEntry(pg.Name, Convert.ToInt32(pg.From), Convert.ToInt32(pg.To));
                 data = comm.ReadDataBlock(data, "Reading profile generic data " + pg.Name, 1);
             }
         }
         finally
         {
             CurrentProfileGeneric = null;
             comm.OnDataReceived -= new GXDLMSCommunicator.DataReceivedEventHandler(this.OnProfileGenericDataReceived);
         }
         return true;
     }
     return false;
 }
Beispiel #5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public GXDLMSDevice(Gurux.Common.IGXMedia media)
 {
     StartProtocol            = StartProtocolType.IEC;
     ClientAddress            = 0x10; // Public client (lowest security level).
     PhysicalAddress          = 1;
     Password                 = "";
     Authentication           = Authentication.None;
     communicator             = new GXDLMSCommunicator(this, media);
     m_Objects                = communicator.client.Objects;
     m_Objects.Tag            = this;
     communicator.OnProgress += new ProgressEventHandler(this.NotifyProgress);
     this.KeepAlive           = new System.Timers.Timer();
     this.KeepAlive.Interval  = 40000;
     this.KeepAlive.Elapsed  += new System.Timers.ElapsedEventHandler(KeepAlive_Elapsed);
     m_Status                 = DeviceState.Initialized;
     WaitTime                 = 5;
     InactivityTimeout        = 120;
     WindowSizeRX             = WindowSizeTX = 1;
     MaxInfoRX                = MaxInfoTX = 128;
     PduSize      = 0xFFFF;
     ServiceClass = ServiceClass.Confirmed;
     Priority     = Priority.High;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 public GXDLMSDevice(Gurux.Common.IGXMedia media)
 {
     StartProtocol = StartProtocolType.IEC;
     ClientID = 0x10; // Public client (lowest security level).
     PhysicalAddress = 1;
     Password = "";
     Authentication = Authentication.None;
     m_Communicator = new GXDLMSCommunicator(this, media);
     m_Objects = m_Communicator.m_Cosem.Objects;
     m_Objects.Tag = this;
     m_Communicator.OnProgress += new ProgressEventHandler(this.NotifyProgress);
     this.KeepAlive = new System.Timers.Timer();
     this.KeepAlive.Interval = 40000;
     this.KeepAlive.Elapsed += new System.Timers.ElapsedEventHandler(KeepAlive_Elapsed);
     m_Status = DeviceState.Initialized;
     WaitTime = 5;
 }
Beispiel #7
0
 public List<GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>> Refresh(GXDLMSProfileGeneric item, GXDLMSCommunicator comm)
 {
     if (item.LogicalName.CompareTo("0.0.99.1.2.255") == 0) // LoadProfile1EndOfRecordingData
     {
         List<GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>> items = new List<GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>>();
         //Read profile generic columns.
         object value = comm.GetProfileGenericColumns(item.Name);
         byte[] data = comm.Read("0.0.99.128.1.255", ObjectType.ProfileGeneric, 2);
         byte[] allData = comm.ReadDataBlock(data, "Get profile generic columns...", 1);
         object[] values = (object[])comm.m_Cosem.GetValue(allData);
         Array info = values[0] as Array;
         GXDLMSObject obj = new GXDLMSData();
         obj.Description = "DateTime";
         obj.SetUIDataType(1, DataType.DateTime);
         items.Add(new GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(obj, new GXDLMSCaptureObject(1, 0)));
         obj = new GXDLMSData();
         obj.Description = "Status";
         items.Add(new GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(obj, new GXDLMSCaptureObject(2, 0)));
         //Two last items contains Start and end date.
         int cnt = 4;
         for (int pos = 0; pos < info.Length - 2; pos += 2)
         {
             obj = new GXDLMSData();
             obj.LogicalName = GXHelpers.ConvertFromDLMS(info.GetValue(pos), DataType.OctetString, DataType.OctetString, false).ToString();
             object scalerUnit = info.GetValue(pos + 1);
             obj.Description = "";
             items.Add(new GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(obj, new GXDLMSCaptureObject(++cnt, 0)));
         }
         LastDateTime = ((GXDateTime) GXDLMS.Common.GXHelpers.ConvertFromDLMS(info.GetValue(info.Length - 1), DataType.OctetString, DataType.DateTime, true)).Value;
         return items;
     }
     return null;
 }
Beispiel #8
0
 public List<GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>> Refresh(GXDLMSProfileGeneric item, GXDLMSCommunicator comm)
 {
     GXReplyData reply = new GXReplyData();
     if (item.LogicalName.CompareTo("0.0.99.1.2.255") == 0) // LoadProfile1EndOfRecordingData
     {
         List<GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>> items = new List<GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>>();
         //Read profile generic columns.
         comm.GetProfileGenericColumns(item);
         byte[] data = comm.Read(item, 2);
         comm.ReadDataBlock(data, "Get profile generic columns...", 1, reply);
         object[] values = (object[])reply.Value;
         Array info = values[0] as Array;
         GXDLMSObject obj = new GXDLMSData();
         obj.Description = "DateTime";
         obj.SetUIDataType(1, DataType.DateTime);
         items.Add(new GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(obj, new GXDLMSCaptureObject(1, 0)));
         obj = new GXDLMSData();
         obj.Description = "Status";
         items.Add(new GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(obj, new GXDLMSCaptureObject(2, 0)));
         //Two last items contains Start and end date.
         int cnt = 4;
         for (int pos = 0; pos < info.Length - 2; pos += 2)
         {
             obj = new GXDLMSData();
             obj.LogicalName = Convert.ToString(GXDLMSClient.ChangeType((byte[])info.GetValue(pos), DataType.OctetString));
             object scalerUnit = info.GetValue(pos + 1);
             obj.Description = "";
             items.Add(new GXKeyValuePair<GXDLMSObject, GXDLMSCaptureObject>(obj, new GXDLMSCaptureObject(++cnt, 0)));
         }
         LastDateTime = (GXDateTime)GXDLMSClient.ChangeType((byte[]) info.GetValue(info.Length - 1), DataType.DateTime);
         return items;
     }
     return null;
 }