@ -506,14 +506,35 @@ namespace Module.EMeter.ModbusTcp
{
{
while ( _is_read )
while ( _is_read )
{
{
var operateResult = _client . Read ( "x=3;0" , 150 ) ;
// var operateResult = _client.Read("x=3;0", 65);
if ( _net_connected & & operateResult . IsSuccess )
// if (_net_connected && operateResult.IsSuccess)
{
// {
var PT = _client . ByteTransform . TransInt16 ( operateResult . Content , 6 ) ;
// var PT = _client.ByteTransform.TransInt16(operateResult.Content, 6);
var CT = _client . ByteTransform . TransInt16 ( operateResult . Content , 8 ) ;
// 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_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;
//_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 ( operateResult 2. Content , 0 ) ) * 65536 + _client . ByteTransform . TransUInt16 ( operateResult 2 . Content , 2) / new decimal ( 1000f ) ) * new decimal ( PT ) * new decimal ( CT ) ;
_show_energy = ( float ) transInt16 ;
_show_energy = ( float ) transInt16 ;
MEMeterParamResult paramRlt = new MEMeterParamResult ( )
MEMeterParamResult paramRlt = new MEMeterParamResult ( )
{
{
@ -525,6 +546,8 @@ namespace Module.EMeter.ModbusTcp
_emeter_param_result = paramRlt ;
_emeter_param_result = paramRlt ;
new ElecMeterValToRedis ( ) . StoredMeterParamResult ( _eqm_code , paramRlt ) ;
new ElecMeterValToRedis ( ) . StoredMeterParamResult ( _eqm_code , paramRlt ) ;
}
}
Thread . Sleep ( 2000 ) ;
Thread . Sleep ( 2000 ) ;
}
}
}
}