更改了CAN和LIN的标志着色问题

保存图片触发两次
CANLIN的一些数据回读到PLC
This commit is contained in:
2025-01-12 15:32:02 +08:00
parent e49a48fb25
commit 914a8b3dbc
15 changed files with 333 additions and 46 deletions

View File

@@ -7,6 +7,7 @@ using CapMachine.Wpf.Dtos;
using CapMachine.Wpf.PrismEvent;
using CapMachine.Wpf.Services;
using Ganss.Excel;
using ImTools;
using Microsoft.VisualBasic;
using Microsoft.Win32;
using NPOI.SS.UserModel.Charts;
@@ -113,9 +114,12 @@ namespace CapMachine.Wpf.ViewModels
if (SelectCanLinConfigPro != null)
{
SelectCanLinConfigPro = canLinConfigPros.Where(a => a.Id == SelectCanLinConfigPro.Id).FirstOrDefault()!;
//无数据就返回
if (SelectCanLinConfigPro == null) return;
SelectedCANConfigExdDto = Mapper.Map<CANConfigExdDto>(SelectCanLinConfigPro!.CANConfigExd);
//配置信息
var WirteData = SelectCanLinConfigPro.CanLinConfigContents!.Where(a => a.RWInfo == RW.Write).ToList();
if (WirteData != null && WirteData.Count > 0)
{
@@ -140,19 +144,55 @@ namespace CapMachine.Wpf.ViewModels
// SignalCmdValue = double.TryParse(item.DefautValue, out double result) == true ? result : 0,
//});
}
}
var ReadData = SelectCanLinConfigPro.CanLinConfigContents!.Where(a => a.RWInfo == RW.Read).ToList();
if (ReadData != null && ReadData.Count > 0)
{
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(ReadData));
}
//匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListCanDbcModel
MatchSeletedAndCanDbcModel();
}
}
/// <summary>
/// 匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListCanDbcModel
/// 为了标注和着色使用
/// </summary>
private void MatchSeletedAndCanDbcModel()
{
//通过CanLinConfigContents标注ListCanDbcModel的选中状态属性,方便着色
if (ListCanDbcModel != null && ListCanDbcModel!.Count() > 0 && SelectCanLinConfigPro.CanLinConfigContents != null && SelectCanLinConfigPro.CanLinConfigContents.Count() > 0)
{
foreach (var itemCanDbcModel in ListCanDbcModel)
{
var FindData = SelectCanLinConfigPro.CanLinConfigContents.FindFirst(a => a.SignalName == itemCanDbcModel.SignalName);
if (FindData != null)//找到了就标注
{
switch (FindData.RWInfo)
{
case RW.Write:
itemCanDbcModel.IsSeletedInfo = 1;
break;
case RW.Read:
itemCanDbcModel.IsSeletedInfo = 2;
break;
default:
break;
}
}
else
{
//没有找到了就标注为0
itemCanDbcModel.IsSeletedInfo = 0;
}
}
}
}
private bool _IsCanConfigProActive = false;
/// <summary>
/// CAN 配置是否被激活
@@ -335,7 +375,7 @@ namespace CapMachine.Wpf.ViewModels
case "Active":
//激活到取消的状态的判断
if (IsCanConfigProActive==true)
if (IsCanConfigProActive == true)
{
//控件的激活
IsCanConfigProActive = !IsCanConfigProActive;
@@ -467,6 +507,7 @@ namespace CapMachine.Wpf.ViewModels
}
SelectCanLinConfigProConfigName = SelectCanLinConfigPro.ConfigName;
return;
}
//先判断是否是正确的集合数据防止DataGrid的数据源刷新导致的触发事件
@@ -653,8 +694,8 @@ namespace CapMachine.Wpf.ViewModels
return;
}
if ((par as SelectionChangedEventArgs)!.AddedItems[0] == null)
//(par as SelectionChangedEventArgs)!.AddedItems[0] == null
if ((par as SelectionChangedEventArgs)!.AddedItems.Count==0)
{
return;
}
@@ -777,7 +818,7 @@ namespace CapMachine.Wpf.ViewModels
switch (Par)
{
case "Open":
if (ComActionService.IsCanToDoWork()==false)
if (ComActionService.IsCanToDoWork() == false)
{
System.Windows.MessageBox.Show("请关闭LIN连接后才能开启CAN同一个时刻只能有一个通信驱动压缩机", "提示", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Hand);
return;
@@ -793,7 +834,13 @@ namespace CapMachine.Wpf.ViewModels
{
var DbcData = CanDriveService.StartDbc(SelectedCANConfigExdDto.DbcPath);
ListCanDbcModel = DbcData;
//ListCanDbcModel有数据后就要看看是否有配置信息有的话就要标注
//匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListCanDbcModel
MatchSeletedAndCanDbcModel();
}
}
else
{

View File

@@ -40,6 +40,7 @@ namespace CapMachine.Wpf.ViewModels
public IFreeSql FreeSql { get; }
public IEventAggregator EventAggregator { get; }
public IMapper Mapper { get; }
public ConfigService ConfigService { get; }
public ILogService Logger { get; }
/// <summary>
@@ -50,13 +51,13 @@ namespace CapMachine.Wpf.ViewModels
/// <param name="eventAggregator"></param>
/// <param name="mapper"></param>
/// <param name="logger"></param>
public HistoryDataViewModel(IDialogService dialogService, IFreeSql freeSql, IEventAggregator eventAggregator, IMapper mapper)
public HistoryDataViewModel(IDialogService dialogService, IFreeSql freeSql, IEventAggregator eventAggregator, IMapper mapper,ConfigService configService)
{
DialogService = dialogService;
FreeSql = freeSql;
EventAggregator = eventAggregator;
Mapper = mapper;
ConfigService = configService;
ListChartTabGroupDto = Mapper.Map<List<ChartTabGroupDto>>(FreeSql.Select<HistoryChartTabGroup>().Where(a => a.IsEnable == true).ToList());
@@ -948,6 +949,8 @@ namespace CapMachine.Wpf.ViewModels
EventAggregator.GetEvent<HistoryChartSetEvent>().Publish(new ChartSetMsg() { Machine = CurSelectedMachine, GroupTabIndex = SeletedGroupTabIndex, ChartSetInfo = "游标放大" });
break;
case "保存照片":
//临时的屏蔽状态
ConfigService.ChartSavePageTempState = true;
//Chart操作
EventAggregator.GetEvent<HistoryChartSetEvent>().Publish(new ChartSetMsg() { Machine = CurSelectedMachine, GroupTabIndex = SeletedGroupTabIndex, ChartSetInfo = "保存照片" });
break;

View File

@@ -18,6 +18,7 @@ using System.Threading.Tasks;
using System.Windows.Controls;
using Microsoft.Win32;
using static CapMachine.Wpf.Models.ComEnum;
using ImTools;
namespace CapMachine.Wpf.ViewModels
{
@@ -37,7 +38,7 @@ namespace CapMachine.Wpf.ViewModels
/// <param name="machineRtDataService"></param>
public LinConfigViewModel(IDialogService dialogService, IFreeSql freeSql,
IEventAggregator eventAggregator, IRegionManager regionManager, SysRunService sysRunService,
ConfigService configService, LinDriveService linDriveService,ComActionService comActionService,
ConfigService configService, LinDriveService linDriveService, ComActionService comActionService,
IMapper mapper, MachineRtDataService machineRtDataService)
{
//LogService = logService;
@@ -113,6 +114,8 @@ namespace CapMachine.Wpf.ViewModels
if (SelectCanLinConfigPro != null)
{
SelectCanLinConfigPro = canLinConfigPros.Where(a => a.Id == SelectCanLinConfigPro.Id).FirstOrDefault()!;
//无数据就返回
if (SelectCanLinConfigPro == null) return;
SelectedLINConfigExdDto = Mapper.Map<LINConfigExdDto>(SelectCanLinConfigPro!.LINConfigExd);
@@ -146,11 +149,47 @@ namespace CapMachine.Wpf.ViewModels
if (ReadData != null && ReadData.Count > 0)
{
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(ReadData));
}
//匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListLinLdfModel
MatchSeletedAndLinLdfModel();
}
}
/// <summary>
/// 匹配选中的SelectCanLinConfigPro.CanLinConfigContents和LinLdfModel
/// 为了标注和着色使用
/// </summary>
private void MatchSeletedAndLinLdfModel()
{
//通过CanLinConfigContents标注ListLinLdfModel的选中状态属性,方便着色
if (ListLinLdfModel != null && ListLinLdfModel!.Count() > 0 && SelectCanLinConfigPro.CanLinConfigContents != null && SelectCanLinConfigPro.CanLinConfigContents.Count() > 0)
{
foreach (var itemLinLdfModel in ListLinLdfModel)
{
var FindData = SelectCanLinConfigPro.CanLinConfigContents.FindFirst(a => a.SignalName == itemLinLdfModel.SignalName);
if (FindData != null)//找到了就标注
{
switch (FindData.RWInfo)
{
case RW.Write:
itemLinLdfModel.IsSeletedInfo = 1;
break;
case RW.Read:
itemLinLdfModel.IsSeletedInfo = 2;
break;
default:
break;
}
}
else
{
//没有找到了就标注为0
itemLinLdfModel.IsSeletedInfo = 0;
}
}
}
}
private bool _IsLinConfigProActive = false;
@@ -611,7 +650,6 @@ namespace CapMachine.Wpf.ViewModels
}
}
/// <summary>
/// 选中的LinLdfModel
/// </summary>
@@ -648,8 +686,7 @@ namespace CapMachine.Wpf.ViewModels
return;
}
if ((par as SelectionChangedEventArgs)!.AddedItems[0] == null)
if ((par as SelectionChangedEventArgs)!.AddedItems.Count == 0)
{
return;
}
@@ -788,6 +825,10 @@ namespace CapMachine.Wpf.ViewModels
{
var LdfData = LinDriveService.StartLdf(SelectedLINConfigExdDto.LdfPath);
ListLinLdfModel = LdfData;
//ListLinLdfModel有数据后就要看看是否有配置信息有的话就要标注
//匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListLinLdfModel
MatchSeletedAndLinLdfModel();
}
}
else

View File

@@ -12,6 +12,7 @@ using Prism.Commands;
using Prism.Events;
using Prism.Regions;
using Prism.Services.Dialogs;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Text;
@@ -2320,6 +2321,8 @@ namespace CapMachine.Wpf.ViewModels
{
//当前的程序开始标记
ProParsSongZhiHelper.Start();
//返回的数据
List<PlcParsData> ReturnPlcParsData = new List<PlcParsData>();
//var Data=FreeSql.Select<ProSegRun>(
//以每个程序为单元循环执行
@@ -2351,14 +2354,19 @@ namespace CapMachine.Wpf.ViewModels
if (FindData != null && FindData.ProSteps != null && FindData.ProSteps.Any())
{
//执行程序的步骤集合数据
var ReturnPlcParsData = ProParsSongZhiHelper.GetPlcParsData(FindData.ProSteps, FindData.ProRepeat);
ProParsSongZhiHelper.LoadDataToPLC(MachineRtDataService.SiemensDrive, ReturnPlcParsData);
//下载完成的话,则标记状态
SysRunService.MachineRunState1.IsProLoad = true;
ReturnPlcParsData = ProParsSongZhiHelper.GetPlcParsData(FindData.ProSteps, FindData.ProRepeat);
}
}
//防止上一次下载的程序多余当前的步骤,为了清空多余的步骤数据,增加一行的数据
ReturnPlcParsData = ProParsSongZhiHelper.AddNullData(ReturnPlcParsData);
//装载PLC地址
ReturnPlcParsData = ProParsSongZhiHelper.LoadPlcCellAddress(ReturnPlcParsData);
ProParsSongZhiHelper.LoadDataToPLC(MachineRtDataService.SiemensDrive, ReturnPlcParsData);
//下载完成的话,则标记状态
SysRunService.MachineRunState1.IsProLoad = true;
}
}

View File

@@ -3,6 +3,7 @@ using CapMachine.Core;
using CapMachine.Model;
using CapMachine.Wpf.Dtos;
using CapMachine.Wpf.PrismEvent;
using CapMachine.Wpf.Services;
using Prism.Commands;
using Prism.Events;
using Prism.Services.Dialogs;
@@ -18,13 +19,13 @@ namespace CapMachine.Wpf.ViewModels
/// <summary>
/// 实例化函数
/// </summary>
public RealTimeChartViewModel(IDialogService dialogService, IFreeSql freeSql, IEventAggregator eventAggregator, IMapper mapper)
public RealTimeChartViewModel(IDialogService dialogService, IFreeSql freeSql, IEventAggregator eventAggregator, IMapper mapper,ConfigService configService)
{
DialogService = dialogService;
FreeSql = freeSql;
EventAggregator = eventAggregator;
Mapper = mapper;
ConfigService = configService;
ListChartTabGroupDto = Mapper.Map<List<ChartTabGroupDto>>(FreeSql.Select<ChartTabGroup>().Where(a => a.IsEnable == true).ToList());
//都要加载数据
@@ -47,6 +48,7 @@ namespace CapMachine.Wpf.ViewModels
/// AutoMap映射
/// </summary>
public IMapper Mapper { get; }
public ConfigService ConfigService { get; }
/// <summary>
/// FreeSQL 实例
@@ -322,6 +324,8 @@ namespace CapMachine.Wpf.ViewModels
EventAggregator.GetEvent<ChartSetEvent>().Publish(new ChartSetMsg() { Machine = CurSelectedMachine, GroupTabIndex = SeletedGroupTabIndex, ChartSetInfo = "游标放大" });
break;
case "保存照片":
//临时的屏蔽状态
ConfigService.ChartSavePageTempState = true;
//Chart操作
EventAggregator.GetEvent<ChartSetEvent>().Publish(new ChartSetMsg() { Machine = CurSelectedMachine, GroupTabIndex = SeletedGroupTabIndex, ChartSetInfo = "保存照片" });
break;