change - 巡检模式修改

master
wenjy 2 months ago
parent 3aae8ae90a
commit 607b0c2fa4

@ -61,8 +61,6 @@ namespace SlnMesnac.Business
_appConfig = appConfig;
}
private bool isFlag = false;
public void Start()
{
try
@ -91,9 +89,12 @@ namespace SlnMesnac.Business
_log.Info($"自动模式初始化成功");
this.AutoModelEvent(null, null);
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<base_cabinet_info> cabinet_Infos = new List<base_cabinet_info>();
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<base_busbar_info> busbar_Infos = new List<base_busbar_info>();
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,6 +232,11 @@ namespace SlnMesnac.Business
this.AwaitArriveSignal("VD1504"); //等待升降电机到位信号
if (!isFlag)
{
return;
}
//控制云台旋转
if (busbar.isRotate == 1)
{
@ -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)
{

@ -39,7 +39,7 @@ namespace SlnMesnac.Business
_ibase_Busbar_InfoServices = ibase_Busbar_InfoServices;
}
public void QueryBusbarInfo(int cabinetCode, out List<base_busbar_info> infos)
public void QueryBusbarInfo(int cabinetCode, out List<base_busbar_info> infos,bool isInsp = true)
{
Expression<Func<base_busbar_info, bool>> 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);
}
}

@ -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<base_cabinet_info> cabinet_Infos = new List<base_cabinet_info>();
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<base_busbar_info> busbar_Infos = new List<base_busbar_info>();
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)
{

@ -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
/// </summary>
/// <param name="cabinetCode"></param>
/// <param name="busbarInfos"></param>
public void GetBusbarInfos(int cabinetCode,out List<base_busbar_info> busbarInfos)
public void GetBusbarInfos(int cabinetCode,out List<base_busbar_info> 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();
}
}
}

@ -145,5 +145,11 @@ namespace SlnMesnac.Repository
[SugarColumn(ColumnName = "is_rotate")]
public int? isRotate { get; set; }
/// <summary>
/// 是否快速巡检
/// </summary>
[SugarColumn(ColumnName = "is_insp")]
public int isInsp { get; set;}
}
}

@ -102,9 +102,9 @@
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding cabinetCode}" Header="电柜编号" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding busbarCode}" Header="母排编号" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding busbarAlias}" Header="母排别名" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding busbarDist}" Header="母排距离" Width="2*" IsReadOnly="True"/>
<!--<DataGridTextColumn Binding="{Binding busbarCode}" Header="母排编号" Width="2*" IsReadOnly="True"/>-->
<DataGridTextColumn Binding="{Binding busbarAlias}" Header="检测位置" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding busbarDist}" Header="升降距离" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding isRotate,Converter={StaticResource IsFlagConvert}}" Header="是否旋转" Width="2*" IsReadOnly="True"/>
@ -112,9 +112,10 @@
<DataGridTextColumn Binding="{Binding wTiltPos}" Header="T" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding wZoomPos}" Header="Z" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding isEnd,Converter={StaticResource IsFlagConvert}}" Header="是否尾排" Width="2*" IsReadOnly="True"/>
<!--<DataGridTextColumn Binding="{Binding isEnd,Converter={StaticResource IsFlagConvert}}" Header="是否尾排" Width="2*" IsReadOnly="True"/>-->
<DataGridTextColumn Binding="{Binding isChecked,Converter={StaticResource IsFlagConvert}}" Header="是否检测" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding isPictures,Converter={StaticResource IsFlagConvert}}" Header="是否拍照" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding isInsp,Converter={StaticResource IsFlagConvert}}" Header="是否快检" Width="2*" IsReadOnly="True"/>
<DataGridTemplateColumn Header="操作" Width="1.5*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>

@ -651,8 +651,8 @@ Canvas.Left="245" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<TextBlock Text="巡检模式" FontSize="16" FontWeight="Black" Foreground="DimGray" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<Border Grid.Row="2" Background="Transparent" BorderBrush="#0050BF" BorderThickness="2" CornerRadius="5" Margin="0,5">
<TextBlock Text="手动模式" FontSize="16" FontWeight="Black" Foreground="DimGray" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Border x:Name="btn_fixedmode" Grid.Row="2" Background="Transparent" BorderBrush="#0050BF" BorderThickness="2" CornerRadius="5" Margin="0,5" MouseDown="btn_fixedmode_MouseDown" >
<TextBlock Text="定点巡检" FontSize="16" FontWeight="Black" Foreground="DimGray" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
</Grid>
</Border>

@ -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;
/// <summary>
/// 巡检模式切换
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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;
}
}
/// <summary>
/// 开启预览
/// </summary>
@ -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)));
}
@ -447,13 +491,15 @@ namespace SlnMesnac.WPF.Page
}
private void FixedPointInspection(int cabinetCode)
{
if (is_fixed_model)
{
FixedPointWindow fixedPointWindow = new FixedPointWindow(cabinetCode);
// 设置窗口属性使其居中顶层显示
fixedPointWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
fixedPointWindow.Topmost = true;
fixedPointWindow.ShowDialog();
}
}
}

@ -64,7 +64,7 @@ namespace SlnMesnac.WPF.ViewModel
public void QueryBusbarInfo(int cabinetCode)
{
busbarInfoBusiness.QueryBusbarInfo(cabinetCode, out List<base_busbar_info> info);
busbarInfoBusiness.QueryBusbarInfo(cabinetCode, out List<base_busbar_info> info,false);
BusbarInfoItems = new ObservableCollection<base_busbar_info>(info);
}

@ -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
/// </summary>
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;

@ -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"

Loading…
Cancel
Save