Browse Source

添加步骤数据表step

master
忱 沈 3 weeks ago
parent
commit
634a2cb475
  1. 59
      applications/data/DATA_comm.c
  2. 31
      applications/data/SC828_DATA_table.c
  3. 29
      applications/data/SC828_DATA_table.h
  4. 1
      applications/data/Variable.c
  5. 2
      applications/data/Variable.h
  6. 2
      applications/main.c

59
applications/data/DATA_comm.c

@ -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)
{

31
applications/data/SC828_DATA_table.c

@ -1,4 +1,5 @@
#include "SC828_DATA_table.h"
#include <rtthread.h>
// 系统数据状态表(表格)
IO_State_DATA data_table[] = {
@ -210,6 +211,8 @@ IO_State_AIO aio_table[] = {
{5013, 0, STR_AIO_LIFT5},
{5014, 0, STR_AIO_LIFT6}
};
//步骤数据表最大99
IO_STEP_DATA step_table[99];
const unsigned char DIO_TABLE_SIZE = sizeof(dio_table) / sizeof(dio_table[0]);
const unsigned char AIO_TABLE_SIZE = sizeof(aio_table) / sizeof(aio_table[0]);
@ -228,4 +231,32 @@ void DATA_Table_Init(){
{
data_table[i].current_data = 0;
}
for(int i=0;i<99;i++)
{
step_table[i].RUN = 0;
step_table[i].Parameter1 = 0;
step_table[i].Parameter2 = 0;
step_table[i].Parameter3 = 0;
step_table[i].Parameter4 = 0;
step_table[i].Parameter5 = 0;
step_table[i].Parameter1_S1 = 0;
step_table[i].Parameter2_S1 = 0;
step_table[i].Parameter3_S1 = 0;
step_table[i].Parameter4_S1 = 0;
step_table[i].Parameter5_S1 = 0;
step_table[i].Parameter1_S2 = 0;
step_table[i].Parameter2_S2 = 0;
step_table[i].Parameter3_S2 = 0;
step_table[i].Parameter4_S2 = 0;
step_table[i].Parameter5_S2 = 0;
step_table[i].Parameter1_S3 = 0;
step_table[i].Parameter2_S3 = 0;
step_table[i].Parameter3_S3 = 0;
step_table[i].Parameter4_S3 = 0;
step_table[i].Parameter5_S3 = 0;
rt_snprintf(step_table[i].StepID, 3,"000");
rt_snprintf(step_table[i].StepID_S1, 3,"000");
rt_snprintf(step_table[i].StepID_S2, 3,"000");
rt_snprintf(step_table[i].StepID_S3, 3,"000");
}
}

29
applications/data/SC828_DATA_table.h

@ -23,9 +23,38 @@ typedef struct {
str_id_t name; // 名称(可选,用于调试)
} IO_State_DATA;
typedef struct {
int RUN;
char StepID[3];
double Parameter1;
double Parameter2;
double Parameter3;
double Parameter4;
double Parameter5;
char StepID_S1[3];
char StepID_S2[3];
char StepID_S3[3];
double Parameter1_S1;
double Parameter2_S1;
double Parameter3_S1;
double Parameter4_S1;
double Parameter5_S1;
double Parameter1_S2;
double Parameter2_S2;
double Parameter3_S2;
double Parameter4_S2;
double Parameter5_S2;
double Parameter1_S3;
double Parameter2_S3;
double Parameter3_S3;
double Parameter4_S3;
double Parameter5_S3;
} IO_STEP_DATA;
extern IO_State_DIO dio_table[];
extern IO_State_AIO aio_table[];
extern IO_State_DATA data_table[];
extern IO_STEP_DATA step_table[99];
extern const unsigned char DIO_TABLE_SIZE;
extern const unsigned char AIO_TABLE_SIZE;

1
applications/data/Variable.c

@ -5,6 +5,7 @@
//系统信息变量
rt_int32_t sys_temperature;//主机环境温度
rt_int32_t sys_humidity;//主机环境湿度
char sys_var[8];//主机版本0.0.00A
unsigned char sys_time[6];//系统时间
unsigned int sys_run_time;//运行时间

2
applications/data/Variable.h

@ -6,8 +6,10 @@
//系统信息变量
extern rt_int32_t sys_temperature;//主机环境温度
extern rt_int32_t sys_humidity;//主机环境湿度
extern char sys_var[8];//主机版本0.0.00A
extern unsigned char sys_time[6];//系统时间
extern unsigned int sys_run_time;//运行时间
// ===== 字符串变量 =====
extern char *DATA_dat;
extern char DATA_machins[3];

2
applications/main.c

@ -11,6 +11,7 @@
#include <rtthread.h>
#include <light/RUN_LED.h>
#include "DB_SQLite.h"
#include "Variable.h"
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
@ -24,5 +25,6 @@ int main(void)
thread_DB_SQLite();
thread_RUN_LED();//运行指示灯线程
rt_snprintf(sys_var, sizeof(sys_var),"0.0.01a");
return RT_EOK;
}

Loading…
Cancel
Save