|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.iflytop.gd.hardware.drivers; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.iflytop.gd.hardware.comm.modbus.ModbusMasterService; |
|
|
|
import com.iflytop.gd.hardware.type.driver.HeaterRodSlavedId; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
@ -65,7 +66,7 @@ public class HeaterRodDriver { |
|
|
|
throw new Exception("Failed to stop heater rod with ID: " + heaterRodId.name()); |
|
|
|
} |
|
|
|
|
|
|
|
log.info("Heater rod with ID: {} stopped.", heaterRodId.name()); |
|
|
|
log.info("{} stopped.", heaterRodId.name()); |
|
|
|
} |
|
|
|
|
|
|
|
public void setTemperature(HeaterRodSlavedId heaterRodId, double temperature) throws Exception { |
|
|
@ -77,7 +78,7 @@ public class HeaterRodDriver { |
|
|
|
throw new Exception("Failed to set temperature for heater rod with ID: " + heaterRodId.name()); |
|
|
|
} |
|
|
|
|
|
|
|
log.info("Heater rod with ID: {} started with temperature: {}", heaterRodId.name(), temperature); |
|
|
|
log.info("{} started with temperature: {}", heaterRodId.name(), temperature); |
|
|
|
} |
|
|
|
|
|
|
|
public double getTemperature(HeaterRodSlavedId heaterRodId) throws Exception { |
|
|
@ -86,15 +87,14 @@ public class HeaterRodDriver { |
|
|
|
|
|
|
|
short[] response = modbusMaster.readHoldingRegisters(slaveId, PV_ADDRESS, 1); |
|
|
|
if (response == null || response.length == 0) { |
|
|
|
throw new Exception("Failed to read temperature for heater rod with ID: " + heaterRodId.name()); |
|
|
|
throw new Exception(StrUtil.format("Failed to read temperature {}", heaterRodId.name())); |
|
|
|
} |
|
|
|
double temperature = response[0] / Math.pow(10, decimalPoint); |
|
|
|
log.info("GET temperature for heater rod with ID: " + heaterRodId.name()); |
|
|
|
log.info("{} GET temperature {}", heaterRodId.name(), temperature); |
|
|
|
return temperature; |
|
|
|
} |
|
|
|
|
|
|
|
// application |
|
|
|
|
|
|
|
// ==== ==== ==== ==== ==== ==== application ==== ==== ==== ==== ==== ==== |
|
|
|
public void open(HeaterRodSlavedId heaterRodId, double temperature) throws Exception { |
|
|
|
this.openPower(heaterRodId); |
|
|
|
this.setTemperature(heaterRodId, temperature); |
|
|
|