public static string Value(TraceGroup group) { string prefix = "***: "; switch (group) { case TraceGroup.CANBUS: prefix = "CAN: "; break; case TraceGroup.TEST: prefix = "TEST: "; break; case TraceGroup.LOG: prefix = "LOG: "; break; case TraceGroup.DEVICE: prefix = "DEVICE: "; break; } return (prefix); }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { /*switch (this.HintIdleAction) * { * case TestOnIdleAction.Unload: * traceGroup.Steps.Add(new WorkflowInstanceTrace(this.HintWorkflowIdentity, WorkflowInstanceState.Unloaded)); * traceGroup.Steps.Add(new WorkflowInstanceTrace(this.HintWorkflowIdentity, WorkflowInstanceState.Resumed)); * break; * case TestOnIdleAction.UnloadNoAutoLoad: * traceGroup.Steps.Add(new WorkflowInstanceTrace(this.HintWorkflowIdentity, WorkflowInstanceState.Unloaded)); * break; * default: * //no op * break; * }*/ }
internal override Outcome GetTrace(TraceGroup traceGroup) { Outcome outcome = Outcome.Completed; HintTrueFalse currentHint = GetCurrentOutcome(); switch (_conditionType) { case ExpressionType.Activity: outcome = _expressionActivity.GetTrace(traceGroup); if (outcome.DefaultPropogationState != OutcomeState.Completed) { return(outcome); } break; case ExpressionType.Literal: new TestDummyTraceActivity(typeof(Literal <bool>), Outcome.Completed).GetTrace(traceGroup); break; case ExpressionType.VisualBasicValue: //Just use LambdaValue as there is no round trip new TestDummyTraceActivity(typeof(LambdaValue <bool>), (currentHint == HintTrueFalse.Exception) ? Outcome.Faulted : Outcome.Completed).GetTrace(traceGroup); break; case ExpressionType.VariableValue: new TestDummyTraceActivity(typeof(VariableValue <bool>), (currentHint == HintTrueFalse.Exception) ? Outcome.Faulted : Outcome.Completed).GetTrace(traceGroup); break; default: break; } if (currentHint == HintTrueFalse.True) { outcome = GetTrueActionTrace(traceGroup); } else if (currentHint == HintTrueFalse.False) { outcome = GetFalseActionTrace(traceGroup); } else { outcome = Outcome.None; } return(outcome); }
public static Ink ToInk(this TraceGroup traceGroup) { var ink = new Ink(); foreach (var trace in traceGroup.Traces) { //var points = new Point[trace.Points.Count]; //foreach (var point in trace.Points) //{ //} var points = trace.Points.ToList().ConvertAll(c => c.ToPoint()); var stroke = ink.CreateStroke(points.ToArray()); ink.Strokes.Add(stroke); } return(ink); }
protected virtual void GetActivitySpecificTrace(TraceGroup traceGroup) { foreach (TestActivity child in GetChildren()) { if (child != null) { Outcome childOutcome = child.GetTrace(traceGroup); if (childOutcome.DefaultPropogationState != OutcomeState.Completed) { // if child didnt complete // propogate the unknown outcome upwards this.CurrentOutcome = childOutcome; break; } } } }
internal Outcome GetActionTrace(TraceGroup traceGroup) { Outcome bOutcome = null; if (this.Trigger != null && this.TriggerOutcome.DefaultPropogationState == OutcomeState.Completed && this.Action != null) { //traceGroup.Steps.Add(new ActivityTrace(this.DisplayName, ActivityInstanceState.Executing)); if (this.ExpectedOutcome.DefaultPropogationState == OutcomeState.None) { bOutcome = this.Action.GetTrace(traceGroup); } else { bOutcome = this.ExpectedOutcome; } // All activities should complete with one of the following switch (bOutcome.DefaultPropogationState) { case OutcomeState.Completed: traceGroup.Steps.Add(new ActivityTrace(this.DisplayName, ActivityInstanceState.Closed)); break; case OutcomeState.Canceled: traceGroup.Steps.Add(new ActivityTrace(this.DisplayName, ActivityInstanceState.Canceled)); break; case OutcomeState.Faulted: traceGroup.Steps.Add(new ActivityTrace(this.DisplayName, ActivityInstanceState.Faulted)); //A handled exception, therefore we should output a workflow instance trace if (bOutcome is HandledExceptionOutcome) { traceGroup.Steps.Add(new WorkflowInstanceTrace(WorkflowInstanceState.UnhandledException)); } break; default: break; } } this.TriggerOutcome = null; return(bOutcome); }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { // This trace is marked optional since it may not always be there. traceGroup.Steps.Add(GetTraces(OpenChannelFactoryOutcome, "OpenChannelFactory")); traceGroup.Steps.Add(new UnorderedTraces() { Optional = true, Steps = { // This trace is marked optional since it may not always be there. GetTraces(WaitOnChannelCorrelationOutcome, "WaitOnChannelCorrelation"), // This trace is marked optional since it may not always be there. GetTraces(OpenChannelAndSendMessageOutcome, "OpenChannelAndSendMessage"), } }); }
private string ReadTraceGroupInUnipenFormat(TraceGroup traceGroup) { var str = new StringBuilder(); foreach (var trace in traceGroup.Traces) { str.AppendLine(".PEN_DOWN"); foreach (var point in trace.Points) { str.AppendLine("X=" + point.X + " Y=" + point.Y); } str.AppendLine(".PEN_UP"); str.AppendLine("----- Total Points = " + trace.Points.Count); } return(str.ToString()); }
internal override Outcome GetTrace(TraceGroup traceGroup) { if (_actionActivity != null) { Outcome outcome = _actionActivity.GetTrace(traceGroup); if (outcome.DefaultPropogationState != OutcomeState.Completed) { return(outcome); } } if (_nextElement != null && !IsFaulting && !IsCancelling) { return(_nextElement.GetTrace(traceGroup)); } return(Outcome.Completed); }
internal Outcome GetTriggerTrace(TraceGroup traceGroup) { traceGroup.Steps.Add(new ActivityTrace(this.DisplayName, ActivityInstanceState.Executing)); if (this.HintTriggerScheduled) { this.TriggerOutcome = this.ExpectedOutcome; } else { this.TriggerOutcome = this.Trigger.GetTrace(traceGroup); } // All activities should complete with one of the following switch (this.TriggerOutcome.DefaultPropogationState) { case OutcomeState.Completed: // close now if there is no action if (_action == null) { traceGroup.Steps.Add(new ActivityTrace(this.DisplayName, ActivityInstanceState.Closed)); } break; case OutcomeState.Canceled: traceGroup.Steps.Add(new ActivityTrace(this.DisplayName, ActivityInstanceState.Canceled)); break; case OutcomeState.Faulted: traceGroup.Steps.Add(new ActivityTrace(this.DisplayName, ActivityInstanceState.Faulted)); //A handled exception, therefore we should output a workflow instance trace if (this.TriggerOutcome is HandledExceptionOutcome) { traceGroup.Steps.Add(new WorkflowInstanceTrace(WorkflowInstanceState.UnhandledException)); } break; default: break; } return(this.TriggerOutcome); }
private static ExpectedTrace RemoveUserTrace(ExpectedTrace expectedTrace) { ExpectedTrace modifiedTrace = new ExpectedTrace(expectedTrace); int count = modifiedTrace.Trace.Steps.Count; int removedCount = 0; for (int i = 0; i < count; i++) { WorkflowTraceStep workflowTraceStep = expectedTrace.Trace.Steps[i]; if (workflowTraceStep is UserTrace) { modifiedTrace.Trace.Steps.Remove(workflowTraceStep); removedCount++; continue; } else if (workflowTraceStep is TraceGroup) { ExpectedTrace tempExpectedTrace = new ExpectedTrace { Trace = TraceGroup.GetNewTraceGroup((TraceGroup)workflowTraceStep) }; //take into account for activities already removed. modifiedTrace.Trace.Steps.RemoveAt(i - removedCount); ExpectedTrace cleanedUpExpectedTrace = TrackingFilter.RemoveUserTrace(tempExpectedTrace); //add only if it is non-empty if ((cleanedUpExpectedTrace != null) && (cleanedUpExpectedTrace.Trace != null) && (cleanedUpExpectedTrace.Trace.Steps != null) && (cleanedUpExpectedTrace.Trace.Steps.Count != 0) ) { modifiedTrace.Trace.Steps.Insert(i - removedCount, cleanedUpExpectedTrace.Trace); } else { removedCount++; } } } return(modifiedTrace); }
public static TraceGroup ToTraceGroup(this Ink ink) { var traceGroup = new TraceGroup(); foreach (var stroke in ink.Strokes) { var trace = new Trace(); foreach (var point in stroke.GetPoints()) { var penPoint = new PenPoint { X = point.X, Y = point.Y }; trace.Points.Add(penPoint); } traceGroup.Traces.Add(trace); } return(traceGroup); }
public IList <RecoResult> Recognize(TraceGroup testTraceGroup) { var testPreProcTraceGroup = _preProc.PreProcess(testTraceGroup); var testFeature = _featureExtractor.ExtractFeature(testPreProcTraceGroup); var distanceList = new List <KeyValuePair <int, float> >(); foreach (var train in _trainList) { var d = _featureExtractor.ComputeEuclideanDistance(train.ShapeFeatures, testFeature); distanceList.Add(new KeyValuePair <int, float>(train.ClassId, d)); } distanceList.Sort((f1, f2) => f1.Value.CompareTo(f2.Value)); var tempRecoResult = new List <RecoResult>(); var sumSimiliarity = 0f; for (var i = 0; i < distanceList.Count; i++) { var foundDuplicated = tempRecoResult.Find(c => c.ShapeId == distanceList[i].Key); if (foundDuplicated == null) { sumSimiliarity += distanceList[i].Value; tempRecoResult.Add(new RecoResult { ShapeId = distanceList[i].Key, ConfidenceLevel = distanceList[i].Value }); if (tempRecoResult.Count == _numOfChoice) { break; } } } for (var i = 0; i < _numOfChoice; i++) { tempRecoResult[i].ConfidenceLevel = (sumSimiliarity - tempRecoResult[i].ConfidenceLevel) / sumSimiliarity; } return(tempRecoResult); }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { // stuff the exception type in so we dont always have to do that manually if (ExpectedOutcome is CaughtExceptionOutcome ceo) { if (ceo.ExceptionType == null) { ceo.ExceptionType = typeof(TException); } } else { if (ExpectedOutcome is UncaughtExceptionOutcome ueo && ueo.ExceptionType == null) { ueo.ExceptionType = typeof(TException); } } base.GetActivitySpecificTrace(traceGroup); }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { GetConditionTrace(traceGroup); if (this.body != null) { for (int counter = 0; counter < HintIterationCount; counter++) { Outcome childOut = body.GetTrace(traceGroup); if (childOut.DefaultPropogationState != OutcomeState.Completed) { CurrentOutcome = childOut; break; } GetConditionTrace(traceGroup); } } }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { if (this.Body != null) { Outcome bodyOutcome = this.Body.GetTrace(traceGroup); // Auto-confim should only happen IFF the ExpectedOutcome is Completed if (this.ExpectedOutcome.DefaultPropogationState == OutcomeState.Completed) { HandleAutoConfirm(traceGroup); } else { HandleError(traceGroup); // The CompensationScope will go to Faulted but we still need to propagate the Body's outcome CurrentOutcome = new Outcome(bodyOutcome.DefaultPropogationState, OutcomeState.Faulted); } } }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { for (int counter = 0; counter < HintIterationCount; counter++) { if (this.body != null) { Outcome childOut = body.GetTrace(traceGroup); if (childOut.DefaultPropogationState != OutcomeState.Completed) { CurrentOutcome = childOut; break; } } if (_conditionActivity != null) { CurrentOutcome = _conditionActivity.GetTrace(traceGroup); } else if (this.ProductDoWhile.Condition != null) { TestActivity condition; //For the case where DisableXamlRoundTrip is true, the trace is different //if (TestParameters.DisableXamlRoundTrip) //{ condition = new TestSequence() { DisplayName = this.ProductDoWhile.Condition.DisplayName, ExpectedOutcome = ConditionOutcome, }; //} //else //{ // condition = new TestDummyTraceActivity(this.ProductDoWhile.Condition, ConditionOutcome); //} CurrentOutcome = condition.GetTrace(traceGroup); } } }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { // Use the anchor as the starting point for the child search if (_anchor != null && !_disableTrace) { // If the target was valid, use that one. Otherwise we need the hints to determine what to do if (_target != null) { TestActivity target = _anchor.Activity.FindChildActivity(_target.Name); target.GetConfirmationTrace(traceGroup); } else { foreach (Directive directive in _confirmationHint) { TestActivity target = _anchor.Activity.FindChildActivity(directive.Name); target.GetConfirmationTrace(traceGroup); } } } }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { if (this.conditionActivity != null) { Outcome conditionOutcome = this.conditionActivity.GetTrace(traceGroup); if (conditionOutcome.DefaultPropogationState != OutcomeState.Completed) { // propogate the unknown outcome upwards this.CurrentOutcome = conditionOutcome; return; } } if (this.CurrentThenOrElse == HintThenOrElse.Then && this.ThenActivity != null) { CurrentOutcome = ThenActivity.GetTrace(traceGroup); } else if (this.CurrentThenOrElse == HintThenOrElse.Else && this.ElseActivity != null) { CurrentOutcome = ElseActivity.GetTrace(traceGroup); } }
internal Outcome GetTriggerTrace(TraceGroup traceGroup) { Outcome outcome = this.ExpectedOutcome; for (int i = 0; i < HintTriggerIterationCount; i++) { TestActivity trigger = this.Trigger; if (this.Trigger == null) { trigger = this.Source.NullTrigger; } outcome = trigger.GetTrace(traceGroup); } if (HintTriggerScheduled == true) { traceGroup.Steps.Add(new ActivityTrace(this.Trigger.DisplayName, ActivityInstanceState.Executing)); } _triggerIterationNumber++; return(outcome); }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { Outcome bodyOutcome = this.Body.GetTrace(traceGroup); if (bodyOutcome.DefaultPropogationState == OutcomeState.Completed) { return; } else if (bodyOutcome.DefaultPropogationState == OutcomeState.Canceled) { if (this.Handler != null) { this.Handler.GetTrace(traceGroup); } this.CurrentOutcome = Outcome.Canceled; } else { throw new NotSupportedException( String.Format("Current CancellationScope test object doesn't support Body.OutCome='{0}'.", bodyOutcome.DefaultPropogationState.ToString())); } }
private Outcome GetTransitOutTrace(TraceGroup traceGroup) { Outcome outcome = this.ExpectedOutcome; this.CurrentOutcome = this.ExpectedOutcome; outcome = this.GetExitTrace(traceGroup); if (CurrentOutcome.IsOverrideable) { this.CurrentOutcome = outcome; } // transition Action is always scheduled and executed after the current State's Exit. if (outcome.DefaultPropogationState == OutcomeState.Completed) { outcome = this.HintTransition.GetActionTrace(traceGroup); if (CurrentOutcome.IsOverrideable) { this.CurrentOutcome = outcome; } } if (CurrentOutcome.DefaultPropogationState == OutcomeState.Completed) { this.GetCloseTrace(traceGroup); } else if (CurrentOutcome.DefaultPropogationState == OutcomeState.Canceled) { this.GetCancelTrace(traceGroup); } else if (CurrentOutcome is CaughtExceptionOutcome) { this.GetFaultTrace(traceGroup); } return(this.CurrentOutcome.Propogate()); }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { if (this.Body != null) { Outcome bodyOutcome = this.Body.GetTrace(traceGroup); if (bodyOutcome.DefaultPropogationState == OutcomeState.Completed) { _bodyExecutedSuccessfully = true; } else if (bodyOutcome.DefaultPropogationState == OutcomeState.Canceled) { this.GetCancellationTrace(traceGroup); this.CurrentOutcome = Outcome.Canceled; this.CurrentOutcome.IsOverrideable = bodyOutcome.IsOverrideable; } else if (this.ExpectedOutcome == Outcome.Canceled) { this.GetCancellationTrace(traceGroup); this.CurrentOutcome = Outcome.Canceled; this.CurrentOutcome.IsOverrideable = this.ExpectedOutcome.IsOverrideable; } else if (this.ExpectedOutcome is UncaughtExceptionOutcome) { this.CurrentOutcome = bodyOutcome; } else { this.GetCompensationTrace(traceGroup); this.CurrentOutcome = Outcome.Canceled; } } else { // A null body is fine _bodyExecutedSuccessfully = true; } }
protected Outcome GetTrace <T>(TraceGroup traceGroup) { Outcome outcome = Outcome.Completed; switch (expressionType) { case ExpressionType.Activity: outcome = this.expressionActivity.GetTrace(traceGroup); if (outcome.DefaultPropogationState != OutcomeState.Completed) { return(outcome); } break; case ExpressionType.Literal: new TestDummyTraceActivity(typeof(Literal <T>), Outcome.Completed).GetTrace(traceGroup); break; case ExpressionType.VisualBasicValue: new TestDummyTraceActivity(typeof(LambdaValue <T>), Outcome.Completed).GetTrace(traceGroup); break; case ExpressionType.VariableValue: new TestDummyTraceActivity(typeof(VariableValue <T>), Outcome.Completed).GetTrace(traceGroup); break; default: break; } TestFlowElement element = GetNextElement(); if (element != null) { return(element.GetTrace(traceGroup)); } return(Outcome.Completed); }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { if (ExpectedOutcome.DefaultPropogationState != OutcomeState.Completed) { return; } if (_messageExpressionActivity != null) { _messageExpressionActivity.GetTrace(traceGroup); } if (this.HintMessageList.Count > 0 && (this.HintMessageList.Count == 1 || this.iterationNumber < this.HintMessageList.Count)) { traceGroup.Steps.Add(new UserTrace(_hintMessageList[this.HintMessageList.Count == 1 ? 0 : this.iterationNumber])); } else { throw new ArgumentException("HintMessage or HintMessageList must be set"); } }
public static string Value(TraceGroup group) { string prefix = "***: "; switch (group) { case TraceGroup.COMM: prefix = "COMM: "; break; case TraceGroup.PARAM: prefix = "PARAM: "; break; case TraceGroup.GUI: prefix = "GUI: "; break; case TraceGroup.CANBUS: prefix = "CAN: "; break; case TraceGroup.TBUS: prefix = "TBUS: "; break; case TraceGroup.RBUS: prefix = "RBUS: "; break; case TraceGroup.BODY: prefix = "BDY: "; break; case TraceGroup.MOVEMENT: prefix = "MVM: "; break; case TraceGroup.DRILL: prefix = "DRL: "; break; case TraceGroup.SEALANT: prefix = "SLT: "; break; case TraceGroup.PUMP: prefix = "PMP: "; break; } return (prefix); }
public static void Write(TraceGroup groupId, string formatString, params object[] args) { string prefix = TracePrefix.Value(groupId); Tracer.Write(prefix + formatString, args); }
public static void SetGroupLevel(TraceGroup group, TraceLevel level) { int index = ((int)group * 2); int offset = (index / 8); int shift = (index % 8); if ((null == Tracer.mask) || (offset >= Tracer.mask.Length)) { if (null == Tracer.mask) { Tracer.mask = new byte[offset + 1]; } if (offset >= Tracer.mask.Length) { Array.Resize<byte>(ref Tracer.mask, offset + 1); } } byte value = Tracer.mask[offset]; value &= (byte)(~(0x3 << shift)); value |= (byte)(((byte)level) << shift); Tracer.mask[offset] = value; }
public static TraceLevel GetGroupLevel(TraceGroup group) { return (Tracer.GroupLevel(group)); }
private static bool Active(TraceGroup group, TraceLevel level) { bool result = false; if (level == TraceLevel.error) { result = true; } else { TraceLevel groupLevel = Tracer.GroupLevel(group); if (level <= groupLevel) { result = true; } } return (result); }
private static TraceLevel GroupLevel(TraceGroup group) { int groupSetting = 0; int index = ((int)group * 2); int offset = (index / 8); int shift = (index % 8); if ((null != Tracer.mask) && (offset < Tracer.mask.Length)) { groupSetting = (Tracer.mask[offset] >> shift) & 0x3; } return ((TraceLevel)groupSetting); }
private Outcome GetTransitInTrace(TraceGroup stateTraceGroup, TestTransition incomingTransition) { HashSet <TestActivity> triggerHash = new HashSet <TestActivity>(); UnorderedTraces triggerTrace = new UnorderedTraces(); Outcome outcome = this.ExpectedOutcome; this.CurrentOutcome = this.ExpectedOutcome; this.GetStartTrace(stateTraceGroup); outcome = this.GetEntryTrace(stateTraceGroup); if (this.CurrentOutcome.IsOverrideable) { this.CurrentOutcome = outcome; } if (outcome.DefaultPropogationState == OutcomeState.Completed) { stateTraceGroup.Steps.Add(triggerTrace); foreach (TestTransition t in this.Transitions) { // Shared trigger transitions if (triggerHash.Add(t.Trigger)) { outcome = t.GetTriggerTrace(triggerTrace); if (outcome.DefaultPropogationState == OutcomeState.Completed) { outcome = t.GetConditionTrace(triggerTrace); if (this.CurrentOutcome.IsOverrideable) { this.CurrentOutcome = outcome.Propogate(); } } else if (outcome.DefaultPropogationState == OutcomeState.Faulted || outcome is UncaughtExceptionOutcome || outcome is CaughtExceptionOutcome) { if (this.CurrentOutcome.IsOverrideable) { this.CurrentOutcome = outcome.Propogate(); } } // trigger cancel can mean two things: // 1. trigger is cancelled by another trigger. This is normal behavior. // 2. trigger is cancelled externally. In such case, Transition.ExpectedOutcome should be set to canceled. else if (outcome.DefaultPropogationState == OutcomeState.Canceled) { if (t.ExpectedOutcome.DefaultPropogationState == OutcomeState.Canceled) { if (this.CurrentOutcome.IsOverrideable) { this.CurrentOutcome = outcome.Propogate(); } } continue; } } else { outcome = t.GetConditionTrace(triggerTrace); if (outcome.DefaultPropogationState != OutcomeState.Completed) { if (CurrentOutcome.IsOverrideable) { CurrentOutcome = outcome.Propogate(); } } } } } if (this.CurrentOutcome.DefaultPropogationState == OutcomeState.Canceled) { this.GetCancelTrace(stateTraceGroup); } return(this.CurrentOutcome.Propogate()); }
private void GetStartTrace(TraceGroup traceGroup) { traceGroup.Steps.Add(new ActivityTrace(this.DisplayName, ActivityInstanceState.Executing)); GetStateTrackingTrace(traceGroup); }
internal override void GetConfirmationTrace(TraceGroup traceGroup) { ProcessCompensationHints(this.CompensationHint, Directive.Confirm, traceGroup); }
public void GroupStart(Group group) { var traceGroup = new TraceGroup(group); if (!(stack.Count == 0)) { ((TraceGroup) stack[stack.Count - 1]).AddGroup(traceGroup); } stack.Add(traceGroup); }
private void UpdateTraceLevel(TraceGroup group, DYNO.Utilities.TraceLevel level) { if (false == this.settingTraceMask) { Tracer.SetGroupLevel(group, level); this.settingTraceMask = true; this.TraceMaskTextBox.Text = Tracer.MaskString; this.settingTraceMask = false; } }
public static void WriteError(TraceGroup groupId, string identifier, string formatString, params object[] args) { if (Tracer.Active(groupId, TraceLevel.error) != false) { string prefix = TracePrefix.Value(groupId); string id = ((null != identifier) && ("" != identifier)) ? (identifier + " ") : string.Empty; Tracer.Write(id + prefix + formatString, args); } }
// // Example hint list describing 3 branches and the order of processing for CA's on each Branch // { Branch, CA2, CA1, Branch, CA3, Branch, CA6, CA5, CA4 } // private void ProcessCompensationHints(IList <Directive> hints, string defaultAction, TraceGroup traceGroup) { // A splited flowchart Confirmation/Compensation are collections of unordered branch traces // (similar to Parallel) UnorderedTraces unordered = new UnorderedTraces(); OrderedTraces ordered = null; foreach (Directive directive in hints) { // If we encounter a Branch directive that means we need to start a new OrderedTraces group if (directive.Name == "Branch") { if (ordered != null) // Already had one, so add it to our collection before we create a new one { if (ordered.Steps.Count > 0) // There's a chance we didn't produce any output { unordered.Steps.Add(ordered); } } ordered = new OrderedTraces(); } else { TestActivity target = FindChildActivity(directive.Name); TestCompensableActivity.ProcessDirective(target, directive, defaultAction, traceGroup); } } // Was there one left over? (From the last branch directive) if (ordered != null) { if (ordered.Steps.Count > 0) // There's a chance we didn't produce any output { unordered.Steps.Add(ordered); } } if (unordered.Steps.Count > 0) { traceGroup.Steps.Add(unordered); } }
protected override void GetActivitySpecificTrace(TraceGroup traceGroup) { traceGroup.Steps.Add(new UserTrace(WaitReadLine <T> .BeforeWait)); traceGroup.Steps.Add(new UserTrace(WaitReadLine <T> .AfterWait)); }
public virtual void AddGroup(TraceGroup traceGroup) { nodes.Add(traceGroup); }
private void GetCloseTrace(TraceGroup traceGroup) { traceGroup.Steps.Add(new ActivityTrace(this.DisplayName, ActivityInstanceState.Closed)); }
public void GroupStart(Group group) { var traceGroup = new TraceGroup(group); if (_stack.Count != 0) _stack.Peek().AddGroup(traceGroup); _stack.Push(traceGroup); }
public static CANResult Start(BusInterfaces busInterface, int bitRate, FramesType messageType, TraceGroup traceGroup, ReceiveDelegateHandler receiveHandler, int ioPort = -1, short interrupt = -1) { int busIndex = (int)busInterface; if (null == context[busIndex]) { context[busIndex] = new BusContext(); } HardwareType hardwareType = GetHardwareType(busInterface); Baudrates interfaceBaudRate = GetInterfaceBaudRate(bitRate); CANResult result = CANResult.ERR_NETINUSE; if (false == context[busIndex].active) { result = CANResult.ERR_OK; string dllVersionString = ""; uint nodeId = 0; if (CANResult.ERR_OK == result) { CANResult dllVersionResult = PCANLight.DllVersionInfo(hardwareType, out dllVersionString); if (CANResult.ERR_OK == dllVersionResult) { int majorVersion = 0; String[] versionTabInfo = dllVersionString.Split('.'); if (versionTabInfo.Length > 0) { Int32.TryParse(versionTabInfo[0].ToString(), out majorVersion); } if (majorVersion < 2) { Tracer.WriteError(traceGroup, "", "DLL version 2.x or higher needed, version \"{0}\" invalid", dllVersionString); } } else { Tracer.WriteError(traceGroup, "", "DLL version error {0}", dllVersionResult.ToString()); result = dllVersionResult; } } if (CANResult.ERR_OK == result) { CANResult initResult = CANResult.ERR_OK; if ((-1 != ioPort) && (-1 != interrupt)) { initResult = PCANLight.Init(hardwareType, interfaceBaudRate, messageType, (uint)ioPort, (ushort)interrupt); } else { initResult = PCANLight.Init(hardwareType, interfaceBaudRate, messageType); } if (CANResult.ERR_OK != initResult) { Tracer.WriteError(traceGroup, "", "DLL init error {0}", initResult.ToString()); result = initResult; } } if (CANResult.ERR_OK == result) { CANResult resetResult = PCANLight.ResetClient(hardwareType); if (CANResult.ERR_OK != resetResult) { Tracer.WriteError(traceGroup, "", "DLL reset error {0}", resetResult.ToString()); result = resetResult; } } if ((HardwareType.USB_1CH == hardwareType) || (HardwareType.USB_2CH == hardwareType)) { if (CANResult.ERR_OK == result) { CANResult deviceNumberResult = CANResult.ERR_OK; deviceNumberResult = PCANLight.GetUSBDeviceNr(hardwareType, out nodeId); if (CANResult.ERR_OK != deviceNumberResult) { Tracer.WriteError(traceGroup, "", "DLL device number error {0}", deviceNumberResult.ToString()); result = deviceNumberResult; } } } if (CANResult.ERR_OK == result) { CANResult setEventResult = CANResult.ERR_OK; context[busIndex].receiveEvent = new AutoResetEvent(false); setEventResult = PCANLight.SetRcvEvent(hardwareType, context[busIndex].receiveEvent); if (CANResult.ERR_OK != setEventResult) { Tracer.WriteError(traceGroup, "", "DLL receive event error {0}", setEventResult.ToString()); result = setEventResult; } } if (CANResult.ERR_OK == result) { context[busIndex].traceGroup = traceGroup; context[busIndex].receiverHandler = new ReceiveDelegateHandler(receiveHandler); context[busIndex].receiveThread = new Thread(() => ReceiveProcess(context[busIndex])); context[busIndex].receiveThread.IsBackground = true; context[busIndex].receiveThread.Name = "CAN " + busInterface.ToString() + " reader"; context[busIndex].receiveThreadExecute = true; context[busIndex].receiveThread.Start(); } if (CANResult.ERR_OK == result) { context[busIndex].activeHardware = hardwareType; context[busIndex].active = true; Tracer.WriteHigh(traceGroup, "", "started, version {0}, node id {1}", dllVersionString, nodeId); } } return (result); }
public void AddGroup(TraceGroup traceGroup) { _nodes.Add(traceGroup); }