• phildunlap

That one is intended to run every minute (.past(MINUTE, 1)) so for a meta point you could do Start of minute or 0 * * * * ? as your update event.

• phildunlap

It's definitely good to contribute methods of doing stuff, but it's best if those methods work (insert links to the many times I've said "untested" next to code snippets here...)

I think your parameters to the angular filter have a syntax error, they should be colon delimited, as,

{{point.value | number:N}}


where N is the number of decimal places, like,

{{point.value*256 | number:1}}


• phildunlap

Hi chio,

Currently this option does not exist, but it would be pretty easy to use a JSON export and a python script to rewrite the file something like...

import json

configFile = open("/path/to/config.json", encoding='utf-8')
config = json.load(configFile)
configFile.close()

csvData = open("/path/to/data.csv", "r")
xidLine = csvData.readline()

# Assume no commas, quotes or newlines in the XIDs
xids = xidLine.replace("\r", "").replace("\n", "").replace("\"", "").split(",")[1:]
#print(xids)

xidMap = {}
for dp in config["dataPoints"] :
xidMap[dp["xid"]] = dp

newFirstLine = "\"timestamp\""
for xid in xids :
newFirstLine += ",\"" + xidMap[xid]["deviceName"] + " - " + xidMap[xid]["name"] + "\""
newFirstLine += "\n"

#print(newFirstLine)
outputFile = open("/path/to/output.csv", "w+")
outputFile.writelines(newFirstLine)
outputFile.writelines(csvData.readlines())
outputFile.close()
csvData.close()


Definitely we see what you're saying and that you've added weight in the discussion that the available formats could be more flexible. I think the original XIDs as headers was done in anticipation of providing a multicolumn data upload, but no such feature exists currently.

I have created a git issue about it: https://github.com/infiniteautomation/ma-core-public/issues/1436

• phildunlap

That command will create the keystore file, yes. Had some weird formatting though, so I edited your post. You may want to use a different storepass than "changei" (or omit that argument to have it ask for that, first)

• phildunlap

I'm largely a librarian of previously answered questions at this point :D

• phildunlap

Hi sky_watcher,

You shouldn't have to worry about mounting the USB drive with fstab as Fox suggested - V3 Mango ES units have usbmount installed to facilitate the USB Utilities actions. It will mount the first USB stick plugged in at /media/usb0

After that, your choices are

1. Set Mango to backup directly to the USB drive instead of to the /opt/mango/backup folder. This is in the system settings
2. Set up a cron pattern as Fox suggested and add that to a crontab either via crontab -e to invoke the script or simply add the script /etc/cron.daily/ (and then you don't need to generate the cron pattern but you have less control).
3. Set a schedule in Mango and use event handlers to copy / move files as necessary.

• phildunlap

That's not the latest for Mango. https://github.com/infiniteautomation/BACnet4J

It doesn't seem to have 3.2.3 in the lib-opt folder, but if you read the RELEASE-NOTES you may see some pertinent stuff. You can get the 3.2.3 jar in the BACnet module.

• phildunlap

Is there any output to the browser's console? You should be able to right click the page and select 'Inspect Element' then navigate to the console.

• phildunlap

Hi Dan,

You're looking for the <session-timeout> tag in Mango/web/WEB-iNF/web.xml

i believe the value is in minutes.

• phildunlap

Hi Dave,

This is done through a meta point.

Something like....

var changeThreshhold = 5 //5 units per minute, let's say
var data = p.past(MINUTE, 5)
if( data.count == 0 ) {
//Handle no data in period condition, raise event?
return true;
} else if ( data.count == 1 ) {
//Handle only one piece of data in our range by getting another value
var lv = p.lastValue(1);
if ( lv == null ) //Only one data point, no cause for alarm. We may not need to check this
return false
return changeThreshhold > ( data.lastValue - lv.value )/((data.lastTime - lv.time)/60000);
} else {
return changeThreshhold > ( data.lastValue - data.firstValue )/((data.lastTime - data.firstTime)/60000);
}


Then having a state detector on the meta point checking for a "true" state. This isn't its own detector because the shrewd observer may see data sets where this logic is deeply flawed (specifically, data that isn't monotonic). For situations where your data varies in both directions, you may be more interested in changing the logic to sum the differences as you iterate the list, and alarm if you cross the threshhold, more like....

var data = p.pointValuesSince(new Date().getTime() - 5*60*1000) //Five minutes in milliseconds
if( data.length <= 1 ) //we have the same edge conditions for our range
return false
var sum = 0;
var changeThreshhold = 5; //so, this would mean that if any point in the period it is more than
for( var k = 0; k < data.length-1; k+=1 ) {
sum += (data[k+1].value - data[k].value);
if( sum < changeThreshhold || sum > changeThreshhold )
return true;
}
return false;


So, what it means to have changed over time can be funky depending on your data set. That second version should be equivalent to seeing if any values in a range are outside the acceptable rate of change... like,

var data = p.pointValuesSince(new Date().getTime() - 5*60*1000) //Five minutes in milliseconds
if( data.length <= 1 ) //we have the same edge conditions for our range
return false
var firstValue = data[0];
var changeThreshhold = 5; //so, this would mean that if any point in the period it is more than
for( var k = 1; k < data.length; k+=1 ) {
if( firstValue.value - data[k].value > changeThreshhold || firstValue.value - data[k].value < changeThreshhold )
return true;
}
return false;


But this could still be flawed. If data[0].value == 0, data[1].value == -3, and data[2].value == 3, then none of these detectors would alarm, even though we experienced a change of 6 at one point. One would expect the next run of the point will have data[0] == -3, but having uniform data in time is an assumption we shouldn't rest our logic on!

• phildunlap

Hi Mircea,

A "Broken pipe" is a general error for an abrupt disconnect of a TCP connection without warning by the other side.

it looks like it occurred while streaming data from the Json Data table. What page were you using when you observed this? Can you repeat it?

By itself a broken pipe isn't too significant but surely if you can reproduce it readily, then it definitely warrants investigation.

• phildunlap

Hi Gary,

I think the problem you're experiencing is probably that there was a bug preventing the HTTP Receiver from being created or saved through the API. I fixed this and released a new version of the module, 1.6.2.

If you've got that version, the easiest / best way to get the JSON model is by doing a GET for a data source you've made through the UI. But, here's the JSON for a an HTTP Receiver from my testing:

{
"xid": "httpReceiver2",
"name": "HTTP Receiver",
"enabled": false,
"modelType": "HTTP_RECEIVER",
"validationMessages": [],
"deviceIdWhiteList": [
"*"
],
"setPointUrl": "",
"ipWhiteList": [
"*.*.*.*"
],
"editPermission": "",
"purgeSettings": {
"override": false,
"frequency": {
"periods": 1,
"type": "YEARS"
}
},
"alarmLevels": {
"SET_POINT_FAILURE": "URGENT"
}
}


One must use the POST /rest/v1/data-sources to create data sources, and the PUT /rest/v1/data-sources/[XID] to update existing data sources.

Thanks for bringing that bug to our attention!

• phildunlap

Hi Mok Kiew,

I've never written any VBA and very little VB personally, but I think this stackoverflow thread does some general API type stuff, and it does contain some information about setting headers: http://stackoverflow.com/questions/19553476/how-to-make-rest-call-with-vba-in-excel

You'll want to do a GET to /rest/v1/login/admin or another user with the password in a header named "password" which will get you a response with a Set-Cookie header if successful. You'll have to pass that header's value as the "Cookie" header in subsequent requests.

You may need to include the XSRF-TOKEN portion of the Cookie under the X-Xsrf-Token header, as well. If this is required you'll have a 403 Forbidden response when using just the Cookie header.

Someone else may chime in with an example script. Good luck!

• phildunlap

Hi Jose,

I'm sure I had a clearer picture in my mind of what I would need to write you when I said that. But, here's a python script to generate JSON you can import on the import/export page. You'll need to edit the paths in the script if you want to use it, and it'll intake a CSV file like:

DP_123456,1003
DP_654321,1004


and output JSON for point links you can import. You may also need to modify the target point XID or other things like that. Here's the python:

import json
from StringIO import StringIO

#use double slashes for windows, i.e. "C:\\path\\to\\new-point-links.csv"
csvPointXids = open("/path/to/new-point-links.csv")
#I will treat this as though it's a CSV with two columns, 0 is source point XID, 1 is the code for the point link body, like 1002

basePointLink = """{
"xid":"PL_17-3-1_gen_%(loopCounter)d",
"sourcePointId":"%(sourceXid)s",
"targetPointId":"almnr",
"event":"CHANGE",
"logLevel":"NONE",
"disabled":false,
"script":"return getPrefix() + '%(outputNumber)s' + source.value",
"scriptPermissions":{
"customPermissions":"",
"dataPointReadPermissions":"superadmin",
"dataPointSetPermissions":"superadmin",
"dataSourcePermissions":"superadmin"
},
"writeAnnotation":false
}"""

#uncomment this if you have a header line to consume
#csvPointXids.readline()

outputConfig = {"pointLinks":[]}
loopCounter = 1
for line in csvPointXids.readlines() :
data = line.replace("\r","").replace("\n","").split(",")
if len(data) < 2 :
continue
pointJson = basePointLink % {"loopCounter": loopCounter, "sourceXid": data[0], "outputNumber": data[1]}
#print pointJson
outputConfig["pointLinks"].append( json.load( StringIO( pointJson ) ) )
loopCounter += 1

csvPointXids.close()

#You need to edit this output path as well. C:\\path\\to\\output.json
output = open("/path/to/output.json", "w+")
output.write( json.dumps( outputConfig, indent=4, sort_keys=False, separators=(",",":") ) )
output.close()


• phildunlap

Hi Jose,

I would bet that means there are no lines in your CSV or there is not a comma in the line separating the two fields. You can add a statement like

print line


to the for line in csvPointXids.readlines() : block before the if len(data). to see it print at the command line. If there are no lines in your file you will see no output. I think if you have the file path wrong in the initial open() it will error.

It looks like I got the separators backwards (should be separators=(",",":"), so I edited that to fix. I did test that the script generates JSON (but I didn't import the json)

• phildunlap

1. IP, hence the "IpNetwork" and "IpNetworkBuilder" instead of MstpNetwork
2. if( localDevice.getNetwork() instanceof IpNetwork ) return "It's an IP network!";
3. Create an MstpNetwork and pass it to new DefaultTransport( mstpNetwork );

• phildunlap

Hi Silvia,

It's a very good question! The answer is that as the UI is being redesigned, a fair bit of functionality hasn't migrated over yet. The "Data sources" menu item will link you back into the old UI, and you can navigate to the old system settings page using the icon bar. Or, you can navigate to the /system_settings.shtm URL.

If you find there's a legacy page you visit especially often, you can link to it using a custom link menu item on the "Edit menu" page, linked to the full URL of the page.

• phildunlap

Hello!

I think what you're looking for is probably...

<@subject>Hey - Stuff is happening with the automation system and I think you should know</@subject>

somewhere in your FTL. For a complete list of subject line options I'll have to refer you to the code a little, as the SubjectDirective class has some parameter options. Aliases override the default (but keep the Critical - and - id portions as you discovered probably), and the last SubjectDirective will probably have the final say.

https://github.com/infiniteautomation/ma-core-public/blob/main/Core/src/com/serotonin/m2m2/email/SubjectDirective.java

• phildunlap

If you wished to accumulate all values instead of just the logged averages, you could more simply have your script body be

return my.value + p.value;

The update event would still be start of minute to get an instant instead of the average. Or you could do a context update accumulator, but presumably there is a reason you're only wanting to accumulate the minute average, or I am misunderstanding.

• phildunlap

He made a great post a little while ago about how to include your own module definitions, if you find that you need to extend Mango in some way we haven't yet: https://forum.infiniteautomation.com/topic/2844/how-to-use-json-receiver-data-point/5