Ejemplo n.º 1
0
 ///<summary>
 ///Get string value from DLMS data.
 ///</summary>
 ///<param name="buff">
 ///Received DLMS data.
 ///</param>
 ///<param name="info">
 ///Data info.
 ///</param>
 ///<returns>
 ///Parsed string value.
 ///</returns>
 private static object GetString(GXByteBuffer buff, GXDataInfo info, bool knownType)
 {
     string value;
     int len;
     if (knownType)
     {
         len = buff.Size;
     }
     else
     {
         len = GXCommon.GetObjectCount(buff);
         // If there is not enough data available.
         if (buff.Size - buff.Position < len)
         {
             info.Complete = false;
             return null;
         }
     }
     if (len > 0)
     {
         value = buff.GetString(len);
     }
     else
     {
         value = "";
     }
     if (info.xml != null)
     {
         if (info.xml.ShowStringAsHex)
         {
             info.xml.AppendLine(info.xml.GetDataType(info.Type), "Value", GXCommon.ToHex(buff.Data, false, buff.Position - len, len));
         }
         else
         {
             info.xml.AppendLine(info.xml.GetDataType(info.Type), "Value", value.Replace('\"', '\''));
         }
     }
     return value;
 }