public ProcessPerformancePart(string partID, ProcessPerformancePartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter) : base(partID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.1).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All)) { Config = new ProcessPerformancePartConfig(config); this.mdrfWriter = mdrfWriter; sampleIntervalTimer = new QpcTimer() { TriggerInterval = config.SampleInterval, AutoReset = true }.Start(); Log.SetDefaultNamedValueSetForEmitter(Logging.MesgType.All, new NamedValueSet() { { "noMDRF" } }); ProcessDeltaOccurrenceInfo = new MDRF.Writer.OccurrenceInfo() { Name = "{0}.ProcessDelta".CheckedFormat(PartID), Comment = "Used to record all process additions, removals, and migrations to/from the active set", FileIndexUserRowFlagBits = config.ProcessDeltaOccurrenceFileIndexUserRowFlagBits, }; activeSetItemTrackerArray = Enumerable.Range(1, Math.Max(config.ActiveSetSize, 1)).Select(groupNum => new ActiveSetItemTracker("{0}.ActSet{1:d2}".CheckedFormat(PartID, groupNum), Config.ActiveSetGroupsFileIndexUserRowFlagBits)).ToArray(); activeSetItemTrackerArrayLength = activeSetItemTrackerArray.Length; activeSetMapGroup = new ActiveSetMapGroupTracker(config.ActiveSetSize, "{0}.ActSetMap".CheckedFormat(PartID), Config.ActiveSetMapGroupFileIndexUserRowFlagBits); GroupInfoArray = activeSetItemTrackerArray.Select(ast => ast.GroupInfo).ToArray(); mdrfWriter.Add(ProcessDeltaOccurrenceInfo); mdrfWriter.Add(activeSetMapGroup.GroupInfo); mdrfWriter.AddRange(GroupInfoArray); }
public NetIfacePerformancePart(string partID, NetIfacePerformancePartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter) : base(partID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.10).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All)) { Config = new NetIfacePerformancePartConfig(config); this.mdrfWriter = mdrfWriter; Log.SetDefaultNamedValueSetForEmitter(Logging.MesgType.All, new NamedValueSet() { { "noMDRF" } }); sampleRecordingIntervalTimer = new QpcTimer() { TriggerInterval = config.SampleRecordingInterval, AutoReset = true }.Start(); sampleIntervalTimer = new QpcTimer() { TriggerInterval = config.SampleRecordingInterval.Min((0.5).FromSeconds()), AutoReset = true }.Start(); netIfaceSettingChangeOccurrence = new MDRF.Writer.OccurrenceInfo() { Name = "{0}.SettingChange".CheckedFormat(PartID), Comment = "Used to record all network adapter setting changes", FileIndexUserRowFlagBits = Config.ChangeOccurrenceFileIndexUserRowFlagBits }; netIfaceStatusChangeOccurrence = new MDRF.Writer.OccurrenceInfo() { Name = "{0}.StatusChange".CheckedFormat(PartID), Comment = "Used to record all network adapter state changes", FileIndexUserRowFlagBits = Config.ChangeOccurrenceFileIndexUserRowFlagBits }; mdrfWriter.Add(netIfaceSettingChangeOccurrence, netIfaceStatusChangeOccurrence); NetworkInterface[] netInterfacesArray = NetworkInterface.GetAllNetworkInterfaces().Where(ni => ni.NetworkInterfaceType != NetworkInterfaceType.Tunnel && ni.NetworkInterfaceType != NetworkInterfaceType.Loopback).ToArray(); netIfaceTrackerArray = netInterfacesArray.Select((netIface, idx) => new NetIfaceTracker(PartID, netIface, idx + 1, config.StatisticsGroupsFileIndexUserRowFlagBits)).ToArray(); netIfaceTrackerArray.DoForEach(nit => netIfaceTrackerDictionary[nit.name] = nit); netIfaceTrackerArray.DoForEach(nit => mdrfWriter.Add(nit.groupInfo)); }