• AldoRamos

    @phildunlap Excellent! That's really useful information.

    posted in Scripting general Discussion read more
  • AldoRamos

    This script is based on the XID; is there a way to get the "VO" from a conext point, or do I need to start with the XID?

    posted in Scripting general Discussion read more
  • AldoRamos

    Thanks @phildunlap, that should make it much more practical and maintainable.

    posted in Scripting general Discussion read more
  • AldoRamos

    I've been debugging a script that checks when Flow Rate exceeds 3gpm, After much confusion, I remembered that the device reports m³/h, and that data point is configured with "Convert Unit for display" checked, to convert it to "gal/min".

    Converted and Rendered values are available in the dashboard data point objects, but apparently not in scripting. Is there an intrinsic method for accessing the converted value, or do I need to do explicit math in the script?

    posted in Scripting general Discussion read more
  • AldoRamos

    We have several temperatures we collect, some in Fahrenheit, some in Celsius with the display unit converted to Fahrenheit.

    Is there a practical way for selecting which units to display, on a custom page for example, depending on the user's locale (or preference) etc.?

    posted in How-To read more
  • AldoRamos

    Thanks @phildunlap

    I did consider that my.lastValue would be returning current values, not historical. I have been working on a more complex function to work with that, but wasn't ready to post it, yet.

    However, the graph I posted was from data created in real-time (not history generation). And I explicitly purged all data before that run executed. I also typically purge and check the "Delete existing data in range" when generating history, to avoid the chance of running into such values.

    Here is the more complex time-traveler version (possibly buggy; I was just throwing stuff together, and haven't gone through with a fine-t0othed comb and debugged yet):

    //LOG.debug(my);
    //var lv = my.lastValue();
    LOG.debug("my.time:\t" + my.time);
    
    var lv = my.pointValueBefore(my.time);
    LOG.debug("lv:\t" + lv.value);
    var lastValue = ((null === lv) ? 0 : lv.value);
    LOG.debug("lastValue:\t" + lastValue);
    
    //var stats = power.past(MINUTE,1);
    var stats = power.getStats(my.time-60000, my.time);
    LOG.debug("stats:\t" + stats);
    
    if ((null === stats))
    {
    LOG.debug("stats:\tnull");
        return lastValue;
    }
    else if ((0 === stats.length) || (0 === stats.count))
    {
    LOG.debug("stats:\tempty");
    LOG.debug("power:\t" + power.pointValueAt(my.time));
        return lastValue + ((power.pointValueAt(my.time)/60)/1000);
    }
    else
    {
    LOG.debug("stats.average:\t" + stats.average);
        return lastValue + ((stats.average/60)/1000);
    }
    

    While I would like having a function I can use for generating history as well as runtime, I would expect at least the simple formula to work, and it would go a long way to helping debug the more complex version.

    posted in Scripting general Discussion read more
  • AldoRamos

    Calculating kWh (using the simple formula given as an example in the forum) and finding drops in the chart, which makes no sense. I have verified that the additive is positive, yet I still see a pattern I cannot explain.

    The formula is simple:

    return my.value + (power.past(MINUTE,1).average/60);
    

    But the result is unexpectedly jagged:
    0_1550697254184_e0eb3ea7-4eb9-47ef-8b12-c7adbce04759-image.png

    I expect this is due to the formula looking back too far for the previous (current) value, but I haven't had any luck calculating a better window. As an example, here is some of what I have been attempting:

    var prev = my.lastValue(0);
    var lastVal = (null === prev) ? my.value : prev.value;
    
    return lastVal + (power.value/60);
    

    FWIW, the data point is not set to update the context; instead, it's set to update every minute.

    Any clarification is greatly appreciated.

    Thanks,

    Aldo

    posted in Scripting general Discussion read more
  • AldoRamos

    I take it back, @MattFox ; apparently the CORS configuration IS necessary. Suddenly found it failing again, and sure enough enabling CORS did the trick.

    I really do go through these tests in a methodical manner, but somehow I'm losing the sequence today.

    Thanks to all who helped me get through this.

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • AldoRamos

    @mattfox Yes, the proxy configuration is exactly what I needed. The CORS configuration didn't seem to help.

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • AldoRamos

    I apologize for not mentioning the proxy. I didn't even think of it, since it had been working previously (and in development I often switch back and forth between proxy and VPN).

    I believe I upgraded from 3.4.1 (no longer have logs to confirm exactly). But I explicitly tested that page before & after to confirm this change in behavior.

    The ma.log shows nothing relevant (no entries except for JSON File Import Job.)

    @MattFox adding CORS configuration made no difference (except locking me out until I opened it up globally).

    Adding the following configuration to the VirtualHost configuration fixes it:

        RewriteEngine On
        RewriteCond %{HTTP:Connection} Upgrade [NC]
        RewriteCond %{HTTP:Upgrade} websocket [NC]
        RewriteRule /(.*) ws://internal.mangoserver.com:8080/$1 [P,L]
    
    

    I apologize for the confusion, but due to some similar issues with another Mango server, I explicitly tested it with this configuration before and after upgrading, which is why I listed the symptoms (and my diagnosis) as I did.

    Bottom line, it's working. Why? uhh.... It's working! ;-)

    posted in Dashboard Designer & Custom AngularJS Pages read more