Example #1
0
        private void InsertMorningCheckData(byte[] morningCheckData)
        {
            try
            {
                DataFrame dataFrame = DataFrame.convertToFrame(morningCheckData);

                new MorningCheckInfoSystem().InsertMorningCheckInfo(dataFrame);

                comPortIsBusy = true;
                handleComClass.WriteSerialCmd(Form1.CONTROL_FRAME_LENGTH, responseFrame.convertToBytes());
                comPortIsBusy = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #2
0
        //问询指令
        private void SendQuery()
        {
            while (true)
            {
                if (!comPortIsBusy)
                {
                    if (machineAddrList != null)
                    {
                        if (machineAddrList.Tables[0].Rows.Count > 0)
                        {
                            foreach (DataRow machineAddr in machineAddrList.Tables[0].Rows)
                            {
                                ControlFrame controlFrame = new ControlFrame();
                                controlFrame.sym      = new byte[] { (byte)'*', (byte)'*' };
                                controlFrame.desAddr  = Convert.ToByte(machineAddr["machine_address"]);
                                controlFrame.srcAddr  = 0;
                                controlFrame.response = CPTT.SystemFramework.Util.QUERY_TOKEN;
                                controlFrame.seq      = CPTT.SystemFramework.Util.FRAME_SEQUENCE_VALUE;
                                controlFrame.computeCheckSum();

                                Monitor.Enter(handleComClass);
                                handleComClass.WriteSerialCmd(CPTT.SystemFramework.Util.CONTROL_FRAME_LENGTH, controlFrame.convertToBytes());                               //发送问询帧
                                Monitor.Exit(handleComClass);

//								Thread.Sleep(3000);
                                Thread.Sleep(CPTT.SystemFramework.Util.QUERY_TIMER_INTERVAL);
                            }

                            if (_lastSyncDate.AddMinutes(10) <= DateTime.Now)
                            {
                                foreach (DataRow machineAddr in machineAddrList.Tables[0].Rows)
                                {
                                    SynchDate(machineAddr["machine_address"]);
                                }

                                _lastSyncDate = DateTime.Now;
                            }
                        }
                        else
                        {
                            Thread.Sleep(CPTT.SystemFramework.Util.QUERY_NULL_INTERVAL);
                        }
                    }
                    else
                    {
                        Thread.Sleep(1000);
                    }

//					if ( _alAuthenticatedHardWare.Count > 0 )
//					{
//						foreach(object o in _alAuthenticatedHardWare)
//						{
//							ControlFrame controlFrame = new ControlFrame();
//							controlFrame.sym = new byte[]{(byte)'*',(byte)'*'};
//							controlFrame.desAddr = Convert.ToByte(o.ToString());
//							controlFrame.srcAddr = 0;
//							controlFrame.response = CPTT.SystemFramework.Util.QUERY_TOKEN;
//							controlFrame.seq = CPTT.SystemFramework.Util.FRAME_SEQUENCE_VALUE;
//							controlFrame.computeCheckSum();
//
//							Monitor.Enter(handleComClass);
//							handleComClass.WriteSerialCmd(CPTT.SystemFramework.Util.CONTROL_FRAME_LENGTH,controlFrame.convertToBytes());//发送问询帧
//							Monitor.Exit(handleComClass);
//
//							Thread.Sleep(CPTT.SystemFramework.Util.QUERY_TIMER_INTERVAL);
//						}
//					}
//					else Thread.Sleep(CPTT.SystemFramework.Util.QUERY_NULL_INTERVAL);
                }
            }
        }