• Recent
    • Tags
    • Popular
    • Register
    • Login

    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.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Logging before and after a trigger or event

    User help
    2
    4
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      Pikey4
      last edited by

      Hi,
      I would like to know how to (if at all possible) to poll a data source as often as 100 times per second and for a particular point, only log values after a trigger, but also just before that trigger.

      Example:
      Data source is a PLC being polled every 10ms
      Pressure Sensor providing readings every 10ms
      Trigger is when over say 500 Kpa
      Begin logging until for 30 seconds then stop logging.
      Also however log the values of the previous 30 seconds before the trigger happened.

      I thought about logging all values then purging every few minutes so that the memory doesn’t fill up but not sure about how to only catch that information I need, before and after the trigger. I have someone that might be able to set something up in a PLC but he is not sure he can do yet.

      Any suggestions would be appreciated.

      Mango Core version: 3.5.6
      Mango API module version: 3.5.2
      MangoUi module version: 3.5.5
      Platform: 10.14 MacOS Mojave
      Chrome: Version 70.0.3538.110 (64-bit)

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by phildunlap

        Hi Pikey4,

        Interesting request! My first inclination would be to try....

        1. Create a high limit event detector on the point that may read over 500, set the limit to 500.
        2. Create a scripting data source with three points, "State triggered" (binary, log value changes, varName 'trigger'), "Last state trigger logging" (binary, log all data, varName 'lastLogged'), "High value window data" (Numeric, all data, varName 'windowData') (of course you can change the names or varNames, but we'll be using the in a moment....). Scripting data source would be on cron "0/1 * * * * ?" . Add the 10ms point the the context, varName "dataIn"
        3. Create a "Set point" event handler from the high limit detector to the "State triggered" point, set it to a static value, true. On the inactive action, set it to false.
        4. Adjust the settings of your 10ms data point to "Do not log" for the logging, set the default cache size to 3500 (10ms is 100/s so 3500 values is 35s of data. This will be kept in RAM)
        5. Scripting data source body:
        var dataWindowSize = 30000; /* 30s */
        if(trigger.value) {
          var dataSinceTime;
          /* check if this is the second trigger in the window  or if we're still in that state*/
          if(trigger.time - lastLogged.time < dataWindowSize)
            dataSinceTime = lastLogged.time;
          else
            dataSinceTime = trigger.time - dataWindowSize;
        
          lastLogged.set(true);
          var newData = dataIn.pointValuesSince( dataSinceTime );
          for( var k = 0; k < newData.length; k+=1 ) {
            windowData.set( newData[k].value, newData[k].time );
          }
        } else if( lastLogged.time - trigger.time < dataWindowSize ) {
            var newData = dataIn.pointValuesSince( lastLogged.time );
            lastLogged.set(false); /* update our timestamp */
            for( var k = 0; k < newData.length; k+=1 ) {
              windowData.set( newData[k].value, newData[k].time );
            }
        }
        

        And that should do it! I didn't really test it, though, so let me know how it goes.

        1 Reply Last reply Reply Quote 0
        • phildunlapP
          phildunlap
          last edited by

          Thinking about it a little more, I messed up the logic a little. It should be the state detector's set point handler's inactive action that sets the trigger point to false. I will modify the suggested script to reflect this...

          1 Reply Last reply Reply Quote 0
          • P
            Pikey4
            last edited by

            Thanks Phillip i'll give this a shot if and when the install goes ahead but at least i know its possible. I agree it is a strange request from my clients

            Mango Core version: 3.5.6
            Mango API module version: 3.5.2
            MangoUi module version: 3.5.5
            Platform: 10.14 MacOS Mojave
            Chrome: Version 70.0.3538.110 (64-bit)

            1 Reply Last reply Reply Quote 0
            • First post
              Last post