diff --git a/SlnMesnac.Business/AutoModeBusiness.cs b/SlnMesnac.Business/AutoModeBusiness.cs index 1efb2dc..c46ac02 100644 --- a/SlnMesnac.Business/AutoModeBusiness.cs +++ b/SlnMesnac.Business/AutoModeBusiness.cs @@ -61,8 +61,6 @@ namespace SlnMesnac.Business _appConfig = appConfig; } - private bool isFlag = false; - public void Start() { try @@ -91,7 +89,10 @@ namespace SlnMesnac.Business _log.Info($"自动模式初始化成功"); this.AutoModelEvent(null, null); - Task.Delay(1000 * 60 * _appConfig.checkCycle).Wait(); + if (isFlag) + { + Task.Delay(1000 * 60 * _appConfig.checkCycle).Wait(); + } } } @@ -139,6 +140,12 @@ namespace SlnMesnac.Business int address = _plc.readInt32ByAddress("VD1100"); //读取轨道电机当前位置,判断原点及起始位置 + if (!isFlag) + { + _log.Info($"自动巡检取消"); + return; + } + //获取电柜信息 List cabinet_Infos = new List(); base.GetCabinetInfos(address, out cabinet_Infos); @@ -160,6 +167,12 @@ namespace SlnMesnac.Business throw new ArgumentException($"下发母排检测完成下发检测完成信号写入失败;VD1512写1"); } Task.Delay(1000).Wait(); + + if (!isFlag) + { + _log.Info($"自动巡检取消"); + break; + } } _log.Info($"巡检结束"); @@ -185,6 +198,11 @@ namespace SlnMesnac.Business this.AwaitArriveSignal("VD1528"); //等待轨道相机到位信号 + if (!isFlag) + { + return; + } + this.SendLiftMotorDict(item.cabinetCode); //if (!_plc.writeInt32ByAddress("VD1520", 0)) @@ -203,7 +221,7 @@ namespace SlnMesnac.Business { List busbar_Infos = new List(); - base.GetBusbarInfos(cabinetCode, out busbar_Infos); + base.GetBusbarInfos(cabinetCode, out busbar_Infos,0); foreach (var busbar in busbar_Infos) { if (!_plc.writeFloatByAddress("VD1524", ((float)busbar.busbarDist))) //下发母排距离,升降电机升降的距离 @@ -214,8 +232,13 @@ namespace SlnMesnac.Business this.AwaitArriveSignal("VD1504"); //等待升降电机到位信号 + if (!isFlag) + { + return; + } + //控制云台旋转 - if(busbar.isRotate == 1) + if (busbar.isRotate == 1) { GimbaRotationControlEvent?.Invoke(busbar.wPanPos, busbar.wTiltPos, busbar.wZoomPos); } @@ -253,6 +276,12 @@ namespace SlnMesnac.Business bool is_arrive = true; while (is_arrive) { + + if (!isFlag) + { + break; + } + int is_arrive_flag = _plc.readInt32ByAddress(signal); //读取PLC轨道电机到位信号 if (is_arrive_flag == 1) { diff --git a/SlnMesnac.Business/BusbarInfoBusiness.cs b/SlnMesnac.Business/BusbarInfoBusiness.cs index c5c1cba..68e4597 100644 --- a/SlnMesnac.Business/BusbarInfoBusiness.cs +++ b/SlnMesnac.Business/BusbarInfoBusiness.cs @@ -39,7 +39,7 @@ namespace SlnMesnac.Business _ibase_Busbar_InfoServices = ibase_Busbar_InfoServices; } - public void QueryBusbarInfo(int cabinetCode, out List infos) + public void QueryBusbarInfo(int cabinetCode, out List infos,bool isInsp = true) { Expression> exp = s1 => true; if (cabinetCode > 0) @@ -47,6 +47,11 @@ namespace SlnMesnac.Business exp = exp.And(x => x.cabinetCode == cabinetCode); } + if (!isInsp) + { + exp = exp.And(x => x.isInsp == 0); + } + infos = _ibase_Busbar_InfoServices.Query(exp); } } diff --git a/SlnMesnac.Business/InspModeBusiness.cs b/SlnMesnac.Business/InspModeBusiness.cs index 3940bb0..0c28d5b 100644 --- a/SlnMesnac.Business/InspModeBusiness.cs +++ b/SlnMesnac.Business/InspModeBusiness.cs @@ -57,18 +57,18 @@ namespace SlnMesnac.Business public void Start(string taskCode,string filePath) { - //record_inspection_cabinet record_Inspection = new record_inspection_cabinet(); - //record_Inspection.taskCode = taskCode; - //record_Inspection.filePath = filePath; - //record_Inspection.beginTime = DateTime.Now; - //_service.Insert(record_Inspection); + if (isFlag) + { + _log.Info($"自动模式运行中,请勿重复开启"); + return; + } InspModeEvent(); } - public void Stop(string taskCode, string filePath) + public void Stop() { - + isFlag = false; } private void InspModeEvent() @@ -79,10 +79,18 @@ namespace SlnMesnac.Business { Task.Delay(1000).Wait(); + isFlag = true; + base.InitEquip(1); //判断PLC状态,下发工作模式 int address = _plc.readInt32ByAddress("VD1100"); //读取轨道电机当前位置,判断原点及起始位置 + if (!isFlag) + { + _log.Info($"快速巡检取消"); + return; + } + //获取电柜信息 List cabinet_Infos = new List(); base.GetCabinetInfos(address, out cabinet_Infos); @@ -104,6 +112,12 @@ namespace SlnMesnac.Business throw new ArgumentException($"快速巡检下发检测完成信号写入失败;VD1512写1"); } Task.Delay(1000).Wait(); + + if (!isFlag) + { + _log.Info($"快速巡检取消"); + break; + } } _log.Info($"快速巡检结束"); @@ -130,6 +144,11 @@ namespace SlnMesnac.Business this.AwaitArriveSignal("VD1528"); //等待轨道相机到位信号 + if (!isFlag) + { + return; + } + this.SendLiftMotorDict(item.cabinetCode); @@ -144,7 +163,7 @@ namespace SlnMesnac.Business { List busbar_Infos = new List(); - base.GetBusbarInfos(cabinetCode, out busbar_Infos); + base.GetBusbarInfos(cabinetCode, out busbar_Infos,1); foreach (var busbar in busbar_Infos) { if (!_plc.writeFloatByAddress("VD1524", ((float)busbar.busbarDist))) //下发母排距离,升降电机升降的距离 @@ -155,6 +174,11 @@ namespace SlnMesnac.Business this.AwaitArriveSignal("VD1504"); //等待升降电机到位信号 + if (!isFlag) + { + return; + } + //控制云台旋转 if (busbar.isRotate == 1) { @@ -188,6 +212,12 @@ namespace SlnMesnac.Business bool is_arrive = true; while (is_arrive) { + + if (!isFlag) + { + break; + } + int is_arrive_flag = _plc.readInt32ByAddress(signal); //读取PLC轨道电机到位信号 if (is_arrive_flag == 1) { diff --git a/SlnMesnac.Business/base/BaseBusiness.cs b/SlnMesnac.Business/base/BaseBusiness.cs index 299f1b4..f3c696c 100644 --- a/SlnMesnac.Business/base/BaseBusiness.cs +++ b/SlnMesnac.Business/base/BaseBusiness.cs @@ -42,6 +42,8 @@ namespace SlnMesnac.Business.@base public readonly Ibase_cabinet_infoServices _ibase_Cabinet_InfoServices; public readonly Ibase_busbar_infoServices _ibase_Busbar_InfoServices; + public bool isFlag = false; + public BaseBusiness(SerilogHelper log,PlcAbsractFactory plc, Ibase_cabinet_infoServices base_Cabinet_InfoServices, Ibase_busbar_infoServices base_Busbar_InfoServices) { @@ -63,6 +65,12 @@ namespace SlnMesnac.Business.@base int plcFlag = 0; do { + + if (!isFlag) + { + break; + } + plcFlag = _plc.readInt32ByAddress("VD1508"); //PLC状态 if (plcFlag != 1) { @@ -110,9 +118,9 @@ namespace SlnMesnac.Business.@base /// /// /// - public void GetBusbarInfos(int cabinetCode,out List busbarInfos) + public void GetBusbarInfos(int cabinetCode,out List busbarInfos,int isInsp = 0) { - busbarInfos = _ibase_Busbar_InfoServices.Query(x=>x.cabinetCode == cabinetCode && x.isChecked == 1).ToList(); + busbarInfos = _ibase_Busbar_InfoServices.Query(x=>x.cabinetCode == cabinetCode && x.isChecked == 1 && x.isInsp == isInsp).ToList(); } } } diff --git a/SlnMesnac.Model/domain/base_busbar_info.cs b/SlnMesnac.Model/domain/base_busbar_info.cs index 707f405..9efe6e9 100644 --- a/SlnMesnac.Model/domain/base_busbar_info.cs +++ b/SlnMesnac.Model/domain/base_busbar_info.cs @@ -145,5 +145,11 @@ namespace SlnMesnac.Repository [SugarColumn(ColumnName = "is_rotate")] public int? isRotate { get; set; } + /// + /// 是否快速巡检 + /// + [SugarColumn(ColumnName = "is_insp")] + public int isInsp { get; set;} + } } diff --git a/SlnMesnac.WPF/Page/CabinetInfo/CabinetInfoControl.xaml b/SlnMesnac.WPF/Page/CabinetInfo/CabinetInfoControl.xaml index cfcf1ca..7458ad0 100644 --- a/SlnMesnac.WPF/Page/CabinetInfo/CabinetInfoControl.xaml +++ b/SlnMesnac.WPF/Page/CabinetInfo/CabinetInfoControl.xaml @@ -102,9 +102,9 @@ - - - + + + @@ -112,9 +112,10 @@ - + + diff --git a/SlnMesnac.WPF/Page/IndexControl.xaml b/SlnMesnac.WPF/Page/IndexControl.xaml index b20c8f6..cb73cbf 100644 --- a/SlnMesnac.WPF/Page/IndexControl.xaml +++ b/SlnMesnac.WPF/Page/IndexControl.xaml @@ -651,8 +651,8 @@ Canvas.Left="245" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1"> - - + + diff --git a/SlnMesnac.WPF/Page/IndexControl.xaml.cs b/SlnMesnac.WPF/Page/IndexControl.xaml.cs index 64ddfdf..ff59bd0 100644 --- a/SlnMesnac.WPF/Page/IndexControl.xaml.cs +++ b/SlnMesnac.WPF/Page/IndexControl.xaml.cs @@ -160,6 +160,12 @@ namespace SlnMesnac.WPF.Page return; } + if (is_fixed_model) + { + MessageBox.Show("当前处于手动模式中,请先关闭手动模式,再开启巡检模式"); + return; + } + btn_automatic.Background = new SolidColorBrush(Colors.LightBlue); is_insp_model = true; indexControlViewModel.Start_InspMode(); @@ -186,7 +192,15 @@ namespace SlnMesnac.WPF.Page if (is_insp_model) { MessageBox.Show("当前处于巡检模式中,请先关闭巡检模式,再开启自动模式"); + return; } + + if (is_fixed_model) + { + MessageBox.Show("当前处于手动模式中,请先关闭手动模式,再开启自动模式"); + return; + } + btn_autotask.Background = new SolidColorBrush(Colors.LightBlue); is_auto_model = true; indexControlViewModel.Start_AutoMode(); @@ -200,6 +214,39 @@ namespace SlnMesnac.WPF.Page } } + private bool is_fixed_model = false; + /// + /// 巡检模式切换 + /// + /// + /// + private void btn_fixedmode_MouseDown(object sender, MouseButtonEventArgs e) + { + if (!is_fixed_model) + { + if (is_auto_model) + { + MessageBox.Show("当前处于自动模式中,请先关闭自动模式,再开启手动模式"); + return; + } + + if (is_insp_model) + { + MessageBox.Show("当前处于巡检模式中,请先关闭巡检模式,再开启手动模式"); + return; + } + + btn_fixedmode.Background = new SolidColorBrush(Colors.LightBlue); + is_fixed_model = true; + } + else + { + btn_fixedmode.Background = new SolidColorBrush(Colors.Transparent); + is_fixed_model = false; + + } + } + /// /// 开启预览 /// @@ -273,13 +320,10 @@ namespace SlnMesnac.WPF.Page // 添加点击事件 station.MouseLeftButtonDown += (sender, e) => { - // 获取被点击的 Rectangle 对象 Rectangle clickedStation = sender as Rectangle; - // 检查是否成功转换 if (clickedStation != null) { - // 获取并输出当前点击的 Name 属性 string stationName = clickedStation.Name; FixedPointInspection(Convert.ToInt32(clickedStation.Name.Replace("station", string.Empty))); } @@ -448,12 +492,14 @@ namespace SlnMesnac.WPF.Page private void FixedPointInspection(int cabinetCode) { - FixedPointWindow fixedPointWindow = new FixedPointWindow(cabinetCode); - // 设置窗口属性使其居中顶层显示 - fixedPointWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen; - fixedPointWindow.Topmost = true; - fixedPointWindow.ShowDialog(); - + if (is_fixed_model) + { + FixedPointWindow fixedPointWindow = new FixedPointWindow(cabinetCode); + // 设置窗口属性使其居中顶层显示 + fixedPointWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen; + fixedPointWindow.Topmost = true; + fixedPointWindow.ShowDialog(); + } } } diff --git a/SlnMesnac.WPF/ViewModel/FixedPointViewModel.cs b/SlnMesnac.WPF/ViewModel/FixedPointViewModel.cs index 8e46e54..a93fd06 100644 --- a/SlnMesnac.WPF/ViewModel/FixedPointViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/FixedPointViewModel.cs @@ -64,7 +64,7 @@ namespace SlnMesnac.WPF.ViewModel public void QueryBusbarInfo(int cabinetCode) { - busbarInfoBusiness.QueryBusbarInfo(cabinetCode, out List info); + busbarInfoBusiness.QueryBusbarInfo(cabinetCode, out List info,false); BusbarInfoItems = new ObservableCollection(info); } diff --git a/SlnMesnac.WPF/ViewModel/IndexControlViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexControlViewModel.cs index fc544a3..1557a04 100644 --- a/SlnMesnac.WPF/ViewModel/IndexControlViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/IndexControlViewModel.cs @@ -605,37 +605,37 @@ namespace SlnMesnac.WPF.ViewModel { string taskCode = DateTime.Now.ToString("yyyyMMddHHmmssffff"); string fileName = $"{taskCode}.mp4"; - Task.Run(() => - { - var url = $"{_appConfig.videoFilePath}\\可见光\\{fileName}"; - CHCNetSDK.NET_DVR_MakeKeyFrame(m_lUserID, 1); - if (!CHCNetSDK.NET_DVR_SaveRealData(Scenery_RealHandle, url)) - { - var str = "可见光通道开启巡检录像失败, error code= " + NET_DVR_GetLastError(); - _log.Info(str); - return; - } - else - { - _log.Info($"可见光通道开启巡检录像成功"); - } - }); - - Task.Run(() => - { - var url = $"{_appConfig.videoFilePath}\\热成像\\{fileName}"; - CHCNetSDK.NET_DVR_MakeKeyFrame(m_lUserID, 2); - if (!CHCNetSDK.NET_DVR_SaveRealData(Thermal_RealHandle, url)) - { - var str = "热成像通道开启巡检录像失败, error code= " + NET_DVR_GetLastError(); - _log.Info(str); - return; - } - else - { - _log.Info($"热成像通道开启巡检录像成功"); - } - }); + //Task.Run(() => + //{ + // var url = $"{_appConfig.videoFilePath}\\可见光\\{fileName}"; + // CHCNetSDK.NET_DVR_MakeKeyFrame(m_lUserID, 1); + // if (!CHCNetSDK.NET_DVR_SaveRealData(Scenery_RealHandle, url)) + // { + // var str = "可见光通道开启巡检录像失败, error code= " + NET_DVR_GetLastError(); + // _log.Info(str); + // return; + // } + // else + // { + // _log.Info($"可见光通道开启巡检录像成功"); + // } + //}); + + //Task.Run(() => + //{ + // var url = $"{_appConfig.videoFilePath}\\热成像\\{fileName}"; + // CHCNetSDK.NET_DVR_MakeKeyFrame(m_lUserID, 2); + // if (!CHCNetSDK.NET_DVR_SaveRealData(Thermal_RealHandle, url)) + // { + // var str = "热成像通道开启巡检录像失败, error code= " + NET_DVR_GetLastError(); + // _log.Info(str); + // return; + // } + // else + // { + // _log.Info($"热成像通道开启巡检录像成功"); + // } + //}); inspModeBusiness.Start(taskCode, fileName); } @@ -645,33 +645,35 @@ namespace SlnMesnac.WPF.ViewModel /// public void Stop_InspMode() { - Task.Run(() => - { - if (!CHCNetSDK.NET_DVR_StopSaveRealData(Scenery_RealHandle)) - { - var str = "可见光通道关闭巡检录像失败, error code= " + NET_DVR_GetLastError(); - _log.Info(str); - return; - } - else - { - _log.Info($"可见光通道关闭巡检录像成功"); - } - }); - - Task.Run(() => - { - if (!CHCNetSDK.NET_DVR_StopSaveRealData(Thermal_RealHandle)) - { - var str = "热成像通道关闭巡检录像失败, error code= " + NET_DVR_GetLastError(); - _log.Info(str); - return; - } - else - { - _log.Info($"热成像通道关闭巡检录像成功"); - } - }); + //Task.Run(() => + //{ + // if (!CHCNetSDK.NET_DVR_StopSaveRealData(Scenery_RealHandle)) + // { + // var str = "可见光通道关闭巡检录像失败, error code= " + NET_DVR_GetLastError(); + // _log.Info(str); + // return; + // } + // else + // { + // _log.Info($"可见光通道关闭巡检录像成功"); + // } + //}); + + //Task.Run(() => + //{ + // if (!CHCNetSDK.NET_DVR_StopSaveRealData(Thermal_RealHandle)) + // { + // var str = "热成像通道关闭巡检录像失败, error code= " + NET_DVR_GetLastError(); + // _log.Info(str); + // return; + // } + // else + // { + // _log.Info($"热成像通道关闭巡检录像成功"); + // } + //}); + + inspModeBusiness.Stop(); } private int lastTrackMotorAddress = 0; diff --git a/SlnMesnac.WPF/appsettings.json b/SlnMesnac.WPF/appsettings.json index b3eb2e0..e40b46a 100644 --- a/SlnMesnac.WPF/appsettings.json +++ b/SlnMesnac.WPF/appsettings.json @@ -28,8 +28,8 @@ { "configId": 1, "plcType": "SiemensPlc", - //"plcIp": "127.0.0.1", - "plcIp": "192.168.2.1", + "plcIp": "127.0.0.1", + //"plcIp": "192.168.2.1", "plcPort": 102, "plcKey": "iot", "isFlage": "true"