/// <summary>
 /// Close connection to the meter.
 /// </summary>
 public void Close()
 {
     if (Media != null && Client != null)
     {
         try
         {
             if (Trace > TraceLevel.Info)
             {
                 Console.WriteLine("Disconnecting from the meter.");
             }
             GXReplyData reply = new GXReplyData();
             try
             {
                 ReadDataBlock(Client.ReleaseRequest(), reply);
             }
             catch (Exception)
             {
                 //All meters don't support release.
             }
             reply.Clear();
             ReadDLMSPacket(Client.DisconnectRequest(), reply);
             Media.Close();
         }
         catch
         {
         }
         Media  = null;
         Client = null;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Close connection to the meter.
 /// </summary>
 public void Close()
 {
     if (Media != null && Client != null)
     {
         try
         {
             if (Trace > TraceLevel.Info)
             {
                 Console.WriteLine("Disconnecting from the meter.");
             }
             GXReplyData reply = new GXReplyData();
             //Release is called only for secured connections. Some older meters don't support release and it might kill them.
             if (Client is GXDLMSSecureClient && (Client as GXDLMSSecureClient).Ciphering.Security != Security.None)
             {
                 ReadDataBlock(Client.ReleaseRequest(), reply);
             }
             reply.Clear();
             ReadDLMSPacket(Client.DisconnectRequest(), reply);
             Media.Close();
         }
         catch
         {
         }
         Media  = null;
         Client = null;
     }
 }