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;
     }
 }
Beispiel #2
0
 public ScanTask(string name, TaskGroup taskGroup) : base(name, taskGroup)
 {
     if (HardwareManage.dicHardwareDriver.ContainsKey("PLC1"))
     {
         _plcDriver = (PlcOmronTypeNJ)HardwareManage.dicHardwareDriver["PLC1"];
     }
     if (HardwareManage.dicHardwareDriver.ContainsKey(HardwareName.内线读码器))
     {
         insideCodeReader = (KeyenceSR700)HardwareManage.dicHardwareDriver[HardwareName.内线读码器];
     }
     if (HardwareManage.dicHardwareDriver.ContainsKey(HardwareName.外线读码器))
     {
         outsideCodeReader = (KeyenceSR700)HardwareManage.dicHardwareDriver[HardwareName.外线读码器];
     }
 }
        public static void InitHardware()
        {
            if (null == dicSettingForms)
            {
                dicSettingForms = new Dictionary <string, Form>();
            }

            try
            {
                dicHardwareDriver = new Dictionary <string, HardwareBase>();
                foreach (KeyValuePair <string, HardwareData> item in docHardware.dicHardwareData)
                {
                    #region Demo
                    if (item.Value.Vender == HardwareVender.Demo)
                    {
                        if (item.Value.Series == HardwareSeries.Demo_InputCard_Common)
                        {
                            DemoInputCard demoCard = new DemoInputCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                        }
                        if (item.Value.Series == HardwareSeries.Demo_InputOutputCard_Common)
                        {
                            DemoInputOutputCard demoCard = new DemoInputOutputCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                        }
                        if (item.Value.Series == HardwareSeries.Demo_MotionCard_Common)
                        {
                            DemoMotionCard demoCard = new DemoMotionCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                        }
                        if (item.Value.Series == HardwareSeries.Demo_OutputCard_Common)
                        {
                            DemoOutputCard demoCard = new DemoOutputCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                        }
                    }
                    #endregion
                    #region LEISAI
                    if (item.Value.Vender == HardwareVender.LeadShine)
                    {
                        if (item.Value.Series == HardwareSeries.LeadShine_InputCard_Common)
                        {
                            LeadShineInputCard demoCard = new LeadShineInputCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                        }
                        if (item.Value.Series == HardwareSeries.LeadShine_OutputCard_Common)
                        {
                            LeadShineOutputCard demoCard = new LeadShineOutputCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                        }
                        if (item.Value.Series == HardwareSeries.LeadShine_InputOutputCard_Common)
                        {
                            LeadShineInputOutputCard demoCard = new LeadShineInputOutputCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                        }
                        if (item.Value.Series == HardwareSeries.LeadShine_MotionCard_Common)
                        {
                            LeadShineMotionCard demoCard = new LeadShineMotionCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                            dicSettingForms.Add(item.Value.Name, new FormLeadShineMotionCard((LeadShineMotionCardData)item.Value));
                        }
                        if (item.Value.Series == HardwareSeries.LeadShine_MotionCard_Dmc1000)
                        {
                            LeadShineMotionCardDmc1000 demoCard = new LeadShineMotionCardDmc1000();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                            dicSettingForms.Add(item.Value.Name, new FormLeadShineMotionCard((LeadShineMotionCardData)item.Value));
                        }
                    }
                    #endregion
                    #region GOOGOL
                    if (item.Value.Vender == HardwareVender.GoogolTech)
                    {
                        if (item.Value.Series == HardwareSeries.GoogolTech_MotionCard_Common)
                        {
                            GoogolMotionCard demoCard = new GoogolMotionCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);

                            dicSettingForms.Add(item.Value.Name, new FormGoogolSetting());
                        }
                    }
                    #endregion
                    #region ADVANCE
                    if (item.Value.Vender == HardwareVender.AdvanTech)
                    {
                        if (item.Value.Series == HardwareSeries.AdvanTech_InputCard_Common)
                        {
                            AdvanInputCard demoCard = new AdvanInputCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                        }
                        if (item.Value.Series == HardwareSeries.AdvanTech_OutputCard_Common)
                        {
                            AdvanOutputCard demoCard = new AdvanOutputCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                        }
                        if (item.Value.Series == HardwareSeries.AdvanTech_InputOutputCard_Common)
                        {
                            AdvanInputOutputCard demoCard = new AdvanInputOutputCard();
                            dicHardwareDriver.Add(item.Value.Name, demoCard);
                        }
                    }
                    #endregion
                    #region Panasonic
                    if (item.Value.Vender == HardwareVender.Panasonic)
                    {
                        if (item.Value.Series == HardwareSeries.Panasonic_PLC_Common)
                        {
                            PlcPanasonic plcPanasonic = new PlcPanasonic((PlcPanasonicData)item.Value);
                            dicHardwareDriver.Add(item.Value.Name, plcPanasonic);
                            dicSettingForms.Add(item.Value.Name, new FormPanasonic((PlcPanasonicData)item.Value));
                        }
                    }
                    #endregion
                    #region Omron
                    if (item.Value.Vender == HardwareVender.Omron)
                    {
                        if (item.Value.Series == HardwareSeries.Omron_PLC_NJ)
                        {
                            PlcOmronTypeNJ demoCard = new PlcOmronTypeNJ((PlcOmronTypeNJData)item.Value);
                            dicHardwareDriver.Add(item.Value.Name, demoCard);

                            dicSettingForms.Add(item.Value.Name, new FormOmronTypeNJ((PlcOmronTypeNJData)item.Value));
                        }
                        else if (item.Value.Series == HardwareSeries.Omron_PLC_NX1P)
                        {
                            PlcOmronTypeNX1P plc = new PlcOmronTypeNX1P((PlcOmronTypeNX1PData)item.Value);
                            dicHardwareDriver.Add(item.Value.Name, plc);
                            dicSettingForms.Add(item.Value.Name, new FormOmronTypeNX1P((PlcOmronTypeNX1PData)item.Value));
                        }
                    }
                    #endregion
                    #region Siemens
                    if (item.Value.Vender == HardwareVender.Siemens)
                    {
                        if (item.Value.Series == HardwareSeries.Siemens_PLC_S7200Smart)
                        {
                            PlcSiemensS7200 demoCard = new PlcSiemensS7200((PlcSiemensS7200Data)item.Value);
                            dicHardwareDriver.Add(item.Value.Name, demoCard);

                            dicSettingForms.Add(item.Value.Name, new FormSiemensS7200((PlcSiemensS7200Data)item.Value));
                        }
                    }
                    #endregion
                    #region Yamaha
                    if (item.Value.Vender == HardwareVender.Yamaha)
                    {
                        if (item.Value.Series == HardwareSeries.Yamaha_Robot_RCX340)
                        {
                            YamahaRobotRCX340 demoCard = new YamahaRobotRCX340((YamahaRobotData)item.Value);
                            dicHardwareDriver.Add(item.Value.Name, demoCard);

                            dicSettingForms.Add(item.Value.Name, new FormYamahaRobotRCX340((YamahaRobotData)item.Value));
                        }
                    }
                    #endregion
                    #region Cognex

                    #endregion
                    #region Keyence
                    if (item.Value.Vender == HardwareVender.Keyence)
                    {
                        if (item.Value.Series == HardwareSeries.Keyence_CodeReader_SR700)
                        {
                            KeyenceSR700 demoCard = new KeyenceSR700((KeyenceSR700Data)item.Value);
                            dicHardwareDriver.Add(item.Value.Name, demoCard);

                            dicSettingForms.Add(item.Value.Name, new FormKeyenceSR700((KeyenceSR700Data)item.Value));
                        }
                    }
                    #endregion
                    #region Basler
                    if (item.Value.Vender == HardwareVender.Basler)
                    {
                        if (item.Value.Series == HardwareSeries.Basler_Camera_Aca500M)
                        {
                            Aca500M driver = new Aca500M((Aca500MData)item.Value);
                            dicHardwareDriver.Add(item.Value.Name, driver);
                            dicSettingForms.Add(item.Value.Name, new FormAca500M((Aca500MData)item.Value));
                        }
                    }
                    #endregion
                    #region ImagingSource
                    if (item.Value.Vender == HardwareVender.ImagingSource)
                    {
                        if (item.Value.Series == HardwareSeries.ImagingSource_Camera_GigE)
                        {
                            ImagingSourceGigE driver = new ImagingSourceGigE((ImagingSourceGigEData)item.Value);
                            dicHardwareDriver.Add(item.Value.Name, driver);
                            dicSettingForms.Add(item.Value.Name, new FormImagingSourceGigE((ImagingSourceGigEData)item.Value));
                        }
                    }
                    #endregion
                }
                foreach (KeyValuePair <string, HardwareBase> item in dicHardwareDriver)
                {
                    item.Value.Init(docHardware.dicHardwareData[item.Key]);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                throw;
            }
        }
 public FormProductInfo()
 {
     InitializeComponent();
     driver1 = null;
     driver2 = null;
 }
Beispiel #5
0
        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
        }