热流器心跳判断功能码校验

This commit is contained in:
易焱 2020-06-27 21:44:19 +08:00
parent 9039f2196e
commit 7947f18e96
4 changed files with 32 additions and 35 deletions

View File

@ -37,7 +37,7 @@ public class ScheduleJob {
*/
public void addJob(JobGroup jobGroup){
try {
log.info(String.format("添加任务:%s.%s",jobGroup.getJobName(),jobGroup.getTriggerName()));
// log.info(String.format("添加任务:%s.%s",jobGroup.getJobName(),jobGroup.getTriggerName()));
// log.info("添加任务:{}.{}",jobGroup.getJobName(),jobGroup.getTriggerName());
//任务
JobDetail jobDetail= JobBuilder.newJob(ExecuteJob.class)
@ -63,7 +63,7 @@ public class ScheduleJob {
*/
public void deleteJob(JobGroup jobGroup){
try {
log.info(String.format("移除任务:%s.%s",jobGroup.getJobName(),jobGroup.getTriggerName()));
// log.info(String.format("移除任务:%s.%s",jobGroup.getJobName(),jobGroup.getTriggerName()));
//触发器
TriggerKey triggerKey = TriggerKey.triggerKey(jobGroup.getTriggerName(),jobGroup.getTriggerGroup());
//停止触发器

View File

@ -100,17 +100,22 @@ public class SomeServer {
} else {
deviceService.save(heater);
}
Integer status = heaterPushStatus.get(macAddress);
//当前水流量不正常 并且更新过正常水流标记 或者是第一次出现没有水流
if (heater.getPh() != 499 && ((status != null && status.intValue() == 2) || status == null)) {
//已推送标记
heaterPushStatus.put(macAddress, 1);
pushNotifcationByPh(macAddress,PushTypeEnum.ph_warn.getValue(),"没有水流, 请及时查看!");
} else {
if (heater.getPh() == 499) {
heaterPushStatus.put(macAddress, 2);
//功能码
if (heater.getCheck_code() == 5 || heater.getCheck_code() == 6 || heater.getCheck_code() == 8) {
Integer status = heaterPushStatus.get(macAddress);
//当前水流量不正常 并且更新过正常水流标记 或者是第一次出现没有水流
if (heater.getPh() != 499 && ((status != null && status.intValue() == 2) || status == null)) {
//已推送标记
heaterPushStatus.put(macAddress, 1);
log.info(heater.toString());
pushNotifcationByPh(macAddress,PushTypeEnum.ph_warn.getValue(),"没有水流, 请及时查看!");
} else {
if (heater.getPh() == 499) {
heaterPushStatus.put(macAddress, 2);
}
}
}
//设备重新连接上则移除延时推送的任务
JobGroup jobGroup = new JobGroup();
jobGroup.setJobName(macAddress);
@ -120,10 +125,15 @@ public class SomeServer {
} else if (message instanceof BackBytes45) {
BackBytes45 backBytes45 = (BackBytes45) message;
String macAddress = ByteUtil.bytesToHexString(backBytes45.getSrc());
//需要推送预警
if (backBytes45.getHumidity() == 2) {
pushNotifcationByPh(macAddress,PushTypeEnum.water_warn.getValue(),"水位预警, 请及时查看!");
System.out.println("macAddress : " + macAddress + ", 水位预警 : " + backBytes45);
if (backBytes45.getCheck_code() == 3 ||
backBytes45.getCheck_code() == 5 ||
backBytes45.getCheck_code() == 6 ||
backBytes45.getCheck_code() == 8) {
//需要推送预警
if (backBytes45.getHumidity() == 2) {
log.info("macAddress : " + macAddress + ", 水位预警 : " + backBytes45);
pushNotifcationByPh(macAddress,PushTypeEnum.water_warn.getValue(),"水位预警, 请及时查看!");
}
}
sendToApp(session, macAddress, backBytes45.getByteMessage());
}

View File

@ -105,10 +105,12 @@ public class ServerDecode implements ProtocolDecoder {
//boolean bln = CRC16.calcCrc16(ByteUtil.hexStringToBytes(hexDump));
switch (length) {
case 31: {
log.info("length:[" + length + "];limit:[" + buf.limit() + "],HexDump:[" + buf.getHexDump() + "]");
functionBackHeater(bytes,buf, out);
break;
}
case 45: {
log.info("length:[" + length + "];limit:[" + buf.limit() + "],HexDump:[" + buf.getHexDump() + "]");
functionBack2f(bytes, buf, out);
break;
}
@ -382,8 +384,6 @@ public class ServerDecode implements ProtocolDecoder {
BackFunctionCodeHeater model = new BackFunctionCodeHeater();
model.setByteMessage(bytes);
buf.getHexDump();
//15字节头
model.setType(buf.get());
model.setCheck_code(buf.get());
@ -398,9 +398,7 @@ public class ServerDecode implements ProtocolDecoder {
}
model.setDest(dest);
model.setRemote_len(buf.get());
model.setMainNumber(buf.get());
model.setMainSwitch(buf.get());
model.setMainSwitch(buf.getShort());
model.setControlState(buf.get());
model.setWaterTemperature(buf.getShort());
model.setHeatingTemperature(buf.getShort());

View File

@ -15,9 +15,7 @@ public class BackFunctionCodeHeater extends HeadModel implements Serializable {
private byte[] byteMessage;
private byte mainNumber;
private byte mainSwitch;
private short mainSwitch;
private byte controlState;
@ -41,19 +39,11 @@ public class BackFunctionCodeHeater extends HeadModel implements Serializable {
this.byteMessage = byteMessage;
}
public byte getMainNumber() {
return mainNumber;
}
public void setMainNumber(byte mainNumber) {
this.mainNumber = mainNumber;
}
public byte getMainSwitch() {
public short getMainSwitch() {
return mainSwitch;
}
public void setMainSwitch(byte mainSwitch) {
public void setMainSwitch(short mainSwitch) {
this.mainSwitch = mainSwitch;
}
@ -116,8 +106,7 @@ public class BackFunctionCodeHeater extends HeadModel implements Serializable {
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("BackFunctionCodeHeater{");
sb.append("mainNumber=").append(mainNumber);
sb.append(", mainSwitch=").append(mainSwitch);
sb.append("mainSwitch=").append(mainSwitch);
sb.append(", controlState=").append(controlState);
sb.append(", waterTemperature=").append(waterTemperature);
sb.append(", heatingTemperature=").append(heatingTemperature);