예제 #1
0
 static void Main()
 {
     mng = new WSMng();
     if (sysModel == 1)
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(new FrmLed());
     }
     else if (sysModel == 0)
     {
         //WINDOWS服务启动
         try
         {
             ServiceBase[] servicesToRun;
             servicesToRun = new ServiceBase[] { new LedEqpService() };
             ServiceBase.Run(servicesToRun);
         }
         catch (Exception ex)
         {
             try
             {
                 CWSException.WriteError("服务开启异常:" + ex.ToString());
             }
             catch { }
         }
     }
     else
     {
         MessageBox.Show("请配置sysModel为O或1");
     }
 }
예제 #2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            #region
            if (!isStart)
            {
                isStart          = true;
                btnStop.Enabled  = true;
                btnStart.Enabled = false;

                try
                {
                    Led1Thread = new Thread(new ThreadStart(DealLed1Message));
                    Led1Thread.Start();
                }
                catch (Exception ex)
                {
                    CWSException.WriteError("LED1线程启动异常:" + ex.ToString());
                }

                try
                {
                    Led2Thread = new Thread(new ThreadStart(DealLed2Message));
                    Led2Thread.Start();
                }
                catch (Exception ex)
                {
                    CWSException.WriteError("LED2线程启动异常:" + ex.ToString());
                }

                try
                {
                    Led3Thread = new Thread(new ThreadStart(DealLed3Message));
                    Led3Thread.Start();
                }
                catch (Exception ex)
                {
                    CWSException.WriteError("LED3线程启动异常:" + ex.ToString());
                }

                try
                {
                    Led4Thread = new Thread(new ThreadStart(DealLed4Message));
                    Led4Thread.Start();
                }
                catch (Exception ex)
                {
                    CWSException.WriteError("LED4线程启动异常:" + ex.ToString());
                }
            }
            #endregion
        }
예제 #3
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     #region
     isStart          = false;
     btnStop.Enabled  = false;
     btnStart.Enabled = true;
     bool isStop = true;
     try
     {
         isStop = isStop & Led1Thread.Join(200);
     }
     catch (Exception ex)
     {
         CWSException.WriteError(ex.ToString());
     }
     try
     {
         isStop = isStop & Led2Thread.Join(200);
     }
     catch (Exception ex)
     {
         CWSException.WriteError(ex.ToString());
     }
     try
     {
         isStop = isStop & Led3Thread.Join(200);
     }
     catch (Exception ex)
     {
         CWSException.WriteError(ex.ToString());
     }
     try
     {
         isStop = isStop & Led4Thread.Join(200);
     }
     catch (Exception ex)
     {
         CWSException.WriteError(ex.ToString());
     }
     if (isStop)
     {
         CWSException.WriteError("LED线程已全部停止!");
     }
     else
     {
         CWSException.WriteError("LED线程未全部停止!");
     }
     #endregion
 }
예제 #4
0
        protected override void OnStart(string[] args)
        {
            #region
            if (!isStart)
            {
                isStart = true;

                try
                {
                    Led1Thread = new Thread(new ThreadStart(DealLed1Message));
                    Led1Thread.Start();
                }
                catch (Exception ex)
                {
                    CWSException.WriteError("LED1线程启动异常:" + ex.ToString());
                }

                try
                {
                    Led2Thread = new Thread(new ThreadStart(DealLed2Message));
                    Led2Thread.Start();
                }
                catch (Exception ex)
                {
                    CWSException.WriteError("LED2线程启动异常:" + ex.ToString());
                }

                try
                {
                    Led3Thread = new Thread(new ThreadStart(DealLed3Message));
                    Led3Thread.Start();
                }
                catch (Exception ex)
                {
                    CWSException.WriteError("LED3线程启动异常:" + ex.ToString());
                }

                try
                {
                    Led4Thread = new Thread(new ThreadStart(DealLed4Message));
                    Led4Thread.Start();
                }
                catch (Exception ex)
                {
                    CWSException.WriteError("LED4线程启动异常:" + ex.ToString());
                }
            }
            #endregion
        }
예제 #5
0
 protected override void OnStop()
 {
     #region
     isStart = false;
     bool isStop = true;
     try
     {
         isStop = isStop & Led1Thread.Join(200);
     }
     catch (Exception ex)
     {
         CWSException.WriteError(ex.ToString());
     }
     try
     {
         isStop = isStop & Led2Thread.Join(200);
     }
     catch (Exception ex)
     {
         CWSException.WriteError(ex.ToString());
     }
     try
     {
         isStop = isStop & Led3Thread.Join(200);
     }
     catch (Exception ex)
     {
         CWSException.WriteError(ex.ToString());
     }
     try
     {
         isStop = isStop & Led4Thread.Join(200);
     }
     catch (Exception ex)
     {
         CWSException.WriteError(ex.ToString());
     }
     if (isStop)
     {
         CWSException.WriteError("LED线程已全部停止!");
     }
     else
     {
         CWSException.WriteError("LED线程未全部停止!");
     }
     #endregion
 }
예제 #6
0
        private void DealLed4Message()
        {
            #region
            while (isStart)
            {
                try
                {
                    int total;
                    int space;
                    int occupy;
                    int fixLct;
                    int spaceBigLct;
                    Program.mng.SelectLctofInfo(out total, out space, out occupy, out fixLct, out spaceBigLct);

                    CMasterTask[] mtsks   = Program.mng.GetAllMasterTaskOfHid(14);
                    string        dataStr = "";
                    CSMG          hall    = Program.mng.SelectSMG(14);
                    if (hall.Available)
                    {
                        #region 作业
                        if (hall.nIsWorking != 0)
                        {
                            CMasterTask gmtsk = null;
                            if (mtsks != null)
                            {
                                foreach (CMasterTask mtsk in mtsks)
                                {
                                    foreach (CTask tsk in mtsk.Tasks)
                                    {
                                        if (hall.nIsWorking == tsk.ID)
                                        {
                                            gmtsk = mtsk;
                                        }
                                    }
                                }
                            }
                            if (gmtsk != null)
                            {
                                if (gmtsk.ICCardCode != "")
                                {
                                    if (gmtsk.Type == EnmMasterTaskType.GetCar)
                                    {
                                        dataStr = "当前取车卡号:" + gmtsk.ICCardCode;
                                    }
                                    else if (gmtsk.Type == EnmMasterTaskType.SaveCar)
                                    {
                                        dataStr = "当前存车卡号:" + gmtsk.ICCardCode;
                                    }
                                    else
                                    {
                                        dataStr = "当前作业卡号:" + gmtsk.ICCardCode;
                                    }
                                }
                            }
                        }
                        else
                        {
                            dataStr = "剩余空闲车位:" + space.ToString() + "  其中大车位:" + spaceBigLct.ToString();
                        }
                        #endregion
                    }
                    else
                    {
                        dataStr = " 正在维护,请稍后存取车";
                    }

                    if (dataStr != "")
                    {
                        if (string.Compare(dataStr, dataStr4) != 0)
                        {
                            myDelegate.DisplayLed4Title(dataStr);
                            dataStr4 = dataStr;
                        }
                    }

                    if (isStart)
                    {
                        Thread.Sleep(1000);
                    }
                }
                catch (Exception ex)
                {
                    CWSException.WriteError(ex.ToString());
                    Thread.Sleep(10000);
                }
            }
            #endregion
        }
예제 #7
0
        public FrmLed()
        {
            InitializeComponent();

            #region LED
            byte effect = Convert.ToByte(pEffcetNum);
            byte rate   = Convert.ToByte(pRate);
            byte stime  = Convert.ToByte(pSingleTime);
            byte ttime  = Convert.ToByte(pTotalTime);

            led1 = new CLedShow(Convert.ToByte(pLed1Address), effect, rate, stime, ttime);
            led2 = new CLedShow(Convert.ToByte(pLed2Address), effect, rate, stime, ttime);
            led3 = new CLedShow(Convert.ToByte(pLed3Address), effect, rate, stime, ttime);
            led4 = new CLedShow(Convert.ToByte(pLed4Address), effect, rate, stime, ttime);

            #region LED通讯端口初始化
            try
            {
                port_Led1                 = new SerialPort();
                port_Led1.PortName        = "COM" + portNum_Led1;
                port_Led1.BaudRate        = 9600;
                port_Led1.DataBits        = 8;
                port_Led1.Handshake       = Handshake.None;
                port_Led1.DiscardNull     = false;
                port_Led1.StopBits        = StopBits.One;
                port_Led1.WriteBufferSize = 4096;
                port_Led1.WriteTimeout    = -1;
                if (port_Led1.IsOpen)
                {
                    port_Led1.Close();
                }
                port_Led1.Open();
            }
            catch (Exception ex)
            {
                CWSException.WriteError("SerialPort_LED1端口初始化异常:" + ex.ToString());
            }

            //try
            //{
            //    port_Led2 = new SerialPort();
            //    port_Led2.PortName = "COM" + portNum_Led2;
            //    port_Led2.BaudRate = 9600;
            //    port_Led2.DataBits = 8;
            //    port_Led2.Handshake = Handshake.None;
            //    port_Led2.DiscardNull = false;
            //    port_Led2.StopBits = StopBits.One;
            //    port_Led2.WriteBufferSize = 4096;
            //    port_Led2.WriteTimeout = -1;
            //    if (port_Led2.IsOpen)
            //    {
            //        port_Led2.Close();
            //    }
            //    port_Led2.Open();
            //}
            //catch (Exception ex)
            //{
            //    CWSException.WriteError("SerialPort_LED2端口初始化异常:" + ex.ToString());
            //}

            try
            {
                port_Led3                 = new SerialPort();
                port_Led3.PortName        = "COM" + portNum_Led3;
                port_Led3.BaudRate        = 9600;
                port_Led3.DataBits        = 8;
                port_Led3.Handshake       = Handshake.None;
                port_Led3.DiscardNull     = false;
                port_Led3.StopBits        = StopBits.One;
                port_Led3.WriteBufferSize = 4096;
                port_Led3.WriteTimeout    = -1;
                if (port_Led3.IsOpen)
                {
                    port_Led3.Close();
                }
                port_Led3.Open();
            }
            catch (Exception ex)
            {
                CWSException.WriteError("SerialPort_LED3端口初始化异常:" + ex.ToString());
            }

            //try
            //{
            //    port_Led4 = new SerialPort();
            //    port_Led4.PortName = "COM" + portNum_Led4;
            //    port_Led4.BaudRate = 9600;
            //    port_Led4.DataBits = 8;
            //    port_Led4.Handshake = Handshake.None;
            //    port_Led4.DiscardNull = false;
            //    port_Led4.StopBits = StopBits.One;
            //    port_Led4.WriteBufferSize = 4096;
            //    port_Led4.WriteTimeout = -1;
            //    if (port_Led4.IsOpen)
            //    {
            //        port_Led4.Close();
            //    }
            //    port_Led4.Open();
            //}
            //catch (Exception ex)
            //{
            //    CWSException.WriteError("SerialPort_LED4端口初始化异常:" + ex.ToString());
            //}
            #endregion
            #endregion
            myDelegate = new CDelegate();
            myDelegate.DisplayLed1TitleEvent += new DisplayLed1TitleDelegate(myDelegate_DisplayLed1TitleEvent);
            myDelegate.DisplayLed2TitleEvent += new DisplayLed2TitleDelegate(myDelegate_DisplayLed2TitleEvent);
            myDelegate.DisplayLed3TitleEvent += new DisplayLed3TitleDelegate(myDelegate_DisplayLed3TitleEvent);
            myDelegate.DisplayLed4TitleEvent += new DisplayLed4TitleDelegate(myDelegate_DisplayLed4TitleEvent);
        }