Compare commits

...

2 Commits

1 changed files with 2 additions and 2 deletions

View File

@ -2332,7 +2332,7 @@
"type": "function",
"z": "58aeeaac02a3a4c7",
"name": "get_total_number_of_limb_strings",
"func": "let total_num_limb_string=0;\nlimb_string_list = msg.payload.limb_string_list;\nmain_switch_state_list = msg.payload.main_switch_state;\nbattery_health = [];\nif (limb_string_list == null){\n msg.payload.battery_health = \"BMS connection lost!\";\n msg.payload.num_limb_string = -1\n return msg;\n}\n\nfor (let i = 0; i < limb_string_list.length; i++) {\n num_limb_string = limb_string_list[i][1][0];\n \n if(num_limb_string>1){\n total_num_limb_string = -1;//if there are more than 1 limb string in a battery, should give alarm to stop use this battery\n battery_health.push(\"Battery \"+(i+2)+\" has more than 1 limb string!\");\n }\n \n if(num_limb_string<=1){\n total_num_limb_string+=num_limb_string;\n battery_health.push(\"Battery \"+(i+2)+\" has \" + num_limb_string+ \" limb strings.\");\n }\n}\nmsg.payload.num_limb_string = total_num_limb_string;\nmsg.payload.battery_health = battery_health;\n\nreturn msg;",
"func": "let total_num_limb_string=0;\nlimb_string_list = msg.payload.limb_string_list;\nmain_switch_state_list = msg.payload.main_switch_state;\nbattery_health = [];\nflag = 1;\nif (limb_string_list == null){\n msg.payload.battery_health = \"BMS connection lost!\";\n msg.payload.num_limb_string = -1\n return msg;\n}\n\nfor (let i = 0; i < limb_string_list.length; i++) {\n num_limb_string = limb_string_list[i][1][0];\n \n if(num_limb_string>1){\n flag = -1;\n }\n \n if(num_limb_string<=1){\n total_num_limb_string+=num_limb_string;\n }\n \n battery_health.push(\"Battery \"+(i+2)+\" has \" + num_limb_string+ \" limb strings.\");\n}\n\nconst updateNumLimbString = (total, flag) => flag === 1 ? total : -1;\nmsg.payload.num_limb_string = updateNumLimbString(total_num_limb_string, flag);\nmsg.payload.battery_health = battery_health;\n\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
@ -2604,7 +2604,7 @@
"rules": [
{
"t": "set",
"p": "payload",
"p": "payload.controller_info",
"pt": "msg",
"to": "Please replace battery first!",
"tot": "str"