Пример #1
0
        public bool InitialPump(char pumpType, string no)
        {
            if (th_overTimeSerialPort == null)
            {
                th_overTimeSerialPort = new Thread(OverTimer);
                th_overTimeSerialPort.Start();
                overtime_count       = 0;
                start_trig_overtime1 = false;
            }

            t_PumpInfo          = new PumpPara();
            t_PumpInfo.pumpType = pumpType.ToString();
            t_PumpInfo.no       = no;

            t_PumpInfo.setMaxPressure = 10;
            if (t_SerialPortCommu.ID == "Tauto")
            {
                t_PumpInfo.setMaxPressure = 10;
                //t_SerialPortCommu.pumpPort.DataReceived += new SerialDataReceivedEventHandler(TautoPumpPort_DataReceived);
                //return true;
            }
            else
            {
                if (t_SerialPortCommu.ID == "10")
                {
                    t_PumpInfo.setMaxPressure = 42;
                }
                else if (t_SerialPortCommu.ID == "11")
                {
                    t_PumpInfo.setMaxPressure = 25;
                }
                else if (t_SerialPortCommu.ID == "20")
                {
                    t_PumpInfo.setMaxPressure = 25;
                }
                t_PumpInfo.setMinPressure = 0;

                if (!PumpSerialPortSendData(0, 18, 20))
                {
                    return(false);
                }
                //if (!PumpSerialPortSendData(0, 13, 4200)) return false;
                if (!PumpSerialPortSendData(0, 14, 0))
                {
                    return(false);
                }
                if (!PumpSerialPortSendData(1, 19, pumpType - 'A' + 1))
                {
                    return(false);
                }
            }
            //t_SerialPortCommu.pumpPort.DataReceived += new SerialDataReceivedEventHandler(pumpPort_DataReceived);
            th_recvFromPumpSerialPort = new Thread(ReadPressure);
            th_recvFromPumpSerialPort.Start();
            th_sendToPumpSerialPort = new Thread(SetFlow);
            th_sendToPumpSerialPort.Start();


            return(true);
        }
Пример #2
0
 public void PumpInstanceDispose()
 {
     try
     {
         t_PumpInfo = new PumpPara();
         if (th_recvFromPumpSerialPort != null && th_recvFromPumpSerialPort.IsAlive)
         {
             th_recvFromPumpSerialPort.Abort();
         }
         if (th_sendToPumpSerialPort != null && th_sendToPumpSerialPort.IsAlive)
         {
             th_sendToPumpSerialPort.Abort();
         }
         if (th_overTimeSerialPort != null && th_overTimeSerialPort.IsAlive)
         {
             th_overTimeSerialPort.Abort();
         }
     }
     catch
     {
         return;
     }
 }