添加Ups前端页面信息展示

master
lch 6 months ago
parent 1578632dbf
commit 43e8389774

@ -58,5 +58,12 @@ namespace Module.UpsEqm.ModBusTcp
} }
return strResult; return strResult;
} }
public static bool GetBitValue(byte value, byte bit)
{
return (value & (byte)Math.Pow(2, bit)) > 0 ? true : false;
}
} }
} }

@ -1,4 +1,5 @@
using System; using Module.UpsEqm.ModBusTcp.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -17,5 +18,6 @@ namespace Module.UpsEqm.ModBusTcp
/// </summary> /// </summary>
public static UpsModbusTool UPS01 = new UpsModbusTool("172.0.50.102", 502, 6, "U001"); public static UpsModbusTool UPS01 = new UpsModbusTool("172.0.50.102", 502, 6, "U001");
#endregion 基础字段 #endregion 基础字段
public static UpsPageShowInfo upsPageShowInfo = new UpsPageShowInfo();
} }
} }

@ -439,6 +439,9 @@ namespace Module.UpsEqm.ModBusTcp
_ups_param_value.F_UpsID = _client.ByteTransform.TransUInt16(results, 30); _ups_param_value.F_UpsID = _client.ByteTransform.TransUInt16(results, 30);
_ups_param_value.F_ProtocolNumber = _client.ByteTransform.TransUInt16(results, 32); _ups_param_value.F_ProtocolNumber = _client.ByteTransform.TransUInt16(results, 32);
_ups_param_value.F_UpsVersion = _client.ByteTransform.TransUInt16(results, 34); _ups_param_value.F_UpsVersion = _client.ByteTransform.TransUInt16(results, 34);
CmnUpsBaseInfo.upsPageShowInfo.upsType = _ups_param_value.F_UpsName;
CmnUpsBaseInfo.upsPageShowInfo.upsVersion = _ups_param_value.F_UpsVersion;
} }
//状态信息 //状态信息
@ -459,6 +462,47 @@ namespace Module.UpsEqm.ModBusTcp
_ups_param_value.F_UpsSystemModal = state_results[2]; _ups_param_value.F_UpsSystemModal = state_results[2];
} }
//前端页面信息展示
OperateResult<byte[]> upsStateInfoResult = _client.Read("x=3;96", 60);
if (upsStateInfoResult.IsSuccess)
{
byte[] config_results = upsStateInfoResult.Content;
//96
CmnUpsBaseInfo.upsPageShowInfo.inputVolt = _client.ByteTransform.TransUInt16(config_results, 0);
//105
CmnUpsBaseInfo.upsPageShowInfo.outputVolt = _client.ByteTransform.TransUInt16(config_results, 18);
//122
CmnUpsBaseInfo.upsPageShowInfo.outPutLoadPct = _client.ByteTransform.TransUInt16(config_results, 52);
//103
CmnUpsBaseInfo.upsPageShowInfo.inputFreq = _client.ByteTransform.TransUInt16(config_results, 14);
//124
CmnUpsBaseInfo.upsPageShowInfo.batteryVolt = _client.ByteTransform.TransUInt16(config_results, 56);
//125
CmnUpsBaseInfo.upsPageShowInfo.temp = _client.ByteTransform.TransUInt16(config_results, 58);
//111
CmnUpsBaseInfo.upsPageShowInfo.tatedCurrent = _client.ByteTransform.TransUInt16(config_results, 30);
//123
CmnUpsBaseInfo.upsPageShowInfo.batteryTotalVolt = _client.ByteTransform.TransUInt16(config_results, 54);
//134
CmnUpsBaseInfo.upsPageShowInfo.frequency = _client.ByteTransform.TransUInt16(config_results, 76);
}
//前端页面信息展示
OperateResult<byte[]> upsInfoResult = _client.Read("x=3;30", 30);
if (upsInfoResult.IsSuccess)
{
byte[] state_results = upsInfoResult.Content;
//BitsConvertUtils
CmnUpsBaseInfo.upsPageShowInfo.mainsPowerFail = BitsConvertUtils.GetBitValue(state_results[41], 1);
CmnUpsBaseInfo.upsPageShowInfo.lowBatteryVolt = BitsConvertUtils.GetBitValue(state_results[41], 4);
CmnUpsBaseInfo.upsPageShowInfo.bypassVoltageStableModel = BitsConvertUtils.GetBitValue(state_results[1], 5);
CmnUpsBaseInfo.upsPageShowInfo.upsFault = BitsConvertUtils.GetBitValue(state_results[35], 4);
CmnUpsBaseInfo.upsPageShowInfo.systemTesting = BitsConvertUtils.GetBitValue(state_results[1], 9);
CmnUpsBaseInfo.upsPageShowInfo.remoteSystemShutdown = BitsConvertUtils.GetBitValue(state_results[1], 1);
CmnUpsBaseInfo.upsPageShowInfo.alarmSounOn = BitsConvertUtils.GetBitValue(state_results[1], 0);
}
//配置数据 //配置数据
OperateResult<byte[]> configResult = _client.Read("x=3;160", 16); OperateResult<byte[]> configResult = _client.Read("x=3;160", 16);
@ -477,6 +521,8 @@ namespace Module.UpsEqm.ModBusTcp
_ups_param_value.F_BatCellNumber = _client.ByteTransform.TransUInt16(config_results, 18); _ups_param_value.F_BatCellNumber = _client.ByteTransform.TransUInt16(config_results, 18);
_ups_param_value.F_BatCellSeries = _client.ByteTransform.TransUInt16(config_results, 20); _ups_param_value.F_BatCellSeries = _client.ByteTransform.TransUInt16(config_results, 20);
CmnUpsBaseInfo.upsPageShowInfo.ratedVolt = _ups_param_value.F_MainVoltage;
} }
//故障信息 //故障信息

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Module.UpsEqm.ModBusTcp.Models
{
public class UpsPageShowInfo
{
/// <summary>
/// 更新时间
/// </summary>
public string update { get; set; }
/// <summary>
/// UPS版本号
/// </summary>
public ushort upsVersion { get; set; }
/// <summary>
/// UPS类型
/// </summary>
public string upsType { get; set; }
/// <summary>
/// 输出电压R 0.1v
/// </summary>
public ushort outputVolt { get; set; }
/// <summary>
/// 输入电压R 0.1v
/// </summary>
public ushort inputVolt { get; set; }
/// <summary>
/// 输入频率 0.1HZ
/// </summary>
public ushort inputFreq { get; set; }
/// <summary>
/// O/P load负载百分比 16%
/// </summary>
public ushort outPutLoadPct { get; set; }
/// <summary>
/// 电池电压
/// </summary>
public ushort batteryVolt { get; set; }
/// <summary>
/// 温度
/// </summary>
public ushort temp { get; set; }
/// <summary>
/// 额定电源电压
/// </summary>
public ushort ratedVolt { get; set; }
/// <summary>
/// 额定电流R
/// </summary>
public ushort tatedCurrent { get; set; }
/// <summary>
/// 电池单元格电压
/// </summary>
public ushort batteryTotalVolt { get; set; }
/// <summary>
/// 输出频率
/// </summary>
public ushort frequency { get; set; }
/// <summary>
/// 市电异常:旁路干线故障
/// </summary>
public bool mainsPowerFail { get; set; } = false;
/// <summary>
/// 旁路/稳压模式
/// </summary>
public bool bypassVoltageStableModel { get; set; } = false;
/// <summary>
/// 电池电压低
/// </summary>
public bool lowBatteryVolt { get; set; } = false;
/// <summary>
/// UPS模块全故障
/// </summary>
public bool upsFault { get; set; } = false;
/// <summary>
/// 电池自检中
/// </summary>
public bool systemTesting { get; set; } = false;
/// <summary>
/// 关机模式
/// </summary>
public bool remoteSystemShutdown { get; set; } = false;
/// <summary>
/// 电池模式下是否有蜂鸣器告警
/// </summary>
public bool alarmSounOn { get; set; }=false;
}
}

@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Module.EMeter.ModbusTcp;
using Module.UpsEqm.ModBusTcp; using Module.UpsEqm.ModBusTcp;
using Module.UpsEqm.ModBusTcp.Models;
namespace Monitor.EqmMgr.WebApi.Controllers namespace Monitor.EqmMgr.WebApi.Controllers
{ {
@ -34,5 +36,40 @@ namespace Monitor.EqmMgr.WebApi.Controllers
new UpsEqmManger().UpsNetReConnectThread(); new UpsEqmManger().UpsNetReConnectThread();
} }
/// <summary>
/// UPS前端页面展示信息类
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("/api/[controller]/upsInfoShow")]
public UpsPageShowInfo UpsInfoShow()
{
CmnUpsBaseInfo.upsPageShowInfo.update = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
return CmnUpsBaseInfo.upsPageShowInfo;
}
/// <summary>
/// UPS、电表连接状态展示
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("/api/[controller]/eqipConnState")]
public List<bool> EqipConnState()
{
List<bool> list = new List<bool>
{
CmnUpsBaseInfo.UPS01.F_NetConnected,
CmnElecMeterBaseInfo.EBC01.F_NetConnected,
CmnElecMeterBaseInfo.EBC02.F_NetConnected,
CmnElecMeterBaseInfo.EBC03.F_NetConnected,
CmnElecMeterBaseInfo.EBC04.F_NetConnected,
CmnElecMeterBaseInfo.EBC05.F_NetConnected,
CmnElecMeterBaseInfo.EBC06.F_NetConnected,
CmnElecMeterBaseInfo.EBC07.F_NetConnected,
};
return list;
}
} }
} }

Loading…
Cancel
Save