1、增加命令发送通道选择
2、d3f0回应答d3f1 3、增加d3f0新字段(串口异常统计)解析
This commit is contained in:
parent
9a95f3d0aa
commit
9683dfc8a9
@ -9,6 +9,9 @@ public interface RtcmClient {
|
||||
@PostMapping("/config")
|
||||
HttpResp config(@RequestParam(name = "deviceId") String deviceId, @RequestParam(name = "configuration") String configData);
|
||||
|
||||
@PostMapping("/config_by_udp")
|
||||
HttpResp configByUdp(@RequestParam(name = "deviceId") String deviceId, @RequestParam(name = "configuration") String configData);
|
||||
|
||||
@PostMapping("/device_param_changed")
|
||||
HttpResp deviceParamChanged(@RequestParam(name = "deviceId") String deviceId,@RequestParam(name = "oldParentId") String oldParentId);
|
||||
|
||||
|
||||
@ -49,6 +49,9 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
||||
Device device = deviceService.findByDeviceId(message.getId());
|
||||
if(device == null) return null;
|
||||
|
||||
//应答
|
||||
sendD3F1Ack(device);
|
||||
|
||||
// 检查是否需要对设备的F9P进行断电操作
|
||||
checkAndSendF9PPowerOffCommand(device);
|
||||
// 补齐tenantId
|
||||
@ -120,4 +123,14 @@ public class D3F0SelfCheckMessageExecutor implements Executor<D3F0SelfCheckMessa
|
||||
rtcmClient.config(device.getDeviceId(), sendCmd);
|
||||
saveMsg(device.getDeviceId(), device.getTenantId(),0xD313, sendCmd, true);
|
||||
}
|
||||
|
||||
void sendD3F1Ack(Device device){
|
||||
int flag = 0xD3F1;
|
||||
short len = (short) (4);
|
||||
String sendCmd = Integer.toHexString(flag)+
|
||||
HexUtil.Short2HexString(len)+
|
||||
HexUtil.Int2HexString(Integer.parseInt(device.getDeviceId()));
|
||||
|
||||
rtcmClient.config(device.getDeviceId(), sendCmd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,6 +68,29 @@ public class D3F0SelfCheckMessage extends BaseMessage {
|
||||
auxInfo = auxInfo + " last active time:"+
|
||||
year+"-"+month+"-"+day+" "+hour+":"+munite;
|
||||
}
|
||||
if(src.readableBytes()>=14){
|
||||
int uart1Exception = src.readUnsignedShort();
|
||||
int uart2Exception = src.readUnsignedShort();
|
||||
int dtuException = src.readUnsignedShort();
|
||||
long lastDtuErrDate = src.readUnsignedInt();
|
||||
long lastDtuErrTime = src.readUnsignedInt();
|
||||
if(uart1Exception>0) {
|
||||
auxInfo = auxInfo + " uart1 err: "+uart1Exception;
|
||||
}
|
||||
if(uart2Exception>0) {
|
||||
auxInfo = auxInfo + " uart2 err: "+uart2Exception;
|
||||
}
|
||||
if(lastDtuErrDate!=0){
|
||||
auxInfo = auxInfo + " last dtu err state: "+dtuException;
|
||||
short year = (short) ((lastDtuErrDate>>16)&0xFF);
|
||||
short month = (short) ((lastDtuErrDate>>8)&0xFF);
|
||||
short day = (short) (lastDtuErrDate&0xFF);
|
||||
byte hour = (byte) (lastDtuErrTime/3600);
|
||||
byte munite = (byte) (lastDtuErrTime/60 - hour*60);
|
||||
auxInfo = auxInfo + " time: "+
|
||||
year+"-"+month+"-"+day+" "+hour+":"+munite;
|
||||
}
|
||||
}
|
||||
|
||||
// read 会移动 bytebuf 的指针,所以保存原始码流需要将此指针挑拨回开始处
|
||||
src.readerIndex(0);
|
||||
|
||||
@ -70,6 +70,33 @@ public class ApiController {
|
||||
return resp;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/config_by_udp")
|
||||
public HttpResp configByUdp(String deviceId, String configuration) {
|
||||
Map<String, Object> status = new HashMap<>();
|
||||
HttpResp resp = new HttpResp();
|
||||
DeviceChannel deviceChannel = OnlineChannels.INSTANCE.getDataChannel(deviceId);
|
||||
|
||||
if(deviceChannel!=null){
|
||||
status.put("status", "Online");
|
||||
// send command
|
||||
ByteBuf buf = Unpooled.buffer();
|
||||
byte[] data = getBinaryData(ConfigDataTypeEnum.HEX, configuration);
|
||||
logger.info("send command:{}", configuration);
|
||||
buf.writeBytes(data);
|
||||
deviceChannel.writeAndFlush(buf);
|
||||
}
|
||||
|
||||
if (status.isEmpty()) {
|
||||
status.put("status", "Offline");
|
||||
resp.setCode(HttpResp.HTTP_RSP_FAILED);
|
||||
resp.setResponseMessage("Offline.");
|
||||
} else {
|
||||
resp.setResponseMessage("Command sent.");
|
||||
}
|
||||
resp.setResponseObject(status);
|
||||
return resp;
|
||||
}
|
||||
|
||||
@PostMapping("/device_param_changed")
|
||||
public HttpResp deviceParamChanged(String deviceId, String oldParentId) {
|
||||
// 更新设备缓存
|
||||
|
||||
@ -60,7 +60,8 @@ public class CmdLineController extends BasicController{
|
||||
public HttpResult configCmd(HttpSession session,
|
||||
@RequestParam("tx_win") String cmd,
|
||||
@RequestParam("device_id") String deviceId,
|
||||
@RequestParam("cmd_type") int cmdType) {
|
||||
@RequestParam("cmd_type") int cmdType,
|
||||
@RequestParam("send_channel") int sendChannel) {
|
||||
String sendCmd = cmd.replaceAll(" +","");
|
||||
short len = 0;
|
||||
int msgType = 0xD310 + cmdType;
|
||||
@ -75,7 +76,10 @@ public class CmdLineController extends BasicController{
|
||||
sendCmd = Integer.toHexString(msgType) + HexUtil.Short2HexString(len)+
|
||||
HexUtil.Int2HexString(Integer.parseInt(deviceId))+sendCmd;
|
||||
}
|
||||
HttpResp<HashMap<String, Object>> rsp = rtcmClient.config(deviceId,sendCmd);
|
||||
HttpResp<HashMap<String, Object>> rsp;
|
||||
if(sendChannel == 0)
|
||||
rsp = rtcmClient.config(deviceId,sendCmd);
|
||||
else rsp = rtcmClient.configByUdp(deviceId,sendCmd);
|
||||
|
||||
String txInfo = "TX "+ dateFormat.format(System.currentTimeMillis())+
|
||||
" "+deviceId+" "+sendCmd;
|
||||
|
||||
@ -53,6 +53,15 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">发送通道</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="send_channel" id="send_channel" lay-filter="send_channel">
|
||||
<option value="0">管理通道</option>
|
||||
<option value="1">数据通道</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-block" style="float:right">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user