更改了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

@@ -80,6 +80,17 @@ namespace CapMachine.Wpf.CanDrive
} }
} }
private int _IsSeletedInfo;
/// <summary>
/// 被选中的信息
/// 方便标注着色
/// </summary>
public int IsSeletedInfo
{
get { return _IsSeletedInfo; }
set { _IsSeletedInfo = value;RaisePropertyChanged(); }
}
/// <summary> /// <summary>
/// 发布者 /// 发布者

View File

@@ -80,6 +80,18 @@ namespace CapMachine.Wpf.LinDrive
} }
} }
private int _IsSeletedInfo;
/// <summary>
/// 被选中的信息
/// 方便标注着色
/// </summary>
public int IsSeletedInfo
{
get { return _IsSeletedInfo; }
set { _IsSeletedInfo = value; RaisePropertyChanged(); }
}
/// <summary> /// <summary>
/// 发布者 /// 发布者
/// </summary> /// </summary>

View File

@@ -532,7 +532,7 @@ namespace CapMachine.Wpf.Models.LightChart
//Reduce memory usage and increase performance. Destroys out-scrolled data. //Reduce memory usage and increase performance. Destroys out-scrolled data.
LgChart.ViewXY.DropOldSeriesData = false; LgChart.ViewXY.DropOldSeriesData = false;
//多个Y曲线摆放形式 //多个Y曲线摆放形式
LgChart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Layered; LgChart.ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Layered;
//网格带 //网格带
@@ -600,8 +600,8 @@ namespace CapMachine.Wpf.Models.LightChart
//CursorValueDisplay.LocationScreenCoords.X = 1480; //CursorValueDisplay.LocationScreenCoords.X = 1480;
//光标注释相对的位置 左上侧 //光标注释相对的位置 左上侧
CursorValueDisplay.LocationScreenCoords.Y = 30; CursorValueDisplay.LocationScreenCoords.Y = 35;
CursorValueDisplay.LocationScreenCoords.X = 250; CursorValueDisplay.LocationScreenCoords.X = 1380;
//CursorValueDisplay.TargetAxisValues.X = 0; //CursorValueDisplay.TargetAxisValues.X = 0;
//CursorValueDisplay.TargetAxisValues.Y = 0; //CursorValueDisplay.TargetAxisValues.Y = 0;
@@ -693,7 +693,7 @@ namespace CapMachine.Wpf.Models.LightChart
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
private void UpdateRecordData(RecordChannelData data) private void UpdateRecordData(RecordChannelData data)
{ {
if (data.Data != null) if (data.Data != null)
{ {
@@ -1462,6 +1462,7 @@ namespace CapMachine.Wpf.Models.LightChart
return; return;
} }
////当前是否是给自己的指令的信息 ////当前是否是给自己的指令的信息
//if (par.GroupTabIndex == CurSelectedGroupTabIndex) //if (par.GroupTabIndex == CurSelectedGroupTabIndex)
//{ //{
@@ -1518,9 +1519,20 @@ namespace CapMachine.Wpf.Models.LightChart
break; break;
case "保存照片": case "保存照片":
//只保存当前TabIndex的图片截图 //只保存当前TabIndex的图片截图
if (par.GroupTabIndex == CurSelectedGroupTabIndex) if (par.GroupTabIndex == CurSelectedGroupTabIndex)
{ {
//临时屏蔽状态,保存会执行两次
if (ConfigService.ChartSavePageTempState)
{
ConfigService.ChartSavePageTempState = false;
}
else
{
return;
}
var PicPath = GetFilePath(); var PicPath = GetFilePath();
if (PicPath != null) if (PicPath != null)
{ {

View File

@@ -90,20 +90,56 @@ namespace CapMachine.Wpf.ProPars
//装载ListPlcParsData的结构数据 //装载ListPlcParsData的结构数据
//for (int i = 0; i < Cycle; i++)//Proge 大循环 未启用,默认执行一次 //for (int i = 0; i < Cycle; i++)//Proge 大循环 未启用,默认执行一次
//{ //{
foreach (ProStep proStep in proSteps)//ProStep 小循环 foreach (ProStep proStep in proSteps)//ProStep 小循环
{ {
//每个ProStep步骤里面包含多个参数的设置 //每个ProStep步骤里面包含多个参数的设置
ListPlcParsData = LoadPlcParsData(proStep, ListPlcParsData);//内部循环 ListPlcParsData = LoadPlcParsData(proStep, ListPlcParsData);//内部循环
} }
//} //}
//装载地址 VW1000 ////防止上一次下载的程序多余当前的步骤,为了清空多余的步骤数据,增加一行的数据
ListPlcParsData = LoadPlcCellAddress(ListPlcParsData);
////装载地址 VW1000
//ListPlcParsData = LoadPlcCellAddress(ListPlcParsData);
//var datga = LoadPlcBlockAddress(ListPlcParsData, 1000); //var datga = LoadPlcBlockAddress(ListPlcParsData, 1000);
return ListPlcParsData; return ListPlcParsData;
} }
/// <summary>
/// 增加一行空的数据,作为终止的执行
/// </summary>
public static List<PlcParsData> AddNullData(List<PlcParsData> plcParsDatas)
{
var NewStep = new ProStep()
{
MeterCond1Temps = new List<MeterCond1Temp>() { new MeterCond1Temp() { ValueType=ConfigValueType.Constant,} },
MeterCond2Presss=new List<MeterCond2Press>() { new MeterCond2Press() { ValueType = ConfigValueType.Constant, } },
MeterCond2Temps= new List<MeterCond2Temp>() { new MeterCond2Temp() { ValueType = ConfigValueType.Constant, } },
MeterEnvRHs = new List<MeterEnvRH>() { new MeterEnvRH() { ValueType = ConfigValueType.Constant, } },
MeterEnvTemps = new List<MeterEnvTemp>() { new MeterEnvTemp() { ValueType = ConfigValueType.Constant, } },
MeterEVAPExpTemps = new List<MeterEVAPExpTemp>() { new MeterEVAPExpTemp() { ValueType = ConfigValueType.Constant, } },
MeterExPresss = new List<MeterExPress>() { new MeterExPress() { ValueType = ConfigValueType.Constant, } },
MeterHVVols = new List<MeterHVVol>() { new MeterHVVol() { ValueType = ConfigValueType.Constant, } },
MeterInhPresss = new List<MeterInhPress>() { new MeterInhPress() { ValueType = ConfigValueType.Constant, } },
MeterInhTemps = new List<MeterInhTemp>() { new MeterInhTemp() { ValueType = ConfigValueType.Constant, } },
MeterLubePresss = new List<MeterLubePress>() { new MeterLubePress() { ValueType = ConfigValueType.Constant, } },
MeterLVVols = new List<MeterLVVol>() { new MeterLVVol() { ValueType = ConfigValueType.Constant, } },
MeterOCRs = new List<MeterOCR>() { new MeterOCR() { ValueType = ConfigValueType.Constant, } },
MeterOS1Temps = new List<MeterOS1Temp>() { new MeterOS1Temp() { ValueType = ConfigValueType.Constant, } },
MeterOS2Temps = new List<MeterOS2Temp>() { new MeterOS2Temp() { ValueType = ConfigValueType.Constant, } },
MeterPTCEntTemps = new List<MeterPTCEntTemp>() { new MeterPTCEntTemp() { ValueType = ConfigValueType.Constant, } },
MeterPTCFlows = new List<MeterPTCFlow>() { new MeterPTCFlow() { ValueType = ConfigValueType.Constant, } },
MeterPTCPws = new List<MeterPTCPw>() { new MeterPTCPw() { ValueType = ConfigValueType.Constant, } },
MeterSpeeds = new List<MeterSpeed>() { new MeterSpeed() { ValueType = ConfigValueType.Constant, } },
StepNo = 0,
SpeedCycle = 0,
Remark = "结束",
};
return LoadPlcParsData(NewStep, plcParsDatas);
}
/// <summary> /// <summary>
/// 加载数据到PLC /// 加载数据到PLC
@@ -1640,7 +1676,7 @@ namespace CapMachine.Wpf.ProPars
/// <returns></returns> /// <returns></returns>
private static int GetCycleCount(int Cycle, int Index, int ListCount) private static int GetCycleCount(int Cycle, int Index, int ListCount)
{ {
if (Cycle==1) if (Cycle == 1)
{ {
//只有一次,也就是没有循环,就是直接的步骤,统一返回没有循环固定值 //只有一次,也就是没有循环,就是直接的步骤,统一返回没有循环固定值
return 0; return 0;
@@ -1675,7 +1711,7 @@ namespace CapMachine.Wpf.ProPars
/// 单元分割 /// 单元分割
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
private static List<PlcParsData> LoadPlcCellAddress(List<PlcParsData> plcParsDatas) public static List<PlcParsData> LoadPlcCellAddress(List<PlcParsData> plcParsDatas)
{ {
//单步长度 //单步长度
int StepLengh = 150; int StepLengh = 150;
@@ -1721,6 +1757,8 @@ namespace CapMachine.Wpf.ProPars
return plcParsDatas; return plcParsDatas;
} }
/// <summary> /// <summary>
/// 加载PLC块地址信息 /// 加载PLC块地址信息
/// </summary> /// </summary>

View File

@@ -68,6 +68,12 @@ namespace CapMachine.Wpf.Services
/// </summary> /// </summary>
public int ChartRtDataCacheTimeSec { get; set; } = 3600_8; public int ChartRtDataCacheTimeSec { get; set; } = 3600_8;
/// <summary>
/// 曲线保存临时状态
/// 曲线照片保存会执行两次,这个是屏蔽的状态
/// </summary>
public bool ChartSavePageTempState { get; set; } = false;
/// <summary> /// <summary>
/// CAN和LIN的运行状态模型 /// CAN和LIN的运行状态模型
/// </summary> /// </summary>

View File

@@ -1154,7 +1154,96 @@ namespace CapMachine.Wpf.Services
default: default:
break; break;
} }
}
else if(itemTag.Value.NameNoUnit == "通讯母线电压")
{
switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
{
case CanLinEnum.Can:
//通信转速 Dbc中间配置名称的转速数据读取出来 给PLC
SiemensDrive.Write(itemTag.Value.PVAddress, (short)CanDriveService.GetDbcSpeedValueBySpeedName("通讯母线电压"));
//itemTag.Value.EngPvValue = 0;
break;
case CanLinEnum.Lin:
//通信转速 Dbc中间配置名称的转速数据读取出来 给PLC
SiemensDrive.Write(itemTag.Value.PVAddress, (short)LinDriveService.GetLdfSpeedValueBySpeedName("通讯母线电压"));
//itemTag.Value.EngPvValue = 0;
break;
default:
break;
}
}
else if (itemTag.Value.NameNoUnit == "通讯母线电流")
{
switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
{
case CanLinEnum.Can:
//通信转速 Dbc中间配置名称的转速数据读取出来 给PLC
SiemensDrive.Write(itemTag.Value.PVAddress, (short)CanDriveService.GetDbcSpeedValueBySpeedName("通讯母线电流"));
//itemTag.Value.EngPvValue = 0;
break;
case CanLinEnum.Lin:
//通信转速 Dbc中间配置名称的转速数据读取出来 给PLC
SiemensDrive.Write(itemTag.Value.PVAddress, (short)LinDriveService.GetLdfSpeedValueBySpeedName("通讯母线电流"));
//itemTag.Value.EngPvValue = 0;
break;
default:
break;
}
}
else if (itemTag.Value.NameNoUnit == "通讯相电流")
{
switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
{
case CanLinEnum.Can:
//通信转速 Dbc中间配置名称的转速数据读取出来 给PLC
SiemensDrive.Write(itemTag.Value.PVAddress, (short)CanDriveService.GetDbcSpeedValueBySpeedName("通讯相电流"));
//itemTag.Value.EngPvValue = 0;
break;
case CanLinEnum.Lin:
//通信转速 Dbc中间配置名称的转速数据读取出来 给PLC
SiemensDrive.Write(itemTag.Value.PVAddress, (short)LinDriveService.GetLdfSpeedValueBySpeedName("通讯相电流"));
//itemTag.Value.EngPvValue = 0;
break;
default:
break;
}
}
else if (itemTag.Value.NameNoUnit == "通讯功率")
{
switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
{
case CanLinEnum.Can:
//通信转速 Dbc中间配置名称的转速数据读取出来 给PLC
SiemensDrive.Write(itemTag.Value.PVAddress, (short)CanDriveService.GetDbcSpeedValueBySpeedName("通讯功率"));
//itemTag.Value.EngPvValue = 0;
break;
case CanLinEnum.Lin:
//通信转速 Dbc中间配置名称的转速数据读取出来 给PLC
SiemensDrive.Write(itemTag.Value.PVAddress, (short)LinDriveService.GetLdfSpeedValueBySpeedName("通讯功率"));
//itemTag.Value.EngPvValue = 0;
break;
default:
break;
}
}
else if (itemTag.Value.NameNoUnit == "通讯芯片温度")
{
switch (ConfigService.CanLinRunStateModel.CurSysSelectedCanLin)
{
case CanLinEnum.Can:
//通信转速 Dbc中间配置名称的转速数据读取出来 给PLC
SiemensDrive.Write(itemTag.Value.PVAddress, (short)CanDriveService.GetDbcSpeedValueBySpeedName("通讯芯片温度"));
//itemTag.Value.EngPvValue = 0;
break;
case CanLinEnum.Lin:
//通信转速 Dbc中间配置名称的转速数据读取出来 给PLC
SiemensDrive.Write(itemTag.Value.PVAddress, (short)LinDriveService.GetLdfSpeedValueBySpeedName("通讯芯片温度"));
//itemTag.Value.EngPvValue = 0;
break;
default:
break;
}
} }
OperateResultShort = SiemensDrive.ReadInt16(itemTag.Value.PVAddress); OperateResultShort = SiemensDrive.ReadInt16(itemTag.Value.PVAddress);
@@ -1285,7 +1374,7 @@ namespace CapMachine.Wpf.Services
} }
DiagnosticsTime.Stop(); DiagnosticsTime.Stop();
ConfigService.PlcCycleTime = (int)DiagnosticsTime.Elapsed.TotalMilliseconds; ConfigService.PlcCycleTime = (int)DiagnosticsTime.Elapsed.TotalMilliseconds-300;
//Console.WriteLine($"扫描时间:{DiagnosticsTime.Elapsed.TotalMilliseconds.ToString()}"); //Console.WriteLine($"扫描时间:{DiagnosticsTime.Elapsed.TotalMilliseconds.ToString()}");
} }
}); });

View File

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

View File

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

View File

@@ -18,6 +18,7 @@ using System.Threading.Tasks;
using System.Windows.Controls; using System.Windows.Controls;
using Microsoft.Win32; using Microsoft.Win32;
using static CapMachine.Wpf.Models.ComEnum; using static CapMachine.Wpf.Models.ComEnum;
using ImTools;
namespace CapMachine.Wpf.ViewModels namespace CapMachine.Wpf.ViewModels
{ {
@@ -37,7 +38,7 @@ namespace CapMachine.Wpf.ViewModels
/// <param name="machineRtDataService"></param> /// <param name="machineRtDataService"></param>
public LinConfigViewModel(IDialogService dialogService, IFreeSql freeSql, public LinConfigViewModel(IDialogService dialogService, IFreeSql freeSql,
IEventAggregator eventAggregator, IRegionManager regionManager, SysRunService sysRunService, IEventAggregator eventAggregator, IRegionManager regionManager, SysRunService sysRunService,
ConfigService configService, LinDriveService linDriveService,ComActionService comActionService, ConfigService configService, LinDriveService linDriveService, ComActionService comActionService,
IMapper mapper, MachineRtDataService machineRtDataService) IMapper mapper, MachineRtDataService machineRtDataService)
{ {
//LogService = logService; //LogService = logService;
@@ -113,6 +114,8 @@ namespace CapMachine.Wpf.ViewModels
if (SelectCanLinConfigPro != null) if (SelectCanLinConfigPro != null)
{ {
SelectCanLinConfigPro = canLinConfigPros.Where(a => a.Id == SelectCanLinConfigPro.Id).FirstOrDefault()!; SelectCanLinConfigPro = canLinConfigPros.Where(a => a.Id == SelectCanLinConfigPro.Id).FirstOrDefault()!;
//无数据就返回
if (SelectCanLinConfigPro == null) return;
SelectedLINConfigExdDto = Mapper.Map<LINConfigExdDto>(SelectCanLinConfigPro!.LINConfigExd); SelectedLINConfigExdDto = Mapper.Map<LINConfigExdDto>(SelectCanLinConfigPro!.LINConfigExd);
@@ -146,11 +149,47 @@ namespace CapMachine.Wpf.ViewModels
if (ReadData != null && ReadData.Count > 0) if (ReadData != null && ReadData.Count > 0)
{ {
ListReadCanLinRWConfigDto = new ObservableCollection<CanLinRWConfigDto>(Mapper.Map<List<CanLinRWConfigDto>>(ReadData)); 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; private bool _IsLinConfigProActive = false;
@@ -611,7 +650,6 @@ namespace CapMachine.Wpf.ViewModels
} }
} }
/// <summary> /// <summary>
/// 选中的LinLdfModel /// 选中的LinLdfModel
/// </summary> /// </summary>
@@ -648,8 +686,7 @@ namespace CapMachine.Wpf.ViewModels
return; return;
} }
if ((par as SelectionChangedEventArgs)!.AddedItems.Count == 0)
if ((par as SelectionChangedEventArgs)!.AddedItems[0] == null)
{ {
return; return;
} }
@@ -788,6 +825,10 @@ namespace CapMachine.Wpf.ViewModels
{ {
var LdfData = LinDriveService.StartLdf(SelectedLINConfigExdDto.LdfPath); var LdfData = LinDriveService.StartLdf(SelectedLINConfigExdDto.LdfPath);
ListLinLdfModel = LdfData; ListLinLdfModel = LdfData;
//ListLinLdfModel有数据后就要看看是否有配置信息有的话就要标注
//匹配选中的SelectCanLinConfigPro.CanLinConfigContents和ListLinLdfModel
MatchSeletedAndLinLdfModel();
} }
} }
else else

View File

@@ -12,6 +12,7 @@ using Prism.Commands;
using Prism.Events; using Prism.Events;
using Prism.Regions; using Prism.Regions;
using Prism.Services.Dialogs; using Prism.Services.Dialogs;
using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Data; using System.Data;
using System.Text; using System.Text;
@@ -2320,6 +2321,8 @@ namespace CapMachine.Wpf.ViewModels
{ {
//当前的程序开始标记 //当前的程序开始标记
ProParsSongZhiHelper.Start(); ProParsSongZhiHelper.Start();
//返回的数据
List<PlcParsData> ReturnPlcParsData = new List<PlcParsData>();
//var Data=FreeSql.Select<ProSegRun>( //var Data=FreeSql.Select<ProSegRun>(
//以每个程序为单元循环执行 //以每个程序为单元循环执行
@@ -2351,14 +2354,19 @@ namespace CapMachine.Wpf.ViewModels
if (FindData != null && FindData.ProSteps != null && FindData.ProSteps.Any()) if (FindData != null && FindData.ProSteps != null && FindData.ProSteps.Any())
{ {
//执行程序的步骤集合数据 //执行程序的步骤集合数据
var ReturnPlcParsData = ProParsSongZhiHelper.GetPlcParsData(FindData.ProSteps, FindData.ProRepeat); ReturnPlcParsData = ProParsSongZhiHelper.GetPlcParsData(FindData.ProSteps, FindData.ProRepeat);
ProParsSongZhiHelper.LoadDataToPLC(MachineRtDataService.SiemensDrive, ReturnPlcParsData);
//下载完成的话,则标记状态
SysRunService.MachineRunState1.IsProLoad = true;
} }
} }
//防止上一次下载的程序多余当前的步骤,为了清空多余的步骤数据,增加一行的数据
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.Model;
using CapMachine.Wpf.Dtos; using CapMachine.Wpf.Dtos;
using CapMachine.Wpf.PrismEvent; using CapMachine.Wpf.PrismEvent;
using CapMachine.Wpf.Services;
using Prism.Commands; using Prism.Commands;
using Prism.Events; using Prism.Events;
using Prism.Services.Dialogs; using Prism.Services.Dialogs;
@@ -18,13 +19,13 @@ namespace CapMachine.Wpf.ViewModels
/// <summary> /// <summary>
/// 实例化函数 /// 实例化函数
/// </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; DialogService = dialogService;
FreeSql = freeSql; FreeSql = freeSql;
EventAggregator = eventAggregator; EventAggregator = eventAggregator;
Mapper = mapper; Mapper = mapper;
ConfigService = configService;
ListChartTabGroupDto = Mapper.Map<List<ChartTabGroupDto>>(FreeSql.Select<ChartTabGroup>().Where(a => a.IsEnable == true).ToList()); ListChartTabGroupDto = Mapper.Map<List<ChartTabGroupDto>>(FreeSql.Select<ChartTabGroup>().Where(a => a.IsEnable == true).ToList());
//都要加载数据 //都要加载数据
@@ -47,6 +48,7 @@ namespace CapMachine.Wpf.ViewModels
/// AutoMap映射 /// AutoMap映射
/// </summary> /// </summary>
public IMapper Mapper { get; } public IMapper Mapper { get; }
public ConfigService ConfigService { get; }
/// <summary> /// <summary>
/// FreeSQL 实例 /// FreeSQL 实例
@@ -322,6 +324,8 @@ namespace CapMachine.Wpf.ViewModels
EventAggregator.GetEvent<ChartSetEvent>().Publish(new ChartSetMsg() { Machine = CurSelectedMachine, GroupTabIndex = SeletedGroupTabIndex, ChartSetInfo = "游标放大" }); EventAggregator.GetEvent<ChartSetEvent>().Publish(new ChartSetMsg() { Machine = CurSelectedMachine, GroupTabIndex = SeletedGroupTabIndex, ChartSetInfo = "游标放大" });
break; break;
case "保存照片": case "保存照片":
//临时的屏蔽状态
ConfigService.ChartSavePageTempState = true;
//Chart操作 //Chart操作
EventAggregator.GetEvent<ChartSetEvent>().Publish(new ChartSetMsg() { Machine = CurSelectedMachine, GroupTabIndex = SeletedGroupTabIndex, ChartSetInfo = "保存照片" }); EventAggregator.GetEvent<ChartSetEvent>().Publish(new ChartSetMsg() { Machine = CurSelectedMachine, GroupTabIndex = SeletedGroupTabIndex, ChartSetInfo = "保存照片" });
break; break;

View File

@@ -73,7 +73,7 @@
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="400" /> <ColumnDefinition Width="400" />
<ColumnDefinition /> <ColumnDefinition />
<ColumnDefinition Width="500" /> <ColumnDefinition Width="550" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid Margin="3"> <Grid Margin="3">
@@ -931,6 +931,14 @@
</ContextMenu> </ContextMenu>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSeletedInfo}" Value="1">
<Setter Property="Background" Value="GreenYellow" />
</DataTrigger>
<DataTrigger Binding="{Binding IsSeletedInfo}" Value="2">
<Setter Property="Background" Value="SkyBlue" />
</DataTrigger>
</Style.Triggers>
</Style> </Style>
</DataGrid.RowStyle> </DataGrid.RowStyle>

View File

@@ -73,7 +73,7 @@
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button <!--<Button
Margin="5,0" Margin="5,0"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Command="{Binding ReportDataCmd}" Command="{Binding ReportDataCmd}"
@@ -89,7 +89,7 @@
Text="&#xedde;" /> Text="&#xedde;" />
<TextBlock Text="导出Excel数据" /> <TextBlock Text="导出Excel数据" />
</StackPanel> </StackPanel>
</Button> </Button>-->
<Button <Button
Margin="5,0" Margin="5,0"
HorizontalAlignment="Center" HorizontalAlignment="Center"
@@ -209,7 +209,7 @@
SelectionMode="Extended" SelectionMode="Extended"
SelectionUnit="FullRow"> SelectionUnit="FullRow">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}"> <DataGridTextColumn MinWidth="300" Binding="{Binding Name}">
<DataGridTextColumn.Header> <DataGridTextColumn.Header>
<TextBlock FontWeight="Bold" Text="试验名称" /> <TextBlock FontWeight="Bold" Text="试验名称" />
</DataGridTextColumn.Header> </DataGridTextColumn.Header>
@@ -271,7 +271,7 @@
SelectionMode="Extended" SelectionMode="Extended"
SelectionUnit="FullRow"> SelectionUnit="FullRow">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding WorkDay}"> <DataGridTextColumn MinWidth="300" Binding="{Binding WorkDay}">
<DataGridTextColumn.Header> <DataGridTextColumn.Header>
<TextBlock FontWeight="Bold" Text="文件名称/日期" /> <TextBlock FontWeight="Bold" Text="文件名称/日期" />
</DataGridTextColumn.Header> </DataGridTextColumn.Header>

View File

@@ -930,6 +930,14 @@
</ContextMenu> </ContextMenu>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding IsSeletedInfo}" Value="1">
<Setter Property="Background" Value="GreenYellow" />
</DataTrigger>
<DataTrigger Binding="{Binding IsSeletedInfo}" Value="2">
<Setter Property="Background" Value="SkyBlue" />
</DataTrigger>
</Style.Triggers>
</Style> </Style>
</DataGrid.RowStyle> </DataGrid.RowStyle>

View File

@@ -1269,11 +1269,11 @@
ToolTip="输出锁定" /> ToolTip="输出锁定" />
</StackPanel> </StackPanel>
<StackPanel Grid.Column="1" HorizontalAlignment="Center"> <StackPanel Grid.Column="1" HorizontalAlignment="Center">
<TextBlock FontSize="12" Text="参数编号(116)" /> <TextBlock FontSize="12" Text="参数编号(110)" />
<TextBox Style="{StaticResource txtboxStyle}" Text="{Binding SelectedSlopMeterSpeed.ParNo}" /> <TextBox Style="{StaticResource txtboxStyle}" Text="{Binding SelectedSlopMeterSpeed.ParNo}" />
</StackPanel> </StackPanel>
<StackPanel Grid.Column="2" HorizontalAlignment="Center"> <StackPanel Grid.Column="2" HorizontalAlignment="Center">
<TextBlock FontSize="12" Text="EV(14)" /> <TextBlock FontSize="12" Text="EV(12)" />
<TextBox Style="{StaticResource txtboxStyle}" Text="{Binding SelectedSlopMeterSpeed.Ev}" /> <TextBox Style="{StaticResource txtboxStyle}" Text="{Binding SelectedSlopMeterSpeed.Ev}" />
</StackPanel> </StackPanel>
<StackPanel Grid.Column="3" HorizontalAlignment="Center"> <StackPanel Grid.Column="3" HorizontalAlignment="Center">
@@ -1297,7 +1297,7 @@
Style="{StaticResource MaterialDesignSwitchToggleButton}" Style="{StaticResource MaterialDesignSwitchToggleButton}"
ToolTip="吸排气阀" /> ToolTip="吸排气阀" />
</StackPanel> </StackPanel>
<StackPanel <!--<StackPanel
Grid.Row="1" Grid.Row="1"
Grid.Column="1" Grid.Column="1"
HorizontalAlignment="Center"> HorizontalAlignment="Center">
@@ -1308,7 +1308,7 @@
IsChecked="{Binding SelectedSlopMeterSpeed.PTCEnable}" IsChecked="{Binding SelectedSlopMeterSpeed.PTCEnable}"
Style="{StaticResource MaterialDesignSwitchToggleButton}" Style="{StaticResource MaterialDesignSwitchToggleButton}"
ToolTip="PTC使能" /> ToolTip="PTC使能" />
</StackPanel> </StackPanel>-->
</Grid> </Grid>
</Border> </Border>