示例#1
0
        void OnFrame(object sender, EventArgs e)
        {
            if (DateTime.Now > NextPulse)
            {
                if (CurState != null && ((Session.Safe && Session.NextSessionChange < Session.Now) || SafetyOff))
                {
                    if (CurState.State(CurState.Params))
                    {
                        if (States.Count > 0)
                        {
                            CurState = States.Last();
                            States.RemoveLast();
                            StateLog.Log("New CurState: {0}", LogType.DEBUG, CurState.ToString());
                        }
                        else
                        {
                            CurState = null;
                        }
                    }
                }

                if (CurState == null)
                {
                    NextPulse = DateTime.Now.AddMilliseconds(DefaultFrequency + rnd.Next(-100, 100));
                }
                else
                {
                    NextPulse = DateTime.Now.AddMilliseconds(CurState.Frequency + rnd.Next(-100, 100));
                }
            }
        }