/// <summary> /// 加载数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Maintenance_Load(object sender, EventArgs e) { try { FiveHistoryRecordData = new DataTable(); FiveHistoryRecordData.Columns.Add("Point"); FiveHistoryRecordData.Columns.Add("SaveTime"); FiveHistoryRecordData.Columns.Add("TypeName"); FiveHistoryRecordData.Columns.Add("StateName"); FiveHistoryRecordData.Columns.Add("Location"); FiveHistoryRecordData.Columns.Add("DeviceTypeName"); FiveHistoryRecordData.Columns.Add("RealData"); FiveHistoryRecordData.Columns.Add("GradingAlarmLevel"); FiveHistoryRecordData.Columns.Add("Voltage"); FiveHistoryRecordData.Columns.Add("FeedBackState"); FiveHistoryRecordData.Columns.Add("FeedState"); gridControlFiveHisData.DataSource = FiveHistoryRecordData; ControlHistoryRecordData = new DataTable(); ControlHistoryRecordData.Columns.Add("Point"); ControlHistoryRecordData.Columns.Add("SaveTime"); ControlHistoryRecordData.Columns.Add("TypeName"); ControlHistoryRecordData.Columns.Add("StateName"); ControlHistoryRecordData.Columns.Add("Location"); ControlHistoryRecordData.Columns.Add("Value"); ControlHistoryRecordData.Columns.Add("ControlDeviceConvert"); gridContrlConHisData.DataSource = ControlHistoryRecordData; var allSubstation = ControlInterfaceFuction.GetAllSubstation(); //获取所有分站缓存数据 RefSubstationFiveHisDataList(allSubstation); RefSubstationConHisDataList(allSubstation); if (_refThr == null) { _ifLoop = true; _refThr = new Thread(RefThrFun) { IsBackground = true }; //_refThr = new Thread(RefThrFun); _refThr.Start(); } LoadKhAndDzh(); StationUpdate su = new StationUpdate(); su.Dock = DockStyle.Fill; su.TopLevel = false; su.TopMost = true; xtraTabPage2.Controls.Add(su); su.Show(); devList = deviceDefineService.GetAllDeviceDefineCache().Data; } catch (Exception exc) { XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// 分站电源箱label点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SubstationLabelClick(object sender, EventArgs e) { try { var tv = (Label)sender; var bi = (BatteryItem)tv.Tag; //label2.Text = bi.BatteryAddress; label2.Text = bi.Channel; _lisDef = ControlInterfaceFuction.GetAllSubstation();//重新加载 string selectStationPointId = ""; Jc_DefInfo def = _lisDef.Find(a => a.Fzh == short.Parse(selectFzhNow)); if (def != null) { selectStationPointId = def.PointID; } //查找分站对应的电源箱5分钟统计信息 BatteryPowerConsumption batteryPowerConsumption = new BatteryPowerConsumption(); if (def.BatteryPowerConsumptions != null) { batteryPowerConsumption = def.BatteryPowerConsumptions.Find(a => a.Channel == bi.Channel); } var tempCharge = new CuCharge(bi, batteryPowerConsumption); //CpanelPowerPac.Controls.Clear(); //重写释放控件的方法,直接clear会导致句柄资源一直增加 20180422 while (CpanelPowerPac.Controls.Count > 0) { if (CpanelPowerPac.Controls[0] != null) { CpanelPowerPac.Controls[0].Dispose(); } } CpanelPowerPac.Controls.Add(tempCharge); tempCharge.Dock = DockStyle.Fill; //var node = treeViewSubstation.SelectedNode; //Dictionary<string, object> dic = new Dictionary<string, object>(); //dic.Add("GetBatteryItem", ((Label)sender).Text); //dic.Add("SelNode", node); //_refStationBattery = new Thread(GetBatteryItem); //_refStationBattery.Start(dic); } catch (Exception exc) { XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//控制历史数据操作按钮事件 private void buttonControlHisData_Click(object sender, EventArgs e) { try { var rowHandle = gridViewConHisTree.FocusedRowHandle; var fzh = gridViewConHisTree.GetRowCellValue(rowHandle, "Fzh"); SubstationBindDto sbd; lock (_locker2) { sbd = _substationConHisDataBindDto.FirstOrDefault(a => a.Fzh == (string)fzh); } if (sbd == null) { XtraMessageBox.Show("未能从列表数据中找到该分站。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //发送获取数据命令 byte conType; if (sbd.DataState == "0" || sbd.DataState == "3") { conType = 1; } else { conType = 0; } var req = new List <StationControlItem>() { new StationControlItem() { controlType = conType, fzh = Convert.ToUInt16(fzh) } }; ControlInterfaceFuction.SendQueryHistoryControlRequest(req); var allSubstation = ControlInterfaceFuction.GetAllSubstation(); //获取所有分站缓存数据 RefSubstationConHisDataList(allSubstation); } catch (Exception exc) { XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
//private void GetBatteryItem(object dic) //{ // Dictionary<string, object> tempdic = dic as Dictionary<string, object>; // string batteryAddress = tempdic["GetBatteryItem"].ToString(); // var node = (TreeNode)tempdic["SelNode"]; // if (node == null) // { // return; // } // var gsa = ControlInterfaceFuction.GetSubstationPowerBoxInfo(node.Name); // if (gsa.PowerDateTime > Convert.ToDateTime("1900-01-01")) // { // BatteryItem item = gsa.PowerBoxInfo.FirstOrDefault(a => a.Channel == batteryAddress.ToString()); // if (item != null) // { // //Action<object> act = RefStationBatteryInfo; // //BeginInvoke(act, item); // MethodInvoker In = new MethodInvoker(() => RefStationBatteryInfo(item)); // if (this.InvokeRequired) // { // this.BeginInvoke(In); // } // //_substationUpdatetime[node.Name] = gsa.PowerDateTime; // //substationUpdatetime.Text = _substationUpdatetime[node.Name].ToString("yyyy-MM-dd HH:mm:ss"); // } // } //} //private void RefStationBatteryInfo(object item) //{ // var tempCharge = new CuCharge((BatteryItem)item); // CpanelPowerPac.Controls.Clear(); // CpanelPowerPac.Controls.Add(tempCharge); // tempCharge.Dock = DockStyle.Fill; // //substationUpdatetime.Text = PowerDateTime.ToString(); //} /// <summary> /// 交换机电源箱label点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SwitchLabelClick(object sender, EventArgs e) { try { var tv = (Label)sender; var bi = (BatteryItem)tv.Tag; label3.Text = bi.Channel; //加载交换机 _lisMac = ControlInterfaceFuction.GetAllSwitch(); Jc_MacInfo mac = _lisMac.Find(a => a.MAC == selectMacNow); //查找分站对应的电源箱5分钟统计信息 BatteryPowerConsumption batteryPowerConsumption = new BatteryPowerConsumption(); if (mac.BatteryPowerConsumptions != null) { batteryPowerConsumption = mac.BatteryPowerConsumptions.Find(a => a.Channel == bi.Channel); } var tempCharge = new CuCharge(bi, batteryPowerConsumption); //panelControl2.Controls.Clear(); //重写释放控件的方法,直接clear会导致句柄资源一直增加 20180422 while (panelControl2.Controls.Count > 0) { if (panelControl2.Controls[0] != null) { panelControl2.Controls[0].Dispose(); } } panelControl2.Controls.Add(tempCharge); tempCharge.Dock = DockStyle.Fill; //var node = treeViewSubstation.SelectedNode; //Dictionary<string, object> dic = new Dictionary<string, object>(); //dic.Add("GetBatteryItem", ((Label)sender).Text); //dic.Add("SelNode", node); //_refStationBattery = new Thread(GetBatteryItemForSwicth); //_refStationBattery.Start(dic); } catch (Exception exc) { XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public List <GetSubstationHistoryRealDataByFzhTimeResponse> GetSubstationHistoryRealDataByFzhTime() { List <GetSubstationHistoryRealDataByFzhTimeResponse> result = new List <GetSubstationHistoryRealDataByFzhTimeResponse>(); try { var rowHandle = gridViewFiveHisTree.FocusedRowHandle; var fzh = gridViewFiveHisTree.GetRowCellValue(rowHandle, "Fzh"); var date = dateTimePickerFiveHisData.Value; result = ControlInterfaceFuction.GetSubstationHistoryRealDataByFzhTime(fzh.ToString(), date); } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(ex); } return(result); }
//窗体关闭时 private void Maintenance_FormClosing(object sender, FormClosingEventArgs e) { try { //if ( // XtraMessageBox.Show("窗体关闭后将取消所有分站历史数据的获取,确认要执行该操作吗?", "提示", MessageBoxButtons.YesNo, // MessageBoxIcon.Question) == DialogResult.Yes) //{ //取消所有数据获取 var lisSc = new List <StationControlItem>(); //5分钟历史数据和控制历史数据共用 lock (_locker1) { foreach (var item in _substationFiveHisDataBindDto) { lisSc.Add(new StationControlItem() { fzh = Convert.ToUInt16(item.Fzh), controlType = 2 }); } } ControlInterfaceFuction.SendQueryHistoryRealDataRequest(lisSc); ControlInterfaceFuction.SendQueryHistoryControlRequest(lisSc); //if (_refThr != null && _refThr.IsAlive == true) //{ // _refThr.Abort(); //} _ifLoop = false; //注释,造成界面卡,就不用调用此段代码 20170811 //if (_refThr != null && _refThr.IsAlive == true) //{ // _refThr.Join(); //} //Dispose(); //} //else //{ // e.Cancel = true; //} } catch (Exception exc) { XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public List <GetStaionControlHistoryDataByByFzhTimeResponse> GetStaionControlHistoryDataByByFzhTime() { List <GetStaionControlHistoryDataByByFzhTimeResponse> result1 = new List <GetStaionControlHistoryDataByByFzhTimeResponse>(); try { //根据分站号获取历史记录信息 var rowHandle1 = gridViewConHisTree.FocusedRowHandle; var fzh1 = gridViewConHisTree.GetRowCellValue(rowHandle1, "Fzh"); var date1 = dateTimePickerConHisData.Value; result1 = ControlInterfaceFuction.GetStaionControlHistoryDataByByFzhTime(fzh1.ToString(), date1); } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(ex); } return(result1); }
private void DyxForm_Load(object sender, EventArgs e) { try { //加载分站树 var fzs = ControlInterfaceFuction.GetDyxFz(); //dt = fzs; if ((fzs != null) && (fzs.Rows.Count > 0)) { foreach (DataRow item in fzs.Rows) { var fzh = item["fzh"].ToString(); treeViewSubstation.Nodes.Add(fzh, fzh); _substationUpdatetime.Add(fzh, new DateTime()); } } //加载交换机树 fzs = ControlInterfaceFuction.GetDyxMac(); //dt1 = fzs; if ((fzs != null) && (fzs.Rows.Count > 0)) { foreach (DataRow item in fzs.Rows) { var wz = item["wz"].ToString(); var mac = item["mac"].ToString(); treeViewSwitch.Nodes.Add(mac, wz); _switchUpdatetime.Add(mac, new DateTime()); } } //加载风电闭锁树 //var allSubstation = ControlInterfaceFuction.GetAllSubstation(); _lisDef = ControlInterfaceFuction.GetAllSubstation(); foreach (var item in _lisDef) { treeViewInterlockedCircuitBreaker.Nodes.Add(item.Fzh.ToString(), item.Fzh.ToString()); } } catch (Exception exc) { XtraMessageBox.Show(exc.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void RefThrFun() { while (_ifLoop) { try { Thread.Sleep(5000); var allSubstation = ControlInterfaceFuction.GetAllSubstation(); //获取所有分站缓存数据 //刷新5分钟历史数据 if (this.InvokeRequired) { Action <object> act = RefSubstationFiveHisDataList; BeginInvoke(act, allSubstation); } //var result = GetSubstationHistoryRealDataByFzhTime(); //if (this.InvokeRequired) //{ // Action<object> act2 = RefFiveHistoryRecord; // BeginInvoke(act2, result); //} //刷新控制历史数据 if (this.InvokeRequired) { Action <object> act3 = RefSubstationConHisDataList; BeginInvoke(act3, allSubstation); } //var result1 = GetStaionControlHistoryDataByByFzhTime(); //if (this.InvokeRequired) //{ // Action<object> act4 = RefControlHistoryRecord; // BeginInvoke(act4, result1); //} } catch (Exception exc) { LogHelper.Error(exc); } } }
/// <summary> /// 交换机电源箱信息刷新线程函数 /// </summary> private void SwitchRefreshRefreshThrFun(object par) { WaitDialogForm wdf = new WaitDialogForm("正在获取电源箱数据...", "请等待..."); int i = 0; for (i = 0; i < 5; i++) { try { var gsp = ControlInterfaceFuction.GetSwitchPowerBoxInfo((string)par); if (gsp.PowerBoxInfo != null && gsp.PowerBoxInfo.Count > 0 && gsp.PowerDateTime > _switchUpdatetime[(string)par]) { _switchUpdatetime[(string)par] = gsp.PowerDateTime; Action <object> act = SwitchInfoRefresh; // 20170914 //BeginInvoke(act, par); BeginInvoke(act, gsp); break; } Thread.Sleep(3000); //Action<object> act = SwitchInfoRefresh; //BeginInvoke(act, par); //Thread.Sleep(3000); //if (!_ifLoop) //{ // break; //} } catch (Exception exc) { //LogHelper.Error(exc); //线程Abort时会报异常,忽略 } } if (i >= 5) { flowLayoutPanel2.BeginInvoke(new Action(() => { //flowLayoutPanel2.Controls.Clear(); //重写释放控件的方法,直接clear会导致句柄资源一直增加 20180422 while (flowLayoutPanel2.Controls.Count > 0) { if (flowLayoutPanel2.Controls[0] != null) { flowLayoutPanel2.Controls[0].Dispose(); } } })); panelControl2.BeginInvoke(new Action(() => { //panelControl2.Controls.Clear(); //重写释放控件的方法,直接clear会导致句柄资源一直增加 20180422 while (panelControl2.Controls.Count > 0) { if (panelControl2.Controls[0] != null) { panelControl2.Controls[0].Dispose(); } } })); } if (wdf != null) { wdf.Close(); } }