电能读取优化

master
rszn 8 months ago
parent 174242fc87
commit eed5f501cb

@ -32,8 +32,6 @@ namespace Module.EMeter.ModbusTcp
/// 3号充电机电表
/// </summary>
public static EMeterModbus527Tool EBC03 = new EMeterModbus527Tool("172.0.50.100", 405, 6, "2号换电站11号充电机");
/// </summary>
public static EMeterModbus527Tool EBC04 = new EMeterModbus527Tool("172.0.50.100", 405, 7, "2号换电站配电总柜");
/// <summary>

@ -506,14 +506,35 @@ namespace Module.EMeter.ModbusTcp
{
while (_is_read)
{
var operateResult = _client.Read("x=3;0", 150);
if (_net_connected && operateResult.IsSuccess)
{
var PT = _client.ByteTransform.TransInt16(operateResult.Content, 6);
var CT = _client.ByteTransform.TransInt16(operateResult.Content, 8);
// var operateResult = _client.Read("x=3;0", 65);
// if (_net_connected && operateResult.IsSuccess)
// {
// var PT = _client.ByteTransform.TransInt16(operateResult.Content, 6);
// var CT = _client.ByteTransform.TransInt16(operateResult.Content, 8);
// //_total_active_power = _client.ByteTransform.TransUInt16(_client.Read("x=3;45", 150).Content, 4);
// //_total_active_energy = _client.ByteTransform.TransSingle(_client.Read("x=3;45", 150).Content, 56) / 1000f;
// var transInt16 = (new decimal(_client.ByteTransform.TransUInt16(operateResult.Content, 126))*65536+_client.ByteTransform.TransUInt16(operateResult.Content, 128)/ new decimal(1000f))*new decimal(PT) *new decimal(CT);
// _show_energy = (float)transInt16;
// MEMeterParamResult paramRlt = new MEMeterParamResult()
// {
// F_EqmCode = _eqm_code,
// F_ShowEnergy=_show_energy,
// F_TotalActivePower = _total_active_power,
// F_TotalActiveEnergy = Convert.ToUInt32(_total_active_energy)
// };
// _emeter_param_result = paramRlt;
// new ElecMeterValToRedis().StoredMeterParamResult(_eqm_code, paramRlt);
// }
var operateResult1 = _client.Read("x=3;0", 10);
var operateResult2 = _client.Read("x=3;63", 10);
if (_net_connected && operateResult1.IsSuccess && operateResult2.IsSuccess)
{
var PT = _client.ByteTransform.TransInt16(operateResult1.Content, 6);
var CT = _client.ByteTransform.TransInt16(operateResult1.Content, 8);
//_total_active_power = _client.ByteTransform.TransUInt16(_client.Read("x=3;45", 150).Content, 4);
//_total_active_energy = _client.ByteTransform.TransSingle(_client.Read("x=3;45", 150).Content, 56) / 1000f;
var transInt16 = (new decimal(_client.ByteTransform.TransUInt16(operateResult.Content, 126))*65536+_client.ByteTransform.TransUInt16(operateResult.Content, 128)/ new decimal(1000f))*new decimal(PT) *new decimal(CT);
var transInt16 = (new decimal(_client.ByteTransform.TransUInt16(operateResult2.Content, 0))*65536+_client.ByteTransform.TransUInt16(operateResult2.Content, 2)/ new decimal(1000f))*new decimal(PT) *new decimal(CT);
_show_energy = (float)transInt16;
MEMeterParamResult paramRlt = new MEMeterParamResult()
{
@ -525,6 +546,8 @@ namespace Module.EMeter.ModbusTcp
_emeter_param_result = paramRlt;
new ElecMeterValToRedis().StoredMeterParamResult(_eqm_code, paramRlt);
}
Thread.Sleep(2000);
}
}

@ -76,10 +76,10 @@ namespace Module.EMeter.ModbusTcp
CmnElecMeterBaseInfo.EBC01.Connect();
}
Thread.Sleep(200);
// if (!CmnElecMeterBaseInfo.EBC02.F_NetConnected)
// {
// CmnElecMeterBaseInfo.EBC02.Connect();
// }
if (!CmnElecMeterBaseInfo.EBC02.F_NetConnected)
{
CmnElecMeterBaseInfo.EBC02.Connect();
}
Thread.Sleep(200);
if (!CmnElecMeterBaseInfo.EBC03.F_NetConnected)
{

Loading…
Cancel
Save