Import javascript library
-
Is https://192.168.1.125:8080 typed into your address bar?
Edit: In the end HTTP localhost 80 prevailed
-
@phildunlap said in Import javascript library:
Is https://192.168.1.125:8080 typed into your address bar?
Edit: In the end HTTP localhost 80 prevailed
ok, i managed to get it working on port 80 and also changing https to http.
Now i see only getValue function in datapoints.js. Is there any sort of setValue function available? Thanks. -
No you would have to add it, something like,
static setValue(xid, valueTime) { return client.restRequest({ method: 'PUT', path: '/rest/v1/point-values/' + encodeURIComponent(xid), data: { "dataType": "NUMERIC", "value": valueTime.value, "timestamp": valueTime.time, "annotation": "annotation" in valueTime ? valueTime.annotation : null } }).then(response => { return response.data; }); } setValue(valueTime) { return this.constructor.setValue(this.xid, valueTime); }
Which should work for numeric points. You would have to do something more clever to make this fully general purpose as currently the DataPoint object doesn't know its data type.
The node library is definitely not a finished product and anything you create is certainly encouraged to be shared.
-
Also be sure to check out test/pointValue.spec.js
-
@phildunlap said in Import javascript library:
No you would have to add it, something like,
static setValue(xid, valueTime) { return client.restRequest({ method: 'PUT', path: '/rest/v1/point-values/' + encodeURIComponent(xid), data: { "dataType": "NUMERIC", "value": valueTime.value, "timestamp": valueTime.time, "annotation": "annotation" in valueTime ? valueTime.annotation : null } }).then(response => { return response.data; }); } setValue(valueTime) { return this.constructor.setValue(this.xid, valueTime); }
Which should work for numeric points. You would have to do something more clever to make this fully general purpose as currently the DataPoint object doesn't know its data type.
The node library is definitely not a finished product and anything you create is certainly encouraged to be shared.
it complains about TypeError: Cannot use 'in' operator to search for 'annotation' in 2118.7704248055056
-
this is what i am calling
DataPoint.setValue('DP_540483','2118.7704248055056');
-
DataPoint.setValue('DP_540483','2118.7704248055056')
should be more like...
DataPoint.setValue('DP_540483', {'value': 2118.7704248055056, 'time': new Date().getTime()});
-
@phildunlap said in Import javascript library:
DataPoint.setValue('DP_540483','2118.7704248055056')
should be more like...
DataPoint.setValue('DP_540483', {'value': 2118.7704248055056, 'time': new Date().getTime()});
Thanks itsl working fine now on the script side. Now i have a script (named CoolpropScript.sh) that I want to schedule it to run every 2 minutes. This script runs the node js code.
#! /bin/sh echo "running RunCoolprop.js" node /opt/mango/web/node-mango-client-master/RunCoolprop.js
If I run the script manually it works fine and executes the RunCoolprop.js. But if I schedule the script to run using crontab i only see some (echo "running RunCoolprop.js") part of the script being executed and not the rest. Here is how i have it added to the crontab:
*/2 * * * * /opt/mango/web/node-mango-client-master/CoolpropScript.sh >> /opt/mango/web/node-mango-client-master/CoolpropScript.log
Is there an auto timeout associated to the crontabs in the mango linux distribution? It seems the scripts timeout after few seconds...
-
No there shouldn't be anything in the operating system getting in the way. I would advise
- Redirect stderr to your output file as well,
*/2 * * * * root /opt/mango/web/node-mango-client-master/CoolpropScript.sh >> /opt/mango/web/node-mango-client-master/CoolpropScript.log 2>&1
- Check
dmesg
output
Edit: - Add the user that's running it... how are you editing this cron?
-
@phildunlap said in Import javascript library:
No there shouldn't be anything in the operating system getting in the way. I would advise
- Redirect stderr to your output file as well,
*/2 * * * * root /opt/mango/web/node-mango-client-master/CoolpropScript.sh >> /opt/mango/web/node-mango-client-master/CoolpropScript.log 2>&1
- Check
dmesg
output
Edit: - Add the user that's running it... how are you editing this cron?
Thats better. It seems that Node path gets messed up when the script is executed through crontab and it was complaining about not being able to find node. I added the "/usr/local/bin/node /opt/mango/web/node-mango-client-master/RunCoolprop.js" to the script and now it executes it but further down the road complains about not finding more files, Seems all the paths are screwed up.
-
Maybe you should try adding
echo $PATH;
to your CoolpropScript.shDid you add a user? If you're editing using crontab -e, you may be running them as the mango user and may have various file permission issues to tackle. If you place them with a user specified in the /etc/cron.d directory you may have more luck.