コード例 #1
0
        /// <summary>
        /// 解析弹夹条码
        /// </summary>
        /// <param name="rev"></param>
        /// <returns></returns>
        public static string ReadClipBarBarcode(string rev)
        {
            if (string.IsNullOrEmpty(rev))
            {
                return("ERROR");
            }
            rev = rev.Replace("\r", "");
            int    lenth   = 0;
            string ss      = HexStr(rev);
            string barcode = "";

            for (int i = 0; i < ss.Length / 2; i++)
            {
                string str = ss.Substring(i * 2, 2);
                if (i == 0)
                {
                    if (str.ToUpper() == "0D" && i > 0)
                    {
                        return(barcode);
                    }
                    lenth = DecimalConversion.HexToTen(str);
                }
                barcode += DecimalConversion.HexStringToASCII(str).Replace("\n", "").Replace("\r", "").Replace("\0", "").Replace("", "").Replace("", "");
            }
            barcode = barcode.Replace("00000000000000000000000000000000", "ERROR").Replace("", "").ToUpper();
            if (!barcode.Contains("ERROR"))
            {
                barcode = barcode.Substring(0, lenth);
            }
            if (string.IsNullOrEmpty(barcode) || barcode.Contains("ERROR"))
            {
                barcode = "ERROR";
            }
            return(barcode);
        }
コード例 #2
0
        /// <summary>
        /// 解析多个寄存器解析出来拼接成字符串   例如条码解析
        /// </summary>
        /// <param name="rev"></param>
        /// <returns></returns>
        public static string ReadDTValueToStr(string rev)
        {
            //地址 %01#RDD0030100309**
            string ss      = PanasonnicSplitJoint.DTValues(rev);
            string barcode = "";

            for (int i = 0; i < ss.Length / 2; i++)
            {
                string str = ss.Substring(i * 2, 2);
                barcode += DecimalConversion.HexStringToASCII(str);
            }
            return(barcode);
        }
コード例 #3
0
        /// <summary>
        /// 解析寄存器读取的值
        /// </summary>
        /// <param name="rev"></param>
        /// <returns></returns>
        public static List <string> ReadDTValue(string rev)
        {
            List <string> list = new List <string>();

            //地址 %01#RDD0030100309**
            rev = PanasonnicSplitJoint.DTValues(rev);
            for (int i = 0; i < rev.Length / 2; i++)
            {
                string str = rev.Substring(i * 2, 2);
                list.Add(DecimalConversion.HexStringToASCII(str));
            }
            return(list);
        }
コード例 #4
0
        /// <summary>
        /// 读取处理得到条码
        /// </summary>
        /// <param name="rev"></param>
        /// <returns></returns>
        public static string ReadBarcode(string rev)
        {
            if (string.IsNullOrEmpty(rev))
            {
                return("ERROR");
            }
            rev = rev.Replace("\r", "");
            string ss      = HexStr(rev);
            string barcode = "";

            for (int i = 0; i < ss.Length / 2; i++)
            {
                string str = ss.Substring(i * 2, 2);
                if (str.ToUpper() == "0D" && i > 0)
                {
                    return(barcode);
                }
                barcode += DecimalConversion.HexStringToASCII(str).Replace("\n", "").Replace("\r", "").Replace("\0", "").Replace("", "");
            }
            return(barcode.Replace("00000000000000000000000000000000", "ERROR").ToUpper());
        }