Search in sources :

Example 6 with SimpleAction

use of me.retrodaredevil.action.SimpleAction in project solarthing by wildmountainfarms.

the class RoverBoostVoltageActionNode method createAction.

@Override
public Action createAction(ActionEnvironment actionEnvironment) {
    RoverMatcher.Provider provider = roverMatcher.createProvider(actionEnvironment.getInjectEnvironment());
    provider.validateData();
    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);
        }
    };
}
Also used : RoverStatusPacket(me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket) SimpleAction(me.retrodaredevil.action.SimpleAction)

Example 7 with SimpleAction

use of me.retrodaredevil.action.SimpleAction 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);
            }
        }
    };
}
Also used : PacketGroupProvider(me.retrodaredevil.solarthing.PacketGroupProvider) PacketGroup(me.retrodaredevil.solarthing.packets.collection.PacketGroup) FXStatusPacket(me.retrodaredevil.solarthing.solar.outback.fx.FXStatusPacket) LatestPacketGroupEnvironment(me.retrodaredevil.solarthing.actions.environment.LatestPacketGroupEnvironment) SimpleAction(me.retrodaredevil.action.SimpleAction)

Example 8 with SimpleAction

use of me.retrodaredevil.action.SimpleAction 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;
            }
        }
    };
}
Also used : PacketGroupProvider(me.retrodaredevil.solarthing.PacketGroupProvider) PacketGroup(me.retrodaredevil.solarthing.packets.collection.PacketGroup) FXStatusPacket(me.retrodaredevil.solarthing.solar.outback.fx.FXStatusPacket) LatestPacketGroupEnvironment(me.retrodaredevil.solarthing.actions.environment.LatestPacketGroupEnvironment) SimpleAction(me.retrodaredevil.action.SimpleAction)

Aggregations

SimpleAction (me.retrodaredevil.action.SimpleAction)8 PacketGroupProvider (me.retrodaredevil.solarthing.PacketGroupProvider)3 LatestPacketGroupEnvironment (me.retrodaredevil.solarthing.actions.environment.LatestPacketGroupEnvironment)3 PacketGroup (me.retrodaredevil.solarthing.packets.collection.PacketGroup)3 FXStatusPacket (me.retrodaredevil.solarthing.solar.outback.fx.FXStatusPacket)3 LatestFragmentedPacketGroupEnvironment (me.retrodaredevil.solarthing.actions.environment.LatestFragmentedPacketGroupEnvironment)2 FragmentedPacketGroup (me.retrodaredevil.solarthing.packets.collection.FragmentedPacketGroup)2 Instant (java.time.Instant)1 AlterPacketsProvider (me.retrodaredevil.solarthing.AlterPacketsProvider)1 AlterPacketsEnvironment (me.retrodaredevil.solarthing.actions.environment.AlterPacketsEnvironment)1 MateCommandEnvironment (me.retrodaredevil.solarthing.actions.environment.MateCommandEnvironment)1 VersionedPacket (me.retrodaredevil.solarthing.database.VersionedPacket)1 RoverStatusPacket (me.retrodaredevil.solarthing.solar.renogy.rover.RoverStatusPacket)1