/// <summary> /// /// </summary> /// <param name="headTask"></param> /// <returns></returns> //private bool DoNotExecutingTask(ITask headTask) private bool CanExecutingTask(ITask headTask) { TaskStatus status = headTask.Check(); if (status == TaskStatus.Ready) { ICommuniPort cp = GetCommuniPort(headTask); if ((cp != null) && (!cp.IsOccupy) && IsHighestLevel(headTask, cp)) { //IDevice device = headTask.Device; //headTask.Begin(cp); ////device.TaskManager.Current = headTask; //device.TaskManager.CaptureCurrent(headTask); return(true); } } return(false); }
/// <summary> /// /// </summary> /// <param name="current"></param> private void DoCurrentTask(ITask current) { TaskStatus status = current.Check(); switch (status) { case TaskStatus.Ready: { ICommuniPort cp = GetCommuniPort(current); if ((cp != null) && (!cp.IsOccupy)) //IsHighestLevel(headTask, cp)) { current.Begin(cp); } } break; case TaskStatus.Executing: break; case TaskStatus.Timeout: { ICommuniPort cp = GetCommuniPort(current); current.End(cp); DoCurrentTask(current); } break; case TaskStatus.Executed: { IParseResult pr = current.LastParseResult; ITaskProcessor processor = GetTaskProcessor(current); processor.Process(current, pr); DoCurrentTask(current); } break; case TaskStatus.Wating: { ClearDeviceCurrentTask(current); IDevice device = current.Device; device.TaskManager.Tasks.Enqueue(current); } break; case TaskStatus.Completed: { // clear current task // // current may not equal to current.Device.TaskManager.Current // so an other executing task will be remove // ClearDeviceCurrentTask(current); } break; default: { // // clear // throw new NotSupportedException(status.ToString()); } } #if DEBUG if (current.Strategy is CycleStrategy) { if (current.Device.TaskManager.Current == null) { bool b = current.Device.TaskManager.Tasks.Contains(current); Debug.Assert(b == true); } } #endif }
/// <summary> /// /// </summary> /// <param name="current"></param> private void DoCurrentTask(ITask current) { TaskStatus status = current.Check(); switch (status) { case TaskStatus.Ready: { ICommuniPort cp = GetCommuniPort(current); if ((cp != null) && (!cp.IsOccupy)) //IsHighestLevel(headTask, cp)) { current.Begin(cp); } } break; case TaskStatus.Executing: break; case TaskStatus.Timeout: { ICommuniPort cp = GetCommuniPort(current); current.End(cp); DoCurrentTask(current); } break; case TaskStatus.Executed: { IParseResult pr = current.LastParseResult; ITaskProcessor processor = GetTaskProcessor(current); processor.Process(current, pr); DoCurrentTask(current); } break; case TaskStatus.Wating: { //ClearDeviceCurrentTask(current); //IDevice device = current.Device; //device.TaskManager.Tasks.Enqueue(current); TaskManager taskMan = current.Device.TaskManager; taskMan.ReleaseCurrent(); } break; case TaskStatus.Completed: { // clear current task // // current may not equal to current.Device.TaskManager.Current // so an other executing task will be remove // //ClearDeviceCurrentTask(current); TaskManager taskMan = current.Device.TaskManager; taskMan.ReleaseCurrent(); } break; default: { // // clear // throw new NotSupportedException(status.ToString()); } } #if DEBUG if (current.Strategy is CycleStrategy) { if (current.Device.TaskManager.Current == null) { bool b = current.Device.TaskManager.Tasks.Contains(current); Debug.Assert(b == true); } } #endif }
/// <summary> /// /// </summary> /// <param name="headTask"></param> /// <returns></returns> private bool DoNotExecutingTask(ITask headTask) { TaskStatus status = headTask.Check(); if (status == TaskStatus.Ready) { ICommuniPort cp = GetCommuniPort(headTask); if ((cp != null) && (!cp.IsOccupy) && IsHighestLevel(headTask, cp)) { IDevice device = headTask.Device; headTask.Begin(cp); device.TaskManager.Current = headTask; return true; } } return false; }