示例#1
0
文件: Parser.cs 项目: VCDH/vve
        public static VLogInfo DecodeInfo(string msg)
        {
            //decodeer informatie bericht: berichttype 0x04
            //  !NULL : geldige waarde -> aantal detectoren met actuele status
            //  NULL  : onjuist bericht

            //voorbeeld bericht: "040200003132392020202020202020202020202020202020"
            //  04: type
            //  020000: versie
            //  3132392020202020202020202020202020202020: vri_id / sys

            //checks
            if (!msgOk(msg, 48, "04"))
            {
                return(null);
            }

            VLogInfo result = new VLogInfo();

            result.VLogVersie = string.Format("{0}.{1}.{2}", hex2int(msg[2], msg[3]), hex2int(msg[4], msg[5]), hex2int(msg[6], msg[7]));
            StringBuilder vriId = new StringBuilder();

            for (int i = 8; i < 48; i += 2)
            {
                vriId.Append((char)hex2int(msg[i], msg[i + 1]));
            }
            result.VriId = vriId.ToString().Trim();

            return(result);
        }
示例#2
0
文件: Test.cs 项目: VCDH/vve
        private static string decodeInfo(string msg)
        {
            VLogInfo res = Parser.DecodeInfo(msg);

            if (res == null)
            {
                return(string.Format("{0} - ongeldig bericht", msg));
            }
            else
            {
                return(string.Format("{0} - {1}", msg, res.ToString()));
            }
        }