Search in sources :

Example 1 with PacketListReceiverHandler

use of me.retrodaredevil.solarthing.program.PacketListReceiverHandler in project solarthing by wildmountainfarms.

the class ExecutingCommandFeedbackActionNode method createAction.

@Override
public Action createAction(ActionEnvironment actionEnvironment) {
    SourceEnvironment sourceEnvironment = actionEnvironment.getInjectEnvironment().get(SourceEnvironment.class);
    EventReceiverEnvironment eventReceiverEnvironment = actionEnvironment.getInjectEnvironment().get(EventReceiverEnvironment.class);
    OpenSource source = sourceEnvironment.getSource();
    PacketListReceiverHandler packetListReceiverHandler = eventReceiverEnvironment.getEventPacketListReceiverHandler();
    List<Packet> packets = Arrays.asList(new ImmutableExecutionFeedbackPacket(message, category, new OpenSourceExecutionReason(source)));
    return Actions.createRunOnce(() -> {
        LOGGER.debug("Going to upload an execution feedback packet.");
        Instant now = Instant.now();
        packetListReceiverHandler.uploadSimple(now, packets);
    });
}
Also used : Packet(me.retrodaredevil.solarthing.packets.Packet) ImmutableExecutionFeedbackPacket(me.retrodaredevil.solarthing.type.event.feedback.ImmutableExecutionFeedbackPacket) SourceEnvironment(me.retrodaredevil.solarthing.actions.environment.SourceEnvironment) EventReceiverEnvironment(me.retrodaredevil.solarthing.actions.environment.EventReceiverEnvironment) OpenSource(me.retrodaredevil.solarthing.type.open.OpenSource) ImmutableExecutionFeedbackPacket(me.retrodaredevil.solarthing.type.event.feedback.ImmutableExecutionFeedbackPacket) Instant(java.time.Instant) PacketListReceiverHandler(me.retrodaredevil.solarthing.program.PacketListReceiverHandler) OpenSourceExecutionReason(me.retrodaredevil.solarthing.reason.OpenSourceExecutionReason)

Aggregations

Instant (java.time.Instant)1 EventReceiverEnvironment (me.retrodaredevil.solarthing.actions.environment.EventReceiverEnvironment)1 SourceEnvironment (me.retrodaredevil.solarthing.actions.environment.SourceEnvironment)1 Packet (me.retrodaredevil.solarthing.packets.Packet)1 PacketListReceiverHandler (me.retrodaredevil.solarthing.program.PacketListReceiverHandler)1 OpenSourceExecutionReason (me.retrodaredevil.solarthing.reason.OpenSourceExecutionReason)1 ImmutableExecutionFeedbackPacket (me.retrodaredevil.solarthing.type.event.feedback.ImmutableExecutionFeedbackPacket)1 OpenSource (me.retrodaredevil.solarthing.type.open.OpenSource)1