Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

  • Cron pattern to copy over a USB drive

    24
    0 Votes
    24 Posts
    17k Views
    S
    ok, Thank you a lot!
  • Best way to store attribute data about data sources

    11
    0 Votes
    11 Posts
    3k Views
    phildunlapP
    Certainly! Glad you figured it out!
  • Setting up an Output Control Switch

    4
    0 Votes
    4 Posts
    1k Views
    BGB
    Hello Phil, Thank you for your reply, You have given me some things to think about. We use point links because that is what worked in Mango 2. We use them to update a flag column in the MySQL input tables so our SQL data sources know which rows have been read already. I was trying to use the point links to do the same job but with an insert command instead of an update command. I need the insert command to work with either state of the binary point. I considered setting the SQL point directly but could only work out how to set a single state that way. And that way I would need an On switch and a separate Off switch on the dashboard. Any coding advice on how to do this would be very helpful. I changed my IF statement to use === (my lack of experience is showing) but I still got the validation error. Here is the trace from the Ma.log that occurs when I try to validate: ERROR 2019-07-30T07:38:49,400 (com.serotonin.m2m2.web.dwr.util.ExceptionDetectionFilter.doFilter:38) - DWR invocation exception java.lang.ClassCastException: java.lang.String cannot be cast to com.serotonin.m2m2.rt.dataImage.PointValueTime at com.serotonin.m2m2.pointLinks.PointLinksDwr.validateScript(PointLinksDwr.java:179) ~[?:?] at sun.reflect.GeneratedMethodAccessor658.invoke(Unknown Source) ~[?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161] at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34) ~[dwr-2.0.11.jar:?] at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428) ~[dwr-2.0.11.jar:?] at com.serotonin.m2m2.web.dwr.util.TranslationsFilter.doFilter(TranslationsFilter.java:37) ~[mango-3.6.3.jar:?] at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428) ~[dwr-2.0.11.jar:?] at com.serotonin.m2m2.web.dwr.util.ExceptionDetectionFilter.doFilter(ExceptionDetectionFilter.java:26) ~[mango-3.6.3.jar:?] at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428) ~[dwr-2.0.11.jar:?] at com.serotonin.m2m2.web.dwr.util.DwrPermissionFilter.doFilter(DwrPermissionFilter.java:46) ~[mango-3.6.3.jar:?] at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:428) ~[dwr-2.0.11.jar:?] at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:431) ~[dwr-2.0.11.jar:?] at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:283) ~[dwr-2.0.11.jar:?] at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52) ~[dwr-2.0.11.jar:?] at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101) ~[dwr-2.0.11.jar:?] at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146) ~[dwr-2.0.11.jar:?] at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) ~[javax.servlet-api-3.1.0.jar:3.1.0] at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[javax.servlet-api-3.1.0.jar:3.1.0] at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] at org.springframework.web.filter.ShallowEtagHeaderFilter.doFilterInternal(ShallowEtagHeaderFilter.java:108) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] at com.serotonin.m2m2.web.filter.MangoShallowEtagHeaderFilter.doFilterInternal(MangoShallowEtagHeaderFilter.java:95) ~[mango-3.6.3.jar:?] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.authentication.switchuser.SwitchUserFilter.doFilter(SwitchUserFilter.java:200) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at com.serotonin.m2m2.web.mvc.spring.security.RateLimitingFilter.doFilterInternal(RateLimitingFilter.java:56) ~[mango-3.6.3.jar:?] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at com.serotonin.m2m2.web.mvc.spring.security.PermissionExceptionFilter.doFilter(PermissionExceptionFilter.java:34) ~[mango-3.6.3.jar:?] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:155) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:100) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) ~[spring-security-web-5.1.5.RELEASE.jar:5.1.5.RELEASE] at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) ~[spring-web-5.1.7.RELEASE.jar:5.1.7.RELEASE] at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) ~[jetty-security-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1340) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) ~[jetty-servlet-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:220) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:740) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.Server.handle(Server.java:503) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260) ~[jetty-server-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) ~[jetty-io-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) ~[jetty-io-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118) ~[jetty-io-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) ~[jetty-util-9.4.12.v20180830.jar:9.4.12.v20180830] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161] Thank you for your help so far. I will add more info as I stumble my way through this :P Cheers Brian
  • Custom View didn't work

    6
    0 Votes
    6 Posts
    2k Views
    phildunlapP
    At least it makes for better time coverage on people getting responses :D
  • Selecting display units at run-time

    1
    0 Votes
    1 Posts
    663 Views
    No one has replied
  • 0 Votes
    4 Posts
    2k Views
    phildunlapP
    https://help.infiniteautomation.com/how-to-upgrade-mango
  • Are event messages available in scripts?

    6
    0 Votes
    6 Posts
    2k Views
    phildunlapP
    In 3.6 security was added to scripts to ensure that only a script with superadmin permissions could invoke Java code. That's probably what you're seeing.
  • How To Setup Twilio Publisher

    1
    4 Votes
    1 Posts
    901 Views
    No one has replied
  • 0 Votes
    4 Posts
    1k Views
    phildunlapP
    https://forum.infiniteautomation.com/topic/3044/can-you-relativise-an-excel-report-driven-by-watchlist-possibly ^ Has an example of a script that uses the watchlist's export to iterate over the XIDs that are in the watchlist. That's really more for static watchlists, but you could also get a watchlist's query string this way to pass to the RQL. There is a DataPointQuery.byXid("DP_12345") function as well to get a single DataPointWrapper. https://help.infiniteautomation.com/about-mango-java-script Has information about the various context objects available to assist in writing scripts. Note from the first link, though, that you can invoke Java directly, making the scripting environment extremely powerful and flexible.
  • How to reset SSH password

    7
    0 Votes
    7 Posts
    2k Views
    phildunlapP
    Smaller than the smallest commercially available these days, I'd think. Edit: Okay nevermind, I'm amazed how small USB drives are still offered! To answer more generally, that function of the USB stick would not require much space, cetainly less than 1MB, but its other functions such as file transfers or log file extraction and whatnot can lead to arbitrary amounts of space being required.
  • Manually altering axis

    5
    0 Votes
    5 Posts
    2k Views
    Jared WiltshireJ
    @Pikey4 here's an example <ma-watch-list-get ng-model="designer.watchList" parameters="designer.parameters" on-points-change="designer.points = $points" id="ff8f56f8-0074-4f46-95a9-e789cda9836a" watch-list-xid="WL_ed918c86-646f-4760-b5af-d9285ff86505"></ma-watch-list-get> <div class="ma-designer-root" id="70fe9bc9-0fba-4311-8d0d-51ca93706697" style="width: 1366px; height: 768px; position: relative;" ng-init="page = {graphs: [null, {hidden: false}, null, null, null, null, {hidden: false, valueAxis: 'right'}, {hidden: false}]}"> <ma-point-values id="49e1ff96-2f4f-44bc-bfc1-97dc87b4a4cc" points="designer.points" from="dateBar.from" to="dateBar.to" rollup="{{dateBar.rollupType}}" rollup-interval="{{dateBar.rollupIntervals + ' ' + dateBar.rollupIntervalPeriod}}" style="position: absolute; left: 148px; top: 124px;" values="pvs"></ma-point-values> <ma-serial-chart id="2e8f4165-aeae-4555-90e0-efec6d3bd1a2" style="position: absolute; width: 1235px; height: 522px; left: 47px; top: 211px;" values="pvs" points="designer.points" legend="true" default-graph-options="{hidden: true}" graph-options="page.graphs"></ma-serial-chart> <md-input-container id="3e22c62f-6166-4e9a-b308-273131c207cd" style="position: absolute; left: 40px; top: 50px;"> <label>Select axis</label> <md-select ng-model="page.graphs[6].valueAxis"> <md-option value="left">Left</md-option> <md-option value="right">Right</md-option> </md-select> </md-input-container> </div>
  • sample code in java

    2
    0 Votes
    2 Posts
    1k Views
    CraigWebC
    Sample of what? A question like this is unlikely to get the response you are looking for...
  • How to start Mango in Raspberry pi 3 b+

    3
    0 Votes
    3 Posts
    2k Views
    ramhuzainiR
    Ok. it works. Thank you very much
  • This topic is deleted!

    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • 0 Votes
    6 Posts
    1k Views
    phildunlapP
    My mistake, try HOUR and .getHours() . I will edit my original post
  • Show me your best charts ...

    1
    0 Votes
    1 Posts
    823 Views
    No one has replied
  • Binary counter

    3
    0 Votes
    3 Posts
    1k Views
    phildunlapP
    Hi Pikey4, The "starts" member reflects how many times the point value was logged in the state in the period the statistics are over (so consecutive polls of 'true' if logging all data will be multiple starts). If there are no samples in the period but there is a start value, the starts will show as 0 despite it being true for the whole period. In that sense the proportion may most clearly resemble what you're trying to look at. But, you could certainly figure out from the stats.startValue if it was true at the beginning. var stats = p.past(MINUTE, 5); //binary point print( stats.get(true).starts ); print( stats.get(true).proportion );
  • Extracting multiple data points from an email

    6
    0 Votes
    6 Posts
    1k Views
    phildunlapP
    What issue did you foresee with the POP3 points? Multiple values per point per email? Here's the script I came up with, //JsonEmport.setImportDuringValidation(true); var pointIndexes = this.pointIndexes; var timezone = this.timezone; if(typeof pointIndexes === 'undefined') { pointIndexes = this.pointIndexes = pointIndexes = { windDirection: 2, windSpeed: 3, barometer: 4, rh: 5, temperature: 6, dewPoint: 7, sensorPower: 8 }; //Create points on the scripting data source with those variable names } var lines = p.value.replace(/\r/g, "").split("\n"); for( var k = 0; k < lines.length; k+=1 ) { var line = lines[k]; var dateMatch = /^.*?(\d\d)\/(\d\d)\/(\d\d)\s*\|\s*(\d\d):(\d\d):(\d\d).*/.exec(line); if(dateMatch !== null) { //Assume times are in server timezone, if UTC use next line, else manual offset var date = new Date(parseInt("20" + dateMatch[3]), parseInt(dateMatch[2])-1, parseInt(dateMatch[1]), parseInt(dateMatch[4]), parseInt(dateMatch[5]), parseInt(dateMatch[6])); // var utcDate = new Date(Date.UTC(parseInt("20" + dateMatch[3]), parseInt(dateMatch[2])-1, parseInt(dateMatch[1]), // parseInt(dateMatch[4]), parseInt(dateMatch[5]), parseInt(dateMatch[6]))) var lineData = line.split("|"); for(var point in pointIndexes) { var nextValue = lineData[pointIndexes[point]]; nextValue = nextValue.replace(/\s+/g, ""); if(typeof this[point] === 'undefined') { //Create a data point using our base point, var newDp = JSON.parse(JsonEmport.dataPointQuery("eq(xid,DP_EmailParser_BasePoint)")).dataPoints[0]; newDp.name = point; newDp.pointLocator.varName = point; newDp.enabled = true; delete newDp.xid; //get a randomly generated xid JsonEmport.doImportGetStatus(JSON.stringify({"dataPoints":[newDp]})); RuntimeManager.sleep(1000); } this[point].set(parseFloat(nextValue), date.getTime()); } } } Where for a similar email you would only need to change the pointIndexes object to be the names you want the points in those columns to be created with. I did it with the formatting still in the email (just add \s* all around some regex!) Here's the JSON for the data source with the base point: { "dataSources":[ { "xid":"DS_8ffb2983-dd50-42e1-9b43-706bc0a10eb2", "name":"Email Parser", "enabled":false, "type":"SCRIPTING", "alarmLevels":{ "SCRIPT_ERROR":"URGENT", "DATA_TYPE_ERROR":"URGENT", "POLL_ABORTED":"URGENT", "LOG_ERROR":"URGENT" }, "purgeType":"YEARS", "updateEvent":"CONTEXT_UPDATE", "context":[ { "varName":"p", "dataPointXid":"DP_f4a4b495-f7a8-4ddc-a619-5172835ebe30", "updateContext":true } ], "logLevel":"NONE", "cronPattern":"", "executionDelaySeconds":0, "historicalSetting":false, "logCount":5, "logSize":1.0, "script":"\/\/JsonEmport.setImportDuringValidation(true);\nvar pointIndexes = this.pointIndexes;\nvar timezone = this.timezone;\nif(typeof pointIndexes === 'undefined') {\n pointIndexes = this.pointIndexes = pointIndexes = {\n windDirection: 2,\n windSpeed: 3,\n barometer: 4,\n rh: 5,\n temperature: 6,\n dewPoint: 7,\n sensorPower: 8\n }; \/\/Create points on the scripting data source with those variable names\n}\n\nvar lines = p.value.replace(\/\\r\/g, \"\").split(\"\\n\");\nfor( var k = 0; k < lines.length; k+=1 ) {\n var line = lines[k];\n var dateMatch = \/^.*?(\\d\\d)\\\/(\\d\\d)\\\/(\\d\\d)\\s*\\|\\s*(\\d\\d):(\\d\\d):(\\d\\d).*\/.exec(line);\n if(dateMatch !== null) {\n \/\/Assume times are in server timezone, if UTC use next line, else manual offset\n var date = new Date(parseInt(\"20\" + dateMatch[3]), parseInt(dateMatch[2])-1, parseInt(dateMatch[1]),\n parseInt(dateMatch[4]), parseInt(dateMatch[5]), parseInt(dateMatch[6]));\n\/\/ var utcDate = new Date(Date.UTC(parseInt(\"20\" + dateMatch[3]), parseInt(dateMatch[2])-1, parseInt(dateMatch[1]),\n\/\/ parseInt(dateMatch[4]), parseInt(dateMatch[5]), parseInt(dateMatch[6])))\n var lineData = line.split(\"|\");\n for(var point in pointIndexes) {\n var nextValue = lineData[pointIndexes[point]];\n nextValue = nextValue.replace(\/\\s+\/g, \"\");\n if(typeof this[point] === 'undefined') {\n \/\/Create a data point using our base point,\n var newDp = JSON.parse(JsonEmport.dataPointQuery(\"eq(xid,DP_EmailParser_BasePoint)\")).dataPoints[0];\n newDp.name = point;\n newDp.pointLocator.varName = point;\n newDp.enabled = true;\n delete newDp.xid; \/\/get a randomly generated xid\n JsonEmport.doImportGetStatus(JSON.stringify({\"dataPoints\":[newDp]}));\n RuntimeManager.sleep(1000);\n }\n this[point].set(parseFloat(nextValue), date.getTime());\n }\n }\n}", "scriptPermissions":{ "customPermissions":"", "dataPointReadPermissions":"superadmin", "dataPointSetPermissions":"superadmin", "dataSourcePermissions":"superadmin" }, "editPermission":"", "purgeOverride":false, "purgePeriod":1 } ], "dataPoints":[ { "xid":"DP_EmailParser_BasePoint", "name":"BasePoint", "enabled":false, "loggingType":"ALL", "intervalLoggingPeriodType":"MINUTES", "intervalLoggingType":"AVERAGE", "purgeType":"YEARS", "pointLocator":{ "dataType":"NUMERIC", "contextUpdate":false, "settable":true, "varName":"basePoint" }, "eventDetectors":[ ], "plotType":"SPLINE", "rollup":"NONE", "unit":"", "simplifyType":"NONE", "chartColour":"", "chartRenderer":{ "type":"IMAGE", "timePeriodType":"DAYS", "numberOfPeriods":1 }, "dataSourceXid":"DS_8ffb2983-dd50-42e1-9b43-706bc0a10eb2", "defaultCacheSize":1, "deviceName":"Email Parser", "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":"ANALOG", "useUnitAsSuffix":true, "unit":"", "renderedUnit":"", "format":"0.000" }, "tolerance":0.0 } ] }
  • Can't import datapoint from CSV file to OPC DA datasource

    2
    0 Votes
    2 Posts
    980 Views
    phildunlapP
    Hi rocketrange, welcome to the forum and thank you for bringing this to our attention! It looks like the outgoing type name and the incoming type name are not the same (as is proper) in the code. You could probably get it to import by changing the type column from PL.OPC to TYPE_NAME and trying the import. I'll try to get a fix out for this today. Edit: See https://forum.infiniteautomation.com/topic/4095/release-notes-for-opcda-3-5-1
  • Capture data as an event for start and finish of a data flow

    5
    0 Votes
    5 Posts
    1k Views
    phildunlapP
    Hi Fox, I've been using CONTEXT.getRuntime() but I strongly get the feeling that this value is constant for when the script is fired - including when I do a force recalculate history. As in the value is the same for each historical execution? That is not the intended behavior, nor what I observed with an Alphanumeric meta point that was doing, return CONTEXT.getRuntime(); and then regenerated history. I could clearly see, whether my point was executing on a cron or context update, that the time returned was not the same. However, it does not change throughout the execution of the script, so, print(CONTEXT.getRuntime()); //time the script kicked off RuntimeManager.sleep(1000); print(CONTEXT.getRuntime()); //still the time the script kicked off You may also in some occasions want to use CONTEXT.getTimestamp(), which should always be the time of the triggering event without the possibility of server load delaying task execution by a few (or many) milliseconds creeping in as with the runtime (really only affects live values). If you're still doing the same sort of thing I'm curious why you'd switch over to the PointValueQuery tool instead of using the last() calls like before. I didn't get too deep into what that last script is trying to achieve. Maybe the issue is that during history generation last() doesn't work properly? You could use var pvt = p.pointValueBefore(CONTEXT.getTimestamp()+1); var pvt2 = p.pointValueBefore(pvt.time);