Last year, I've introduced the basic_formula process, without brackets or mathematical functions. The simpliest formula example can be symbolized as follow, assuming you work on feeds 1,2,3 :
f1+2*f2-f3/12
This 2020 pull request implements brackets and the max function....
So you can elaborate more complex expression such as :
1162.5*5.19*max(f7-f11,0)
or :
1162.5*f10*(f7-11)
This is usefull when you have to deal with hot water flows
Caution : (f12-f13)*(f7-f11) will not be recognized as a valid function !!
Others functions can be easily injected by adding a new element to the functions library
// functions list
// brackets must always be the last function in the list
$functions=[
["name"=>"max","f"=>"max\(($Xbf),($Xnbr)\)"],
["name"=>"brackets","f"=>"\(($Xbf)\)"],
];
$Xbf invokes a regular expression to catch a basic formula such as f1+2*f2-f3/12$Xnbr invokes a regular expression to catch a float or an int
In order to implement a new function, others part of the code have to be updated :
Last year, I've introduced the basic_formula process, without brackets or mathematical functions. The simpliest formula example can be symbolized as follow, assuming you work on feeds 1,2,3 :
This 2020 pull request implements brackets and the max function.... So you can elaborate more complex expression such as :
or :
This is usefull when you have to deal with hot water flows
Caution : (f12-f13)*(f7-f11) will not be recognized as a valid function !!
Others functions can be easily injected by adding a new element to the functions library
$Xbf
invokes a regular expression to catch a basic formula such asf1+2*f2-f3/12
$Xnbr
invokes a regular expression to catch a float or an intIn order to implement a new function, others part of the code have to be updated :