• 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

    Enhance Reports by adding device vs. individual point selection

    Wishlist
    2
    4
    1.0k
    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

      When creating a report it would be nice to have the option to choose a "Device" (datasource) and have all points added to the report vs. having to add each one individually. Sometimes its quicker to include all points and delete the few you don't want then adding them individually. Maybe choose a device from the drop-down which displays available points with check boxes similar to adding points when using BACnet discovery by device instance? This report could then become a template that could be applied to other like devices.

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

        Hi Wingnut2.0,

        Thanks for the idea! I know internally we're talking about ways to unify the reporting, and I would definitely expect we'll consider this and put in some mechanisms resembling those in the Watchlist Builder.

        One could do something like this with either a python script or a script inside of Mango. I can show you how, but admittedly it isn't as smooth as having a UI to do it from.

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

          Thank you, Philip. Something similar to the Watchlist Builder sounds great.
          If you had a simple python example I could use as a starting point I would be owe you yet another beer.

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

            A better script, a tastier beer?

            import requests
            import json
            from StringIO import StringIO
            import copy
            
            #Script information, CONFIGURE
            reportXid = "Your Report XID" #Report XID to add points to
            removeExistingPoints = False #Remove the points that are already on the report
            addDataSources = ["DS_1234"] #list of data source xids to add
            additionalRQL = "limit(-1)" #use a high limit if not H2, or whatever limit is desired
            
            #Server information, CONFIGURE
            host = "192.168.1.111"
            port = "80"
            login = {"username": "admin", "password": "admin"}
            
            #Begin script....
            hostPort = host + ":" + port
            
            s = requests.Session()
            s.headers.update({'Cookie':'MANGO'+port+'=initial; XSRF-TOKEN=init','X-Xsrf-Token':'init','Accept': 'application/json', 'Accept-Encoding': 'gzip', 'Content-Type': 'application/json;charset=UTF-8'});
            
            r = s.post('http://' + hostPort + "/rest/v2/login", data=json.dumps(login))
            
            #del s.headers["Content-Type"]
            del s.headers["Cookie"]
            s.headers["X-Xsrf-Token"] = s.cookies["XSRF-TOKEN"]
            
            #get the report's JSON:
            reportsResponse = s.get('http://' + hostPort + "/rest/v2/json-emport?exportElements=reports")
            #print reportsResponse.text
            reportsList = json.load( StringIO( reportsResponse.text ))["reports"]
            report = None
            for rpt in reportsList :
            	if rpt["xid"] == reportXid :
            		report = rpt
            		break
            		
            if report is None :
            	print "Couldn't find report with xid: " + reportXid
            	exit()
            	
            if removeExistingPoints :
            	report.points = []
            	
            baseReportPoint = {
                           "pointXid":"",
                           "colour":"",
                           "consolidatedChart":True,
                           "plotType":1,
                           "pointKey":"p",
                           "weight":1.0
                        }
            
            if len(addDataSources) > 0 :
            	dataPointsRql = "or("
            	for dsXid in addDataSources :
            		dataPointsRql += "eq(dataSourceXid," + dsXid + "),"
            	dataPointsRql = dataPointsRql[:-1] + ")&" + additionalRQL
            else :
            	dataPointsRql = additionalRQL
            	
            #print dataPointsRql
            
            def pointInReport(reportPoints, point) :
            	for pnt in reportPoints :
            		if pnt["pointXid"] == point["xid"] :
            			return True
            	return False
            
            pointsResponse = s.get("http://" + hostPort + "/rest/v2/data-points?" + dataPointsRql)
            #print pointsResponse.text
            pointsList = json.load( StringIO( pointsResponse.text ))["items"]
            for pnt in pointsList :
            	#You may wish to configure the report points here as well
            	if not pointInReport(report["points"], pnt) :
            		newReportPoint = copy.deepcopy(baseReportPoint)
            		newReportPoint["pointXid"] = pnt["xid"]
            		newReportPoint["pointKey"] += str(pnt["id"])
            		report["points"].append(newReportPoint)
            		#print "Added point: " + pnt["xid"]
            
            #Save the modified report through the json-emport
            saveResponse = s.post("http://" + hostPort + "/rest/v2/json-emport", data=json.dumps({"reports":[report]}))
            print "Saving report returned status: ", saveResponse
            

            You probably need to change my print statements if you're using Python 3.

            Edit: Fixed up the multiple data source possibility some

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