How to-icon.png

How to modify units globally?


DAQ can export values as unit gravity, instead of m/s^2. Then write "g" as unit in data files. After loading data files in jBEAM, this "g" is handled as weight gram, not gravity. Is there an easy way to change this "g" to "grav" for hundreds of channels in jBEAM?

This script demonstrates two variants to group channels (e.g. for later simultaneous calculation) using the GroupOfChannels data object.


There are two possible ways to solve that issue in jBEAM by scripting, both work only with no weight g in project:

javax.units.UnitFormat.getStandardInstance().alias(NonSI.G, "g");

This Script manipulates the unit service in the running jBEAM-instance, that means the script has to ran again after next jBEAM-start. In this case every g in the running project is interpreted as grav. A possible way to secure the script execution with every jBEAM-start is to define it by start parameters ( instead of starting manually.

List<AbstractNumericObject> numericObjects = jD.getDataObjects(AbstractNumericObject.class);
Set<jbDataObjectIF> numericObjectsDeep = new LinkedHashSet<jbDataObjectIF>();
for (AbstractNumericObject numericObject : numericObjects) {
if (numericObject instanceof jBGroupOfDataObjectsIF) {
numericObjectsDeep.addAll(((jBGroupOfDataObjectsIF) numericObject).getGroupedItems());
for (jbDataObjectIF numericObject : numericObjectsDeep) {
if (numericObject != null && "g".equals(numericObject.getUnit()))

This second script overwrites the units in channels and has to run again after modifying importers.

How To » How to collection for customization of jBEAM (using API or scripts) » How to modify units for multiple channels

Copyright by Kistler Chemnitz GmbH 2021
XWiki Enterprise 4.4 - Documentation