Search in sources :

Example 1 with InstanceFragmentIndicatorPacket

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);
}
Also used : Packet(me.retrodaredevil.solarthing.packets.Packet) InstanceFragmentIndicatorPacket(me.retrodaredevil.solarthing.packets.instance.InstanceFragmentIndicatorPacket) InstancePacket(me.retrodaredevil.solarthing.packets.instance.InstancePacket) InstanceSourcePacket(me.retrodaredevil.solarthing.packets.instance.InstanceSourcePacket) InstanceTargetPacket(me.retrodaredevil.solarthing.packets.instance.InstanceTargetPacket) InstancePacket(me.retrodaredevil.solarthing.packets.instance.InstancePacket)

Aggregations

Packet (me.retrodaredevil.solarthing.packets.Packet)1 InstanceFragmentIndicatorPacket (me.retrodaredevil.solarthing.packets.instance.InstanceFragmentIndicatorPacket)1 InstancePacket (me.retrodaredevil.solarthing.packets.instance.InstancePacket)1 InstanceSourcePacket (me.retrodaredevil.solarthing.packets.instance.InstanceSourcePacket)1 InstanceTargetPacket (me.retrodaredevil.solarthing.packets.instance.InstanceTargetPacket)1