• P
    Pedro

    @phildunlap @craigweb

    Thank you both. This time the error was mine. I thought the point was multistate, but I now realize it was numeric rendered as a range. So I exported its historic values, changed the point type, then imported the values back in. It works now.

    The containsKey() example in the Mango Javascript help also works. In the past some of the examples did not work or were not consistent with new back-end functionality. I have not checked the other examples.

    posted in Scripting general Discussion read more
  • P
    Pedro

    Thank you for adding the get() function back into the statistics object. I can get it to work for binary data types, but I can't get it to work for multistate data.

    var bulk = 1;
    var stagePastDay = stage.past(DAY);
    var bulkHours = stagePastDay.data.get(bulk).runtime / (1000*60*60);
    return bulkHours;
    

    Script error: TypeError: Cannot read property "get" from undefined in <eval> at line number 3 in <eval> at line number 3
    If I replace "stage" with a boolean datapoint, it works fine.

    I also tried using .getStartsAndRuntime(), but that also did not work. Even the .getStartsAndRuntime() example from the "Mango Java Script" help page did not work.

    How can I obtain the runtime of a given state in a multistate datapoint?
    Have all the examples in the "Mango Java Script" been verified to still work after the changes?
    ma-core 3.5.5
    meta 3.5.0

    posted in Scripting general Discussion read more
  • P
    Pedro

    @terrypacker Thanks, that would be handy. Currently I have to add three lines of code to each .proportion or .percentage call. Some of the scripts run only at the end of the month, so with luck I'll be able to upgrade before the end of the month and edit those scripts before the month is up. Now I'm editing the scripts that run every minute.

    posted in Scripting general Discussion read more
  • P
    Pedro

    @terrypacker Thanks for the clarification.

    I'm sure users would be grateful if there were a couple of different examples of the new usage in the context help, including a warning about the potential to return null. It seems that any calls where .proportion or .percentage returned a 0 will now fail, and must be preceded by a check for null before the method is called.

    posted in Scripting general Discussion read more
  • P
    Pedro

    @jared-wiltshire said in Not a function:

    startsAndRuntime

    I found it under the core release notes:

    Removing get(object) and get(DataValue) from StartsAndRuntimeList javascript wrapper so these methods are no longer available and should never have been used

    Still wondering why the abrupt removal. I hope the documentation is changed to illustrate what to use instead.

    posted in Scripting general Discussion read more
  • P
    Pedro

    @jared-wiltshire said in Not a function:

    I can confirm that the .get() method was removed from the starts and runtimes wrapper for the scripting context in Mango v3.4.0, it was listed in the release notes.

    Thanks, Jared. I did not see any mention of .get() removal in the release notes, including the meta release notes. Perhaps I looked in the wrong place. Can you please provide a link to those release notes so that I can read it in context?

    What does appear to work more like the previous behavior is something like this -
    if (OverVLimit.past(HOUR, 1).startsAndRuntime[true].proportion > 0) return 1;

    Thanks. I just tried that, and this is the result:
    Script error: TypeError: Cannot get property "proportion" of null in at line number 5 in at line number 5

    So it seems that in addition to finding and deleting get() from all my scripts, I need to figure out the equivalent syntax for each , and then check for null before proceeding with the intended use, then test each script. Then I have to figure out the syntax for other .get() functions, and check multiple combinations of data to make sure each new code still works. This is quite a hassle, as I have 25 .get() calls to find among 337 metadata scripts.

    The removal of .get() is clearly breaking many scripts. I'm looking forward to hearing why .get() was removed. If it can be put back in and released in the next week or so, I may be better off waiting for the new release rather than changing, debugging, and testing all those scripts. Since the Mango Java Script online documentation still shows .get(), I have some hope that this functionality will be restored in the next release. When do you reckon the next release will be? I also have to weigh this against a version rollback.

    Thanks.

    posted in Scripting general Discussion read more
  • P
    Pedro

    I now have multiple IndexOutOfBoundsException errors. I believe it's a consequence of changing the metadata function syntax by inserting ['data'] before .get. However, the metadata function syntax check did not return an error. Even if the error is due to the new ['data'] Mango syntax, I'm not clear on how to fix the problem, since deleting ['data'] to match the Mango scripting documentation will just revert back to the not a function error in the metadata script.

    ERROR 2018-07-11T20:59:00,003 (com.serotonin.m2m2.meta.MetaPointLocatorRT.execute:321) - Index: 1, Size: 1 java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at java.util.ArrayList.rangeCheck(ArrayList.java:653) ~[?:1.8.0_131] at java.util.ArrayList.get(ArrayList.java:429) ~[?:1.8.0_131] at jdk.nashorn.internal.scripts.Script$Recompilation$23961$30$\^eval\_.__scriptExecutor__(<eval>:2) ~[?:?] at jdk.nashorn.internal.scripts.Script$23926$\^eval\_.:program(<eval>:213) ~[?:?] at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637) ~[nashorn.jar:?] at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) ~[nashorn.jar:?] at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) ~[nashorn.jar:?] at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449) ~[nashorn.jar:?] at jdk.nashorn.api.scripting.NashornScriptEngine.access$200(NashornScriptEngine.java:73) ~[nashorn.jar:?] at jdk.nashorn.api.scripting.NashornScriptEngine$3.eval(NashornScriptEngine.java:510) ~[nashorn.jar:?] at javax.script.CompiledScript.eval(CompiledScript.java:92) ~[?:1.8.0_131] at com.serotonin.m2m2.rt.script.CompiledScriptExecutor.execute(CompiledScriptExecutor.java:89) ~[mango-3.4.4.jar:?] at com.serotonin.m2m2.meta.JavaScriptPointLocatorRT.executeImpl(JavaScriptPointLocatorRT.java:84) ~[meta-ds-3.4.0.jar:?] at com.serotonin.m2m2.meta.MetaPointLocatorRT.execute(MetaPointLocatorRT.java:310) [meta-ds-3.4.0.jar:?] at com.serotonin.m2m2.meta.MetaPointLocatorRT$ScheduledUpdateTimeout.run(MetaPointLocatorRT.java:212) [meta-ds-3.4.0.jar:?] at com.serotonin.timer.Task.runTask(Task.java:179) [mango-3.4.4.jar:?] at com.serotonin.timer.TaskWrapper.run(TaskWrapper.java:23) [mango-3.4.4.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]

    Can someone please shed more light on this new Mango syntax? Where is it documented? Thanks.

    posted in Scripting general Discussion read more
  • P
    Pedro

    @joelhaggar Thanks for that the link to the manual upgrade. The upgrade worked, but there are still problems. The upgrade from 3.3.4 to 3.4.4 broke numerous metadata scripts (a problem someone else posted in https://forum.infiniteautomation.com/topic/3627/not-a-function). Also, the internal upgrade is still not working.

    I just tried to upgrade the two modules listed on /ui/administration/modules/upgrade:

    mangoNoSqlDatabase 	Time Series Data Store 	3.4.0 	3.4.1 	
    MangoUI 	Provides an AngularJS user interface,  	3.4.6 	3.4.7
    

    However, the automated download failed once again:

    WARN 2018-07-11T20:40:26,229 (com.serotonin.m2m2.web.dwr.ModulesDwr$UpgradeDownloader.run:503) - Upgrade download error java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[?:1.8.0_131] at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[?:1.8.0_131] at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137) ~[httpcore-4.4.9.jar:4.4.9] at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153) ~[httpcore-4.4.9.jar:4.4.9] at org.apache.http.impl.io.SessionInputBufferImpl.read(SessionInputBufferImpl.java:206) ~[httpcore-4.4.9.jar:4.4.9] at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:176) ~[httpcore-4.4.9.jar:4.4.9] at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135) ~[httpclient-4.5.5.jar:4.5.5] at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:148) ~[httpclient-4.5.5.jar:4.5.5] at com.serotonin.io.StreamUtils.transfer(StreamUtils.java:34) ~[mango-3.4.4.jar:?] at com.serotonin.io.StreamUtils.transfer(StreamUtils.java:27) ~[mango-3.4.4.jar:?] at com.serotonin.web.http.HttpUtils4.execute(HttpUtils4.java:105) ~[mango-3.4.4.jar:?] at com.serotonin.m2m2.web.dwr.ModulesDwr$UpgradeDownloader.run(ModulesDwr.java:499) [mango-3.4.4.jar:?] at com.serotonin.timer.Task.runTask(Task.java:179) [mango-3.4.4.jar:?] at com.serotonin.timer.TaskWrapper.run(TaskWrapper.java:23) [mango-3.4.4.jar:?] at com.serotonin.timer.OrderedThreadPoolExecutor$OrderedTaskCollection.run(OrderedThreadPoolExecutor.java:336) [mango-3.4.4.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_131] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_131] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_131]

    The ping time from my Mango server to infiniteautomation.com is close to 700ms. Perhaps there is a timeout in the Mango download function that is too strict to meet that loop time?

    posted in User help read more
  • P
    Pedro

    I just upgraded from 3.3.4 to 3.4.0, and I have the same problem:

    For example, this used to work:

    if (OverVLimit.past(HOUR, 1).get(true).proportion > 0) return 1;
    

    Now I get an error:

    Script error: TypeError: OverVLimit.past(HOUR, 1).get is not a function in at line number 5 in at line number 5
    

    Inserting ['data'] resolved the issue...

    if (OverVLimit.past(HOUR, 1)['data'].get(true).proportion > 0) return 1;
    

    However:

    • I have many metadata functions with similar errors, all of which are now broken since the upgrade.
    • This was not required before
    • This syntax is contrary to what is shown in the "Mango Java Script" help page
    • After changing the syntax, the metadata javascript editor now issues the following warning: ['data'] is better written in dot notation

    How would I write this in 'dot notation?' Will the "Mango Java Script" help page be changed to illustrate the new syntax?

    It would be a good idea to add all the metadata function calls to the default configuration that is used to test new Mango versions.

    Thanks,

    posted in Scripting general Discussion read more