use of me.retrodaredevil.solarthing.program.receiver.RoverEventUpdaterListReceiver in project solarthing by wildmountainfarms.
the class RequestMain method startRequestProgram.
public static <T extends PacketHandlingOption & CommandOption> int startRequestProgram(T options, AnalyticsManager analyticsManager, List<DataRequester> dataRequesterList, long period, long minimumWait) throws Exception {
EnvironmentUpdater[] environmentUpdaterReference = new EnvironmentUpdater[1];
PacketHandlerInit.Result handlersResult = PacketHandlerInit.initHandlers(options, () -> environmentUpdaterReference[0], Collections.singleton(new RoverAnalyticsHandler(analyticsManager)));
PacketListReceiverHandlerBundle bundle = handlersResult.getBundle();
List<PacketListReceiver> packetListReceiverList = new ArrayList<>();
List<EnvironmentUpdater> environmentUpdaters = new ArrayList<>();
for (DataRequester dataRequester : dataRequesterList) {
DataRequesterResult result = dataRequester.create(new RequestObject(bundle.getEventHandler().getPacketListReceiverAccepter()));
packetListReceiverList.add(result.getStatusPacketListReceiver());
environmentUpdaters.add(result.getEnvironmentUpdater());
}
// will add events for each rover packet if there are any to add
packetListReceiverList.add(new RoverEventUpdaterListReceiver(bundle.getEventHandler().getPacketListReceiverAccepter()));
// will add events for each tracer packet if there are any to add
packetListReceiverList.add(new TracerEventUpdaterListReceiver(bundle.getEventHandler().getPacketListReceiverAccepter()));
if (options.hasCommands()) {
packetListReceiverList.add(new AvailableCommandsListUpdater(options.getCommandInfoList(), false));
}
environmentUpdaterReference[0] = new EnvironmentUpdaterMultiplexer(environmentUpdaters);
packetListReceiverList.add(new DataIdentifiablePacketListChecker());
packetListReceiverList.add(new DaySummaryLogListReceiver());
packetListReceiverList.addAll(bundle.createDefaultPacketListReceivers());
return doRequest(new PacketListReceiverMultiplexer(packetListReceiverList), Duration.ofMillis(period), Duration.ofMillis(minimumWait));
}
Aggregations