Unable to display value from Meta data point
-
I am using the below Meta Data Point for an ma-point-value source in a custom page, but get no value displayed. I have tried refactoring numerous times - but cannot get a value to display. Perhaps someone could shed some light on my confusion here? (the script has a numeric input and a string return).
{
"dataPoints":[
{
"xid":"DP_t1_msg",
"name":"t1_msg",
"enabled":true,
"loggingType":"INTERVAL",
"intervalLoggingPeriodType":"MINUTES",
"intervalLoggingType":"INSTANT",
"purgeType":"YEARS",
"pointLocator":{
"dataType":"ALPHANUMERIC",
"updateEvent":"NONE",
"contextUpdateEvent":"CONTEXT_CHANGE",
"context":[
{
"varName":"state_no",
"dataPointXid":"DP_t1_state",
"updateContext":true
}
],
"logLevel":"NONE",
"variableName":"val",
"executionDelaySeconds":0,
"logCount":5,
"logSize":1.0,
"script":"\nif (state_no < 0) {\n return "fault";\n} else {\n switch (state_no) {\n case 0: return "idle";\n case 1: return "filling";\n case 2: return "add mix";\n case 3: return "ready";\n case 4: return "processing";\n case 5: return "overfull";\n case 9: return "empty";\n default: return "fault";\n}}",
"scriptPermissions":{
"customPermissions":"",
"dataPointReadPermissions":"superadmin",
"dataPointSetPermissions":"superadmin",
"dataSourcePermissions":"superadmin"
},
"settable":false,
"updateCronPattern":""
},
"eventDetectors":[
],
"plotType":"STEP",
"rollup":"NONE",
"unit":"",
"simplifyType":"NONE",
"chartColour":"",
"chartRenderer":null,
"dataSourceXid":"DS_tank_state",
"defaultCacheSize":1,
"deviceName":"tank_state",
"discardExtremeValues":false,
"discardHighLimit":1.7976931348623157E308,
"discardLowLimit":-1.7976931348623157E308,
"intervalLoggingPeriod":1,
"intervalLoggingSampleWindowSize":0,
"overrideIntervalLoggingSamples":false,
"preventSetExtremeValues":false,
"purgeOverride":false,
"purgePeriod":1,
"readPermission":"",
"setExtremeHighLimit":1.7976931348623157E308,
"setExtremeLowLimit":-1.7976931348623157E308,
"setPermission":"",
"tags":{
},
"textRenderer":{
"type":"PLAIN",
"useUnitAsSuffix":true,
"unit":"",
"renderedUnit":"",
"suffix":""
},
"tolerance":0.0
}
]
} -
Hi @bullitbd
Your context variable is an object. Your IF statement and switch will need to use
(state_no.value)
-
Hi @CraigWeb
Thank you - Duh, sorry - thought I'd done that. So, using the .value property, script works as intended when running in the environment - it returns the proper string. However, it still doesn't show up in the directive:
<td class="point-val"><ma-point-value id="60b670c1-2919-4ad8-a2b9-0da3a9365fee" enable-popup="hide" style="position: relative; height: 40px; color: rgb(255, 255, 255); width: 113px;" point-xid="DP_t1_msg" display-type="rendered" flash-on-change="true"></ma-point-value></td>.
Using latest Chrome, MangoES, updated. No browser errors... Any further thoughts?
Thank you for your time!
-
Hi Bullitbd
It didn't occur to me early but you might be better off making the original point (DP_t1_state) a multi state point and giving the point text rendering properties like the picture. I am not quite sure why the meta DP does not work with <ma-point-value>. I get the same problem.
-
I was not able to reproduce. I imported your JSON and used that markup (without even putting it in a table) but was able to display the value.
-
Thanks @CraigWeb
Good idea! Unfortunately, it only displays 0, even though that's a defined key. Also, doesn't appear to be a way to deal with < 0 keys. Arrg.
-
Thanks @phildunlap. I assume you mean my original Meta Point. I just did the same and got the same blank stare. I'm obviously missing something here... any thoughts?
-
The only thing that occurs to me is that the point may not have a value / not be enabled. Perhaps you could try an alphanumeric meta point simply returning a string on a cron pattern?
-
well, problem was "raw" display setting (thank you @Jared-Wiltshire) among other things. Used range display on his and @CraigWeb's advice - works great.
Thanks, all!