• Recent
    • Tags
    • Popular
    • Register
    • Login
    1. Home
    2. Mert
    3. Posts

    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
    M
    • Profile
    • Following 5
    • Followers 2
    • Topics 3
    • Posts 6
    • Best 1
    • Controversial 0
    • Groups 0

    Posts made by Mert

    • How to query field names for events, data-points , and realtime endpoints?

      Hello everyone,

      In our app, some queries take around 12 seconds to download response data, therefore we want to reduce query times by querying for only necessary fields.
      There is "fields" query parameter for "point-values/latest" API. Is there any similar way or a workaround to query fields for APIs in below:

      http://[host]:[port]/rest/latest/events
      http://[host]:[port]/rest/v3/data-points
      http://[host]:[port]/rest/v3/realtime
      
      

      Also if you have any advice about reducing query times I'd love to hear it.

      posted in How-To rest api
      M
      Mert
    • RE: How can I make HTTP request with HttpBuilder in the new scripting environment?

      @terrypacker thanks a lot, an example code is more than enough. I will look into the library in detail and see how to use it in the upcoming days.

      Thanks once again!

      posted in How-To
      M
      Mert
    • RE: How can I make HTTP request with HttpBuilder in the new scripting environment?

      @terrypacker I'm using Graal.js. Here is the script :

      const HttpBuilder = Java.type('com.serotonin.m2m2.rt.script.HttpBuilderScriptUtility');
      
      HttpBuilder.request({
              path: url,
      	method: "POST",
      	headers: {
                     ContentType : "application/json",
                     Authorization : "Basic "+token,
      	},
      	content: JSON.stringify({
                     "type": 0,
                     "message": "This is a test message"
              }),
      	err: function(status, headers, content) { //errorCallback
      		throw "Request got bad response: " + status + content;
      	},
      	resp: function(status, headers, content) { //responseCallback
      	        console.log(content)
          	        return true;
      	},
      	excp: function(exception) { //exceptionCallback
      		throw exception.getMessage();
      	}
      });
      
      posted in How-To
      M
      Mert
    • How can I make HTTP request with HttpBuilder in the new scripting environment?

      Hello,

      I need to make an HTTP post request in a Script Event Handler. But I keep getting errors when using HttpBuilder.

      At first I got the error: ReferenceError: HttpBuilder is not defined

      Then I defined the HttpBuilder as :

      const HttpBuilder = Java.type('com.serotonin.m2m2.rt.script.HttpBuilderScriptUtility');
      

      Now I'm getting the error: TypeError: invokeMember (request) on com.serotonin.m2m2.rt.script.HttpBuilderScriptUtility failed due to: Unknown identifier: request

      What am I missing here?

      posted in How-To httpbuilder graal.js httprequest
      M
      Mert
    • RE: How to get event instance data as object using Script Event Handler

      I figured out how to do it by using java class methods in ma-core-public.

      const DataSourceDao = Java.type('com.serotonin.m2m2.db.dao.DataSourceDao');
      
      function myHandler(evt) {
          var point = evt.getContext().context.get("point");
          var pointXid = point.getXid();
          var pointTags = point.getTags();
      
          var dataSourceXid = point.getDataSourceXid();
          var ip = DataSourceDao.getInstance().getByXid(dataSourceXid).getHost();
      posted in How-To
      M
      Mert
    • How to get event instance data as object using Script Event Handler

      Hello everyone,

      We started exploring new scripting environment and currently trying to use Script Event Handlers instead of Set Point Event Handlers (Set To Scripted Value). We are be able to use the evt variable in global scripts with the code in below

      function myHandler(evt) {
          var point = evt.context.point;
          var pointXid = evt.context.point.xid;
          var pointTags = point.tags;
      

      But in the new Script Event Handler the evt variable returns a string. Is there a way to format evt variable into a proper object or do we need to do this in a different way in the new scripting environment?

      Thanks,
      Mert

      posted in How-To
      M
      Mert