|
@@ -105,6 +105,7 @@ const char *MegaTecCMD[] = {
|
|
|
"BT\r",
|
|
|
"QTPR\r",
|
|
|
"QFS\r",
|
|
|
+ "SOFF\r",
|
|
|
};
|
|
|
|
|
|
extern bool flUpdateLog;
|
|
@@ -122,6 +123,7 @@ void init_UPS_value(void)
|
|
|
UPS.Load = 0;
|
|
|
UPS.Load_test_akb = 0;
|
|
|
UPS.SOC = 0;
|
|
|
+ UPS.SOC_prev = 0;
|
|
|
UPS.work_time = 0;
|
|
|
UPS.akb_work_time = 0;
|
|
|
UPS.Status = 0;
|
|
@@ -129,6 +131,7 @@ void init_UPS_value(void)
|
|
|
UPS.Alarm = 0;
|
|
|
UPS.warn_status = 0;
|
|
|
UPS.Test_Status = 0;
|
|
|
+ UPS.fault_type = 0;
|
|
|
UPS.cnt_err_ups = 0;
|
|
|
UPS.Flag_Present = false;
|
|
|
UPS.Present = UPS_WAIT_CONNECT;
|
|
@@ -341,15 +344,7 @@ void ups_status_response(char *data)
|
|
|
if (len > 0) {
|
|
|
UPS.Vcell_curr = atof(value);
|
|
|
}
|
|
|
- // if (sSettings.UPS_Setting.type_ups == ups_kestar || sSettings.UPS_Setting.type_ups == ups_offline) {
|
|
|
- if (UPS.Vcell_curr < 7) {
|
|
|
- UPS.SOC = round(100 * (UPS.Vcell_curr - sSettings.UPS_Setting.Ucellmin) / (sSettings.UPS_Setting.Ucellmax -
|
|
|
- sSettings.UPS_Setting.Ucellmin));
|
|
|
- } else {
|
|
|
- UPS.SOC = round(100 * (UPS.Vcell_curr / AKB_NUM_CELL - sSettings.UPS_Setting.Ucellmin) /
|
|
|
- (sSettings.UPS_Setting.Ucellmax - sSettings.UPS_Setting.Ucellmin));
|
|
|
- }
|
|
|
- // }
|
|
|
+
|
|
|
len = get_ups_param(data, " ", value);
|
|
|
data += (len + 1);
|
|
|
if (len > 0) {
|
|
@@ -368,6 +363,19 @@ void ups_status_response(char *data)
|
|
|
UPS.Status = stat;
|
|
|
}
|
|
|
|
|
|
+ // if (sSettings.UPS_Setting.type_ups == ups_kestar || sSettings.UPS_Setting.type_ups == ups_offline) {
|
|
|
+ if(UPS.Status & 0x04){
|
|
|
+ UPS.SOC_prev = UPS.SOC;
|
|
|
+ }
|
|
|
+ if (UPS.Vcell_curr < 7) {
|
|
|
+ UPS.SOC = round(100 * (UPS.Vcell_curr - sSettings.UPS_Setting.Ucellmin) / (sSettings.UPS_Setting.Ucellmax -
|
|
|
+ sSettings.UPS_Setting.Ucellmin));
|
|
|
+ } else {
|
|
|
+ UPS.SOC = round(100 * (UPS.Vcell_curr / AKB_NUM_CELL - sSettings.UPS_Setting.Ucellmin) /
|
|
|
+ (sSettings.UPS_Setting.Ucellmax - sSettings.UPS_Setting.Ucellmin));
|
|
|
+ }
|
|
|
+ // }
|
|
|
+
|
|
|
if((UPS.Status >> 2) & 0x01 || ((UPS.Status >> 7) & 0x01)) {
|
|
|
UPS.Load_test_akb = UPS.Load;
|
|
|
TM_RTC_t data;
|
|
@@ -601,6 +609,7 @@ void ups_akb_info_response(char *data)
|
|
|
len = get_ups_param(data, " ", value);
|
|
|
data += (len + 1);
|
|
|
/* if (len > 0) {
|
|
|
+ UPS.SOC_prev = UPS.SOC;
|
|
|
UPS.SOC = atoi(value);
|
|
|
}*/
|
|
|
|
|
@@ -866,7 +875,7 @@ void ups_buzzer_cntrl_response(char *data)
|
|
|
|
|
|
void ups_mode_response(char *data)
|
|
|
{
|
|
|
- char value[20];
|
|
|
+ char value[50];
|
|
|
uint8_t len = 0;
|
|
|
DBG printf("ups_serialresponse: %s\r\n", data);
|
|
|
if (data[0] != '(') {
|
|
@@ -886,6 +895,24 @@ void ups_mode_response(char *data)
|
|
|
#ifdef UPS_MODE_MONITOR
|
|
|
memset(value, 0, sizeof(value));
|
|
|
GetModeStr(value, &len);
|
|
|
+ if(UPS.Mode == 'F') {
|
|
|
+ memset(ups_pdu.data, 0, UPS_PDU_MAX_LEN);
|
|
|
+ send_MegaTec_cmd(ups_fault_status);
|
|
|
+ if (ups_megatec_rx_pdu()) {
|
|
|
+ if (ups_pdu.data[0] != '(' || strncmp(ups_pdu.data, "(OK", 3) == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ UPS.fault_type = (ups_pdu.data[1] - 0x30) << 4 | (ups_pdu.data[2] - 0x30);
|
|
|
+ strncat(value, &ups_pdu.data[1], 6);
|
|
|
+ strncat(value, &ups_pdu.data[14], 4);
|
|
|
+ strncat(value, &ups_pdu.data[25], 8);
|
|
|
+ strncat(value, &ups_pdu.data[35], 4);
|
|
|
+ strncat(value, &ups_pdu.data[41], 4);
|
|
|
+ strncat(value, &ups_pdu.data[47], 4);
|
|
|
+ strncat(value, &ups_pdu.data[53], 4);
|
|
|
+ strncat(value, &ups_pdu.data[59], 8);
|
|
|
+ }
|
|
|
+ }
|
|
|
SNMP_SendUserTrap(UPS_MODE);
|
|
|
syslog(SYSLOG_INFORMATIONAL, "Режим ИБП: %s", value);
|
|
|
log_event_data(LOG_UPS_MODE, value);
|
|
@@ -995,13 +1022,6 @@ void ups_temperature_response(char *data)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void ups_fault_status_response(char *data)
|
|
|
-{
|
|
|
- if (data[0] != '(') {
|
|
|
- return;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
void ups_megatec_process_pdu(cmdMegaTecEnums_t command)
|
|
|
{
|
|
@@ -1061,8 +1081,6 @@ void ups_megatec_process_pdu(cmdMegaTecEnums_t command)
|
|
|
case ups_temperature:
|
|
|
ups_temperature_response(ups_pdu.data);
|
|
|
break;
|
|
|
- case ups_fault_status:
|
|
|
-
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -1187,7 +1205,7 @@ void kstar_mode(void)
|
|
|
void request_task(void *params)
|
|
|
{
|
|
|
uint8_t kestar_req[4] = { ups_status_req, ups_remain_time_reg, ups_info, ups_kstar_status};
|
|
|
- uint8_t voltronic_req[10] = {ups_temperature, ups_status_req, ups_akb_info, ups_model_req, ups_mode_req, ups_version_req, ups_version2_req, ups_serial_req, ups_warning_status, ups_fault_status};//
|
|
|
+ uint8_t voltronic_req[9] = {ups_temperature, ups_status_req, ups_akb_info, ups_model_req, ups_mode_req, ups_version_req, ups_version2_req, ups_serial_req, ups_warning_status};//
|
|
|
uint8_t num_req = 0;
|
|
|
uint8_t *req;
|
|
|
bool flag_init_ups = false;
|
|
@@ -1206,12 +1224,14 @@ void request_task(void *params)
|
|
|
UPS.Load = 0;
|
|
|
UPS.Load_test_akb = 0;
|
|
|
UPS.SOC = 0;
|
|
|
+ UPS.SOC_prev = 0;
|
|
|
UPS.work_time = 0;
|
|
|
UPS.Status = 0;
|
|
|
UPS.Mode = 0;
|
|
|
UPS.Test_Status = 0;
|
|
|
UPS.Alarm = 0;
|
|
|
UPS.warn_status = 0;
|
|
|
+ UPS.fault_type = 0;
|
|
|
UPS.Present = UPS_FAIL_CONNECT;
|
|
|
|
|
|
//memset(UPS.model, 0, 11);
|
|
@@ -1374,6 +1394,23 @@ void UPSRestoreCallback(TimerHandle_t pxTimer)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void UPScmd(cmdMegaTecEnums_t cmd)
|
|
|
+{
|
|
|
+ if (UPS.Present == UPS_CONNECTED) {
|
|
|
+ while (!megatec_send) {
|
|
|
+ vTaskDelay(50);
|
|
|
+ }
|
|
|
+ memset(ups_pdu.data, 0, UPS_PDU_MAX_LEN);
|
|
|
+ megatec_send = false;
|
|
|
+ //UPS.Flag_Present = false;
|
|
|
+ send_MegaTec_cmd(cmd);
|
|
|
+ if (ups_megatec_rx_pdu()) {
|
|
|
+ ups_megatec_process_pdu(cmd);
|
|
|
+ }
|
|
|
+ megatec_send = true;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void UPSReadTestStatus(void)
|
|
|
{
|
|
|
if(sSettings.UPS_Setting.type_ups == ups_kestar
|