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));
}
}
}
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());
}
}
}
}
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));
}
Aggregations