Commit 0b2c4ba0 authored by duanruiming's avatar duanruiming

[update] 信号机心跳测试

parent 9927b379
...@@ -10,7 +10,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -10,7 +10,7 @@ import org.apache.commons.lang3.StringUtils;
@Getter @Getter
public enum CommandResultSign { public enum CommandResultSign {
HEARTBEAT("55ab", "heartBeatService"), HEARTBEAT("7e00", "heartBeatService"),
GET_DEVICE_INFO("2001", "getDeviceInfoService"), GET_DEVICE_INFO("2001", "getDeviceInfoService"),
GET_SIGNAL_BASE_INFO("2002","getBaseInfoService"), GET_SIGNAL_BASE_INFO("2002","getBaseInfoService"),
GET_LIGHTS_GROUP_INFO("2003", "getLightsGroupInfoService"), GET_LIGHTS_GROUP_INFO("2003", "getLightsGroupInfoService"),
......
package net.wanji.com.netty.response.impl; package net.wanji.com.netty.response.impl;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.wanji.com.common.constants.Constants;
import net.wanji.com.netty.NettyClient; import net.wanji.com.netty.NettyClient;
import net.wanji.com.netty.pojo.CommandPojo; import net.wanji.com.netty.pojo.CommandPojo;
import net.wanji.com.netty.response.CommandResponseFactory; import net.wanji.com.netty.response.CommandResponseFactory;
import net.wanji.com.pojo.netty.MessageResultPojo; import net.wanji.com.pojo.netty.MessageResultPojo;
import net.wanji.com.util.CRC16Utils;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -22,13 +24,15 @@ public class HeartBeatService implements CommandResponseFactory { ...@@ -22,13 +24,15 @@ public class HeartBeatService implements CommandResponseFactory {
@Scheduled(fixedRate = 1000, initialDelay = 10 * 1000) @Scheduled(fixedRate = 1000, initialDelay = 10 * 1000)
public void heartbeat() { public void heartbeat() {
// String body = String.format("%02x", Constants.COMMAND_HEARTBEAT.length() / 2).concat(Constants.COMMAND_HEARTBEAT); String body = String.format("%02x", Constants.COMMAND_HEARTBEAT.length() / 2).concat(Constants.COMMAND_HEARTBEAT);
// String crc16HexStr = CRC16Utils.getCRC16HexStr(body); String crc16HexStr = CRC16Utils.getCRC16HexStr(body);
// String heartBeatRequest = Constants.buildMessageBody(body, crc16HexStr); String heartBeatRequest = Constants.buildMessageBody(body, crc16HexStr);
// MessageResultPojo resultPojo2 = NettyClient.sendMessage("10.102.1.204", 5050, heartBeatRequest, "55ab", 300); MessageResultPojo resultPojo2 = NettyClient.sendMessage("10.102.1.204", 4050, heartBeatRequest, "7e00", 300);
log.info("信号返回字符串:{}", resultPojo2.getHexMessageResult());
String str = "55ac00000000000017050f11060b0000000000000000000000000000000000";
MessageResultPojo resultPojo = NettyClient.sendMessage("10.102.1.204", 5050, str, "55ab", 300); // String str = "55ac00000000000017050f11060b0000000000000000000000000000000000";
log.info("信号返回字符串:{}", resultPojo.getHexMessageResult()); // MessageResultPojo resultPojo = NettyClient.sendMessage("10.102.1.204", 4050, str, "55ab", 300);
// log.info("信号返回字符串:{}", resultPojo.getHexMessageResult());
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment