Reflection use for datasource host
-
Hy, I've several modbus datasources each one with the target host ip
it is possible to assign this IP to a virtual datapoint like this:
and use it to select the host in the modbus datasource definition?
instead seems to be possible to use it directly in a scripting data source?
var response = com.serotonin.m2m2.rt.maint.work.ProcessWorkItem.executeProcessCommand("/home/solergy/./tracker_upgrade_IP.sh S07E-MCU-3AX.bin upload " + STM32_IP.value , 300);
and also,
there's a way to know the MANGO path inside a script?Thanks,
Antonio -
Hi Antonio,
You can modify the configuration of a Mango instance on the fly from scripts using the JsonEmport script utility, which can allow you to work with JSON as you would via the Configuration Import/Export page.
See this help page https://help.infiniteautomation.com/about-mango-java-script
And here's an example from the forum changing theu pdate period of a data source: https://forum.infiniteautomation.com/topic/3288/alter-data-source-update-time-via-event-handlerYou could adapt that to use the virtual point's .value to update the host of the Modbus IP data source in question. Would that work for what you're asking?
there's a way to know the MANGO path inside a script?
You mean the directory that it is installed to? Yes,
var pathToMango = com.serotonin.m2m2.Common.MA_HOME_PATH; //java.nio.file.Path, get a string via .toString()
-
Thanks,
JsonEmport seems to be not available in mango 2.8.8
but it is not a problem because instead is available the following:
var hostIP = (com.serotonin.m2m2.db.dao.DataSourceDao.instance.getByXid("FML01-main")).host
Concerning instead MA_HOME seems to be undefined,
In your documentation is stated somewhere that it is necessary to create this environment variable?
Actually is not defined in my system but it seems it is not a problem, everything else seems ok.
Thanks -
Concerning instead MA_HOME seems to be undefined,
Best to include that you're using 2.8 in every first post or I'll assume you've apprehended the value added and upgraded.
-
Thanks,
MA_HOME is defined but not the value of MA_HOME,
path: undefinedI follow this during installation:
https://help.infiniteautomation.com/linux-installation
and it is not mentionedMA_HOME is a simple environment variable?
Thanks,
Antonio -
No, it's a reference to the variable in Java directly.