|
@@ -202,9 +202,10 @@ const parseData = (payload: any) => {
|
|
|
var variable = group.valueVariables.find((f: any) => f.code == mqttCode)
|
|
|
if (variable != null) {
|
|
|
if (variable.variableType == 10) {
|
|
|
- variable.value = mqttValue == true ? '开启' : '闭合'
|
|
|
+ variable.value = mqttValue === 'true' || mqttValue === true ? '开启' : '闭合'
|
|
|
} else {
|
|
|
- variable.value = mqttValue
|
|
|
+ let value = formatValue(mqttValue, variable.translate)
|
|
|
+ variable.value = evaluateFormula(value, variable.formula)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -212,6 +213,9 @@ const parseData = (payload: any) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//解析档位
|
|
|
const parseGear = (gear: any, code: any, value: any) => {
|
|
|
if (gear != null) {
|
|
@@ -257,6 +261,23 @@ const updateAlarm = (trueLight: string, name: string, value: any) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const evaluateFormula = (value: any, formula: any) => {
|
|
|
+ if (formula == null || formula == undefined || formula === '') {
|
|
|
+ return value
|
|
|
+ }
|
|
|
+ //函数模板
|
|
|
+ const array = formula.split(",")
|
|
|
+ //字符串模本
|
|
|
+ var templete = array[0]
|
|
|
+ const formulaArray = array.slice(1)
|
|
|
+ formulaArray.forEach((item: any, index: number) => {
|
|
|
+ const func = item.replace("{Value}", value)
|
|
|
+ const result = eval(func)
|
|
|
+ templete = templete.replace(`{${index}}`, Math.floor(parseFloat(result)))
|
|
|
+ })
|
|
|
+ return templete
|
|
|
+}
|
|
|
+
|
|
|
const getColor = (el: any) => {
|
|
|
const obj: any = {
|
|
|
green: '#6AD28C',
|