Ejemplo n.º 1
0
        public SerialEchoPerformancePart(string partID, SerialEchoPerformancePartConfig config, PartsLib.Tools.MDRF.Writer.IMDRFWriter mdrfWriter)
            : base(partID, initialSettings: SimpleActivePartBaseSettings.DefaultVersion0.Build(waitTimeLimit: (0.10).FromSeconds(), goOnlineAndOfflineHandling: GoOnlineAndGoOfflineHandling.All))
        {
            Config          = new SerialEchoPerformancePartConfig(config);
            this.mdrfWriter = mdrfWriter;

            sampleIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.SampleInterval, AutoReset = true
            }.Start();
            aggregationIntervalTimer = new QpcTimer()
            {
                TriggerInterval = Config.AggregationInterval, AutoReset = true
            }.Start();

            AddExplicitDisposeAction(() => Release());

            int targetCount = 1;

            serialEchoTrackerArray = Config.PortTargetSpecArray.Select(portTargetSpec => new SerialEchoTracker("SerialEchoPort_{0:d2}".CheckedFormat(targetCount++), portTargetSpec, binBoundariesArray, Config, this, Log)).ToArray();

            serialEchoTrackerArray.DoForEach(pt => mdrfWriter.Add(pt.hGrp.GroupInfo));

            noMDRFLogger = new Logging.Logger(PartID).SetDefaultNamedValueSetForEmitter(Logging.LogGate.All, new NamedValueSet()
            {
                { "noMDRF" }
            });
        }
Ejemplo n.º 2
0
 public SerialEchoPerformancePartConfig(SerialEchoPerformancePartConfig other)
 {
     AggregateGroupsFileIndexUserRowFlagBits = other.AggregateGroupsFileIndexUserRowFlagBits;
     SampleInterval       = other.SampleInterval;
     AggregationInterval  = other.AggregationInterval;
     ResponseTimeLimit    = other.ResponseTimeLimit;
     TestDataLength       = Math.Max(16, other.TestDataLength);
     TestDataPatternCount = Math.Max(1, other.TestDataPatternCount);
     PortTargetSpecArray  = other.PortTargetSpecArray ?? EmptyArrayFactory <string> .Instance;
 }
Ejemplo n.º 3
0
            public SerialEchoTracker(string portPartID, string portTargetSpec, double[] binBoundariesArray, SerialEchoPerformancePartConfig config, INotifyable notifyOnDone, Logging.IBasicLogger logger)
            {
                PortTargetSpec = portTargetSpec;
                Config         = config;
                NotifyOnDone   = notifyOnDone;
                Logger         = logger;

                h = new Histogram(binBoundariesArray);

                timeoutCountGPI = new MDRF.Writer.GroupPointInfo()
                {
                    Name = "timeoutCount", ValueCST = ContainerStorageType.UInt64, VC = new ValueContainer(0L)
                };
                failureCountGPI = new MDRF.Writer.GroupPointInfo()
                {
                    Name = "failureCount", ValueCST = ContainerStorageType.UInt64, VC = new ValueContainer(0L)
                };

                hGrp = new MDRFHistogramGroupSource("{0}".CheckedFormat(portPartID),
                                                    h,
                                                    (ulong)config.AggregateGroupsFileIndexUserRowFlagBits,
                                                    extraClientNVS: new NamedValueSet()
                {
                    { "SerialEcho" }, { "PortTargetSpec", PortTargetSpec }
                },
                                                    extraGPISet: new[] { timeoutCountGPI, failureCountGPI });

                try
                {
                    portConfig = new PortConfig(portPartID, portTargetSpec)
                    {
                        TxLineTerm          = LineTerm.None,
                        RxLineTerm          = LineTerm.CR,
                        ConnectTimeout      = (2.0).FromSeconds(),
                        WriteTimeout        = (1.0).FromSeconds(),
                        ReadTimeout         = (1.0).FromSeconds(),
                        IdleTime            = (1.0).FromSeconds(),
                        EnableAutoReconnect = true,
                    };

                    port = MosaicLib.SerialIO.Factory.CreatePort(portConfig);

                    portGetNextPacketAction = port.CreateGetNextPacketAction();
                    portFlushAction         = port.CreateFlushAction();
                    portWriteAction         = port.CreateWriteAction(portWriteActionParam = new WriteActionParam());
                }
                catch (System.Exception ex)
                {
                    Logger.Error.Emit("Port setup for '{0}' failed: {1}", portTargetSpec, ex.ToString(ExceptionFormat.TypeAndMessage));
                }
            }