Pencil-icon.png

Unknown macro: floating-toc

Import channels in StandBy mode and reload a specific channel

Edit

If you want to import multiple channels, it is possible to load it in standby mode. This means concretely that the metadata of the corresponding channels are loaded, but not the channel data itself. The channel data can then be loaded in different ways. The following example describes two of these different possibilities.

Import data

Edit

This script ensures that the data import is performed. During the import the channels are loaded in StandBy mode.

import org.asam.cea.Cea2Bus.Cea2BusIF;
import org.asam.cea.Cea2Items.Cea2ItemIF;

// import type for DIADEM import
int importType = jbComponentIF.DIADEM_FILE;
// no editor dialog of component
boolean withEditor = false;
// new DIADEN importer component
FileImport_Diadem diademImporter = (FileImport_Diadem)jC.newComponent (importType, withEditor);
// producer is not file name
diademImporter.setProducerNameIsFileName(false);
// sets name of component
diademImporter.setName("Diadem_Import");
// get DIADEM file
importFile = new File("D:\\data\\testskript\\Drive.dat");
// sets import file
diademImporter.setImportFile(importFile);
// set loadStatus for all channels to StandBy
for (AbstractDataFileImporter.BasicChannelInfoIF diadIF : diademImporter.getBasicChannelInfos()) {
 diadIF.setLoadStatus(AbstractDataFileImporter.LoadStatus.StandBy, true);
}
// validate framework to import file and get a valid jBEAM
// If parameter block is true, validation runs in main thread if operationMode is set to jbDataItemManagerIF.NOT_THREADED until the validation is finished
jC.validateFramework(true);

Option 1

Edit

This script shows you how to reload a specific channel from an importer, if only the name of the importer and the channel name is known. The main advantage of this variant is, that you can set the channel to StandBy again after reload it. This allows you to reload or hide channels when ever you want.

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

// name of the importer
importerName = "Diadem_Import";
// name of the channel, which should be change the loadStatus
channelName = "Zeit";
// get the file import for a diadem file
FileImport_Diadem importer = (FileImport_Diadem) jC.getComponentByName(importerName);
// go through all hannel headers
for (BasicChannelInfoIF channelInfo : importer.getBasicChannelInfos())
// compare the given channelName with all names of the channelInfos
if (channelName.equalsIgnoreCase(channelInfo.getName()))
// change loadStatus of the found channel
channelInfo.setLoadStatus(LoadStatus.Complete, true);
// set the channel header invalid to validate them it with the next validation
importer.invalidateHeader();
// validate framework to import file and get a valid jBEAM
// If parameter block is true, validation runs in main thread if operationMode is set to jbDataItemManagerIF.NOT_THREADED until the validation is finished
jC.validateFramework(true);

Option 2

This script also shows you how to reload a specific channel from an importer, if only the name of the importer and the channel name is known. The main disadvantage of this varaint ist, that you aren´t able to set the loadStatus of a channel to StandBy again. So you only be able to reload a specific channels sequently.

import com.AMS.jBEAM.jbProducerIF.ValueStorageMode;

// name of the importer
importerName = "Diadem_Import";
// name of the channel, which should be change the loadStatus
channelName = "Zeit";
// get the file import for a diadem file
FileImport_Diadem importer = (FileImport_Diadem) jC.getComponentByName(importerName);
// get the channel, which gets the result from the importer
AbstractNumericChannel channel = (AbstractNumericChannel) importer.getResultByName(channelName);
// array of dataObjects
jbDataObjectIF[] inputObjects = new jbDataObjectIF[1];
// set the channel to the array
inputObjects[0] = channel;
// add consumer to channel -> to get the channel reloaded
jP.setInputObjects(inputObjects);
// validate framework to import file and get a valid jBEAM
// If parameter block is true, validation runs in main thread if operationMode is set to jbDataItemManagerIF.NOT_THREADED until the validation is finished
jC.validateFramework(true);

Import channel from ODS Import

Because the ODS import components are not derived from the Fileimport component class structure, you need to call some different methods to select a specific channel from an ODS import component to load. Below is a snippet example of how to import a channel named "RPM" from an ODS import component called "Local ODS Data".

import com.AMS.jBEAM.AbstractDataFileImporter.LoadStatus;

// get ODS import component by name
jbProducerIF producer = jC.getComponentByName("Local ODS Data");
// get result channel to load from ODS import component
jbDataObjectIF resultItem = producer.getResultByName("RPM");
// set load status of result item to Complete
producer.setLoadStatus(resultItem, LoadStatus.Complete);
// run the import by validation of the bus
jC.validateFramework();
How To » How to collection for customization of jBEAM (using API or scripts) » Import channels in StandBy mode and reload a specific channel
Tags:

Copyright by Kistler Chemnitz GmbH 2021
XWiki Enterprise 4.4 - Documentation