Search in sources :

Example 1 with PacketHandlerMultiplexer

use of me.retrodaredevil.solarthing.packets.handling.PacketHandlerMultiplexer in project solarthing by wildmountainfarms.

the class PacketListReceiverHandlerBundle method createFrom.

public static <T extends PacketHandlingOption & CommandOption> PacketListReceiverHandlerBundle createFrom(T options, PacketHandlerBundle packetHandlerBundle, List<PacketHandler> statusPacketHandlers) {
    PacketListReceiver sourceAndFragmentUpdater = SolarMain.getSourceAndFragmentUpdater(options);
    PacketListReceiverHandler eventPacketListReceiverHandler = createEventPacketListReceiverHandler(sourceAndFragmentUpdater, options.getZoneId(), packetHandlerBundle);
    PacketListReceiverHandler statusPacketListReceiverHandler = new PacketListReceiverHandler(new PacketListReceiverMultiplexer(sourceAndFragmentUpdater, (packets) -> {
        LOGGER.debug("Debugging all packets");
        try {
            LOGGER.debug(MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(packets));
        } catch (JsonProcessingException e) {
            LOGGER.debug("Never mind about that...", e);
        }
    }), new PacketHandlerMultiplexer(statusPacketHandlers), SolarMain.createIdGenerator(options.getUniqueIdsInOneHour(), options.isDocumentIdShort()), options.getZoneId());
    return new PacketListReceiverHandlerBundle(statusPacketListReceiverHandler, eventPacketListReceiverHandler);
}
Also used : CommandOption(me.retrodaredevil.solarthing.config.options.CommandOption) Arrays(java.util.Arrays) Logger(org.slf4j.Logger) PacketHandlingOption(me.retrodaredevil.solarthing.config.options.PacketHandlingOption) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) LoggerFactory(org.slf4j.LoggerFactory) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) PacketHandler(me.retrodaredevil.solarthing.packets.handling.PacketHandler) PacketCollectionIdGenerator(me.retrodaredevil.solarthing.packets.collection.PacketCollectionIdGenerator) ZoneId(java.time.ZoneId) List(java.util.List) SolarThingConstants(me.retrodaredevil.solarthing.SolarThingConstants) PacketHandlerMultiplexer(me.retrodaredevil.solarthing.packets.handling.PacketHandlerMultiplexer) PacketListReceiverMultiplexer(me.retrodaredevil.solarthing.packets.handling.PacketListReceiverMultiplexer) PacketListReceiver(me.retrodaredevil.solarthing.packets.handling.PacketListReceiver) JacksonUtil(me.retrodaredevil.solarthing.util.JacksonUtil) PacketListReceiverMultiplexer(me.retrodaredevil.solarthing.packets.handling.PacketListReceiverMultiplexer) PacketHandlerMultiplexer(me.retrodaredevil.solarthing.packets.handling.PacketHandlerMultiplexer) PacketListReceiver(me.retrodaredevil.solarthing.packets.handling.PacketListReceiver) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ZoneId (java.time.ZoneId)1 Arrays (java.util.Arrays)1 List (java.util.List)1 SolarThingConstants (me.retrodaredevil.solarthing.SolarThingConstants)1 CommandOption (me.retrodaredevil.solarthing.config.options.CommandOption)1 PacketHandlingOption (me.retrodaredevil.solarthing.config.options.PacketHandlingOption)1 PacketCollectionIdGenerator (me.retrodaredevil.solarthing.packets.collection.PacketCollectionIdGenerator)1 PacketHandler (me.retrodaredevil.solarthing.packets.handling.PacketHandler)1 PacketHandlerMultiplexer (me.retrodaredevil.solarthing.packets.handling.PacketHandlerMultiplexer)1 PacketListReceiver (me.retrodaredevil.solarthing.packets.handling.PacketListReceiver)1 PacketListReceiverMultiplexer (me.retrodaredevil.solarthing.packets.handling.PacketListReceiverMultiplexer)1 JacksonUtil (me.retrodaredevil.solarthing.util.JacksonUtil)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1