浏览代码

add setting UPS type

balbekova 6 年之前
父节点
当前提交
f779c9744b
共有 4 个文件被更改,包括 17 次插入16 次删除
  1. 8 9
      modules/MegaTec/megatec.c
  2. 0 7
      modules/MegaTec/megatec.h
  3. 1 0
      modules/settings_api.c
  4. 8 0
      modules/settings_api.h

+ 8 - 9
modules/MegaTec/megatec.c

@@ -33,7 +33,6 @@ uint16_t TimeParam = 0;
 uint16_t TimeParam2 = 0;
 bool megatec_send = true;
 UPS_value_t UPS;
-uint8_t type_ups = ups_kestar;
 
 enum {
 	NORMAL = 0x00,
@@ -243,7 +242,7 @@ void ups_status_response(char *data)
 	//TODO
 	len = get_ups_param(data, " ", value);
 	data += (len + 1);
-	if(type_ups == ups_kestar){
+	if(sSettings.UPS_Setting.type_ups == ups_kestar){
 		if(len > 0){
 			//UPS.SOC = round(100*(((atof(value))/6) - 1.85)/0.4166666667); // 1.85 - минимальное напряжение на ячейки АКБ; 2.266666667 - максимальное напряжение на ячейки АКБ; (2.266666667 - 1.85) = 0.4166666667
 			//UPS.SOC = round(100*((atof(value)) - 1.67)/0.58); // 1.667 - минимальное напряжение на ячейки АКБ; 2.267 - максимальное напряжение на ячейки АКБ; (2.267 - 1.667) = 0.6
@@ -570,13 +569,13 @@ void ups_protocol_id_response(char *data)
 
 	if(data[0] != '('){
 		if(strncmp(data, "NAK", 3) == 0){
-			type_ups = ups_kestar;
+			sSettings.UPS_Setting.type_ups = ups_kestar;
 		}
 		return;
 	}
 
 	data++;
-	type_ups = ups_voltronic;
+	sSettings.UPS_Setting.type_ups = ups_voltronic;
 
 	DBG printf("UPS ups_protocol_id_parser_start: %s\r\n", data);
 
@@ -635,13 +634,13 @@ int ups_metac_service_pdu(cmdMegaTecEnums_t command)
 		if (ups_megatec_rx_pdu())
 		{
 			megatec_send = true;
-			if(type_ups == ups_kestar){
+			if(sSettings.UPS_Setting.type_ups == ups_kestar){
 				if(strncmp(ups_pdu.data, "ACK", 3) == 0)
 					return 1;
 				else if(strncmp(ups_pdu.data, "NAK", 3) == 0)
 					return 0;
 			}
-			else if(type_ups == ups_voltronic){
+			else if(sSettings.UPS_Setting.type_ups == ups_voltronic){
 				if(strncmp(ups_pdu.data, "(ACK", 4) == 0)
 					return 1;
 				else if(strncmp(ups_pdu.data, "(NAK", 4) == 0)
@@ -687,7 +686,7 @@ void request_task(void* params)
 				}
 			}
 
-			if(megatec_send){
+		/*	if(megatec_send){
 				memset(ups_pdu.data, 0, UPS_PDU_MAX_LEN);
 				megatec_send= false;
 				UPS.Flag_Present = false;
@@ -696,9 +695,9 @@ void request_task(void* params)
 					ups_megatec_process_pdu(ups_protocol_id_req);
 
 				megatec_send=true;
-			}
+			}*/
 
-			switch(type_ups){
+			switch(sSettings.UPS_Setting.type_ups){
 			case ups_kestar:
 				num_req = sizeof(kestar_req);
 				req = kestar_req;

+ 0 - 7
modules/MegaTec/megatec.h

@@ -12,13 +12,6 @@
 #include <stdint.h>
 #include <stdlib.h>
 
-typedef enum{
-	ups_kestar,
-	ups_voltronic,
-
-	type_ups_max
-} typeUPSEnums_t;
-
 typedef enum{
 	ups_status_req,
 	ups_test_10sec,

+ 1 - 0
modules/settings_api.c

@@ -142,6 +142,7 @@ void SETTINGS_SetUPSSettingsDef(void)
 {
   sSettings.UPS_Setting.Ucellmin = 1.67;
   sSettings.UPS_Setting.Ucellmax = 2.27;
+  sSettings.UPS_Setting.type_ups = ups_kestar;
 }
 
 /**

+ 8 - 0
modules/settings_api.h

@@ -222,6 +222,13 @@ typedef struct
     ALARM_LEVEL_RANGE_t Temprature_range;
 } ALARM_MNGR_t;
 
+typedef enum{
+	ups_kestar,
+	ups_voltronic,
+
+	type_ups_max
+} typeUPSEnums_t;
+
 /**
   * @brief  Настройки ИБП.
   */
@@ -229,6 +236,7 @@ typedef struct
 {
 	float Ucellmin;
 	float Ucellmax;
+	uint8_t type_ups;
 } UPS_Setting_t;
 
 #ifndef HARDWARE_BT6708