示例#1
0
 private void CCT_Send(int idx)
 {
     if (sm != null)
     {
         int          i            = 0;
         CCTEventArgs cCTEventArgs = new CCTEventArgs(msgTxLen[idx]);
         sm.ResetRecIdx();
         if (bEchoEnabled)
         {
             bWaitForEcho    = true;
             sm.SetRecThresh = msgTxLen[idx];
         }
         sm.Transmit(cct_tx[idx], msgTxLen[idx]);
         for (; i < msgTxLen[idx]; i++)
         {
             cCTEventArgs.buf[i] = cct_tx[idx][i];
         }
         cCTEventArgs.CCTEvType = 0;
         tTimeOut.Interval      = 200.0;
         tTimeOut.Start();
         if (this.OnCCTTxData != null)
         {
             this.OnCCTTxData(this, cCTEventArgs);
         }
     }
 }
示例#2
0
        private void tTimeOut_Elapsed(object sender, ElapsedEventArgs e)
        {
            CCTEventArgs cCTEventArgs = new CCTEventArgs(3);

            tTimeOut.Stop();
            int num = 0;

            while (num < 3)
            {
                cCTEventArgs.buf[num++] = 42;
            }
            cCTEventArgs.CCTEvType = 2;
            if (this.OnCCTRxData != null)
            {
                this.OnCCTRxData(this, cCTEventArgs);
            }
        }
示例#3
0
        private void datarec(object sender, SerialDataReceivedEventArgs ev)
        {
            int          receivedBytesThreshold = ser.ReceivedBytesThreshold;
            CCTEventArgs e = new CCTEventArgs(idxIn, idxIn + receivedBytesThreshold);

            if (ev.EventType == SerialData.Chars)
            {
                ser.Read(rxBuff, idxIn, receivedBytesThreshold);
                idxIn += receivedBytesThreshold;
                try
                {
                    this.OnReceivedData(sender, e);
                }
                catch
                {
                }
            }
        }
示例#4
0
 private void sm_OnReceivedData(object sender, CCTEventArgs e)
 {
     for (int i = e.idxStart; i < e.idxEnd; i++)
     {
         cct_rx[i] = sm.GetRxByte(i);
     }
     if (bWaitForEcho)
     {
         bWaitForEcho = false;
         e.msgChk     = CCT_VerifyChecksum(e.nData);
         for (int i = 0; i < e.idxEnd; i++)
         {
             e.buf[i] = cct_rx[i];
         }
         e.CCTEvType = 1;
         if (this.OnCCTRxData != null)
         {
             this.OnCCTRxData(this, e);
         }
         sm.ResetRecIdx();
         return;
     }
     e.CCTEvType = 2;
     if (e.idxStart == 0)
     {
         if (cct_rx[1] == 0)
         {
             e.msgChk = CCT_VerifyChecksum(e.nData);
             for (int i = 0; i < e.idxEnd; i++)
             {
                 e.buf[i] = cct_rx[i];
             }
             tTimeOut.Stop();
             if (this.OnCCTRxData != null)
             {
                 this.OnCCTRxData(this, e);
             }
             sm.ResetRecIdx();
             return;
         }
         int num = cct_rx[1] - sm.SaveBufferContent();
         if (num > 0)
         {
             sm.SetRecThresh = num;
             return;
         }
         for (int i = e.idxEnd; i < e.idxEnd + cct_rx[1]; i++)
         {
             cct_rx[i] = sm.GetRxByte(i);
         }
         e.idxEnd += cct_rx[1];
         e.nData   = e.idxEnd;
         e.msgChk  = CCT_VerifyChecksum(e.nData);
         for (int i = 0; i < e.idxEnd; i++)
         {
             e.buf[i] = cct_rx[i];
         }
         tTimeOut.Stop();
         if (this.OnCCTRxData != null)
         {
             this.OnCCTRxData(this, e);
         }
         sm.ResetRecIdx();
     }
     else
     {
         for (int i = 0; i < e.idxEnd; i++)
         {
             cct_rx[i] = sm.GetRxByte(i);
         }
         e.msgChk = CCT_VerifyChecksum(e.idxEnd);
         for (int i = 0; i < e.idxEnd; i++)
         {
             e.buf[i] = cct_rx[i];
         }
         e.nData = e.idxEnd;
         tTimeOut.Stop();
         if (this.OnCCTRxData != null)
         {
             this.OnCCTRxData(this, e);
         }
         sm.ResetRecIdx();
     }
 }
示例#5
0
 private void cct_OnCCTTxData(object sender, CCTEventArgs e)
 {
     if (sm != null)
     {
     }
 }
示例#6
0
        private void cct_OnCCTRxData(object sender, CCTEventArgs e)
        {
            if (sm == null)
            {
                return;
            }
            string text = "";

            for (int i = 0; i < e.nData; i++)
            {
                text += $"{e.buf[i]:X} ";
            }
            if (e.nData >= 16)
            {
                TimeOutComs = 0;
                if (Ult_ser != e.buf[4])
                {
                    Ult_ser = e.buf[4];
                    if (e.buf[6] == 1)
                    {
                        bill = byte.MaxValue;
                        if (e.buf[5] < 15)
                        {
                            CreateCmdString(new byte[5]
                            {
                                40,
                                1,
                                1,
                                154,
                                1
                            }, send: true);
                            confirm_OK = true;
                        }
                        else
                        {
                            CreateCmdString(new byte[5]
                            {
                                40,
                                1,
                                1,
                                154,
                                0
                            }, send: true);
                            confirm_OK = false;
                        }
                    }
                    else if (e.buf[6] == 0 && e.buf[8] == 1 && confirm_OK)
                    {
                        CreateCmdString(new byte[5]
                        {
                            40,
                            1,
                            1,
                            154,
                            1
                        }, send: true);
                        confirm_OK = false;
                        bill       = e.buf[5];
                        if (bill > 0 && bill < 15 && NoMoney == 0 && Canal[bill - 1] > 0)
                        {
                            m_Creditos = Canal[bill - 1];
                        }
                    }
                }
            }
            if (e.CCTEvType == 2 && !bFoundAcceptor && CheckForAnswer(text) && text != "28 0 31 9F 5D " && text[0] == '1' && text[1] == ' ' && text[2] == 'B')
            {
                bFoundAcceptor = true;
            }
        }