122 lines
4.2 KiB
C#
122 lines
4.2 KiB
C#
using JiShe.CollectBus.Common.Enums;
|
|
using JiShe.CollectBus.Common.Extensions;
|
|
using JiShe.CollectBus.Common.Models;
|
|
using JiShe.CollectBus.RabbitMQ.Senders;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace JiShe.CollectBus.Host.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("[controller]/[action]")]
|
|
public class CommandController : ControllerBase
|
|
{
|
|
private readonly ILogger<CommandController> _logger;
|
|
private readonly INSender _nSender;
|
|
|
|
public CommandController(INSender nSender, ILogger<CommandController> logger)
|
|
{
|
|
_nSender = nSender;
|
|
_logger = logger;
|
|
}
|
|
|
|
[HttpGet(Name = "AmmeterParameterSend")]
|
|
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;
|
|
}
|
|
|
|
[HttpGet(Name = "AmmeterParameterReading")]
|
|
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;
|
|
}
|
|
|
|
[HttpGet(Name = "ActivePowerIndicationReading")]
|
|
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;
|
|
}
|
|
|
|
}
|
|
}
|