change - 自动巡检调试

master
wenjy 2 months ago
parent 844534ecf6
commit 643a5ed023

@ -61,17 +61,43 @@ namespace SlnMesnac.Business
_appConfig = appConfig;
}
private bool isFlag = false;
public void Start()
{
try
{
timer = new System.Timers.Timer(1000 * 60 * _appConfig.checkCycle);
timer.Elapsed += new System.Timers.ElapsedEventHandler(AutoModelEvent);
timer.AutoReset = true;
timer.Enabled = false;
timer.Start();
_log.Info($"自动模式初始化成功");
this.AutoModelEvent(null, null);
//timer = new System.Timers.Timer(1000 * 60 * _appConfig.checkCycle);
//timer.Elapsed += new System.Timers.ElapsedEventHandler(AutoModelEvent);
//timer.AutoReset = true;
//timer.Enabled = false;
//timer.Start();
//_log.Info($"自动模式初始化成功");
//this.AutoModelEvent(null, null);
if (isFlag)
{
_log.Info($"自动模式运行中,请勿重复开启");
return;
}
Task.Run(() =>
{
lock (string.Empty)
{
isFlag = true;
while (isFlag)
{
_log.Info($"自动模式初始化成功");
this.AutoModelEvent(null, null);
Task.Delay(1000 * 60 * _appConfig.checkCycle).Wait();
}
}
});
}
catch (Exception ex)
{
@ -83,13 +109,16 @@ namespace SlnMesnac.Business
{
try
{
if (timer.Enabled)
{
timer.Stop();
timer.Close();
timer.Dispose();
_log.Info($"自动模式关闭成功");
}
//if (timer.Enabled)
//{
// timer.Stop();
// timer.Close();
// timer.Dispose();
// _log.Info($"自动模式关闭成功");
//}
isFlag = false;
_log.Info($"自动模式关闭成功");
}
catch (Exception ex)
{
@ -102,49 +131,43 @@ namespace SlnMesnac.Business
/// </summary>
private void AutoModelEvent(object source, System.Timers.ElapsedEventArgs e)
{
lock(string.Empty)
try
{
try
{
Task.Run(() =>
{
Task.Delay(1000).Wait();
base.InitEquip(1); //判断PLC状态下发工作模式
Task.Delay(1000).Wait();
int address = _plc.readInt32ByAddress("VD2005"); //读取轨道电机当前位置,判断原点及起始位置
base.InitEquip(1); //判断PLC状态下发工作模式
//获取电柜信息
List<base_cabinet_info> cabinet_Infos = new List<base_cabinet_info>();
base.GetCabinetInfos(address, out cabinet_Infos);
int address = _plc.readInt32ByAddress("VD1100"); //读取轨道电机当前位置,判断原点及起始位置
if (!_plc.writeInt32ByAddress("VD1517", 1)) //下发轨道电机启动信号
{
throw new ArgumentException($"启动信号写入PLC失败VD1517写1");
}
//获取电柜信息
List<base_cabinet_info> cabinet_Infos = new List<base_cabinet_info>();
base.GetCabinetInfos(address, out cabinet_Infos);
_log.Info($"启动信号写入PLC成功VD1517写1");
if (!_plc.writeInt32ByAddress("VD1517", 1)) //下发轨道电机启动信号
{
throw new ArgumentException($"启动信号写入PLC失败VD1517写1");
}
foreach (var item in cabinet_Infos)
{
_log.Info($"启动信号写入PLC成功VD1517写1");
this.SendTrackMotorAddress(item);
foreach (var item in cabinet_Infos)
{
if (!_plc.writeInt32ByAddress("VD1513", 1)) //母排检测完成下发检测完成信号,升降电机可以回到原位等待
{
throw new ArgumentException($"下发母排检测完成下发检测完成信号写入失败VD1513写1");
}
Task.Delay(1000).Wait();
}
this.SendTrackMotorAddress(item);
_log.Info($"巡检结束");
});
}catch (Exception ex)
{
throw new InvalidOperationException($"自动巡检逻辑处理异常:{ex.Message}");
if (!_plc.writeInt32ByAddress("VD1513", 1)) //母排检测完成下发检测完成信号,升降电机可以回到原位等待
{
throw new ArgumentException($"下发母排检测完成下发检测完成信号写入失败VD1513写1");
}
Task.Delay(1000).Wait();
}
}
_log.Info($"巡检结束");
}
catch (Exception ex)
{
throw new InvalidOperationException($"自动巡检逻辑处理异常:{ex.Message}");
}
}
/// <summary>
@ -164,10 +187,10 @@ namespace SlnMesnac.Business
this.SendLiftMotorDict(item.cabinetCode);
if (!_plc.writeInt32ByAddress("VD1521", 0))
{
throw new ArgumentException($"电柜检测完成轨道电机地址写0失败VD1521写0");
}
//if (!_plc.writeInt32ByAddress("VD1521", 0))
//{
// throw new ArgumentException($"电柜检测完成轨道电机地址写0失败VD1521写0");
//}
}
@ -204,11 +227,11 @@ namespace SlnMesnac.Business
this.SaveBusbarTemp(busbar.busbarCode, busbar.cabinetCode, _realTemperatureInfo,busbar.isPictures);
Task.Delay(1000).Wait();
if (!_plc.writeFloatByAddress("VD1525", 0))
{
throw new ArgumentException($"母排检测完成向PLC升降距离写0失败VD1525写0");
}
_log.Info($"母排检测完成向PLC升降距离写0成功VD1525写0");
//if (!_plc.writeFloatByAddress("VD1525", 0))
//{
// throw new ArgumentException($"母排检测完成向PLC升降距离写0失败VD1525写0");
//}
//_log.Info($"母排检测完成向PLC升降距离写0成功VD1525写0");
if(busbar.isRotate == 1)
{
@ -311,10 +334,38 @@ namespace SlnMesnac.Business
public int GetTrackMotorAddress()
{
int is_arrive_flag = _plc.readInt32ByAddress("VD2005");
int is_arrive_flag = _plc.readInt32ByAddress("VD1100");
return is_arrive_flag;
}
public double GetDeviceSpeed()
{
double speed = _plc.readFloatByAddress("VD2022");
return speed;
}
public string GetDeviceStatus()
{
int deviceStatus = _plc.readInt32ByAddress("VD1509");
string deviceStatusFlag = string.Empty;
if (deviceStatus == 1)
{
deviceStatusFlag = "自动";
}
else if (deviceStatus == 2)
{
deviceStatusFlag = "本地";
}
else if (deviceStatus == 3)
{
deviceStatusFlag = "报警";
}
return deviceStatusFlag;
}
}
}

@ -20,7 +20,7 @@
<RowDefinition Height="0.7*"/>
</Grid.RowDefinitions>
<Border Grid.Row="0" BorderBrush="Red" BorderThickness="0" CornerRadius="0" Background="#0050BF">
<TextBlock Text="轨道巡检控制系统" FontSize="30" Foreground="White" FontWeight="Bold" Margin="50,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<TextBlock Text="智能巡检控制系统" FontSize="30" Foreground="White" FontWeight="Bold" Margin="50,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center"/>
</Border>
<Border Grid.Row="1" BorderBrush="Red" BorderThickness="0" CornerRadius="5" Background="Transparent" Margin="0,20">
<ContentControl Content="{Binding UserContent}"/>

@ -330,7 +330,7 @@ Canvas.Left="245" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<TextBlock Text="设备状态" Foreground="Gray" FontSize="16" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
<Border Grid.Row="0" Grid.Column="2">
<TextBlock Text="停止" FontSize="16" Foreground="Red" FontWeight="Black" VerticalAlignment="Center"/>
<TextBlock Text="{Binding RealDeviceStatus}" FontSize="16" Foreground="Red" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
<Border Grid.Row="1" Grid.Column="0">
<Image Source="/Templates/image/speed.png" Margin="10"/>
@ -339,8 +339,8 @@ Canvas.Left="245" Canvas.Top="155" Stroke="Transparent" StrokeThickness="1">
<TextBlock Text="运行速度" Foreground="Gray" FontSize="16" FontWeight="Black" VerticalAlignment="Center"/>
</Border>
<StackPanel Grid.Row="1" Grid.Column="2" Orientation="Horizontal">
<TextBlock Text="0" FontSize="16" Foreground="Gray" FontWeight="Black" VerticalAlignment="Center"/>
<TextBlock Text="m/s" FontSize="16" Foreground="Gray" FontWeight="Black" Margin="20,0,0,0" VerticalAlignment="Center"/>
<TextBlock Text="{Binding RealDeviceSpeed}" FontSize="16" Foreground="Gray" FontWeight="Black" VerticalAlignment="Center"/>
<TextBlock Text="mm/s" FontSize="16" Foreground="Gray" FontWeight="Black" Margin="20,0,0,0" VerticalAlignment="Center"/>
</StackPanel>

@ -241,6 +241,12 @@ namespace SlnMesnac.WPF.Page
for (int i = 0; i < 19; i++)
{
var stationNumber = GetStationNumber(i, true);
if(stationNumber == 0)
{
continue;
}
Rectangle station = new Rectangle
{
Width = 35,
@ -343,7 +349,7 @@ namespace SlnMesnac.WPF.Page
{
List<int> list = new List<int>()
{
26,27,28,29,30,31,32,33,34,1,2,3,4,5,6,7,8,9,10
25,26,27,28,29,30,31,32,33,0,1,2,3,4,5,6,7,8,9
};
number = list[i];
@ -352,7 +358,7 @@ namespace SlnMesnac.WPF.Page
{
List<int> list = new List<int>()
{
25,24,23,22,21,20,19,18,17,16,15,14,13,12,11
24,23,22,21,20,19,18,17,16,15,14,13,12,11,10
};
number = list[i];

@ -96,6 +96,20 @@ namespace SlnMesnac.WPF.ViewModel
set => SetProperty(ref _realPlcAddress, value);
}
private double _realDeviceSpeed = 0.0;
public double RealDeviceSpeed
{
get => _realDeviceSpeed;
set => SetProperty(ref _realDeviceSpeed, value);
}
private string _realDeviceStatus = "未连接";
public string RealDeviceStatus
{
get => _realDeviceStatus;
set => SetProperty(ref _realDeviceStatus, value);
}
public RealTemperatureInfo _realTemperature;
public RealTemperatureInfo RealTemperature
{
@ -665,6 +679,11 @@ namespace SlnMesnac.WPF.ViewModel
RealPlcAddress = trackMotorAddress;
RefreshHighlightStationEvent?.Invoke(trackMotorAddress);
}
double speed = autoModeBusiness.GetDeviceSpeed();
RealDeviceSpeed = Math.Round(speed,2);
string deviceStatus = autoModeBusiness.GetDeviceStatus();
RealDeviceStatus = deviceStatus;
Task.Delay(1000).Wait();
}
});

@ -16,7 +16,7 @@
"cameraPort": 8000,
"cameraUserName": "admin",
"cameraPassword": "haiwei@2024",
"checkCycle": 50,
"checkCycle": 5,
"SqlConfig": [
{
"configId": "iot",

Loading…
Cancel
Save