Skip to content

Commit

Permalink
Deleted classes, added auxstate action
Browse files Browse the repository at this point in the history
  • Loading branch information
retrodaredevil committed Jun 17, 2020
1 parent 6e511e7 commit 5c1477e
Show file tree
Hide file tree
Showing 15 changed files with 119 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import me.retrodaredevil.action.Action;
import me.retrodaredevil.solarthing.actions.environment.ActionEnvironment;
import me.retrodaredevil.solarthing.actions.mate.ACModeActionNode;
import me.retrodaredevil.solarthing.actions.mate.AuxStateActionNode;
import me.retrodaredevil.solarthing.actions.mate.MateCommandActionNode;
import me.retrodaredevil.solarthing.actions.mate.MateCommandWaitActionNode;

Expand All @@ -20,6 +21,7 @@
@JsonSubTypes.Type(RaceActionNode.class),

@JsonSubTypes.Type(ACModeActionNode.class),
@JsonSubTypes.Type(AuxStateActionNode.class),
@JsonSubTypes.Type(MateCommandActionNode.class),
@JsonSubTypes.Type(MateCommandWaitActionNode.class),
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
public class ACModeActionNode implements ActionNode {
private static final Logger LOGGER = LoggerFactory.getLogger(ACModeActionNode.class);
private final ACMode acMode;
private final boolean not;

@JsonCreator
public ACModeActionNode(@JsonProperty("mode") String mode) {
this(parseMode(mode));
public ACModeActionNode(@JsonProperty(value = "mode", required = true) String mode, @JsonProperty("not") Boolean not) {
this(parseMode(mode), Boolean.TRUE.equals(not));
}

public ACModeActionNode(ACMode acMode) {
public ACModeActionNode(ACMode acMode, boolean not) {
this.acMode = acMode;
this.not = not;
}
private static ACMode parseMode(String modeName) {
modeName = modeName.replaceAll(" ", "").toLowerCase();
Expand All @@ -53,7 +55,7 @@ protected void onUpdate() {
if (fxStatusPacket == null) {
LOGGER.warn("No master FX Status Packet!");
} else {
setDone(fxStatusPacket.getACMode() == acMode);
setDone((fxStatusPacket.getACMode() == acMode) == !not);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package me.retrodaredevil.solarthing.actions.mate;

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.solarthing.actions.ActionNode;
import me.retrodaredevil.solarthing.actions.PacketGroupProvider;
import me.retrodaredevil.solarthing.actions.environment.ActionEnvironment;
import me.retrodaredevil.solarthing.actions.environment.LatestPacketGroupEnvironment;
import me.retrodaredevil.solarthing.solar.outback.OutbackUtil;
import me.retrodaredevil.solarthing.solar.outback.fx.FXStatusPacket;
import me.retrodaredevil.solarthing.solar.outback.fx.MiscMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@JsonTypeName("auxstate")
public class AuxStateActionNode implements ActionNode {
private static final Logger LOGGER = LoggerFactory.getLogger(AuxStateActionNode.class);
private final boolean on;

@JsonCreator
public AuxStateActionNode(@JsonProperty(value = "on", required = true) boolean on) {
this.on = on;
}

@Override
public Action createAction(ActionEnvironment actionEnvironment) {
LatestPacketGroupEnvironment latestPacketGroupEnvironment = actionEnvironment.getInjectEnvironment().get(LatestPacketGroupEnvironment.class);
PacketGroupProvider packetGroupProvider = latestPacketGroupEnvironment.getPacketGroupProvider();
return new SimpleAction(false) {
@Override
protected void onUpdate() {
super.onUpdate();
FXStatusPacket fxStatusPacket = OutbackUtil.getMasterFX(packetGroupProvider.getPacketGroup());
if (fxStatusPacket == null) {
LOGGER.warn("No master FX Status Packet!");
} else {
setDone(fxStatusPacket.getMiscModes().contains(MiscMode.AUX_OUTPUT_ON) == on);
}
}
};

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import me.retrodaredevil.action.Action;
import me.retrodaredevil.action.ActionMultiplexer;
import me.retrodaredevil.action.Actions;
import me.retrodaredevil.solarthing.DataReceiver;
import me.retrodaredevil.solarthing.DataSource;
import me.retrodaredevil.solarthing.PacketGroupReceiver;
import me.retrodaredevil.solarthing.SolarThingConstants;
Expand Down
66 changes: 64 additions & 2 deletions config_templates/commands/generator_shut_off.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,82 @@
{ "type": "unlock", "name": "send_commands" }
]
},
"run_commands": {
"force_drop": {
"type": "queue",
"actions": [
{ "type": "matecommand", "command": "DROP" },
{ "type": "matecommandwait" },
{
"type": "race",
"racers": [
[{ "type": "acmode", "mode": "AC USE", "not": true }, { "type": "pass"}],
[{ "type": "waitms", "wait": 2300}, { "type": "call", "name": "force_drop"}]
]
}
]
},
"force_aux_on": {
"type": "queue",
"actions": [
{ "type": "matecommand", "command": "AUX ON" },
{ "type": "matecommandwait" },
{
"type": "race",
"racers": [
[{ "type": "auxstate", "on": true}, { "type": "pass"}],
[{ "type": "waitms", "wait": 2300}, { "type": "call", "name": "force_aux_on"}]
]
}
]
},
"force_aux_off": {
"type": "queue",
"actions": [
{ "type": "matecommand", "command": "AUX OFF" },
{ "type": "matecommandwait" },
{
"type": "race",
"racers": [
[{ "type": "auxstate", "on": false}, { "type": "pass"}],
[{ "type": "waitms", "wait": 2300}, { "type": "call", "name": "force_aux_off"}]
]
}
]
},
"run_commands": {
"type": "queue",
"actions": [
{
"type": "race",
"racers": [
[{ "type": "call", "name": "force_drop" }, { "type": "pass" }],
[{ "type": "waitms", "wait": 5300}, { "type": "pass" }]
]
},
{ "type": "waitms", "wait": 1000},
{
"type": "race",
"racers": [
[{ "type": "call", "name": "force_aux_on" }, { "type": "pass" }],
[{ "type": "waitms", "wait": 5300}, { "type": "pass" }]
]
},
{
"type": "race",
"racers": [
[{ "type": "acmode", "mode": "NO AC" }, { "type": "pass" }],
[{ "type": "waitms", "wait": 10000 }, { "type": "log", "message": "AC is still present!"}]
]
},
{ "type": "matecommand", "command": "AUX OFF"},
{ "type": "waitms", "wait": 500},
{
"type": "race",
"racers": [
[{ "type": "call", "name": "force_aux_off" }, { "type": "pass" }],
[{ "type": "waitms", "wait": 5300}, { "type": "pass" }]
]
},
{ "type": "waitms", "wait": 2000},
{ "type": "matecommand", "command": "USE"},
{ "type": "matecommandwait" },
{ "type": "log", "message": "Sent all commands!"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
*/
@JsonSubTypes({
@JsonSubTypes.Type(FXACModeChangePacket.class),
@JsonSubTypes.Type(FXDayEndPacket.class),
@JsonSubTypes.Type(MXDayEndPacket.class),
@JsonSubTypes.Type(MXRawDayEndPacket.class),
@JsonSubTypes.Type(FXAuxStateChangePacket.class),
@JsonSubTypes.Type(FXOperationalModeChangePacket.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

import com.fasterxml.jackson.annotation.JsonSubTypes;
import me.retrodaredevil.solarthing.solar.SolarPacket;
import me.retrodaredevil.solarthing.solar.outback.fx.charge.FXChargingPacket;
import me.retrodaredevil.solarthing.solar.outback.fx.extra.DailyFXPacket;
import me.retrodaredevil.solarthing.solar.outback.mx.extra.DailyMXPacket;

@JsonSubTypes({
@JsonSubTypes.Type(DailyFXPacket.class),
@JsonSubTypes.Type(DailyMXPacket.class),
@JsonSubTypes.Type(FXChargingPacket.class),
})
public interface SolarExtraPacket extends SolarPacket<SolarExtraPacketType> {
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5c1477e

Please sign in to comment.