Search in sources :

Example 6 with OpenSource

use of me.retrodaredevil.solarthing.type.open.OpenSource in project solarthing by wildmountainfarms.

the class RequestHeartbeatReceiver method receivePacketGroup.

@Override
public void receivePacketGroup(String sender, TargetPacketGroup packetGroup) {
    Instant now = Instant.now();
    for (Packet packet : packetGroup.getPackets()) {
        if (packet instanceof RequestHeartbeatPacket) {
            RequestHeartbeatPacket requestHeartbeatPacket = (RequestHeartbeatPacket) packet;
            HeartbeatData data = requestHeartbeatPacket.getData();
            OpenSource openSource = new OpenSource(sender, packetGroup.getDateMillis(), requestHeartbeatPacket, requestHeartbeatPacket.getUniqueString());
            ExecutionReason executionReason = new OpenSourceExecutionReason(openSource);
            HeartbeatPacket heartbeatPacket = new ImmutableHeartbeatPacket(data, executionReason);
            eventPacketListReceiverHandler.uploadSimple(now, Arrays.asList(heartbeatPacket));
        }
    }
}
Also used : Packet(me.retrodaredevil.solarthing.packets.Packet) HeartbeatPacket(me.retrodaredevil.solarthing.type.event.feedback.HeartbeatPacket) RequestHeartbeatPacket(me.retrodaredevil.solarthing.commands.packets.open.RequestHeartbeatPacket) ImmutableHeartbeatPacket(me.retrodaredevil.solarthing.type.event.feedback.ImmutableHeartbeatPacket) RequestHeartbeatPacket(me.retrodaredevil.solarthing.commands.packets.open.RequestHeartbeatPacket) HeartbeatData(me.retrodaredevil.solarthing.type.event.feedback.HeartbeatData) OpenSource(me.retrodaredevil.solarthing.type.open.OpenSource) Instant(java.time.Instant) HeartbeatPacket(me.retrodaredevil.solarthing.type.event.feedback.HeartbeatPacket) RequestHeartbeatPacket(me.retrodaredevil.solarthing.commands.packets.open.RequestHeartbeatPacket) ImmutableHeartbeatPacket(me.retrodaredevil.solarthing.type.event.feedback.ImmutableHeartbeatPacket) ExecutionReason(me.retrodaredevil.solarthing.reason.ExecutionReason) OpenSourceExecutionReason(me.retrodaredevil.solarthing.reason.OpenSourceExecutionReason) OpenSourceExecutionReason(me.retrodaredevil.solarthing.reason.OpenSourceExecutionReason) ImmutableHeartbeatPacket(me.retrodaredevil.solarthing.type.event.feedback.ImmutableHeartbeatPacket)

Example 7 with OpenSource

use of me.retrodaredevil.solarthing.type.open.OpenSource in project solarthing by wildmountainfarms.

the class ActionNodeDataReceiver method receivePacketGroup.

@Override
public void receivePacketGroup(String sender, TargetPacketGroup packetGroup) {
    for (Packet packet : packetGroup.getPackets()) {
        if (packet instanceof CommandOpenPacket) {
            CommandOpenPacket commandOpenPacket = (CommandOpenPacket) packet;
            if (commandOpenPacket.getPacketType() == CommandOpenPacketType.REQUEST_COMMAND) {
                RequestCommandPacket requestCommand = (RequestCommandPacket) commandOpenPacket;
                OpenSource source = new OpenSource(sender, packetGroup.getDateMillis(), requestCommand, requestCommand.getCommandName());
                receiveData(source, requestCommand.getCommandName());
            }
        }
    }
}
Also used : Packet(me.retrodaredevil.solarthing.packets.Packet) RequestCommandPacket(me.retrodaredevil.solarthing.commands.packets.open.RequestCommandPacket) CommandOpenPacket(me.retrodaredevil.solarthing.commands.packets.open.CommandOpenPacket) RequestCommandPacket(me.retrodaredevil.solarthing.commands.packets.open.RequestCommandPacket) OpenSource(me.retrodaredevil.solarthing.type.open.OpenSource) CommandOpenPacket(me.retrodaredevil.solarthing.commands.packets.open.CommandOpenPacket)

Example 8 with OpenSource

use of me.retrodaredevil.solarthing.type.open.OpenSource in project solarthing by wildmountainfarms.

the class OnMateCommandSent method onCommandExecute.

@Override
public void onCommandExecute(SourcedCommand<MateCommand> command) {
    OpenSource source = command.getSource();
    ExecutionReason reason = new OpenSourceExecutionReason(source);
    Packet packet = new ImmutableSuccessMateCommandPacket(SuccessMateCommandPacket.VERSION_LATEST, command.getCommand(), // for legacy reasons, include the data source converted to a string
    source.toDataSource().toString(), reason);
    packetListReceiver.receive(Collections.singletonList(packet));
}
Also used : Packet(me.retrodaredevil.solarthing.packets.Packet) SuccessMateCommandPacket(me.retrodaredevil.solarthing.solar.outback.command.packets.SuccessMateCommandPacket) ImmutableSuccessMateCommandPacket(me.retrodaredevil.solarthing.solar.outback.command.packets.ImmutableSuccessMateCommandPacket) OpenSource(me.retrodaredevil.solarthing.type.open.OpenSource) ExecutionReason(me.retrodaredevil.solarthing.reason.ExecutionReason) OpenSourceExecutionReason(me.retrodaredevil.solarthing.reason.OpenSourceExecutionReason) OpenSourceExecutionReason(me.retrodaredevil.solarthing.reason.OpenSourceExecutionReason) ImmutableSuccessMateCommandPacket(me.retrodaredevil.solarthing.solar.outback.command.packets.ImmutableSuccessMateCommandPacket)

Aggregations

OpenSource (me.retrodaredevil.solarthing.type.open.OpenSource)8 OpenSourceExecutionReason (me.retrodaredevil.solarthing.reason.OpenSourceExecutionReason)6 Packet (me.retrodaredevil.solarthing.packets.Packet)5 ImmutableRequestCommandPacket (me.retrodaredevil.solarthing.commands.packets.open.ImmutableRequestCommandPacket)3 ExecutionReason (me.retrodaredevil.solarthing.reason.ExecutionReason)3 Instant (java.time.Instant)2 SourceEnvironment (me.retrodaredevil.solarthing.actions.environment.SourceEnvironment)2 CommandOpenPacket (me.retrodaredevil.solarthing.commands.packets.open.CommandOpenPacket)2 RequestCommandPacket (me.retrodaredevil.solarthing.commands.packets.open.RequestCommandPacket)2 Test (org.junit.jupiter.api.Test)2 ArrayList (java.util.ArrayList)1 EventReceiverEnvironment (me.retrodaredevil.solarthing.actions.environment.EventReceiverEnvironment)1 MateCommandEnvironment (me.retrodaredevil.solarthing.actions.environment.MateCommandEnvironment)1 SourcedCommand (me.retrodaredevil.solarthing.commands.command.SourcedCommand)1 DeleteAlterPacket (me.retrodaredevil.solarthing.commands.packets.open.DeleteAlterPacket)1 RequestFlagPacket (me.retrodaredevil.solarthing.commands.packets.open.RequestFlagPacket)1 RequestHeartbeatPacket (me.retrodaredevil.solarthing.commands.packets.open.RequestHeartbeatPacket)1 ScheduleCommandPacket (me.retrodaredevil.solarthing.commands.packets.open.ScheduleCommandPacket)1 VersionedPacket (me.retrodaredevil.solarthing.database.VersionedPacket)1 IncompatibleUpdateTokenException (me.retrodaredevil.solarthing.database.exception.IncompatibleUpdateTokenException)1