Sfoglia il codice sorgente

F427 显示屏显示相信息

liyi 9 mesi fa
parent
commit
64c7e80166
4 ha cambiato i file con 231 aggiunte e 33 eliminazioni
  1. 3 2
      f427/applications/cfg.h
  2. 1 1
      f427/applications/dflt.c
  3. 16 11
      f427/applications/snmp.c
  4. 211 19
      f427/applications/ui/menu.c

+ 3 - 2
f427/applications/cfg.h

@@ -54,8 +54,9 @@
 		//#define PROD_TYPE                             PDU_AC_I3O1
     //#define PROD_TYPE 													 PDU_DC_I1O1
     #define USE_UI
-    #define ROTATE                             90
-
+    #define ROTATE                              90
+		#define  PH_INFO       										"111112222233333"
+		
 #else
     #error define a PRJ_XXXX please!
 #endif

+ 1 - 1
f427/applications/dflt.c

@@ -81,7 +81,7 @@ const paras_data_t DFLT_PARAS={
 					.trapmode = 1,
 					.nms_ip = "127.0.0.1",
 				},
-				.phase_seq="33333333222222223333333311111111",
+				.phase_seq=PH_INFO,
 				.phase_seq_2={
 					.phase_left="11111111222222223333333311111111",
 					.phase_right="22222222333333331111111122222222",				

+ 16 - 11
f427/applications/snmp.c

@@ -116,7 +116,7 @@ static s16_t total_get_value(const struct snmp_scalar_array_node_def *node, void
     s16_t var_len;
 		char buff[100]= {0};
 		power_all_t *all = power_get_all();
-		
+		uint8_t id = 0;
 		switch(node->oid)
 		{
 			case SCALAR_VOLTAGE:
@@ -929,6 +929,11 @@ static s16_t power_get_value(struct snmp_node_instance *instance, void *value)
     u32_t row = instance->reference.u32;
     u32_t col = SNMP_TABLE_GET_COLUMN_FROM_OID(instance->instance_oid.id);
 		char buff[100]= {0};
+		uint8_t id = 0;
+		if(all->ttl.type == PDU_AC_I3O2 || all->ttl.type == PDU_AC_I3O3 || all->ttl.type == PDU_AC_I3O1 || all->ttl.type == PDU_AC_I3O1_H)
+		{
+			id = all->pch[row-1].info.ph_id - 1;
+		}
 		switch (col)
 		{
 			case COLUMN_PDUCHANNELID:
@@ -952,40 +957,40 @@ static s16_t power_get_value(struct snmp_node_instance *instance, void *value)
 				break;
 			case COLUMN_PDUCHANNELVOLTAGE:
 			{
-				sprintf(buff,"%.2f",((float)all->pch[row-1].power[0].voltage)/100.0);
+				sprintf(buff,"%.2f",((float)all->pch[row-1].power[id].voltage)/100.0);
 			}
 				break;
 			case COLUMN_PDUCHANNELCURRENT:
 			{
-				sprintf(buff,"%.2f",((float)all->pch[row-1].power[0].current)/100.0);
+				sprintf(buff,"%.2f",((float)all->pch[row-1].power[id].current)/100.0);
 			}
 				break;
 			case COLUMN_PDUCHANNELFREQUENCY:
 			{
-				sprintf(buff,"%.2f",((float)all->pch[row-1].power[0].freq)/100.0);
+				sprintf(buff,"%.2f",((float)all->pch[row-1].power[id].freq)/100.0);
 			}
 				break;
 			case COLUMN_PDUCHANNELCONSUMPTION:
 			{
-				sprintf(buff,"%.2f",((float)all->pch[row-1].power[0].consump)/100.0);
+				sprintf(buff,"%.2f",((float)all->pch[row-1].power[id].consump)/100.0);
 			}
 				break;
 			case COLUMN_PDUCHANNELPOWERFACTOR:
 			{
-				sprintf(buff,"%.2f",((float)all->pch[row-1].power[0].factor)/100.0);
+				sprintf(buff,"%.2f",((float)all->pch[row-1].power[id].factor)/100.0);
 			}
 				break;
 			case COLUMN_PDUCHANNELPACTIVEPOWER:
 			{
-				sprintf(buff,"%.2f",((float)all->pch[row-1].power[0].power)/100.0);
+				sprintf(buff,"%.2f",((float)all->pch[row-1].power[id].power)/100.0);
 			}
 				break;
 			case COLUMN_PDUCHANNELREACTIVEPOWER:
 			{
 				float reactive = 0.0;
-				if(all->pch[row-1].power[0].power > 0)
+				if(all->pch[row-1].power[id].power > 0)
 				{
-					reactive =  (float)(all->pch[row-1].power[0].power) / all->pch[row-1].power[0].factor - ((float)all->pch[row-1].power[0].power/100.0);
+					reactive =  (float)(all->pch[row-1].power[id].power) / all->pch[row-1].power[id].factor - ((float)all->pch[row-1].power[id].power/100.0);
 				}
 				sprintf(buff,"%.2f",reactive);
 			}
@@ -993,8 +998,8 @@ static s16_t power_get_value(struct snmp_node_instance *instance, void *value)
 			case COLUMN_PDUCHANNELAPPARENTPOWER:
 			{
 				float app_power = 0.0;
-				if(all->pch[row-1].power[0].power > 0)
-					app_power = (float)(all->pch[row-1].power[0].power) / all->pch[row-1].power[0].factor;
+				if(all->pch[row-1].power[id].power > 0)
+					app_power = (float)(all->pch[row-1].power[id].power) / all->pch[row-1].power[id].factor;
 				sprintf(buff,"%.2f",app_power);
 			}
 				break;

+ 211 - 19
f427/applications/ui/menu.c

@@ -142,12 +142,16 @@ static int is_ph3_in(menu_handle_t *h)
     }
     return 0;
 }
-static int is_ph3_out(menu_handle_t *h)
+static int is_ph3_2_out(menu_handle_t *h)
 {
     paras_data_t *p=paras_get();
-    if (p->prod.type == PDU_AC_I3O3) {
+    if (p->prod.type == PDU_AC_I3O3) 
+		{
         return 1;
-    }
+    }else if(p->prod.type == PDU_AC_I3O2)
+		{
+			return 2;
+		}
     return 0;
 }
 static int get_input(menu_handle_t *h, int ph, total_t *ttl)
@@ -158,7 +162,10 @@ static int get_input(menu_handle_t *h, int ph, total_t *ttl)
     if(all.chs==0 || !ttl) {
         return -1;
     }
-    *ttl = all.ttl.total[ph];
+		if(ph > 0)
+			*ttl = all.ttl.total[ph-1];
+		else
+			*ttl = all.ttl.total[ph];
     return 0;
 }
 static int get_output(menu_handle_t *h, int ch, int ph, power_ch_t *pwr_ch)
@@ -242,7 +249,7 @@ static void menu_input_paint(menu_handle_t *h, int font1, int font2, int item_h,
     r = get_input(h, h->ph_in, pttl);
     if(r==0) {
         if(h->menu.menu_lv==1 && h->ph_in>0) {
-            sprintf(tmp, "%s-L%d", lang_get_str(h->lang, STR_ID_INPUT), h->ph_in);
+            sprintf(tmp, "%s - L%d", lang_get_str(h->lang, STR_ID_INPUT), h->ph_in);
         }
     }
 
@@ -325,6 +332,26 @@ static void menu_output_paint(menu_handle_t *h, int font1, int font2, int item_h
 		}
 		
     if(h->ch_out_max>0) {
+			if(h->menu.menu_lv == 1)
+			{
+				if(all->ttl.type == PDU_AC_I3O2)
+				{
+					if(h->ph_out == 1)
+					{
+						sprintf(tmp, "%s CH%d - L%d", lang_get_str(h->lang, STR_ID_OUTPUT), h->ch_out+1,all->pch[h->ch_out+1].info.ph_id);
+					}else
+					{
+						sprintf(tmp, "%s CH%d - L%d", lang_get_str(h->lang, STR_ID_OUTPUT), h->ch_out+1,all->pch[h->ch_out+1].info.ph_val);
+					}
+				}else if(all->ttl.type == PDU_AC_I3O3)
+				{
+					sprintf(tmp, "%s CH%d - L%d", lang_get_str(h->lang, STR_ID_OUTPUT), h->ch_out+1,h->ph_out);
+				}else
+				{
+					sprintf(tmp, "%s CH%d", lang_get_str(h->lang, STR_ID_OUTPUT), h->ch_out+1);
+				}
+			}
+			else
         sprintf(tmp, "%s CH%d", lang_get_str(h->lang, STR_ID_OUTPUT), h->ch_out+1);
     }else
 		{
@@ -366,34 +393,99 @@ static void menu_output_paint(menu_handle_t *h, int font1, int font2, int item_h
 			lcd_draw_string(LCD_WIDTH/2, item_h, LCD_WIDTH/2, item_h, tmp, font2, COLOR_RED, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
 		}
 		
+		float current = 0.0;
+		float power = 0.0;
+		float factor = 0.0;
+		float consumer = 0.0;
+	
+		if(all->ttl.type == PDU_AC_I3O1 || all->ttl.type == PDU_AC_I3O1_H)
+		{
+			uint8_t id = all->pch[h->ch_out+1].info.ph_id - 1;
+			current = all->pch[h->ch_out+1].power[id].current/100.0;
+			power = all->pch[h->ch_out+1].power[id].power/100.0;
+			factor = all->pch[h->ch_out+1].power[id].factor/100.0;
+			consumer = all->pch[h->ch_out+1].power[id].consump/100.0;
+		}else if(all->ttl.type == PDU_AC_I3O3)
+		{
+			if(h->menu.menu_lv == 1)
+			{
+				uint8_t id = h->ph_out - 1;
+				current = all->pch[h->ch_out+1].power[id].current/100.0;
+				power = all->pch[h->ch_out+1].power[id].power/100.0;
+				factor = all->pch[h->ch_out+1].power[id].factor/100.0;
+				consumer = all->pch[h->ch_out+1].power[id].consump/100.0;				
+			}
+			else
+			{
+				current = all->pch[h->ch_out+1].power[0].current/100.0;
+				power = all->pch[h->ch_out+1].power[0].power/100.0;
+				factor = all->pch[h->ch_out+1].power[0].factor/100.0;
+				consumer = all->pch[h->ch_out+1].power[0].consump/100.0;				
+			}			
+		}else if(all->ttl.type == PDU_AC_I3O2)
+		{
+			if(h->menu.menu_lv == 1)
+			{
+				if(h->ph_out == 1)
+				{
+					uint8_t id = all->pch[h->ch_out+1].info.ph_id -1;
+					current = all->pch[h->ch_out+1].power[id].current/100.0;
+					power = all->pch[h->ch_out+1].power[id].power/100.0;
+					factor = all->pch[h->ch_out+1].power[id].factor/100.0;
+					consumer = all->pch[h->ch_out+1].power[id].consump/100.0;							
+				}else
+				{
+					uint8_t id = all->pch[h->ch_out+1].info.ph_val -1;
+					current = all->pch[h->ch_out+1].power[id].current/100.0;
+					power = all->pch[h->ch_out+1].power[id].power/100.0;
+					factor = all->pch[h->ch_out+1].power[id].factor/100.0;
+					consumer = all->pch[h->ch_out+1].power[id].consump/100.0;						
+				}
+			}else
+			{
+					uint8_t id = all->pch[h->ch_out+1].info.ph_id - 1;
+					current = all->pch[h->ch_out+1].power[id].current/100.0;
+					power = all->pch[h->ch_out+1].power[id].power/100.0;
+					factor = all->pch[h->ch_out+1].power[id].factor/100.0;
+					consumer = all->pch[h->ch_out+1].power[id].consump/100.0;						
+			}
+		}else{
+					current = all->pch[h->ch_out+1].power[0].current/100.0;
+					power = all->pch[h->ch_out+1].power[0].power/100.0;
+					factor = all->pch[h->ch_out+1].power[0].factor/100.0;
+					consumer = all->pch[h->ch_out+1].power[0].consump/100.0;							
+		}
+		
+		
+		
+		
 		sprintf(tmp, "%s(A) :",lang_get_str(h->lang, STR_ID_CURRENT));
     lcd_draw_string(5, item_h*2,  LCD_WIDTH/2-5, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
-		sprintf(tmp, "%0.2f", ((float)all->pch[h->ch_out+1].power[0].current)/100.0);
+		sprintf(tmp, "%0.2f",current);
 		lcd_draw_string(LCD_WIDTH/2, item_h*2, LCD_WIDTH/2, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
 		
 		
 		
 		sprintf(tmp, "%s(W) :",lang_get_str(h->lang, STR_ID_POWER));
     lcd_draw_string(5, item_h*3,  LCD_WIDTH/2-5, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
-		sprintf(tmp, "%0.2f", ((float)all->pch[h->ch_out+1].power[0].power)/100.0);
+		sprintf(tmp, "%0.2f", power);
 		lcd_draw_string(LCD_WIDTH/2, item_h*3, LCD_WIDTH/2, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
 		
 		
 		sprintf(tmp, "%s(F) :",lang_get_str(h->lang, STR_ID_FACTOR));
     lcd_draw_string(5, item_h*4,  LCD_WIDTH/2-5, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
-		sprintf(tmp, "%0.2f", ((float)all->pch[h->ch_out+1].power[0].factor)/100.0);
+		sprintf(tmp, "%0.2f", factor);
 		lcd_draw_string(LCD_WIDTH/2, item_h*4, LCD_WIDTH/2, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
 		
 	
 #endif
 		sprintf(tmp, "%s(kW):",lang_get_str(h->lang, STR_ID_CONSUMP));
     lcd_draw_string(5, item_h*5,  LCD_WIDTH/2-5, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);
-		float cosumer = ((float)all->pch[h->ch_out+1].power[0].consump)/100.0;
-		if(cosumer > 9999999.0)
+		if(consumer > 9999999.0)
 		{
-			cosumer = 9999999.0;
+			consumer = 9999999.0;
 		}
-		sprintf(tmp, "%0.2f", cosumer);
+		sprintf(tmp, "%0.2f", consumer);
 		lcd_draw_string(LCD_WIDTH/2, item_h*5, LCD_WIDTH/2, item_h, tmp, font2, COLOR_WHITE, COLOR_BLACK, HORIZONTAL_LEFT, VERTICAL_CENTER);	
     //lcd_refresh();
     
@@ -2106,7 +2198,7 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
                         h->menu.menu_id++;
                     }
                 }
-                else if(kv->key==KEY_OK && kv->type==TYPE_SHORT) {
+                else if(kv->key==KEY_OK && kv->type==TYPE_LONG) {
                     if(is_ph3_in(h)) {
                         h->ph_in = 1;
                         h->menu.menu_lv = 1;
@@ -2140,7 +2232,11 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
                             h->ph_in = 1;
                         }
                     }
-                }
+                }else if(kv->key==KEY_OK && kv->type==TYPE_SHORT)
+								{
+										h->ph_in = 0;
+                    h->menu.menu_lv = 0;								
+								}
                 else if(h->uflag&UFLAG_FLIP) {
                     if(h->ph_in<3) {
                         h->ph_in++;
@@ -2155,8 +2251,7 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
                     //
                 }
                 else {
-                    h->ph_in = 0;
-                    h->menu.menu_lv = 0;
+                    
                 }
             }
         }
@@ -2164,7 +2259,9 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
 
         case MENU_OUTPUT:
         {
-            if(h->uflag&UFLAG_FLIP || ((kv->key==KEY_UP || kv->key==KEY_DOWN) && kv->type==TYPE_SHORT)) {
+					if(h->menu.menu_lv==0) {
+            if(h->uflag&UFLAG_FLIP || ((kv->key==KEY_UP || kv->key==KEY_DOWN) && kv->type==TYPE_SHORT)) 
+						{
                 if(kv->key==KEY_UP) {
                     if(h->ch_out>0) {
                         h->ch_out--;
@@ -2183,8 +2280,103 @@ static int menu_key_handle(menu_handle_t *h, key_val_t *kv)
                         h->menu.menu_id++;
                     }
                 }
-            }
-        }
+            }else if(kv->key==KEY_UP && kv->type==TYPE_LONG)
+						{
+							int val = is_ph3_2_out(h);
+							if(val == 1)
+							{
+								h->menu.menu_lv = 1;
+								h->ph_out = 1;
+							}else if(val == 2)
+							{
+								h->menu.menu_lv = 1;
+								h->ph_out = 1;
+							}
+						}else if(h->uflag&UFLAG_FLIP) 
+						{
+//               if(h->ph_in<3) {
+//                        h->ph_in++;
+//                    }
+//                    else {
+//                        h->ph_in = 0;
+//                        h->menu.menu_lv = 0;
+//                        h->menu.menu_id++;
+//                    }
+             } else if(h->uflag&UFLAG_REFRESH) 
+						 {
+                    //
+             } else 
+						 {
+                    
+             }
+					}else if(h->menu.menu_lv == 1)
+					{
+						int val = is_ph3_2_out(h);
+						if(kv->key==KEY_UP && kv->type==TYPE_SHORT) 
+						{
+							if(val == 1)
+							{
+								if(h->ph_out>1)      //	3 ph 
+							  {
+										 h->ph_out--;
+								} else {
+										 h->ph_out = 3;
+								}
+							}else if(val == 2)			//double fire
+							{
+								// h->ph_out = h->ph_out ? 0 : 1;
+								if(h->ph_out > 0) 
+								{
+									h->ph_out --;
+								}else
+								{
+									h->ph_out = 1;
+								}
+							}							
+						}else if(kv->key==KEY_DOWN && kv->type==TYPE_SHORT) 
+						{
+							if(val == 1)
+							{
+								if(h->ph_out < 3)      //	3 ph 
+							  {
+										 h->ph_out++;
+								} else {
+										 h->ph_out = 1;
+								}
+							}else if(val == 2)			//double fire
+							{
+								if(h->ph_out < 2) 
+								{
+									h->ph_out ++;
+								}else
+								{
+									h->ph_out = 1;
+								}
+							}	
+						}else if(kv->key == KEY_OK && kv->type==TYPE_SHORT)
+						{
+							h->menu.menu_lv = 0;
+							h->ph_out  = 0;
+						}else if(h->uflag&UFLAG_FLIP) 
+						{
+//               if(h->ph_in<3) {
+//                  h->ph_in++;
+//               }
+//               else 
+//							{
+//									h->ph_in = 0;
+//									h->menu.menu_lv = 0;
+//									h->menu.menu_id++;
+//               }
+             } else if(h->uflag&UFLAG_REFRESH) 
+						 {
+                    //
+             } else 
+						 {
+                    
+             }
+					}
+				}
         break;
 
         case MENU_MODBUS: