change - 添加报警刷新

master
wenjy 2 months ago
parent 532cd2f5e1
commit 708d6e8c45

@ -2,6 +2,7 @@
using SlnMesnac.TouchSocket; using SlnMesnac.TouchSocket;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Text; using System.Text;
#region << 版 本 注 释 >> #region << 版 本 注 释 >>
@ -38,6 +39,9 @@ namespace SlnMesnac.Business
public delegate void RefreshDeviceAlarmMessage(string message); public delegate void RefreshDeviceAlarmMessage(string message);
public event RefreshDeviceAlarmMessage? RefreshDeviceAlarmMessageEvent; public event RefreshDeviceAlarmMessage? RefreshDeviceAlarmMessageEvent;
public delegate void RefreshDeviceStatus(bool rfidFlag,bool camFlag);
public event RefreshDeviceStatus? RefreshDeviceStatusEvent;
public TagScanBusiness(ApiServer apiServer) public TagScanBusiness(ApiServer apiServer)
{ {
@ -65,8 +69,33 @@ namespace SlnMesnac.Business
{ {
RefreshDeviceAlarmMessageEvent?.Invoke(item); RefreshDeviceAlarmMessageEvent?.Invoke(item);
} }
List<string> rfidList = new List<string>();
List<string> camList = new List<string>();
foreach (string str in info.device_status)
{
if (str.Length == 2)
{
int number;
bool isNumber = int.TryParse(str, out number);
if (isNumber && str[0] == '1')
{
camList.Add(str);
continue;
}
rfidList.Add(str);
} }
} }
RefreshDeviceStatusEvent?.Invoke(rfidList.Count > 0 ? true : false, camList.Count > 0 ? true : false);
}
}
else
{
RefreshDeviceStatusEvent?.Invoke(false, false);
}
}; };
} }

@ -67,13 +67,13 @@
<Ellipse.Style> <Ellipse.Style>
<Style TargetType="Ellipse"> <Style TargetType="Ellipse">
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding ShellScannerStatus}" Value="0"> <DataTrigger Binding="{Binding RfidStatus}" Value="0">
<Setter Property="Shape.Fill" Value="Orange"/> <Setter Property="Shape.Fill" Value="Orange"/>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding ShellScannerStatus}" Value="1"> <DataTrigger Binding="{Binding RfidStatus}" Value="1">
<Setter Property="Shape.Fill" Value="Green"/> <Setter Property="Shape.Fill" Value="Green"/>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding ShellScannerStatus}" Value="2"> <DataTrigger Binding="{Binding RfidStatus}" Value="2">
<Setter Property="Shape.Fill" Value="Red"/> <Setter Property="Shape.Fill" Value="Red"/>
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
@ -98,13 +98,13 @@
<Ellipse.Style> <Ellipse.Style>
<Style TargetType="Ellipse"> <Style TargetType="Ellipse">
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding BoldScannerStatus}" Value="0"> <DataTrigger Binding="{Binding CamStatus}" Value="0">
<Setter Property="Shape.Fill" Value="Orange"/> <Setter Property="Shape.Fill" Value="Orange"/>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding BoldScannerStatus}" Value="1"> <DataTrigger Binding="{Binding CamStatus}" Value="1">
<Setter Property="Shape.Fill" Value="Green"/> <Setter Property="Shape.Fill" Value="Green"/>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding BoldScannerStatus}" Value="2"> <DataTrigger Binding="{Binding CamStatus}" Value="2">
<Setter Property="Shape.Fill" Value="Red"/> <Setter Property="Shape.Fill" Value="Red"/>
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>

@ -8,11 +8,18 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="appsettings.json" />
<None Remove="Templates\image\background.jpg" /> <None Remove="Templates\image\background.jpg" />
<None Remove="Templates\image\left.png" /> <None Remove="Templates\image\left.png" />
<None Remove="Templates\image\right.png" /> <None Remove="Templates\image\right.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SlnMesnac.Business\SlnMesnac.Business.csproj" /> <ProjectReference Include="..\SlnMesnac.Business\SlnMesnac.Business.csproj" />
<ProjectReference Include="..\SlnMesnac.Common\SlnMesnac.Common.csproj" /> <ProjectReference Include="..\SlnMesnac.Common\SlnMesnac.Common.csproj" />

@ -2,6 +2,7 @@
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SlnMesnac.Business;
using SlnMesnac.WPF.Page; using SlnMesnac.WPF.Page;
using SlnMesnac.WPF.Page.History; using SlnMesnac.WPF.Page.History;
using System; using System;
@ -12,38 +13,30 @@ namespace SlnMesnac.WPF.ViewModel
public class MainWindowViewModel: ViewModelBase public class MainWindowViewModel: ViewModelBase
{ {
private readonly ILogger<MainWindowViewModel> _logger; private readonly ILogger<MainWindowViewModel> _logger;
private readonly TagScanBusiness tagScanBusiness;
private IndexControl indexControl = new IndexControl(); private IndexControl indexControl = new IndexControl();
private HistoryControl historyControl = new HistoryControl(); private HistoryControl historyControl = new HistoryControl();
#region 参数定义 #region 参数定义
/// <summary> /// <summary>
/// PLC设备状态 /// RFID状态
/// </summary> /// </summary>
private int _PlcStatus = 0; private int _RfidStatus = 0;
public int PlcStatus public int RfidStatus
{ {
get { return _PlcStatus; } get { return _RfidStatus; }
set { _PlcStatus = value; RaisePropertyChanged(nameof(PlcStatus)); } set { _RfidStatus = value; RaisePropertyChanged(nameof(RfidStatus)); }
}
/// <summary>
/// 箱壳扫码器状态
/// </summary>
private int _ShellScannerStatus = 0;
public int ShellScannerStatus
{
get { return _ShellScannerStatus; }
set { _ShellScannerStatus = value; RaisePropertyChanged(nameof(ShellScannerStatus)); }
} }
/// <summary> /// <summary>
/// 内胆扫码器状态 /// 相机状态
/// </summary> /// </summary>
private int _BoldScannerStatus = 0; private int _CamStatus = 0;
public int BoldScannerStatus public int CamStatus
{ {
get { return _BoldScannerStatus; } get { return _CamStatus; }
set { _BoldScannerStatus = value; RaisePropertyChanged(nameof(BoldScannerStatus)); } set { _CamStatus = value; RaisePropertyChanged(nameof(CamStatus)); }
} }
public System.Windows.Controls.UserControl _content; public System.Windows.Controls.UserControl _content;
@ -83,12 +76,34 @@ namespace SlnMesnac.WPF.ViewModel
var sp = App.ServiceProvider; var sp = App.ServiceProvider;
_logger = App.ServiceProvider.GetService<ILogger<MainWindowViewModel>>(); _logger = App.ServiceProvider.GetService<ILogger<MainWindowViewModel>>();
tagScanBusiness = App.ServiceProvider.GetService<TagScanBusiness>();
ControlOnClickCommand = new RelayCommand<object>(obj => ControlOnClick(obj)); ControlOnClickCommand = new RelayCommand<object>(obj => ControlOnClick(obj));
FormControlCommand = new RelayCommand<object>(x => FormControl(x)); FormControlCommand = new RelayCommand<object>(x => FormControl(x));
UserContent = indexControl; UserContent = indexControl;
tagScanBusiness.RefreshDeviceStatusEvent += (rfid, cam) =>
{
if (rfid)
{
RfidStatus = 2;
}
else
{
RfidStatus = 1;
}
if (cam)
{
CamStatus = 2;
}
else
{
CamStatus = 1;
}
};
} }
/// <summary> /// <summary>

@ -13,43 +13,8 @@
{ {
"configId": "mes", "configId": "mes",
"dbType": 4, "dbType": 4,
"connStr": "PORT=5432;DATABASE=daxing;HOST=127.0.0.1;PASSWORD=123456;USER ID=postgres" "connStr": "PORT=5432;DATABASE=daxing;HOST=192.168.0.101;PASSWORD=123456;USER ID=postgres"
} }
], ]
"PlcConfig": [
{
"configId": 1,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcPort": 6000,
"plcKey": "mcs",
"isFlage": true
},
{
"configId": 2,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcPort": 6001,
"plcKey": "cwss",
"isFlage": true
}
],
"RfidConfig": [
{
"configId": 1,
"equipIp": "127.0.0.1",
"equipPort": 6003,
"equipKey": "test1",
"isFlage": true
},
{
"configId": 2,
"equipIp": "127.0.0.1",
"equipPort": 6004,
"equipKey": "test2",
"isFlage": true
}
],
"redisConfig": "175.27.215.92:6379,password=redis@2023"
} }
} }

Loading…
Cancel
Save