Exemplo n.º 1
0
        public static string WriteDQBH(string str)
        {
            byte[] databuff = new byte[1];
            byte[] buff     = new byte[2];
            string data     = "";

            data  = LConvert.int_hex(str);
            icdev = IC.ic_init(1, 9600);
            buff  = System.Text.Encoding.ASCII.GetBytes(data);
            IC.asc_hex(buff, databuff, 2);
            st = IC4442.swr_4442(icdev, 71, 1, databuff);
            if (st == 0)
            {
                return("写数据成功!" + data);
            }
            else
            {
                return("写数据失败!" + data);
            }
        }
Exemplo n.º 2
0
        /*      表内剩余气量回写区
         * 存储区地址:3DH—3FH(61 – 63)数据说明:此存储区数据为燃气表对用户卡回写的表内剩余气量值。
         * 剩余气量 = (3DH单元数值) X 100 + (3EH单元数值) X 1+ (3FH单元数值) X 0.1。
         * 表内剩余气量最大数值为999.9立方米,其中,3DH单元数值范围为:0—9,3EH单元数值范围为:0—99,3FH单元数值范围为0 -- 9。
         * 例如:若用户表内剩余气量为123.4立方米,则IC卡3DH—3FH存储单元应为:01H,17H,04H。*/
        public static string ReadRemainQL()
        {
            string s = "";

            byte[] data     = new byte[3];
            byte[] databuff = new byte[6];
            int[]  sum      = new int[8];
            string lbResult;

            icdev = IC.ic_init(port, baud);
            st    = IC4442.srd_4442(icdev, 61, 3, data);
            if (st == 0)
            {
                st       = IC.hex_asc(data, databuff, 3);
                lbResult = System.Text.Encoding.ASCII.GetString(databuff);
                s        = LConvert.hex_int(lbResult);
                int    lll     = s.Length;
                byte[] intbuff = new byte[lll];
                byte[] key     = new byte[2];
                int    k       = 0;
                double d       = 0;
                intbuff = System.Text.Encoding.ASCII.GetBytes(s);
                for (int j = 0; j < 6; j = j + 2)
                {
                    key[0] = intbuff[j];
                    key[1] = intbuff[j + 1];
                    string x = System.Text.Encoding.ASCII.GetString(key);
                    sum[k] = Convert.ToInt32(x);
                    k++;
                }
                d        = 100 * sum[0] + sum[1] + 0.1 * sum[2];
                lbResult = "剩余气量" + d.ToString() + lbResult;
            }
            else
            {
                lbResult = "读数据失败!";
            }
            return(lbResult);
        }
Exemplo n.º 3
0
        public static string WriteRemainQL(string str)
        {
            byte[] databuff = new byte[3];
            byte[] buff     = new byte[6];
            string f_i      = "";
            string data     = "";

            f_i   = LConvert.float_int(str);
            data  = LConvert.int_hex(f_i);
            icdev = IC.ic_init(1, 9600);
            buff  = System.Text.Encoding.ASCII.GetBytes(data);
            IC.asc_hex(buff, databuff, 6);
            st = IC4442.swr_4442(icdev, 61, 3, databuff);
            if (st == 0)
            {
                return("写数据成功!" + data);
            }
            else
            {
                return("写数据失败!" + data);
            }
        }
Exemplo n.º 4
0
        //用户编号区 21H—24H(33 – 36)当存储在IC卡上时,8位数从低位到高位,每两位为1组,每组存入1个字节中。
        //例如:若从卡上用户编号区读出的数据为:0CH,22H,38H,4EH,则用户编号为12345678。
        public static string ReadUserId()
        {
            string s = "";

            byte[] data     = new byte[4];
            byte[] databuff = new byte[8];
            string lbResult;

            icdev = IC.ic_init(port, baud);
            st    = IC4442.srd_4442(icdev, 33, 4, data);
            if (st == 0)
            {
                st       = IC.hex_asc(data, databuff, 4);
                lbResult = System.Text.Encoding.ASCII.GetString(databuff);
                s        = LConvert.hex_int(lbResult);
                s       += LConvert.int_hex(s);
                lbResult = s + lbResult;
            }
            else
            {
                lbResult = "读数据失败!";
            }
            return(lbResult);
        }