private void cb_Driver_SelectedIndexChanged(object sender, EventArgs e) { if (cb_Driver.SelectedItem != null) { try { Scada.Model.SCADA_DEVICE_DRIVER driver = cb_Driver.SelectedItem as Scada.Model.SCADA_DEVICE_DRIVER; DriverKernel = FormManager.CreateDeviceDrive(driver); DriverKernel.IsCreateControl = true; try { DriverKernel.InitKernel(Server, Communication, Device, null, driver); } catch (Exception emx) { FormManager.DisplayException(new Exception("设备驱动初始化InitDriver失败" + emx.Message)); } try { if (DriverKernel.DeviceCtrl != null) { DriverKernel.DeviceCtrl.SetUIParameter(Server, Device); } } catch (Exception emx) { FormManager.DisplayException(new Exception("解析设备驱动参数失败(SetUIParameter)" + emx.Message)); } this.tabPage2.Controls.Clear(); if (DriverKernel.DeviceCtrl != null) { this.tabPage2.Controls.Add(DriverKernel.DeviceCtrl); } } catch (Exception emx) { FormManager.DisplayException(new Exception("加载设备驱动失败" + emx.Message)); } } }
public void InitForm() { groupBoxMN.Visible = false; this.groupBoxKG.Visible = false; this.groupBoxGS.Visible = false; this.groupDatabase.Visible = false; if (Para == null) { Para = new IO_PARA(); Para.IO_ID = ""; Para.IO_ADDRESS = "1"; Para.IO_COMM_ID = Comunication.IO_COMM_ID; Para.IO_DEVICE_ID = Device.IO_DEVICE_ID; Para.IO_SERVER_ID = Server.SERVER_ID; Para.IO_SYSTEM = 0; Para.IO_ENABLEALARM = 0; Para.IO_ENABLERANGECONVERSION = 0; cb_paratype.SelectedIndex = 0; cb_datatype.SelectedIndex = 0; cbo_minmin.SelectedIndex = 0; cbo_min.SelectedIndex = 0; cbo_max.SelectedIndex = 0; cbo_maxmax.SelectedIndex = 0; } if (Device != null) { txtFormula.InitDevice(Device); } comconType.SelectedIndex = 0; this.cbDatabaseType.SelectedIndex = 0; this.txtDataSourceDateRecordRange.SelectedIndex = 0; this.txtDataSourceOrderRecordType.SelectedIndex = 0; this.txtDataSourceValueRecordType.Text = "NONE"; this.tb_paraname.Text = Para.IO_NAME; this.tb_parachname.Text = Para.IO_LABEL; this.tb_initvalue.Text = Para.IO_INITALVALUE; this.cb_unittype.Text = Para.IO_UNIT; this.tb_address.Text = Para.IO_ADDRESS; for (int i = 0; i < cb_paratype.Items.Count; i++) { if (cb_paratype.Items[i].ToString() == Para.IO_POINTTYPE) { cb_paratype.SelectedIndex = i; break; } } for (int i = 0; i < cb_datatype.Items.Count; i++) { if (cb_datatype.Items[i].ToString() == Para.IO_DATATYPE) { cb_datatype.SelectedIndex = i; break; } } cb_range.Checked = Convert.ToBoolean(Para.IO_ENABLERANGECONVERSION); tb_minrange.Text = Para.IO_RANGEMIN; tb_maxrange.Text = Para.IO_RANGEMAX; tb_valuemin.Text = Para.IO_MINVALUE; tb_valuemax.Text = Para.IO_MAXVALUE; ///小数位数 this.tbDecimalplace.Text = Para.IO_OUTLIES; tb_zone.Text = Para.IO_ZERO; tb_one.Text = Para.IO_ONE; //报警属性设置 cb_alarm.Checked = Convert.ToBoolean(Para.IO_ENABLEALARM); cb_minminenable.Checked = Convert.ToBoolean(Para.AlarmConfig.IO_ENABLE_MINMIN); cb_minenable.Checked = Convert.ToBoolean(Para.AlarmConfig.IO_ENABLE_MIN); cb_maxenable.Checked = Convert.ToBoolean(Para.AlarmConfig.IO_ENABLE_MAX); cb_maxmaxenable.Checked = Convert.ToBoolean(Para.AlarmConfig.IO_ENABLE_MAXMAX); //报警限值设置 nb_maxmax.Value = Para.AlarmConfig.IO_MAXMAX_VALUE.Value; nb_max.Value = Para.AlarmConfig.IO_MAX_VALUE.Value; nb_min.Value = Para.AlarmConfig.IO_MIN_VALUE.Value; nb_minmin.Value = Para.AlarmConfig.IO_MINMIN_VALUE.Value; //报警类型 for (int i = 0; i < cbo_minmin.Items.Count; i++) { if (cbo_minmin.Items[i].ToString() == Para.AlarmConfig.IO_MINMIN_TYPE) { cbo_minmin.SelectedIndex = i; break; } } for (int i = 0; i < cbo_min.Items.Count; i++) { if (cbo_min.Items[i].ToString() == Para.AlarmConfig.IO_MIN_TYPE) { cbo_min.SelectedIndex = i; break; } } for (int i = 0; i < cbo_max.Items.Count; i++) { if (cbo_max.Items[i].ToString() == Para.AlarmConfig.IO_MAX_TYPE) { cbo_max.SelectedIndex = i; break; } } for (int i = 0; i < cbo_maxmax.Items.Count; i++) { if (cbo_maxmax.Items[i].ToString() == Para.AlarmConfig.IO_MAXMAX_TYPE) { cbo_maxmax.SelectedIndex = i; break; } } //报警子项是否开启 cb_minminenable.Checked = Convert.ToBoolean(Para.AlarmConfig.IO_ENABLE_MINMIN); cb_minenable.Checked = Convert.ToBoolean(Para.AlarmConfig.IO_ENABLE_MIN); cb_maxenable.Checked = Convert.ToBoolean(Para.AlarmConfig.IO_ENABLE_MAX); cb_maxmaxenable.Checked = Convert.ToBoolean(Para.AlarmConfig.IO_ENABLE_MAXMAX); string[] condions = Para.AlarmConfig.IO_CONDITION.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); this.listCons.Items.Clear(); this.listCons.Items.AddRange(condions); listParas.Items.Clear(); for (int i = 0; i < FormManager.mediator.IOParaForm.IOListView.ListView.Items.Count; i++) { listParas.Items.Add(FormManager.mediator.IOParaForm.IOListView.ListView.Items[i].SubItems[1].Text); } //加载设备驱动 Scada.Business.SCADA_DEVICE_DRIVER driverBll = new Scada.Business.SCADA_DEVICE_DRIVER(); Scada.Model.SCADA_DEVICE_DRIVER driver = driverBll.GetModel(Device.DEVICE_DRIVER_ID); if (driver != null) { DeviceKernel = FormManager.CreateDeviceDrive(driver); DeviceKernel.InitKernel(Server, Comunication, Device, Para, driver); DeviceKernel.ParaCtrl.SetUIParameter(Server, Device, Para); this.tabPage3.Controls.Clear(); this.tabPage3.Controls.Add(DeviceKernel.ParaCtrl); } this.txtFormula.Text = Para.IO_FORMULA; //配置数据源连接 string[] datasorces = Para.IO_DATASOURCE.Split(','); if (datasorces.Length == 13) { this.txtDataSourceIP.Text = datasorces[0]; this.txtDataSourceName.Text = datasorces[1]; this.cbDatabaseType.Text = datasorces[2]; this.txtDataSourceUser.Text = datasorces[3]; this.txtDataSourcePassword.Text = datasorces[4]; this.txtDataSourceTable.Text = datasorces[5]; this.txtDataSourceValueRecord.Text = datasorces[6]; this.txtDataSourceValueRecordType.Text = datasorces[7]; this.txtDataSourceDateRecord.Text = datasorces[8]; this.txtDataSourceDateRecordRange.Text = datasorces[9]; this.txtDataSourceOrderRecord.Text = datasorces[10]; this.txtDataSourceOrderRecordType.Text = datasorces[11]; this.txtDataSourceWhere.Text = datasorces[12]; } }