Search in sources :

Example 1 with RoverAnalyticsHandler

use of me.retrodaredevil.solarthing.analytics.RoverAnalyticsHandler 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));
}
Also used : EnvironmentUpdaterMultiplexer(me.retrodaredevil.solarthing.actions.command.EnvironmentUpdaterMultiplexer) AvailableCommandsListUpdater(me.retrodaredevil.solarthing.commands.packets.status.AvailableCommandsListUpdater) ArrayList(java.util.ArrayList) EnvironmentUpdater(me.retrodaredevil.solarthing.actions.command.EnvironmentUpdater) RoverAnalyticsHandler(me.retrodaredevil.solarthing.analytics.RoverAnalyticsHandler) RoverEventUpdaterListReceiver(me.retrodaredevil.solarthing.program.receiver.RoverEventUpdaterListReceiver) DataIdentifiablePacketListChecker(me.retrodaredevil.solarthing.misc.common.DataIdentifiablePacketListChecker) DaySummaryLogListReceiver(me.retrodaredevil.solarthing.solar.DaySummaryLogListReceiver) DataRequesterResult(me.retrodaredevil.solarthing.config.request.DataRequesterResult) PacketListReceiverMultiplexer(me.retrodaredevil.solarthing.packets.handling.PacketListReceiverMultiplexer) DataRequester(me.retrodaredevil.solarthing.config.request.DataRequester) PacketListReceiver(me.retrodaredevil.solarthing.packets.handling.PacketListReceiver) TracerEventUpdaterListReceiver(me.retrodaredevil.solarthing.program.receiver.TracerEventUpdaterListReceiver) RequestObject(me.retrodaredevil.solarthing.config.request.RequestObject)

Aggregations

ArrayList (java.util.ArrayList)1 EnvironmentUpdater (me.retrodaredevil.solarthing.actions.command.EnvironmentUpdater)1 EnvironmentUpdaterMultiplexer (me.retrodaredevil.solarthing.actions.command.EnvironmentUpdaterMultiplexer)1 RoverAnalyticsHandler (me.retrodaredevil.solarthing.analytics.RoverAnalyticsHandler)1 AvailableCommandsListUpdater (me.retrodaredevil.solarthing.commands.packets.status.AvailableCommandsListUpdater)1 DataRequester (me.retrodaredevil.solarthing.config.request.DataRequester)1 DataRequesterResult (me.retrodaredevil.solarthing.config.request.DataRequesterResult)1 RequestObject (me.retrodaredevil.solarthing.config.request.RequestObject)1 DataIdentifiablePacketListChecker (me.retrodaredevil.solarthing.misc.common.DataIdentifiablePacketListChecker)1 PacketListReceiver (me.retrodaredevil.solarthing.packets.handling.PacketListReceiver)1 PacketListReceiverMultiplexer (me.retrodaredevil.solarthing.packets.handling.PacketListReceiverMultiplexer)1 RoverEventUpdaterListReceiver (me.retrodaredevil.solarthing.program.receiver.RoverEventUpdaterListReceiver)1 TracerEventUpdaterListReceiver (me.retrodaredevil.solarthing.program.receiver.TracerEventUpdaterListReceiver)1 DaySummaryLogListReceiver (me.retrodaredevil.solarthing.solar.DaySummaryLogListReceiver)1