use of me.retrodaredevil.solarthing.PacketGroupProvider in project solarthing by wildmountainfarms.
the class ACModeActionNode method createAction.
@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();
PacketGroup packetGroup = packetGroupProvider.getPacketGroup();
if (packetGroup == null) {
LOGGER.warn("packetGroup is null!");
return;
}
FXStatusPacket fxStatusPacket = OutbackUtil.getMasterFX(packetGroup);
if (fxStatusPacket == null) {
LOGGER.warn("No master FX Status Packet!");
} else {
setDone((fxStatusPacket.getACMode() == acMode) == !not);
}
}
};
}
use of me.retrodaredevil.solarthing.PacketGroupProvider in project solarthing by wildmountainfarms.
the class FXOperationalModeActionNode method createAction.
@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();
PacketGroup packetGroup = packetGroupProvider.getPacketGroup();
if (packetGroup == null) {
// packetGroup will only be null in the automation program if a query fails or something. This should never happen in the mate program
LOGGER.warn("packetGroup is null!");
return;
}
FXStatusPacket fxStatusPacket = OutbackUtil.getMasterFX(packetGroup);
if (fxStatusPacket == null) {
LOGGER.warn("No master FX Status Packet!");
} else {
setDone((fxStatusPacket.getOperationalMode() == operationalMode) == !not);
}
}
};
}
use of me.retrodaredevil.solarthing.PacketGroupProvider in project solarthing by wildmountainfarms.
the class AuxStateActionNode method createAction.
@Override
public Action createAction(ActionEnvironment actionEnvironment) {
LatestPacketGroupEnvironment latestPacketGroupEnvironment = actionEnvironment.getInjectEnvironment().get(LatestPacketGroupEnvironment.class);
PacketGroupProvider packetGroupProvider = latestPacketGroupEnvironment.getPacketGroupProvider();
return new SimpleAction(false) {
/**
* A simple variable to prevent spamming of the log file
*/
private boolean hadFX = true;
@Override
protected void onUpdate() {
super.onUpdate();
PacketGroup packetGroup = packetGroupProvider.getPacketGroup();
if (packetGroup == null) {
LOGGER.warn("packetGroup is null!");
return;
}
FXStatusPacket fxStatusPacket = OutbackUtil.getMasterFX(packetGroup);
if (fxStatusPacket == null) {
if (hadFX) {
LOGGER.warn("No master FX Status Packet!");
}
hadFX = false;
} else {
setDone(fxStatusPacket.isAuxOn() == on);
if (!hadFX) {
LOGGER.info("We now have a master FX Status Packet");
}
hadFX = true;
}
}
};
}
Aggregations