private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { try { if (null == driver1) { driver1 = (KeyenceSR700)HardwareManage.dicHardwareDriver[HardwareName.内线读码器]; } if (null == driver2) { driver2 = (KeyenceSR700)HardwareManage.dicHardwareDriver[HardwareName.外线读码器]; } if (null == driver1 || null == driver2) { throw new Exception(); } btnCodeReaderTrigger1.Enabled = driver1.IsConnected(); btnCodeReaderTrigger2.Enabled = driver2.IsConnected(); } catch (Exception) { btnCodeReaderTrigger1.Enabled = false; btnCodeReaderTrigger2.Enabled = false; } }
private void timer1_Tick(object sender, EventArgs e) { #region Clr button pressed handle if (_bClrAllAlarm) { if (MainModule.alarmManage.IsAlarm && _bClrAllAlarm) { MainModule.alarmManage.RemoveAllAlarm(); } _bClrAllAlarm = false; } #endregion #region Set toolStripStatus if (null == _codereader1 && HardwareManage.dicHardwareDriver.ContainsKey(HardwareName.内线读码器)) { _codereader1 = (KeyenceSR700)HardwareManage.dicHardwareDriver[HardwareName.内线读码器]; } if (null == _codereader2 && HardwareManage.dicHardwareDriver.ContainsKey(HardwareName.外线读码器)) { _codereader2 = (KeyenceSR700)HardwareManage.dicHardwareDriver[HardwareName.外线读码器]; } if (null != _plc1 && null != _plc2) { MainModule.formMain.SetPLCStatus(1, _plc1.IsConnected()); MainModule.formMain.SetPLCStatus(2, _plc2.IsConnected()); //if (!_plc1.IsConnected()) // MainModule.alarmManage.InsertAlarm(AppAlarmKeys.与主控PLC连接断开, "与主控PLC连接断开,请检查PLC是否已上电以及网络连接是否正常。"); //else // MainModule.alarmManage.RemoveAlarm(AppAlarmKeys.与主控PLC连接断开); //if (!_plc2.IsConnected()) // MainModule.alarmManage.InsertAlarm(AppAlarmKeys.与清洗机PLC连接断开, "与清洗机PLC连接断开,请检查PLC是否已上电以及网络连接是否正常。"); //else // MainModule.alarmManage.RemoveAlarm(AppAlarmKeys.与清洗机PLC连接断开); } if (null != _codereader1 && null != _codereader2) { MainModule.formMain.SetCodeReaderStatus(1, _codereader2.IsConnected()); MainModule.formMain.SetCodeReaderStatus(2, _codereader2.IsConnected()); //if (!_codereader1.IsConnected()) // MainModule.alarmManage.InsertAlarm(AppAlarmKeys.与内线读码器连接断开, "与内线读码器连接断开。"); //else // MainModule.alarmManage.RemoveAlarm(AppAlarmKeys.与内线读码器连接断开); //if (!_codereader2.IsConnected()) // MainModule.alarmManage.InsertAlarm(AppAlarmKeys.与外线读码器连接断开, "与外线读码器连接断开。"); //else // MainModule.alarmManage.RemoveAlarm(AppAlarmKeys.与外线读码器连接断开); } #endregion #region Write PC status to PLC try { if (null != _plc1 && _plc1.IsConnected()) { int iPCAlarmSta = MainModule.alarmManage.IsAlarm ? 1 : 0; if (!iPCAlarmSta.ToString().Equals(_plc1.plcData.dicScanItems[PLC1.位机状态].strValue)) { _plc1.WriteData(PLC1.位机状态, iPCAlarmSta); } } } catch (Exception) { } #endregion }