예제 #1
0
        public bool SetLedCfg(int iAddr, CardCfgByJson cfg)
        {
            lock (this)
            {
                try
                {
                    ClearOldReadBuf();
                    bool bError = false;
                    GlareLedSysDefPub.GasCardCfg cardcfg = new GlareLedSysDefPub.GasCardCfg();
                    cardcfg.bDobule       = cfg.bDobule;
                    cardcfg.bShowAppend   = cfg.bShowAppend;
                    cardcfg.iCardDigCount = cfg.iCardDigCount;
                    cardcfg.iCardType     = cfg.iCardType;
                    cardcfg.iFirmVer      = cfg.iFirmVer;
                    cardcfg.iHardVer      = cfg.iHardVer;
                    cardcfg.iID           = cfg.iID;
                    cardcfg.iLight        = cfg.iLight;
                    cardcfg.iScreenCount  = cfg.iScreenCount;

                    byte[] bBuf = GLLedProtocol.MakeCmdLedSetCfg(iAddr, cardcfg);
                    Write(bBuf, 0, bBuf.Length);
                    Thread.Sleep(100);
                    byte[] bRead = Read(out bError);
                    return(GLLedProtocol.AnalyeseRecSetCardCfg(bRead, iAddr));
                }
                catch (System.Exception ex)
                {
                    LogMgr.WriteInfoDefSys("读写异常" + ex.Message);
                    return(false);
                }
            }
        }
예제 #2
0
 public bool SendOilDot(int iAddr, string lstStrings)
 {
     lock (this)
     {
         try
         {
             ClearOldReadBuf();
             int[]    iArr   = new int[12];
             string[] strArr = lstStrings.Split(new char[] { '-' });
             int      i      = 0;
             foreach (string strAstr in strArr)
             {
                 int.TryParse(strArr[i], out iArr[i]);
                 i++;
             }
             byte[] bBuf = GLLedProtocol.MakeCmdLedSetDecimal(iAddr, iArr);
             Write(bBuf, 0, bBuf.Length);
             Thread.Sleep(100);
             bool   bError = false;
             byte[] bRead  = Read(out bError);
             if (bRead != null)
             {
                 LogMgr.WriteInfoDefSys("recbuf bytes:" + BitConverter.ToString(bRead));
             }
             return(GLLedProtocol.AnalyeseRecSetDecemil(bRead, iAddr));
         }
         catch (System.Exception ex)
         {
             LogMgr.WriteInfoDefSys("读写异常" + ex.Message);
             return(false);
         }
     }
 }
예제 #3
0
 public bool SendOilContext(int iAddr, IList <string> lstStrings)
 {
     lock (this)
     {
         try
         {
             ClearOldReadBuf();
             bool bError = false;
             IList <GlareLedSysDefPub.CardGasValEachNumAByte> lstOilVals = GLLedProtocol.MakeOilValBytesByString(lstStrings);
             byte[] bBuf = GLLedProtocol.MakeCmdLedSetOilVal(iAddr, lstOilVals);
             Write(bBuf, 0, bBuf.Length);
             LogMgr.WriteInfoDefSys("send bytes:" + BitConverter.ToString(bBuf));
             Thread.Sleep(100);
             byte[] bRead = Read(out bError);
             if (bRead != null)
             {
                 LogMgr.WriteInfoDefSys("recbuf bytes:" + BitConverter.ToString(bRead));
             }
             return(GLLedProtocol.AnalyeseRecSetOilVal(bRead, iAddr));
         }
         catch (System.Exception ex)
         {
             LogMgr.WriteInfoDefSys("Write Execption" + ex.Message);
             return(false);
         }
     }
 }
예제 #4
0
 /// <summary>
 /// 设置ID,强制设置
 /// </summary>
 /// <param name="iAddr">旧ID,可以为0</param>
 /// <param name="iNewID">新ID</param>
 /// <returns></returns>
 public bool SetID(int iAddr, int iNewID)
 {
     ClearOldReadBuf();
     byte[] bBuf = GLLedProtocol.MakeCmdLedSetID(iNewID);
     Write(bBuf, 0, bBuf.Length);
     Thread.Sleep(1000);
     byte[] bRead = Read();
     if (bRead == null)
     {
         LogMgr.WriteErrorDefSys("Set Id RecBuf is Null");
         return(false);
     }
     return(GLLedProtocol.AnalyeseRecSetID(bRead, iNewID));
 }
예제 #5
0
 /// <summary>
 /// 读取时间
 /// </summary>
 public bool ReadTime(int iAddr, ref DateTime dtRead)
 {
     ClearOldReadBuf();
     byte[] bBuf = TimeTempProtocol.MakeGetTime(iAddr);
     Write(bBuf, 0, bBuf.Length);
     Thread.Sleep(1000);
     byte[] bRead = Read();
     if (bRead == null)
     {
         LogMgr.WriteErrorDefSys("GetCfg RecBuf is Null");
         return(false);
     }
     return(GLLedProtocol.AnalyeseRecSetCardCfg(bRead, iAddr));
 }
예제 #6
0
 public bool ReadLedDotValString(int iAddr, ref string strVals)
 {
     ClearOldReadBuf();
     byte[] bBuf = GLLedProtocol.MakeCmdLedGetDecimal(iAddr);
     Write(bBuf, 0, bBuf.Length);
     Thread.Sleep(1000);
     byte[] bRead = Read();
     if (bRead == null)
     {
         LogMgr.WriteErrorDefSys("GetCfg RecBuf is Null");
         return(false);
     }
     return(GLLedProtocol.AnalyeseRecGetDecmailString(bRead, ref strVals));
 }
예제 #7
0
 /// <summary>
 /// 设置油价牌卡上的小数点
 /// </summary>
 /// <param name="iAddr">ID</param>
 /// <param name="iArrDecmails">每块牌上的小数点位置(一个控制卡可以接N个显示屏)</param>
 /// <returns></returns>
 public bool SetCardDecmial(int iAddr, int[] iArrDecmails)
 {
     ClearOldReadBuf();
     byte[] bBuf = GLLedProtocol.MakeCmdLedSetDecimal(iAddr, iArrDecmails);
     Write(bBuf, 0, bBuf.Length);
     Thread.Sleep(1000);
     byte[] bRead = Read();
     if (bRead == null)
     {
         LogMgr.WriteErrorDefSys("GetCfg RecBuf is Null");
         return(false);
     }
     return(GLLedProtocol.AnalyeseRecSetDecemil(bRead, iAddr));
 }
예제 #8
0
 /// <summary>
 /// 读取油价牌的内容
 /// </summary>
 /// <param name="iAddr"></param>
 /// <param name="objOilVal"></param>
 /// <returns></returns>
 public bool ReadOilVal(int iAddr, ref List <GlareLedSysDefPub.CardGasValEachNumAByte> lstOilVal)
 {
     ClearOldReadBuf();
     byte[] bBuf = GLLedProtocol.MakeCmdLedGetOilVal(iAddr);
     Write(bBuf, 0, bBuf.Length);
     Thread.Sleep(1000);
     byte[] bRead = Read();
     if (bRead == null)
     {
         LogMgr.WriteErrorDefSys("GetCfg RecBuf is Null");
         return(false);
     }
     return(GLLedProtocol.AnalyeseRecGetOilVal(bRead, iAddr, ref lstOilVal));
 }
예제 #9
0
 /// <summary>
 /// 设置卡的参数
 /// </summary>
 /// <param name="iAddr">卡ID</param>
 /// <param name="objCardCfg">参数</param>
 /// <returns></returns>
 public bool SetCfg(int iAddr, GlareLedSysDefPub.GasCardCfg objCardCfg)
 {
     ClearOldReadBuf();
     byte[] bBuf = GLLedProtocol.MakeCmdLedSetCfg(iAddr, objCardCfg);
     Write(bBuf, 0, bBuf.Length);
     Thread.Sleep(1000);
     byte[] bRead = Read();
     if (bRead == null)
     {
         LogMgr.WriteErrorDefSys("GetCfg RecBuf is Null");
         return(false);
     }
     return(GLLedProtocol.AnalyeseRecSetCardCfg(bRead, iAddr));
 }
예제 #10
0
        static public byte[] MakeGetTempture(int iID)
        {
            List <byte> lstCmd = new List <byte>();

            lstCmd.Add(0xfe);
            lstCmd.Add(0xff);
            lstCmd.Add(0);    // 命令长度
            lstCmd.Add(0x23); //
            lstCmd.Add((byte)iID);
            lstCmd[2] = (byte)(lstCmd.Count - 3 + 2);
            byte bMakcScheckSum = GLLedProtocol.MakeCheckSum(lstCmd.ToArray(), 2, lstCmd.Count);

            lstCmd.Add(bMakcScheckSum);
            lstCmd.Add(0xfe);
            return(lstCmd.ToArray());
        }
예제 #11
0
        public bool SendOilContext(int iAddr, IList <string> lstStrings)
        {
            ClearOldReadBuf();
            IList <GlareLedSysDefPub.CardGasValEachNumAByte> lstOilVals = GLLedProtocol.MakeOilValBytesByString(lstStrings);

            byte[] bBuf = GLLedProtocol.MakeCmdLedSetOilVal(iAddr, lstOilVals);
            Write(bBuf, 0, bBuf.Length);
            Thread.Sleep(1000);
            byte[] bRead = Read();
            if (bRead == null)
            {
                LogMgr.WriteErrorDefSys("SendOilContext RecBuf is Null");
                return(false);
            }
            return(GLLedProtocol.AnalyeseRecSetOilVal(bRead, iAddr));
        }
예제 #12
0
 public bool ReadLedDotValString(int iAddr, ref string strVals)
 {
     try
     {
         ClearOldReadBuf();
         bool   bError = false;
         byte[] bBuf   = GLLedProtocol.MakeCmdLedGetDecimal(iAddr);
         Write(bBuf, 0, bBuf.Length);
         Thread.Sleep(100);
         byte[] bRead = Read(out bError);
         return(GLLedProtocol.AnalyeseRecGetDecmailString(bRead, ref strVals));
     }
     catch (System.Exception ex)
     {
         LogMgr.WriteInfoDefSys("读写异常" + ex.Message);
         return(false);
     }
 }
예제 #13
0
        public static byte[] MakeSetCfg(int iID, int iTmp, int iDigCount, int iBrightness)
        {
            List <byte> lstCmd = new List <byte>();

            lstCmd.Add(0xfe);
            lstCmd.Add(0xff);
            lstCmd.Add(0);                 // 命令长度
            lstCmd.Add(0x20);              //
            lstCmd.Add((byte)iID);
            lstCmd.Add((byte)iTmp);        //
            lstCmd.Add((byte)iDigCount);   //
            lstCmd.Add((byte)iBrightness); //
            lstCmd[2] = (byte)(lstCmd.Count - 3 + 2);
            byte bMakcScheckSum = GLLedProtocol.MakeCheckSum(lstCmd.ToArray(), 2, lstCmd.Count);

            lstCmd.Add(bMakcScheckSum);
            lstCmd.Add(0xfe);
            return(lstCmd.ToArray());
        }
예제 #14
0
        static public bool AnalyseGetTime(byte[] pBufRec, int iBufLen, ref DateTime dt)
        {
            byte bCmdType = GlareLedSysDefPub.GasCardDef.BT_CmdGetTime;

            if (pBufRec[0] != GlareLedSysDefPub.GasCardDef.BT_CmdStart &&
                pBufRec[1] != GlareLedSysDefPub.GasCardDef.BT_RecCmdStart &&
                pBufRec[GlareLedSysDefPub.GasCardDef.CmdOffsetOfTypeSection] != bCmdType &&
                pBufRec[pBufRec.Length - 1] != GlareLedSysDefPub.GasCardDef.BT_CmdEnd)
            {
                LogMgr.WriteErrorDefSys("命令码不对");
                return(false);
            }

            if (!GLLedProtocol.IsCheckSumCorrect(pBufRec, pBufRec[pBufRec.Length - 2]))
            {
                LogMgr.WriteErrorDefSys("校验错了");
                return(false);
            }

            return(true);
        }
예제 #15
0
        /// <summary>
        /// 构造同步时间的命令
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        static public byte[] MakeSyncTime(int id, DateTime dtSet)
        {
            List <byte> lstCmd = new List <byte>();

            lstCmd.Add(0xfe);
            lstCmd.Add(0xff);
            lstCmd.Add(0);    // 命令长度
            lstCmd.Add(0x21); //
            lstCmd.Add((byte)id);
            lstCmd.Add((byte)(dtSet.Year % 100));
            lstCmd.Add((byte)(dtSet.Month));
            lstCmd.Add((byte)(dtSet.Day));
            lstCmd.Add((byte)(dtSet.Hour));
            lstCmd.Add((byte)(dtSet.Minute));
            lstCmd.Add((byte)(dtSet.Second));
            lstCmd[2] = (byte)(lstCmd.Count - 3 + 2);
            byte bMakcScheckSum = GLLedProtocol.MakeCheckSum(lstCmd.ToArray(), 2, lstCmd.Count);

            lstCmd.Add(bMakcScheckSum);
            lstCmd.Add(0xfe);
            return(lstCmd.ToArray());
        }
예제 #16
0
 public bool ReadOilVal(int iAddr, ref List <GlareLedSysDefPub.CardGasValEachNumAByte> lstOilVal)
 {
     try
     {
         ClearOldReadBuf();
         bool   bError = false;
         byte[] bBuf   = GLLedProtocol.MakeCmdLedGetOilVal(iAddr);
         Write(bBuf, 0, bBuf.Length);
         Thread.Sleep(1000);
         byte[] bRead = Read(out bError);
         if (bRead != null)
         {
             LogMgr.WriteInfoDefSys("recbuf bytes:" + BitConverter.ToString(bRead));
         }
         return(GLLedProtocol.AnalyeseRecGetOilVal(bRead, iAddr, ref lstOilVal));
     }
     catch (System.Exception ex)
     {
         LogMgr.WriteInfoDefSys("Write Exception" + ex.Message);
         return(false);
     }
 }
예제 #17
0
 public bool GetLedCfg(int iAddr, ref CardCfgByJson cfg)
 {
     lock (this)
     {
         try
         {
             bool bError = false;
             ClearOldReadBuf();
             GlareLedSysDefPub.GasCardCfg cardcfg = new GlareLedSysDefPub.GasCardCfg();
             byte[] bBuf = GLLedProtocol.MakeCmdLedGetCfg(iAddr);
             Write(bBuf, 0, bBuf.Length);
             LogMgr.WriteInfoDefSys("send to dev:" + BitConverter.ToString(bBuf));
             Thread.Sleep(100);
             byte[] bRead = Read(out bError);
             bool   bRet  = GLLedProtocol.AnalyeseRecGetCfg(bRead, iAddr, ref cardcfg);
             if (bRet)
             {
                 cfg.bDobule       = cardcfg.bDobule;
                 cfg.bShowAppend   = cardcfg.bShowAppend;
                 cfg.iCardDigCount = cardcfg.iCardDigCount;
                 cfg.iCardType     = cardcfg.iCardType;
                 cfg.iFirmVer      = cardcfg.iFirmVer;
                 cfg.iHardVer      = cardcfg.iHardVer;
                 cfg.iID           = cardcfg.iID;
                 cfg.iLight        = cardcfg.iLight;
                 cfg.iScreenCount  = cardcfg.iScreenCount;
                 return(true);
             }
             return(false);
         }
         catch (System.Exception ex)
         {
             LogMgr.WriteInfoDefSys("读写异常" + ex.Message);
             return(false);
         }
     }
 }
예제 #18
0
 public bool ReadOilValString(int iAddr, ref string strVals)
 {
     lock (this)
     {
         try
         {
             byte[] bBuf = GLLedProtocol.MakeCmdLedGetOilVal(iAddr);
             Write(bBuf, 0, bBuf.Length);
             Thread.Sleep(100);
             bool   bError = false;
             byte[] bRead  = Read(out bError);
             if (bRead != null)
             {
                 LogMgr.WriteInfoDefSys("recbuf bytes:" + BitConverter.ToString(bRead));
             }
             return(GLLedProtocol.AnalyeseRecGetOilValString(bRead, iAddr, ref strVals));
         }
         catch (System.Exception ex)
         {
             LogMgr.WriteInfoDefSys("读写异常" + ex.Message);
             return(false);
         }
     }
 }