public static SacnPacket Parse(ReadOnlySpan <byte> bytes) { RootLayer rootLayer = RootLayer.Parse(bytes); if (rootLayer == null) { return(null); } bytes = bytes.Slice(RootLayer.Length); FramingLayer framingLayer = FramingLayer.Parse(bytes, rootLayer.Vector); switch (framingLayer) { case DataPacketFramingLayer dataLayer: bytes = bytes.Slice(DataPacketFramingLayer.Length); return(DataPacket.Parse(bytes, rootLayer, dataLayer)); case SynchronizationPacketFramingLayer syncLayer: bytes = bytes.Slice(SynchronizationPacketFramingLayer.Length); return(SynchronizationPacket.Parse(bytes, rootLayer, syncLayer)); case UniverseDiscoveryPacketFramingLayer discoveryLayer: bytes = bytes.Slice(UniverseDiscoveryPacketFramingLayer.Length); return(UniverseDiscoveryPacket.Parse(bytes, rootLayer, discoveryLayer)); default: return(null); } }
private UniverseDiscoveryPacket CreateUniverseDiscoveryPage(IEnumerable <UInt16> universes, byte page, byte lastPage) { UniverseDiscoveryPacket packet = new UniverseDiscoveryPacket(); packet.RootLayer.CID = CID; packet.FramingLayer.SourceName = SourceName; packet.UniverseDiscoveryLayer.Page = page; packet.UniverseDiscoveryLayer.LastPage = lastPage; packet.UniverseDiscoveryLayer.Universes = universes.ToArray(); return(packet); }
public static UniverseDiscoveryPacket Parse(ReadOnlySpan <byte> bytes, RootLayer rootLayer, UniverseDiscoveryPacketFramingLayer framingLayer) { UniverseDiscoveryPacket dataPacket = new UniverseDiscoveryPacket { RootLayer = rootLayer, FramingLayer = framingLayer, UniverseDiscoveryLayer = UniverseDiscoveryLayer.Parse(bytes) }; return(dataPacket); }