protected void ExecuteHsm(string modelName, qf4net.ILQHsm hsm) { TestAppForm appForm = _Context.AppForm(); try { qf4net.ModelInformation modelInformation = hsm.ModelInformation; StateDiagramView sd = new StateDiagramView(false); sd.StateControl.SetStateMachine(_LastFileName, hsm); #warning Cleanup this code - this control uses knowledge of its parent - below (TestAppForm) and above (StateDiagramView) // find Top level form if (appForm != null) { appForm.AddChild(modelName, modelName, sd); appForm.RegisterHsm(hsm); } else { Form frm = new Form(); frm.Text = modelName; frm.Controls.Add(sd); sd.Dock = DockStyle.Fill; frm.Show(); } } catch {} }
public static qf4net.ILQHsm CreateHsm(Type type) { qf4net.IQTimer timer = new qf4net.QSystemTimer(); qf4net.QSingleHsmEventManager eventManager = new qf4net.QSingleHsmEventManager(timer); object ohsm = Activator.CreateInstance(type, new object[] { eventManager }); //object ohsm = _AppDomain.CreateInstanceAndUnwrap (assemblyName, typeName); qf4net.ILQHsm hsm = ohsm as qf4net.ILQHsm; return(hsm); }
private void hsmListInput_SelectedIndexChanged_update_CommandInput(object sender, System.EventArgs e) { qf4net.ILQHsm hsm = SelectedHSM; commandInput.Text = ""; commandInput.Items.Clear(); if (hsm == null) { return; } #warning Add command filling code... }
private void hsmListInput_SelectedIndexChanged_update_EventInput(object sender, System.EventArgs e) { qf4net.ILQHsm hsm = SelectedHSM; eventInput.Text = ""; eventInput.Items.Clear(); if (hsm == null) { return; } qf4net.TransitionEventAttribute[] transitionEventAttributes = hsm.TransitionEvents; foreach (qf4net.TransitionEventAttribute te in transitionEventAttributes) { eventInput.Items.Add(te); } }
private void loadHsmButton_Click(object sender, System.EventArgs e) { string[] strlist = typeNameInput.Text.Split(','); if (strlist.Length != 2) { throw new FormatException("TypeName must be fully qualified"); } string typeName = strlist [0].Trim(); string assemblyName = strlist [1].Trim(); typeName = typeName + ", " + assemblyName; Type type = Type.GetType(typeName); if (type == null) { throw new NullReferenceException("Type [" + typeName + "] not found"); } qf4net.ILQHsm hsm = HsmUtil.CreateHsm(type); Controller.Execute(hsm); }
public void SetMachineModel(DiagramModel model, TestAppForm appForm) { CodeCompiler compiler = new CodeCompiler(); System.CodeDom.Compiler.CompilerResults results = compiler.Compile(model); if (!results.Errors.HasErrors) { string typeName = model.Header.NameSpace + "." + model.Header.Name; Type type = results.CompiledAssembly.GetType(typeName); qf4net.ILQHsm hsm = HsmUtil.CreateHsm(type); Controller.Execute(hsm); } else { foreach (string msg in results.Output) { appForm.Log(Color.Red, msg + "\n"); } } }
protected void ExecuteHsm(string typeName) { /* * ExecutionControllerView view = new ExecutionControllerView (); * view.Controller = new ExecutionController (_Glyphs); * view.Controller.Refresh += new EventHandler(Controller_Refresh); * view.Show (); */ QHsmExecutionControllerView view = new QHsmExecutionControllerView(); view.Controller = new QHsmExecutionController(_Model); view.Controller.Refresh += new EventHandler(_Context.RefreshView); view.SetMachineName(typeName); //view.SetMachineModel (_Model, AppForm ()); #warning Cleanup this code - this control uses knowledge of its parent StateDiagramView dv = _Context.ParentStateDiagramView; dv.SetExecutionWindow(view); view.Show(); qf4net.ILQHsm hsm = view.Controller.Hsm; TestAppForm appForm = _Context.AppForm(); if (appForm != null) { appForm.RegisterHsm(hsm); } qf4net.IQSupportsSubMachines supportsSubMachines = hsm as qf4net.IQSupportsSubMachines; if (supportsSubMachines != null) { foreach (DictionaryEntry de in supportsSubMachines.SubMachines) { qf4net.ILQHsm subMachine = de.Value as qf4net.ILQHsm; ExecuteHsm(de.Key.ToString(), subMachine); } } }
public void SetMachine(qf4net.ILQHsm hsm) { typeNameInput.Text = hsm.GetType().FullName; Controller.Execute(hsm); }
public void RegisterHsm(qf4net.ILQHsm hsm) { throw new NotImplementedException(); }
private void injectButton_Click(object sender, System.EventArgs e) { qf4net.ILQHsm hsm = SelectedHSM; if (hsm == null) { throw new ArgumentException("No hsm selected"); } if (eventInput.Text.Trim() != "") { string inject = eventInput.Text; inject = inject.Trim(); // if inject matches a TransitionEventAttribute then find its editor an edit! foreach (qf4net.TransitionEventAttribute te in hsm.TransitionEvents) { if (te.HasDataType) { if (te.ToString() == inject) { qf4net.IQEventEditor eventEditor = GetEditor(te); Form frm = new OkCancelForm(); frm.Text = "Event " + te.EventName; QEventDefaultEditContext ctx = new QEventDefaultEditContext(frm); if (eventEditor.Edit(ctx) == false) { return; } hsm.AsyncDispatch(new qf4net.QEvent(te.EventName, ctx.Instance)); if (eventEditor.SupportsParse) { inject = te + "|" + ctx.Instance; if (!eventInput.Items.Contains(inject)) { eventInput.Items.Add(inject); } } return; } } } // if inject matches a TransitionEventAttribute + extra data then parse the extra data! foreach (qf4net.TransitionEventAttribute te in hsm.TransitionEvents) { if (te.HasDataType) { if (inject.StartsWith(te.ToString() + "|")) { qf4net.IQEventEditor eventEditor = GetEditor(te); if (!eventEditor.SupportsParse) { throw new NotSupportedException(te.ToString() + " editor does not support string parsing"); } string[] strlist = inject.Split(new char[] { '|' }, 2); string eventName = strlist[0].Trim(); System.Diagnostics.Debug.Assert(eventName != "" && eventName == te.ToString()); string data = null; if (strlist.Length > 1) { data = strlist [1].Trim(); } if (data == null) { throw new ArgumentException("[" + inject + "] does not contain a Parsable event data string"); } object instance = eventEditor.Parse(data); hsm.AsyncDispatch(new qf4net.QEvent(te.EventName, instance)); return; } } } hsm.AsyncDispatch(new qf4net.QEvent(inject)); } }