Пример #1
0
        public CControlCentral()
        {
            mControlBoard = new CControlBoard();
            mBoardInfo    = new CControlBoardInfo();

            queSendingCommands = new Queue <CCommandQueueItem>();
            bgw_RS232          = new BackgroundWorker();
            bgw_RS232.WorkerReportsProgress      = true;
            bgw_RS232.WorkerSupportsCancellation = true;
            bgw_RS232.DoWork          += bgw_DoWork;
            bgw_RS232.ProgressChanged += bgw_ProgressChanged;
            bgw_RS232.RunWorkerAsync();
        }
        public CControlCentral()
        {
            mControlBoard = new CControlBoard();
            mBoardInfo = new CControlBoardInfo();

            queSendingCommands = new Queue<CCommandQueueItem>();
            bgw_RS232 = new BackgroundWorker();
            bgw_RS232.WorkerReportsProgress = true;
            bgw_RS232.WorkerSupportsCancellation = true;
            bgw_RS232.DoWork += bgw_DoWork;
            bgw_RS232.ProgressChanged += bgw_ProgressChanged;
            bgw_RS232.RunWorkerAsync();
        }
Пример #3
0
        /// <summary>
        /// 查询控制板数据
        /// </summary>
        /// <returns></returns>

        #endregion

        #region Public Methods
        public bool QueryStatus(ref CControlBoardInfo BoardInfo)
        {
#if DEBUG
            StringBuilder boardquery = new StringBuilder();
            Random        r          = new Random(DateTime.Now.Second + DateTime.Now.Millisecond);

            for (int i = 0; i < 8; i++)
            {
                // 随机产生治疗状态

                //double tmp = r.NextDouble();
                //if (tmp < 0.25)
                //    boardquery.Append("0");     // Standby
                //else if (tmp < 0.5)
                //    boardquery.Append("1");     // Curing
                //else if (tmp < 0.75)
                //    boardquery.Append("2");     // Heating
                //else
                //    boardquery.Append("e");     // Disconnected

                boardquery.Append("1");
                boardquery.Append(",");

                // 随机产生治疗带使用时间
                boardquery.Append(r.Next(1000).ToString());
                boardquery.Append(",");

                // 随机产生治疗带温度
                boardquery.Append(((40 + r.NextDouble() * 10) * 100).ToString("F0"));

                if (i < 7)
                {
                    boardquery.Append(";");
                }
            }

            BoardInfo.AnalyzeQuaryString(boardquery.ToString());

            return(true);
#else
            bool blnRet = false;
            try
            {
                port.WriteLine("Q?\r");
                string ret = port.ReadLine();
                ret = ret.Replace("\r", "").Replace("\n", "").Trim();
                BoardInfo.AnalyzeQuaryString(ret);
                blnRet        = true;
                intCommErrCnt = 0;
            }
            catch (Exception ex)
            {
                intCommErrCnt++;
                if (intCommErrCnt >= 10)
                {
                    strLastError = ex.Message;
                    blnRet       = false;
                }
                else
                {
                    blnRet = true;
                }
            }
            return(blnRet);
#endif
        }
        public bool QueryStatus(ref CControlBoardInfo BoardInfo)
        {
            #if DEBUG
             StringBuilder boardquery = new StringBuilder();
            Random r = new Random(DateTime.Now.Second + DateTime.Now.Millisecond);

            for (int i = 0; i < 8; i++)
            {
                // 随机产生治疗状态

                //double tmp = r.NextDouble();
                //if (tmp < 0.25)
                //    boardquery.Append("0");     // Standby
                //else if (tmp < 0.5)
                //    boardquery.Append("1");     // Curing
                //else if (tmp < 0.75)
                //    boardquery.Append("2");     // Heating
                //else
                //    boardquery.Append("e");     // Disconnected

                boardquery.Append("1");
                boardquery.Append(",");

                // 随机产生治疗带使用时间
                boardquery.Append(r.Next(1000).ToString());
                boardquery.Append(",");

                // 随机产生治疗带温度
                boardquery.Append(((40 + r.NextDouble() * 10) * 100).ToString("F0"));

                if (i < 7)
                    boardquery.Append(";");
            }

            BoardInfo.AnalyzeQuaryString(boardquery.ToString());

            return true;
            #else
            bool blnRet = false;
            try
            {
                port.WriteLine("Q?\r");
                string ret = port.ReadLine();
                ret = ret.Replace("\r", "").Replace("\n", "").Trim();
                BoardInfo.AnalyzeQuaryString(ret);
                blnRet = true;
                intCommErrCnt = 0;
            }
            catch (Exception ex)
            {
                intCommErrCnt++;
                if (intCommErrCnt >= 10)
                {
                    strLastError = ex.Message;
                    blnRet = false;
                }
                else
                {
                    blnRet = true;
                }
            }
            return blnRet;
            #endif
        }