diff --git a/.editorconfig b/.editorconfig index 1422ed50..e3e5ff81 100644 --- a/.editorconfig +++ b/.editorconfig @@ -35,6 +35,7 @@ indent_size = 4 [{*.js,*.css,*.ts,*.tsx,*.jsx,*.graphql,*.ns}] indent_style = space indent_size = 2 +trim_trailing_whitespace = true [core/**/*.js] # CouchDB design document JavaScript files get special treatment indent_size = 4 diff --git a/client/src/main/java/me/retrodaredevil/solarthing/actions/rover/RoverBoostVoltageActionNode.java b/client/src/main/java/me/retrodaredevil/solarthing/actions/rover/RoverBoostVoltageActionNode.java deleted file mode 100644 index 93aeff45..00000000 --- a/client/src/main/java/me/retrodaredevil/solarthing/actions/rover/RoverBoostVoltageActionNode.java +++ /dev/null @@ -1,50 +0,0 @@ -package me.retrodaredevil.solarthing.actions.rover; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonTypeName; -import me.retrodaredevil.action.Action; -import me.retrodaredevil.action.SimpleAction; -import me.retrodaredevil.action.node.ActionNode; -import me.retrodaredevil.action.node.environment.ActionEnvironment; -import me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated(forRemoval = true) -@JsonTypeName("roverboostvoltage") -public class RoverBoostVoltageActionNode implements ActionNode { - private static final Logger LOGGER = LoggerFactory.getLogger(RoverBoostVoltageActionNode.class); - - private final int boostVoltageRaw; - private final boolean not; - private final RoverMatcher roverMatcher; - - @JsonCreator - public RoverBoostVoltageActionNode( - @JsonProperty(value = "voltageraw", required = true) int boostVoltageRaw, - @JsonProperty("not") Boolean not, - @JsonProperty("fragment") Integer fragmentId, - @JsonProperty("number") Integer number - ) { - this.boostVoltageRaw = boostVoltageRaw; - this.not = Boolean.TRUE.equals(not); - roverMatcher = RoverMatcher.createFromRaw(fragmentId, number); - } - @Override - public Action createAction(ActionEnvironment actionEnvironment) { - RoverMatcher.Provider provider = roverMatcher.createProvider(actionEnvironment.getInjectEnvironment()); - return new SimpleAction(false) { - @Override - protected void onUpdate() { - super.onUpdate(); - RoverStatusPacket roverStatusPacket = provider.get(); - if (roverStatusPacket == null) { - LOGGER.warn("Couldn't find rover status packet!"); - return; - } - setDone((roverStatusPacket.getBoostChargingVoltageRaw() == boostVoltageRaw) != not); - } - }; - } -} diff --git a/client/src/main/java/me/retrodaredevil/solarthing/program/ActionUtil.java b/client/src/main/java/me/retrodaredevil/solarthing/program/ActionUtil.java index 7a78e300..b06fc62b 100644 --- a/client/src/main/java/me/retrodaredevil/solarthing/program/ActionUtil.java +++ b/client/src/main/java/me/retrodaredevil/solarthing/program/ActionUtil.java @@ -50,8 +50,6 @@ public static ObjectMapper registerActionNodes(ObjectMapper objectMapper) { RoverModbusActionNode.class, RoverLoadActionNode.class, RoverBoostSetActionNode.class, - // RoverBoostVoltageActionNode commented out until we confirm that replacing it works as intended -// RoverBoostVoltageActionNode.class, TracerModbusActionNode.class, TracerLoadActionNode.class, diff --git a/config_templates/actions-ns/check_boost.ns b/config_templates/actions-ns/check_boost.ns index f3d6cc7f..e8623c10 100644 --- a/config_templates/actions-ns/check_boost.ns +++ b/config_templates/actions-ns/check_boost.ns @@ -1,13 +1,15 @@ scope : queue { + // The expression will evaluate to either [], [true], or [false] + init-exp is_normal_voltage : eq(rover-boost-voltage(fragment=2), const(148)) act set_normal : race { - racer(roverboostvoltage(voltageraw=148, fragment="2", not=true)) : call set_normal_command - racer(roverboostvoltage(voltageraw=148, fragment="2")) : log("Boost voltage is normal!", debug=true) + racer(any : not : ref is_normal_voltage) : call set_normal_command + racer(any : ref is_normal_voltage) : log("Boost voltage is normal!", debug=true) racer(pass) : log "Rover not found!" } act set_equalize : race { - racer(roverboostvoltage(voltageraw=148, fragment="2", not=true)) : log("Already equalizing", debug=true) - racer(roverboostvoltage(voltageraw=148, fragment="2")) : call set_equalize_command + racer(any : not : ref is_normal_voltage) : log("Already equalizing", debug=true) + racer(any : ref is_normal_voltage) : call set_equalize_command racer(pass) : log "Rover not found!" } act set_normal_command : sendopen( diff --git a/config_templates/actions/check_boost.json b/config_templates/actions/check_boost.json deleted file mode 100644 index 6de5c560..00000000 --- a/config_templates/actions/check_boost.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "type": "declaration", - "main": { - "type": "withlock", - "name": "check_boost", - "action": { "type": "call", "name": "check"}, - "ontimeout": { "type": "log", "message": "Something else had a lock on check_boost"} - }, - "check": { - "type": "race", - "racers": [ - [{ "type": "fxoperational", "mode": "eq"}, { "type": "call", "name": "set_equalize"}], - [{ "type": "fxoperational", "mode": "eq", "not": true}, { "type": "call", "name": "set_normal"}], - [{ "type": "pass" }, { "type": "log", "message": "There must be no FX devices!"}] - ] - }, - "set_normal": { - "type": "race", - "racers": [ - [{ "type": "roverboostvoltage", "voltageraw": "148", "fragment": 2, "not": true}, { "type": "call", "name": "set_normal_command"}], - [{ "type": "roverboostvoltage", "voltageraw": "148", "fragment": 2}, { "type": "log", "message": "Boost voltage is normal!", "debug": true}], - [{ "type": "pass" }, { "type": "log", "message": "Rover not found!"}] - ] - }, - "set_equalize": { - "type": "race", - "racers": [ - [{ "type": "roverboostvoltage", "voltageraw": "148", "fragment": 2, "not": true}, { "type": "log", "message": "Already equalizing", "debug": true }], - [{ "type": "roverboostvoltage", "voltageraw": "148", "fragment": 2}, { "type": "call", "name": "set_equalize_command"}], - [{ "type": "pass" }, { "type": "log", "message": "Rover not found!"}] - ] - }, - "set_normal_command": { - "type": "sendopen", - "directory": ".data/keys", - "targets": [2], - "sender": "nasplex", - "data": { - "type": "requestcommand", - "command": "SET BOOST NORMAL" - } - }, - "set_equalize_command": { - "type": "sendopen", - "directory": ".data/keys", - "targets": [2], - "sender": "nasplex", - "data": { - "type": "requestcommand", - "command": "SET BOOST EQUALIZE" - } - } -}