117 lines
4.0 KiB
C#
117 lines
4.0 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using JiShe.CollectBus.Application.Contracts;
|
|||
|
|
using JiShe.CollectBus.Common.Enums;
|
|||
|
|
using JiShe.CollectBus.Common.Extensions;
|
|||
|
|
using JiShe.CollectBus.Common.Models;
|
|||
|
|
using JiShe.CollectBus.MQ.Sender;
|
|||
|
|
using Microsoft.Extensions.Logging;
|
|||
|
|
using Volo.Abp.DependencyInjection;
|
|||
|
|
|
|||
|
|
namespace JiShe.CollectBus.Application
|
|||
|
|
{
|
|||
|
|
public class CommandService: ICommandService,ISingletonDependency
|
|||
|
|
{
|
|||
|
|
private readonly ILogger<CommandService> _logger;
|
|||
|
|
private readonly INSender _nSender;
|
|||
|
|
|
|||
|
|
public async Task<bool> AmmeterParameterSendAsync()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
var listMeter = new List<AmmeterParameter>()
|
|||
|
|
{
|
|||
|
|
new AmmeterParameter()
|
|||
|
|
{
|
|||
|
|
Pn = 1,
|
|||
|
|
BaudRate = 3,
|
|||
|
|
Port = 2,
|
|||
|
|
ProtocolType = CommunicationProtocolType.DLT6452007,
|
|||
|
|
Address = "312408006642",
|
|||
|
|
Password = "000000",
|
|||
|
|
RateNumber = 4,
|
|||
|
|
IntegerBitNumber = 4,
|
|||
|
|
DecimalBitNumber = 4,
|
|||
|
|
CollectorAddress = "000000000000",
|
|||
|
|
UserCategoryNumber = 0,
|
|||
|
|
UserSubclassNumber = 0
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
var bytes = HexStringExtensions.BuildAmmeterParameterSetSendCmd(new ReqParameter2()
|
|||
|
|
{
|
|||
|
|
AFN = AFN.设置参数,
|
|||
|
|
FunCode = (int)CMasterStationFunCode.请求1级数据,
|
|||
|
|
A = "322009872",
|
|||
|
|
Seq = new Seq()
|
|||
|
|
{
|
|||
|
|
TpV = TpV.附加信息域中无时间标签,
|
|||
|
|
FIRFIN = FIRFIN.单帧,
|
|||
|
|
CON = CON.需要对该帧进行确认,
|
|||
|
|
PRSEQ = 10,
|
|||
|
|
},
|
|||
|
|
MSA = 13,
|
|||
|
|
Pn = 0,
|
|||
|
|
Fn = 10
|
|||
|
|
}, listMeter);
|
|||
|
|
|
|||
|
|
await _nSender.SendToIssuedAsync(new MessageIssuedEvent { DeviceNo = "322009872", Message = bytes, Type = IssuedEventType.Data, MessageId = Guid.NewGuid().ToString() });
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool AmmeterParameterReading()
|
|||
|
|
{
|
|||
|
|
HexStringExtensions.BuildAmmeterParameterReadingSendCmd(new ReqParameter2()
|
|||
|
|
{
|
|||
|
|
AFN = AFN.查询参数,
|
|||
|
|
FunCode = (int)CMasterStationFunCode.请求2级数据,
|
|||
|
|
A = "322009872",
|
|||
|
|
Seq = new Seq()
|
|||
|
|
{
|
|||
|
|
TpV = TpV.附加信息域中无时间标签,
|
|||
|
|
FIRFIN = FIRFIN.单帧,
|
|||
|
|
CON = CON.不需要对该帧进行确认,
|
|||
|
|
PRSEQ = 2,
|
|||
|
|
},
|
|||
|
|
MSA = 13,
|
|||
|
|
Pn = 0,
|
|||
|
|
Fn = 10
|
|||
|
|
}, new List<int>() { 1, 2 });
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool ActivePowerIndicationReading()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//var str = "68A600A6006888203290261A0A6200000201010001000100621E426622082431000000000000040300000000000000CA16";
|
|||
|
|
//var cmdResult = new BuildCommand().AnalysisCmd(str);
|
|||
|
|
//if(cmdResult != null)
|
|||
|
|
//{
|
|||
|
|
// var list = new BuildCommand().AnalysisAFN04F10DataUnit(cmdResult.HexDatas);
|
|||
|
|
//}
|
|||
|
|
HexStringExtensions.BuildSendCommandBytes(new ReqParameter2()
|
|||
|
|
{
|
|||
|
|
AFN = AFN.请求实时数据,
|
|||
|
|
FunCode = (int)CMasterStationFunCode.请求2级数据,
|
|||
|
|
A = "322009872",
|
|||
|
|
Seq = new Seq()
|
|||
|
|
{
|
|||
|
|
TpV = TpV.附加信息域中无时间标签,
|
|||
|
|
FIRFIN = FIRFIN.单帧,
|
|||
|
|
CON = CON.不需要对该帧进行确认,
|
|||
|
|
PRSEQ = 2,
|
|||
|
|
},
|
|||
|
|
MSA = 13,
|
|||
|
|
Pn = 1,
|
|||
|
|
Fn = 129
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
//HexStringExtensions.AmmeterValveControl("312408006642", "", "000000", true);
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|