Ejemplo n.º 1
0
        /// <summary>
        /// 卸载设备
        /// </summary>
        private void UnloadHardware()
        {
            // 注意此段代码
            Application.DoEvents();

            try
            {
                commonDAO.SetSignalDataValue(CommonAppConfig.GetInstance().AppIdentifier, eSignalDataName.当前车Id.ToString(), string.Empty);
                commonDAO.SetSignalDataValue(CommonAppConfig.GetInstance().AppIdentifier, eSignalDataName.当前车号.ToString(), string.Empty);
            }
            catch { }
            try
            {
                Hardwarer.Iocer.OnReceived     -= new IOC.JMDM20DIOV2.JMDM20DIOV2Iocer.ReceivedEventHandler(Iocer_Received);
                Hardwarer.Iocer.OnStatusChange -= new IOC.JMDM20DIOV2.JMDM20DIOV2Iocer.StatusChangeHandler(Iocer_StatusChange);

                Hardwarer.Iocer.CloseCom();
            }
            catch { }
            try
            {
                Hardwarer.Rwer1.CloseCom();
            }
            catch { }
            try
            {
                if (this.LED1ConnectStatus)
                {
                    YB14DynamicAreaLeder.SendDeleteDynamicAreasCommand(this.LED1nScreenNo, 1, "");
                    YB14DynamicAreaLeder.DeleteScreen(this.LED1nScreenNo);
                }
            }
            catch { }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新LED1动态区域
        /// </summary>
        /// <param name="value1">第一行内容</param>
        /// <param name="value2">第二行内容</param>
        /// <param name="value3">第三行内容</param>
        private void UpdateLed1Show(string value1 = "", string value2 = "", string value3 = "")
        {
            if (!this.LED1ConnectStatus)
            {
                return;
            }
            if (this.LED1PrevLedFileContent == value1 + value2 + value3)
            {
                return;
            }

            string ledContent = GenerateFillLedContent12(value1);

            File.WriteAllText(this.LED1TempFile, ledContent, Encoding.UTF8);

            ledContent = GenerateFillLedContent12(value2);
            File.WriteAllText(this.LED2TempFile, ledContent, Encoding.UTF8);

            ledContent = GenerateFillLedContent12(value3);
            File.WriteAllText(this.LED3TempFile, ledContent, Encoding.UTF8);

            if (LED1m_bSendBusy == false)
            {
                LED1m_bSendBusy = true;

                int nResult = YB14DynamicAreaLeder.SendDynamicAreaInfoCommand(this.LED1nScreenNo, this.LED1DYArea_ID1);
                nResult = YB14DynamicAreaLeder.SendDynamicAreaInfoCommand(this.LED1nScreenNo, this.LED1DYArea_ID2);
                nResult = YB14DynamicAreaLeder.SendDynamicAreaInfoCommand(this.LED1nScreenNo, this.LED1DYArea_ID3);
                if (nResult != YB14DynamicAreaLeder.RETURN_NOERROR)
                {
                    Log4Neter.Error("更新LED动态区域", new Exception(YB14DynamicAreaLeder.GetErrorMessage("SendDynamicAreaInfoCommand", nResult)));
                }

                LED1m_bSendBusy = false;
            }

            this.LED1PrevLedFileContent = value1 + value2;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 初始化外接设备
        /// </summary>
        private void InitHardware()
        {
            try
            {
                bool success = false;

                this.InductorCoil1Port = commonDAO.GetAppletConfigInt32("IO控制器_地感1端口");
                this.InductorCoil2Port = commonDAO.GetAppletConfigInt32("IO控制器_地感2端口");
                this.InductorCoil3Port = commonDAO.GetAppletConfigInt32("IO控制器_地感3端口");
                this.InductorCoil4Port = commonDAO.GetAppletConfigInt32("IO控制器_地感4端口");

                // IO控制器
                Hardwarer.Iocer.OnReceived     += new IOC.JMDM20DIOV2.JMDM20DIOV2Iocer.ReceivedEventHandler(Iocer_Received);
                Hardwarer.Iocer.OnStatusChange += new IOC.JMDM20DIOV2.JMDM20DIOV2Iocer.StatusChangeHandler(Iocer_StatusChange);
                success = Hardwarer.Iocer.OpenCom(commonDAO.GetAppletConfigInt32("IO控制器_串口"), commonDAO.GetAppletConfigInt32("IO控制器_波特率"), commonDAO.GetAppletConfigInt32("IO控制器_数据位"), (StopBits)commonDAO.GetAppletConfigInt32("IO控制器_停止位"), (Parity)commonDAO.GetAppletConfigInt32("IO控制器_校验位"));
                if (!success)
                {
                    MessageBoxEx.Show("IO控制器连接失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                this.iocControler = new IocControler(Hardwarer.Iocer);

                // 读卡器1
                Hardwarer.Rwer1.StartWith       = commonDAO.GetAppletConfigString("读卡器_标签过滤");
                Hardwarer.Rwer1.OnStatusChange += new RW.LZR12.Lzr12Rwer.StatusChangeHandler(Rwer1_OnStatusChange);
                Hardwarer.Rwer1.OnScanError    += new RW.LZR12.Lzr12Rwer.ScanErrorEventHandler(Rwer1_OnScanError);
                success = Hardwarer.Rwer1.OpenCom(commonDAO.GetAppletConfigInt32("读卡器1_串口"));
                if (!success)
                {
                    MessageBoxEx.Show("读卡器1连接失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                #region LED控制卡

                string led1SocketIP = commonDAO.GetAppletConfigString("LED显示屏1_IP地址");
                if (!string.IsNullOrEmpty(led1SocketIP))
                {
                    if (CommonUtil.PingReplyTest(led1SocketIP))
                    {
                        int nResult = YB14DynamicAreaLeder.AddScreen(YB14DynamicAreaLeder.CONTROLLER_BX_5E1, this.LED1nScreenNo, YB14DynamicAreaLeder.SEND_MODE_NETWORK, 96, 32, 1, 1, "", 0, led1SocketIP, 5005, "");
                        if (nResult == YB14DynamicAreaLeder.RETURN_NOERROR)
                        {
                            nResult = YB14DynamicAreaLeder.AddScreenDynamicArea(this.LED1nScreenNo, this.LED1DYArea_ID, 0, 10, 1, "", 0, 0, 0, 96, 32, 255, 0, 255, 7, 6, 1);
                            if (nResult == YB14DynamicAreaLeder.RETURN_NOERROR)
                            {
                                nResult = YB14DynamicAreaLeder.AddScreenDynamicAreaFile(this.LED1nScreenNo, this.LED1DYArea_ID, this.LED1TempFile, 0, "宋体", 12, 0, 120, 1, 3, 0);
                                if (nResult == YB14DynamicAreaLeder.RETURN_NOERROR)
                                {
                                    // 初始化成功
                                    this.LED1ConnectStatus = true;
                                }
                                else
                                {
                                    this.LED1ConnectStatus = false;
                                    Log4Neter.Error("初始化LED1控制卡", new Exception(YB14DynamicAreaLeder.GetErrorMessage("AddScreenDynamicAreaFile", nResult)));
                                    MessageBoxEx.Show("LED1控制卡连接失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }
                            else
                            {
                                this.LED1ConnectStatus = false;
                                Log4Neter.Error("初始化LED1控制卡", new Exception(YB14DynamicAreaLeder.GetErrorMessage("AddScreenDynamicArea", nResult)));
                                MessageBoxEx.Show("LED1控制卡连接失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            this.LED1ConnectStatus = false;
                            Log4Neter.Error("初始化LED1控制卡", new Exception(YB14DynamicAreaLeder.GetErrorMessage("AddScreen", nResult)));
                            MessageBoxEx.Show("LED1控制卡连接失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        this.LED1ConnectStatus = false;
                        Log4Neter.Error("初始化LED1控制卡,网络连接失败", new Exception("网络异常"));
                        MessageBoxEx.Show("LED1控制卡网络连接失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }

                #endregion

                //语音设置
                voiceSpeaker.SetVoice(commonDAO.GetAppletConfigInt32("语速"), commonDAO.GetAppletConfigInt32("音量"), commonDAO.GetAppletConfigString("语音包"));

                timer1.Enabled = true;
            }
            catch (Exception ex)
            {
                Log4Neter.Error("设备初始化", ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新卸煤沟LED
        /// </summary>
        /// <param name="carNumber">车牌号</param>
        /// <param name="isAdd">是否显示</param>
        public bool UpdateLEDShow(CmcsUnLoadLED unLoadLED)
        {
            if (unLoadLED == null)
            {
                return(false);
            }
            string carNumber1 = string.Empty, carNumber2 = string.Empty;

            if (!string.IsNullOrEmpty(unLoadLED.CarNumber))
            {
                string[] carNumbers = unLoadLED.CarNumber.Split('|');
                carNumber1 = carNumbers[0];
                if (carNumbers.Length == 2)
                {
                    carNumber2 = carNumbers[1];
                }
            }

            #region LED控制卡

            string led1SocketIP = unLoadLED.IP;

            if (!string.IsNullOrEmpty(led1SocketIP))
            {
                if (YB14DynamicAreaLeder.PingReplyTest(led1SocketIP))
                {
                    //初始化之前先重置屏幕区域
                    //YB14DynamicAreaLeder.SendDeleteDynamicAreasCommand(this.LED1nScreenNo, 1, string.Format("{0},{1},{2}", this.LED1DYArea_ID1, this.LED1DYArea_ID2, this.LED1DYArea_ID3));
                    YB14DynamicAreaLeder.DeleteScreen(this.LED1nScreenNo);

                    int nResult = YB14DynamicAreaLeder.AddScreen(YB14DynamicAreaLeder.CONTROLLER_BX_5E1, this.LED1nScreenNo, YB14DynamicAreaLeder.SEND_MODE_NETWORK, 192, 64, 1, 1, "", 0, led1SocketIP, 5005, "");
                    if (nResult == YB14DynamicAreaLeder.RETURN_NOERROR)
                    {
                        //屏幕分为3个区域 左 64*64 右上 128*32 右下 128*32
                        #region 左
                        nResult = YB14DynamicAreaLeder.AddScreenDynamicArea(this.LED1nScreenNo, this.LED1DYArea_ID1, 0, 10, 1, "", 0, 0, 0, 64, 64, 255, 0, 255, 7, 6, 1);
                        if (nResult == YB14DynamicAreaLeder.RETURN_NOERROR)
                        {
                            nResult = YB14DynamicAreaLeder.AddScreenDynamicAreaFile(this.LED1nScreenNo, this.LED1DYArea_ID1, this.LED1TempFile, 0, "宋体", 48, 0, 120, 1, 3, 0);
                            if (nResult == YB14DynamicAreaLeder.RETURN_NOERROR)
                            {
                                // 初始化成功
                                this.LED1ConnectStatus = true;
                            }
                            else
                            {
                                this.LED1ConnectStatus = false;
                                Log4Neter.Error("初始化卸煤沟LED控制卡", new Exception(YB14DynamicAreaLeder.GetErrorMessage("AddScreenDynamicAreaFile", nResult)));
                            }
                        }
                        #endregion

                        #region 右上
                        nResult = YB14DynamicAreaLeder.AddScreenDynamicArea(this.LED1nScreenNo, this.LED1DYArea_ID2, 0, 10, 1, "", 0, 64, 0, 128, 32, 255, 0, 255, 7, 6, 1);
                        if (nResult == YB14DynamicAreaLeder.RETURN_NOERROR)
                        {
                            nResult = YB14DynamicAreaLeder.AddScreenDynamicAreaFile(this.LED1nScreenNo, this.LED1DYArea_ID2, this.LED2TempFile, 0, "宋体", 22, 0, 120, 1, 3, 0);
                            if (nResult == YB14DynamicAreaLeder.RETURN_NOERROR)
                            {
                                // 初始化成功
                                this.LED1ConnectStatus = true;
                            }
                            else
                            {
                                this.LED1ConnectStatus = false;
                                Log4Neter.Error("初始化卸煤沟LED控制卡", new Exception(YB14DynamicAreaLeder.GetErrorMessage("AddScreenDynamicAreaFile", nResult)));
                            }
                        }
                        #endregion

                        #region 右下
                        nResult = YB14DynamicAreaLeder.AddScreenDynamicArea(this.LED1nScreenNo, this.LED1DYArea_ID3, 0, 10, 1, "", 0, 64, 32, 128, 32, 255, 0, 255, 7, 6, 1);

                        if (nResult == YB14DynamicAreaLeder.RETURN_NOERROR)
                        {
                            nResult = YB14DynamicAreaLeder.AddScreenDynamicAreaFile(this.LED1nScreenNo, this.LED1DYArea_ID3, this.LED3TempFile, 0, "宋体", 22, 0, 120, 1, 3, 0);
                            if (nResult == YB14DynamicAreaLeder.RETURN_NOERROR)
                            {
                                // 初始化成功
                                this.LED1ConnectStatus = true;
                            }
                            else
                            {
                                this.LED1ConnectStatus = false;
                                Log4Neter.Error("初始化卸煤沟LED控制卡", new Exception(YB14DynamicAreaLeder.GetErrorMessage("AddScreenDynamicAreaFile", nResult)));
                            }
                        }
                        else
                        {
                            this.LED1ConnectStatus = false;
                            Log4Neter.Error("初始化卸煤沟LED控制卡", new Exception(YB14DynamicAreaLeder.GetErrorMessage("AddScreenDynamicArea", nResult)));
                        }
                        #endregion
                    }
                    else
                    {
                        this.LED1ConnectStatus = false;
                        Log4Neter.Error("初始化卸煤沟LED控制卡", new Exception(YB14DynamicAreaLeder.GetErrorMessage("AddScreen", nResult)));
                    }
                }
                else
                {
                    this.LED1ConnectStatus = false;
                    Log4Neter.Error("初始化卸煤沟LED控制卡", new Exception("网络连接失败"));
                }
            }

            #endregion

            if (this.LED1ConnectStatus)
            {
                UpdateLed1Show(unLoadLED.UnLoadName, !string.IsNullOrEmpty(carNumber1) ? carNumber1 : "等待车辆", !string.IsNullOrEmpty(carNumber2) ? carNumber2 : "等待车辆");
                return(true);
            }
            return(false);
        }