コード例 #1
0
 /// <summary>
 /// Removes X.509 v3 certificate from the server using serial number.
 /// </summary>
 /// <param name="client">DLMS client that is used to generate action.</param>
 /// <param name="serialNumber">Serial number.</param>
 /// <param name="issuer">Issuer.</param>
 /// <returns>Generated action.</returns>
 public byte[][] RemoveCertificateBySerial(GXDLMSClient client, byte[] serialNumber, byte[] issuer)
 {
     GXByteBuffer bb = new GXByteBuffer();
     bb.SetUInt8(DataType.Structure);
     bb.SetUInt8(2);
     //Add enum
     bb.SetUInt8(DataType.Enum);
     bb.SetUInt8(1);
     //Add certificate_identification_by_entity
     bb.SetUInt8(DataType.Structure);
     bb.SetUInt8(2);
     //serialNumber
     GXCommon.SetData(client.Settings, bb, DataType.OctetString, serialNumber);
     //issuer
     GXCommon.SetData(client.Settings, bb, DataType.OctetString, issuer);
     return client.Method(this, 8, bb.Array(), DataType.OctetString);
 }
コード例 #2
0
 /// <summary>
 ///  Imports an X.509 v3 certificate of a public key.
 /// </summary>
 /// <param name="client">DLMS client that is used to generate action.</param>
 /// <param name="key">Public key.</param>
 /// <returns>Generated action.</returns>
 public byte[][] ImportCertificate(GXDLMSClient client, byte[] key)
 {
     return client.Method(this, 6, key, DataType.OctetString);
 }
コード例 #3
0
 /// <summary>
 /// Removes X.509 v3 certificate from the server using entity.
 /// </summary>
 /// <param name="client">DLMS client that is used to generate action.</param>
 /// <param name="entity">Certificate entity type.</param>
 /// <param name="type">Certificate type.</param>
 /// <param name="systemTitle">System title.</param>
 /// <returns>Generated action.</returns>
 public byte[][] RemoveCertificateByEntity(GXDLMSClient client, CertificateEntity entity, CertificateType type, byte[] systemTitle)
 {
     GXByteBuffer bb = new GXByteBuffer();
     bb.SetUInt8(DataType.Structure);
     bb.SetUInt8(2);
     //Add enum
     bb.SetUInt8(DataType.Enum);
     bb.SetUInt8(0);
     //Add certificate_identification_by_entity
     bb.SetUInt8(DataType.Structure);
     bb.SetUInt8(3);
     //Add certificate_entity
     bb.SetUInt8(DataType.Enum);
     bb.SetUInt8(entity);
     //Add certificate_type
     bb.SetUInt8(DataType.Enum);
     bb.SetUInt8(type);
     //system_title
     GXCommon.SetData(client.Settings, bb, DataType.OctetString, systemTitle);
     return client.Method(this, 8, bb.Array(), DataType.OctetString);
 }
コード例 #4
0
 /// <summary>
 /// Method attribute value.
 /// </summary>
 public void Method(GXDLMSObject it, int attributeIndex, object value, DataType type)
 {
     ReadDataBlock(Client.Method(it, attributeIndex, value, type)[0]);
 }
コード例 #5
0
 /// <summary>
 ///  Ask Server sends the Certificate Signing Request (CSR) data.
 /// </summary>
 /// <param name="client">DLMS client that is used to generate action.</param>
 /// <param name="type">identifies the key pair for which the certificate will be requested.</param>
 /// <returns>Generated action.</returns>
 public byte[][] GenerateCertificate(GXDLMSClient client, CertificateType type)
 {
     return client.Method(this, 5, type, DataType.Enum);
 }
コード例 #6
0
 public byte[][] ImageVerify(GXDLMSClient client)
 {
     return client.Method(this, 3, 0, DataType.Int8);
 }
コード例 #7
0
 public byte[] MethodRequest(GXDLMSObject target, int methodIndex, object data)
 {
     return(ReadDataBlock(m_Cosem.Method(target, methodIndex, data, DataType.None), ""));
 }
コード例 #8
0
ファイル: GXDLMSClock.cs プロジェクト: jacea/Gurux.DLMS.Net
 /// <summary>
 /// This Method is used in conjunction with the preset_adjusting_time
 /// Method. If the meter’s time lies between validity_interval_start and
 /// validity_interval_end, then time is set to preset_time.
 /// </summary>
 /// <returns></returns>
 public byte[][] AdjustToPresetTime(GXDLMSClient client)
 {
     return client.Method(this, 4, 0, DataType.Int8);            
 }
コード例 #9
0
ファイル: GXDLMSClock.cs プロジェクト: jacea/Gurux.DLMS.Net
 /// <summary>
 /// Presets the time to a new value (preset_time) and defines a validity_interval within which the new time can be activated.
 /// </summary>
 /// <param name="presetTime"></param>
 /// <param name="validityIntervalStart"></param>
 /// <param name="validityIntervalEnd"></param>
 /// <returns></returns>
 public byte[][] PresetAdjustingTime(GXDLMSClient client, DateTime presetTime, DateTime validityIntervalStart, DateTime validityIntervalEnd)
 {
     List<byte> buff = new List<byte>();
     buff.Add((byte)DataType.Structure);
     buff.Add((byte)3);
     GXCommon.SetData(buff, DataType.DateTime, presetTime);
     GXCommon.SetData(buff, DataType.DateTime, validityIntervalStart);
     GXCommon.SetData(buff, DataType.DateTime, validityIntervalEnd);
     return client.Method(this, 5, buff.ToArray(), DataType.Array);            
 }
コード例 #10
0
ファイル: GXDLMSClock.cs プロジェクト: jacea/Gurux.DLMS.Net
 /// <summary>
 /// Sets the meter’s time to the nearest (+/-) starting point of a measuring period.
 /// </summary>
 /// <returns></returns>
 public byte[][] AdjustToMeasuringPeriod(GXDLMSClient client)
 {
     return client.Method(this, 2, 0, DataType.Int8);            
 }
コード例 #11
0
ファイル: GXDLMSClock.cs プロジェクト: jacea/Gurux.DLMS.Net
 /// <summary>
 /// Sets the meter’s time to the nearest minute.
 /// If second_counter < 30 s, so second_counter is set to 0.
 /// If second_counter ³ 30 s, so second_counter is set to 0, and
 /// minute_counter and all depending clock values are incremented if necessary.
 /// </summary>
 /// <returns></returns>
 public byte[][] AdjustToMinute(GXDLMSClient client)
 {
     return client.Method(this, 3, 0, DataType.Int8);            
 }
コード例 #12
0
ファイル: GXDLMSClock.cs プロジェクト: jacea/Gurux.DLMS.Net
 /// <summary>
 /// Sets the meter’s time to the nearest (+/-) quarter of an hour value (*:00, *:15, *:30, *:45).
 /// </summary>
 /// <returns></returns>
 public byte[][] AdjustToQuarter(GXDLMSClient client)
 {
     return client.Method(this, 1, 0, DataType.Int8);            
 }
コード例 #13
0
ファイル: GXDLMSClock.cs プロジェクト: Gurux/Gurux.DLMS.Net
 /// <summary>
 /// Presets the time to a new value (preset_time) and defines a validity_interval within which the new time can be activated.
 /// </summary>
 /// <param name="presetTime"></param>
 /// <param name="validityIntervalStart"></param>
 /// <param name="validityIntervalEnd"></param>
 /// <returns></returns>
 public byte[][] PresetAdjustingTime(GXDLMSClient client, DateTime presetTime, DateTime validityIntervalStart, DateTime validityIntervalEnd)
 {
     GXByteBuffer buff = new GXByteBuffer();
     buff.Add((byte)DataType.Structure);
     buff.Add((byte)3);
     GXCommon.SetData(client.Settings, buff, DataType.OctetString, presetTime);
     GXCommon.SetData(client.Settings, buff, DataType.OctetString, validityIntervalStart);
     GXCommon.SetData(client.Settings, buff, DataType.OctetString, validityIntervalEnd);
     return client.Method(this, 5, buff.Array(), DataType.Array);
 }
コード例 #14
0
        /// <summary>
        /// Method attribute value.
        /// </summary>
        public void Method(GXDLMSObject it, int attributeIndex, object value, DataType type)
        {
            GXReplyData reply = new GXReplyData();

            ReadDataBlock(Client.Method(it, attributeIndex, value, type), reply);
        }
コード例 #15
0
 public byte[][] ImageTransferInitiate(GXDLMSClient client, string imageIdentifier, long imageSize)
 {
     if (ImageBlockSize == 0)
     {
         throw new Exception("Invalid image block size");
     }
     List<byte> data = new List<byte>();
     data.Add((byte)DataType.Structure);
     data.Add((byte)2);
     GXCommon.SetData(data, DataType.OctetString, ASCIIEncoding.ASCII.GetBytes(imageIdentifier));
     GXCommon.SetData(data, DataType.UInt32, imageSize);
     return client.Method(this, 1, data.ToArray(), DataType.Array);
 }
コード例 #16
0
ファイル: GXDLMSClock.cs プロジェクト: jacea/Gurux.DLMS.Net
 /// <summary>
 /// Shifts the time by n (-900 <= n <= 900) s.
 /// </summary>
 /// <param name="time"></param>
 /// <returns></returns>
 public byte[][] ShiftTime(GXDLMSClient client, int time)
 {
     if (time < -900 || time > 900)
     {
         throw new ArgumentOutOfRangeException("Invalid shift time.");
     }
     return client.Method(this, 6, time, DataType.Int16);            
 }
コード例 #17
0
 public byte[][] ImageBlockTransfer(GXDLMSClient client, byte[] imageBlockValue, out int ImageBlockCount)
 {
     ImageBlockCount = (int)(imageBlockValue.Length / ImageBlockSize);
     if (imageBlockValue.Length % ImageBlockSize != 0)
     {
         ++ImageBlockCount;
     }
     List<byte[]> packets = new List<byte[]>();
     for (int pos = 0; pos != ImageBlockCount; ++pos)
     {
         List<byte> data = new List<byte>();
         data.Add((byte)DataType.Structure);
         data.Add((byte)2);
         GXCommon.SetData(data, DataType.UInt32, pos);
         byte[] tmp;
         int bytes = (int)(imageBlockValue.Length - ((pos + 1) * ImageBlockSize));
         //If last packet
         if (bytes < 0)
         {
             bytes = (int)(imageBlockValue.Length - (pos * ImageBlockSize));
             tmp = new byte[bytes];
             Array.Copy(imageBlockValue, pos * ImageBlockSize, tmp, 0, bytes);
         }
         else
         {
             tmp = new byte[ImageBlockSize];
             Array.Copy(imageBlockValue, (pos * ImageBlockSize), tmp, 0, ImageBlockSize);
         }
         GXCommon.SetData(data, DataType.OctetString, tmp);
         packets.AddRange(client.Method(this, 2, data.ToArray(), DataType.Array));
     }
     return packets.ToArray();
 }
コード例 #18
0
 /// <summary>
 /// Activates and strengthens the security policy.
 /// </summary>
 /// <param name="client">DLMS client that is used to generate action.</param>
 /// <param name="security">New security level.</param>
 /// <returns>Generated action.</returns>
 public byte[][] Activate(GXDLMSClient client, Gurux.DLMS.Enums.Security security)
 {
     return client.Method(this, 1, GetSecurityValue(security), DataType.Enum);
 }
コード例 #19
0
 public byte[][] ImageActivate(GXDLMSClient client)
 {
     return client.Method(this, 4, 0, DataType.Int8);
 }
コード例 #20
0
 /// <summary>
 /// Agree on one or more symmetric keys using the key agreement algorithm.
 /// </summary>
 /// <param name="client"> DLMS client that is used to generate action.</param>
 /// <param name="list"> List of keys.</param>
 /// <returns>Generated action.</returns>
 public byte[][] keyAgreement(GXDLMSClient client, List<KeyValuePair<GlobalKeyType, byte[]>> list)
 {
     if (list == null || list.Count == 0)
     {
         throw new ArgumentException("Invalid list. It is empty.");
     }
     GXByteBuffer bb = new GXByteBuffer();
     bb.SetUInt8(DataType.Array);
     bb.SetUInt8((byte)list.Count);
     foreach (KeyValuePair<GlobalKeyType, byte[]> it in list)
     {
         bb.SetUInt8(DataType.Structure);
         bb.SetUInt8(2);
         GXCommon.SetData(client.Settings, bb, DataType.Enum, it.Key);
         GXCommon.SetData(client.Settings, bb, DataType.OctetString, it.Value);
     }
     return client.Method(this, 3, bb.Array(), DataType.Array);
 }
コード例 #21
0
 /// <summary>
 /// Reset value.
 /// </summary>
 /// <returns></returns>
 public byte[][] Reset(GXDLMSClient client)
 {
     return client.Method(this, 1, (int)0);            
 }
コード例 #22
0
 /// <summary>
 /// Activates the push process.
 /// </summary>
 /// <returns></returns>
 public byte[][] Activate(GXDLMSClient client)
 {
     return client.Method(this, 1, (byte)0);
 }