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.
Best posts made by phildunlap
-
RE: kWh Consumption
-
RE: External IP
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)
-
RE: ma-point-value: number formatting
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}}
-
RE: Show Data Point Name as Column in Watch List CSV Download
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
-
RE: Cron pattern to copy over a USB drive
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
- Set Mango to backup directly to the USB drive instead of to the /opt/mango/backup folder. This is in the system settings
- 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). - Set a schedule in Mango and use event handlers to copy / move files as necessary.
-
RE: Get Current and Historic Point Values Through REST API
I'm largely a librarian of previously answered questions at this point :D
-
RE: How to setup and event on rate of change?
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!
-
RE: Mango in active-passive cluster
Hi jae, welcome to the forum!
The last time a question similar was posed was here: https://forum.infiniteautomation.com/topic/3910/mango-on-aws-with-ha-architecture and the answer hasn't changed that much.
-
RE: How to access Rest API Login Endpoint using VBA
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!
-
RE: Internet Explorer Public View icons
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.
Latest posts made by phildunlap
-
RE: Bacnet Event registration
Hi Andreas, welcome to the forum!
I think, I have to set the localDevice as a receifer in the notifications class on the the remote device.
Yes, this is correct. You need to add your device as a destination in the recipientsList property on a notificationClass object. Then, on the object you wish to use that notification class to handle cases of intrinsic reporting, you set the notificationClass property on the object doing the intrinsic reporting to the object instance number of the notificationClass object you wish to use.
You may need to try a CreateObjectRequest if the remote device doesn't have any existing notification classes.
-
RE: Installation stops at 40 percent
Hi N8Hart, welcome to the forum!
The batch file can be terminated normally and I don't see any errors in the log file
The batch file should open a CMD window which stays open until closed (a hard kill to the process running in it) or Ctrl+C to tell Mango to shut down. If it opens and closes quickly there was some error during startup.
To check what the error is, if it's going to stderr and not into the log file, you can open a command prompt and
cd C:\Path\To\Mango\bin ma-start.bat
and then it will not close the window when it experiences the error and you can post the output or search if it has already been answered.
-
RE: SNMP Publisher / Agent
@craigweb said in SNMP Publisher / Agent:
Hi @ricardo
Mango only has 4 publishers: BACnet, Modbus, Mango PTCP and an HTTP publisher
Also Twilio and Pachube.
-
RE: SNMP Publisher / Agent
Hi Ricardo,
No, Mango does not currently have an SNMP publisher.
Can Mango send SNMP traps as an Event Handler type?
Yes, but it isn't really set up to make such a thing easy. I think we'd best to have a running SNMP data source and use some reflection, something like this, in a Set Point Event Handler,
//untested var snmpDataSourceId = com.serotonin.m2m2.db.dao.DataPointDao.instance.getIdByXid("DS_XID_HERE"); var snmpDataSourceRT = com.serotonin.m2m2.Common.runtimeManager.getRunningDataSource( snmpDataSourceId ); if( snmpDataSourceRT !== null ) { var field = snmpDataSourceRT.getClass().getDeclearedField("snmp"); field.setAccessible( true ); var snmp = field.get( snmpDataSourceRT ); //get the SNMP version information field = snmpDataSourceRT.getClass().getDeclearedField("writeVersion"); field.setAccessible( true ); var writeVersion = field.get( snmpDataSourceRT ); //get the target to send it to var target = writeVersion.getTarget( "192.168.0.123", 162, 1, 5000 ); //host, port, retries, timeout //construct the PDU var pdu = writeVersion.createPDU(); if( target.getVersion === org.snmp4j.mp.SnmpConstants.version1 ) { pdu.setType( org.snmp4j.PDU.V1TRAP ); pdu.setEnterprise( new org.snmp4j.smi.OID( "1.1.1.1.1.1.1") ); //probably a clever way to get the OID from the event pdu.setGenericTrap( org.snmp4j.PDUv1.ENTERPRISE_SPECIFIC ); pdu.setSpecificTrap( 1 ); //looks like this may need to cycle in value 1-5 pdu.setAgentAddress( new org.snmp4j.smi.IpAddress( "127.0.0.1" )); //Mango's IP on the network here snmp.send( pdu, target ); } else if ( target.getVersion === org.snmp4j.mp.SnmpConstants.version2c ) { throw "not yet implemented!"; } else if ( target.getVersion === org.snmp4j.mp.SnmpConstants.version3 ) { throw "not yet implemented!"; } else throw "unknown snmp version!"; } else { throw "Data source not found to send trap for event: " + event; } return UNCHANGED; //don't set from the set point handler
I would be somewhat surprised if this works, but it shouldn't be too far from the way to do it. I consulted this site for the V1 implementation, and there is also a v2c example: https://www.jitendrazaa.com/blog/java/snmp/generating-trap-in-snmp-using-snmp4j/
So, possible, but will probably take some trial and error to figure out.
-
RE: ES version bacnet module 3.6.0 issue compare ver. 3.5.2
Hi techalton,
This is the git issue it is being tracked in: https://github.com/infiniteautomation/BACnet4J/issues/43
Michel has responded and it looks like Terry has coded a prospective solution to this specific issue, but that it needs review / assistance to generalize the relaxing of the type checking in reading properties from other devices.
-
RE: /v1/point-values PUT not updating in datasources other than virtual
No worries, the data file data source probably requires the most Java knowledge outside of writing scripts that invoke the code. Even then, the scripts get to benefit from JavaScripts willingness to store any ole' type into a variable, where everything needs to be properly typed and declared in the data file classes. Tricky when there are but few examples and it's closed source!
I would guess there was an informative event raised about a failure to instantiate the poll class, but I couldn't say.
-
RE: /v1/point-values PUT not updating in datasources other than virtual
The issue with the poll class it will not work as an abstract class, it must be able to be instantiated so that it may be run. I just tested and was able to set values to data file points when my poll class looked like this:
import com.infiniteautomation.datafilesource.rt.AbstractPollClass; import com.infiniteautomation.datafilesource.rt.PollClassInvoker; import com.serotonin.m2m2.rt.dataImage.DataPointRT; import com.serotonin.m2m2.rt.dataImage.PointValueTime; import com.serotonin.m2m2.rt.dataImage.SetPointSource; public class PutPollClass extends AbstractPollClass { @Override public void run(long time, PollClassInvoker invoker, String[] arguments) {} @Override public boolean setPointValueImpl(DataPointRT dataPoint, PointValueTime valueTime,SetPointSource source) { return true; } }
Remember, you'll need to recompile the class, and then restart the data source for the modifications to be applied.
-
RE: Upgrade to 3.6.4 core module does not work from upgrades page. installing?
Hi jleblancmango,
How did you set up your path? Can you set the JAVA_HOME environment variable to your JDK directory? Either that, or you'd need to make sure the jar.exe file is in one of the locations defined by the "Path" environment variable for the user that is launching Mango.
-
RE: /v1/point-values PUT not updating in datasources other than virtual
Hi Fox,
Can you post your poll class? What is the logging type of your points?
The PUT endpoint behaves like a set through Mango. If the user your PUT'ing the value through the API has permission to set the point, you should see that get to the poll class's method I said you had to implement:
public boolean setPointValueImpl(DataPointRT dataPoint, PointValueTime valueTime, SetPointSource source)
You could do something in this method to prove to yourself it got there. If that returns true, then it will call setPointValue on the DataPointRT and that has some subtleties from logging type.
EDIT: Alternatively, how hard would it be to convert the Data File datasources into Virtual datasources? If I could manage that, it would save a lot of fluff.
You would have to do some work to ensure the id to xid set was the same (i.e. SELECT id, xid FROM dataPoints; and save that to make a bunch of update statements for the modified points. Here's an old python script that will convert all data source and data points in a JSON file to virtual sources and points (you may want to make them no change point locators): https://github.com/infiniteautomation/ma-devtools/blob/master/PythonUtilities/Simulation/virtualizeDataSources.py
You would have to delete the old, import the new, and then run the SQL update statements to set the ID based on the XID such that old data wasn't lost. So, possible by maybe not trivial.
-
RE: Modbus Serial Datasource fixed length string issue
Hi Thomas, thanks for bringing this to our attention!
I have created a git issue for this in the Modbus module's repo.