public static string AddNewHardware(HardwareVender vender, HardwareType type, HardwareSeries series) { bool bUnknowHardware = true; string strName = string.Empty; try { #region Demo if (vender == HardwareVender.Demo) { #region Motion Card if (type == HardwareType.MotionCard) { if (series == HardwareSeries.Demo_MotionCard_Common) { DemoMotionCardData data = new DemoMotionCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new DemoMotionCard()); bUnknowHardware = false; } } if (type == HardwareType.InputCard) { if (series == HardwareSeries.Demo_InputCard_Common) { DemoInputCardData data = new DemoInputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new DemoInputCard()); bUnknowHardware = false; } } if (type == HardwareType.OutputCard) { if (series == HardwareSeries.Demo_OutputCard_Common) { DemoOutputCardData data = new DemoOutputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new DemoOutputCard()); bUnknowHardware = false; } } if (type == HardwareType.InputOutputCard) { if (series == HardwareSeries.Demo_InputOutputCard_Common) { DemoInputOutputCardData data = new DemoInputOutputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new DemoInputOutputCard()); bUnknowHardware = false; } } #endregion #region GEMotion Card if (type == HardwareType.GEMotionCard) { } #endregion #region Input Card if (type == HardwareType.InputCard) { DemoInputCardData data = new DemoInputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new DemoInputCard()); bUnknowHardware = false; } #endregion #region Output Card if (type == HardwareType.OutputCard) { DemoOutputCardData data = new DemoOutputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new DemoOutputCard()); bUnknowHardware = false; } #endregion #region InputOutput Card if (type == HardwareType.InputOutputCard) { DemoInputOutputCardData data = new DemoInputOutputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new DemoInputOutputCard()); bUnknowHardware = false; } #endregion #region AIO Card if (type == HardwareType.AIOCard) { } #endregion } #endregion #region GoogolTech if (vender == HardwareVender.GoogolTech) { #region Motion Card if (type == HardwareType.MotionCard) { if (series == HardwareSeries.GoogolTech_MotionCard_Common) { GoogolMotionCardData data = new GoogolMotionCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new GoogolMotionCard()); dicSettingForms.Add(data.Name, new FormGoogolSetting()); bUnknowHardware = false; } } #endregion #region GEMotion Card if (type == HardwareType.GEMotionCard) { } #endregion #region Input Card if (type == HardwareType.InputCard) { if (series == HardwareSeries.GoogolTech_InputCard_Common) { GoogolInputCardData data = new GoogolInputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new GoogolInputCard()); bUnknowHardware = false; } } #endregion #region Output Card if (type == HardwareType.OutputCard) { if (series == HardwareSeries.GoogolTech_OutputCard_Common) { GoogolOutputCardData data = new GoogolOutputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new GoogolOutputCard()); bUnknowHardware = false; } } #endregion #region InputOutput Card if (type == HardwareType.InputOutputCard) { if (series == HardwareSeries.GoogolTech_InputOutputCard_Common) { GoogolInputOutputCardData data = new GoogolInputOutputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new GoogolInputOutputCard()); bUnknowHardware = false; } } #endregion #region AIO Card if (type == HardwareType.AIOCard) { } #endregion } #endregion #region LeadShine if (vender == HardwareVender.LeadShine) { #region Motion Card if (type == HardwareType.MotionCard) { if (series == HardwareSeries.LeadShine_MotionCard_Common) { LeadShineMotionCardData data = new LeadShineMotionCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new LeadShineMotionCard()); dicSettingForms.Add(data.Name, new FormLeadShineMotionCard(data)); bUnknowHardware = false; } if (series == HardwareSeries.LeadShine_MotionCard_Dmc1000) { LeadShineMotionCardData data = new LeadShineMotionCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new LeadShineMotionCardDmc1000()); dicSettingForms.Add(data.Name, new FormLeadShineMotionCard(data)); bUnknowHardware = false; } } #endregion #region GEMotion Card if (type == HardwareType.GEMotionCard) { } #endregion #region Input Card if (type == HardwareType.InputCard) { LeadShineInputCardData data = new LeadShineInputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new LeadShineInputCard()); bUnknowHardware = false; } #endregion #region Output Card if (type == HardwareType.OutputCard) { LeadShineOutputCardData data = new LeadShineOutputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new LeadShineOutputCard()); bUnknowHardware = false; } #endregion #region InputOutput Card if (type == HardwareType.InputOutputCard) { LeadShineInputOutputCardData data = new LeadShineInputOutputCardData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new LeadShineInputOutputCard()); bUnknowHardware = false; } #endregion #region AIO Card if (type == HardwareType.AIOCard) { } #endregion } #endregion #region AdvanTech if (vender == HardwareVender.AdvanTech) { #region Motion Card if (type == HardwareType.MotionCard) { } #endregion #region GEMotion Card if (type == HardwareType.GEMotionCard) { } #endregion #region Input Card if (type == HardwareType.InputCard) { } #endregion #region Output Card if (type == HardwareType.OutputCard) { } #endregion #region InputOutput Card if (type == HardwareType.InputOutputCard) { } #endregion #region AIO Card if (type == HardwareType.AIOCard) { } #endregion } #endregion #region Omron if (vender == HardwareVender.Omron) { #region PLC if (type == HardwareType.PLC) { if (series == HardwareSeries.Omron_PLC_NJ) { PlcOmronTypeNJData data = new PlcOmronTypeNJData { Name = GetNewHardwareName(HardwareVender.Omron, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new PlcOmronTypeNJ(data)); dicSettingForms.Add(data.Name, new FormOmronTypeNJ(data)); bUnknowHardware = false; } if (series == HardwareSeries.Omron_PLC_NX1P) { PlcOmronTypeNX1PData data = new PlcOmronTypeNX1PData { Name = GetNewHardwareName(HardwareVender.Omron, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new PlcOmronTypeNX1P(data)); dicSettingForms.Add(data.Name, new FormOmronTypeNX1P(data)); bUnknowHardware = false; } } #endregion } #endregion #region Panasonic if (vender == HardwareVender.Panasonic) { #region PLC if (type == HardwareType.PLC) { if (series == HardwareSeries.Panasonic_PLC_Common) { PlcPanasonicData data = new PlcPanasonicData { Name = GetNewHardwareName(vender, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new PlcPanasonic(data)); dicSettingForms.Add(data.Name, new FormPanasonic(data)); bUnknowHardware = false; } } #endregion } #endregion #region Siemens if (vender == HardwareVender.Siemens) { #region PLC if (type == HardwareType.PLC) { if (series == HardwareSeries.Siemens_PLC_S7200Smart) { PlcSiemensS7200Data data = new PlcSiemensS7200Data { Name = GetNewHardwareName(HardwareVender.Siemens, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new PlcSiemensS7200(data)); dicSettingForms.Add(data.Name, new FormSiemensS7200(data)); bUnknowHardware = false; } } #endregion } #endregion #region Yamaha if (vender == HardwareVender.Yamaha) { #region Robot if (type == HardwareType.Robot) { if (series == HardwareSeries.Yamaha_Robot_RCX340) { YamahaRobotData data = new YamahaRobotData { Name = GetNewHardwareName(HardwareVender.Yamaha, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new YamahaRobotRCX340(data)); dicSettingForms.Add(data.Name, new FormYamahaRobotRCX340(data)); bUnknowHardware = false; } } #endregion } #endregion #region Basler if (vender == HardwareVender.Basler) { #region Camera if (type == HardwareType.Camera) { if (series == HardwareSeries.Basler_Camera_Aca500M) { Aca500MData data = new Aca500MData { Name = GetNewHardwareName(HardwareVender.Basler, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new Aca500M(data)); dicSettingForms.Add(data.Name, new FormAca500M(data)); bUnknowHardware = false; } } #endregion } #endregion #region ImagingSource if (vender == HardwareVender.ImagingSource) { #region Camera if (type == HardwareType.Camera) { if (series == HardwareSeries.ImagingSource_Camera_GigE) { ImagingSourceGigEData data = new ImagingSourceGigEData { Name = GetNewHardwareName(HardwareVender.ImagingSource, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new ImagingSourceGigE(data)); dicSettingForms.Add(data.Name, new FormImagingSourceGigE(data)); bUnknowHardware = false; } } #endregion } #endregion #region Cognex #endregion #region Keyence if (vender == HardwareVender.Keyence) { #region CodeReader if (type == HardwareType.CodeReader) { if (series == HardwareSeries.Keyence_CodeReader_SR700) { KeyenceSR700Data data = new KeyenceSR700Data { Name = GetNewHardwareName(HardwareVender.Keyence, type, series), Vender = vender, Series = series, Type = type }; strName = data.Name; data.Text = data.Name; docHardware.dicHardwareData.Add(data.Name, data); docHardware.listHardwareData.Add(data); dicHardwareDriver.Add(data.Name, new KeyenceSR700(data)); dicSettingForms.Add(data.Name, new FormKeyenceSR700(data)); bUnknowHardware = false; } } #endregion } #endregion if (bUnknowHardware) { MessageBox.Show("Unknow hardware!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification); return(null); } return(strName); } catch (Exception) { return(null); } }
public static string GetNewHardwareName(HardwareVender hardwareVender, HardwareType type, HardwareSeries series) { string strTemp = hardwareVender.ToString() + "_" + type.ToString() + "_" + series.ToString() + "_"; int index = 1; if (docHardware == null) { return(strTemp + index.ToString()); } while (true) { if (!docHardware.dicHardwareData.ContainsKey(strTemp + index.ToString())) { return(strTemp + index.ToString()); } index++; continue; } }