添加项目文件。
This commit is contained in:
119
OrpaonEMS.App/Models/AlarmCell.cs
Normal file
119
OrpaonEMS.App/Models/AlarmCell.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using OrpaonEMS.Core.ChannelModel;
|
||||
using OrpaonEMS.Core.EventHandMsg;
|
||||
using OrpaonEMS.Core.Model;
|
||||
using System;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警单元
|
||||
/// </summary>
|
||||
public class AlarmCell
|
||||
{
|
||||
public AlarmCell(Channel<AlarmChannelData> channel, string content, string address, int level, ushort bitindex)
|
||||
{
|
||||
CurTimeInfo = new AlarmTimeInfo();
|
||||
|
||||
Content = content;
|
||||
Address = address;
|
||||
Level = level;
|
||||
BitIndex = bitindex;
|
||||
AlarmChannel = channel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 报警通道数据
|
||||
/// </summary>
|
||||
public Channel<AlarmChannelData> AlarmChannel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发布报警信息
|
||||
/// </summary>
|
||||
public event EventHandler<BmsAlarmCellEventHandMsg> PubBmsAlarmEventHandler;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 报警状态
|
||||
/// </summary>
|
||||
public bool State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新值 返回当前的报警状态 这个状态用于返回给PLC 用于屏蔽后面的报警数据
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void UpdateValue(bool value)
|
||||
{
|
||||
if (State == false && value == true)//初次触发报警为On时机
|
||||
{
|
||||
CurTimeInfo.StartTime = DateTime.Now;
|
||||
State = true;//报警开始
|
||||
// 需要异步执行吗???
|
||||
PubBmsAlarmEventHandler(this, new BmsAlarmCellEventHandMsg()
|
||||
{
|
||||
AlarmLevel = Level,
|
||||
AlarmContent = Content,
|
||||
AlarmTime = DateTime.Now,
|
||||
AlarmState = true
|
||||
});
|
||||
//return false;
|
||||
}
|
||||
else if (State == true && value == false)//报警结束 报警为OFF时机
|
||||
{
|
||||
CurTimeInfo.EndTime = DateTime.Now;
|
||||
State = false;
|
||||
|
||||
PubBmsAlarmEventHandler(this, new BmsAlarmCellEventHandMsg()
|
||||
{
|
||||
AlarmLevel = Level,
|
||||
AlarmContent = Content,
|
||||
AlarmTime = CurTimeInfo.StartTime,
|
||||
AlarmState = false
|
||||
});
|
||||
|
||||
//报警结束,可以采集数据
|
||||
AlarmChannel.Writer.WriteAsync(new AlarmChannelData()
|
||||
{
|
||||
MsgTime = DateTime.Now,
|
||||
alarmChannel = new AlarmChannel()
|
||||
{
|
||||
Content = Content,
|
||||
StartTime = CurTimeInfo.StartTime,
|
||||
EndTime = CurTimeInfo.EndTime,
|
||||
AlarmDur = (decimal)CurTimeInfo.AlarmDur,
|
||||
Level = Level,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 报警时间信息
|
||||
/// </summary>
|
||||
public AlarmTimeInfo CurTimeInfo { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 报警内容
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警等级
|
||||
/// </summary>
|
||||
public int Level { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 索引位置 队列位位置
|
||||
/// </summary>
|
||||
public ushort BitIndex { get; set; }
|
||||
}
|
||||
}
|
||||
22
OrpaonEMS.App/Models/AlarmChannelData.cs
Normal file
22
OrpaonEMS.App/Models/AlarmChannelData.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using OrpaonEMS.Core.ChannelModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
public class AlarmChannelData
|
||||
{
|
||||
/// <summary>
|
||||
/// 消息触发的时间
|
||||
/// </summary>
|
||||
public DateTime MsgTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警数据
|
||||
/// </summary>
|
||||
public AlarmChannel alarmChannel { get; set; }
|
||||
}
|
||||
}
|
||||
46
OrpaonEMS.App/Models/AnalysisModel/CoolAnalyse.cs
Normal file
46
OrpaonEMS.App/Models/AnalysisModel/CoolAnalyse.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 液冷分析
|
||||
/// </summary>
|
||||
public class CoolAnalyse : BindableBase
|
||||
{
|
||||
private int _DayActionCount;
|
||||
/// <summary>
|
||||
/// 液冷 今日动作次数
|
||||
/// </summary>
|
||||
public int DayActionCount
|
||||
{
|
||||
get { return _DayActionCount; }
|
||||
set { _DayActionCount = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _DayRunTime;
|
||||
/// <summary>
|
||||
/// 液冷 今日运行时长 分钟
|
||||
/// </summary>
|
||||
public double DayRunTime
|
||||
{
|
||||
get { return _DayRunTime; }
|
||||
set { _DayRunTime = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private double _DayPw;
|
||||
/// <summary>
|
||||
/// 液冷 今日耗电量 kWh
|
||||
/// </summary>
|
||||
public double DayPw
|
||||
{
|
||||
get { return _DayPw; }
|
||||
set { _DayPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
177
OrpaonEMS.App/Models/AnalysisModel/EsAnalyse.cs
Normal file
177
OrpaonEMS.App/Models/AnalysisModel/EsAnalyse.cs
Normal file
@@ -0,0 +1,177 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 储能分析
|
||||
/// 总充电量和总放电量通过PCS统计
|
||||
/// 在储能柜体中加装电表的可以使用这个统计数据信息
|
||||
/// </summary>
|
||||
public class EsAnalyse : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 一天的开始0时充电量数据
|
||||
/// </summary>
|
||||
public double DayStartPointChargPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 一天的开始0时放电量数据
|
||||
/// </summary>
|
||||
public double DayStartPointDisChargPw { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 月度的开始1号充电量数据
|
||||
/// </summary>
|
||||
public double MonthStartPointChargPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 月度的开始1号充电量数据
|
||||
/// </summary>
|
||||
public double MonthStartPointDisChargPw { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 年的开始1号充电量数据
|
||||
/// </summary>
|
||||
public double YearStartPointChargPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 年的开始1号充电量数据
|
||||
/// </summary>
|
||||
public double YearStartPointDisChargPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ////////////////////////////////////收益数据////////////////////////////////////////////
|
||||
/// </summary>
|
||||
|
||||
|
||||
private int _DayRevenue;
|
||||
/// <summary>
|
||||
/// 储能 今日收益
|
||||
/// </summary>
|
||||
public int DayRevenue
|
||||
{
|
||||
get { return _DayRevenue; }
|
||||
set { _DayRevenue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private int _MonthRevenue;
|
||||
/// <summary>
|
||||
/// 储能 本月收益
|
||||
/// </summary>
|
||||
public int MonthRevenue
|
||||
{
|
||||
get { return _MonthRevenue; }
|
||||
set { _MonthRevenue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private int _TotalRevenue;
|
||||
/// <summary>
|
||||
/// 储能 累计收益
|
||||
/// </summary>
|
||||
public int TotalRevenue
|
||||
{
|
||||
get { return _TotalRevenue; }
|
||||
set { _TotalRevenue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ////////////////////////////////////储能充电量////////////////////////////////////////////
|
||||
/// </summary>
|
||||
|
||||
|
||||
private double _DayChargPw;
|
||||
/// <summary>
|
||||
/// 储能 日充电量 kWh
|
||||
/// </summary>
|
||||
public double DayChargPw
|
||||
{
|
||||
get { return _DayChargPw; }
|
||||
set { _DayChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _MonthChargPw;
|
||||
/// <summary>
|
||||
/// 储能 月充电量 kWh
|
||||
/// </summary>
|
||||
public double MonthChargPw
|
||||
{
|
||||
get { return _MonthChargPw; }
|
||||
set { _MonthChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _YearChargPw;
|
||||
/// <summary>
|
||||
/// 储能 年充电量 kWh
|
||||
/// </summary>
|
||||
public double YearChargPw
|
||||
{
|
||||
get { return _YearChargPw; }
|
||||
set { _YearChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _TotalChargPw;
|
||||
/// <summary>
|
||||
/// 储能 总充电量 kWh
|
||||
/// </summary>
|
||||
public double TotalChargPw
|
||||
{
|
||||
get { return _TotalChargPw; }
|
||||
set { _TotalChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ////////////////////////////////////储能放电量////////////////////////////////////////////
|
||||
/// </summary>
|
||||
|
||||
|
||||
private double _DayDisChargPw;
|
||||
/// <summary>
|
||||
/// 储能 日放电量 kWh
|
||||
/// </summary>
|
||||
public double DayDisChargPw
|
||||
{
|
||||
get { return _DayDisChargPw; }
|
||||
set { _DayDisChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _MonthDisChargPw;
|
||||
/// <summary>
|
||||
/// 储能 月放电量 kWh
|
||||
/// </summary>
|
||||
public double MonthDisChargPw
|
||||
{
|
||||
get { return _MonthDisChargPw; }
|
||||
set { _MonthDisChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _YearDisChargPw;
|
||||
/// <summary>
|
||||
/// 储能 年放电量 kWh
|
||||
/// </summary>
|
||||
public double YearDisChargPw
|
||||
{
|
||||
get { return _YearDisChargPw; }
|
||||
set { _YearDisChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _TotalDisChargPw;
|
||||
/// <summary>
|
||||
/// 储能 总放电量 kWh
|
||||
/// </summary>
|
||||
public double TotalDisChargPw
|
||||
{
|
||||
get { return _TotalDisChargPw; }
|
||||
set { _TotalDisChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
75
OrpaonEMS.App/Models/AnalysisModel/SolarAnalyse.cs
Normal file
75
OrpaonEMS.App/Models/AnalysisModel/SolarAnalyse.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 光伏 统计信息
|
||||
/// </summary>
|
||||
public class SolarAnalyse : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 一天的开始0时发电量数据
|
||||
/// </summary>
|
||||
public double DayStartPointPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 月份的开始0时发电量数据
|
||||
/// </summary>
|
||||
public double MonthStartPointPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 年的开始0时发电量数据
|
||||
/// </summary>
|
||||
public double YearStartPointPw { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
private double _DayChargPw;
|
||||
/// <summary>
|
||||
/// 光伏 光伏日发电量 kWh
|
||||
/// </summary>
|
||||
public double DayChargPw
|
||||
{
|
||||
get { return _DayChargPw; }
|
||||
set { _DayChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _MonthChargPw;
|
||||
/// <summary>
|
||||
/// 光伏 光伏月发电量 kWh
|
||||
/// </summary>
|
||||
public double MonthChargPw
|
||||
{
|
||||
get { return _MonthChargPw; }
|
||||
set { _MonthChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _YearChargPw;
|
||||
/// <summary>
|
||||
/// 光伏 光伏年发电量 kWh
|
||||
/// </summary>
|
||||
public double YearChargPw
|
||||
{
|
||||
get { return _YearChargPw; }
|
||||
set { _YearChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _TotalChargPw;
|
||||
/// <summary>
|
||||
/// 光伏 光伏总发电量 kWh
|
||||
/// </summary>
|
||||
public double TotalChargPw
|
||||
{
|
||||
get { return _TotalChargPw; }
|
||||
set { _TotalChargPw = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
103
OrpaonEMS.App/Models/BMSRoCell.cs
Normal file
103
OrpaonEMS.App/Models/BMSRoCell.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// BMS只读数据
|
||||
/// </summary>
|
||||
public class BMSRoCell : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public BMSRoCell(string name, int offset, double ratio, int index, int lengh, string address, bool focus, string unit)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Offset = offset;
|
||||
this.Ratio = ratio;
|
||||
this.Index = index;
|
||||
this.Unit = unit;
|
||||
this.Address = address;
|
||||
//this.ValueRangeInfo = valueRange;
|
||||
this.Lengh = lengh;
|
||||
this.Focus = focus;
|
||||
}
|
||||
|
||||
private uint _SrRtValue;
|
||||
/// <summary>
|
||||
/// 标签原始的实时值
|
||||
/// uint 因为有些数据是占用两个字
|
||||
/// </summary>
|
||||
public uint SrRtValue
|
||||
{
|
||||
get { return _SrRtValue; }
|
||||
set
|
||||
{
|
||||
_SrRtValue = value;
|
||||
RtValue = (value * Ratio) + Offset;
|
||||
//LastUpdateTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
private double _RtValue;
|
||||
/// <summary>
|
||||
/// 标签实时值
|
||||
/// </summary>
|
||||
public double RtValue
|
||||
{
|
||||
get { return _RtValue; }
|
||||
set { _RtValue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 偏移值
|
||||
/// </summary>
|
||||
public int Offset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分辨率
|
||||
/// </summary>
|
||||
public double Ratio { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Index 连续区域的位置
|
||||
/// </summary>
|
||||
public int Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值长度
|
||||
/// </summary>
|
||||
public int Lengh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址标签
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否关注这个数据,比如关注后,那么就在界面上展示,此时RaisePropertyChanged()就会被使能,单独在界面上展示否则就可以在表格里面展示
|
||||
/// </summary>
|
||||
public bool Focus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前数据的范围
|
||||
/// </summary>
|
||||
public ValueRange ValueRangeInfo { get; set; }
|
||||
}
|
||||
}
|
||||
103
OrpaonEMS.App/Models/BMSRoShortCell.cs
Normal file
103
OrpaonEMS.App/Models/BMSRoShortCell.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Bms只读 Short
|
||||
/// 有符号16位整数
|
||||
/// </summary>
|
||||
public class BMSRoShortCell : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public BMSRoShortCell(string name, int offset, double ratio, int index, int lengh, string address, bool focus, string unit)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Offset = offset;
|
||||
this.Ratio = ratio;
|
||||
this.Index = index;
|
||||
this.Unit = unit;
|
||||
this.Address = address;
|
||||
//this.ValueRangeInfo = valueRange;
|
||||
this.Lengh = lengh;
|
||||
this.Focus = focus;
|
||||
}
|
||||
|
||||
private short _SrRtValue;
|
||||
/// <summary>
|
||||
/// 标签原始的实时值
|
||||
/// </summary>
|
||||
public short SrRtValue
|
||||
{
|
||||
get { return _SrRtValue; }
|
||||
set
|
||||
{
|
||||
_SrRtValue = value;
|
||||
RtValue = (value * Ratio) + Offset;
|
||||
//LastUpdateTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
private double _RtValue;
|
||||
/// <summary>
|
||||
/// 标签实时值
|
||||
/// </summary>
|
||||
public double RtValue
|
||||
{
|
||||
get { return _RtValue; }
|
||||
set { _RtValue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 偏移值
|
||||
/// </summary>
|
||||
public int Offset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分辨率
|
||||
/// </summary>
|
||||
public double Ratio { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Index 连续区域的位置
|
||||
/// </summary>
|
||||
public int Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值长度
|
||||
/// </summary>
|
||||
public int Lengh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址标签
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否关注这个数据,比如关注后,那么就在界面上展示,此时RaisePropertyChanged()就会被使能,单独在界面上展示否则就可以在表格里面展示
|
||||
/// </summary>
|
||||
public bool Focus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前数据的范围
|
||||
/// </summary>
|
||||
public ValueRange ValueRangeInfo { get; set; }
|
||||
}
|
||||
}
|
||||
98
OrpaonEMS.App/Models/BMSRoUIntCell.cs
Normal file
98
OrpaonEMS.App/Models/BMSRoUIntCell.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
public class BMSRoUIntCell
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public BMSRoUIntCell(string name, int offset, double ratio, int index, int lengh, string address, bool focus, string unit)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Offset = offset;
|
||||
this.Ratio = ratio;
|
||||
this.Index = index;
|
||||
this.Unit = unit;
|
||||
this.Address = address;
|
||||
//this.ValueRangeInfo = valueRange;
|
||||
this.Lengh = lengh;
|
||||
this.Focus = focus;
|
||||
}
|
||||
|
||||
private uint _SrRtValue;
|
||||
/// <summary>
|
||||
/// 标签原始的实时值
|
||||
/// </summary>
|
||||
public uint SrRtValue
|
||||
{
|
||||
get { return _SrRtValue; }
|
||||
set
|
||||
{
|
||||
_SrRtValue = value;
|
||||
RtValue = (value * Ratio) + Offset;
|
||||
//LastUpdateTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
private double _RtValue;
|
||||
/// <summary>
|
||||
/// 标签实时值
|
||||
/// </summary>
|
||||
public double RtValue
|
||||
{
|
||||
get { return _RtValue; }
|
||||
set { _RtValue = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 偏移值
|
||||
/// </summary>
|
||||
public int Offset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分辨率
|
||||
/// </summary>
|
||||
public double Ratio { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Index 连续区域的位置
|
||||
/// </summary>
|
||||
public int Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值长度
|
||||
/// </summary>
|
||||
public int Lengh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址标签
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否关注这个数据,比如关注后,那么就在界面上展示,此时RaisePropertyChanged()就会被使能,单独在界面上展示否则就可以在表格里面展示
|
||||
/// </summary>
|
||||
public bool Focus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前数据的范围
|
||||
/// </summary>
|
||||
public ValueRange ValueRangeInfo { get; set; }
|
||||
}
|
||||
}
|
||||
102
OrpaonEMS.App/Models/BMSRoUShortCell.cs
Normal file
102
OrpaonEMS.App/Models/BMSRoUShortCell.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Bms只读 UShort
|
||||
/// </summary>
|
||||
public class BMSRoUShortCell:BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public BMSRoUShortCell(string name, int offset, double ratio, int index, int lengh, string address, bool focus, string unit)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Offset = offset;
|
||||
this.Ratio = ratio;
|
||||
this.Index = index;
|
||||
this.Unit = unit;
|
||||
this.Address = address;
|
||||
//this.ValueRangeInfo = valueRange;
|
||||
this.Lengh = lengh;
|
||||
this.Focus = focus;
|
||||
}
|
||||
|
||||
private ushort _SrRtValue;
|
||||
/// <summary>
|
||||
/// 标签原始的实时值
|
||||
/// </summary>
|
||||
public ushort SrRtValue
|
||||
{
|
||||
get { return _SrRtValue; }
|
||||
set
|
||||
{
|
||||
_SrRtValue = value;
|
||||
RtValue = (value * Ratio) + Offset;
|
||||
//LastUpdateTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
private double _RtValue;
|
||||
/// <summary>
|
||||
/// 标签实时值
|
||||
/// </summary>
|
||||
public double RtValue
|
||||
{
|
||||
get { return _RtValue; }
|
||||
set { _RtValue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 偏移值
|
||||
/// </summary>
|
||||
public int Offset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分辨率
|
||||
/// </summary>
|
||||
public double Ratio { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Index 连续区域的位置
|
||||
/// </summary>
|
||||
public int Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值长度
|
||||
/// </summary>
|
||||
public int Lengh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址标签
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否关注这个数据,比如关注后,那么就在界面上展示,此时RaisePropertyChanged()就会被使能,单独在界面上展示否则就可以在表格里面展示
|
||||
/// </summary>
|
||||
public bool Focus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前数据的范围
|
||||
/// </summary>
|
||||
public ValueRange ValueRangeInfo { get; set; }
|
||||
}
|
||||
}
|
||||
166
OrpaonEMS.App/Models/BmsAlarmModel.cs
Normal file
166
OrpaonEMS.App/Models/BmsAlarmModel.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
using ImTools;
|
||||
using OrpaonEMS.Core.EventHandMsg;
|
||||
using OrpaonEMS.Model.MasterSlave;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Bms报警模型
|
||||
/// </summary>
|
||||
public class BmsAlarmModel : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 声明委托对象-报警消失时BMS报警复位的触发事件
|
||||
/// </summary>
|
||||
public event EventHandler<string> BmsAlarmResetEventHandler;
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="alarmCells"></param>
|
||||
public BmsAlarmModel(List<AlarmCell> alarmCells)
|
||||
{
|
||||
ListBmsAlarm = alarmCells;
|
||||
//RtListViewItems = new ObservableCollection<RtAlarm>()
|
||||
//{
|
||||
// new RtAlarm() {Content="SDFA",Level=2,CreatTime=DateTime.Now},
|
||||
// new RtAlarm() {Content="DFGSDF",Level=2,CreatTime=DateTime.Now},
|
||||
// new RtAlarm() {Content="FGHSFD",Level=3,CreatTime=DateTime.Now},
|
||||
//};
|
||||
|
||||
//报警发布和统计
|
||||
foreach (var itemAlarm in ListBmsAlarm)
|
||||
{
|
||||
itemAlarm.PubBmsAlarmEventHandler += ItemAlarm_PubBmsAlarmEventHandler;
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<RtAlarm> _RtListViewItems = new ObservableCollection<RtAlarm>();
|
||||
/// <summary>
|
||||
/// 实时报警 数据集合
|
||||
/// </summary>
|
||||
public ObservableCollection<RtAlarm> RtListViewItems
|
||||
{
|
||||
get { return _RtListViewItems; }
|
||||
set { _RtListViewItems = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 报警发布方法
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void ItemAlarm_PubBmsAlarmEventHandler(object sender, BmsAlarmCellEventHandMsg data)
|
||||
{
|
||||
if (data.AlarmState)//报警开始
|
||||
{
|
||||
//报警开始
|
||||
AlarmCount++;//报警加1
|
||||
//当前没有的话,则新增
|
||||
CurAlarmContent = data.AlarmContent;
|
||||
|
||||
if (RtListViewItems.Where(a => a.Content == data.AlarmContent).Count() == 0)
|
||||
{
|
||||
RtListViewItems.Add(new RtAlarm()
|
||||
{
|
||||
Content = data.AlarmContent,
|
||||
Level = data.AlarmLevel,
|
||||
CreatTime = data.AlarmTime,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//报警消失
|
||||
AlarmCount--;//报警减1
|
||||
//找到之前的报警
|
||||
if (RtListViewItems.Where(a => a.Content == data.AlarmContent).Count() > 0)
|
||||
{
|
||||
//找到并删除
|
||||
var FindOne = RtListViewItems.FindFirst(a => a.Content == data.AlarmContent);
|
||||
RtListViewItems.Remove(FindOne);
|
||||
}
|
||||
|
||||
if (data.AlarmContent== CurAlarmContent)
|
||||
{
|
||||
CurAlarmContent = "";
|
||||
}
|
||||
|
||||
//报警消失
|
||||
if (AlarmCount==0)
|
||||
{
|
||||
//报警消失后复位一下
|
||||
BmsAlarmResetEventHandler(this,"No Alarm");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bms报警集合数据
|
||||
/// </summary>
|
||||
public List<AlarmCell> ListBmsAlarm { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前报警信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<string> GetCurAlarm()
|
||||
{
|
||||
if (AlarmCount > 0)
|
||||
{
|
||||
var ListInfo = new List<string>();
|
||||
var ListAlarm = ListBmsAlarm.Where(a => a.State == true).ToList();
|
||||
foreach (var itemAlarm in ListAlarm)
|
||||
{
|
||||
ListInfo.Add($"时间:{itemAlarm.CurTimeInfo.StartTime}-{itemAlarm.Content}");
|
||||
}
|
||||
return ListInfo;
|
||||
}
|
||||
return new List<string>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 报警个数
|
||||
/// </summary>
|
||||
public int AlarmCount { get; set; }
|
||||
|
||||
|
||||
private string _CurAlarmContent;
|
||||
/// <summary>
|
||||
/// 当前关注报警内容
|
||||
/// </summary>
|
||||
public string CurAlarmContent
|
||||
{
|
||||
get { return _CurAlarmContent; }
|
||||
set { _CurAlarmContent = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前报警等级
|
||||
/// </summary>
|
||||
public int CurAlarmLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前报警激活时间
|
||||
/// </summary>
|
||||
public DateTime CurAlarmActiveTime { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 显示报警数据
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public int TopAlarmCount()
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
31
OrpaonEMS.App/Models/BmsRtAlarmModel.cs
Normal file
31
OrpaonEMS.App/Models/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.App.Models
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
156
OrpaonEMS.App/Models/BmsRwCell.cs
Normal file
156
OrpaonEMS.App/Models/BmsRwCell.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using OrpaonEMS.Core.Enums;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 读写信号
|
||||
/// BMS的保持寄存器(功能码:读 0x03,写 0x06、0x10)
|
||||
/// 一些阀值的设置及参数配置
|
||||
/// </summary>
|
||||
public class BmsRwCell : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public BmsRwCell(string name, int offset, double ratio, int index, int lengh, string address, bool focus, string unit, ValueRange valueRange, string WR)
|
||||
{
|
||||
this.Name = name;
|
||||
this.Offset = offset;
|
||||
this.Ratio = ratio;
|
||||
this.Index = index;
|
||||
this.Unit = unit;
|
||||
this.Address = address;
|
||||
//this.ValueRangeInfo = valueRange;
|
||||
this.Lengh = lengh;
|
||||
this.Focus = focus;
|
||||
ValueRangeInfo = valueRange;
|
||||
switch (WR)
|
||||
{
|
||||
case "读/写":
|
||||
IOTypeInfo = IOType.RW;
|
||||
break;
|
||||
case "读":
|
||||
IOTypeInfo = IOType.R;
|
||||
break;
|
||||
case "写":
|
||||
IOTypeInfo = IOType.W;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private short _SrRtValue;
|
||||
/// <summary>
|
||||
/// 标签原始的实时值
|
||||
/// </summary>
|
||||
public short SrRtValue
|
||||
{
|
||||
get { return _SrRtValue; }
|
||||
set
|
||||
{
|
||||
_SrRtValue = value;
|
||||
RtValue = (value * Ratio) + Offset;
|
||||
//LastUpdateTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
private double _RtValue;
|
||||
/// <summary>
|
||||
/// 标签实时值
|
||||
/// 工程含义值
|
||||
/// </summary>
|
||||
public double RtValue
|
||||
{
|
||||
get { return _RtValue; }
|
||||
set { _RtValue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入的值
|
||||
/// </summary>
|
||||
public double WriteValue { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 写入设备的值
|
||||
///// </summary>
|
||||
//public ushort WriteDeviceValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取写入设备的值
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ushort GetWriteDeviceValue()
|
||||
{
|
||||
//RtValue = (value * Ratio) + Offset;
|
||||
|
||||
if (Ratio != 0)
|
||||
{
|
||||
return (ushort)((RtValue - Offset) / Ratio);
|
||||
}
|
||||
|
||||
//如果数据有问题的话,则返回之前的值
|
||||
return (ushort)SrRtValue;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 偏移值
|
||||
/// </summary>
|
||||
public int Offset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分辨率
|
||||
/// </summary>
|
||||
public double Ratio { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Index 连续区域的位置
|
||||
/// </summary>
|
||||
public int Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值长度
|
||||
/// </summary>
|
||||
public int Lengh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址标签
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否关注这个数据,比如关注后,那么就在界面上展示,此时RaisePropertyChanged()就会被使能,单独在界面上展示否则就可以在表格里面展示
|
||||
/// </summary>
|
||||
public bool Focus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前数据的范围
|
||||
/// </summary>
|
||||
public ValueRange ValueRangeInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 读写类型
|
||||
/// </summary>
|
||||
public IOType IOTypeInfo { get; set; }
|
||||
}
|
||||
}
|
||||
21
OrpaonEMS.App/Models/CoolAlarm.cs
Normal file
21
OrpaonEMS.App/Models/CoolAlarm.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
public class CoolAlarm
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警内容
|
||||
/// </summary>
|
||||
public string? Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警时间
|
||||
/// </summary>
|
||||
public DateTime AlarmTime { get; set; }
|
||||
}
|
||||
}
|
||||
77
OrpaonEMS.App/Models/CoolBitAlarmInfo.cs
Normal file
77
OrpaonEMS.App/Models/CoolBitAlarmInfo.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using OrpaonEMS.App.Event;
|
||||
using OrpaonEMS.Core.EventHandMsg;
|
||||
using OrpaonEMS.Core.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态字的位报警内容
|
||||
/// </summary>
|
||||
public class CoolBitAlarmInfo
|
||||
{
|
||||
public CoolBitAlarmInfo()
|
||||
{
|
||||
CurTimeInfo=new AlarmTimeInfo();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发布报警信息
|
||||
/// </summary>
|
||||
public event EventHandler<CoolAlarmCellEventHandMsg> PubCoolAlarmEventHandler;
|
||||
|
||||
private bool _State;
|
||||
/// <summary>
|
||||
/// 报警状态
|
||||
/// </summary>
|
||||
public bool State
|
||||
{
|
||||
get { return _State; }
|
||||
set
|
||||
{
|
||||
if (_State != value && value == true)//报警发生
|
||||
{
|
||||
_State = value;
|
||||
|
||||
CurTimeInfo.StartTime = DateTime.Now;
|
||||
|
||||
//发布报警
|
||||
PubCoolAlarmEventHandler(this, new CoolAlarmCellEventHandMsg() { State = true, Content = Content, Category = Category, CurTimeInfo = CurTimeInfo });
|
||||
|
||||
}
|
||||
else if (_State != value && value == false)//报警消失
|
||||
{
|
||||
_State = value;
|
||||
CurTimeInfo.EndTime = DateTime.Now;
|
||||
//发布报警
|
||||
PubCoolAlarmEventHandler(this, new CoolAlarmCellEventHandMsg() { State = false, Content = Content, Category = Category, CurTimeInfo = CurTimeInfo });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 报警时间信息
|
||||
/// </summary>
|
||||
public AlarmTimeInfo CurTimeInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类别
|
||||
/// </summary>
|
||||
public ushort Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Bit位置
|
||||
/// </summary>
|
||||
public ushort BitIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报警内容
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
}
|
||||
}
|
||||
126
OrpaonEMS.App/Models/DataCell.cs
Normal file
126
OrpaonEMS.App/Models/DataCell.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using OrpaonEMS.Core.Enums;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 布尔类型数据单元
|
||||
/// </summary>
|
||||
public class DataCell : BindableBase
|
||||
{
|
||||
|
||||
private short _SrRtValue;
|
||||
/// <summary>
|
||||
/// 标签原始的实时值
|
||||
/// </summary>
|
||||
public short SrRtValue
|
||||
{
|
||||
set
|
||||
{
|
||||
if (_SrRtValue != value)
|
||||
{
|
||||
_SrRtValue = value;
|
||||
RtValue = (value + Offset);
|
||||
}
|
||||
|
||||
//LastUpdateTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private double _RtValue;
|
||||
/// <summary>
|
||||
/// 标签实时值
|
||||
/// </summary>
|
||||
public double RtValue
|
||||
{
|
||||
get { return _RtValue; }
|
||||
set
|
||||
{
|
||||
_RtValue = value;
|
||||
if (IsUI)
|
||||
{
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
//if (PopValue != null)
|
||||
//{
|
||||
// PopValue(Name, value);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 偏移值
|
||||
/// </summary>
|
||||
public int Offset { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分辨率
|
||||
/// </summary>
|
||||
public double Ratio { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 读写类型
|
||||
/// </summary>
|
||||
public IOType IoTypeInfo { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Index 连续区域的位置
|
||||
/// </summary>
|
||||
public int Index { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Index 连续区域的位置基础基数
|
||||
/// </summary>
|
||||
public int Base { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值长度
|
||||
/// </summary>
|
||||
public int Lengh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址标签
|
||||
/// </summary>
|
||||
public string? Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标签名称
|
||||
/// </summary>
|
||||
public string? Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string? Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否关注这个数据,比如关注后,那么就在界面上展示,此时RaisePropertyChanged()就会被使能,单独在界面上展示否则就可以在表格里面展示
|
||||
/// </summary>
|
||||
public bool IsUI { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当前数据的范围
|
||||
/// </summary>
|
||||
public ValueRange? ValueRangeInfo { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// Tag状态
|
||||
///// </summary>
|
||||
//public bool TagLinkState { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 上次更新时间信息
|
||||
///// </summary>
|
||||
//public DateTime LastUpdateTime { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
53
OrpaonEMS.App/Models/DoughnutModel.cs
Normal file
53
OrpaonEMS.App/Models/DoughnutModel.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Doughnut图形的模型数据
|
||||
/// </summary>
|
||||
public class DoughnutModel : BindableBase
|
||||
{
|
||||
///// <summary>
|
||||
///// 绑定XBindingPath
|
||||
///// </summary>
|
||||
//public string Title { get; set; }
|
||||
|
||||
private string _Title;
|
||||
/// <summary>
|
||||
/// 绑定XBindingPath
|
||||
/// </summary>
|
||||
public string Title
|
||||
{
|
||||
get { return _Title; }
|
||||
set { _Title = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private double _Value;
|
||||
/// <summary>
|
||||
/// 绑定YBindingPath
|
||||
/// </summary>
|
||||
public double Value
|
||||
{
|
||||
get { return _Value; }
|
||||
set { _Value = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 绑定YBindingPath
|
||||
///// </summary>
|
||||
//public double Value { get; set; }
|
||||
|
||||
public string States { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图形
|
||||
/// </summary>
|
||||
public Uri Image { get; set; }
|
||||
}
|
||||
}
|
||||
83
OrpaonEMS.App/Models/EleMeter.cs
Normal file
83
OrpaonEMS.App/Models/EleMeter.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 电表
|
||||
/// </summary>
|
||||
public class EleMeter : BindableBase
|
||||
{
|
||||
public EleMeter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private double _RtPw;
|
||||
/// <summary>
|
||||
/// 实时功率
|
||||
/// </summary>
|
||||
public double RtPw
|
||||
{
|
||||
get { return _RtPw; }
|
||||
set
|
||||
{
|
||||
ListAve.Add(value);
|
||||
if (ListAve.Count()>20)
|
||||
{
|
||||
ListAve.RemoveAt(0);
|
||||
}
|
||||
AvePw= ListAve.Average();
|
||||
_RtPw = value;
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 平均值
|
||||
/// </summary>
|
||||
public double AvePw { get; set; }
|
||||
|
||||
private bool _MeterLinkState;
|
||||
/// <summary>
|
||||
/// 连接状态
|
||||
/// </summary>
|
||||
public bool MeterLinkState
|
||||
{
|
||||
get { return _MeterLinkState; }
|
||||
set { _MeterLinkState = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _EleQ_P;
|
||||
/// <summary>
|
||||
/// 正向有功电能
|
||||
/// </summary>
|
||||
public double EleQ_P
|
||||
{
|
||||
get { return _EleQ_P; }
|
||||
set { _EleQ_P = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _EleQ_N;
|
||||
/// <summary>
|
||||
/// 反向有功电能
|
||||
/// </summary>
|
||||
public double EleQ_N
|
||||
{
|
||||
get { return _EleQ_N; }
|
||||
set { _EleQ_N = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据集合
|
||||
/// </summary>
|
||||
private List<double> ListAve { get; set; } = new List<double>()
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
32
OrpaonEMS.App/Models/EleMeterActionValue.cs
Normal file
32
OrpaonEMS.App/Models/EleMeterActionValue.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
public class EleMeterActionValue
|
||||
{
|
||||
/// <summary>
|
||||
/// 上限值
|
||||
/// </summary>
|
||||
public double UpValue { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 中间值
|
||||
///// </summary>
|
||||
//public double MidValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下限值
|
||||
/// </summary>
|
||||
public double DownValue { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 目标值
|
||||
/// </summary>
|
||||
public double TargetValue { get; set; }
|
||||
}
|
||||
}
|
||||
108
OrpaonEMS.App/Models/EnergyStorageRunConfig.cs
Normal file
108
OrpaonEMS.App/Models/EnergyStorageRunConfig.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 储能的运行配置值
|
||||
/// </summary>
|
||||
public class EnergyStorageRunConfig : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public EnergyStorageRunConfig()
|
||||
{
|
||||
PcsChargOffset = 0;//3
|
||||
PcsDisChargOffset = 0;//3
|
||||
MaxBatChargRatio = 0.8;//
|
||||
MaxBatDisChargRatio = 0.9;//
|
||||
BMSSocUpSignLimitValue = 90;//
|
||||
BMSSocDownSignLimitValue = 5;
|
||||
|
||||
}
|
||||
|
||||
private int myVar;
|
||||
|
||||
public int MyProperty
|
||||
{
|
||||
get { return myVar; }
|
||||
set { myVar = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private double _PcsChargOffset;
|
||||
/// <summary>
|
||||
/// PCS充电功率补偿值 Kw
|
||||
/// </summary>
|
||||
public double PcsChargOffset
|
||||
{
|
||||
get { return _PcsChargOffset; }
|
||||
set { _PcsChargOffset = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _PcsDisChargOffset;
|
||||
/// <summary>
|
||||
/// PCS放电功率补偿值 Kw
|
||||
/// </summary>
|
||||
public double PcsDisChargOffset
|
||||
{
|
||||
get { return _PcsDisChargOffset; }
|
||||
set { _PcsDisChargOffset = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private double _MaxBatChargRatio;
|
||||
/// <summary>
|
||||
/// BMS以最大的功率充电的比值
|
||||
/// 设置一个安全的比值,0.95 0.9等这个的比值,防止充电电流太大导致问题
|
||||
/// </summary>
|
||||
public double MaxBatChargRatio
|
||||
{
|
||||
get { return _MaxBatChargRatio; }
|
||||
set { _MaxBatChargRatio = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private double _MaxBatDisChargRatio;
|
||||
/// <summary>
|
||||
/// BMS以最大的功率放电的比值
|
||||
/// 设置一个安全的比值,0.95 0.9等这个的比值,防止充电电流太大导致问题
|
||||
/// </summary>
|
||||
public double MaxBatDisChargRatio
|
||||
{
|
||||
get { return _MaxBatDisChargRatio; }
|
||||
set { _MaxBatDisChargRatio = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private double _BMSSocUpSignLimitValue;
|
||||
/// <summary>
|
||||
/// BMS满的标志
|
||||
/// BMS自己有满充报警的机制
|
||||
/// 这里有个保护的阀值,不需要充到报警才
|
||||
/// </summary>
|
||||
public double BMSSocUpSignLimitValue
|
||||
{
|
||||
get { return _BMSSocUpSignLimitValue; }
|
||||
set { _BMSSocUpSignLimitValue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private double _BMSSocDownSignLimitValue;
|
||||
/// <summary>
|
||||
/// BMS空的标志
|
||||
/// BMS自己有满充报警的机制
|
||||
/// 这里有个保护的阀值,不需要充到报警才
|
||||
/// </summary>
|
||||
public double BMSSocDownSignLimitValue
|
||||
{
|
||||
get { return _BMSSocDownSignLimitValue; }
|
||||
set { _BMSSocDownSignLimitValue = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
14
OrpaonEMS.App/Models/HourPwData.cs
Normal file
14
OrpaonEMS.App/Models/HourPwData.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
public class HourPwData
|
||||
{
|
||||
public double[] Xs { get; set; } = new double[0];
|
||||
public double[] Ys { get; set; } = new double[0];
|
||||
}
|
||||
}
|
||||
65
OrpaonEMS.App/Models/NavigationItem.cs
Normal file
65
OrpaonEMS.App/Models/NavigationItem.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单功能模型
|
||||
/// </summary>
|
||||
public class NavigationItem : BindableBase
|
||||
{
|
||||
public NavigationItem(
|
||||
string icon,
|
||||
string name,
|
||||
string pageName,
|
||||
ObservableCollection<NavigationItem> items = null)
|
||||
{
|
||||
Icon = icon;
|
||||
Name = name;
|
||||
PageName = pageName;
|
||||
Items = items;
|
||||
}
|
||||
|
||||
private string name;
|
||||
private string icon;
|
||||
private ObservableCollection<NavigationItem> items;
|
||||
|
||||
/// <summary>
|
||||
/// 图标
|
||||
/// </summary>
|
||||
public string Icon
|
||||
{
|
||||
get { return icon; }
|
||||
set { icon = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单名称
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单导航的页面
|
||||
/// </summary>
|
||||
public string PageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 导航菜单列表
|
||||
/// 菜单子项
|
||||
/// </summary>
|
||||
public ObservableCollection<NavigationItem> Items
|
||||
{
|
||||
get { return items; }
|
||||
set { items = value; RaisePropertyChanged(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
169
OrpaonEMS.App/Models/NightChargEleModel.cs
Normal file
169
OrpaonEMS.App/Models/NightChargEleModel.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using OrpaonEMS.App.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 判断是不是夜晚充的电量
|
||||
/// 判断模型
|
||||
/// </summary>
|
||||
public class NightChargEleModel
|
||||
{
|
||||
public NightChargEleModel(ConfigDataService configDataService)
|
||||
{
|
||||
MasterCheck = DischargInfo.NoComplete;
|
||||
SlaveCheck = DischargInfo.NoComplete;
|
||||
ConfigDataService = configDataService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否开始校验
|
||||
/// </summary>
|
||||
public bool IsStartCheck { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 夜间充的电 主储能箱是否放完
|
||||
/// </summary>
|
||||
public DischargInfo MasterCheck { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 夜间充的电 从储能箱是否放完
|
||||
/// </summary>
|
||||
public DischargInfo SlaveCheck { get; set; }
|
||||
|
||||
|
||||
private double _MasterSoc;
|
||||
/// <summary>
|
||||
/// 主储能柜的SOC
|
||||
/// 在新的一天中,根据SOC达到阈值决定是否夜间的电放完
|
||||
/// </summary>
|
||||
public double MasterSoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return _MasterSoc;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (IsStartCheck)
|
||||
{
|
||||
if (_MasterSoc != value && value <= ConfigDataService.energyStorageRunConfig.BMSSocDownSignLimitValue)
|
||||
{
|
||||
MasterCheck = DischargInfo.DischargComplete;
|
||||
_MasterSoc = value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_MasterSoc = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private double _SlaveSoc;
|
||||
/// <summary>
|
||||
/// 从储能柜的SOC
|
||||
/// 在新的一天中,根据SOC达到阈值决定是否夜间的电放完
|
||||
/// </summary>
|
||||
public double SlaveSoc
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SlaveSoc;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (IsStartCheck)
|
||||
{
|
||||
if (_SlaveSoc != value && value <= ConfigDataService.energyStorageRunConfig.BMSSocDownSignLimitValue)
|
||||
{
|
||||
SlaveCheck = DischargInfo.DischargComplete;
|
||||
_SlaveSoc = value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_SlaveSoc = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置数据
|
||||
/// </summary>
|
||||
public ConfigDataService ConfigDataService { get; }
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 获取状态
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public bool GetCheckState()
|
||||
//{
|
||||
// return MasterCheck && SlaveCheck;
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置一天的初始状态
|
||||
/// </summary>
|
||||
public void SetDayInitState(double Mastersoc, double Slavesoc)
|
||||
{
|
||||
//比如从夜间切换到白天,算是一天的开始,判断此时的SOC是否被充满,如果是充满的话,则是属于夜间低谷的电量,需要标记
|
||||
|
||||
IsStartCheck = true;
|
||||
|
||||
if (Mastersoc >= ConfigDataService.energyStorageRunConfig.BMSSocUpSignLimitValue * 0.8)
|
||||
{
|
||||
MasterCheck = DischargInfo.NoComplete;
|
||||
}
|
||||
else
|
||||
{
|
||||
MasterCheck = DischargInfo.DischargComplete;
|
||||
}
|
||||
|
||||
//理论是从储能充电60%
|
||||
if (Slavesoc >= 50)
|
||||
{
|
||||
SlaveCheck = DischargInfo.NoComplete;
|
||||
}
|
||||
else
|
||||
{
|
||||
SlaveCheck = DischargInfo.DischargComplete;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置白天结束的状态
|
||||
/// </summary>
|
||||
public void SetDayEndState()
|
||||
{
|
||||
IsStartCheck = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 放电信息
|
||||
/// </summary>
|
||||
public enum DischargInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 放电放完了
|
||||
/// </summary>
|
||||
DischargComplete = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 没有完成
|
||||
/// </summary>
|
||||
NoComplete = 2
|
||||
}
|
||||
}
|
||||
464
OrpaonEMS.App/Models/PCSStateModel.cs
Normal file
464
OrpaonEMS.App/Models/PCSStateModel.cs
Normal file
@@ -0,0 +1,464 @@
|
||||
using HslCommunication.ModBus;
|
||||
using OrpaonEMS.App.Services;
|
||||
using OrpaonEMS.Core.Enums;
|
||||
using Prism.Mvvm;
|
||||
using Stateless;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// PCS状态模型
|
||||
/// </summary>
|
||||
public class PCSStateModel : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
/// <param name="modbusTcpNetDrive"></param>
|
||||
public PCSStateModel(InPowerPCSDataService inPowerPCSDataService)
|
||||
{
|
||||
PCSStateMachineInitalConfig();
|
||||
InPowerPCSDataService = inPowerPCSDataService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PCS的状态信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public PCSState PcsStateInfo { get; set; }
|
||||
|
||||
private string _PcsStateMsg;
|
||||
/// <summary>
|
||||
/// PCS的状态信息
|
||||
/// 状态文本
|
||||
/// </summary>
|
||||
public string PcsStateMsg
|
||||
{
|
||||
get { return _PcsStateMsg; }
|
||||
set { _PcsStateMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PCS运行状态机
|
||||
/// </summary>
|
||||
public StateMachine<PCSState, PCSStateTrigger> PcsStateMachine { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 上位机连接PCS状态机
|
||||
/// </summary>
|
||||
public StateMachine<LinkState, LinkStateTrig> CurIPCLinkStateMachine { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// PCS链接状态
|
||||
/// </summary>
|
||||
public LinkState PcsLinkState { get; set; }
|
||||
|
||||
private string _LinkStateMsg;
|
||||
/// <summary>
|
||||
/// PCS连接PC的状态信息文本
|
||||
/// </summary>
|
||||
public string LinkStateMsg
|
||||
{
|
||||
get { return _LinkStateMsg; }
|
||||
set { _LinkStateMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PCS的初始配置
|
||||
/// </summary>
|
||||
public void PCSStateMachineInitalConfig()
|
||||
{
|
||||
//PCS运行状态
|
||||
PcsStateMachine = new StateMachine<PCSState, PCSStateTrigger>(PCSState.Inital);
|
||||
//初始化->
|
||||
PcsStateMachine.Configure(PCSState.Inital)
|
||||
.Permit(PCSStateTrigger.RunTrig, PCSState.Run)
|
||||
.Permit(PCSStateTrigger.StandbyTrig, PCSState.Standby)
|
||||
.Permit(PCSStateTrigger.StopTrig, PCSState.Stop)
|
||||
.OnEntry(() => PCSInital());
|
||||
|
||||
PcsStateMachine.Configure(PCSState.Run)
|
||||
.Permit(PCSStateTrigger.StandbyTrig, PCSState.Standby)
|
||||
.Permit(PCSStateTrigger.StopTrig, PCSState.Stop)
|
||||
.Ignore(PCSStateTrigger.RunTrig)
|
||||
.OnEntry(() => PCSStartAsync());
|
||||
|
||||
PcsStateMachine.Configure(PCSState.Stop)
|
||||
.Permit(PCSStateTrigger.RunTrig, PCSState.Run)
|
||||
.Permit(PCSStateTrigger.StandbyTrig, PCSState.Standby)
|
||||
.Ignore(PCSStateTrigger.StopTrig)
|
||||
.OnEntry(() => PCSStopAsync());
|
||||
|
||||
PcsStateMachine.Configure(PCSState.Standby)
|
||||
.Permit(PCSStateTrigger.RunTrig, PCSState.Run)
|
||||
.Permit(PCSStateTrigger.StopTrig, PCSState.Stop)
|
||||
.Ignore(PCSStateTrigger.StandbyTrig)
|
||||
.OnEntry(() => PCSStandbyAsync());
|
||||
|
||||
|
||||
//PCS 上位机连接状态
|
||||
CurIPCLinkStateMachine = new StateMachine<LinkState, LinkStateTrig>(LinkState.Initial);
|
||||
CurIPCLinkStateMachine.Configure(LinkState.Initial)
|
||||
.Permit(LinkStateTrig.LinkOKTrig, LinkState.LinkOK)
|
||||
.Permit(LinkStateTrig.LinkNGTrig, LinkState.LinkNG);
|
||||
CurIPCLinkStateMachine.Configure(LinkState.LinkNG)
|
||||
.Permit(LinkStateTrig.LinkOKTrig, LinkState.LinkOK)
|
||||
.Ignore(LinkStateTrig.LinkNGTrig)
|
||||
.OnEntry(() => IPCLinkNG());
|
||||
CurIPCLinkStateMachine.Configure(LinkState.LinkOK)
|
||||
.Permit(LinkStateTrig.LinkNGTrig, LinkState.LinkNG)
|
||||
.Ignore(LinkStateTrig.LinkOKTrig)
|
||||
.OnEntry(() => IPCLinkOK());
|
||||
}
|
||||
|
||||
#region PCS运行状态
|
||||
|
||||
/// <summary>
|
||||
/// PCS 初始化
|
||||
/// </summary>
|
||||
private void PCSInital()
|
||||
{
|
||||
PcsStateInfo = PCSState.Inital;
|
||||
PcsStateMsg = "初始化";
|
||||
Console.WriteLine($"时间:{DateTime.Now.ToString()}:PCS进入【初始】模式 ");
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PCS 进入停机
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private void PCSStandbyAsync()
|
||||
{
|
||||
PcsStateInfo = PCSState.Standby;
|
||||
PcsStateMsg = "待机";
|
||||
Console.WriteLine($"时间:{DateTime.Now.ToString()}:PCS进入【待机】模式 ");
|
||||
//return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PCS 进入停止
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private void PCSStopAsync()
|
||||
{
|
||||
PcsStateInfo = PCSState.Stop;
|
||||
PcsStateMsg = "停止";
|
||||
Console.WriteLine($"时间:{DateTime.Now.ToString()}:PCS进入【停止】模式 ");
|
||||
//return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PCS 进入运行
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void PCSStartAsync()
|
||||
{
|
||||
PcsStateInfo = PCSState.Run;
|
||||
PcsStateMsg = "运行";
|
||||
Console.WriteLine($"时间:{DateTime.Now.ToString()}:PCS进入【运行】模式 ");
|
||||
//return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private bool[] _PCSStateValue = new bool[3];
|
||||
/// <summary>
|
||||
/// PCS运行状态字数据
|
||||
///需要转换数据
|
||||
/// </summary>
|
||||
public bool[] PCSStateValue
|
||||
{
|
||||
get { return _PCSStateValue; }
|
||||
set
|
||||
{
|
||||
if (!value.SequenceEqual(_PCSStateValue))
|
||||
{
|
||||
if (value[0])
|
||||
{
|
||||
PcsStateMachine.FireAsync(PCSStateTrigger.StopTrig);
|
||||
}
|
||||
else if (value[1])
|
||||
{
|
||||
PcsStateMachine.FireAsync(PCSStateTrigger.StandbyTrig);
|
||||
}
|
||||
else if (value[2])
|
||||
{
|
||||
PcsStateMachine.FireAsync(PCSStateTrigger.RunTrig);
|
||||
}
|
||||
else
|
||||
{
|
||||
PcsStateMachine.FireAsync(PCSStateTrigger.StopTrig);
|
||||
}
|
||||
_PCSStateValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PCS总故障状态
|
||||
/// </summary>
|
||||
public PcsFaultState PcsSysFaultState { get; set; }
|
||||
|
||||
|
||||
private string _PcsSysFaultStateMsg;
|
||||
/// <summary>
|
||||
/// PC总S故障状态文本
|
||||
/// </summary>
|
||||
public string PcsSysFaultStateMsg
|
||||
{
|
||||
get { return _PcsSysFaultStateMsg; }
|
||||
set { _PcsSysFaultStateMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
private bool _PcsSysFaultStateVaue;
|
||||
/// <summary>
|
||||
/// 总故障状态字
|
||||
/// </summary>
|
||||
public bool PcsSysFaultStateVaue
|
||||
{
|
||||
get { return _PcsSysFaultStateVaue; }
|
||||
set
|
||||
{
|
||||
if (value != _PcsSysFaultStateVaue)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
PcsSysFaultState = PcsFaultState.Fault;
|
||||
PcsSysFaultStateMsg = "故障中";
|
||||
//产生报警
|
||||
Console.WriteLine($"datetime:{DateTime.Now.ToString()} PCS 故障产生");
|
||||
}
|
||||
else
|
||||
{
|
||||
PcsSysFaultState = PcsFaultState.Normal;
|
||||
PcsSysFaultStateMsg = "正常";
|
||||
//故障消失后,故障复位一下
|
||||
InPowerPCSDataService.PCSFaultReset();
|
||||
//报警消失
|
||||
Console.WriteLine($"datetime:{DateTime.Now.ToString()} PCS 故障消失");
|
||||
}
|
||||
_PcsSysFaultStateVaue = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PCS报警状态
|
||||
/// </summary>
|
||||
public PcsAlarmState PcsSysAlarmState { get; set; }
|
||||
|
||||
|
||||
private string _PcsSysAlarmStateMsg = "";
|
||||
/// <summary>
|
||||
/// PCS报警状态文本
|
||||
/// </summary>
|
||||
public string PcsSysAlarmStateMsg
|
||||
{
|
||||
get { return _PcsSysAlarmStateMsg; }
|
||||
set { _PcsSysAlarmStateMsg = value; }
|
||||
}
|
||||
|
||||
|
||||
private bool _PcsSysAlarmVaue;
|
||||
/// <summary>
|
||||
/// PCS报警状态字
|
||||
/// </summary>
|
||||
public bool PcsSysAlarmVaue
|
||||
{
|
||||
get { return _PcsSysAlarmVaue; }
|
||||
set
|
||||
{
|
||||
if (value != _PcsSysAlarmVaue)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
PcsSysAlarmState = PcsAlarmState.Alarm;
|
||||
PcsSysAlarmStateMsg = "报警中";
|
||||
//产生报警
|
||||
Console.WriteLine($"datetime:{DateTime.Now.ToString()} PCS 报警产生");
|
||||
}
|
||||
else
|
||||
{
|
||||
PcsSysAlarmState = PcsAlarmState.Normal;
|
||||
PcsSysAlarmStateMsg = "正常";
|
||||
//报警消失后,报警复位一下
|
||||
InPowerPCSDataService.PCSFaultReset();
|
||||
//报警消失
|
||||
Console.WriteLine($"datetime:{DateTime.Now.ToString()} PCS 报警消失");
|
||||
}
|
||||
_PcsSysAlarmVaue = value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PCS并离网状态
|
||||
/// </summary>
|
||||
public PCSOffLineInfo PcsOffLineState;
|
||||
|
||||
private string _PcsOffLineStateMsg;
|
||||
/// <summary>
|
||||
/// PCS并离网状态消息
|
||||
/// </summary>
|
||||
public string PcsOffLineStateMsg
|
||||
{
|
||||
get { return _PcsOffLineStateMsg; }
|
||||
set { _PcsOffLineStateMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private bool _PcsOffLineStateValue;
|
||||
/// <summary>
|
||||
/// PCS并离网故障状态值
|
||||
/// </summary>
|
||||
public bool PcsOffLineStateValue
|
||||
{
|
||||
get { return _PcsOffLineStateValue; }
|
||||
set
|
||||
{
|
||||
if (value != _PcsOffLineStateValue)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
PcsOffLineState = PCSOffLineInfo.OffLine;
|
||||
PcsOffLineStateMsg = "并网";
|
||||
//产生报警
|
||||
Console.WriteLine($"时间:{DateTime.Now.ToString()} PCS 并网状态");
|
||||
}
|
||||
else
|
||||
{
|
||||
PcsOffLineState = PCSOffLineInfo.OnLine;
|
||||
PcsOffLineStateMsg = "离网";
|
||||
//报警消失
|
||||
Console.WriteLine($"时间:{DateTime.Now.ToString()} PCS 离网状态");
|
||||
}
|
||||
_PcsOffLineStateValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PCS远程本地状态cs
|
||||
/// </summary>
|
||||
public PcsRemoteLocation PcsRemoteLocationState;
|
||||
|
||||
|
||||
private string _PcsRemoteLocationStateMsg;
|
||||
/// <summary>
|
||||
/// PCS远程本地状态消息
|
||||
/// </summary>
|
||||
public string PcsRemoteLocationStateMsg
|
||||
{
|
||||
get { return _PcsRemoteLocationStateMsg; }
|
||||
set { _PcsRemoteLocationStateMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private bool _PcsRemoteLocationStateValue;
|
||||
/// <summary>
|
||||
/// PCS远程本地状态值
|
||||
/// </summary>
|
||||
public bool PcsRemoteLocationStateValue
|
||||
{
|
||||
get { return _PcsRemoteLocationStateValue; }
|
||||
set
|
||||
{
|
||||
//if (value != _PCSRemoteLocationValue)
|
||||
//{
|
||||
if (value)
|
||||
{
|
||||
PcsRemoteLocationState = PcsRemoteLocation.Remote;
|
||||
PcsRemoteLocationStateMsg = "远程";
|
||||
//产生报警
|
||||
//Console.WriteLine($"datetime:{DateTime.Now.ToString()} PCS 远程");
|
||||
}
|
||||
else
|
||||
{
|
||||
PcsRemoteLocationState = PcsRemoteLocation.Location;
|
||||
PcsRemoteLocationStateMsg = "本地";
|
||||
//报警消失
|
||||
//Console.WriteLine($"datetime:{DateTime.Now.ToString()} PCS 本地");
|
||||
}
|
||||
_PcsRemoteLocationStateValue = value;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 上位机连接状态
|
||||
|
||||
private ushort _LinkBitValue=3;
|
||||
/// <summary>
|
||||
/// PCS上位机连接的结果值
|
||||
/// </summary>
|
||||
public ushort LinkBitValue
|
||||
{
|
||||
get { return _LinkBitValue; }
|
||||
set
|
||||
{
|
||||
if (value != _LinkBitValue)//连接状态值改变
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case 1:
|
||||
if (CurIPCLinkStateMachine.State!=LinkState.LinkOK)
|
||||
{
|
||||
CurIPCLinkStateMachine.Fire(LinkStateTrig.LinkOKTrig);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (CurIPCLinkStateMachine.State != LinkState.LinkNG)
|
||||
{
|
||||
CurIPCLinkStateMachine.Fire(LinkStateTrig.LinkNGTrig);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
_LinkBitValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InPowerPCSDataService InPowerPCSDataService { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// IPC连接NG的执行方法
|
||||
/// </summary>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void IPCLinkNG()
|
||||
{
|
||||
LinkStateMsg = "失败";
|
||||
PcsLinkState = LinkState.LinkNG;
|
||||
Console.WriteLine($"DateTime:{DateTime.Now.ToString()}-【PCS状态模块】-【PCS上位机连接失败】");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IPC连接成功的执行方法
|
||||
/// </summary>
|
||||
private void IPCLinkOK()
|
||||
{
|
||||
LinkStateMsg = "正常";
|
||||
PcsLinkState = LinkState.LinkOK;
|
||||
Console.WriteLine($"DateTime:{DateTime.Now.ToString()}-【PCS状态模块】-【PCS上位机连接成功】");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
76
OrpaonEMS.App/Models/PcsAlarmCell.cs
Normal file
76
OrpaonEMS.App/Models/PcsAlarmCell.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using OrpaonEMS.Core.EventHandMsg;
|
||||
using OrpaonEMS.Core.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// PCS故障单元
|
||||
/// </summary>
|
||||
public class PcsAlarmCell
|
||||
{
|
||||
public PcsAlarmCell()
|
||||
{
|
||||
CurTimeInfo = new AlarmTimeInfo();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发布报警信息
|
||||
/// </summary>
|
||||
public event EventHandler<PcsAlarmCellEventHandMsg> PubPcsAlarmEventHandler;
|
||||
|
||||
/// <summary>
|
||||
/// 报警内容
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Bit位置
|
||||
/// </summary>
|
||||
public ushort BitIndex { get; set; }
|
||||
|
||||
private bool _State;
|
||||
/// <summary>
|
||||
/// 报警状态
|
||||
/// </summary>
|
||||
public bool State
|
||||
{
|
||||
get { return _State; }
|
||||
set
|
||||
{
|
||||
if (_State != value && value == true)//报警发生
|
||||
{
|
||||
_State = value;
|
||||
|
||||
CurTimeInfo.StartTime = DateTime.Now;
|
||||
|
||||
//发布报警
|
||||
PubPcsAlarmEventHandler(this, new PcsAlarmCellEventHandMsg() { State = true, Content = Content, Level = 3, CurTimeInfo = CurTimeInfo });
|
||||
|
||||
}
|
||||
else if (_State != value && value == false)//报警消失
|
||||
{
|
||||
_State = value;
|
||||
CurTimeInfo.EndTime = DateTime.Now;
|
||||
//发布报警
|
||||
PubPcsAlarmEventHandler(this, new PcsAlarmCellEventHandMsg() { State = false, Content = Content, Level = 3, CurTimeInfo = CurTimeInfo });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 报警时间信息
|
||||
/// </summary>
|
||||
public AlarmTimeInfo CurTimeInfo { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 报警状态
|
||||
///// </summary>
|
||||
//public bool State { get; set; }
|
||||
}
|
||||
}
|
||||
377
OrpaonEMS.App/Models/PcsAlarmModel.cs
Normal file
377
OrpaonEMS.App/Models/PcsAlarmModel.cs
Normal file
@@ -0,0 +1,377 @@
|
||||
using OrpaonEMS.Core.ChannelModel;
|
||||
using OrpaonEMS.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using Prism.Mvvm;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// PCS报警模型
|
||||
/// </summary>
|
||||
public class PcsAlarmModel : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警通道数据
|
||||
/// </summary>
|
||||
public Channel<AlarmChannelData> AlarmChannel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public PcsAlarmModel(Channel<AlarmChannelData> channel)
|
||||
{
|
||||
AlarmChannel = channel;
|
||||
|
||||
foreach (var itemAlarmCell in ListAlarmWord1)
|
||||
{
|
||||
itemAlarmCell.PubPcsAlarmEventHandler += ItemAlarmCell_PubPcsAlarmEventHandler;
|
||||
}
|
||||
foreach (var itemAlarmCell in ListAlarmWord2)
|
||||
{
|
||||
itemAlarmCell.PubPcsAlarmEventHandler += ItemAlarmCell_PubPcsAlarmEventHandler;
|
||||
}
|
||||
foreach (var itemAlarmCell in ListAlarmWord3)
|
||||
{
|
||||
itemAlarmCell.PubPcsAlarmEventHandler += ItemAlarmCell_PubPcsAlarmEventHandler;
|
||||
}
|
||||
foreach (var itemAlarmCell in ListAlarmWord4)
|
||||
{
|
||||
itemAlarmCell.PubPcsAlarmEventHandler += ItemAlarmCell_PubPcsAlarmEventHandler;
|
||||
}
|
||||
foreach (var itemAlarmCell in ListAlarmWord5)
|
||||
{
|
||||
itemAlarmCell.PubPcsAlarmEventHandler += ItemAlarmCell_PubPcsAlarmEventHandler;
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<string> _ListAlarmContent=new ObservableCollection<string>();
|
||||
/// <summary>
|
||||
///报警内容
|
||||
/// </summary>
|
||||
public ObservableCollection<string> ListAlarmContent
|
||||
{
|
||||
get { return _ListAlarmContent; }
|
||||
set { _ListAlarmContent = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
public string _CurAlarmMsg;
|
||||
/// <summary>
|
||||
/// 当前报警数据
|
||||
/// </summary>
|
||||
public string CurAlarmMsg
|
||||
{
|
||||
get { return _CurAlarmMsg; }
|
||||
set { _CurAlarmMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private int _AlarmCount;
|
||||
/// <summary>
|
||||
/// 报警个数
|
||||
/// </summary>
|
||||
public int AlarmCount
|
||||
{
|
||||
get { return _AlarmCount; }
|
||||
set { _AlarmCount = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 报警发布事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
private void ItemAlarmCell_PubPcsAlarmEventHandler(object sender, Core.EventHandMsg.PcsAlarmCellEventHandMsg AlarmData)
|
||||
{
|
||||
//统计个数
|
||||
var Count1 = ListAlarmWord1.Where(a => a.State == true).Count();
|
||||
var Count2 = ListAlarmWord2.Where(a => a.State == true).Count();
|
||||
var Count3 = ListAlarmWord3.Where(a => a.State == true).Count();
|
||||
var Count4 = ListAlarmWord4.Where(a => a.State == true).Count();
|
||||
var Count5 = ListAlarmWord5.Where(a => a.State == true).Count();
|
||||
AlarmCount = Count1 + Count2 + Count3 + Count4 + Count5;
|
||||
|
||||
if (AlarmData.State)//报警发生
|
||||
{
|
||||
CurAlarmMsg = AlarmData.Content;
|
||||
if (!ListAlarmContent.Contains(AlarmData.Content))
|
||||
{
|
||||
ListAlarmContent.Add(AlarmData.Content);
|
||||
}
|
||||
Console.WriteLine($"时间:{DateTime.Now.ToString()}:PCS报警激活:{AlarmData.Content} ");
|
||||
}
|
||||
else//报警消失
|
||||
{
|
||||
if (AlarmData.Content== CurAlarmMsg)
|
||||
{
|
||||
CurAlarmMsg ="";
|
||||
}
|
||||
Console.WriteLine($"时间:{DateTime.Now.ToString()}:PCS报警消失:{AlarmData.Content} ");
|
||||
if (ListAlarmContent.Contains(AlarmData.Content))
|
||||
{
|
||||
ListAlarmContent.Remove(AlarmData.Content);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//报警结束,可以采集数据
|
||||
AlarmChannel.Writer.WriteAsync(new AlarmChannelData()
|
||||
{
|
||||
MsgTime = DateTime.Now,
|
||||
alarmChannel = new AlarmChannel()
|
||||
{
|
||||
Content = AlarmData.Content,
|
||||
StartTime = AlarmData.CurTimeInfo.StartTime,
|
||||
EndTime = AlarmData.CurTimeInfo.EndTime,
|
||||
AlarmDur = (decimal)AlarmData.CurTimeInfo.AlarmDur,
|
||||
Level = AlarmData.Level,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//报警个数为0,那么就清空报警数据了
|
||||
if (AlarmCount == 0)
|
||||
{
|
||||
ListAlarmContent.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region 报警字信息
|
||||
|
||||
private ushort _AlarmWord1;
|
||||
/// <summary>
|
||||
/// 报警字1
|
||||
/// </summary>
|
||||
public ushort AlarmWord1
|
||||
{
|
||||
get { return _AlarmWord1; }
|
||||
set
|
||||
{
|
||||
if (_AlarmWord1 != value)
|
||||
{
|
||||
foreach (var itemAlarm in ListAlarmWord1)
|
||||
{
|
||||
itemAlarm.State = ComHelper.GetBitValue(value, itemAlarm.BitIndex);
|
||||
}
|
||||
|
||||
_AlarmWord1 = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ushort _AlarmWord2;
|
||||
/// <summary>
|
||||
/// 报警字1
|
||||
/// </summary>
|
||||
public ushort AlarmWord2
|
||||
{
|
||||
get { return _AlarmWord2; }
|
||||
set
|
||||
{
|
||||
if (_AlarmWord2 != value)
|
||||
{
|
||||
foreach (var itemAlarm in ListAlarmWord2)
|
||||
{
|
||||
itemAlarm.State = ComHelper.GetBitValue(value, itemAlarm.BitIndex);
|
||||
}
|
||||
|
||||
_AlarmWord2 = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ushort _AlarmWord3;
|
||||
/// <summary>
|
||||
/// 报警字3
|
||||
/// </summary>
|
||||
public ushort AlarmWord3
|
||||
{
|
||||
get { return _AlarmWord3; }
|
||||
set
|
||||
{
|
||||
if (_AlarmWord3 != value)
|
||||
{
|
||||
foreach (var itemAlarm in ListAlarmWord3)
|
||||
{
|
||||
itemAlarm.State = ComHelper.GetBitValue(value, itemAlarm.BitIndex);
|
||||
}
|
||||
|
||||
_AlarmWord3 = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ushort _AlarmWord4;
|
||||
/// <summary>
|
||||
/// 报警字4
|
||||
/// </summary>
|
||||
public ushort AlarmWord4
|
||||
{
|
||||
get { return _AlarmWord4; }
|
||||
set
|
||||
{
|
||||
if (_AlarmWord4 != value)
|
||||
{
|
||||
foreach (var itemAlarm in ListAlarmWord4)
|
||||
{
|
||||
itemAlarm.State = ComHelper.GetBitValue(value, itemAlarm.BitIndex);
|
||||
}
|
||||
_AlarmWord4 = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ushort _AlarmWord5;
|
||||
/// <summary>
|
||||
/// 报警字5
|
||||
/// </summary>
|
||||
public ushort AlarmWord5
|
||||
{
|
||||
get { return _AlarmWord5; }
|
||||
set
|
||||
{
|
||||
if (_AlarmWord5 != value)
|
||||
{
|
||||
foreach (var itemAlarm in ListAlarmWord5)
|
||||
{
|
||||
itemAlarm.State = ComHelper.GetBitValue(value, itemAlarm.BitIndex);
|
||||
}
|
||||
_AlarmWord5 = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 报警集合数据
|
||||
|
||||
/// <summary>
|
||||
/// PCS 故障字 1
|
||||
/// 集合
|
||||
/// </summary>
|
||||
public List<PcsAlarmCell> ListAlarmWord1 { get; set; } = new List<PcsAlarmCell>()
|
||||
{
|
||||
new PcsAlarmCell(){Content="FPGA 硬件故障-A 相硬件过流",BitIndex=0 },
|
||||
new PcsAlarmCell(){Content="FPGA 硬件故障-B 相硬件过流",BitIndex=1 },
|
||||
new PcsAlarmCell(){Content="FPGA 硬件故障-C 相硬件过流",BitIndex=2 },
|
||||
new PcsAlarmCell(){Content="FPGA 硬件故障-N 相硬件过流",BitIndex=3 },
|
||||
new PcsAlarmCell(){Content="FPGA 硬件故障-单元直压故障",BitIndex=6 },
|
||||
new PcsAlarmCell(){Content="FPGA 硬件故障-开关电源欠压",BitIndex=9 },
|
||||
new PcsAlarmCell(){Content="FPGA 软件故障-A 相 IGBT 故障",BitIndex=10 },
|
||||
new PcsAlarmCell(){Content="FPGA 硬件故障-B 相 IGBT 故障",BitIndex=11 },
|
||||
new PcsAlarmCell(){Content="FPGA 硬件故障-C 相 IGBT 故障",BitIndex=12 },
|
||||
new PcsAlarmCell(){Content="FPGA 硬件故障-N 相 IGBT 故障",BitIndex=13 },
|
||||
new PcsAlarmCell(){Content="FPGA 硬件故障-过温故障",BitIndex=14 },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// PCS 故障字 2
|
||||
/// 集合
|
||||
/// </summary>
|
||||
public List<PcsAlarmCell> ListAlarmWord2 { get; set; } = new List<PcsAlarmCell>()
|
||||
{
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-A 相输出过流",BitIndex=0 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-A 相输出速断",BitIndex=1 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-B 相输出过流",BitIndex=2 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-B 相输出速断",BitIndex=3 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-C 相输出过流",BitIndex=4 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-C 相输出速断",BitIndex=5 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-N 相输出速断",BitIndex=6 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-N 相输出速断",BitIndex=7 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-交流过压",BitIndex=8 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-交流欠压",BitIndex=9 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-交流过频",BitIndex=10 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-交流欠频",BitIndex=11 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-电压 THDU 超限",BitIndex=12 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-系统缺相",BitIndex=13 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-系统相序错误",BitIndex=14 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-直流极性反接",BitIndex=15 },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// PCS 故障字 3
|
||||
/// 集合
|
||||
/// </summary>
|
||||
public List<PcsAlarmCell> ListAlarmWord3 { get; set; } = new List<PcsAlarmCell>()
|
||||
{
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-直流母线软件过压",BitIndex=0 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-直流母线软件欠压",BitIndex=1 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-系统过频率",BitIndex=2 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-系统欠频率",BitIndex=3 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-直流充电过流",BitIndex=4 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-直流放电过流",BitIndex=5 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-孤岛保护",BitIndex=6 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-保留",BitIndex=7 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-交流主接合闸故障",BitIndex=8 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-交流主接分闸故障",BitIndex=9 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-交流软启合闸故障",BitIndex=10 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-交流软启分闸故障",BitIndex=11 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-直流主接合闸故障",BitIndex=12 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-直流主接分闸故障",BitIndex=13 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-直流软启合闸故障",BitIndex=14 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-直流软启合闸故障",BitIndex=15 },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// PCS 故障字 4
|
||||
/// 集合
|
||||
/// </summary>
|
||||
public List<PcsAlarmCell> ListAlarmWord4 { get; set; } = new List<PcsAlarmCell>()
|
||||
{
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-铁电参数存储错误",BitIndex=0 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-直流软起失败",BitIndex=1 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-保留",BitIndex=2 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-保留",BitIndex=3 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-起机条件不满足",BitIndex=4 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-运行中开关故障",BitIndex=5 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-逆变启动超时",BitIndex=6 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-参数下发设置错误",BitIndex=7 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-BMS 通讯故障",BitIndex=8 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-BMS 温度异常",BitIndex=9 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-BMS 跳机",BitIndex=10 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-BMS 电池告警",BitIndex=11 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-DCDC 通讯故障",BitIndex=12 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-EMS 通讯故障",BitIndex=13 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-急停或熔芯故障",BitIndex=14 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-保留",BitIndex=15 },
|
||||
};
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// PCS 故障字 5
|
||||
/// 集合
|
||||
/// </summary>
|
||||
public List<PcsAlarmCell> ListAlarmWord5 { get; set; } = new List<PcsAlarmCell>()
|
||||
{
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-保留",BitIndex=0 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-电池软件过压",BitIndex=1 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-电池软件欠压",BitIndex=2 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-母线不平衡异常",BitIndex=3 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-母线半直压过压",BitIndex=4 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-DCDC 启动超时",BitIndex=5 },
|
||||
new PcsAlarmCell(){Content="ARM 软件故障-保留",BitIndex=6 },
|
||||
//new PcsAlarmCell(){Content="xxx",BitIndex=7 },
|
||||
//new PcsAlarmCell(){Content="xxx",BitIndex=8 },
|
||||
//new PcsAlarmCell(){Content="xxx",BitIndex=9 },
|
||||
//new PcsAlarmCell(){Content="xxx",BitIndex=10 },
|
||||
//new PcsAlarmCell(){Content="xxx",BitIndex=11 },
|
||||
//new PcsAlarmCell(){Content="xxx",BitIndex=12 },
|
||||
//new PcsAlarmCell(){Content="xxx",BitIndex=13 },
|
||||
//new PcsAlarmCell(){Content="xxx",BitIndex=14 },
|
||||
//new PcsAlarmCell(){Content="xxx",BitIndex=15 },
|
||||
};
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
270
OrpaonEMS.App/Models/PubData.cs
Normal file
270
OrpaonEMS.App/Models/PubData.cs
Normal file
@@ -0,0 +1,270 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 发布的数据信息
|
||||
/// Mqtt
|
||||
/// </summary>
|
||||
public class PubData
|
||||
{
|
||||
/// <summary>
|
||||
/// 电池簇电流值
|
||||
/// </summary>
|
||||
public double BmsCur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电池簇电压
|
||||
/// </summary>
|
||||
public double BmsVol { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电池簇总SOC
|
||||
/// </summary>
|
||||
public double BmsSOC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电池簇总SOH
|
||||
/// </summary>
|
||||
public double BmsSOH { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电池簇总SOE
|
||||
/// </summary>
|
||||
public double BmsSOE { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电池簇绝缘电阻R+
|
||||
/// </summary>
|
||||
public double BmsResP { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电池簇绝缘电阻R
|
||||
/// </summary>
|
||||
public double BmsResN { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 累计充电电量
|
||||
/// </summary>
|
||||
public double BmsAccCharg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 累计放电电量
|
||||
/// </summary>
|
||||
public double BmsAccDisCharg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Bms功率
|
||||
/// </summary>
|
||||
public double BmsPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电池簇电池状态
|
||||
/// </summary>
|
||||
public string BmsBatState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大允许充电功率
|
||||
/// </summary>
|
||||
public double MaxChargePower { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大允许放电功率
|
||||
/// </summary>
|
||||
public double MaxDisChargePower { get; set; }
|
||||
|
||||
|
||||
|
||||
////////////////光伏的数据////////////////
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 储能PCS的实时功率
|
||||
/// </summary>
|
||||
public double PcsPower { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电网无功功率
|
||||
/// </summary>
|
||||
public double PcsTotalReactivePw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 电网视在功率
|
||||
/// </summary>
|
||||
public double PcsTotalApparentPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 输入电压
|
||||
/// </summary>
|
||||
public double PcsInputVol { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 输入电流
|
||||
/// </summary>
|
||||
public double PcsInputCur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 输入功率
|
||||
/// </summary>
|
||||
public double PcsInputPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PCS报警状态文本
|
||||
/// </summary>
|
||||
public string PcsCurAlarmStateStr { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PCS A相电压
|
||||
/// </summary>
|
||||
public double PcsAVol { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PCS B相电压
|
||||
/// </summary>
|
||||
public double PcsBVol { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PCS C相电压
|
||||
/// </summary>
|
||||
public double PcsCVol { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PCS A相电流
|
||||
/// </summary>
|
||||
public double PcsACur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PCS B相电流
|
||||
/// </summary>
|
||||
public double PcsBCur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PCS C相电流
|
||||
/// </summary>
|
||||
public double PcsCCur { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PCS 状态
|
||||
/// </summary>
|
||||
public string PCSFaultStateStr { get; set; }
|
||||
|
||||
|
||||
////////////////光伏的数据////////////////
|
||||
|
||||
/// <summary>
|
||||
/// 光伏实时功率
|
||||
/// </summary>
|
||||
public double SolarPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 光伏日发电量
|
||||
/// </summary>
|
||||
public double SolarDayPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 光伏月发电量
|
||||
/// </summary>
|
||||
public double SolarMonthPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 无功功率
|
||||
/// </summary>
|
||||
public double SolarReactivePw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 功率因数
|
||||
/// </summary>
|
||||
public double SolarPwFactor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 效率
|
||||
/// </summary>
|
||||
public double SolarEfficiency { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 内部温度
|
||||
/// </summary>
|
||||
public double SolarInternalTemp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 绝缘阻抗值
|
||||
/// </summary>
|
||||
public double SolarResV { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备状态
|
||||
/// </summary>
|
||||
public string SolarState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 累计发电量
|
||||
/// </summary>
|
||||
public double SolarAccPw { get; set; }
|
||||
|
||||
|
||||
//////////////////////电表数据/////////////////////////
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 负载电表数据
|
||||
/// </summary>
|
||||
public double LoadMeterPw { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// xxx
|
||||
///// </summary>
|
||||
//public double xxx { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// xxx
|
||||
///// </summary>
|
||||
//public double xxx { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// xxx
|
||||
///// </summary>
|
||||
//public double xxx { get; set; }
|
||||
|
||||
//////////////////////电表数据/////////////////////////
|
||||
|
||||
/// <summary>
|
||||
/// 削峰填谷状态
|
||||
/// </summary>
|
||||
public string PeakVellyState { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// xxx
|
||||
///// </summary>
|
||||
//public double xxx { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// xxx
|
||||
///// </summary>
|
||||
//public double xxx { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// xxx
|
||||
///// </summary>
|
||||
//public double xxx { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// xxx
|
||||
///// </summary>
|
||||
//public double xxx { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// xxx
|
||||
///// </summary>
|
||||
//public double xxx { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// xxx
|
||||
///// </summary>
|
||||
//public double xxx { get; set; }
|
||||
}
|
||||
}
|
||||
21
OrpaonEMS.App/Models/ResultInfo.cs
Normal file
21
OrpaonEMS.App/Models/ResultInfo.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
public class ResultInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 结果
|
||||
/// </summary>
|
||||
public bool Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消息
|
||||
/// </summary>
|
||||
public string Msg { get; set; }
|
||||
}
|
||||
}
|
||||
16
OrpaonEMS.App/Models/RtAlarm.cs
Normal file
16
OrpaonEMS.App/Models/RtAlarm.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
public class RtAlarm
|
||||
{
|
||||
public string? Content { get; set; }
|
||||
public int Level { get; set; }
|
||||
public DateTime CreatTime { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
31
OrpaonEMS.App/Models/RtPcsPwChartModel.cs
Normal file
31
OrpaonEMS.App/Models/RtPcsPwChartModel.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.App.Models
|
||||
{
|
||||
public class RtPcsPwChartModel
|
||||
{
|
||||
public RtPcsPwChartModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
public DateTime CurTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 输出有功功率值
|
||||
/// </summary>
|
||||
public double QPw { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 指令数据功率值
|
||||
/// </summary>
|
||||
public double CmdPw { get; set; }
|
||||
}
|
||||
}
|
||||
127
OrpaonEMS.App/Models/SwitchModel.cs
Normal file
127
OrpaonEMS.App/Models/SwitchModel.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using HslCommunication.ModBus;
|
||||
using OrpaonEMS.Model.Enums;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 开关模型
|
||||
/// </summary>
|
||||
public class SwitchModel : BindableBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// 地址和ModbusPull一样
|
||||
/// 第一个合闸 第二个分闸
|
||||
/// </summary>
|
||||
public SwitchModel(string onAddress, string offAddress, ModbusTcpNet modbusTcpNet)
|
||||
{
|
||||
OnAddress = onAddress;
|
||||
OffAddress = offAddress;
|
||||
ModbusTcpNet = modbusTcpNet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开地址
|
||||
/// 开和关是不同的地址
|
||||
/// </summary>
|
||||
private string OnAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 关地址
|
||||
/// 开和关是不同的地址
|
||||
/// </summary>
|
||||
private string OffAddress { get; set; }
|
||||
|
||||
private SwitchEm _CurSwtichState;
|
||||
/// <summary>
|
||||
/// 开关的状态
|
||||
/// 读取合闸的信号 DI读取
|
||||
/// </summary>
|
||||
public SwitchEm CurSwtichState
|
||||
{
|
||||
get { return _CurSwtichState; }
|
||||
set { _CurSwtichState = value; }
|
||||
}
|
||||
|
||||
private SwitchErr _CurSwtichErrInfo;
|
||||
/// <summary>
|
||||
/// 开关的故障状态
|
||||
/// 读取开关的Err信号 DI读取
|
||||
/// </summary>
|
||||
public SwitchErr CurSwtichErrInfo
|
||||
{
|
||||
get { return _CurSwtichErrInfo; }
|
||||
set { _CurSwtichErrInfo = value; }
|
||||
}
|
||||
|
||||
private SwitchStateInfo _CurSwitchStateInfo;
|
||||
/// <summary>
|
||||
/// 开关的状态
|
||||
/// </summary>
|
||||
public SwitchStateInfo CurSwitchStateInfo
|
||||
{
|
||||
get { return _CurSwitchStateInfo; }
|
||||
set { _CurSwitchStateInfo = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// 开关的故障状态
|
||||
///// 读取开关的Err信号 DI读取
|
||||
///// </summary>
|
||||
//public SwitchErr CurSwtichErrInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 驱动
|
||||
/// </summary>
|
||||
public ModbusTcpNet ModbusTcpNet { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 设置Switch开和关
|
||||
/// 可实时赋值
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool SetRtSwitch(SwitchEm state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case SwitchEm.On://开
|
||||
if (CurSwtichState == SwitchEm.Off)
|
||||
{
|
||||
Task.Run(new Action(() =>
|
||||
{
|
||||
ModbusTcpNet.Write(OnAddress, true);
|
||||
Thread.Sleep(100);
|
||||
ModbusTcpNet.Write(OnAddress, false);
|
||||
//可以判断DI的结果是否正确
|
||||
}));
|
||||
}
|
||||
break;
|
||||
case SwitchEm.Off://关
|
||||
if (CurSwtichState == SwitchEm.On)
|
||||
{
|
||||
Task.Run(new Action(() =>
|
||||
{
|
||||
ModbusTcpNet.Write(OffAddress, true);
|
||||
Thread.Sleep(100);
|
||||
ModbusTcpNet.Write(OffAddress, false);
|
||||
//可以判断DI的结果是否正确
|
||||
}));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
79
OrpaonEMS.App/Models/TrigModuleStartRunAction.cs
Normal file
79
OrpaonEMS.App/Models/TrigModuleStartRunAction.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using OrpaonEMS.App.Services;
|
||||
using OrpaonEMS.Core.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 自动触发模块运行模型
|
||||
/// 比如PCS
|
||||
/// </summary>
|
||||
public class TrigModuleStartRunAction
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化
|
||||
/// </summary>
|
||||
public TrigModuleStartRunAction(EnergyStorageService energyStorage)
|
||||
{
|
||||
//实例注入
|
||||
energyStorages = energyStorage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取储能的实例
|
||||
/// </summary>
|
||||
private EnergyStorageService energyStorages { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 线程使能
|
||||
/// </summary>
|
||||
private bool PcsAutoTrigThreadEnable = true;
|
||||
|
||||
/// <summary>
|
||||
/// PCS自动触发运行
|
||||
/// </summary>
|
||||
public void PcsAutoTrigRun()
|
||||
{
|
||||
Console.WriteLine($"时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff")}:PCS自动触发运行-开始运行自动触发循环");
|
||||
//先使能线程的循环的条件
|
||||
PcsAutoTrigThreadEnable = true;
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (PcsAutoTrigThreadEnable)
|
||||
{
|
||||
energyStorages.InPowerPCSDataService.PCSStart();
|
||||
|
||||
//延迟6秒 看结果
|
||||
Thread.Sleep(6000);
|
||||
|
||||
if (energyStorages.InPowerPCSDataService.PcsRunState.PcsStateInfo != PCSState.Stop)
|
||||
{
|
||||
PcsAutoTrigThreadEnable = false;
|
||||
Console.WriteLine($"时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff")}:PCS自动触发运行-触发启动成功-结束循环扫描 ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 如果一直触发没有成功的话,则取消即可
|
||||
/// 关闭触发PCS自动触发运行
|
||||
/// 可能是报警到其他的状态了,不需要自动触发了
|
||||
/// 即使没有运行这个触发循环,也可以执行这个函数
|
||||
/// </summary>
|
||||
public void PcsAutoTrigClose()
|
||||
{
|
||||
PcsAutoTrigThreadEnable = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
33
OrpaonEMS.App/Models/ValueRange.cs
Normal file
33
OrpaonEMS.App/Models/ValueRange.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrpaonEMS.App.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 值范围
|
||||
/// </summary>
|
||||
public class ValueRange
|
||||
{
|
||||
/// <summary>
|
||||
/// 实例化函数
|
||||
/// </summary>
|
||||
public ValueRange(double downValue, double upValue)
|
||||
{
|
||||
this.DownValue = downValue;
|
||||
this.UpValue = upValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上限值
|
||||
/// </summary>
|
||||
public double UpValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 下限值
|
||||
/// </summary>
|
||||
public double DownValue { get; private set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user