예제 #1
0
        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));
        }
예제 #2
0
 public NetIfacePerformancePartConfig(NetIfacePerformancePartConfig other)
 {
     StatisticsGroupsFileIndexUserRowFlagBits = other.StatisticsGroupsFileIndexUserRowFlagBits;
     ChangeOccurrenceFileIndexUserRowFlagBits = other.ChangeOccurrenceFileIndexUserRowFlagBits;
     SampleRecordingInterval = other.SampleRecordingInterval;
 }