public IOCommunicationNode GetCommunicationNode(IO_SERVER server, IO_COMMUNICATION communication) { for (int i = 0; i < this.Nodes.Count; i++) { if (this.Nodes[i] is IOServerNode) { IOServerNode serNode = this.Nodes[i] as IOServerNode; if (serNode.Server == server) { for (int j = 0; j < serNode.Nodes.Count; j++) { if (serNode.Nodes[j] is IOCommunicationNode) { IOCommunicationNode commNode = serNode.Nodes[j] as IOCommunicationNode; if (commNode.Communication == communication) { return(commNode); } } } } } } return(null); }
public void InitDevice(IO_SERVER server, IO_COMMUNICATION communication, IO_DEVICE device) { Device = device; Server = server; Communication = communication; SeriesIndex = -1; InitSeires(); InitListView(); if (Device != null) { //获取读取实时值 IOCenterManager.QueryFormManager.ReadRealDevice(this.Server, this.Communication, this.Device); TreeNode[] finders = this.hsComboBox.TreeView.Nodes.Find(Device.IO_DEVICE_ID, true); if (finders.Length > 0) { IoDeviceTreeNode node = finders[0] as IoDeviceTreeNode; this.hsComboBox.ShowItem(node); } realtimer.Interval = Device.IO_DEVICE_UPDATECYCLE * 1000; } if (Device != null) { realtimer.Interval = this.Device.IO_DEVICE_UPDATECYCLE * 1000; realtimer.Tick += Realtimer_Tick; realtimer.Start(); } }
public IOCommunicationNode() { Communication = new IO_COMMUNICATION(); mContextMenu = new ContextMenu(); mContextMenu.MenuItems.Add(new MenuItem("删除通讯通道") { Tag = 1 }); mContextMenu.MenuItems.Add(new MenuItem("修改通讯通道") { Tag = 2 }); mContextMenu.MenuItems.Add(new MenuItem("新增设备") { Tag = 3 }); mContextMenu.MenuItems[0].Click += IOCommunicationNode_Click; mContextMenu.MenuItems[1].Click += IOCommunicationNode_Click; mContextMenu.MenuItems[2].Click += IOCommunicationNode_Click; this.ContextMenu = mContextMenu; Communication.IO_COMM_ID = GUIDTo16.GuidToLongID().ToString(); this.SelectedImageIndex = 1; this.StateImageIndex = 1; this.ImageIndex = 1; ChangedNode(); }
public void LoadProject() { Task.Run(() => { DataBaseFileName = Application.StartupPath + "\\IOProject\\IOCenterServer.station"; //设置数据库数据源 DbHelperSQLite.connectionString = "Data Source=" + DataBaseFileName; IO_SERVER serverBll = new IO_SERVER(); IO_COMMUNICATION commBll = new IO_COMMUNICATION(); IO_DEVICE deviceBll = new IO_DEVICE(); AddLog("初始化采集站数据......"); Servers = serverBll.GetModelList(""); AddLog("采集站数据已经完成!"); AddLog("加载通道数据......"); Communications = commBll.GetModelList(""); AddLog("通道数据已经完成!"); AddLog("加载设备及其IO点表......"); Devices = deviceBll.GetModelList(""); AddLog("加载设备及其IO点表已经完成"); for (int i = 0; i < Communications.Count; i++) { Communications[i].Devices = Devices.FindAll(x => x.IO_COMM_ID == Communications[i].IO_COMM_ID && x.IO_SERVER_ID == Communications[i].IO_SERVER_ID); } }); }
//通讯驱动被关闭后120秒后重新再连接 public static void CDriverDll_CommunctionClose(IO_SERVER server, IO_COMMUNICATION comm, object tag) { var analysisTask = Task.Run(() => { AddLogToMainLog(comm.IO_COMM_NAME + "通讯通道已关闭!"); }); }
/// <summary> /// 报警生产的显示 /// </summary> /// <param name="server"></param> /// <param name="communication"></param> /// <param name="device"></param> /// <param name="alarm"></param> /// <param name="uploadresult"></param> public void InsertMonitorAlarmListView(IO_SERVER server, IO_COMMUNICATION communication, IO_DEVICE device, IO_PARAALARM alarm, string uploadresult) { if (IOMonitorManager.IsBackRun) { return; } if (uccbRealAlarm.Checked) { if (listViewAlarm.IsHandleCreated) { listViewAlarm.BeginInvoke(new EventHandler(delegate { ListViewItem lvi = new ListViewItem(alarm.IO_ALARM_ID); lvi.SubItems.Add(alarm.IO_ALARM_DATE); lvi.SubItems.Add(alarm.IO_NAME + "[" + alarm.IO_LABEL + "]"); lvi.SubItems.Add(alarm.IO_ALARM_VALUE); lvi.SubItems.Add(alarm.IO_ALARM_TYPE); lvi.SubItems.Add(alarm.IO_ALARM_LEVEL); lvi.SubItems.Add(server.SERVER_NAME); lvi.SubItems.Add(communication.IO_COMM_NAME + "[" + communication.IO_COMM_LABEL + "]"); lvi.SubItems.Add(device.IO_DEVICE_NAME + "[" + device.IO_DEVICE_LABLE + "]"); lvi.SubItems.Add(uploadresult); listViewAlarm.Items.Insert(0, lvi); if (listViewAlarm.Items.Count > int.Parse(this.ucLateAlarmSIze.SelectedValue)) { listViewAlarm.Items.RemoveAt(listViewAlarm.Items.Count - 1); } })); } } }
public bool InitKernel(IO_SERVER server, IO_COMMUNICATION communication, IO_DEVICE device, IO_PARA para, SCADA_DEVICE_DRIVER driver) { try { this.ParaString = ""; this.DeviceParaString = ""; this.IOServer = server; this.IOCommunication = communication; this.IODevice = device; this.Driver = driver; if (para != null) { this.ParaString = para.IO_PARASTRING; } if (device != null) { this.DeviceParaString = device.IO_DEVICE_PARASTRING; } return(InitDeviceKernel(server, communication, device, para, driver)); } catch { return(false); } }
public void ChangedBinds(IO_SERVER server, IO_COMMUNICATION comm, IO_DEVICE device) { if (IOMonitorManager.IsBackRun) { return; } if (this.IsHandleCreated) { listView.BeginInvoke(new EventHandler(delegate { if (device != null) { ucRollText.Text = "IO路径: /" + server.SERVER_NAME + "/" + comm.IO_COMM_NAME + "[" + comm.IO_COMM_LABEL + "]/" + device.IO_DEVICE_NAME + "[" + device.IO_DEVICE_LABLE + "]"; this.listView.Items.Clear(); foreach (IO_PARA para in device.IOParas) { ListViewItem lvItem = new ListViewItem(para.IO_ID); lvItem.Text = para.IO_ID; lvItem.Tag = para; lvItem.SubItems.Add(para.IO_NAME); lvItem.SubItems.Add(para.IO_LABEL); lvItem.SubItems.Add(para.RealValue); lvItem.SubItems.Add(para.IO_UNIT); lvItem.SubItems.Add(para.RealDate); lvItem.SubItems.Add(para.RealQualityStamp.ToString()); lvItem.SubItems.Add(para.IO_POINTTYPE.ToString()); this.listView.Items.Add(lvItem); } } })); } }
/// <summary> /// 发送数据完成的事件 /// </summary> /// <param name="server"></param> /// <param name="device"></param> /// <param name="para"></param> /// <param name="value"></param> protected void DataSended(IO_SERVER server, IO_COMMUNICATION comm, IO_DEVICE device, IO_PARA para, string value, bool result) { if (DeviceSended != null) { DeviceSended(server, comm, device, para, value, result); } }
private void ucBtn_Search_BtnClick(object sender, EventArgs e) { if (hsComboBoxDevices.SelectedItem == null) { FrmDialog.ShowDialog(this, "请选择要查询历史数据的设备节点!", "提示"); return; } if (dateStart.Value > dateEnd.Value) { FrmDialog.ShowDialog(this, "开始时间必须小于结束时间!", "提示"); return; } if ((dateEnd.Value - dateStart.Value).Days >= 31) { FrmDialog.ShowDialog(this, "您选择的时间段太长,时间段不能超过31天!", "提示"); return; } IoDeviceTreeNode node = hsComboBoxDevices.SelectedItem as IoDeviceTreeNode; if (SearchClick != null) { this.Server = ((IoServerTreeNode)node.Parent.Parent).Server; this.Communication = ((IoCommunicationTreeNode)node.Parent).Communication; SearchClick(node.Device, e); } }
public void InitDevice(IO_SERVER server, IO_COMMUNICATION communication, IO_DEVICE device) { InitSeriesListBox(device); Device = device; Server = server; Communication = communication; this.search.StartDate = DateTime.Now.AddDays(-10); this.search.EndDate = DateTime.Now; this.listBoxSeries.Items.Clear(); //此处只增加模拟量的IO点 for (int i = 0; i < Device.IOParas.Count; i++) { if (Device.IOParas[i].IO_POINTTYPE == "模拟量") { this.listBoxSeries.Items.Add(Device.IOParas[i]); } } if (Device != null) { ///设置下拉菜单选中项 this.search.SetSelectItem(this.Server, this.Communication, this.Device); ReadHistory(); } }
public void CloseForm() { Server = null; Communication = null; Device = null; this.DialogResult = DialogResult.Cancel; }
private void btnCancel_BtnClick(object sender, EventArgs e) { Server = null; Communication = null; Device = null; this.DialogResult = DialogResult.Cancel; }
protected override bool InitCommunicateKernel(IO_SERVER server, IO_COMMUNICATION communication, List <IO_DEVICE> ioDevices, SCADA_DRIVER driver) { if (IsCreateControl) { CommunicationControl = new Modbus_Serial_Ctrl(); if (communication != null) { CommunicationControl.SetUIParameter(communication.IO_COMM_PARASTRING); } } Serial_PARA = new Modbus_Serial_PARA(); if (communication != null) { comParaPack = new ParaPack(communication.IO_COMM_PARASTRING); Serial_PARA.BaudRate = Convert.ToInt32(comParaPack.GetValue("波特率")); Serial_PARA.CollectFaultsInternal = Convert.ToInt32(comParaPack.GetValue("重试间隔")); Serial_PARA.CollectFaultsNumber = Convert.ToInt32(comParaPack.GetValue("重试次数")); Serial_PARA.ContinueCollect = comParaPack.GetValue("连续采集") == "1" ? true : false; Serial_PARA.DataBits = Convert.ToInt32(comParaPack.GetValue("数据位")); Serial_PARA.ModbusType = (ModbusType)Enum.Parse(typeof(ModbusType), comParaPack.GetValue("MODBUS类型")); Serial_PARA.OffsetInterval = Convert.ToInt32(comParaPack.GetValue("偏移间隔")); Serial_PARA.PackMaxSize = Convert.ToInt32(comParaPack.GetValue("包最大长度")); Serial_PARA.ReadTimeout = Convert.ToInt32(comParaPack.GetValue("读超时时间")); Serial_PARA.RSTSendPreKeeyTime = Convert.ToInt32(comParaPack.GetValue("发送前RTS保持时间")); Serial_PARA.RTSSendAfterKeeyTime = Convert.ToInt32(comParaPack.GetValue("发送后RTS保持时间")); Serial_PARA.RTSEnable = comParaPack.GetValue("RTS") == "1" ? true : false; Serial_PARA.SerialCheck = (SerialCheck)Enum.Parse(typeof(SerialCheck), comParaPack.GetValue("校验")); Serial_PARA.SerialPort = comParaPack.GetValue("串口"); Serial_PARA.SimulatorSerialPort = comParaPack.GetValue("模拟器串口"); Serial_PARA.SixCommmand = comParaPack.GetValue("支持6号命令") == "1" ? true : false; Serial_PARA.SixteenCommmand = comParaPack.GetValue("支持16号命令") == "1" ? true : false;; Serial_PARA.StopBits = (StopBits)Enum.Parse(typeof(StopBits), comParaPack.GetValue("停止位")); Serial_PARA.WriteTimeout = Convert.ToInt32(comParaPack.GetValue("写超时时间")); //构造获取数据命令的字节数组,Modbus for (int i = 0; i < this.IODevices.Count; i++) { object fragment = new ModbusFragmentStore(); RealData mRealData = new RealData(); mRealData.Device = this.IODevices[i]; ScadaDeviceKernel driverDll = DeviceDrives.Find(x => x.DeviceDriverID == this.IODevices[i].DEVICE_DRIVER_ID); if (driverDll != null) { driverDll.InitKernel(IOServer, IOCommunication, this.IODevices[i], null, this.IODevices[i].DriverInfo); //IO_DEVICE_ADDRESS中存储的是DTU编号 mRealData.SlaveId = this.IODevices[i].IO_DEVICE_ADDRESS; //数据库中系统编号 mRealData.DEVICEID = this.IODevices[i].IO_DEVICE_ID; //获取下发命令的参数,注意此次要进心分段存储,因为modbus一次不能超过123个寄存器地址 mRealData.Fragment = (ModbusFragmentStore)fragment; RealDevices.Add(mRealData); } } } return(true); }
/// <summary> /// /// </summary> /// <param name="server"></param> /// <param name="comm"></param> /// <param name="device"></param> /// <param name="receivedatas">接收的数据的字节</param> /// <param name="date">接收数据的日期</param> /// <param name="sender">接收数据的其它限定参数</param> protected void ReceiveData(IO_SERVER server, IO_COMMUNICATION comm, IO_DEVICE device, byte[] receivedatas, string date, object sender = null) { Task.Run(() => { if (OnDataReceived != null) { OnDataReceived(server, comm, device, receivedatas, date, sender); } }); }
/// <summary> /// 设备通讯状态变化的时候修改对应的界面显示效果,树结构中的参数 /// </summary> /// <param name="server"></param> /// <param name="device"></param> /// <param name="para"></param> /// <param name="tag"></param> protected void DeviceStatus(IO_SERVER server, IO_COMMUNICATION comm, IO_DEVICE device, IO_PARA para, object tag) { if (device != null) { if (DeviceStatusChanged != null) { DeviceStatusChanged(server, comm, device, para, tag); } } }
//由于此处Para里面设置的可能是不同命令的IO参数,所以需要返回不同命令的实时获取的数据,此处不需要返回Byte字节数组 public List <byte[]> GetDataCommandBytes(IO_SERVER server, IO_COMMUNICATION Communication, IO_DEVICE device, List <IO_PARA> paras, IO_PARA currentpara, ref object sender) { List <byte[]> cmmdBytes = new List <byte[]>(); //必须Read的IO参数 List <ModbusFragmentStore> modbusCodes = new List <ModbusFragmentStore>(); for (int i = 0; i < paras.Count; i++) { ParaPack paraPack = new ParaPack(paras[i].IO_PARASTRING); if (!modbusCodes.Exists(x => x.StoredCode == paraPack.GetValue("内存区")) && paraPack.GetValue("内存区") != "") { ModbusFragmentStore stored = new ModbusFragmentStore(); stored.StoredCode = paraPack.GetValue("内存区"); stored.Fragments = new List <ModbusFragment>(); stored.Units = new List <ushort>(); modbusCodes.Add(stored); } paraPack.Dispose(); paraPack = null; } for (int i = 0; i < paras.Count; i++) { ParaPack paraPack = new ParaPack(paras[i].IO_PARASTRING); if (paraPack.GetValue("内存区") != "") { if (modbusCodes.Exists(x => x.StoredCode == paraPack.GetValue("内存区")) && paraPack.GetValue("内存区") != "") { ModbusFragmentStore stored = modbusCodes.Find(x => x.StoredCode == paraPack.GetValue("内存区")); if (paraPack.GetValue("偏置") != "") { ushort offset = 0; if (ushort.TryParse(paraPack.GetValue("偏置"), out offset)) { if (!stored.Units.Contains(offset)) { stored.Units.Add(offset); } } } } } } ModbusFragmentStore mainStored = new ModbusFragmentStore(); //由于modbus获取寄存器最大数量是124个,所以要进行分段,最大线圈数量是1999个 foreach (ModbusFragmentStore stored in modbusCodes) { stored.MakeFragment(); mainStored.Fragments.AddRange(stored.Fragments); } //获取要解析的命令 sender = mainStored; return(cmmdBytes); }
protected virtual bool InitCommunicateKernel(IO_SERVER server, IO_COMMUNICATION communication, List <IO_DEVICE> ioDevices, SCADA_DRIVER driver) { try { return(true); } catch { return(false); } }
public void SetSelectItem(IO_SERVER server, IO_COMMUNICATION communication, IO_DEVICE device) { Device = device; Communication = communication; Server = server; TreeNode[] finders = this.hsComboBoxDevices.TreeView.Nodes.Find(device.IO_DEVICE_ID, true); if (finders.Length > 0) { IoDeviceTreeNode node = finders[0] as IoDeviceTreeNode; this.hsComboBoxDevices.ShowItem(node); } }
protected override bool InitCommunicateKernel(IO_SERVER server, IO_COMMUNICATION communication, List <IO_DEVICE> ioDevices, SCADA_DRIVER driver) { if (IsCreateControl) { CommunicationControl = new Modbus_UDP_Ctrl(); if (communication != null) { CommunicationControl.SetUIParameter(communication.IO_COMM_PARASTRING); } } Udp_PARA = new Modbus_TCP_PARA(); if (communication != null) { TcpParaPack = new ParaPack(communication.IO_COMM_PARASTRING); Udp_PARA.CollectFaultsInternal = Convert.ToInt32(TcpParaPack.GetValue("重试间隔")); Udp_PARA.CollectFaultsNumber = Convert.ToInt32(TcpParaPack.GetValue("重试次数")); Udp_PARA.ContinueCollect = TcpParaPack.GetValue("重试") == "1" ? true : false; Udp_PARA.LocalTCP_Port = TcpParaPack.GetValue("本地端口"); Udp_PARA.LocalTCP_IP = TcpParaPack.GetValue("本地IP"); Udp_PARA.SimulatorTCP_Port = TcpParaPack.GetValue("模拟设备端口"); Udp_PARA.SimulatorTCP_IP = TcpParaPack.GetValue("模拟设备IP"); Udp_PARA.WriteTimeout = int.Parse(TcpParaPack.GetValue("写超时时间")); Udp_PARA.ReadTimeout = int.Parse(TcpParaPack.GetValue("读超时时间")); Udp_PARA.WriteBufferSize = int.Parse(TcpParaPack.GetValue("写缓存")); Udp_PARA.ReadBufferSize = int.Parse(TcpParaPack.GetValue("读缓存")); //构造获取数据命令的字节数组,Modbus for (int i = 0; i < this.IODevices.Count; i++) { object fragment = new ModbusFragmentStore(); RealData mRealData = new RealData(); mRealData.Device = this.IODevices[i]; ScadaDeviceKernel driverDll = DeviceDrives.Find(x => x.DeviceDriverID == this.IODevices[i].DEVICE_DRIVER_ID); if (driverDll != null) { driverDll.InitKernel(IOServer, IOCommunication, this.IODevices[i], null, this.IODevices[i].DriverInfo); //IO_DEVICE_ADDRESS中存储的是DTU编号 mRealData.SlaveId = this.IODevices[i].IO_DEVICE_ADDRESS; //数据库中系统编号 mRealData.DEVICEID = this.IODevices[i].IO_DEVICE_ID; //获取下发命令的参数,注意此次要进心分段存储,因为modbus一次不能超过123个寄存器地址 //mRealData.ReadSendByte = driverDll.GetDataCommandBytes(this.IOServer, this.IOCommunication, this.IODevices[i], this.IODevices[i].IOParas, null, ref fragment); } mRealData.Fragment = (ModbusFragmentStore)fragment; RealDevices.Add(mRealData); } } return(true); }
/// <summary> /// 初始化驱动 /// </summary> /// <param name="server"></param> /// <param name="communication"></param> /// <param name="ioDevices"></param> /// <param name="driver"></param> /// <returns></returns> protected override bool InitCommunicateKernel(IO_SERVER server, IO_COMMUNICATION communication, List <IO_DEVICE> ioDevices, SCADA_DRIVER driver) { try { ParaPack communicatePack = new ParaPack(communication.IO_COMM_PARASTRING); if (communication.IO_COMM_PARASTRING != null && communication.IO_COMM_PARASTRING != "") { this.ServerIP = communicatePack.GetValue("服务器IP"); this.ServerPort = int.Parse(communicatePack.GetValue("端口号")); this.UserName = communicatePack.GetValue("用户名"); this.Password = communicatePack.GetValue("密码"); this.EaableAnonymousAuthentication = bool.Parse(communicatePack.GetValue("开启匿名验证")); this.HeartTime = int.Parse(communicatePack.GetValue("心跳时间")); string msgqulity = communicatePack.GetValue("消息质量"); switch (msgqulity) { case "QoS 0 最多分发一次": MessageQulity = MqttQualityOfServiceLevel.AtMostOnce; break; case "QoS 1 至少分发一次": MessageQulity = MqttQualityOfServiceLevel.AtLeastOnce; break; case "QoS 2 只分发一次": MessageQulity = MqttQualityOfServiceLevel.ExactlyOnce; break; } this.WillFlag = communicatePack.GetValue("遗愿标志"); this.MqttDataType = communicatePack.GetValue("数据格式"); this.EaableClientIDAuthentication = bool.Parse(communicatePack.GetValue("开启Mqtt客户端识别")); } if (IsCreateControl) { CommunicationControl = new MQTTServerCtrl(); if (communication != null && communication.IO_COMM_PARASTRING != "") { CommunicationControl.SetUIParameter(communication.IO_COMM_PARASTRING); } } } catch (Exception emx) { this.DeviceException(emx.Message); return(false); } return(true); }
/// <summary> /// 本通讯通道内设备发送数据后返回的事件 /// </summary> /// <param name="server"></param> /// <param name="comm"></param> /// <param name="device"></param> /// <param name="para"></param> /// <param name="value"></param> /// <param name="result"></param> public static void CDriverDll_DeviceSended(IO_SERVER server, IO_COMMUNICATION comm, IO_DEVICE device, IO_PARA para, string value, bool result) { var analysisTask = Task.Run(() => { if (result) { AddLogToMainLog("下置" + device.IO_DEVICE_NAME + "设备" + para.IO_NAME + "IO点值" + value + "成功!"); } else { AddLogToMainLog("下置" + device.IO_DEVICE_NAME + "设备" + para.IO_NAME + "IO点值" + value + "失败!"); } }); }
//发送下置命令,没有返回结构的值 public ScadaResult SendCommand(IO_SERVER server, IO_COMMUNICATION comm, IO_DEVICE device, IO_PARA para, string value) { try { ScadaResult result = IOSendCommand(server, comm, device, para, value); if (DeviceSended != null) { DeviceSended(server, comm, device, para, value, false); } return(result); } catch { return(new ScadaResult(false, "发送数据失败")); } }
public override bool InitDriver(IO_SERVER server, IO_COMMUNICATION communication, List <IO_DEVICE> ioDevices, SCADA_DRIVER driver) { try { base.InitDriver(server, communication, ioDevices, driver); if (IsCreateControl) { CommunicationControl = new Modbus_TCP_Network_Bridge_Ctrl(); } } catch { return(false); } return(true); }
//用户发送下置命令 public override bool SendCommand(IO_SERVER server, IO_COMMUNICATION communication, IO_DEVICE device, IO_PARA para, string value) { try { Dtu_Data data = new Dtu_Data(); data.DeviceID = device.IO_DEVICE_ID; //获取value 的字节数组 DeviceDrive driver = DeviceDrives.Find(x => x.DeviceDriverID == device.DEVICE_DRIVER_ID); if (driver != null) { data.datas = driver.GetSendValueBytes(server, this.IOCommunication, device, para, value); this.DeviceException("error=10011," + device.IO_DEVICE_ADDRESS + "设备驱动不存在"); } data.ParaID = para.IO_ID; data.DtuID = device.IO_DEVICE_ADDRESS; data.DataStatus = DataStatus.WriterData; string error = ""; bool result = false; Thread.Sleep(100);//停止10秒,保证之前发送命令已经发送出去 if (!svr.Send(data.DtuID, data.datas, out error, false)) { this.DeviceException("error=10010" + error); result = false; } else { result = true; } //信息发送完成的事件 DataSended(server, this.IOCommunication, device, para, value, result); return(true); ///接收的数据 } catch (Exception emx) { return(false); } finally { } }
public override bool InitDrive(IO_SERVER server, IO_COMMUNICATION communication, IO_DEVICE device, IO_PARA para, SCADA_DEVICE_DRIVER driver) { bool res = base.InitDrive(server, communication, device, para, driver); if (res) { if (IsCreateControl) { if (para != null) { this.ParaCtrl = new TCP_IOParaCtrl(); } this.DeviceCtrl = new TCP_IODeviceCtrl(); } } return(res); }
public void InitDevice(IO_SERVER server, IO_COMMUNICATION communication, IO_DEVICE device) { Device = device; Server = server; Communication = communication; this.search.StartDate = DateTime.Now.AddDays(-10); this.search.EndDate = DateTime.Now; if (Device != null) { ///设置下拉菜单选中项 this.search.SetSelectItem(this.Server, this.Communication, this.Device); ReadAlarmHistory(); } }
public IOData AnalysisData(IO_SERVER server, IO_COMMUNICATION Communication, IO_DEVICE device, IO_PARA para, byte[] datas, DateTime datatime, object sender) { try { return(Task <IOData> .Run(() => { IOData data = Analysis(server, Communication, device, para, datas, datatime, sender); return data; }).Result); } catch (Exception emx) { DeviceException(emx.Message); return(null); } }
protected override bool InitDeviceKernel(IO_SERVER server, IO_COMMUNICATION communication, IO_DEVICE device, IO_PARA para, SCADA_DEVICE_DRIVER driver) { if (IsCreateControl) { if (para != null) { this.ParaCtrl = new IOParaCtrl(); this.ParaCtrl.SetUIParameter(server, device, para); } this.DeviceCtrl = new IODeviceCtrl(); this.DeviceCtrl.SetUIParameter(server, device); } if (para != null) { this.ParaString = para.IO_PARASTRING; } this.DeviceParaString = device.IO_DEVICE_PARASTRING; return(true); }
private void hsComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (hsComboBoxDevices.SelectedItem != null) { IoDeviceTreeNode node = hsComboBoxDevices.SelectedItem as IoDeviceTreeNode; //如果选择的还是同一个设备,就不做处理 if (this.Device != node.Device) { this.Server = node.Server; this.Communication = node.Communication; this.Device = node.Device; if (SelectedIndexChanged != null) { SelectedIndexChanged(sender, e); } } } }