mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
能测试添加, 能获取
This commit is contained in:
@@ -200,7 +200,7 @@ exit:
|
||||
static int HttpGetTasks(httpd_request_t *req)
|
||||
{
|
||||
pTimedTask pt = (pTimedTask)malloc(sizeof(struct TimedTask));
|
||||
pt->time = time(NULL);
|
||||
pt->time = time(NULL) + 5;
|
||||
pt->socket_idx = 5;
|
||||
pt->on = 0;
|
||||
AddTask(pt);
|
||||
|
||||
@@ -77,6 +77,11 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="task">
|
||||
<legend>Timed Task</legend>
|
||||
<button onclick="GetTimedTask()">Test</button>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="chart">
|
||||
<legend>Power Status</legend>
|
||||
<table class="pw">
|
||||
@@ -437,6 +442,19 @@ function GetSysLog() {
|
||||
});
|
||||
}
|
||||
|
||||
function GetTimedTask() {
|
||||
HttpGet("/task", function (re) {
|
||||
alert(re);
|
||||
});
|
||||
}
|
||||
|
||||
function AddTimedTask() {
|
||||
var sec = document.getElementById("task_time").value;
|
||||
HttpPost("/task", function (re) {
|
||||
alert(re);
|
||||
}, sec);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -177,6 +177,10 @@ int application_start(void)
|
||||
UserRelaySet(task_top->socket_idx, task_top->on);
|
||||
DelFirstTask();
|
||||
}
|
||||
else
|
||||
{
|
||||
os_log("task_top[%u]");
|
||||
}
|
||||
mico_thread_msleep(1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,15 +88,20 @@ bool DelTask(int time)
|
||||
|
||||
char* GetTaskStr()
|
||||
{
|
||||
char* str = (char*)malloc(sizeof(char)*task_count * 40);
|
||||
char* str = (char*)malloc(sizeof(char)*task_count * 52);
|
||||
pTimedTask tmp_tsk = task_top;
|
||||
char* tmp_str = str;
|
||||
tmp_str[0] = '[';
|
||||
tmp_str++;
|
||||
while (tmp_tsk)
|
||||
{
|
||||
sprintf(tmp_str, "{time:%d,socket_index:%d,on:%d},",
|
||||
tmp_tsk->time, tmp_tsk->socket_idx, tmp_tsk->on);
|
||||
char buffer[26];
|
||||
struct tm* tm_info;
|
||||
tm_info = localtime(&tmp_tsk->time);
|
||||
strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);
|
||||
|
||||
sprintf(tmp_str, "{time:'%s',socket_index:%d,on:%d},",
|
||||
buffer, tmp_tsk->socket_idx, tmp_tsk->on);
|
||||
tmp_str += strlen(tmp_str);
|
||||
tmp_tsk = tmp_tsk->next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user