|
|
|
@ -127,10 +127,10 @@ void pasre_DAT(const char *api, const char *json_str) |
|
|
|
char systime[18] = {0}; // 初始化为 0
|
|
|
|
rt_snprintf(systime, sizeof(systime),"%d-%d-%d_%d:%d:%d", |
|
|
|
sys_time[5], sys_time[4], sys_time[3],sys_time[2],sys_time[1], sys_time[0]); |
|
|
|
|
|
|
|
cJSON_AddItemToObject(dat,"SYSTEMP",cJSON_CreateNumber(sys_temperature)); |
|
|
|
cJSON_AddItemToObject(dat,"SYSHUM",cJSON_CreateNumber(sys_humidity)); |
|
|
|
cJSON_AddItemToObject(dat,"SYSTIME",cJSON_CreateString(systime)); |
|
|
|
cJSON_AddItemToObject(dat,"VAR",cJSON_CreateString(sys_var)); |
|
|
|
} |
|
|
|
else if (strcmp(api, "SC810") == 0) |
|
|
|
{ |
|
|
|
@ -147,10 +147,8 @@ void pasre_DAT(const char *api, const char *json_str) |
|
|
|
// 定义足够大的缓冲区
|
|
|
|
char sql[512] = {0}; // 初始化为 0
|
|
|
|
// 安全格式化
|
|
|
|
rt_snprintf(sql, sizeof(sql), |
|
|
|
"INSERT INTO WorkOrder(WorkOrder,DYELOT,ReDye,StartTime,Time)" |
|
|
|
"VALUES('%s','%s',0,'%s','%s')", |
|
|
|
Work_, Dye_, STime_,pTime_); |
|
|
|
rt_snprintf(sql, sizeof(sql),"INSERT INTO WorkOrder(WorkOrder,DYELOT,ReDye,StartTime,Time)" |
|
|
|
"VALUES('%s','%s',0,'%s','%s')",Work_, Dye_, STime_,pTime_); |
|
|
|
if( db_send_command(DB_CMD_EXEC, sql, 500)==RT_EOK) //
|
|
|
|
{ |
|
|
|
cJSON_AddItemToObject(dat,"Work",cJSON_CreateString(Work_)); |
|
|
|
@ -196,10 +194,8 @@ void pasre_DAT(const char *api, const char *json_str) |
|
|
|
char sql[512] = {0}; // 初始化为 0
|
|
|
|
|
|
|
|
// 安全格式化
|
|
|
|
rt_snprintf(sql, sizeof(sql), |
|
|
|
"INSERT INTO WorkorderSteps(WorkOrder,DYELOT,ReDye,Step,StepID,P1,P2,P3,P4,P5,StepID_S1,P1_S1,P2_S1,P3_S1,P4_S1,P5_S1)" |
|
|
|
"VALUES('%s','%s',0,%d,'%s',%d,%d,%d,%d,%d,'%s',%d,%d,%d,%d,%d)", |
|
|
|
Work_, Dye_, StepN_,StepID_,P1_, P2_, P3_, P4_, P5_,SIDS1_,P1S1_,P2S1_,P3S1_,P4S1_,P5S1_ ); |
|
|
|
rt_snprintf(sql, sizeof(sql),"INSERT INTO WorkorderSteps(WorkOrder,DYELOT,ReDye,Step,StepID,P1,P2,P3,P4,P5,StepID_S1,P1_S1,P2_S1,P3_S1,P4_S1,P5_S1)" |
|
|
|
"VALUES('%s','%s',0,%d,'%s',%d,%d,%d,%d,%d,'%s',%d,%d,%d,%d,%d)",Work_, Dye_, StepN_,StepID_,P1_, P2_, P3_, P4_, P5_,SIDS1_,P1S1_,P2S1_,P3S1_,P4S1_,P5S1_ ); |
|
|
|
if( db_send_command(DB_CMD_EXEC, sql, 500)==RT_EOK) //
|
|
|
|
{ |
|
|
|
cJSON_AddItemToObject(dat,"Work",cJSON_CreateString(Work_)); |
|
|
|
@ -227,10 +223,8 @@ void pasre_DAT(const char *api, const char *json_str) |
|
|
|
// 定义足够大的缓冲区
|
|
|
|
char sql[512] = {0}; // 初始化为 0
|
|
|
|
// 安全格式化
|
|
|
|
rt_snprintf(sql, sizeof(sql), |
|
|
|
"INSERT OR IGNORE INTO WorkOrderSet(WorkOrder,ReDye,PumpSpeed,Blower,ClothWheel,Swing,Nozzle)" |
|
|
|
"VALUES('%s',0,%d,%d,%d,%d,%d)", |
|
|
|
Work_, Pump_,Blower_,ClothWheel_, Swing_, Nozzle_); |
|
|
|
rt_snprintf(sql, sizeof(sql),"INSERT OR IGNORE INTO WorkOrderSet(WorkOrder,ReDye,PumpSpeed,Blower,ClothWheel,Swing,Nozzle)" |
|
|
|
"VALUES('%s',0,%d,%d,%d,%d,%d)",Work_, Pump_,Blower_,ClothWheel_, Swing_, Nozzle_); |
|
|
|
if( db_send_command(DB_CMD_EXEC, sql, 500)==RT_EOK) //
|
|
|
|
{ |
|
|
|
cJSON_AddItemToObject(dat,"Work",cJSON_CreateString(Work_)); |
|
|
|
@ -259,10 +253,8 @@ void pasre_DAT(const char *api, const char *json_str) |
|
|
|
// 定义足够大的缓冲区
|
|
|
|
char sql[512] = {0}; // 初始化为 0
|
|
|
|
// 安全格式化
|
|
|
|
rt_snprintf(sql, sizeof(sql), |
|
|
|
"INSERT OR IGNORE INTO Dyelot(WorkOrder,Dyelot,ReDye,Step,ProductCode,ProductName,ProductType,Grams)" |
|
|
|
"VALUES('%s','%s',0,%d,%s,%s,%d,%s)", |
|
|
|
Work_, Dye_,StepN_,ProductCode_,ProductName_ ,ProductType_,Grams_); |
|
|
|
rt_snprintf(sql, sizeof(sql),"INSERT OR IGNORE INTO Dyelot(WorkOrder,Dyelot,ReDye,Step,ProductCode,ProductName,ProductType,Grams)" |
|
|
|
"VALUES('%s','%s',0,%d,%s,%s,%d,%s)",Work_, Dye_,StepN_,ProductCode_,ProductName_ ,ProductType_,Grams_); |
|
|
|
if( db_send_command(DB_CMD_EXEC, sql, 500)==RT_EOK) //
|
|
|
|
{ |
|
|
|
cJSON_AddItemToObject(dat,"Work",cJSON_CreateString(Work_)); |
|
|
|
@ -274,14 +266,41 @@ void pasre_DAT(const char *api, const char *json_str) |
|
|
|
else if (strcmp(api, "SC820") == 0) |
|
|
|
{//设置系统时间
|
|
|
|
char Time_[25]; |
|
|
|
|
|
|
|
GET_STRING(Time_, root, "Work", sizeof(Time_)); |
|
|
|
|
|
|
|
cJSON_AddItemToObject(dat,"time",cJSON_CreateString("systime")); |
|
|
|
char systime[18] = {0}; // 初始化为 0
|
|
|
|
rt_snprintf(systime, sizeof(systime),"%d-%d-%d_%d:%d:%d", |
|
|
|
sys_time[5], sys_time[4], sys_time[3],sys_time[2],sys_time[1], sys_time[0]); |
|
|
|
|
|
|
|
cJSON_AddItemToObject(dat,"time",cJSON_CreateString(systime)); |
|
|
|
} |
|
|
|
else if (strcmp(api, "SC821") == 0) |
|
|
|
{ |
|
|
|
printf("Processing:SC821\n"); |
|
|
|
char ins_[8]; |
|
|
|
GET_STRING(ins_, root, "INSTRUCTION", sizeof(ins_)); |
|
|
|
if (strcmp(ins_, "START") == 0) |
|
|
|
{} |
|
|
|
else if (strcmp(ins_, "STOP") == 0) |
|
|
|
{} |
|
|
|
else if (strcmp(ins_, "PAUSE") == 0) |
|
|
|
{} |
|
|
|
else if (strcmp(ins_, "CONTINUE") == 0) |
|
|
|
{} |
|
|
|
else if (strcmp(ins_, "JUMP") == 0) |
|
|
|
{} |
|
|
|
else if (strcmp(ins_, "INSERT") == 0) |
|
|
|
{} |
|
|
|
else if (strcmp(ins_, "EDIT") == 0) |
|
|
|
{} |
|
|
|
else if (strcmp(ins_, "DELETE") == 0) |
|
|
|
{ |
|
|
|
int ID_s; |
|
|
|
GET_INT_FROM_ANY(ID_s, root, "ID", sizeof(ID_s)); |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{} |
|
|
|
|
|
|
|
} |
|
|
|
else if (strcmp(api, "SC822") == 0) |
|
|
|
{ |
|
|
|
|