根据新需求更改
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
60
MoviconHub.App/Models/DeviceStatusChange.cs
Normal file
60
MoviconHub.App/Models/DeviceStatusChange.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
/// 测试数据值集合
|
||||
|
||||
@@ -128,6 +128,7 @@
|
||||
<Compile Include="Models\DeviceAlarm.cs" />
|
||||
<Compile Include="Models\DeviceState.cs" />
|
||||
<Compile Include="Models\DeviceStateStaticModel.cs" />
|
||||
<Compile Include="Models\DeviceStatusChange.cs" />
|
||||
<Compile Include="Models\FaultDetails.cs" />
|
||||
<Compile Include="Models\DeviceStatusData.cs" />
|
||||
<Compile Include="Models\EnvironmentData.cs" />
|
||||
|
||||
@@ -257,7 +257,7 @@ namespace MoviconHub.App.Services
|
||||
Test_WaterTankAdd = webSocketData.TestData.Test_WaterTankAdd,
|
||||
Test_CleaningAgentTankHeat = webSocketData.TestData.Test_CleaningAgentTankHeat,
|
||||
Test_CleaningAgentTankAdd = webSocketData.TestData.Test_CleaningAgentTankAdd,
|
||||
|
||||
|
||||
// 监控信息
|
||||
Test_ElectricSurveillance = webSocketData.TestData.Test_ElectricSurveillance,
|
||||
Test_SteamSurveillance = webSocketData.TestData.Test_SteamSurveillance
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace MoviconHub.App
|
||||
|
||||
ClearActionInstance = new ClearAction();
|
||||
ClearActionInstance.ClearActionEvent += ClearActionInstance_ClearActionEvent;
|
||||
ClearActionInstance.DeviceStateChangeEvent += ClearActionInstance_DeviceStateChangeEvent;
|
||||
|
||||
ListAlarmModels = new List<AlarmModel>()
|
||||
{
|
||||
@@ -437,6 +438,29 @@ namespace MoviconHub.App
|
||||
|
||||
}
|
||||
|
||||
private void ClearActionInstance_DeviceStateChangeEvent(object sender, StateInfo Value)
|
||||
{
|
||||
var Data = new DeviceStatusChange()
|
||||
{
|
||||
DeviceCode = "942010002",
|
||||
DeviceName = "机车构架及大部件自动化智能清洗设备",
|
||||
DeviceState = Value.State,
|
||||
StartTime = Value.StartTime,
|
||||
EndTime = Value.EndTime,
|
||||
};
|
||||
|
||||
var Result = FRemoteSqlContext.FDb.Insert<DeviceStatusChange>(Data).ExecuteInserted();
|
||||
if (Result != null && Result.Count > 0)
|
||||
{
|
||||
Logger.Info("设备数据状态改变保存完成");
|
||||
|
||||
BeginInvoke(new Action(() =>
|
||||
{
|
||||
MainText.AppendText($"时间:{DateTime.Now}-Msg:设备数据状态改变保存完成 {Environment.NewLine}");
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清洗动作实例信息
|
||||
/// </summary>
|
||||
@@ -532,7 +556,23 @@ namespace MoviconHub.App
|
||||
|
||||
// 监控信息
|
||||
Test_ElectricSurveillance = CurDBServices.RealtimeData.TestData.Test_ElectricSurveillance,
|
||||
Test_SteamSurveillance = CurDBServices.RealtimeData.TestData.Test_SteamSurveillance
|
||||
Test_SteamSurveillance = CurDBServices.RealtimeData.TestData.Test_SteamSurveillance,
|
||||
|
||||
//Test_Rob1Axis7BackwardLimitOK = CurDBServices.RealtimeData.TestData.Test_Rob1Axis7BackwardLimitOK,
|
||||
//Test_Rob1Axis7ForwardLimitOK = CurDBServices.RealtimeData.TestData.Test_Rob1Axis7ForwardLimitOK,
|
||||
//Test_Rob1Axis7Home = CurDBServices.RealtimeData.TestData.Test_Rob1Axis7Home,
|
||||
//Test_Rob2Axis7BackwardLimitOK = CurDBServices.RealtimeData.TestData.Test_Rob2Axis7BackwardLimitOK,
|
||||
//Test_Rob2Axis7ForwardLimitOK = CurDBServices.RealtimeData.TestData.Test_Rob2Axis7ForwardLimitOK,
|
||||
//Test_Rob2Axis7Home = CurDBServices.RealtimeData.TestData.Test_Rob2Axis7Home,
|
||||
//Test_TrussLiftHome = CurDBServices.RealtimeData.TestData.Test_TrussLiftHome,
|
||||
//Test_TrussLiftLowerLimit = CurDBServices.RealtimeData.TestData.Test_TrussLiftLowerLimit,
|
||||
//Test_TrussLiftPoolPos = CurDBServices.RealtimeData.TestData.Test_TrussLiftPoolPos,
|
||||
//Test_TrussLiftRiseLimit = CurDBServices.RealtimeData.TestData.Test_TrussLiftRiseLimit,
|
||||
//Test_TrussLiftWashPos = CurDBServices.RealtimeData.TestData.Test_TrussLiftWashPos,
|
||||
//Test_TrussMoveBackwardLimit = CurDBServices.RealtimeData.TestData.Test_TrussMoveBackwardLimit,
|
||||
//Test_TrussMoveForwardLimit = CurDBServices.RealtimeData.TestData.Test_TrussMoveForwardLimit,
|
||||
//Test_TrussMoveHome = CurDBServices.RealtimeData.TestData.Test_TrussMoveHome,
|
||||
|
||||
};
|
||||
|
||||
var Result = FRemoteSqlContext.FDb.Insert<ClearData>(curRunData).ExecuteInserted();
|
||||
@@ -594,6 +634,8 @@ namespace MoviconHub.App
|
||||
/// </summary>
|
||||
private OperateResult<Int16[]> OperateResultDeviceStateStatic { get; set; }
|
||||
|
||||
private OperateResult<Int16> OperateResultDeviceStateChange { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 通信初始化
|
||||
/// </summary>
|
||||
@@ -677,18 +719,26 @@ namespace MoviconHub.App
|
||||
}
|
||||
}
|
||||
|
||||
OperateResultDeviceStateChange = MelsecMcNetDrive.ReadInt16("D4000");
|
||||
if (OperateResultDeviceStateChange.IsSuccess)
|
||||
{
|
||||
ClearActionInstance.DeviceState = OperateResultDeviceStateChange.Content;
|
||||
}
|
||||
|
||||
//OperateResultClearEnd = MelsecMcNetDrive.ReadBool("M210");
|
||||
//if (OperateResultClearEnd.IsSuccess)
|
||||
//{
|
||||
// ClearActionInstance.ClearEnd = OperateResultClearEnd.Content;
|
||||
//}
|
||||
|
||||
//设备清洗结束
|
||||
OperateResultClearEnd = MelsecMcNetDrive.ReadBool("M211");
|
||||
if (OperateResultClearEnd.IsSuccess)
|
||||
{
|
||||
ClearActionInstance.ClearEnd = OperateResultClearEnd.Content;
|
||||
}
|
||||
|
||||
//设备关机
|
||||
OperateResultDeviceClose = MelsecMcNetDrive.ReadBool("M210");
|
||||
if (OperateResultDeviceClose.IsSuccess)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user