public TransitionInfo(ITransitionGlyph trans, string fromStateName, string toStateName, IStateGlyph toStateGlyph) { Transition = trans; FromStateName = fromStateName; ToStateName = toStateName; ToStateGlyph = toStateGlyph; }
public void Visit(ITransitionGlyph transition) { WriteDefaults(transition); _Writer.WriteElementString("EventSignal", transition.EventSignal); _Writer.WriteElementString("EventSource", transition.EventSource); _Writer.WriteElementString("GuardCondition", transition.GuardCondition); _Writer.WriteElementString("Action", transition.Action); _Writer.WriteElementString("EvaluationOrderPriority", transition.EvaluationOrderPriority.ToString()); _Writer.WriteElementString("EventType", transition.EventType); _Writer.WriteElementString("IsInnerTransition", transition.IsInnerTransition.ToString().ToLower()); _Writer.WriteElementString("TimeOutExpression", transition.TimeOutExpression); _Writer.WriteElementString("TransitionType", transition.TransitionType.ToString()); foreach (ITransitionContactPointGlyph contactPoint in transition.ContactPoints) { if (contactPoint.Parent != null) { IStateGlyph state = contactPoint.Parent as IStateGlyph; System.Diagnostics.Debug.Assert(state != null); _Writer.WriteStartElement("State"); try { _Writer.WriteElementString("Id", state.Id); _Writer.WriteElementString("Name", state.Name); } finally { _Writer.WriteEndElement(); } } } }
public override void Draw(MurphyPA.H2D.Interfaces.IGraphicsContext GC) { if (_WhichEnd == TransitionContactEnd.To) { // want to draw an arrow here... pointer.Draw(GC, _OtherEnd.Centre, this.Centre, _Radius, _Radius); } else { base.Draw(GC); } if (_WhichEnd == TransitionContactEnd.To) { ITransitionGlyph trans = Owner as ITransitionGlyph; if (trans != null && trans.TransitionType == TransitionType.DeepHistory) { using (Brush brush = new System.Drawing.SolidBrush(GC.Color)) { GC.DrawString("H*", brush, 12, _Centre, false); } } } }
void SaveTransitionGlyph(TextWriter sw, ITransitionGlyph glyph) { SaveBounds(sw, "TRANSITION:", glyph); IGroupGlyph groupGlyph = glyph as IGroupGlyph; foreach (IGlyph contact in groupGlyph.ContactPoints) { if (contact.Parent != null) { sw.WriteLine(contact.Parent.Id); } else { sw.WriteLine("NOPARENT"); } } SaveGlyphCommon(sw, glyph); ITransitionGlyph trans = glyph; SaveText(sw, "NAME", trans.Name); SaveText(sw, "EVENT", trans.EventSignal); SaveText(sw, "GUARD", trans.GuardCondition); SaveText(sw, "ACTION", trans.Action); SaveText(sw, "TRANSITIONTYPE", trans.TransitionType.ToString()); SaveText(sw, "EVENTSOURCE", trans.EventSource); SaveTextIfNotDefault(sw, "EVENTTYPE", trans.EventType, ""); SaveText(sw, "EVALUATIONORDERPRIORITY", trans.EvaluationOrderPriority.ToString()); sw.WriteLine(trans.IsInnerTransition); SaveText(sw, "TIMEOUTEXPRESSION", trans.TimeOutExpression); }
protected void RefreshCurrentStateView(string qhsmName, string currentTransitionName) { ClearCurrentStateView(); foreach (IGlyph glyph in _View.StateControl.Model.Glyphs) { if (currentTransitionName == null) { IStateGlyph stateGlyph = glyph as IStateGlyph; if (stateGlyph != null) { if (qhsmName == GetStateName(stateGlyph)) { stateGlyph.Selected = true; } } } else { ITransitionGlyph trans = glyph as ITransitionGlyph; if (trans != null) { string sx = trans.FullyQualifiedStateName; foreach (IGlyph owned in trans.OwnedItems) { IStateGlyph sg = owned.Parent as IStateGlyph; if (sg != null) { if (GetStateName(sg) == qhsmName) { string transName = trans.CompleteEventText(true, true); if (trans.Action != "") { transName = transName + "/" + trans.Action; } if (transName == currentTransitionName) { trans.Selected = true; _View.StateControl.RefreshView(); if (_TransitionDelay > 0) { System.Threading.Thread.Sleep(TimeSpan.FromMilliseconds(_TransitionDelay)); } } } } break; } } } } _View.StateControl.RefreshView(); }
public int Compare(object x, object y) { /// State ahead of Transition /// /// State sorted in Parent Depth order /// Same Depth - sort by name /// /// Transition sorted by event if (x == y) { return(0); } if (x is IStateGlyph && y is IStateGlyph) { IStateGlyph X = x as IStateGlyph; IStateGlyph Y = y as IStateGlyph; int overrideComp = X.IsOverriding.CompareTo(Y.IsOverriding); if (overrideComp == 0) { string xname = X.FullyQualifiedStateName; string yname = Y.FullyQualifiedStateName; return(xname.CompareTo(yname)); } else { return(overrideComp); } } else if (x is ITransitionGlyph && y is ITransitionGlyph) { ITransitionGlyph X = x as ITransitionGlyph; ITransitionGlyph Y = y as ITransitionGlyph; string xevent = X.Event != null ? X.Event : ""; string yevent = Y.Event != null ? Y.Event : ""; return(xevent.CompareTo(yevent)); } else { if (x is IStateGlyph) // states to front of list { return(-1); } else { return(1); } } }
protected virtual void PrepareGlyphs() { _Glyphs = (ArrayList)_SourceGlyphs.Clone(); _Glyphs.Sort(new ConvertToCodeGlyphSorter()); _States = new ArrayList(); _Transitions = new ArrayList(); _Ports = new ArrayList(); foreach (IGlyph glyph in _Glyphs) { IStateGlyph state = glyph as IStateGlyph; if (state != null) { _States.Add(state); } ITransitionGlyph trans = glyph as ITransitionGlyph; if (trans != null) { _Transitions.Add(trans); } IStateTransitionPortGlyph port = glyph as IStateTransitionPortGlyph; if (port != null) { _Ports.Add(port); } } _StatesWithHistoryTransitions = new Hashtable(); foreach (IStateGlyph state in _States) { foreach (TransitionInfo info in GetTransitionList(state)) { if (info.Transition.TransitionType == TransitionType.History) { throw new NotImplementedException("History not yet implemented"); } if (info.Transition.TransitionType == TransitionType.DeepHistory) { IStateGlyph historyKeeper = info.ToStateGlyph; if (!_StatesWithHistoryTransitions.Contains(historyKeeper)) { _StatesWithHistoryTransitions.Add(historyKeeper, info); } } } } }
protected void AnalyseTransition(IStateGlyph state, ArrayList groupedTransitionList) { foreach (TransitionInfo transInfo in groupedTransitionList) { ITransitionGlyph trans = transInfo.Transition; if (HasGuardCondition(trans)) { AnalyseGuardAction(state, trans, trans.GuardCondition); } if (IsNotEmptyString(trans.Action)) { AnalyseAction(state, trans, trans.Action); } } }
public int Compare(object x, object y) { if (x == y) { return(0); } ITransitionGlyph xTrans = x as ITransitionGlyph; ITransitionGlyph yTrans = y as ITransitionGlyph; int compName = ValidString(xTrans.EventSignal).CompareTo(ValidString(yTrans.EventSignal)); if (compName == 0) { return(ValidString(xTrans.EventType).CompareTo(ValidString(yTrans.EventType))); } return(compName); }
protected void GetTransitionList(ArrayList transitionList, IStateGlyph state) { // now find transitions foreach (IGlyph child in state.Children) { ITransitionContactPointGlyph transContactPoint = child as ITransitionContactPointGlyph; if (transContactPoint != null) { ITransitionGlyph trans = transContactPoint.Owner as ITransitionGlyph; if (transContactPoint.WhichEnd == TransitionContactEnd.From) { // this is a from transition ITransitionContactPointGlyph transTo = null; foreach (ITransitionContactPointGlyph contactPoint in trans.ContactPoints) { if (contactPoint.WhichEnd == TransitionContactEnd.To) { transTo = contactPoint; break; } } System.Diagnostics.Debug.Assert(transTo != null, "Transition To Contact Point not found"); IStateGlyph toStateGlyph = transTo.Parent as IStateGlyph; string toStateName = "TRANSITION_TOSTATE_NOT_SET"; if (toStateGlyph != null) { if (IsNotEmptyString(toStateGlyph.Name)) { toStateName = StateNameFrom(toStateGlyph); } else { toStateName = "TRANSITION_TOSTATE_SET_BUT_STATE_NOT_NAMED"; } } TransitionInfo info = new TransitionInfo(trans, StateNameFrom(state), toStateName, toStateGlyph); transitionList.Add(info); } } } }
protected void SetCurrentTransitionName (string stateName, string eventDesc) { CurrentTransition = null; foreach (IStateGlyph state in _States) { string loopStateName = StateNameFrom (state); if (stateName == loopStateName) { ArrayList transitions = GetTransitionList (state); foreach (TransitionInfo info in transitions) { if (info.Transition.DisplayText () == eventDesc) { CurrentTransition = info.Transition; } } } } }
void LoadTransitionGlyph(TextReader sr) { string id; int X, Y, width, height; LoadBounds(sr, out id, out X, out Y, out width, out height); string parentIdFrom = NextLine(sr); string parentIdTo = NextLine(sr); _EntityLinkRel [id] = new StringPair(parentIdFrom, parentIdTo); ITransitionGlyph glyph = _Factory.CreateTransition(id, new Rectangle(X, Y, width, height)); LoadGlyphCommon(sr, glyph); ITransitionGlyph trans = glyph; trans.Name = LoadText(sr, "NAME"); trans.EventSignal = LoadText(sr, "EVENT"); trans.GuardCondition = LoadText(sr, "GUARD"); trans.Action = LoadText(sr, "ACTION"); string transType = LoadText(sr, "TRANSITIONTYPE"); trans.TransitionType = (TransitionType)Enum.Parse(typeof(TransitionType), transType, true); trans.EventSource = LoadText(sr, "EVENTSOURCE"); trans.EventType = LoadText(sr, "EVENTTYPE", ""); string evalOrder = LoadText(sr, "EVALUATIONORDERPRIORITY"); trans.EvaluationOrderPriority = int.Parse(evalOrder); trans.IsInnerTransition = bool.Parse(NextLine(sr)); string timeoutExpression = LoadText(sr, "AFTERTIMEOUT", ""); // this needs to be here because AFTERTIMEOUT being replaced by TIMEOUTEXPRESSION timeoutExpression = ClearZeroTimeOut(timeoutExpression); timeoutExpression = LoadText(sr, "TIMEOUTEXPRESSION", timeoutExpression); timeoutExpression = ClearZeroTimeOut(timeoutExpression); trans.TimeOutExpression = timeoutExpression; BlankLine(sr); // blank line _GlyphLookup.Add(id, glyph); _Glyphs.Add(glyph); }
protected void hsm_StateChange(object sender, EventArgs e) { LogStateEventArgs args = e as LogStateEventArgs; ILQHsm hsm = sender as ILQHsm; if (args.LogType == StateLogType.Log) { return; } string stateName = QStateNameFrom (args.State); switch (args.LogType) { case StateLogType.Init: { SetCurrentStateName (stateName); } break; case StateLogType.Entry: { SetCurrentStateName (stateName); } break; case StateLogType.Exit: { CurrentState = null; } break; case StateLogType.EventTransition: { CurrentTransition = null; DoRefresh (); SetCurrentStateName (stateName); SetCurrentTransitionName (stateName, args.EventDescription); DoRefresh (); } break; case StateLogType.Log: { } break; default: throw new NotSupportedException ("StateLogType." + args.LogType.ToString ()); } DoRefresh (); }
protected bool HasGuardCondition(ITransitionGlyph trans) { return IsNotEmptyString (trans.GuardCondition); }
public override void KeyUp(object sender, KeyEventArgs e) { if (_LastSelectedGlyph == null) { return; } if (_Model.IsStateGlyph(_LastSelectedGlyph)) { if (IsControlKey(e, Keys.T)) // Toggle Start State { IStateGlyph stateGlyph = _LastSelectedGlyph as IStateGlyph; stateGlyph.IsStartState = !stateGlyph.IsStartState; } if (IsControlKey(e, Keys.N)) // name { _LastSelectedGlyph.Name = InputDialog.Execute(_Context.ParentStateDiagramView, "State Property Input", "State Name", _LastSelectedGlyph.Name); } else if (IsControlKey(e, Keys.E)) // entry action { IStateGlyph stateGlyph = _LastSelectedGlyph as IStateGlyph; stateGlyph.EntryAction = InputDialog.Execute(_Context.ParentStateDiagramView, "State Property Input", "State Entry Action", stateGlyph.EntryAction); } else if (IsControlKey(e, Keys.X)) // exit action { IStateGlyph stateGlyph = _LastSelectedGlyph as IStateGlyph; stateGlyph.ExitAction = InputDialog.Execute(_Context.ParentStateDiagramView, "State Property Input", "State Exit Action", stateGlyph.ExitAction); } else if (IsControlKey(e, Keys.F)) { IStateGlyph stateGlyph = _LastSelectedGlyph as IStateGlyph; stateGlyph.IsFinalState = !stateGlyph.IsFinalState; } } else if (_Model.IsTransitionGlyph(_LastSelectedGlyph)) { if (IsControlKey(e, Keys.N)) { _LastSelectedGlyph.Name = InputDialog.Execute(_Context.ParentStateDiagramView, "Transition Property Input", "Transition Name", _LastSelectedGlyph.Name); } else if (IsControlKey(e, Keys.V)) { ITransitionGlyph transitionGlyph = _LastSelectedGlyph as ITransitionGlyph; transitionGlyph.EventSignal = InputDialog.Execute(_Context.ParentStateDiagramView, "Transition Property Input", "Transition Event Signal", transitionGlyph.EventSignal); } else if (IsControlKey(e, Keys.K)) { ITransitionGlyph transitionGlyph = _LastSelectedGlyph as ITransitionGlyph; transitionGlyph.EventSource = InputDialog.Execute(_Context.ParentStateDiagramView, "Transition Property Input", "Transition Event Source", transitionGlyph.EventSource); } else if (IsControlKey(e, Keys.G)) { ITransitionGlyph transitionGlyph = _LastSelectedGlyph as ITransitionGlyph; transitionGlyph.GuardCondition = InputDialog.Execute(_Context.ParentStateDiagramView, "Transition Property Input", "Transition Event Guard Condition", transitionGlyph.GuardCondition); } else if (IsControlKey(e, Keys.A)) { ITransitionGlyph transitionGlyph = _LastSelectedGlyph as ITransitionGlyph; transitionGlyph.Action = InputDialog.Execute(_Context.ParentStateDiagramView, "Transition Property Input", "Transition Event Action", transitionGlyph.Action); } else if (IsControlKey(e, Keys.I)) { ITransitionGlyph transitionGlyph = _LastSelectedGlyph as ITransitionGlyph; transitionGlyph.IsInnerTransition = !transitionGlyph.IsInnerTransition; } } else if (_Model.IsStateTransitionPortGlyph(_LastSelectedGlyph)) { if (IsControlKey(e, Keys.N)) { _LastSelectedGlyph.Name = InputDialog.Execute(_Context.ParentStateDiagramView, "State Transition Port Property Input", "Port Name", _LastSelectedGlyph.Name); } } else if (_Model.IsComponentGlyph(_LastSelectedGlyph)) { if (IsControlKey(e, Keys.N)) { _LastSelectedGlyph.Name = InputDialog.Execute(_Context.ParentStateDiagramView, "Component Property Input", "Component Name", _LastSelectedGlyph.Name); } } else { if (IsControlKey(e, Keys.N)) { _LastSelectedGlyph.Name = InputDialog.Execute(_Context.ParentStateDiagramView, "Property Input", "Name", _LastSelectedGlyph.Name); } } _Context.RefreshView(); }
protected void AnalyseGuardAction(IStateGlyph state, ITransitionGlyph trans, string actions) { string[] names = ParseNames(actions); }
protected void SetCurrentTransitionName(string stateName, string eventDesc) { CurrentTransition = null; foreach (IStateGlyph state in _States) { string loopStateName = StateNameFrom (state); if (stateName == loopStateName) { ArrayList transitions = GetTransitionList (state); foreach (TransitionInfo info in transitions) { if (info.Transition.DisplayText () == eventDesc) { CurrentTransition = info.Transition; } } } } }
protected bool HasGuardCondition(ITransitionGlyph trans) { return(IsNotEmptyString(trans.GuardCondition)); }
public void Visit(ITransitionGlyph transition) { WriteDefaults (transition); _Writer.WriteElementString ("EventSignal", transition.EventSignal); _Writer.WriteElementString ("EventSource", transition.EventSource); _Writer.WriteElementString ("GuardCondition", transition.GuardCondition); _Writer.WriteElementString ("Action", transition.Action); _Writer.WriteElementString ("EvaluationOrderPriority", transition.EvaluationOrderPriority.ToString ()); _Writer.WriteElementString ("EventType", transition.EventType); _Writer.WriteElementString ("IsInnerTransition", transition.IsInnerTransition.ToString ()); _Writer.WriteElementString ("TimeOutExpression", transition.TimeOutExpression); _Writer.WriteElementString ("TransitionType", transition.TransitionType.ToString ()); foreach (ITransitionContactPointGlyph contactPoint in transition.ContactPoints) { if (contactPoint.Parent != null) { IStateGlyph state = contactPoint.Parent as IStateGlyph; System.Diagnostics.Debug.Assert (state != null); _Writer.WriteStartElement ("State"); try { _Writer.WriteElementString ("Id", state.Id); _Writer.WriteElementString ("Name", state.Name); } finally { _Writer.WriteEndElement (); } } } }
void SaveTransitionGlyph(TextWriter sw, ITransitionGlyph glyph) { SaveBounds (sw, "TRANSITION:", glyph); IGroupGlyph groupGlyph = glyph as IGroupGlyph; foreach (IGlyph contact in groupGlyph.ContactPoints) { if (contact.Parent != null) { sw.WriteLine (contact.Parent.Id); } else { sw.WriteLine ("NOPARENT"); } } SaveGlyphCommon (sw, glyph); ITransitionGlyph trans = glyph; SaveText (sw, "NAME", trans.Name); SaveText (sw, "EVENT", trans.EventSignal); SaveText (sw, "GUARD", trans.GuardCondition); SaveText (sw, "ACTION", trans.Action); SaveText (sw, "TRANSITIONTYPE", trans.TransitionType.ToString ()); SaveText (sw, "EVENTSOURCE", trans.EventSource); SaveTextIfNotDefault (sw, "EVENTTYPE", trans.EventType, ""); SaveText (sw, "EVALUATIONORDERPRIORITY", trans.EvaluationOrderPriority.ToString ()); sw.WriteLine (trans.IsInnerTransition); SaveText (sw, "TIMEOUTEXPRESSION", trans.TimeOutExpression); }
protected string NormalisedTransitionDisplayText(ITransitionGlyph trans) { string text = trans.DisplayText (); text = text.Replace ("\"", "\\\""); text = text.Replace ("\r", "; "); text = text.Replace ("\n", "; "); text = text.Replace ("\r\n", "; "); while (text.IndexOf (";;") != -1) { text = text.Replace (";;", ";"); } return text; }
protected void AnalyseGuardAction(IStateGlyph state, ITransitionGlyph trans, string actions) { string[] names = ParseNames (actions); }