示例#1
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;
 }
示例#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;
 }