Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 public GQHSMTimeOut(string name, TimeSpan duration, IQEvent ev, TimeOutType type, GQHSMAction action)
 {
     _name     = name;
     _duration = duration;
     _event    = ev;
     _type     = type;
     _action   = action;
     _callType = GQHSMCallType.TIMEOUT_TIMESPAN_TYPE;
 }
Esempio n. 3
0
 public static void Set(string key, object value, int timeOut, TimeOutType timeOutType)
 {
     if (timeOutType == TimeOutType.Absolute)
     {
         SetAbsoluteExpiration(key, value, timeOut);
     }
     else
     {
         SetSlidingExpiration(key, value, timeOut);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 获取
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static object Get(string dbName, string key, TimeOutType timeOutType, int timeOut)
 {
     try
     {
         var obj = GetService(dbName).Get(key);
         if (timeOutType == TimeOutType.Absolute && obj != null)
         {
             Set(dbName, key, obj, timeOut);
         }
         return(obj);
     }
     catch { }
     return(null);
 }
Esempio n. 5
0
            protected void Init(QSystemTimer qTimer, string name, TimeSpan duration, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
            {
                _QTimer      = qTimer;
                _Name        = name;
                _Hsm         = hsm;
                _Event       = ev;
                _TimeOutType = timeOutType;
                if (duration.TotalMilliseconds == 0)
                {
                    _TimeOutType = TimeOutType.Single;
                    _Timer_Elapsed(this, null);
                    return;
                }

                double ms         = duration.TotalMilliseconds;
                double msInterval = ms > 0 ? ms : TimeSpan.MaxValue.TotalMilliseconds;

                _Timer          = new System.Timers.Timer(msInterval);
                _Timer.Elapsed += new System.Timers.ElapsedEventHandler(_Timer_Elapsed);
                _Timer.Enabled  = ms > 0;

                _Principal = System.Threading.Thread.CurrentPrincipal;
            }
 public void SetTimeOut(string name, TimeSpan duration, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     _Timer.SetTimeOut (name, duration, hsm, ev, timeOutType);
 }
Esempio n. 7
0
            public TimeOutCmd(QSystemTimer qTimer, string name, DateTime at, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
            {
                TimeSpan duration = new TimeSpan(0);

                _Time = at;
                DateTime now = DateTime.Now;

                if (at > now)
                {
                    duration = at - now;
                }
                Init(qTimer, name, duration, hsm, ev, timeOutType);
            }
 protected virtual TimeOutCmd CreateTimeOut(string name, DateTime at, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     return new TimeOutCmd (this, name, at, hsm, ev, timeOutType);
 }
            protected void Init(QSystemTimer qTimer, string name, TimeSpan duration, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
            {
                _QTimer = qTimer;
                _Name = name;
                _Hsm = hsm;
                _Event = ev;
                _TimeOutType = timeOutType;
                double ms = duration.TotalMilliseconds;
                double msInterval = ms > 0 ? ms : TimeSpan.MaxValue.TotalMilliseconds;
                _Timer = new System.Timers.Timer (msInterval);
                _Timer.Elapsed += new System.Timers.ElapsedEventHandler(_Timer_Elapsed);
                _Timer.Enabled = ms > 0;

                _Principal = System.Threading.Thread.CurrentPrincipal;
            }
Esempio n. 10
0
 public void SetTimeOut(string name, DateTime at, IQEvent ev, TimeOutType timeOutType)
 {
     _EventManager.SetTimeOut(ToTimeOutName(name), at, this, ev, timeOutType);
 }
Esempio n. 11
0
 public void SetTimeOut(string name, TimeSpan duration, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     _Timer.SetTimeOut(name, duration, hsm, ev, timeOutType);
 }
Esempio n. 12
0
 public void SetTimeOut(string name, DateTime at, IQEvent ev, TimeOutType timeOutType)
 {
     _EventManager.SetTimeOut (ToTimeOutName (name), at, this, ev, timeOutType);
 }
Esempio n. 13
0
 protected virtual TimeOutCmd CreateTimeOut(string name, TimeSpan duration, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     if (_TimingScale != 1)
     {
         duration = new TimeSpan(duration.Ticks * _TimingScale);
     }
     return(new TimeOutCmd(this, name, duration, hsm, ev, timeOutType));
 }
Esempio n. 14
0
        /// <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));
                }
            }
        }
Esempio n. 15
0
 public void SetTimeOut(string name, TimeSpan duration, IQEvent ev, TimeOutType timeOutType)
 {
     _EventManager.SetTimeOut (ToTimeOutName (name), duration, this, ev, timeOutType);
 }
Esempio n. 16
0
 protected virtual TimeOutCmd CreateTimeOut(string name, TimeSpan duration, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     if (_TimingScale != 1)
     {
         duration = new TimeSpan (duration.Ticks * _TimingScale);
     }
     return new TimeOutCmd (this, name, duration, hsm, ev, timeOutType);
 }
Esempio n. 17
0
 public void SetTimeOut(string name, DateTime at, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     TimeOutCmd timeOut = CreateTimeOut (name, at, hsm, ev, timeOutType);
     SetTimeOut (timeOut);
 }
Esempio n. 18
0
 public void SetTimeOut(string name, TimeSpan duration, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     TimeOutCmd timeOut = CreateTimeOut (name, duration, hsm, ev, timeOutType);
     SetTimeOut (timeOut);
 }
 public void SetTimeOut(string name, DateTime at, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     _Timer.SetTimeOut (name, at, hsm, ev, timeOutType);
 }
Esempio n. 20
0
 protected virtual TimeOutCmd CreateTimeOut(string name, DateTime at, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     return(new TimeOutCmd(this, name, at, hsm, ev, timeOutType));
 }
Esempio n. 21
0
 public void SetTimeOut(string name, TimeSpan duration, IQEvent ev, TimeOutType timeOutType)
 {
     _EventManager.SetTimeOut(ToTimeOutName(name), duration, this, ev, timeOutType);
 }
Esempio n. 22
0
 public static void Set(string dbName, string key, object value, int timeOut, TimeOutType timeOutType)
 {
     Set(dbName, key, value, timeOut);
 }
Esempio n. 23
0
 public TimeOutCmd(QSystemTimer qTimer, string name, TimeSpan duration, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     Init (qTimer, name, duration, hsm, ev, timeOutType);
 }
Esempio n. 24
0
        public void SetTimeOut(string name, DateTime at, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
        {
            TimeOutCmd timeOut = CreateTimeOut(name, at, hsm, ev, timeOutType);

            SetTimeOut(timeOut);
        }
Esempio n. 25
0
 public void SetTimeOut(string name, DateTime at, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     _Timer.SetTimeOut(name, at, hsm, ev, timeOutType);
 }
Esempio n. 26
0
 public TimeOutCmd(QSystemTimer qTimer, string name, TimeSpan duration, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     Init(qTimer, name, duration, hsm, ev, timeOutType);
 }
Esempio n. 27
0
        public void SetTimeOut(string name, TimeSpan duration, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
        {
            TimeOutCmd timeOut = CreateTimeOut(name, duration, hsm, ev, timeOutType);

            SetTimeOut(timeOut);
        }
Esempio n. 28
0
 public TimeOutCmd(QSystemTimer qTimer, string name, DateTime at, IQHsm hsm, IQEvent ev, TimeOutType timeOutType)
 {
     TimeSpan duration = new TimeSpan (0);
     _Time = at;
     DateTime now = DateTime.Now;
     if (at > now)
     {
         duration = at - now;
     }
     Init (qTimer, name, duration, hsm, ev, timeOutType);
 }