Multistate from analog ranges
-
Hi all,
Perhaps this has been covered previously but I could not find. Or perhaps this question could help others also.....I am trying to create a multistate data point from different ranges of values from an analog point. These could be pressures, flows, power, temp and so on.
Example:
Analog Data Point is <1 = 1
Analog Data Point is between 1-1.5 = 2
Analog Data Point is between 1.5-2.5 = 3
etc.From which I can generate pie charts. Still wrapping my head around meta data points so assistance appreciated.
Thanks In advance.
-
Hi Pikey4,
I think you may be able to achieve this using a range text renderer for the sake of the pie chart! But, a meta point will enable it to behave as a proper multistate point everywhere. That'd be having the source point in context updating context, with a script like,
if( p.value < 1 ) return 1; else if( p.value < 1.5 ) return 2; else if( p.value < 2.5 ) return 3; //etc return -1;
-
Thanks Phillip,
The first part of this seems to work ok but the:
****else if( p.value < 1.5 ) return 2; else if( p.value < 2.5 ) return 3; //etc return -1;****
Doesn't seem to return anything. do I need to specify the range between for the additional point states aft 1 ?
between 1 - 1.5 ??
Also does the
return -1;
have any meaning. What does this represent?Thanks.
-
I'm not sure what you mean it doesn't return anything. This is in a multistate meta point with a numeric point in its context, yes? I don't think I messed that logic up...
We don't need to specify the range explicitly in each if statement because they are evaluated sequentially and if it were in that range the value would have returned from the earlier return statement.
The
return -1
was to say something else because your ranges were not exhaustive of the possibilities and not returning anything will be interpreted as an implicitreturn null;
which would cast to a zero value for multistate. -
Thanks Phil,
Your logic was sound.
I was trying to set this remotely over a very slow connection I wonder if that was the problem??
Went to site and deleted the point and started again, everything worked fine.
Cheers!