public LinkDriver(NetIfManager manager, ILinkNetIf netIfDevice, byte netIfIndex, bool mappingEnabled, bool threaded, bool doesIO, bool hasTasks) { Manager = manager; IoNetIfDevice = netIfDevice; NetIfIndex = netIfIndex; MappingEnabled = mappingEnabled; DoesIO = doesIO; HasTasks = hasTasks; NumTasks = 0; DeviceContextIndex = 0; duplexKind = (byte)LinkMonitor.LINK_DUPLEX_KIND.LINK_DUPLEX_KIND_NONE; duplexApply = 0; Monitor = (DoesIO ? new LinkMonitor(this) : null); Parser = (DoesIO ? new PacketParser(this) : null); IOThreads = (threaded ? new LinkIOThreads(this) : null); NotStale = false; HasRead = false; SerialIndex = -1; SchedulerInterval = SchedulerIntervalDefault; ResponseInterval = ResponseIntervalDefault; LinkWriteQueue = new DequeBlockingCollection <int>(LinkWriteQSize, -1); LinkVerifyQueue = new DequeBlockingCollection <int>(LinkVerifyQSize, -1); LinkMissingQueue = new DequeBlockingCollection <byte>(LinkMissingQSize, ProtocolConstants.VNO_NULL); OutputMapBuffer = (mappingEnabled ? new byte[LinkMappingBufferSize] : null); ClearLinkDriver(); manager.SerialNumberManager.NetIfSerialNumberSetup(NetIfIndex); }
// Debug aid: loops over message Q, showing messages in buffer. public static string DumpPacketQueue(NetIfManager manager, DequeBlockingCollection <int> q) { String s = ""; DequeBlockingCollection <int> tmp = new DequeBlockingCollection <int>(q); int n = 0; int idx, count = q.Size(); while ((idx = tmp.Pop()) != -1) { PacketBuffer b = manager.IoBuffers[idx]; s += String.Format("{0:d}/{1:d}:cmd={2:x2}", n, count, b.command()); s += DumpMessage(b); ++n; } return(s); }
// Finds message with Vno in VerifyQ. // Returns message idx, or -1. public int FindVnoInVerifyQueue(DequeBlockingCollection <int> q, byte vno) { return(q.FindFirstOccurrence(VnoVerifyComparison, vno)); }