/// <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端口"); this.InductorCoil3Port = commonDAO.GetAppletConfigInt32("IO控制器_地感3端口"); // 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.Net.Lzr12Rwer.StatusChangeHandler(Rwer1_OnStatusChange); Hardwarer.Rwer1.OnScanError += new RW.LZR12.Net.Lzr12Rwer.ScanErrorEventHandler(Rwer1_OnScanError); success = CommonUtil.PingReplyTest(commonDAO.GetAppletConfigString("读卡器1_IP地址")) && Hardwarer.Rwer1.OpenCom(commonDAO.GetAppletConfigString("读卡器1_IP地址"), 500, Convert.ToByte(commonDAO.GetAppletConfigInt32("读卡器1_功率"))); if (!success) { MessageBoxEx.Show("读卡器1连接失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //语音设置 voiceSpeaker.SetVoice(commonDAO.GetAppletConfigInt32("语速"), commonDAO.GetAppletConfigInt32("音量"), commonDAO.GetAppletConfigString("语音包")); timer1.Enabled = true; } catch (Exception ex) { Log4Neter.Error("设备初始化", ex); } }
/// <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); } }