public object CallActionHandler(GQHSMAction action) { string actionName = action.Name; List <GQHSMHandler> actionList; List <object> retObjects = new List <object>(); if (actionName.StartsWith("^")) { CallPortForward(action); return(null); } else { actionList = m_ActionHandlersMap[actionName]; } if (actionList != null) { foreach (GQHSMHandler scHandler in actionList) { retObjects.Add(scHandler.Invoke(action.Params)); } } if (retObjects.Count == 1) { return(retObjects[0]); } else if (retObjects.Count > 1) { return(retObjects.ToArray()); } return(null); }
public GQHSMTimeOut(string name, DateTime dt, IQEvent ev, TimeOutType type, GQHSMAction action) { _name = name; _dt = dt; _event = ev; _action = action; _callType = GQHSMCallType.TIMEOUT_DATETIME_TYPE; }
public GQHSMTimeOut(string name, TimeSpan duration, IQEvent ev, GQHSMAction action) { _name = name; _duration = duration; _event = ev; _action = action; _callType = GQHSMCallType.TIMEOUT_TIMESPAN; }
public void CallPortForward(GQHSMAction action) { string[] splitS = action.Name.Split(new char[] { '^', '.' }, StringSplitOptions.RemoveEmptyEntries); if (splitS.Length <= 1) { Logger.Error("Need Source port and Action, i.e. ^Sourceport.Action"); return; } // use port links to get destination port, if available GQHSMPort gp = GetPort(splitS[0]); if (gp != null) { gp.Port.Send(new QEvent(splitS[1], action.Params)); } }
/// <summary> /// Parse Timeout Expressions /// single float (i.e. 1.0, 0.1, etc converts to TimeSpan.FromSeconds(value) /// every float (i.e. "every 1.0") repeats timeout every TimeSpan.FromSeconds(value) /// at DateTime (i.e. "at Sat, 01 Nov 2008 19:35:00 GMT") does single at DateTime.Parse(value) /// </summary> /// <param name="transition"></param> /// <param name="expression"></param> public void RegisterTimeOutExpression(GQHSMTransition transition, string expression) { string timeOutExpression = expression.Trim(); string eventSignal = transition.EventSignal; if (transition.EventSignal.Length > 0) { eventSignal = transition.EventSignal; } else { eventSignal = transition.Name; } if (timeOutExpression.IndexOf(" ") == -1) { double timeOut = 0.0f; GQHSMAction action = null; if (!Double.TryParse(timeOutExpression, out timeOut)) { action = new GQHSMAction(this, timeOutExpression); } RegisterTimeOutExpression(transition.GetSourceStateID(), new GQHSMTimeOut(transition.State[0].Name + "." + transition.GetFullName(), TimeSpan.FromSeconds(timeOut), new QEvent(eventSignal), action)); } else { string[] strList = timeOutExpression.Split(' '); string timeOutValue = strList [strList.Length - 1].Trim(); TimeOutType flag = TimeOutType.Single; if (timeOutExpression.StartsWith("every")) { flag = TimeOutType.Repeat; } if (timeOutExpression.StartsWith("at")) { flag = TimeOutType.Single; DateTime dt; GQHSMAction action = null; if (!DateTime.TryParse(timeOutValue, out dt)) { action = new GQHSMAction(this, timeOutValue); } RegisterTimeOutExpression(transition.GetSourceStateID(), new GQHSMTimeOut(transition.State[0].Name + "." + transition.GetFullName(), dt, new QEvent(eventSignal), action)); } else { Double timeOut = 0.0f; GQHSMAction action = null; if (!Double.TryParse(timeOutValue, out timeOut)) { action = new GQHSMAction(this, timeOutValue); } RegisterTimeOutExpression(transition.GetSourceStateID(), new GQHSMTimeOut(transition.State[0].Name + "." + transition.GetFullName(), TimeSpan.FromSeconds(timeOut), new QEvent(eventSignal), flag, action)); } } }