|
@@ -329,15 +329,69 @@ void web_GetRunTime(Webs *wp){
|
|
|
uint16_t wRet = LIBIPMI_E_SUCCESS;
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
|
uint8_t target_addr;
|
|
|
- uint32_t TotalRunTime = 1000; //模块总运行时间,单位: 分钟
|
|
|
- uint32_t CurRunTime = 50; //模块本次运行时间,单位: 分钟
|
|
|
+ uint8_t min_per_cnt = 0;
|
|
|
+ uint32_t counts = 0;
|
|
|
+ uint32_t totalhours = 0;
|
|
|
+ uint32_t hours = 0, days = 0, minutes = 0;
|
|
|
+ uint32_t totalsMinutes = 0;
|
|
|
+ char totalRunTimeStr[50]={0};
|
|
|
+ char curRunTimeStr[50] = {0};
|
|
|
+
|
|
|
+ LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+
|
|
|
+ //获取总运行时间
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ wRet = IPMI_GetPOH( &UDSSession, &min_per_cnt, &counts,DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ websError(wp, 404, "web_GetRunTime failed!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wRet = IPMC_GetPOH( &UDSSession, target_addr, &min_per_cnt, &counts, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ websError(wp, 404, "web_GetRunTime failed!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ totalhours = counts*min_per_cnt/60; //hours
|
|
|
+ days = totalhours/24;
|
|
|
+ hours = totalhours%24;
|
|
|
+ sprintf(totalRunTimeStr, "%d days, %d hours", days, hours);
|
|
|
+
|
|
|
+ //获取当前运行时间
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ wRet = IPMI_GetCurRunTime( &UDSSession, &totalsMinutes, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ websError(wp, 404, "web_GetRunTime failed!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wRet = IPMC_GetCurRunTime( &UDSSession, target_addr, &totalsMinutes, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ websError(wp, 404, "web_GetRunTime failed!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ days = totalsMinutes/(24*60);
|
|
|
+ hours = (totalsMinutes%(24*60))/(60);
|
|
|
+ minutes = totalsMinutes%60;
|
|
|
+ sprintf(curRunTimeStr, "%d days, %d hours, %d minutes", days, hours, minutes);
|
|
|
+
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
|
|
|
|
|
|
cJSON * root = cJSON_CreateObject();
|
|
|
cJSON * data = cJSON_CreateObject();
|
|
|
cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
- cJSON_AddStringToObject(data, "TotalRunTime", "129 hour 40 min");
|
|
|
- cJSON_AddStringToObject(data, "CurRunTime", "1 hour 3 min");
|
|
|
+ cJSON_AddStringToObject(data, "TotalRunTime", totalRunTimeStr);
|
|
|
+ cJSON_AddStringToObject(data, "CurRunTime", curRunTimeStr);
|
|
|
cJSON_AddStringToObject(root, "msg", "");
|
|
|
cJSON_AddNumberToObject(root, "code", 200);
|
|
|
|
|
@@ -346,7 +400,7 @@ void web_GetRunTime(Webs *wp){
|
|
|
websSetStatus(wp, 200);
|
|
|
websWriteHeaders(wp, -1, 0);
|
|
|
websWriteEndHeaders(wp);
|
|
|
- websWrite(wp,"%s", pStr);
|
|
|
+ websWrite(wp, pStr);
|
|
|
websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
//printf("cJSON:%s\n", pStr);
|
|
@@ -364,30 +418,63 @@ void web_SetModIdentifyOn(Webs *wp){
|
|
|
char *strTime = websGetVar(wp, "timeSelect", NULL); //
|
|
|
int timeSelect = atoi(strTime);
|
|
|
uint8_t identifySec = 0;
|
|
|
+ uint8_t ForceIdentify = 0;
|
|
|
|
|
|
switch(timeSelect)
|
|
|
{
|
|
|
case 0: //15s
|
|
|
identifySec = 15;
|
|
|
+ ForceIdentify = 0;
|
|
|
break;
|
|
|
case 1: //30s
|
|
|
identifySec = 30;
|
|
|
+ ForceIdentify = 0;
|
|
|
break;
|
|
|
case 2: //60s
|
|
|
identifySec = 60;
|
|
|
+ ForceIdentify = 0;
|
|
|
break;
|
|
|
case 3: //120s
|
|
|
identifySec = 120;
|
|
|
+ ForceIdentify = 0;
|
|
|
break;
|
|
|
case 4: //forever
|
|
|
identifySec = 0xff;
|
|
|
+ ForceIdentify = 1;
|
|
|
break;
|
|
|
default:
|
|
|
identifySec = 15;
|
|
|
+ ForceIdentify = 0;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
printf("---> identify on Sec = %d\n", identifySec);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //Create session
|
|
|
+ LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ wRet = IPMICMD_ChassisIdentify(&UDSSession, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wRet = IPMC_ChassisIdentify(&UDSSession, target_addr, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
+
|
|
|
cJSON * root = cJSON_CreateObject();
|
|
|
cJSON * data = cJSON_CreateObject();
|
|
|
cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
@@ -399,7 +486,7 @@ void web_SetModIdentifyOn(Webs *wp){
|
|
|
websSetStatus(wp, 200);
|
|
|
websWriteHeaders(wp, -1, 0);
|
|
|
websWriteEndHeaders(wp);
|
|
|
- websWrite(wp,"%s", pStr);
|
|
|
+ websWrite(wp, pStr);
|
|
|
websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
//printf("cJSON:%s\n", pStr);
|
|
@@ -415,9 +502,33 @@ void web_SetModIdentifyOff(Webs *wp){
|
|
|
IPMI20_UDS_SESSION_T UDSSession;
|
|
|
uint8_t target_addr;
|
|
|
uint8_t identifySec = 0;
|
|
|
+ uint8_t ForceIdentify = 0;
|
|
|
|
|
|
|
|
|
printf("---> identify off Sec = %d\n", identifySec);
|
|
|
+ //Create session
|
|
|
+ LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
|
|
|
+
|
|
|
+ target_addr = gIPMBAddr[wp->index];
|
|
|
+ if(target_addr == 0x20)
|
|
|
+ {
|
|
|
+ wRet = IPMICMD_ChassisIdentify(&UDSSession, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ wRet = IPMC_ChassisIdentify(&UDSSession, target_addr, identifySec, ForceIdentify, DEFAULT_TIMEOUT);
|
|
|
+ if(wRet != 0)
|
|
|
+ {
|
|
|
+ printf("chassis identify failed! interval %d, force %d!\n", identifySec, ForceIdentify);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ LIBIPMI_CloseSession(&UDSSession );
|
|
|
+
|
|
|
cJSON * root = cJSON_CreateObject();
|
|
|
cJSON * data = cJSON_CreateObject();
|
|
|
cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
@@ -429,7 +540,7 @@ void web_SetModIdentifyOff(Webs *wp){
|
|
|
websSetStatus(wp, 200);
|
|
|
websWriteHeaders(wp, -1, 0);
|
|
|
websWriteEndHeaders(wp);
|
|
|
- websWrite(wp,"%s", pStr);
|
|
|
+ websWrite(wp, pStr);
|
|
|
websFlush(wp, 0);
|
|
|
websDone(wp);
|
|
|
//printf("cJSON:%s\n", pStr);
|