Task增加当前任务

This commit is contained in:
Stone 2016-06-17 02:13:13 +00:00
parent 9794a0c806
commit 00163b5cf0
3 changed files with 11 additions and 7 deletions

View File

@ -230,7 +230,7 @@ String Esp8266::Send(const String& cmd, cstring expect, cstring expect2, uint ms
String rs; String rs;
auto tid = Task::Scheduler()->Current->ID; auto task = Task::Current();
// 判断是否正在发送其它指令 // 判断是否正在发送其它指令
if(_Expect) if(_Expect)
{ {
@ -241,7 +241,7 @@ String Esp8266::Send(const String& cmd, cstring expect, cstring expect2, uint ms
w->Command->Trim().Show(false); w->Command->Trim().Show(false);
else else
net_printf("数据"); net_printf("数据");
net_printf(" %d 无法发送 ", tid); net_printf(" %d 无法发送 ", task.ID);
cmd.Trim().Show(true); cmd.Trim().Show(true);
#endif #endif
@ -250,7 +250,7 @@ String Esp8266::Send(const String& cmd, cstring expect, cstring expect2, uint ms
// 在接收事件中拦截 // 在接收事件中拦截
WaitExpect we; WaitExpect we;
we.TaskID = tid; we.TaskID = task.ID;
//we.Command = &cmd; //we.Command = &cmd;
we.Result = &rs; we.Result = &rs;
we.Key1 = expect; we.Key1 = expect;
@ -275,7 +275,7 @@ String Esp8266::Send(const String& cmd, cstring expect, cstring expect2, uint ms
if(EnableLog) if(EnableLog)
{ {
we.Command = &cmd; we.Command = &cmd;
net_printf("%d=> ", tid); net_printf("%d=> ", task.ID);
cmd.Trim().Show(true); cmd.Trim().Show(true);
} }
#endif #endif
@ -289,7 +289,7 @@ String Esp8266::Send(const String& cmd, cstring expect, cstring expect2, uint ms
#if NET_DEBUG #if NET_DEBUG
if(EnableLog && rs) if(EnableLog && rs)
{ {
net_printf("%d<= ", tid); net_printf("%d<= ", task.ID);
rs.Trim().Show(true); rs.Trim().Show(true);
} }
#endif #endif

View File

@ -153,12 +153,15 @@ Task* Task::Get(int taskid)
return (*Scheduler())[taskid]; return (*Scheduler())[taskid];
} }
Task& Task::Current()
{
return *(Scheduler()->Current);
}
#pragma arm section code #pragma arm section code
TaskScheduler::TaskScheduler(cstring name) TaskScheduler::TaskScheduler(cstring name)
{ {
//_Tasks.Clear();
//_Tasks.SetLength(0);
Name = name; Name = name;
Running = false; Running = false;

View File

@ -44,6 +44,7 @@ public:
// 全局任务调度器 // 全局任务调度器
static TaskScheduler* Scheduler(); static TaskScheduler* Scheduler();
static Task* Get(int taskid); static Task* Get(int taskid);
static Task& Current();
private: private:
friend class TaskScheduler; friend class TaskScheduler;