根据新需求更改

This commit is contained in:
2025-09-17 17:22:09 +08:00
parent e7adae128e
commit a954427d41
21 changed files with 633 additions and 126 deletions

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
namespace MoviconHub.App.Models
{
@@ -11,11 +7,22 @@ namespace MoviconHub.App.Models
/// </summary>
public class ClearAction
{
/// <summary>
/// 清洗事件
/// </summary>
public event EventHandler<string> ClearActionEvent;
/// <summary>
/// 设备状态改变事件
/// </summary>
public event EventHandler<StateInfo> DeviceStateChangeEvent;
// 状态变更并发锁:确保在多线程环境下,状态切换与事件发布的原子性,避免竞态条件
private readonly object _stateLock = new object();
// 是否已存在当前状态:用于首次赋值时不发布“上一状态”事件的标记
private bool _hasCurrentState = false;
private bool _ClearEnd;
/// <summary>
@@ -61,7 +68,74 @@ namespace MoviconHub.App.Models
}
}
/// <summary>
/// 当前状态信息
/// </summary>
public StateInfo CurStateInfo { get; set; } = new StateInfo();
private int _DeviceState;
/// <summary>
/// 设备状态
/// </summary>
public int DeviceState
{
get { return _DeviceState; }
set
{
if (_DeviceState != value)
{
lock (_stateLock)
{
var now = DateTime.Now;
// 若已有当前状态,先发布上一个状态的维持区间
if (_hasCurrentState)
{
var prevStateInfo = new StateInfo
{
StartTime = CurStateInfo.StartTime,
EndTime = now,
State = CurStateInfo.State
};
var handler = DeviceStateChangeEvent;
handler?.BeginInvoke(this, prevStateInfo, null, null);
}
// 更新为新的当前状态
_DeviceState = value;
CurStateInfo = new StateInfo
{
StartTime = now,
EndTime = default, // 结束时间在下次状态变化时确定
State = value
};
_hasCurrentState = true;
}
}
}
}
}
/// <summary>
/// 状态信息
/// </summary>
public class StateInfo
{
/// <summary>
/// 开始时间
/// </summary>
public DateTime StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public DateTime EndTime { get; set; }
/// <summary>
/// 值
/// </summary>
public int State { get; set; }
}
}

View File

@@ -181,6 +181,112 @@ namespace MoviconHub.App.Models
[Column(Name = "Test_SteamSurveillance", StringLength = 100, IsNullable = true)]
public string Test_SteamSurveillance { get; set; }
///// <summary>
///// ​零部件车间桁架平移原位​​
///// </summary>
//[Column(Name = "Test_TrussMoveHome", StringLength = 100, IsNullable = true)]
//public string Test_TrussMoveHome { get; set; }
///// <summary>
///// ​零部件车间桁架平移后退极限位​​
///// </summary>
//[Column(Name = "Test_TrussMoveBackwardLimit", StringLength = 100, IsNullable = true)]
//public string Test_TrussMoveBackwardLimit { get; set; }
///// <summary>
///// ​零部件车间桁架平移前进极限位​​
///// </summary>
//[Column(Name = "Test_TrussMoveForwardLimit", StringLength = 100, IsNullable = true)]
//public string Test_TrussMoveForwardLimit { get; set; }
///// <summary>
///// ​零部件车间桁架吊装浸泡池吊装位​​
///// </summary>
//[Column(Name = "Test_TrussLiftPoolPos", StringLength = 100, IsNullable = true)]
//public string Test_TrussLiftPoolPos { get; set; }
///// <summary>
///// ​零部件车间桁架吊装下降极限位​​
///// </summary>
//[Column(Name = "Test_TrussLiftLowerLimit", StringLength = 100, IsNullable = true)]
//public string Test_TrussLiftLowerLimit { get; set; }
///// <summary>
///// ​零部件车间桁架吊装原位​​
///// </summary>
//[Column(Name = "Test_TrussLiftHome", StringLength = 100, IsNullable = true)]
//public string Test_TrussLiftHome { get; set; }
///// <summary>
///// ​零部件车间桁架吊装上升极限位​​
///// </summary>
//[Column(Name = "Test_TrussLiftRiseLimit", StringLength = 100, IsNullable = true)]
//public string Test_TrussLiftRiseLimit { get; set; }
///// <summary>
///// ​零部件车间桁架吊装漫射吊装位​​
///// </summary>
//[Column(Name = "Test_TrussLiftWashPos", StringLength = 100, IsNullable = true)]
//public string Test_TrussLiftWashPos { get; set; }
///// <summary>
///// ROB1_第7轴接近开关ROB1原位
///// </summary>
//[Column(Name = "Test_Rob1Axis7Home", StringLength = 100, IsNullable = true)]
//public string Test_Rob1Axis7Home { get; set; }
///// <summary>
///// ROB1_第7轴接近开关前进极限位正常
///// </summary>
//[Column(Name = "Test_Rob1Axis7ForwardLimitOK", StringLength = 100, IsNullable = true)]
//public string Test_Rob1Axis7ForwardLimitOK { get; set; }
///// <summary>
///// ROB1_第7轴接近开关后退极限位正常
///// </summary>
//[Column(Name = "Test_Rob1Axis7BackwardLimitOK", StringLength = 100, IsNullable = true)]
//public string Test_Rob1Axis7BackwardLimitOK { get; set; }
///// <summary>
///// ROB2_第7轴接近开关ROB2原位
///// </summary>
//[Column(Name = "Test_Rob2Axis7Home", StringLength = 100, IsNullable = true)]
//public string Test_Rob2Axis7Home { get; set; }
///// <summary>
///// ROB2_第7轴接近开关前进极限位正常
///// </summary>
//[Column(Name = "Test_Rob2Axis7ForwardLimitOK", StringLength = 100, IsNullable = true)]
//public string Test_Rob2Axis7ForwardLimitOK { get; set; }
///// <summary>
///// ROB2_第7轴接近开关后退极限位正常
///// </summary>
//[Column(Name = "Test_Rob2Axis7BackwardLimitOK", StringLength = 100, IsNullable = true)]
//public string Test_Rob2Axis7BackwardLimitOK { get; set; }
/// <summary>
/// 创建时间
/// </summary>

View File

@@ -0,0 +1,60 @@
using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MoviconHub.App.Models
{
/// <summary>
/// 设备状态改变
/// </summary>
[Table(Name = "DeviceStatusChange")]
public class DeviceStatusChange
{
/// <summary>
/// 主键ID
/// </summary>
[Column(IsPrimary = true, IsIdentity = true)]
public long Id { get; set; }
/// <summary>
/// 设备码
/// </summary>
[Column(Name = "DeviceCode", StringLength = 100, IsNullable = true)]
public string DeviceCode { get; set; }
/// <summary>
/// 设备名称
/// </summary>
[Column(Name = "DeviceName", StringLength = 100, IsNullable = true)]
public string DeviceName { get; set; }
/// <summary>
/// 开始时间
/// </summary>
[Column(Name = "StartTime", IsNullable = true)]
public DateTime StartTime { get; set; }
/// <summary>
/// 结束时间
/// </summary>
[Column(Name = "EndTime", IsNullable = true)]
public DateTime EndTime { get; set; }
/// <summary>
/// 设备状态
/// </summary>
[Column(Name = "DeviceState", IsNullable = true)]
public int? DeviceState { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Column(ServerTime = DateTimeKind.Local, CanUpdate = false)]
public DateTime CreateTime { get; set; }
}
}

View File

@@ -209,6 +209,89 @@ namespace MoviconHub.App.Models
[JsonProperty("Test_SteamSurveillance")]
public string Test_SteamSurveillance { get; set; }
/// <summary>
/// ​零部件车间桁架平移原位​​
/// </summary>
[JsonProperty("Test_TrussMoveHome")]
public string Test_TrussMoveHome { get; set; }
/// <summary>
/// ​零部件车间桁架平移后退极限位​​
/// </summary>
[JsonProperty("Test_TrussMoveBackwardLimit")]
public string Test_TrussMoveBackwardLimit { get; set; }
/// <summary>
/// ​零部件车间桁架平移前进极限位​​
/// </summary>
[JsonProperty("Test_TrussMoveForwardLimit")]
public string Test_TrussMoveForwardLimit { get; set; }
/// <summary>
/// ​零部件车间桁架吊装浸泡池吊装位​​
/// </summary>
[JsonProperty("Test_TrussLiftPoolPos")]
public string Test_TrussLiftPoolPos { get; set; }
/// <summary>
/// ​零部件车间桁架吊装下降极限位​​
/// </summary>
[JsonProperty("Test_TrussLiftLowerLimit")]
public string Test_TrussLiftLowerLimit { get; set; }
/// <summary>
/// ​零部件车间桁架吊装原位​​
/// </summary>
[JsonProperty("Test_TrussLiftHome")]
public string Test_TrussLiftHome { get; set; }
/// <summary>
/// ​零部件车间桁架吊装上升极限位​​
/// </summary>
[JsonProperty("Test_TrussLiftRiseLimit")]
public string Test_TrussLiftRiseLimit { get; set; }
/// <summary>
/// ​零部件车间桁架吊装漫射吊装位​​
/// </summary>
[JsonProperty("Test_TrussLiftWashPos")]
public string Test_TrussLiftWashPos { get; set; }
/// <summary>
/// ROB1_第7轴接近开关ROB1原位
/// </summary>
[JsonProperty("Test_Rob1Axis7Home")]
public string Test_Rob1Axis7Home { get; set; }
/// <summary>
/// ROB1_第7轴接近开关前进极限位正常
/// </summary>
[JsonProperty("Test_Rob1Axis7ForwardLimitOK")]
public string Test_Rob1Axis7ForwardLimitOK { get; set; }
/// <summary>
/// ROB1_第7轴接近开关后退极限位正常
/// </summary>
[JsonProperty("Test_Rob1Axis7BackwardLimitOK")]
public string Test_Rob1Axis7BackwardLimitOK { get; set; }
/// <summary>
/// ROB2_第7轴接近开关ROB2原位
/// </summary>
[JsonProperty("Test_Rob2Axis7Home")]
public string Test_Rob2Axis7Home { get; set; }
/// <summary>
/// ROB2_第7轴接近开关前进极限位正常
/// </summary>
[JsonProperty("Test_Rob2Axis7ForwardLimitOK")]
public string Test_Rob2Axis7ForwardLimitOK { get; set; }
/// <summary>
/// ROB2_第7轴接近开关后退极限位正常
/// </summary>
[JsonProperty("Test_Rob2Axis7BackwardLimitOK")]
public string Test_Rob2Axis7BackwardLimitOK { get; set; }
/// <summary>
/// 测试数据值集合