Search in sources :

Example 1 with DocumentedPacketType

use of me.retrodaredevil.solarthing.packets.DocumentedPacketType in project solarthing by wildmountainfarms.

the class FXStatusListUpdater method receive.

@Override
public void receive(List<Packet> packets) {
    long now = System.currentTimeMillis();
    long timeId = timeIdentifier.getTimeId(now);
    final Long lastTimeId = this.lastTimeId;
    this.lastTimeId = timeId;
    if (lastTimeId != null && lastTimeId != timeId) {
        fxMap.clear();
    }
    for (Packet packet : new ArrayList<>(packets)) {
        if (packet instanceof DocumentedPacket) {
            DocumentedPacketType packetType = ((DocumentedPacket) packet).getPacketType();
            if (packetType == SolarStatusPacketType.FX_STATUS) {
                FXStatusPacket fx = (FXStatusPacket) packet;
                Identifier identifier = fx.getIdentifier();
                FXListUpdater updater = fxMap.get(identifier);
                if (updater == null) {
                    updater = new FXListUpdater();
                    fxMap.put(identifier, updater);
                }
                updater.update(now, packets, fx);
            }
        }
    }
}
Also used : Packet(me.retrodaredevil.solarthing.packets.Packet) ImmutableDailyFXPacket(me.retrodaredevil.solarthing.solar.outback.fx.extra.ImmutableDailyFXPacket) DailyFXPacket(me.retrodaredevil.solarthing.solar.outback.fx.extra.DailyFXPacket) DocumentedPacket(me.retrodaredevil.solarthing.packets.DocumentedPacket) FXStatusPacket(me.retrodaredevil.solarthing.solar.outback.fx.FXStatusPacket) FXStatusPacket(me.retrodaredevil.solarthing.solar.outback.fx.FXStatusPacket) TimeIdentifier(me.retrodaredevil.solarthing.util.time.TimeIdentifier) Identifier(me.retrodaredevil.solarthing.packets.identification.Identifier) DocumentedPacket(me.retrodaredevil.solarthing.packets.DocumentedPacket) DocumentedPacketType(me.retrodaredevil.solarthing.packets.DocumentedPacketType)

Example 2 with DocumentedPacketType

use of me.retrodaredevil.solarthing.packets.DocumentedPacketType in project solarthing by wildmountainfarms.

the class PointUtil method getTags.

public static Map<String, String> getTags(Packet packet) {
    Map<String, String> r = new HashMap<>();
    if (packet instanceof Identifiable) {
        Identifier identifier = ((Identifiable) packet).getIdentifier();
        r.put("identifier", identifier.getRepresentation());
        if (identifier instanceof SupplementaryIdentifier) {
            SupplementaryIdentifier supplementaryIdentifier = (SupplementaryIdentifier) identifier;
            r.put("identifier_supplementaryTo", supplementaryIdentifier.getSupplementaryTo().getRepresentation());
        }
    }
    if (packet instanceof DocumentedPacket) {
        DocumentedPacket documentedPacket = (DocumentedPacket) packet;
        DocumentedPacketType type = documentedPacket.getPacketType();
        r.put("packetType", type.toString());
    }
    return r;
}
Also used : Identifier(me.retrodaredevil.solarthing.packets.identification.Identifier) SupplementaryIdentifier(me.retrodaredevil.solarthing.packets.identification.SupplementaryIdentifier) DocumentedPacket(me.retrodaredevil.solarthing.packets.DocumentedPacket) SupplementaryIdentifier(me.retrodaredevil.solarthing.packets.identification.SupplementaryIdentifier) DocumentedPacketType(me.retrodaredevil.solarthing.packets.DocumentedPacketType) Identifiable(me.retrodaredevil.solarthing.packets.identification.Identifiable)

Aggregations

DocumentedPacket (me.retrodaredevil.solarthing.packets.DocumentedPacket)2 DocumentedPacketType (me.retrodaredevil.solarthing.packets.DocumentedPacketType)2 Identifier (me.retrodaredevil.solarthing.packets.identification.Identifier)2 Packet (me.retrodaredevil.solarthing.packets.Packet)1 Identifiable (me.retrodaredevil.solarthing.packets.identification.Identifiable)1 SupplementaryIdentifier (me.retrodaredevil.solarthing.packets.identification.SupplementaryIdentifier)1 FXStatusPacket (me.retrodaredevil.solarthing.solar.outback.fx.FXStatusPacket)1 DailyFXPacket (me.retrodaredevil.solarthing.solar.outback.fx.extra.DailyFXPacket)1 ImmutableDailyFXPacket (me.retrodaredevil.solarthing.solar.outback.fx.extra.ImmutableDailyFXPacket)1 TimeIdentifier (me.retrodaredevil.solarthing.util.time.TimeIdentifier)1