Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

Most import components in jBEAM allow you to define whether a channel/signal should be loaded completely, on standby or not at all. This can be set via the LoadStatus in the BasicChannelInfos of the channels, even before the import runs for the first time.

In this example script (Groovy/Java) we create a new DeweSoft file importer component, set the LoadStatus of two channels to complete and all other channels were set to be ignored.

The script uses the most general importer class so that it can be easily adapted to other importer types. e.g. jC.newComponent(jbComponentIF.MDF_FILE, false);

import com.AMS.jBEAM.AbstractDataFileImporter.BasicChannelInfoIF;
import com.AMS.jBEAM.AbstractDataFileImporter.LoadStatus;

AbstractDataFileImporter importer = (AbstractDataFileImporter) jC.newComponent(jbComponentIF.DEWESOFT_FILE, false);
importer.setImportFile(new File("path.to.file.dxd"));
List<String> namesOfChannelsToLoad = Arrays.asList("W-C", "I-B");
BasicChannelInfoIF[] allHeaders = importer.getBasicChannelInfos();
for(BasicChannelInfoIF channelHeader: allHeaders) {
	LoadStatus status = LoadStatus.Ignore;
	if(namesOfChannelsToLoad.contains(channelHeader.getResultItemName())) {
		status = LoadStatus.Complete;
	}
	channelHeader.setLoadStatus(status, true);
}
//jC.validateFramework(true);  //will actually run the import - this line is normally not needed

Opening the resulting import window shows that only the two named channels were actually loaded, the rest is set to ignored state.

image-20240913-150635.png

Deciding Based on Mapped Names

The above script decides on the LoadStatus based solely on the Result Name. This is sufficient in most cases. In more advanced cases, it may be the case, that this decision should be made based on the mapped name. But this channel name/unit mapping functionality is actually only carried out at the end of the import.

This can be achieved using non-public script functions:

//Initial to generate the mapping
importer.initializeChannelNameUnitMapping();

//Get mapped name for the individual channel header (let 2nd parameter unchanged)
String mappedName = importer.mapUnitAndGetTargetName(channelHeader, jbDataObjectIF.DOUBLE_CHANNEL);

With this information, the initial script (especially the if-condition at the end) can be extended.

  • No labels