• 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

    Using JSON Store for Data Point tagging - Can it be done?

    User help
    2
    4
    1.3k
    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.
    • W
      Wingnut2.0
      last edited by

      Can JSON Store be used to link additional attributes to a DataPoint? Use-case might be tagging circuit breaker readings with a customer or department name and then retrieving information or running reports by customer.

      Can a JSON Store value be made available to Meta Data Points via the Script context drop-down?

      Any small examples would be greatly appreciated.

      1 Reply Last reply Reply Quote 0
      • Jared WiltshireJ
        Jared Wiltshire
        last edited by

        We have talked about adding more flexible data point tagging, its something we definitely see the value in. Hopefully we can add this to a release soon!

        But in regards to your question, yes you can add additional information about a data point to the JSON store and access it from a meta data point. This is something we have been doing a fair recently for our customer projects.

        Here's an example meta data point script that retrieves settings for its data point XID. It only retrieves the JSON data when the point starts not every poll.

        var pointConfig = this.pointConfig;
        if (!pointConfig) {
            var dao = com.serotonin.m2m2.db.dao.JsonDataDao.instance;
            var jsonDataVo = dao.getByXid('point-configuration');
            var dataAsString = jsonDataVo.jsonData.toString();
            var data = JSON.parse(dataAsString);
            pointConfig = this.pointConfig = data[point.dataPointWrapper.xid];
        }
        
        var result = contextPoint.value * pointConfig.multiplier + pointConfig.offset; 
        return isFinite(result) ? result : UNCHANGED;
        

        Developer at Radix IoT

        1 Reply Last reply Reply Quote 0
        • W
          Wingnut2.0
          last edited by

          Thank you, Jared.
          I have tried to apply this using the example from the maJsonStore demo to input a value to "phone".

          <ma-json-store xid="phoneData" item="myItem" value="myValue"></ma-json-store>
          <input ng-model="myValue.phone">
          <md-button class="md-raised md-primary md-hue-3" ng-click="myItem.$save()">
              <md-icon>save</md-icon> Save
          </md-button>
          <p>Phone # from JSON store: {{myItem.jsonData.phone}}</p>
          

          I then have a Meta Data Point that attempts to retrieve the value of "phone" utilizing the code you provided. I am having trouble understanding the context of the following line and how it should be modified to return the phone.value that was added via the UI.

          data[point.dataPointWrapper.xid]
          

          Using this....

          var pointConfig = this.pointConfig;
          if (!pointConfig) {
              var dao = com.serotonin.m2m2.db.dao.JsonDataDao.instance;
              var jsonDataVo = dao.getByXid('phoneData');
              var dataAsString = jsonDataVo.jsonData.toString();
              var data = JSON.parse(dataAsString);
              pointConfig = this.pointConfig = data[point.dataPointWrapper.xid];
          }
          
          var result = pointConfig.phone; 
          

          I receive this error....

          ReferenceError: "point" is not defined
          

          Thank you.

          1 Reply Last reply Reply Quote 0
          • Jared WiltshireJ
            Jared Wiltshire
            last edited by

            point is the variable name I gave to the meta data point the script is in. It defaults to my I believe, there is a text box for it on the meta data point edit page.

            Developer at Radix IoT

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