|
|
|
@ -40,6 +40,18 @@ static void return_disabled(struct db_command *cmd); |
|
|
|
static void handle_db_command(struct db_command *cmd); |
|
|
|
static int callback(void *result_str, int argc, char **argv, char **azColName); |
|
|
|
extern int sqlite3_init_with_sdram_heap(void); |
|
|
|
|
|
|
|
static const char *sql_upgrade_program_steps = |
|
|
|
"CREATE TABLE ProgramSteps (ProgramID VARCHAR,Program VARCHAR,Mode VARCHAR,Step INT,StepID VARCHAR,StepName VARCHAR," |
|
|
|
"ParameterName VARCHAR,P1 DOUBLE,P2 DOUBLE,P3 DOUBLE,P4 DOUBLE,P5 DOUBLE,P6 INT,P7 INT,P8 INT,P9 INT,P10 INT," |
|
|
|
"Remark VARCHAR,StepTime INT,StepID_S1 VARCHAR,StepID_S2 VARCHAR,StepID_S3 VARCHAR,StepName_S1 VARCHAR," |
|
|
|
"StepName_S2 VARCHAR,StepName_S3 VARCHAR,P1_S1 DOUBLE,P1_S2 DOUBLE,P1_S3 DOUBLE,P2_S1 DOUBLE,P2_S2 DOUBLE," |
|
|
|
"P2_S3 DOUBLE,P3_S1 DOUBLE,P3_S2 DOUBLE,P3_S3 DOUBLE,P4_S1 DOUBLE,P4_S2 DOUBLE,P4_S3 DOUBLE,P5_S1 DOUBLE," |
|
|
|
"P5_S2 DOUBLE,P5_S3 DOUBLE); "; |
|
|
|
|
|
|
|
static const char *sql_upgrade_programname = |
|
|
|
"CREATE TABLE ProgramName (ProgramName VARCHAR,ProgramID VARCHAR,[Group] VARCHAR,Step INT,Time VARCHAR,Notes VARCHAR); "; |
|
|
|
|
|
|
|
static const char *sql_upgrade_workorder_steps = |
|
|
|
"CREATE TABLE WorkorderSteps (WorkOrder VARCHAR,DYELOT VARCHAR,ProgramID VARCHAR,Program VARCHAR,ReDye INT DEFAULT (0)," |
|
|
|
"Mode VARCHAR,Step INT,StepID VARCHAR,StepName VARCHAR,ParameterName VARCHAR,P1 DOUBLE,P2 DOUBLE,P3 DOUBLE," |
|
|
|
@ -305,9 +317,14 @@ void db_sqlite_init_full(void) |
|
|
|
{ |
|
|
|
LOG_D("[DataBase] Init SQLite"); |
|
|
|
|
|
|
|
rt_uint8_t * ptr = rt_malloc(1024*4); |
|
|
|
rt_uint8_t * ptr = rt_malloc_align(1024*4, 8); |
|
|
|
sqlite3_config(SQLITE_CONFIG_PAGECACHE, ptr, 4096, 1); |
|
|
|
|
|
|
|
if (ptr == RT_NULL) { |
|
|
|
LOG_E("Failed to allocate PAGECACHE memory!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
sqlite3_initialize(); |
|
|
|
|
|
|
|
if (access(DB_NAME, F_OK) != 0) |
|
|
|
@ -325,6 +342,18 @@ void db_sqlite_init_full(void) |
|
|
|
|
|
|
|
sqlite3_exec(g_db, "PRAGMA cache_size = 8;", 0, 0, 0); |
|
|
|
|
|
|
|
if(sqlite3_exec(g_db,sql_upgrade_program_steps, 0, 0, 0)==0) |
|
|
|
{ |
|
|
|
LOG_D("[DataBASE]ProgramSteps Created successfully "); |
|
|
|
}else{ |
|
|
|
LOG_E("[DataBASE]ProgramSteps Creation failed "); |
|
|
|
} |
|
|
|
if(sqlite3_exec(g_db,sql_upgrade_programname, 0, 0, 0)==0) |
|
|
|
{ |
|
|
|
LOG_D("[DataBASE]ProgramName Created successfully "); |
|
|
|
}else{ |
|
|
|
LOG_E("[DataBASE]ProgramName Creation failed "); |
|
|
|
} |
|
|
|
if(sqlite3_exec(g_db,sql_upgrade_workorder_steps, 0, 0, 0)==0) |
|
|
|
{ |
|
|
|
LOG_D("[DataBASE]WorkorderSteps Created successfully "); |
|
|
|
|