Import javascript library
-
I do not see Timer Already Cancelled errors in your log after you restarted Mango.
-
@phildunlap said in Import javascript library:
I do not see Timer Already Cancelled errors in your log after you restarted Mango.
my bad. that was an old log. i sent you a newer one.
-
You ran out of memory using a large excel report. Are you using rollups? You should probably be watching the console output while you're developing your solution.
-
@phildunlap said in Import javascript library:
You ran out of memory using a large excel report. Are you using rollups? You should probably be watching the console output while you're developing your solution.
i dont understand. what i was developing is that simple httpget, unless that javascript load issue is causing issues up again.
-
ERROR 2017-07-19 13:31:23,974 (com.serotonin.m2m2.rt.maint.BackgroundProcessing$1.run:76) - Error in work item java.lang.OutOfMemoryError: Java heap space at org.apache.xmlbeans.impl.store.Xobj$AttrXobj.newNode(Xobj.java:2780) at org.apache.xmlbeans.impl.store.Xobj.copyNode(Xobj.java:1112) at org.apache.xmlbeans.impl.store.Xobj.copy_contents_from(Xobj.java:2337) at org.apache.xmlbeans.impl.store.Xobj.copy(Xobj.java:2411) at org.apache.xmlbeans.impl.values.XmlObjectBase._copy(XmlObjectBase.java:169) at org.apache.xmlbeans.impl.values.XmlObjectBase._copy(XmlObjectBase.java:152) at org.apache.xmlbeans.impl.values.XmlObjectBase.copy(XmlObjectBase.java:122) at org.apache.poi.xssf.usermodel.XSSFRow.onDocumentWrite(XSSFRow.java:501) at org.apache.poi.xssf.usermodel.XSSFSheet.write(XSSFSheet.java:3357) at org.apache.poi.xssf.usermodel.XSSFSheet.commit(XSSFSheet.java:3321) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:464) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:469) at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:211) at com.infiniteautomation.mango.excelreports.rt.ExcelReportWorkItem.execute(ExcelReportWorkItem.java:527) at com.serotonin.m2m2.rt.maint.BackgroundProcessing$1.run(BackgroundProcessing.java:73) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
if you are not using Excel Reports then delete whatever report this is and restart Mango.
-
@phildunlap said in Import javascript library:
ERROR 2017-07-19 13:31:23,974 (com.serotonin.m2m2.rt.maint.BackgroundProcessing$1.run:76) - Error in work item java.lang.OutOfMemoryError: Java heap space at org.apache.xmlbeans.impl.store.Xobj$AttrXobj.newNode(Xobj.java:2780) at org.apache.xmlbeans.impl.store.Xobj.copyNode(Xobj.java:1112) at org.apache.xmlbeans.impl.store.Xobj.copy_contents_from(Xobj.java:2337) at org.apache.xmlbeans.impl.store.Xobj.copy(Xobj.java:2411) at org.apache.xmlbeans.impl.values.XmlObjectBase._copy(XmlObjectBase.java:169) at org.apache.xmlbeans.impl.values.XmlObjectBase._copy(XmlObjectBase.java:152) at org.apache.xmlbeans.impl.values.XmlObjectBase.copy(XmlObjectBase.java:122) at org.apache.poi.xssf.usermodel.XSSFRow.onDocumentWrite(XSSFRow.java:501) at org.apache.poi.xssf.usermodel.XSSFSheet.write(XSSFSheet.java:3357) at org.apache.poi.xssf.usermodel.XSSFSheet.commit(XSSFSheet.java:3321) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:464) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:469) at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:211) at com.infiniteautomation.mango.excelreports.rt.ExcelReportWorkItem.execute(ExcelReportWorkItem.java:527) at com.serotonin.m2m2.rt.maint.BackgroundProcessing$1.run(BackgroundProcessing.java:73) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
if you are not using Excel Reports then delete whatever report this is and restart Mango.
thanks. i deleted it and it worked. Now i see the httpget running. but the issue is that it runs only the first time (when i enable the datasource). My update period is set to 2 min but i dont see the time stamp for the virtual DP to be ever updated after that initial enable toggle button clicked, Thanks.
-
@arvand.owji said in Import javascript library:
@phildunlap said in Import javascript library:
ERROR 2017-07-19 13:31:23,974 (com.serotonin.m2m2.rt.maint.BackgroundProcessing$1.run:76) - Error in work item java.lang.OutOfMemoryError: Java heap space at org.apache.xmlbeans.impl.store.Xobj$AttrXobj.newNode(Xobj.java:2780) at org.apache.xmlbeans.impl.store.Xobj.copyNode(Xobj.java:1112) at org.apache.xmlbeans.impl.store.Xobj.copy_contents_from(Xobj.java:2337) at org.apache.xmlbeans.impl.store.Xobj.copy(Xobj.java:2411) at org.apache.xmlbeans.impl.values.XmlObjectBase._copy(XmlObjectBase.java:169) at org.apache.xmlbeans.impl.values.XmlObjectBase._copy(XmlObjectBase.java:152) at org.apache.xmlbeans.impl.values.XmlObjectBase.copy(XmlObjectBase.java:122) at org.apache.poi.xssf.usermodel.XSSFRow.onDocumentWrite(XSSFRow.java:501) at org.apache.poi.xssf.usermodel.XSSFSheet.write(XSSFSheet.java:3357) at org.apache.poi.xssf.usermodel.XSSFSheet.commit(XSSFSheet.java:3321) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:464) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:469) at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:211) at com.infiniteautomation.mango.excelreports.rt.ExcelReportWorkItem.execute(ExcelReportWorkItem.java:527) at com.serotonin.m2m2.rt.maint.BackgroundProcessing$1.run(BackgroundProcessing.java:73) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
if you are not using Excel Reports then delete whatever report this is and restart Mango.
thanks. i deleted it and it worked. Now i see the httpget running. but the issue is that it runs only the first time (when i enable the datasource). My update period is set to 2 min but i dont see the time stamp for the virtual DP to be ever updated after that initial enable toggle button clicked, Thanks.
ok, just to be exact, it does seem that it actualy updates the DP but it doesnt do it every 2 minutes. I left it since the last post and I see the value time stamp is 13:50.
-
@arvand.owji said in Import javascript library:
@arvand.owji said in Import javascript library:
@phildunlap said in Import javascript library:
ERROR 2017-07-19 13:31:23,974 (com.serotonin.m2m2.rt.maint.BackgroundProcessing$1.run:76) - Error in work item java.lang.OutOfMemoryError: Java heap space at org.apache.xmlbeans.impl.store.Xobj$AttrXobj.newNode(Xobj.java:2780) at org.apache.xmlbeans.impl.store.Xobj.copyNode(Xobj.java:1112) at org.apache.xmlbeans.impl.store.Xobj.copy_contents_from(Xobj.java:2337) at org.apache.xmlbeans.impl.store.Xobj.copy(Xobj.java:2411) at org.apache.xmlbeans.impl.values.XmlObjectBase._copy(XmlObjectBase.java:169) at org.apache.xmlbeans.impl.values.XmlObjectBase._copy(XmlObjectBase.java:152) at org.apache.xmlbeans.impl.values.XmlObjectBase.copy(XmlObjectBase.java:122) at org.apache.poi.xssf.usermodel.XSSFRow.onDocumentWrite(XSSFRow.java:501) at org.apache.poi.xssf.usermodel.XSSFSheet.write(XSSFSheet.java:3357) at org.apache.poi.xssf.usermodel.XSSFSheet.commit(XSSFSheet.java:3321) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:464) at org.apache.poi.POIXMLDocumentPart.onSave(POIXMLDocumentPart.java:469) at org.apache.poi.POIXMLDocument.write(POIXMLDocument.java:211) at com.infiniteautomation.mango.excelreports.rt.ExcelReportWorkItem.execute(ExcelReportWorkItem.java:527) at com.serotonin.m2m2.rt.maint.BackgroundProcessing$1.run(BackgroundProcessing.java:73) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
if you are not using Excel Reports then delete whatever report this is and restart Mango.
thanks. i deleted it and it worked. Now i see the httpget running. but the issue is that it runs only the first time (when i enable the datasource). My update period is set to 2 min but i dont see the time stamp for the virtual DP to be ever updated after that initial enable toggle button clicked, Thanks.
ok, just to be exact, it does seem that it actualy updates the DP but it doesnt do it every 2 minutes. I left it since the last post and I see the value time stamp is 13:50.
ok, so the problem was that the virtual data point was set to update every 10 min and the httpget was 2 minutes. I changed virtual dp to 2 min and now its working as expected. Thanks for the help :)
-
Nice, glad you got it figured out!
-
Hi,
Its been a while but i'm encountering a new issue that is very related to what we discussed here before. I developed the code and everything was working fine in the test box and i left it for few months. Didn't pay much attention until now.
I have an HTTP Retriever that calls a local url (my file is in /opt/mango/web). This url, reads bunch of XIDs and then does some calculations and then sets bunch of other XIDs.
My HTTP Retriever runs fine with no error (set on update every 2 minutes and I see it under Polls) but my values dont get updated. Its as if the code is not running. I dont see any errors in ma.log and so far i coudln't see any indication of an issue. Even when i enable/disable the data source, i still dont see the data being updated (in ma.log, i see the data source being disabled/enabled with no issue).
To test the url for the http retriever, i manually ran it in a browser and it actually updated the values but if i do "curl" from the mango command prompt, i dont see the values being updated.
Where can i see the actual result from HTTP Retriever, is there a log for it? Thanks. -
Hi arvand,
It doesn't look like there's more logging to be enabled. Be sure to keep an eye on your events, as I would expect an event to be raised in Mango if there was an error. It's possible an error is escaping to stderr, but I wouldn't think so. You can launch Mango manually with /opt/mango/bin/ma.sh start and then trigger a poll to see if there's an exception escaping.
More likely than not, if the checkmark on the data source fetches the data (unless your browser has some authenticating cookie), it's going to be a problem with a point of some kind. If you've made recent edits, I would try disabling those points, or all but one, and trying again.
I do not know what you mean, "but if I do curl from the mango command prompt." I don't refer to anything as the Mango command prompt. Do you mean you SSH'ed into the device?
-
@phildunlap said in Import javascript library:
I do not know what you mean, "but if I do curl from the mango command prompt." I don't refer to anything as the Mango command prompt. Do you mean you SSH'ed into the device?
What imeant was that if i ssh to the box and run curl with the url, i still dont see the values being updated. The only case that it works is to run the url through a web browser.
-
Running curl on the command line doesn't do anything to Mango.
So, the checkmark opens the page successfully, the checkmark on the edit point for the value regex gets the right value, curl gets the data but it doesn't update in Mango (and was never supposed to), but when polling on its own the data source gets no values? Any chance you have an authentication cookie in your browser?
You can email in your json for the Http retriever and a sample document to support@infiniteautomation.com or you can post it here and I'll look at it.
-
@phildunlap ok thanks. im trying it on a newer box now (version 3). If it doesnt work on this one either, i will let you know. It was working fine on the old box until it stopped.
-
when i look at the poll data for the http retriever data source i see the poll time is 0 second. is this right?
2017/09/28 18:46:40.849 0ms
2017/09/28 18:48:40.849 0ms
2017/09/28 18:50:40.849 0ms -
here is the json. The box has access to the url. i confirmed by issuing wget and curl from ssh.
"dataSources":[
{
"xid":"DS_608664",
"name":"CoolPropRet",
"enabled":true,
"type":"HTTP_RETRIEVER",
"alarmLevels":{
"DATA_RETRIEVAL_FAILURE":"URGENT",
"POLL_ABORTED":"URGENT",
"SET_POINT_FAILURE":"URGENT",
"PARSE_EXCEPTION":"URGENT"
},
"purgeType":"YEARS",
"updatePeriodType":"MINUTES",
"quantize":false,
"retries":3,
"setPointUrl":"",
"timeoutSeconds":40,
"updatePeriods":2,
"url":"http://IPADDRESS:85/coolprop4.html",
"editPermission":"",
"purgeOverride":false,
"purgePeriod":1
}
]
} -
and here is the html for coolprop4.html
<!DOCTYPE html> <html> <head> <title>Set Point Value</title> <!-- Add the Mango Favicon --> <link rel="icon" href="/images/favicon.ico"> <!-- Page Style --> <style></style> <link href="/resources/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="/modules/dashboards/web/private/css/dashboard.css" rel="stylesheet"> <!-- Base Library --> <script type="text/javascript" src="/resources/loaderConfig.js"></script> <script type="text/javascript" src="/resources/require.js"></script> <script type="text/javascript" src="/resources/main.js"></script> <script type="text/javascript" src="coolprop.js"></script> <script type="text/javascript"> require(['jquery', 'mango/api'], function($, MangoAPI) { //defaiult numbers for pressure and temperature //The temperatures are in *F and pressures are in var Pressure = 40; var Temprature = 500; $('#document').ready(function(){ MangoAPI.defaultApi.getCurrentValue('DP_962596').then(function(currentValue){ var statusRow = []; statusRow.push('System Start time is' + currentValue.value+' minutes ago.'); statusRow.push(new Date()); $('#status').append(createRow(statusRow)); if(currentValue.value>0.1){ MangoAPI.defaultApi.getCurrentValue('DP_833148').then(function(currentValue){ Pressure=currentValue.value; MangoAPI.defaultApi.getCurrentValue('DP_529391').then(function(currentValue){ Temprature=currentValue.value; var xid = 'DP_274226'; //S_Nitrogen var Gas_Type='Nitrogen'; SetValues(xid,Pressure,Temprature,Gas_Type); xid = 'DP_540483'; //S_R134a Gas_Type='R134a'; SetValues(xid,Pressure,Temprature,Gas_Type); xid = 'DP_499589'; //S_R404A Gas_Type='R404A'; SetValues(xid,Pressure,Temprature,Gas_Type); xid = 'DP_052405'; //S_R410A Gas_Type='R410A'; SetValues(xid,Pressure,Temprature,Gas_Type); xid = 'DP_403680'; //S_R507A Gas_Type='R507A'; SetValues(xid,Pressure,Temprature,Gas_Type); }).fail(MangoAPI.logError); }).fail(MangoAPI.logError); } }).fail(MangoAPI.logError); }); function SetValues(xid,Pressure,Temprature,Gas_Type){ //We need the data type for the point MangoAPI.defaultApi.getPoint(xid).then(function(point){ //Check to see if settable if(point.pointLocator.settable === false){ var statusRow = []; statusRow.push(xid + ' not settable.'); statusRow.push(new Date()); //Append a status row $('#status').append(createRow(statusRow)); return; } var pvt = getPointValueTime(point,Pressure,Temprature,Gas_Type); MangoAPI.defaultApi.putValue(xid, pvt).then(function(response){ var statusRow = []; statusRow.push('Set Value For ' + xid +'('+Gas_Type+')'+' to ' + pvt.value); statusRow.push(new Date()); //Append a status row $('#status').append(createRow(statusRow)); }).fail(MangoAPI.logError); }).fail(MangoAPI.logError); } function createRow(columns){ var tr = $('<tr>'); for(var i=0; i<columns.length; i++){ var td = $('<td>'); td.text(columns*); tr.append(td); } return tr; } function getPointValueTime(dataPoint,Pressure,Temprature,Gas_Type){ var value = null; value= Module.PropsSI('S', 'P', Pressure, 'T', Temprature, Gas_Type); return { value: value, timestamp: new Date().getTime(), annotation: 'Set by custom dashboard', dataType: dataPoint.pointLocator.dataType, }; } }); </script> </head> <body> <div id="main"> <div class="row"> <div class="col-md-12"> <table class="table"> <tr><th>Status</th><th>Time</th></tr> <tbody id="status"></tbody> </table> </div> </div> </div> </body> </html>
-
The detail that is missing is the regex you are trying to use to get values from this. You didn't put any data points in your export.
I must say, I'm confused. Why would you have a data source regex'ing a script for constant content? The JavaScript and HTML (or whatever content) are not interpreted beyond the data points you create to parse it.
A 0ms poll isn't that surprising, as it's loading a file locally. Here were my poll times reading the regex Set(.*) for group 1 (which gives me value,
Point Value</title>
)from that content saved as you describe,2017/09/28 20:53:15.311 16ms
2017/09/28 20:53:20.311 8ms
2017/09/28 20:53:25.311 0ms
2017/09/28 20:53:30.311 0ms
2017/09/28 20:53:35.311 0ms
2017/09/28 20:53:40.311 0ms
2017/09/28 20:53:45.311 0ms
2017/09/28 20:53:50.311 8ms
2017/09/28 20:53:55.311 4ms
2017/09/28 20:54:00.311 0msBecause it's doing the same thing every time. It will definitely be 0ms if you don't have any data points.
-
@phildunlap I agree. What im trying to do is a bit confusing but here is my attempt for a s simple explanation...
I have a javascript library named coolprop.js that is about 7mb in size and too big to use inside a mango script. So what i ended up to do was to create an html page that:
Step 1: retrieves bunch of data points value by XID then
Step 2: passes those data points value to a function provided by coolprop to do some calculation, then
Step 3: use mango api to assign values calculated in above step to some other Data points.I then use the url pointed to this html file into httpretriever to simply run this html file every 2 minutes. Once html is ran, it should set the values as detailed out in the above steps. I know the html works because if i run it through my browser, it perfectly does what it suppose to but when i run it through httpretreiver, nothing happens (as if the whole URL is not even being called every 2 minutes). This script used to work before but suddenly stopped working. and unfortunately i cant really debug it. When running in the browser, i can see the output and errors written in the chrome devtool but i have no visibility to errors when using http retriever.
-
@phildunlap i hope that my explanation above made sense. Thanks.