Exemplo n.º 1
0
 public bool cHJTempBoardIni()
 {
     mHJBoardInit = mStandarBoard.StandarBoardInit();
     if (!mHJBoardInit)
     {
         if (errStr.IndexOf(mStandarBoard.ErrStr) < 0)
         {
             errStr = errStr + mStandarBoard.ErrStr;
         }
     }
     return(mHJBoardInit);
 }
Exemplo n.º 2
0
        /// <summary>
        /// FT2010初始化
        /// </summary>
        /// <returns>bool,返回初始结果</returns>
        public bool Ft2010Init()
        {
            mFt2010Init = mStandarBoard.StandarBoardInit();
            if (!mFt2010Init)
            {
                if (errStr.IndexOf(mStandarBoard.ErrStr) < 0)
                {
                    errStr = errStr + mStandarBoard.ErrStr;
                }
            }
            return(mFt2010Init);

            /*
             * if (cMain.isDebug)
             * {
             *  mFt2010Init = true;
             *  return true;
             * }
             * byte[] WriteBuff = new byte[10];//发送数据
             * byte[] ReadBuff = new byte[20];//接收数据
             * int ReturnByte = 0;//返回数据
             * bool IsReturn = false;//是否成功返回
             * bool IsTimeOut = false;//是否超时
             * DateTime NowTime = DateTime.Now;//当前时间
             * TimeSpan ts;//时间差
             * byte CrcHi = 0, CrcLo = 0;//CRC校验
             * try
             * {
             *  if (!comPort.IsOpen)
             *  {
             *      comPort.Open();
             *  }
             *  WriteBuff[0] = (byte)(Ft2010Address & 0xFF);
             *  WriteBuff[1] = 0x03;
             *  WriteBuff[2] = 0x00;
             *  WriteBuff[3] = 0x00;
             *  WriteBuff[4] = 0x00;
             *  WriteBuff[5] = 0x01;
             *  cMain.CRC_16(WriteBuff, 6, ref CrcLo, ref CrcHi);
             *  WriteBuff[6] = CrcLo;
             *  WriteBuff[7] = CrcHi;
             *  comPort.DiscardOutBuffer();
             *  comPort.Write(WriteBuff, 0, 8);
             *  NowTime = DateTime.Now;
             *  do
             *  {
             *      if (comPort.BytesToRead >= WriteBuff[5] * 2 + 5)//收到数据
             *      {
             *          ReturnByte = comPort.BytesToRead;
             *          IsReturn = true;
             *      }
             *      ts = DateTime.Now - NowTime;
             *      if (ts.TotalMilliseconds > timeOut)//时间超时
             *      {
             *          IsTimeOut = true;
             *      }
             *  } while (!IsReturn && !IsTimeOut);
             *  if (!IsReturn && IsTimeOut)//超时
             *  {
             *      if (ErrStr.IndexOf("接收数据已超时") < 0)
             *      {
             *          ErrStr = ErrStr + DateTime.Now.ToString() + mName + mName + ":初始失败,接收数据已超时" + (char)13 + (char)10;
             *      }
             *
             *      return false;
             *  }
             *  else
             *  {
             *      comPort.Read(ReadBuff, 0, ReturnByte);
             *      if ((ReadBuff[0] != WriteBuff[0]) || (ReadBuff[1] != WriteBuff[1]))//数据检验失败
             *      {
             *           if (ErrStr.IndexOf("接收数据错误") < 0)
             *          {
             *              ErrStr = ErrStr + DateTime.Now.ToString() + mName + ":初始失败,接收数据错误" + (char)13 + (char)10;
             *          }
             *          return false;
             *      }
             *      else
             *      {
             *          mFt2010Init = true;
             *      }
             *  }
             * }
             * catch (Exception exc)
             * {
             *  if (ErrStr.IndexOf(exc.ToString()) < 0)
             *  {
             *      ErrStr = ErrStr + DateTime.Now.ToString() + mName + ":" + exc.ToString() + (char)13 + (char)10;
             *  }
             *  return false;
             * }
             * return true;
             * */
        }