• 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

    Creating New equation

    How-To
    2
    2
    1.2k
    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.
    • N
      Nikospps
      last edited by

      Hello! I would like to create a new equation using a specific variable.

      This variable shows the total energy every specific time (refresh every 5 sec). I aim to create an equation where will be done a subtraction between this variable at 00:00 of this day (subtracter) and the instant Value of energy (subtrahend) as i take it from Mango.

      Let's assume E is the total energy variable, i would like to create an equation like: E(t)-E(00:00-start of the day). Is any way to implement this?

      Thanks in advance,
      Nikos.

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

        Hi Nikos,

        Yes, you could use a meta point like,

        var dayStartTime = new Date();
        dayStartTime.setHours(0);
        dayStartTime.setMinutes(0);
        dayStartTime.setSeconds(0);
        dayStartTime.setMilliseconds(1);
        
        //Get the value before the first millisecond of the day 
        // (00:00:00.000, or the last value from yesterday if it didn't change)
        var subtracter = variableContextPoint.pointValueBefore(dayStartTime.getTime())
        var subtrahend = energyContextPoint.value;
        
        if(subtracter == null)
          return -subtrahend;
        return subtracter.doubleValue - subtrahend;
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post