public SCADA_DEVICE_DRIVER Copy() { SCADA_DEVICE_DRIVER driver = new SCADA_DEVICE_DRIVER() { _devicefullname = this._devicefullname, _id = this._id, _devicename = this._devicename, _dll_guid = this._dll_guid, _dll_name = this._dll_name, _title = this._title, _dll_title = this._dll_title, _namespace = this._namespace, _fillname = this._fillname }; return(driver); }
public void InitForm() { FormManager.IODeviceDriveCombox(cb_Driver, Communication.IO_COMM_DRIVER_ID); if (Device == null) { Device = new IO_DEVICE(); Device.IO_DEVICE_ID = GUIDTo16.GuidToLongID().ToString(); IOCommunicationNode commNode = FormManager.mediator.IOTreeForm.IoTree.GetCommunicationNode(Server, Communication); if (commNode != null) { int num = commNode.DeviceNumber; Device.IO_DEVICE_NAME = "Device" + num; Device.IO_DEVICE_LABLE = Device.IO_DEVICE_NAME; Device.IO_DEVICE_OVERTIME = 120; Device.IO_DEVICE_UPDATECYCLE = 120; Device.IO_DEVICE_ADDRESS = num.ToString(); } Device.IO_DEVICE_STATUS = 0; } Device.IO_COMM_ID = Communication.IO_COMM_ID; Device.IO_SERVER_ID = Server.SERVER_ID; this.txtID.Text = Device.IO_DEVICE_ID; this.txtLabel.Text = Device.IO_DEVICE_LABLE; this.txtName.Text = Device.IO_DEVICE_NAME; this.txtRemark.Text = Device.IO_DEVICE_REMARK; this.txtAddress.Text = Device.IO_DEVICE_ADDRESS; this.nd_timeout.Value = Device.IO_DEVICE_OVERTIME; this.nd_updatecycle.Value = Device.IO_DEVICE_UPDATECYCLE; for (int i = 0; i < this.cb_Driver.Items.Count; i++) { Scada.Model.SCADA_DEVICE_DRIVER driver = this.cb_Driver.Items[i] as Scada.Model.SCADA_DEVICE_DRIVER; if (driver.Id == Device.DEVICE_DRIVER_ID) { this.cb_Driver.SelectedIndex = i; break; } } if (this.cb_Driver.SelectedIndex <= 0 && this.cb_Driver.Items.Count > 0) { this.cb_Driver.SelectedIndex = 0; } }
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]; } }
private void wizardTabControl_ButtonOK(object sender, EventArgs e) { if (cb_Driver.SelectedItem == null) { MessageBox.Show("请选择设备驱动"); return; } if (this.txtLabel.Text.Trim() == "") { MessageBox.Show("请输入中文标识"); return; } if (this.txtName.Text.Trim() == "") { MessageBox.Show("请输入设备名称"); return; } IOCommunicationNode commNode = FormManager.mediator.IOTreeForm.IoTree.GetCommunicationNode(Server, Communication); if (commNode != null) { for (int i = 0; i < commNode.Nodes.Count; i++) { IODeviceNode deviceNode = commNode.Nodes[i] as IODeviceNode; if (deviceNode.Device.IO_DEVICE_ADDRESS.Trim() == Device.IO_DEVICE_ADDRESS.Trim() && deviceNode.Device != Device) { MessageBox.Show("设备地址与" + deviceNode.Device.IO_DEVICE_LABLE + " 的设备地址重复!"); return; } } } if (DriverKernel != null) { ScadaResult res = DriverKernel.DeviceCtrl.IsValidParameter(); if (res.Result) { Scada.Model.SCADA_DEVICE_DRIVER driver = cb_Driver.SelectedItem as Scada.Model.SCADA_DEVICE_DRIVER; Device.DEVICE_DRIVER_ID = driver.Id; Device.IO_DEVICE_LABLE = this.txtLabel.Text.Trim(); Device.IO_DEVICE_NAME = this.txtName.Text.Trim(); Device.IO_DEVICE_REMARK = this.txtRemark.Text; Device.IO_DEVICE_STATUS = 1; Device.IO_DEVICE_ADDRESS = this.txtAddress.Text.Trim(); Device.IO_SERVER_ID = Server.SERVER_ID; Device.IO_COMM_ID = Communication.IO_COMM_ID; Device.IO_DEVICE_UPDATECYCLE = Convert.ToInt32(this.nd_updatecycle.Value); Device.IO_DEVICE_OVERTIME = Convert.ToInt32(this.nd_timeout.Value); Device.IO_DEVICE_PARASTRING = DriverKernel.DeviceCtrl.GetUIParameter(); FormManager.InsertIODeviceNode(this.Server, this.Communication, this.Device); this.DialogResult = DialogResult.OK; } else { MessageBox.Show(res.Message); } } this.txtID.Text = Device.IO_DEVICE_ID; this.txtLabel.Text = Device.IO_DEVICE_LABLE; this.txtName.Text = Device.IO_DEVICE_NAME; this.txtRemark.Text = Device.IO_DEVICE_REMARK; this.nd_timeout.Value = Device.IO_DEVICE_OVERTIME; this.nd_updatecycle.Value = Device.IO_DEVICE_UPDATECYCLE; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Scada.Model.SCADA_DEVICE_DRIVER model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Scada.Model.SCADA_DEVICE_DRIVER model) { return(dal.Add(model)); }