private void PacketSource_ReceivedPacket(PacketSource <WaxPacket> sender, PacketEventArgs <WaxPacket> e) { // If a correctly parsed packet... if (e.Packet != null && e.Packet is WaxPacket) { WaxPacket packet = (WaxPacket)e.Packet; //Console.WriteLine("[" + packet.Timestamp + "]"); //Console.WriteLine(packet.ToString()); lock (SyncRoot) { if (!waxDevices.ContainsKey(packet.DeviceId)) { // Create new device waxDevices.Add(packet.DeviceId, new WaxDevice(packet.DeviceId, packet.Timestamp)); OnNewDevice(new ManagerEventArgs(waxDevices[packet.DeviceId])); } WaxDevice waxDevice = waxDevices[packet.DeviceId]; waxDevice.AddSamples(packet.Samples); // Forward packet to all destinations foreach (PacketDest <WaxPacket> dest in packetDests) { dest.SendPacket(packet); } if (packet != null) { DebugString = packet.ToString(); } } OnReceivedPacket(new ManagerEventArgs(waxDevices[packet.DeviceId], packet)); } }
public ManagerEventArgs(WaxDevice device, WaxPacket packet) { Device = device; Packet = packet; }