示例#1
0
        public IObservable <RegionSelectorResult> SelectRegion()
        {
            return(Observable.Create <RegionSelectorResult>(
                       observer =>
            {
                var windowAnchors = new CompositeDisposable();

                var temporarilyDisableAuras = new DefaultTrigger()
                {
                    IsActive = false
                };
                Disposable.Create(() => sharedContext.SystemTrigger.Triggers.Remove(temporarilyDisableAuras)).AddTo(windowAnchors);
                temporarilyDisableAuras.AddTo(sharedContext.SystemTrigger.Triggers);

                var window = regionSelectorWindowFactory.Create().AddTo(windowAnchors);
                Disposable.Create(() => Log.Debug("Disposed selector window: {window}")).AddTo(windowAnchors);
                Log.Debug($"Created new selector window: {window}");

                Observable.FromEventPattern <EventHandler, EventArgs>(h => window.Closed += h, h => window.Closed -= h)
                .Select(x => window.Result)
                .Take(1)
                .Subscribe(observer)
                .AddTo(windowAnchors);

                window.Show();

                return windowAnchors;
            }));
        }
示例#2
0
        public void StartDataLogging2(string logConfigName, string lDescription, string lFilePath, double fTriggerLevel,
                                      int iTriggerSlope, string lTriggerChannel, double lRate, string[] lFilePropertiesNames, string[] lFilePropertiesValues, string[] lChannelsToLog,
                                      double lDuration, double lPreTriggerDuration, bool lReplaceFile, string[] lChannelShortNames)
        {
            //VeriStand 2013 and later, logging for EXAM startMeasurement
            FileConflictOperation fileConflict = new FileConflictOperation();

            if (lReplaceFile)
            {
                fileConflict = FileConflictOperation.OverwriteExisting;
            }
            else
            {
                fileConflict = FileConflictOperation.CreateUnique;
            }

            TdmsLogFile logFile = new TdmsLogFile(lFilePath, fileConflict);
            DataLoggingSpecification loggingSpec    = new DataLoggingSpecification(logFile);
            DefaultTrigger           defStopTrigger = new DefaultTrigger(false);
            Slope            triggerSlope           = new Slope();
            TdmsChannelGroup logChannelGroup        = new TdmsChannelGroup("EXAM_Data");
            TdmsChannelGroup logChannelGroupInt     = new TdmsChannelGroup("EXAM_Data_Internal");

            //Internal info channel
            logChannelGroupInt.AddChannel("System Time", "Targets/Controller/System Channels/System Time");

            if (iTriggerSlope < 0)
            {
                triggerSlope = Slope.Falling;
            }
            else
            {
                triggerSlope = Slope.Rising; // Rising = 0
            }

            string lTriggerChannelLower = lTriggerChannel.ToLower();

            if (lTriggerChannel.Trim() != "" && lTriggerChannelLower.Trim() != "notrigger")
            {
                //Console.WriteLine("@@" + lTriggerChannel+"@@");
                AnalogEdgeTrigger startTrigger = new AnalogEdgeTrigger(lTriggerChannel.Trim(), fTriggerLevel, triggerSlope, true);
                loggingSpec.StartTrigger = startTrigger;
            }
            else
            {
                DefaultTrigger startTrigger = new DefaultTrigger(true);
                loggingSpec.StartTrigger = startTrigger;
            }

            if (lDuration > 0)
            {
                loggingSpec.PostTriggerDuration = lDuration;
                defStopTrigger.DefaultResult    = true;
            }

            loggingSpec.StopTrigger                    = defStopTrigger;
            loggingSpec.PreTriggerDuration             = lPreTriggerDuration;
            loggingSpec.Retriggerable                  = false;
            loggingSpec.LogDataAtTargetRate            = false;
            loggingSpec.SegmentFileOnTrigger           = false;
            loggingSpec.LogDataAgainstAbsoluteTimeBase = true;
            loggingSpec.CustomRate = lRate;

            uint           j = 0;
            IList <string> tempPrVariables = new List <string>(lChannelsToLog);
            int            varCount        = tempPrVariables.Count;

            foreach (string Channel in tempPrVariables)
            {
                //string channelName = Channel.Replace(@"/", @"_");
                //channelName = channelName.Replace(@" ", @"_");
                //TdmsChannel vSLogChan = new TdmsChannel(channelName,Channel);
                TdmsChannel vSLogChan = new TdmsChannel(Channel, Channel);
                //TdmsProperty vSProperty = new TdmsProperty("channelName",TdmsPropertyDataType.String,(String)Channel);
                //vSLogChan.AddProperty(vSProperty);
                TdmsProperty vSProperty = new TdmsProperty("ChannelShortName", TdmsPropertyDataType.String, (String)lChannelShortNames[j]);
                vSLogChan.AddProperty(vSProperty);
                logChannelGroup.AddChannel(vSLogChan);
                j++;
            }
            j = 0;

            for (int i = 0; i < lFilePropertiesNames.GetLength(0); i++)
            {
                TdmsProperty vSProperty = new TdmsProperty(lFilePropertiesNames[i], TdmsPropertyDataType.String, (String)lFilePropertiesValues[i]);
                logFile.AddProperty(vSProperty);
            }

            logFile.AddChannelGroup(logChannelGroup);
            logFile.AddChannelGroup(logChannelGroupInt);
            logFile.Description = lDescription;
            loggingSpec.LogFile = logFile;
            ErrChk(this.LoggingManager.StartDataLoggingSession(logConfigName, loggingSpec));
        }