Search in sources :

Example 1 with SimpleAction

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

the class RequireFullOutputActionNode method createAction.

@Override
public Action createAction(ActionEnvironment actionEnvironment) {
    LatestFragmentedPacketGroupEnvironment latestPacketGroupEnvironment = actionEnvironment.getInjectEnvironment().get(LatestFragmentedPacketGroupEnvironment.class);
    return new SimpleAction(false) {

        @Override
        protected void onUpdate() {
            super.onUpdate();
            FragmentedPacketGroup latestPacketGroup = latestPacketGroupEnvironment.getFragmentedPacketGroupProvider().getPacketGroup();
            if (latestPacketGroup != null) {
                setDone(isFullOutput(latestPacketGroup));
            }
        }
    };
}
Also used : FragmentedPacketGroup(me.retrodaredevil.solarthing.packets.collection.FragmentedPacketGroup) LatestFragmentedPacketGroupEnvironment(me.retrodaredevil.solarthing.actions.environment.LatestFragmentedPacketGroupEnvironment) SimpleAction(me.retrodaredevil.action.SimpleAction)

Example 2 with SimpleAction

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

the class FlagActionNode method createAction.

@Override
public Action createAction(ActionEnvironment actionEnvironment) {
    AlterPacketsEnvironment alterPacketsEnvironment = actionEnvironment.getInjectEnvironment().get(AlterPacketsEnvironment.class);
    AlterPacketsProvider provider = alterPacketsEnvironment.getAlterPacketsProvider();
    return new SimpleAction(false) {

        @Override
        protected void onUpdate() {
            super.onUpdate();
            List<VersionedPacket<StoredAlterPacket>> packets = provider.getPackets();
            if (packets != null) {
                Instant now = Instant.now();
                if (FlagUtil.isFlagActive(now, flagName, packets.stream().map(VersionedPacket::getPacket)) != not) {
                    setDone(true);
                }
            }
        }
    };
}
Also used : AlterPacketsProvider(me.retrodaredevil.solarthing.AlterPacketsProvider) VersionedPacket(me.retrodaredevil.solarthing.database.VersionedPacket) Instant(java.time.Instant) AlterPacketsEnvironment(me.retrodaredevil.solarthing.actions.environment.AlterPacketsEnvironment) SimpleAction(me.retrodaredevil.action.SimpleAction)

Example 3 with SimpleAction

use of me.retrodaredevil.action.SimpleAction 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);
            }
        }
    };
}
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 4 with SimpleAction

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

the class RequiredIdentifierActionNode method createAction.

@Override
public Action createAction(ActionEnvironment actionEnvironment) {
    LatestFragmentedPacketGroupEnvironment latestPacketGroupEnvironment = actionEnvironment.getInjectEnvironment().get(LatestFragmentedPacketGroupEnvironment.class);
    return new SimpleAction(false) {

        @Override
        protected void onUpdate() {
            super.onUpdate();
            FragmentedPacketGroup packetGroup = latestPacketGroupEnvironment.getFragmentedPacketGroupProvider().getPacketGroup();
            if (packetGroup == null) {
                return;
            }
            String reason = IdentifierUtil.getRequirementNotMetReason(requiredIdentifierMap, packetGroup);
            if (reason != null) {
                if (log) {
                    LOGGER.info("Requirement not met: " + reason);
                }
            } else {
                setDone(true);
            }
        }
    };
}
Also used : FragmentedPacketGroup(me.retrodaredevil.solarthing.packets.collection.FragmentedPacketGroup) LatestFragmentedPacketGroupEnvironment(me.retrodaredevil.solarthing.actions.environment.LatestFragmentedPacketGroupEnvironment) SimpleAction(me.retrodaredevil.action.SimpleAction)

Example 5 with SimpleAction

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

the class MateCommandWaitActionNode method createAction.

@Override
public Action createAction(ActionEnvironment actionEnvironment) {
    MateCommandEnvironment mateCommandEnvironment = actionEnvironment.getInjectEnvironment().get(MateCommandEnvironment.class);
    Queue<?> queue = mateCommandEnvironment.getQueue();
    return new SimpleAction(false) {

        @Override
        protected void onUpdate() {
            super.onUpdate();
            setDone(queue.isEmpty());
        }
    };
}
Also used : MateCommandEnvironment(me.retrodaredevil.solarthing.actions.environment.MateCommandEnvironment) 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