一些更改

This commit is contained in:
2025-01-21 18:35:00 +08:00
parent 914a8b3dbc
commit 0bbe361ab7
23 changed files with 536 additions and 101 deletions

View File

@@ -53,6 +53,11 @@ namespace CapMachine.Wpf.Models
/// 字节
/// </summary>
Byte = 0,
/// <summary>
/// 字节
/// </summary>
Bool = 4,
}
/// <summary>

View File

@@ -20,7 +20,7 @@ namespace CapMachine.Wpf.Models
/// <summary>
/// 实例化
/// </summary>
public MachineRunState(string name, IEventAggregator eventAggregator, ConfigService configService)
public MachineRunState(string name, IEventAggregator eventAggregator, ConfigService configService, CanDriveService canDriveService, LinDriveService linDriveService)
{
Name = name;
EventAggregator = eventAggregator;
@@ -29,7 +29,7 @@ namespace CapMachine.Wpf.Models
}
private string _RunStateMsg="等待";
private string _RunStateMsg = "等待";
/// <summary>
/// 运行状态
/// </summary>
@@ -39,10 +39,27 @@ namespace CapMachine.Wpf.Models
set { _RunStateMsg = value; RaisePropertyChanged(); }
}
private bool _IsRunState;
/// <summary>
/// 是否运行状态
/// </summary>
public bool IsRunState
{
get { return _IsRunState; }
set { _IsRunState = value; RaisePropertyChanged(); }
}
private bool _IsProLoad;
/// <summary>
/// PLC程序是否下载
/// </summary>
public bool IsProLoad { get; set; }
public bool IsProLoad
{
get { return _IsProLoad; }
set { _IsProLoad = value; RaisePropertyChanged(); }
}
/// <summary>
/// 状态机
@@ -320,22 +337,33 @@ namespace CapMachine.Wpf.Models
Console.WriteLine($"{Name}-StopExitCall");
}
/// <summary>
/// 进入停止状态
/// </summary>
private void StopEntryCall()
{
RunStateMsg = "停止";
Console.WriteLine($"{Name}-StopEntryCall");
}
private void RunExitCall()
{
//退出运行状态
IsRunState = false;
Console.WriteLine($"{Name}-RunExitCall");
}
/// <summary>
/// 进入运行状态
/// </summary>
private void RunEntryCall()
{
RunStateMsg = "运行";
Console.WriteLine($"{Name}-RunEntryCall");
//进入运行状态
IsRunState = true;
}
private void AlarmExitCall()
@@ -376,5 +404,7 @@ namespace CapMachine.Wpf.Models
public string Name { get; set; }
public IEventAggregator EventAggregator { get; }
public ConfigService ConfigService { get; }
public CanDriveService CanDriveService { get; }
public LinDriveService LinDriveService { get; }
}
}

View File

@@ -0,0 +1,39 @@
using CapMachine.Wpf.Models.Tag;
using HslCommunication.Profinet.Siemens;
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 SysExdBoolInfo:BindableBase
{
public SysExdBoolInfo(SiemensS7Net siemensS7Net)
{
QuickTags = new List<QuickTag>()
{
new QuickTag(siemensS7Net) { Name = "开始状态", Group = "状态", Unit = "", ValueAddress = "V40.0", Precision = 0, ValueType = ComEnum.DataType.Bool, ByteLength = 1 },
};
StartRunStateQuickTag = QuickTags.Find(a=>a.Name== "开始状态")!;
}
/// <summary>
/// 快速标签
/// </summary>
public List<QuickTag> QuickTags { get; set; }
/// <summary>
/// 开始运行状态标签
/// </summary>
public QuickTag StartRunStateQuickTag { get; set; }
}
}

View File

@@ -47,14 +47,19 @@ namespace CapMachine.Wpf.Models.Tag
private object? _Value;
/// <summary>
/// 实时值
/// 这样会不会导致内存泄露
/// </summary>
public object? Value
{
get { return _Value; }
set
{
_Value = value;
ValueStr = value?.ToString();
if (!value.Equals(_Value) )
{
_Value = value;
RaisePropertyChanged();
ValueStr = value?.ToString();
}
}
}
@@ -81,6 +86,9 @@ namespace CapMachine.Wpf.Models.Tag
case DataType.Byte:
Value = SiemensS7Net.ByteTransform.TransByte(value!.Content, 0);
break;
case DataType.Bool:
Value = SiemensS7Net.ByteTransform.TransBool(value!.Content, 0);
break;
default:
break;
}