添加项目文件。
This commit is contained in:
50
OrpaonEMS.Core/Model/AlarmTimeInfo.cs
Normal file
50
OrpaonEMS.Core/Model/AlarmTimeInfo.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.Core.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警时间信息
|
||||
/// </summary>
|
||||
public class AlarmTimeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 开始报警
|
||||
/// </summary>
|
||||
public DateTime StartTime { set; get; }
|
||||
|
||||
|
||||
private DateTime _EndTime;
|
||||
/// <summary>
|
||||
/// 结束报警
|
||||
/// </summary>
|
||||
public DateTime EndTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return _EndTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
_EndTime = value;
|
||||
this.AlarmDur = (EndTime - StartTime).TotalMinutes;
|
||||
}
|
||||
}
|
||||
|
||||
private double _AlarmDur;
|
||||
public double AlarmDur
|
||||
{
|
||||
get
|
||||
{
|
||||
return _AlarmDur;
|
||||
}
|
||||
set
|
||||
{
|
||||
_AlarmDur = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
OrpaonEMS.Core/Model/BmsRtAlarmModel.cs
Normal file
31
OrpaonEMS.Core/Model/BmsRtAlarmModel.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.Core.Model
|
||||
{
|
||||
public class BmsRtAlarmModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警状态
|
||||
/// </summary>
|
||||
public bool AlarmState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alarm等级
|
||||
/// </summary>
|
||||
public int AlarmLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alarm内容
|
||||
/// </summary>
|
||||
public string AlarmContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alarm时间
|
||||
/// </summary>
|
||||
public DateTime AlarmTime { get; set; }
|
||||
}
|
||||
}
|
||||
78
OrpaonEMS.Core/Model/LinkStateModel.cs
Normal file
78
OrpaonEMS.Core/Model/LinkStateModel.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.Core.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 连接状态模型
|
||||
/// 有些设备有时候会出现一次连接失败,但是下一次就会连接成功,那么不能判断为连接失败
|
||||
/// </summary>
|
||||
public class LinkStateModel : BindableBase
|
||||
{
|
||||
public LinkStateModel()
|
||||
{
|
||||
_LinkState = true;
|
||||
}
|
||||
|
||||
|
||||
private string _BmsLinkStateMsg = "失败";
|
||||
/// <summary>
|
||||
/// Bms通信状态Msg
|
||||
/// </summary>
|
||||
public string BmsLinkStateMsg
|
||||
{
|
||||
get { return _BmsLinkStateMsg; }
|
||||
set { _BmsLinkStateMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private bool _LinkState;
|
||||
/// <summary>
|
||||
/// 通信连接状态
|
||||
/// </summary>
|
||||
public bool LinkState
|
||||
{
|
||||
get { return _LinkState; }
|
||||
set
|
||||
{
|
||||
if (_LinkState != value)
|
||||
{
|
||||
if (value)//改变后连接成功
|
||||
{
|
||||
//连接成功了就把报错的设置为0
|
||||
LinkErrCount = 0;
|
||||
BmsLinkStateMsg = "正常";
|
||||
_LinkState = value;
|
||||
}
|
||||
else//改变后连接失败
|
||||
{
|
||||
//
|
||||
LinkErrCount = LinkErrCount + 1;
|
||||
if (LinkErrCount >= 3)//连续达到三次算作报错
|
||||
{
|
||||
BmsLinkStateMsg = "失败";
|
||||
//连接失败
|
||||
_LinkState = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//小于三次的话则判定为没有问题
|
||||
_LinkState = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通信连接失败次数
|
||||
/// </summary>
|
||||
public int LinkErrCount { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
81
OrpaonEMS.Core/Model/TranceCmdValue.cs
Normal file
81
OrpaonEMS.Core/Model/TranceCmdValue.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.Core.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// 追踪指令值的模型
|
||||
/// </summary>
|
||||
public class TranceCmdValue
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="changeThreshold"></param>
|
||||
public TranceCmdValue(double changeThreshold)
|
||||
{
|
||||
ChangeThreshold = changeThreshold;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 变化的阀值
|
||||
/// </summary>
|
||||
public double ChangeThreshold { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 事件
|
||||
/// </summary>
|
||||
public event EventHandler<double> CmdValueChanged;
|
||||
|
||||
|
||||
private double _CmdValue;
|
||||
/// <summary>
|
||||
/// 指令值
|
||||
/// 可实时赋值
|
||||
/// </summary>
|
||||
public double CmdValue
|
||||
{
|
||||
get { return _CmdValue; }
|
||||
set
|
||||
{
|
||||
//发送0,代表是待机,此时不需要看变化了,防止上一个值在0附近,没有触发变化,还是输出一个靠近0的值出去
|
||||
if (value == 0 && value != _CmdValue)//value != _CmdValue 防止一直0值导致不停是Invoke事件
|
||||
{
|
||||
_CmdValue = value;
|
||||
//超过变化的阀值,可以触发动作 BeginInvoke 换 Invoke 可能导致问题
|
||||
CmdValueChanged.Invoke(this, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value != _CmdValue && GetChange(value, _CmdValue))
|
||||
{
|
||||
_CmdValue = value;
|
||||
//超过变化的阀值,可以触发动作
|
||||
CmdValueChanged.Invoke(this, value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否超过某个阀值数据
|
||||
/// </summary>
|
||||
/// <param name="newValue"></param>
|
||||
/// <param name="oldValue"></param>
|
||||
/// <returns></returns>
|
||||
private bool GetChange(double newValue, double oldValue)
|
||||
{
|
||||
if (Math.Abs(newValue - oldValue) >= ChangeThreshold)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user