How to use Subsets
Subsets allow to use one FESA class only for several (slightly) different devices such as magnet power supplies. From one base FESA class design several other design can be derived. Those subsets contain a smaller set of properties or properties with different data items.
FESA Class Design
The subsets are defined in the base FESA class design. Each subset contains a list of the properties. Per property a list of the per subset used value-items may be defined. The properties to be added to each subset may be difeined using a wizard available from the class design toolbar right above the XML (
). Properties used in a subset must allow partial setting. On the push of a toolbar button (
) the subset design files are created in the subfolder subsets. The file extension for FESA class design subset files is ".subset".
Example:
<equipment-model>
<interface>
<device-interface>...</device-interface>
<global-interface>...</global-interface>
<subset-interfaces>
<subset name="SubsetA">
<property property-name-ref="Init" id="_150826165418_0"/>
<property property-name-ref="Reset" id="_150826164917_0"/>
<property property-name-ref="Setting" id="_150826164917_1">
<items id="_150827102545_0"><value-item value-item-name-ref="aValueA"/></items>
</property>
<property property-name-ref="Power" id="_150826164917_2"/>
<property property-name-ref="Status" id="_150826164917_3"/>
<property property-name-ref="Acquisition" id="_150826164917_4">
<items id="_150827160951_0"><value-item value-item-name-ref="anAcqValueA"/></items>
</property>
<property property-name-ref="Version" id="_150826164917_5"/>
</subset>
<subset name="SubsetB">
<property property-name-ref="Init" id="_150826165603_0"/>
<property property-name-ref="Reset" id="_150826165609_0"/>
<property property-name-ref="Setting" id="_150826165617_0">
<items id="_150827160948_0"><value-item value-item-name-ref="aValueB"/></items>
</property>
<property property-name-ref="Power" id="_150826165618_0"/>
<property property-name-ref="Status" id="_150826165618_1"/>
<property property-name-ref="Acquisition" id="_150826165618_2">
<items id="_150827161007_0"><value-item value-item-name-ref="anAcqValueB"/></items>
</property>
<property property-name-ref="Version" id="_150826165618_3"/>
</subset>
</subset-interfaces>
...
</equipment-model>
The subsets are instantiated at runtime. Therefore a configuration item must be defined in the FESA class design:
<equipment-model>
...
<data>
<device-data>
<configuration>
<subset name="subset">
<array type="char">
<dim1>10</dim1>
</array>
<default>SubsetA</default>
</subset>
</configuration>
</equipment-model>
Source Code
In the C++ source code the subsets must be distuingished. The appropriate code must be selected at runtime depending on the current subset.
Example:
void SettingSetAction::execute(fesa::RequestEvent* pEvt, Device* pDev, SettingPropertyData& data)
{
MultiplexingContext *pCtxt = pEvt->getMultiplexingContext();
// treat data from subsets differently
std::vector<Device*> devices = SubsetServiceLocator_->getDeviceCollection();
for (unsigned int i=0;i<devices.size();i++)
{
try
{
Device *device = devices[i];
boost::shared_ptr<DeviceInstantiationData> instData = device->getInstantiationData();
std::string subset = instData->getSubset();
if( subset.compare("SubsetA") == 0 ) {
std::cout << instData->getDeviceName() << " Subset A" << std::endl;
if( data.isAValueBAvailable() ) {
bool b = data.getAValueB();
std::cout << " aValueA set to " << b << std::endl;
}
} else if( subset.compare("SubsetB") == 0 ) {
std::cout << instData->getDeviceName() << " Subset B" << std::endl;
if( data.isAValueBAvailable() ) {
int32_t i = data.getAValueB();
std::cout << " aValueB set to " << i << std::endl;
}
}
}
catch(const fesa::FesaException& exception)
{
LOG_ERROR_IF(logger, exception.getMessage());
}
}
}
FESA Instance File
In the instance file the configuration applies per device.
Example:
<device-instance name=" SubsetTestA " state="development">
<configuration>
<description value=""/>
...
<subset idref="">
<value>SubsetA</value>
</subset>
</configuration>
...
Database Usage
To avoid trouble with the database please don't insert the original FESA class/deploy-unit/instance design! Please insert the subset designs from the subfolder only using the toolbar button
(Export...).
FESA Deploy-Units and Instance Files
FESA deploy-units and instance files must be exported to the database too. For the usage of subsets special FESA deploy-unit and instance files have to be created for database export only. These files are also created on the push of a toolbar button (
) in subfolders named subset. The file extension for FESA deploy-unit subsets is ".deploysubset" and ".instancesubset" for FESA instance files. Please note that these files cannot be validated. To confirm XML wellformedness please use an external XML editor such as oxygen-xml.
Info
https://www-acc.gsi.de/wiki/FESA/FESA3PowerSuppliesConcept
Noteworthy
- If a subset is named like the orginal FESA class weird effects are to be expected. A name like the original FESA class should be avoided!