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