mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-12-05 22:08:19 +00:00
Expanded expressions, slightly new syntax
An expression can now refer to the value it has to compute (@), but also to other values. This is now perfectly valid as an expression: vid + in_min - in_max * 2 / @ Not that this is very sensible, but you get the idea. Please install the new example config file, or replace all old 'val' occurences with '@'. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@107 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
657798a79c
commit
1c12665831
7 files changed
+40
-18
No files matched your search
+16
-5
@@ -23,6 +23,7 @@
|
||||
#include "error.h"
|
||||
#include "data.h"
|
||||
#include "sensors.h"
|
||||
#include "access.h"
|
||||
|
||||
sensors_chip *sensors_config_chips = NULL;
|
||||
int sensors_config_chips_count = 0;
|
||||
@@ -200,24 +201,34 @@ int sensors_parse_i2cbus_name(const char *name, int *res)
|
||||
}
|
||||
|
||||
|
||||
int sensors_eval_expr(sensors_expr *expr, double val, double *result)
|
||||
int sensors_eval_expr(sensors_chip_name chipname, sensors_expr *expr,
|
||||
double val, double *result)
|
||||
{
|
||||
double res1,res2;
|
||||
int res;
|
||||
sensors_chip_feature *feature;
|
||||
|
||||
if (expr->kind == sensors_kind_val) {
|
||||
*result = expr->data.val;
|
||||
return 0;
|
||||
}
|
||||
if (expr->kind == sensors_kind_var) {
|
||||
/* We should check the kind of variable here! */
|
||||
if (expr->kind == sensors_kind_source) {
|
||||
*result = val;
|
||||
return 0;
|
||||
}
|
||||
if ((res = sensors_eval_expr(expr->data.subexpr.sub1,val,&res1)))
|
||||
if (expr->kind == sensors_kind_var) {
|
||||
/* We should check the kind of variable here! */
|
||||
if (! (feature = sensors_lookup_feature_name(chipname.prefix,
|
||||
expr->data.var)))
|
||||
return SENSORS_ERR_NO_ENTRY;
|
||||
if (! (res = sensors_get_feature(chipname,feature->number,result)))
|
||||
return res;
|
||||
return 0;
|
||||
}
|
||||
if ((res = sensors_eval_expr(chipname,expr->data.subexpr.sub1,val,&res1)))
|
||||
return res;
|
||||
if (expr->data.subexpr.sub2 &&
|
||||
(res = sensors_eval_expr(expr->data.subexpr.sub2,val,&res2)))
|
||||
(res = sensors_eval_expr(chipname,expr->data.subexpr.sub2,val,&res2)))
|
||||
return res;
|
||||
switch(expr->data.subexpr.op) {
|
||||
case sensors_add:
|
||||
|
||||
Reference in new issue
Block a user