/// <summary>
        /// Retrieves the Time String representation of the element in the array of bytes </summary>
        /// <param name="data"> array of bytes containing data result from a dlms-get </param>
        /// <returns> A Strig that represents the time in the data </returns>
        /// <exception cref="DlmsException"> </exception>
        public static string getTimeString(byte[] data)
        {
            verify(data);
            DlmsType type = DlmsType.fromTag(data[0]);

            return(DlmsParser.getTimeStringValue(getPayload(type, data)));
        }
        public int getImageBlockSize(DlmsClient dlms, PhyLayer phy)
        {
            LnDescriptor att = createDesc(attBlockSize);

            dlms.get(phy, att);
            return(DlmsParser.getInteger(att.getResponseData()));
        }
        public bool isTransferEnabled(DlmsClient dlms, PhyLayer phy)
        {
            LnDescriptor att = createDesc(attTransferEnabled);

            dlms.get(phy, att);
            return(DlmsParser.getBoolean(att.getResponseData()));
        }
 public void testTimeToString()
 {
     Assert.AreEqual("10:00:00", DlmsParser.getString(new byte[] { 0x1B, 0x0A, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("22:55:41", DlmsParser.getString(new byte[] { 0x1B, 0x16, 0x37, 0x29, 0x00 }));
     Assert.AreEqual("10:00:00", DlmsParser.getTimeString(new byte[] { 0x1B, 0x0A, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("22:55:41", DlmsParser.getTimeString(new byte[] { 0x1B, 0x16, 0x37, 0x29, 0x00 }));
     Assert.AreEqual("10:00:00", DlmsParser.getTimeString(new byte[] { 0x09, 0x04, 0x0A, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("22:55:41", DlmsParser.getTimeString(new byte[] { 0x09, 0x04, 0x16, 0x37, 0x29, 0x00 }));
 }
 public void testDateToString()
 {
     Assert.AreEqual("2018/10/13", DlmsParser.getString(new byte[] { 0x1A, 0x07, ((byte)0xE2), 0x0A, 0x0D, 0x00 }));
     Assert.AreEqual("2018/01/30", DlmsParser.getString(new byte[] { 0x1A, 0x07, ((byte)0xE2), 0x01, 0x1E, 0x00 }));
     Assert.AreEqual("2018/10/13", DlmsParser.getDateString(new byte[] { 0x1A, 0x07, ((byte)0xE2), 0x0A, 0x0D, 0x00 }));
     Assert.AreEqual("2018/01/30", DlmsParser.getDateString(new byte[] { 0x1A, 0x07, ((byte)0xE2), 0x01, 0x1E, 0x00 }));
     Assert.AreEqual("2018/10/13", DlmsParser.getDateString(new byte[] { 0x09, 0x05, 0x07, ((byte)0xE2), 0x0A, 0x0D, 0x00 }));
     Assert.AreEqual("2018/01/30", DlmsParser.getDateString(new byte[] { 0x09, 0x05, 0x07, ((byte)0xE2), 0x01, 0x1E, 0x00 }));
 }
 public void testDateTimeToString()
 {
     Assert.AreEqual("2018/10/13 10:00:00", DlmsParser.getString(new byte[] { 0x19, 0x07, ((byte)0xE2), 0x0A, 0x0D, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("2018/01/30 22:55:41", DlmsParser.getString(new byte[] { 0x19, 0x07, ((byte)0xE2), 0x01, 0x1E, 0x00, 0x16, 0x37, 0x29, 0x00, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("2018/10/13 10:00:00", DlmsParser.getDateTimeString(new byte[] { 0x19, 0x07, ((byte)0xE2), 0x0A, 0x0D, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("2018/01/30 22:55:41", DlmsParser.getDateTimeString(new byte[] { 0x19, 0x07, ((byte)0xE2), 0x01, 0x1E, 0x00, 0x16, 0x37, 0x29, 0x00, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("2018/10/13 10:00:00", DlmsParser.getDateTimeString(new byte[] { 0x09, 0x0C, 0x07, ((byte)0xE2), 0x0A, 0x0D, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("2018/01/30 22:55:41", DlmsParser.getDateTimeString(new byte[] { 0x09, 0x0C, 0x07, ((byte)0xE2), 0x01, 0x1E, 0x00, 0x16, 0x37, 0x29, 0x00, 0x00, 0x00, 0x00 }));
 }
 public void testUint8toString()
 {
     Assert.AreEqual("0", DlmsParser.getString(new byte[] { 0x11, 0x00 }));
     Assert.AreEqual("1", DlmsParser.getString(new byte[] { 0x11, 0x01 }));
     Assert.AreEqual("12", DlmsParser.getString(new byte[] { 0x11, 0x0C }));
     Assert.AreEqual("33", DlmsParser.getString(new byte[] { 0x11, 0x21 }));
     Assert.AreEqual("254", DlmsParser.getString(new byte[] { 0x11, ((byte)0xFE) }));
     Assert.AreEqual("255", DlmsParser.getString(new byte[] { 0x11, ((byte)0xFF) }));
 }
 public void testInt8toString()
 {
     Assert.AreEqual("0", DlmsParser.getString(new byte[] { 0x0F, 0x00 }));
     Assert.AreEqual("1", DlmsParser.getString(new byte[] { 0x0F, 0x01 }));
     Assert.AreEqual("12", DlmsParser.getString(new byte[] { 0x0F, 0x0C }));
     Assert.AreEqual("45", DlmsParser.getString(new byte[] { 0x0F, 0x2D }));
     Assert.AreEqual("127", DlmsParser.getString(new byte[] { 0x0F, (byte)0x7F }));
     Assert.AreEqual("-128", DlmsParser.getString(new byte[] { 0x0F, ((byte)0x80) }));
     Assert.AreEqual("-127", DlmsParser.getString(new byte[] { 0x0F, ((byte)0x81) }));
     Assert.AreEqual("-95", DlmsParser.getString(new byte[] { 0x0F, ((byte)0xA1) }));
     Assert.AreEqual("-2", DlmsParser.getString(new byte[] { 0x0F, ((byte)0xFE) }));
     Assert.AreEqual("-1", DlmsParser.getString(new byte[] { 0x0F, ((byte)0xFF) }));
 }
 public void testUint32toString()
 {
     Assert.AreEqual("0", DlmsParser.getString(new byte[] { 0x06, 0x00, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("1", DlmsParser.getString(new byte[] { 0x06, 0x00, 0x00, 0x00, 0x01 }));
     Assert.AreEqual("12", DlmsParser.getString(new byte[] { 0x06, 0x00, 0x00, 0x00, 0x0C }));
     Assert.AreEqual("45", DlmsParser.getString(new byte[] { 0x06, 0x00, 0x00, 0x00, 0x2D }));
     Assert.AreEqual("4388", DlmsParser.getString(new byte[] { 0x06, 0x00, 0x00, 0x11, 0x24 }));
     Assert.AreEqual("16640", DlmsParser.getString(new byte[] { 0x06, 0x00, 0x00, 0x41, 0x00 }));
     Assert.AreEqual("2147483647", DlmsParser.getString(new byte[] { 0x06, 0x7F, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF) }));
     Assert.AreEqual("2147483648", DlmsParser.getString(new byte[] { 0x06, ((byte)0x80), (byte)0x00, (byte)0x00, (byte)0x00 }));
     Assert.AreEqual("2147483649", DlmsParser.getString(new byte[] { 0x06, ((byte)0x80), (byte)0x00, (byte)0x00, (byte)0x01 }));
     Assert.AreEqual("4294967201", DlmsParser.getString(new byte[] { 0x06, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xA1) }));
     Assert.AreEqual("4294967294", DlmsParser.getString(new byte[] { 0x06, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFE) }));
     Assert.AreEqual("4294967295", DlmsParser.getString(new byte[] { 0x06, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF) }));
 }
 public void testInt16toString()
 {
     Assert.AreEqual("0", DlmsParser.getString(new byte[] { 0x10, 0x00, 0x00 }));
     Assert.AreEqual("1", DlmsParser.getString(new byte[] { 0x10, 0x00, 0x01 }));
     Assert.AreEqual("12", DlmsParser.getString(new byte[] { 0x10, 0x00, 0x0C }));
     Assert.AreEqual("45", DlmsParser.getString(new byte[] { 0x10, 0x00, 0x2D }));
     Assert.AreEqual("4388", DlmsParser.getString(new byte[] { 0x10, 0x11, 0x24 }));
     Assert.AreEqual("16640", DlmsParser.getString(new byte[] { 0x10, 0x41, 0x00 }));
     Assert.AreEqual("32767", DlmsParser.getString(new byte[] { 0x10, 0x7F, ((byte)0xFF) }));
     Assert.AreEqual("-32768", DlmsParser.getString(new byte[] { 0x10, ((byte)0x80), (byte)0x00 }));
     Assert.AreEqual("-32767", DlmsParser.getString(new byte[] { 0x10, ((byte)0x80), (byte)0x01 }));
     Assert.AreEqual("-95", DlmsParser.getString(new byte[] { 0x10, ((byte)0xFF), ((byte)0xA1) }));
     Assert.AreEqual("-2", DlmsParser.getString(new byte[] { 0x10, ((byte)0xFF), ((byte)0xFE) }));
     Assert.AreEqual("-1", DlmsParser.getString(new byte[] { 0x10, ((byte)0xFF), ((byte)0xFF) }));
 }
 public void testInt64toString()
 {
     Assert.AreEqual("0", DlmsParser.getString(new byte[] { 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("1", DlmsParser.getString(new byte[] { 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }));
     Assert.AreEqual("12", DlmsParser.getString(new byte[] { 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C }));
     Assert.AreEqual("45", DlmsParser.getString(new byte[] { 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2D }));
     Assert.AreEqual("4388", DlmsParser.getString(new byte[] { 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x24 }));
     Assert.AreEqual("16640", DlmsParser.getString(new byte[] { 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00 }));
     Assert.AreEqual("9223372036854775806", DlmsParser.getString(new byte[] { 0x14, (byte)0x7F, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFE) }));
     Assert.AreEqual("9223372036854775807", DlmsParser.getString(new byte[] { 0x14, (byte)0x7F, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF) }));
     Assert.AreEqual("-9223372036854775808", DlmsParser.getString(new byte[] { 0x14, ((byte)0x80), (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }));
     Assert.AreEqual("-9223372036854775807", DlmsParser.getString(new byte[] { 0x14, ((byte)0x80), (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01 }));
     Assert.AreEqual("-95", DlmsParser.getString(new byte[] { 0x14, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xA1) }));
     Assert.AreEqual("-2", DlmsParser.getString(new byte[] { 0x14, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFE) }));
     Assert.AreEqual("-1", DlmsParser.getString(new byte[] { 0x14, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF) }));
 }
 public void testUint64toString()
 {
     Assert.AreEqual("0", DlmsParser.getString(new byte[] { 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("1", DlmsParser.getString(new byte[] { 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }));
     Assert.AreEqual("12", DlmsParser.getString(new byte[] { 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C }));
     Assert.AreEqual("45", DlmsParser.getString(new byte[] { 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2D }));
     Assert.AreEqual("4388", DlmsParser.getString(new byte[] { 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x24 }));
     Assert.AreEqual("16640", DlmsParser.getString(new byte[] { 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00 }));
     Assert.AreEqual("9223372036854775806", DlmsParser.getString(new byte[] { 0x15, (byte)0x7F, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFE) }));
     Assert.AreEqual("9223372036854775807", DlmsParser.getString(new byte[] { 0x15, (byte)0x7F, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF) }));
     Assert.AreEqual("9223372036854775808", DlmsParser.getString(new byte[] { 0x15, ((byte)0x80), (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }));
     Assert.AreEqual("9223372036854775809", DlmsParser.getString(new byte[] { 0x15, ((byte)0x80), (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01 }));
     Assert.AreEqual("18446744073709551521", DlmsParser.getString(new byte[] { 0x15, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xA1) }));
     Assert.AreEqual("18446744073709551614", DlmsParser.getString(new byte[] { 0x15, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFE) }));
     Assert.AreEqual("18446744073709551615", DlmsParser.getString(new byte[] { 0x15, ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF), ((byte)0xFF) }));
 }
 /// <summary>
 /// Retrieves the String representation of the element in the array of bytes </summary>
 /// <param name="type"> the DlmsType of the byte array </param>
 /// <param name="data"> array of bytes containing data result from a dlms-get </param>
 /// <returns> A Strig that represents the element in the data </returns>
 /// <exception cref="DlmsException"> </exception>
 public static string getString(DlmsType type, byte[] payload)
 {
     return(DlmsParser.getStringValue(type, payload));
 }
 public void testUtf8toString()
 {
     Assert.AreEqual("", DlmsParser.getString(new byte[] { 0x0C, 0x00 }));
     Assert.AreEqual("one flew over the cuckoo's nest", DlmsParser.getString(new byte[] { 0x0C, 0x1F, 0x6F, 0x6E, 0x65, 0x20, 0x66, 0x6C, 0x65, 0x77, 0x20, 0x6F, 0x76, 0x65, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x75, 0x63, 0x6B, 0x6F, 0x6F, 0x27, 0x73, 0x20, 0x6E, 0x65, 0x73, 0x74 }));
     Assert.AreEqual("all work and no play makes jack a dull boyall work and no play makes jack a dull boyall work and no play makes jack a dull boyall work and no play makes jack a dull boyall work and no play makes jack a dull boyall work and no play makes jack a dull boyall work and no play makes jack a dull boyall work and no play makes jack a dull boyall work and no play makes jack a dull boyall work and no play makes jack a dull boy", DlmsParser.getString(new byte[] { 0x0C, ((byte)0x82), 0x01, ((byte)0xA4), 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6a, 0x61, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x64, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x6f, 0x79, 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6a, 0x61, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x64, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x6f, 0x79, 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6a, 0x61, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x64, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x6f, 0x79, 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6a, 0x61, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x64, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x6f, 0x79, 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6a, 0x61, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x64, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x6f, 0x79, 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6a, 0x61, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x64, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x6f, 0x79, 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6a, 0x61, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x64, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x6f, 0x79, 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6a, 0x61, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x64, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x6f, 0x79, 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6a, 0x61, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x64, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x6f, 0x79, 0x61, 0x6c, 0x6c, 0x20, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x6f, 0x20, 0x70, 0x6c, 0x61, 0x79, 0x20, 0x6d, 0x61, 0x6b, 0x65, 0x73, 0x20, 0x6a, 0x61, 0x63, 0x6b, 0x20, 0x61, 0x20, 0x64, 0x75, 0x6c, 0x6c, 0x20, 0x62, 0x6f, 0x79 }));
 }
 public void testFloat64toString()
 {
     Assert.AreEqual("1", DlmsParser.getString(new byte[] { 0x18, 0x3F, ((byte)0xF0), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }));
     Assert.AreEqual("62056", DlmsParser.getString(new byte[] { 0x18, 0x40, ((byte)0xEE), 0x4D, 0x00, 0x00, 0x00, 0x00, 0x00 }));
 }
 public void testFloat32toString()
 {
     Assert.AreEqual("1", DlmsParser.getString(new byte[] { 0x17, 0x3F, ((byte)0x80), 0x00, 0x00 }));
     Assert.AreEqual("62056", DlmsParser.getString(new byte[] { 0x17, 0x47, 0x72, 0x68, 0x00 }));
     Assert.AreEqual("238.877", DlmsParser.getString(new byte[] { 0x17, (byte)0x43, (byte)0x6E, ((byte)0xE0), ((byte)0x83) }));
 }