From 9dcdecf9161a336e6f128a728abdda870901e37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=B1=20=E6=B2=88?= <2401809606@qq.com> Date: Sun, 22 Feb 2026 23:40:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E9=A1=B5=E9=9D=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/lvgl/guider/custom/custom.c | 95 +++++++++++++++++++ applications/lvgl/guider/custom/custom.h | 2 + .../lvgl/guider/generated/gui_guider.h | 2 + .../lvgl/guider/generated/setup_scr_screen.c | 6 +- applications/lvgl/lv__user_gui.c | 2 + applications/lvgl/ui_data_csv.c | 2 +- applications/lvgl/ui_data_labels.c | 49 +++++++++- applications/lvgl/ui_data_labels.h | 10 +- 8 files changed, 157 insertions(+), 11 deletions(-) diff --git a/applications/lvgl/guider/custom/custom.c b/applications/lvgl/guider/custom/custom.c index 1a84e57..4e4f751 100644 --- a/applications/lvgl/guider/custom/custom.c +++ b/applications/lvgl/guider/custom/custom.c @@ -39,6 +39,9 @@ */ int16_t Work_row = -1; int16_t Work_step_row = -1; +int16_t run_step_row = -1; +int16_t pname_row = -1; +int16_t pname_step_row = -1; // 绘图回调 static void table_style_cb(lv_event_t *e) { @@ -69,6 +72,24 @@ static void table_style_cb(lv_event_t *e) dsc->label_dsc->color = lv_color_hex(0xFFFFFF); // 白色文字 dsc->label_dsc->font = &lv_font_simsun_24; } + else if ((table == guider_ui.screen_run_step)&&(row == run_step_row)) { + dsc->rect_dsc->bg_color = lv_color_hex(0x007185); // 蓝色背景 + dsc->rect_dsc->bg_opa = LV_OPA_COVER; + dsc->label_dsc->color = lv_color_hex(0xFFFFFF); // 白色文字 + dsc->label_dsc->font = &lv_font_simsun_24; + } + else if ((table == guider_ui.screen_pname_row)&&(row == pname_row)) { + dsc->rect_dsc->bg_color = lv_color_hex(0x007185); // 蓝色背景 + dsc->rect_dsc->bg_opa = LV_OPA_COVER; + dsc->label_dsc->color = lv_color_hex(0xFFFFFF); // 白色文字 + dsc->label_dsc->font = &lv_font_simsun_24; + } + else if ((table == guider_ui.screen_pname_step_row)&&(row == pname_step_row)) { + dsc->rect_dsc->bg_color = lv_color_hex(0x007185); // 蓝色背景 + dsc->rect_dsc->bg_opa = LV_OPA_COVER; + dsc->label_dsc->color = lv_color_hex(0xFFFFFF); // 白色文字 + dsc->label_dsc->font = &lv_font_simsun_24; + } ; } } } @@ -134,6 +155,9 @@ static void table_click_event_cb(lv_event_t *e) { } Work_row=-1; Work_step_row=-1; + run_step_row = -1; + pname_row = -1; + pname_step_row = -1; //获得来源表 if(table == guider_ui.screen_list_inf)//总览信息/工艺信息 { @@ -147,6 +171,19 @@ static void table_click_event_cb(lv_event_t *e) { rt_snprintf(sql, sizeof(sql),"%s' AND Step = '%s'",value_W,lv_table_get_cell_value(guider_ui.screen_w_list, row, 0)); Work_Program_stepINF_ui(sql); } + else if(table == guider_ui.screen_run_step){//工艺信息 + run_step_row = row;// 写入行号 + if(value_W[0] == '\0') return; + } + else if(table == guider_ui.screen_pname_row){//工艺程序信息 + pname_row = row;// 写入行号 + rt_snprintf(value_W, sizeof(value_W),lv_table_get_cell_value(guider_ui.screen_pname_row, row, 0)); + UI_pname_step_row(value_W); + } + else if(table == guider_ui.screen_pname_step_row){//工艺程序细节信息 + pname_step_row = row;// 写入行号 + if(value_W[0] == '\0') return; + } } // 初始化样式 @@ -199,11 +236,43 @@ void table_style_init(lv_obj_t *container) lv_obj_set_style_pad_right(container, 10, LV_PART_ITEMS|LV_STATE_CHECKED); } +// 页面事件回调函数 +static void tabview_event_cb(lv_event_t *e) +{ + lv_event_code_t code = lv_event_get_code(e); + lv_obj_t *tabview = lv_event_get_target(e); + + if (code == LV_EVENT_VALUE_CHANGED) { + // 获取当前选中的 Tab 索引 + uint16_t tab_id = lv_tabview_get_tab_act(tabview); + // 根据 tab_id 执行不同操作 + switch (tab_id) { + case 0://工单页面 + + break; + case 1://工艺页面 + + break; + case 2: + + break; + case 3://程序页面 + UI_pname_row(); + break; + case 4: + + break; + } + } +} + void custom_init(lv_ui *ui) { lv_obj_clear_flag(lv_tabview_get_content(ui->screen_tabview), LV_OBJ_FLAG_SCROLLABLE);//禁止左右滑动 lv_obj_clear_flag(lv_tabview_get_content(ui->screen_w_io), LV_OBJ_FLAG_SCROLLABLE);//禁止左右滑动 + lv_obj_add_event_cb(ui->screen_tabview, tabview_event_cb, LV_EVENT_VALUE_CHANGED, NULL);// + lv_obj_set_style_pad_all(ui->screen_tabview_tab_1, 0, LV_PART_MAIN); lv_obj_set_style_pad_all(ui->screen_tabview_tab_2, 0, LV_PART_MAIN); lv_obj_set_style_pad_all(ui->screen_tabview_tab_3, 0, LV_PART_MAIN); @@ -263,6 +332,32 @@ void custom_init(lv_ui *ui) lv_table_set_col_width(guider_ui.screen_run_step, 1, 370); lv_table_set_cell_value(guider_ui.screen_run_step,0,0,"步"); lv_table_set_cell_value(guider_ui.screen_run_step,0,1,"工艺"); + + //程序页面的工艺信息列表 + guider_ui.screen_pname_row = lv_table_create(guider_ui.screen_step_set); + table_style_init(guider_ui.screen_pname_row); + lv_obj_add_event_cb(guider_ui.screen_pname_row, table_style_cb, LV_EVENT_DRAW_PART_BEGIN, NULL); + lv_table_set_col_cnt(guider_ui.screen_pname_row,3); + lv_table_set_col_width(guider_ui.screen_pname_row, 0, 430); + lv_table_set_col_width(guider_ui.screen_pname_row, 1, 84); + lv_table_set_col_width(guider_ui.screen_pname_row, 2, 200); + lv_table_set_cell_value(guider_ui.screen_pname_row,0,0,"工艺"); + lv_table_set_cell_value(guider_ui.screen_pname_row,0,1,"步骤"); + lv_table_set_cell_value(guider_ui.screen_pname_row,0,2,"时间"); + + + //程序页面的步骤列表 + guider_ui.screen_pname_step_row = lv_table_create(guider_ui.screen_proess_set); + lv_obj_set_pos(guider_ui.screen_pname_step_row, 0, 0); + lv_obj_set_size(guider_ui.screen_pname_step_row, 300, 50); + table_style_init(guider_ui.screen_pname_step_row); + lv_obj_add_event_cb(guider_ui.screen_pname_step_row, table_style_cb, LV_EVENT_DRAW_PART_BEGIN, NULL); + lv_table_set_row_cnt(guider_ui.screen_pname_step_row,1); + lv_table_set_col_width(guider_ui.screen_pname_step_row, 0, 50); + lv_table_set_col_width(guider_ui.screen_pname_step_row, 1, 250); + lv_table_set_cell_value(guider_ui.screen_pname_step_row,0,0,"步"); + lv_table_set_cell_value(guider_ui.screen_pname_step_row,0,1,"工艺"); + /* Add your codes here */ } diff --git a/applications/lvgl/guider/custom/custom.h b/applications/lvgl/guider/custom/custom.h index d9b1daa..ba2cdd9 100644 --- a/applications/lvgl/guider/custom/custom.h +++ b/applications/lvgl/guider/custom/custom.h @@ -17,6 +17,8 @@ extern "C" { extern int16_t Work_row; extern int16_t Work_step_row; +extern int16_t pname_row; +extern int16_t pname_step_row; void custom_init(lv_ui *ui); diff --git a/applications/lvgl/guider/generated/gui_guider.h b/applications/lvgl/guider/generated/gui_guider.h index 92ab3ee..4685827 100644 --- a/applications/lvgl/guider/generated/gui_guider.h +++ b/applications/lvgl/guider/generated/gui_guider.h @@ -452,6 +452,8 @@ typedef struct lv_obj_t *screen_list_inf; lv_obj_t *screen_w_list_NAME; lv_obj_t *screen_run_step; + lv_obj_t *screen_pname_row; + lv_obj_t *screen_pname_step_row; }lv_ui; typedef void (*ui_setup_scr_t)(lv_ui * ui); diff --git a/applications/lvgl/guider/generated/setup_scr_screen.c b/applications/lvgl/guider/generated/setup_scr_screen.c index 960389d..9b6d1e9 100644 --- a/applications/lvgl/guider/generated/setup_scr_screen.c +++ b/applications/lvgl/guider/generated/setup_scr_screen.c @@ -7188,7 +7188,7 @@ void setup_scr_screen(lv_ui *ui) //Write codes screen_w_5 ui->screen_w_5 = lv_obj_create(ui->screen_tabview_tab_5); lv_obj_set_pos(ui->screen_w_5, 0, 0); - lv_obj_set_size(ui->screen_w_5, 800, 470); + lv_obj_set_size(ui->screen_w_5, 800, 460); lv_obj_set_scrollbar_mode(ui->screen_w_5, LV_SCROLLBAR_MODE_OFF); //Write style for screen_w_5, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT. @@ -7245,7 +7245,7 @@ void setup_scr_screen(lv_ui *ui) ui->screen_sys_name = lv_label_create(ui->screen_w_5); lv_label_set_text(ui->screen_sys_name, "机台名"); lv_label_set_long_mode(ui->screen_sys_name, LV_LABEL_LONG_WRAP); - lv_obj_set_pos(ui->screen_sys_name, 20, 79); + lv_obj_set_pos(ui->screen_sys_name, 20, 80); lv_obj_set_size(ui->screen_sys_name, 100, 30); //Write style for screen_sys_name, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT. @@ -7342,7 +7342,7 @@ void setup_scr_screen(lv_ui *ui) lv_obj_align(ui->screen_sys_save_label, LV_ALIGN_CENTER, 0, 0); lv_obj_set_style_pad_all(ui->screen_sys_save, 0, LV_STATE_DEFAULT); lv_obj_set_width(ui->screen_sys_save_label, LV_PCT(100)); - lv_obj_set_pos(ui->screen_sys_save, 880, 420); + lv_obj_set_pos(ui->screen_sys_save, 880, 400); lv_obj_set_size(ui->screen_sys_save, 100, 50); //Write style for screen_sys_save, Part: LV_PART_MAIN, State: LV_STATE_DEFAULT. diff --git a/applications/lvgl/lv__user_gui.c b/applications/lvgl/lv__user_gui.c index 74da874..1c5dff0 100644 --- a/applications/lvgl/lv__user_gui.c +++ b/applications/lvgl/lv__user_gui.c @@ -70,10 +70,12 @@ void setup_s_screen(lv_ui *ui) { //工单 lv_label_set_text(ui->screen_order, (const char *)Work);//显示当前信息 + lv_label_set_text(ui->screen_process, (const char *)Process); lv_obj_clear_flag(ui->screen_inf_plc, LV_OBJ_FLAG_HIDDEN); }else{ lv_obj_add_flag(ui->screen_inf_plc, LV_OBJ_FLAG_HIDDEN); lv_label_set_text(ui->screen_order, "PLC Not Connected");//显示plc断开 + lv_label_set_text(ui->screen_process, "工艺[停止]"); } if(USB_OK)//USB接入 { diff --git a/applications/lvgl/ui_data_csv.c b/applications/lvgl/ui_data_csv.c index a6db9bb..4fccea9 100644 --- a/applications/lvgl/ui_data_csv.c +++ b/applications/lvgl/ui_data_csv.c @@ -331,7 +331,7 @@ int run_csv_to_set(const char *csv_data) { //数据组信息 rt_snprintf(Work,sizeof(Work),csv_get_cell(user, 1, 0)); rt_snprintf(Dye,sizeof(Dye),csv_get_cell(user, 1, 1)); - rt_snprintf(Process,sizeof(Process),csv_get_cell(user, 1, 2)); + rt_snprintf(Process,sizeof(Process),"%s:%s","工艺",csv_get_cell(user, 1, 2)); Pump = atoi(csv_get_cell(user, 1, 3)); Fan = atoi(csv_get_cell(user, 1, 4)); Swing = atoi(csv_get_cell(user, 1, 5)); diff --git a/applications/lvgl/ui_data_labels.c b/applications/lvgl/ui_data_labels.c index a1abe0c..c5679e3 100644 --- a/applications/lvgl/ui_data_labels.c +++ b/applications/lvgl/ui_data_labels.c @@ -374,7 +374,14 @@ void Work_Program_step_ui(char* str_data) // 表格绘图 parse_csv_to_inf(guider_ui.screen_text_inf,"",550,230); - if((select_data_ui[0]=='N')&&(select_data_ui[1]=='o'))return; + if((select_data_ui[0]=='N')&&(select_data_ui[1]=='o')){ + parse_csv_to_inf(guider_ui.screen_text_inf,"",550,230); + lv_table_set_col_cnt(guider_ui.screen_w_list,2); + lv_table_set_row_cnt(guider_ui.screen_w_list,0); + lv_table_set_col_width(guider_ui.screen_w_list, 0, 50); + lv_table_set_col_width(guider_ui.screen_w_list, 1, 250); + return; + } parse_csv_to_table(guider_ui.screen_w_list, select_data_ui,1); lv_table_set_col_width(guider_ui.screen_w_list, 0, 50); lv_table_set_col_width(guider_ui.screen_w_list, 1, 250); @@ -401,8 +408,9 @@ void Work_Program_stepINF_ui(char* str_data) parse_csv_to_inf(guider_ui.screen_text_inf,select_data_ui,550,230); } } + //启动按钮 -void Work_start() +void Work_start(void) { if (Work_NAME[0] == '\0') return; if(Work_Program_DATA==0) @@ -414,7 +422,6 @@ void Work_start() //启动信息 rt_snprintf(sqlSELECT, sizeof(sqlSELECT),"%s w.WorkOrder = '%s' LIMIT 1;",select_Workorder_R,Work_NAME); db_send_select(DB_CMD_SELECT, sqlSELECT, 500,select_data_ui); - rt_kprintf(select_data_ui); run_csv_to_set(select_data_ui); } else @@ -425,3 +432,39 @@ void Work_start() run_csv_to_table(select_data_ui); } } + +// +void UI_pname_row(void) +{ + pname_row = -1; + pname_step_row = -1; + // 查询工艺数据 + db_send_select(DB_CMD_SELECT, select_Program_DATA, 500,select_data_ui); + // 表格绘图 + parse_csv_to_table(guider_ui.screen_pname_row, select_data_ui,0); + lv_table_set_col_width(guider_ui.screen_pname_row, 0, 430); + lv_table_set_col_width(guider_ui.screen_pname_row, 1, 80); + lv_table_set_col_width(guider_ui.screen_pname_row, 2, 200); +} + +// +void UI_pname_step_row(char* str_data) +{ + pname_step_row = -1; + // 查询工艺数据 + rt_snprintf(sqlSELECT, sizeof(sqlSELECT),"%s'%s' ORDER BY Step ASC;",select_ProgramSteps_DATA,str_data); + db_send_select(DB_CMD_SELECT, sqlSELECT, 500,select_data_ui); + // 表格绘图 + if((select_data_ui[0]=='N')&&(select_data_ui[1]=='o')){ + lv_table_set_col_cnt(guider_ui.screen_pname_step_row,2); + lv_table_set_row_cnt(guider_ui.screen_pname_step_row,0); + lv_table_set_col_width(guider_ui.screen_pname_step_row, 0, 50); + lv_table_set_col_width(guider_ui.screen_pname_step_row, 1, 250); + lv_table_set_cell_value(guider_ui.screen_pname_step_row,0,0,"步"); + lv_table_set_cell_value(guider_ui.screen_pname_step_row,0,1,"步骤工艺"); + return; + } + parse_csv_to_table(guider_ui.screen_pname_step_row, select_data_ui,0); + lv_table_set_col_width(guider_ui.screen_pname_step_row, 0, 50); + lv_table_set_col_width(guider_ui.screen_pname_step_row, 1, 250); +} diff --git a/applications/lvgl/ui_data_labels.h b/applications/lvgl/ui_data_labels.h index 166825e..71a5695 100644 --- a/applications/lvgl/ui_data_labels.h +++ b/applications/lvgl/ui_data_labels.h @@ -13,6 +13,8 @@ #define select_WorkOrder_DATA "SELECT WorkOrder AS 工单,ProgramName AS 工艺 ,Dyelot || '@' || ReDye AS 领料单,\ StartTime AS 预计开始,EndTime AS 预计完成,Time AS 预计用时,lock AS 锁定,State AS 状态,USER AS 用户 FROM WorkOrder WHERE State=101 AND EndTime > " #define select_Program_DATA "SELECT ProgramName AS 工艺 ,Step AS 步骤,Time AS 预计时间 FROM ProgramName" +#define select_ProgramSteps_DATA "SELECT Step AS 步 ,StepName AS 步骤工艺 FROM ProgramSteps WHERE Program=" +#define select_WorkorderSteps_DATA "SELECT Step AS 步 ,StepName AS 步骤工艺 FROM WorkorderSteps WHERE WorkOrder=" #define select_Workorder_R "SELECT w.WorkOrder, w.Dyelot, w.ProgramName, s.PumpSpeed, s.Blower, s.Swing, s.ClothWheel, s.Nozzle\ FROM WorkOrder w LEFT JOIN WorkOrderSet s ON w.WorkOrder = s.WorkOrder WHERE" @@ -23,9 +25,6 @@ StepID_S1,StepID_S2,StepID_S3 FROM WorkorderSteps WHERE " P1_S1,P2_S1,P3_S1,P4_S1,P5_S1,P1_S2,P2_S2,P3_S2,P4_S2,P5_S2,P1_S3,P2_S3,P3_S3,P4_S3,P5_S3,ReDye,\ StepID_S1,StepID_S2,StepID_S3 FROM ProgramSteps WHERE" -#define select_ProgramSteps_DATA "SELECT Step AS 步 ,StepName AS 步骤工艺 FROM ProgramSteps WHERE Program=" -#define select_WorkorderSteps_DATA "SELECT Step AS 步 ,StepName AS 步骤工艺 FROM WorkorderSteps WHERE WorkOrder=" - #define select_ProgramStepsinf_DATA "SELECT Program AS 工艺 ,Step AS 步号 ,StepName AS 步骤工艺 , ParameterName AS 细节,\ P1 AS 参数1 ,P2 AS 参数2 ,P3 AS 参数3 ,P4 AS 参数4 ,P5 AS 参数5 ,StepName_S1 AS 副功能1 ,P1_S1 AS 参数1_1 ,P2_S1 AS 参数1_2,\ P3_S1 AS 参数1_3 ,P4_S1 AS 参数1_4 ,P5_S1 AS 参数1_5 ,StepName_S2 AS 功能2 ,P1_S2 AS 参数2_1 ,P2_S2 AS 参数2_2, \ @@ -109,6 +108,9 @@ char* get_time_str(char *buf, size_t size); void Work_Program_ui(void); void Work_Program_step_ui(char* str_data); void Work_Program_stepINF_ui(char* str_data); -void Work_start(); +void Work_start(void); + +void UI_pname_row(void); +void UI_pname_step_row(char* str_data); #endif /* APPLICATIONS_LVGL_UI_DATA_LABELS_H_ */