示例#1
0
文件: Program.cs 项目: fishykins/CAM
        /// <summary>
        /// Main loop where coroutine.Update() is called.
        /// </summary>
        /// <param name="argument"></param>
        /// <param name="updateSource"></param>
        public void Main(string argument, UpdateType updateSource)
        {
            //Catch manual triggers and exclude from cycles
            if (updateSource == UpdateType.Trigger || updateSource == UpdateType.Terminal)
            {
                manualProgram.Trigger(argument, output);
                output.Update();
                return;
            }

            //Run diagnostics every loop
            diagnostics.Update();

            //Prevent routines running if sleeping
            if (sleepTimeLeft > 0)
            {
                sleepTimeLeft--;
                EndUpdate();
                return;
            }

            //Loop index
            if (routineIndex >= routineCount)
            {
                cycle++;
                routineIndex = 0;
            }

            currentRoutine = routines[routineIndex];

            SetDisplayHeader();

            //Run a coroutine
            currentRoutine.Update();

            EndUpdate();
        }