use of me.retrodaredevil.solarthing.packets.instance.InstanceFragmentIndicatorPacket in project solarthing by wildmountainfarms.
the class PacketGroups method parseToInstancePacketGroup.
public static InstancePacketGroup parseToInstancePacketGroup(PacketGroup group, DefaultInstanceOptions defaultInstanceOptions) {
if (group instanceof InstancePacketGroup) {
return (InstancePacketGroup) group;
}
List<Packet> packets = new ArrayList<>();
String sourceId = defaultInstanceOptions.getDefaultSourceId();
int fragmentId = defaultInstanceOptions.getDefaultFragmentId();
for (Packet packet : group.getPackets()) {
if (packet instanceof InstancePacket) {
InstancePacket instancePacket = (InstancePacket) packet;
switch(instancePacket.getPacketType()) {
case SOURCE:
sourceId = ((InstanceSourcePacket) instancePacket).getSourceId();
break;
case FRAGMENT_INDICATOR:
fragmentId = ((InstanceFragmentIndicatorPacket) instancePacket).getFragmentId();
break;
default:
break;
}
} else {
packets.add(packet);
}
}
return createInstancePacketGroup(packets, group.getDateMillis(), sourceId, fragmentId);
}
Aggregations