Esempio n. 1
0
        public StatusPack getStatus()
        {
            StatusPack stausPack = new StatusPack();

            Send(Cmds.GET_STATUS_STAT);


            Receive(ref readBuff);

            if (!(readBuff[2] == 0x70))
            {
                Receive(ref readBuff);
            }


            if (readBuff[2] == 0x70 && readBuff[3] == 0x00)
            {
                stausPack.okPrintCount = BitConverter.ToInt32(readBuff, 4);
                stausPack.printCount   = BitConverter.ToInt32(readBuff, 8);

                switch (readBuff[19])
                {
                case Cmds.NOT_PRINTING_MODE:

                    stausPack.isPrinting     = false;
                    stausPack.printIsStarted = false;

                    break;

                case Cmds.PRINTING_WAITING_SIGNAL_MODE:

                    stausPack.isPrinting     = false;
                    stausPack.printIsStarted = true;

                    break;

                case Cmds.ACTUALLY_PRINTING_MODE:

                    stausPack.isPrinting     = true;
                    stausPack.printIsStarted = true;

                    break;
                }

                if ((readBuff[28] == Cmds.ALARMSACTIVE) || (readBuff[28] == Cmds.HARDWAERFAULURE))
                {
                    stausPack.isAlarm   = true;
                    stausPack.alarmCode = readBuff[30];
                }
                else
                {
                    stausPack.isAlarm = false;
                }
            }



            return(stausPack);
        }
Esempio n. 2
0
        /// <summary>
        /// Выполнить сеанс опроса КП
        /// </summary>
        public override void Session()
        {
            if (writeState)
            {
                WriteToLog("");
                WriteToLog(state);
                writeState = false;
            }

            kpStats.SessCnt++;

            if (config.CheckTimeSession)
            {
                startSessionTime = DateTime.Now;
            }



            SetCurData(1, laser.reqActualNum(1), 1);
            Thread.Sleep(config.ReqDelay);

            SetCurData(2, laser.reqActualNum(2), 1);
            Thread.Sleep(config.ReqDelay);

            StatusPack status = laser.getStatus();

            Thread.Sleep(config.ReqDelay);

            SetCurData(3, status.printCount, 1);
            SetCurData(4, status.okPrintCount, 1);
            SetCurData(5, Convert.ToDouble(status.printIsStarted), 1);

            if (!status.isPrinting && isPrintingCount > 0)
            {
                isPrintingCount--;
            }
            if (status.isPrinting)
            {
                isPrintingCount = 5;
                SetCurData(6, Convert.ToDouble(status.isPrinting), 1);
            }

            if (!status.isPrinting && isPrintingCount <= 0)
            {
                SetCurData(6, Convert.ToDouble(status.isPrinting), 1);
            }


            SetCurData(7, Convert.ToDouble(status.isAlarm), 1);
            SetCurData(8, Convert.ToDouble(status.alarmCode), 1);
            SetCurData(9, Convert.ToDouble(liveBit = !liveBit), 1);


            if (config.CheckTimeSession)
            {
                SetCurData(10, Convert.ToDouble(DateTime.Now.Subtract(startSessionTime).Ticks / 10000), 1);
            }
        }