整理了错误的捕捉
关闭窗口验证
This commit is contained in:
@@ -96,7 +96,7 @@ namespace CapMachine.Wpf
|
||||
var IsOK = SoftAuthorizeHelper.CheckLience(MachineCode, PublicKey, Lience);
|
||||
if (!IsOK)
|
||||
{
|
||||
LogService.Error("授权失败");
|
||||
LogService.Info("授权失败");
|
||||
//this.Shutdown();
|
||||
}
|
||||
}
|
||||
@@ -289,7 +289,7 @@ namespace CapMachine.Wpf
|
||||
|
||||
//给当前的全局异常捕捉服务使用
|
||||
LogService = ContainerLocator.Container.Resolve<ILogService>();
|
||||
LogService.Error("Start-->OnInitialized");
|
||||
LogService.Info("程序启动");
|
||||
base.OnInitialized();
|
||||
|
||||
//#endregion
|
||||
@@ -317,7 +317,7 @@ namespace CapMachine.Wpf
|
||||
void App_Exit(object sender, ExitEventArgs e)
|
||||
{
|
||||
//程序退出时需要处理的业务
|
||||
LogService.Error("程序退出");
|
||||
LogService.Info("App-程序退出");
|
||||
}
|
||||
|
||||
|
||||
@@ -332,12 +332,14 @@ namespace CapMachine.Wpf
|
||||
try
|
||||
{
|
||||
HandleException(e.Exception);
|
||||
MessageBox.Show("UI线程异常:" + e.Exception.Message);
|
||||
//MessageBox.Show("UI线程异常:" + e.Exception.Message);
|
||||
LogService.Error("UI线程异常:" + e.Exception.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
HandleException(ex);
|
||||
MessageBox.Show("UI线程发生致命错误!");
|
||||
//MessageBox.Show("UI线程发生致命错误!");
|
||||
LogService.Error("UI线程发生致命错误!");
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -374,8 +376,8 @@ namespace CapMachine.Wpf
|
||||
{
|
||||
sbEx.Append(e.ExceptionObject);
|
||||
}
|
||||
MessageBox.Show(sbEx.ToString());
|
||||
|
||||
//MessageBox.Show(sbEx.ToString());
|
||||
LogService.Error(sbEx.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -402,7 +404,8 @@ namespace CapMachine.Wpf
|
||||
{
|
||||
HandleException(exception);
|
||||
//task线程内未处理捕获
|
||||
MessageBox.Show("Task线程异常:" + e.Exception.Message);
|
||||
//MessageBox.Show("Task线程异常:" + e.Exception.Message);
|
||||
LogService.Error($"Task线程异常");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -423,7 +426,7 @@ namespace CapMachine.Wpf
|
||||
private void HandleException(Exception ex)
|
||||
{
|
||||
//记录日志
|
||||
LogService.Error(ex.ToString());
|
||||
LogService.Error($"App捕捉HandleException-{ex.ToString()}");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
{
|
||||
ContainerProvider = containerProvider;
|
||||
HighSpeedDataService = ContainerProvider.Resolve<HighSpeedDataService>();
|
||||
|
||||
LogService = ContainerProvider.Resolve<ILogService>();
|
||||
//Stopwatch.Frequency表示高精度计时器每秒的计数次数(ticks/秒)每毫秒的ticks数 = 每秒的ticks数 ÷ 1000
|
||||
TicksPerMs = Stopwatch.Frequency / 1000.0;
|
||||
}
|
||||
@@ -42,10 +42,14 @@ namespace CapMachine.Wpf.CanDrive
|
||||
/// </summary>
|
||||
public HighSpeedDataService HighSpeedDataService { get; set; }
|
||||
|
||||
public ILogService LogService { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始CAN的驱动
|
||||
/// </summary>
|
||||
public void StartCanDrive()
|
||||
{
|
||||
try
|
||||
{
|
||||
IsExistsDllFile();
|
||||
ScanDevice();
|
||||
@@ -53,7 +57,12 @@ namespace CapMachine.Wpf.CanDrive
|
||||
GetDeviceInfo();
|
||||
GetCANConfig();
|
||||
InitCAN();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogService.Error(ex.Message);
|
||||
System.Windows.MessageBox.Show($"{ex.Message}", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -473,8 +482,6 @@ namespace CapMachine.Wpf.CanDrive
|
||||
|
||||
private static readonly Random _random = new Random();
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 精确周期发送CAN数据
|
||||
/// </summary>
|
||||
@@ -608,6 +615,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogService.Error(ex.Message);
|
||||
Console.WriteLine($"CAN周期发送异常: {ex.Message}");
|
||||
// 短暂暂停避免异常情况下CPU占用过高
|
||||
await Task.Delay(10, token);
|
||||
@@ -618,7 +626,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
{
|
||||
// 确保在任何情况下(正常退出、异常、取消)都会停止计时器
|
||||
Stopwatcher.Stop();
|
||||
|
||||
LogService.Error(ex.Message);
|
||||
// 清理其他可能的资源
|
||||
Console.WriteLine("CAN周期发送任务已结束,资源已清理");
|
||||
}
|
||||
@@ -818,6 +826,7 @@ namespace CapMachine.Wpf.CanDrive
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogService.Error(ex.Message);
|
||||
//LogService.Info($"时间:{DateTime.Now.ToString()}-【Meter】-{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ namespace CapMachine.Wpf.Models
|
||||
SelectedCanLinMsg = "CAN";
|
||||
CanLinRunState=true;
|
||||
break;
|
||||
case CanLinEnum.CANFD:
|
||||
SelectedCanLinMsg = "CANFD";
|
||||
CanLinRunState = true;
|
||||
break;
|
||||
case CanLinEnum.Lin:
|
||||
SelectedCanLinMsg = "LIN";
|
||||
CanLinRunState = true;
|
||||
|
||||
69
CapMachine.Wpf/Models/SysErrState.cs
Normal file
69
CapMachine.Wpf/Models/SysErrState.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统错误状态
|
||||
/// </summary>
|
||||
public class SysErrState : BindableBase
|
||||
{
|
||||
|
||||
private string? _ErrTime= "无错误";
|
||||
/// <summary>
|
||||
/// 错误时间
|
||||
/// </summary>
|
||||
public string? ErrTime
|
||||
{
|
||||
get { return _ErrTime; }
|
||||
set { _ErrTime = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private string? _ErrMsg;
|
||||
/// <summary>
|
||||
/// 错误消息
|
||||
/// </summary>
|
||||
public string? ErrMsg
|
||||
{
|
||||
get { return _ErrMsg; }
|
||||
set { _ErrMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private bool _ErrState=false;
|
||||
/// <summary>
|
||||
/// 错误状态
|
||||
/// </summary>
|
||||
public bool ErrState
|
||||
{
|
||||
get { return _ErrState; }
|
||||
set { _ErrState = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 激活错误状态
|
||||
/// </summary>
|
||||
public void ActiveErr(string Msg)
|
||||
{
|
||||
ErrState=true;
|
||||
ErrTime =DateTime.Now.ToString("MM-dd HH:mm:ss");
|
||||
ErrMsg = "见日志";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空错误状态
|
||||
/// </summary>
|
||||
public void ClearErr()
|
||||
{
|
||||
ErrState = false;
|
||||
ErrTime = "无错误";
|
||||
ErrMsg = "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
17
CapMachine.Wpf/PrismEvent/ErrStateEvent.cs
Normal file
17
CapMachine.Wpf/PrismEvent/ErrStateEvent.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Prism.Events;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.PrismEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误状态事件
|
||||
/// </summary>
|
||||
public class ErrStateEvent : PubSubEvent<ErrStateMsg>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
19
CapMachine.Wpf/PrismEvent/ErrStateMsg.cs
Normal file
19
CapMachine.Wpf/PrismEvent/ErrStateMsg.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CapMachine.Wpf.PrismEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误状态消息
|
||||
/// </summary>
|
||||
public class ErrStateMsg
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误消息内容
|
||||
/// </summary>
|
||||
public string? ErrMsg { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -310,6 +310,8 @@ namespace CapMachine.Wpf.Services
|
||||
while (await RecoredChannelInfo.Reader.WaitToReadAsync())
|
||||
{
|
||||
if (RecoredChannelInfo.Reader.TryRead(out var recordChannelData))
|
||||
{
|
||||
try
|
||||
{
|
||||
////第一次计时
|
||||
//stopwatch.Start(); //启动Stopwatch
|
||||
@@ -375,6 +377,12 @@ namespace CapMachine.Wpf.Services
|
||||
//Console.WriteLine("保存数据耗时::{0}", stopwatch.Elapsed.TotalSeconds.ToString());
|
||||
//stopwatch.Reset();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogService.Error(ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,7 +482,7 @@ namespace CapMachine.Wpf.Services
|
||||
catch (Exception ex)
|
||||
{
|
||||
//CycleTimer.Start(); //执行完毕后再开启器
|
||||
LogService.Info($"时间:{DateTime.Now.ToString()}-【PwAnalyze-CycleAction】-{ex.Message}");
|
||||
LogService.Error($"时间:{DateTime.Now.ToString()}-【RecoredCycleAction】-{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using NLog;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using NLog;
|
||||
using Prism.Events;
|
||||
using Prism.Services.Dialogs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,6 +17,16 @@ namespace CapMachine.Wpf.Services
|
||||
{
|
||||
private static Logger Logger = LogManager.GetCurrentClassLogger(); //初始化日志类
|
||||
|
||||
public IEventAggregator EventAggregator { get; }
|
||||
|
||||
/// <summary>
|
||||
/// NLog服务构造函数
|
||||
/// </summary>
|
||||
public LogService(IEventAggregator eventAggregator)
|
||||
{
|
||||
EventAggregator = eventAggregator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调试日志
|
||||
/// </summary>
|
||||
@@ -48,6 +60,8 @@ namespace CapMachine.Wpf.Services
|
||||
public void Error(string msg)
|
||||
{
|
||||
Logger.Error(msg);
|
||||
//发布错误状态消息,给页脚显示用
|
||||
EventAggregator.GetEvent<ErrStateEvent>().Publish(new ErrStateMsg() { ErrMsg=msg});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace CapMachine.Wpf.Services
|
||||
private IEventAggregator _EventAggregator { get; set; }
|
||||
public AlarmService AlarmService { get; }
|
||||
public ConfigService ConfigService { get; }
|
||||
public ILogService LogService { get; }
|
||||
public CanDriveService CanDriveService { get; }
|
||||
public CanFdDriveService CanFdDriveService { get; }
|
||||
public LinDriveService LinDriveService { get; }
|
||||
@@ -121,7 +122,7 @@ namespace CapMachine.Wpf.Services
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="eventAggregator"></param>
|
||||
public MachineRtDataService(IEventAggregator eventAggregator, AlarmService alarmService, ConfigService configService,
|
||||
public MachineRtDataService(IEventAggregator eventAggregator, AlarmService alarmService, ConfigService configService,ILogService logService,
|
||||
CanDriveService canDriveService, CanFdDriveService canFdDriveService, LinDriveService linDriveService, SysRunService sysRunService)//, AlarmService alarmService
|
||||
{
|
||||
//ConcurrentDictionary<DateTime, RecordInfo> keyValuePairs = new ConcurrentDictionary<DateTime, RecordInfo>();
|
||||
@@ -139,6 +140,7 @@ namespace CapMachine.Wpf.Services
|
||||
_EventAggregator = eventAggregator;
|
||||
AlarmService = alarmService;
|
||||
ConfigService = configService;
|
||||
LogService = logService;
|
||||
CanDriveService = canDriveService;
|
||||
CanFdDriveService = canFdDriveService;
|
||||
LinDriveService = linDriveService;
|
||||
@@ -1728,7 +1730,7 @@ namespace CapMachine.Wpf.Services
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//LogService.Info($"时间:{DateTime.Now.ToString()}-【Meter】-{ex.Message}");
|
||||
LogService.Error(ex.Message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CapMachine.Wpf.Models;
|
||||
using CapMachine.Wpf.PrismEvent;
|
||||
using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
@@ -10,11 +11,11 @@ using System.Threading.Tasks;
|
||||
namespace CapMachine.Wpf.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统
|
||||
/// 系统运行服务
|
||||
/// </summary>
|
||||
public class SysRunService : BindableBase
|
||||
{
|
||||
public SysRunService(IEventAggregator eventAggregator,ConfigService configService,CanDriveService canDriveService,LinDriveService linDriveService)
|
||||
public SysRunService(IEventAggregator eventAggregator, ConfigService configService, CanDriveService canDriveService, LinDriveService linDriveService)
|
||||
{
|
||||
// 创建一个定时器,设置间隔时间为2000毫秒(即2秒)
|
||||
CurTimer = new System.Timers.Timer(5000);
|
||||
@@ -28,10 +29,27 @@ namespace CapMachine.Wpf.Services
|
||||
ConfigService = configService;
|
||||
CanDriveService = canDriveService;
|
||||
LinDriveService = linDriveService;
|
||||
MachineRunState1 = new MachineRunState("M1", EventAggregator, ConfigService,canDriveService,linDriveService);
|
||||
MachineRunState1 = new MachineRunState("M1", EventAggregator, ConfigService, canDriveService, linDriveService);
|
||||
|
||||
EventAggregator.GetEvent<ErrStateEvent>().Subscribe(ErrStateAction);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误状态处理方法
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void ErrStateAction(ErrStateMsg errStateMsg)
|
||||
{
|
||||
SysErrStateInfo.ActiveErr(errStateMsg.ErrMsg!);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 系统错误状态
|
||||
/// </summary>
|
||||
public SysErrState SysErrStateInfo { get; set; } = new SysErrState();
|
||||
|
||||
/// <summary>
|
||||
/// 设备运行状态
|
||||
/// </summary>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"DataType": "Short",
|
||||
"RWInfo": "PLCRead",
|
||||
"PVModel": {
|
||||
"Address": "VW15000",
|
||||
"Address": "VW14100",
|
||||
"ReWritePLCAddress": "V14100",
|
||||
"EngValue": 0,
|
||||
"EngValueStr": "",
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
{
|
||||
public CANFDConfigViewModel(IDialogService dialogService, IFreeSql freeSql,
|
||||
IEventAggregator eventAggregator, IRegionManager regionManager, SysRunService sysRunService,
|
||||
ComActionService actionService,
|
||||
ComActionService actionService,ILogService logService,
|
||||
ConfigService configService, CanFdDriveService canFdDriveService,
|
||||
IMapper mapper, MachineRtDataService machineRtDataService)
|
||||
{
|
||||
@@ -44,6 +44,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
RegionManager = regionManager;
|
||||
SysRunService = sysRunService;
|
||||
ComActionService = actionService;
|
||||
LogService = logService;
|
||||
ConfigService = configService;
|
||||
CanFdDriveService = canFdDriveService;
|
||||
Mapper = mapper;
|
||||
@@ -139,6 +140,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
public IRegionManager RegionManager { get; }
|
||||
public SysRunService SysRunService { get; }
|
||||
public ComActionService ComActionService { get; }
|
||||
public ILogService LogService { get; }
|
||||
public ConfigService ConfigService { get; }
|
||||
public CanFdDriveService CanFdDriveService { get; }
|
||||
public IMapper Mapper { get; }
|
||||
@@ -905,6 +907,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
switch (Par)
|
||||
{
|
||||
case "Open":
|
||||
|
||||
if (ComActionService.IsCanToDoWork() == false)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请关闭LIN连接后才能开启CAN,同一个时刻只能有一个通信驱动压缩机", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
|
||||
|
||||
@@ -64,6 +64,31 @@ namespace CapMachine.Wpf.ViewModels
|
||||
IsTopDrawerOpen = false;
|
||||
}
|
||||
|
||||
//private DelegateCommand _WindowClosingCmd;
|
||||
///// <summary>
|
||||
///// 顶部弹窗按钮命令
|
||||
///// </summary>
|
||||
//public DelegateCommand WindowClosingCmd
|
||||
//{
|
||||
// set
|
||||
// {
|
||||
// _WindowClosingCmd = value;
|
||||
// }
|
||||
// get
|
||||
// {
|
||||
// if (_WindowClosingCmd == null)
|
||||
// {
|
||||
// _WindowClosingCmd = new DelegateCommand(() => WindowClosingCmdCall());
|
||||
// }
|
||||
// return _WindowClosingCmd;
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void WindowClosingCmdCall()
|
||||
//{
|
||||
// var dd = 1;
|
||||
//}
|
||||
|
||||
private DelegateCommand<string> _TopDrawerCmd;
|
||||
/// <summary>
|
||||
/// 顶部弹窗按钮命令
|
||||
|
||||
@@ -27,7 +27,8 @@ namespace CapMachine.Wpf.ViewModels
|
||||
/// <param name="machineRtDataService"></param>
|
||||
/// <param name="dialogService"></param>
|
||||
public MonitorViewModel(ConfigService configService, IEventAggregator eventAggregator,
|
||||
DataRecordService dataRecordService, SysRunService sysRunService, AlarmService alarmService, PPCService pPCService,CanDriveService canDriveService,LinDriveService linDriveService,
|
||||
DataRecordService dataRecordService, SysRunService sysRunService, AlarmService alarmService, PPCService pPCService,
|
||||
CanDriveService canDriveService, CanFdDriveService canFdDriveService, LinDriveService linDriveService,
|
||||
MachineRtDataService machineRtDataService, IDialogService dialogService)
|
||||
{
|
||||
ConfigService = configService;
|
||||
@@ -38,6 +39,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
AlarmService = alarmService;
|
||||
PPCService = pPCService;
|
||||
CanDriveService = canDriveService;
|
||||
CanFdDriveService = canFdDriveService;
|
||||
LinDriveService = linDriveService;
|
||||
MachineRtDataService = machineRtDataService;
|
||||
DialogService = dialogService;
|
||||
@@ -75,6 +77,7 @@ namespace CapMachine.Wpf.ViewModels
|
||||
public AlarmService AlarmService { get; }
|
||||
public PPCService PPCService { get; }
|
||||
public CanDriveService CanDriveService { get; }
|
||||
public CanFdDriveService CanFdDriveService { get; }
|
||||
public LinDriveService LinDriveService { get; }
|
||||
public MachineRtDataService MachineRtDataService { get; }
|
||||
public IDialogService DialogService { get; }
|
||||
@@ -229,6 +232,10 @@ namespace CapMachine.Wpf.ViewModels
|
||||
this.SysRunServer.MachineRunState1.FireStart();
|
||||
|
||||
DataRecordService.StartRecord();
|
||||
|
||||
//清空错误状态
|
||||
SysRunServer.SysErrStateInfo.ClearErr();
|
||||
|
||||
break;
|
||||
case "结束":
|
||||
MachineRtDataService.SysEnd();
|
||||
@@ -244,6 +251,11 @@ namespace CapMachine.Wpf.ViewModels
|
||||
CanDriveService.UpdateSpeedCmdData(0);
|
||||
//itemTag.Value.EngPvValue = 0;
|
||||
break;
|
||||
case CanLinEnum.CANFD:
|
||||
//获取PLC的SV数据 更新SV的速度值到压缩机
|
||||
CanFdDriveService.UpdateSpeedCmdData(0);
|
||||
//itemTag.Value.EngPvValue = 0;
|
||||
break;
|
||||
case CanLinEnum.Lin:
|
||||
//获取PLC的SV数据 更新SV的速度值到压缩机
|
||||
LinDriveService.UpdateSpeedCmdData(0);
|
||||
@@ -261,6 +273,9 @@ namespace CapMachine.Wpf.ViewModels
|
||||
this.SysRunServer.MachineRunState1.FireReset();
|
||||
DataRecordService.EndRecord();
|
||||
|
||||
//清空错误状态
|
||||
SysRunServer.SysErrStateInfo.ClearErr();
|
||||
|
||||
//结束运行的时候,需要将压缩机的速度值设置为0
|
||||
switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
|
||||
{
|
||||
@@ -269,6 +284,11 @@ namespace CapMachine.Wpf.ViewModels
|
||||
CanDriveService.UpdateSpeedCmdData(0);
|
||||
//itemTag.Value.EngPvValue = 0;
|
||||
break;
|
||||
case CanLinEnum.CANFD:
|
||||
//获取PLC的SV数据 更新SV的速度值到压缩机
|
||||
CanFdDriveService.UpdateSpeedCmdData(0);
|
||||
//itemTag.Value.EngPvValue = 0;
|
||||
break;
|
||||
case CanLinEnum.Lin:
|
||||
//获取PLC的SV数据 更新SV的速度值到压缩机
|
||||
LinDriveService.UpdateSpeedCmdData(0);
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
<TextBlock
|
||||
FontSize="16"
|
||||
Foreground="White"
|
||||
Text="系统状态:" />
|
||||
Text="运行状态:" />
|
||||
<TextBlock
|
||||
Margin="5,0"
|
||||
FontSize="16"
|
||||
@@ -247,6 +247,38 @@
|
||||
Text="{Binding DataRecordService.IsRecord, Converter={StaticResource BoolStateStrConvert}}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border>
|
||||
<Border.Style>
|
||||
<Style BasedOn="{StaticResource BoardStyle}" TargetType="Border">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding SysRunService.SysErrStateInfo.ErrState}" Value="false">
|
||||
<Setter Property="Background" Value="LimeGreen" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding SysRunService.SysErrStateInfo.ErrState}" Value="true">
|
||||
<Setter Property="Background" Value="OrangeRed" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
<StackPanel Style="{StaticResource StackPanelStyle}">
|
||||
<TextBlock
|
||||
Margin="5,0,5,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="/Assets/Fonts/#iconfont"
|
||||
FontSize="16"
|
||||
Foreground="White"
|
||||
Text="" />
|
||||
<TextBlock
|
||||
FontSize="16"
|
||||
Foreground="White"
|
||||
Text="软件信息:" />
|
||||
<TextBlock
|
||||
Margin="5,0"
|
||||
FontSize="16"
|
||||
Foreground="White"
|
||||
Text="{Binding SysRunService.SysErrStateInfo.ErrTime}" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<Border>
|
||||
<Border.Style>
|
||||
<Style BasedOn="{StaticResource BoardStyle}" TargetType="Border">
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
Width="1920"
|
||||
Height="1080"
|
||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||
Closed="Window_Closed"
|
||||
Closing="Window_Closing"
|
||||
Icon="/Assets/Images/favicon.ico"
|
||||
StateChanged="Window_StateChanged"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
@@ -24,8 +26,8 @@
|
||||
<localEx:BindingProxy x:Key="Proxy" Data="{Binding}" />
|
||||
</Window.Resources>
|
||||
<!--<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="StateChanged">
|
||||
<prism:InvokeCommandAction Command="{Binding WindowStateChangedCmd}" CommandParameter="{Binding ElementName=MainDatagrid, Path=SelectedItem}" />
|
||||
<i:EventTrigger EventName="Closing">
|
||||
<prism:InvokeCommandAction Command="{Binding WindowClosingCmd}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>-->
|
||||
<Grid>
|
||||
|
||||
@@ -26,6 +26,34 @@ namespace CapMachine.Wpf.Views
|
||||
LogService.Info($"Windows状态:{this.WindowState}-Visibility: {this.Visibility}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主界面正要关闭
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
// 弹窗提示是否确定要退出
|
||||
MessageBoxResult result = MessageBox.Show("您确定要退出程序吗?", "提示", MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.Cancel);
|
||||
//System.Console.WriteLine(result);
|
||||
if (result == MessageBoxResult.Cancel)
|
||||
{
|
||||
e.Cancel = true; // 中断点击事件
|
||||
}
|
||||
else
|
||||
{
|
||||
LogService.Info("Windows关闭");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主界面完成关闭
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Window_Closed(object sender, EventArgs e)
|
||||
{
|
||||
Environment.Exit(0); // 强制结束
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user