XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions...
-
Upload
jane-beasley -
Category
Documents
-
view
212 -
download
0
Transcript of XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions...
XMLconfigXML scheme for configuration data
V.Černý
Technical improvements thanks to suggestions by Aleksey Khudyakov
• No changes concerning configuration data structs• All work possibly done by users on data structures can be used by the upgraded
scheme without any change• The xml-file structure unchanged• Just one line of code needed to read or write the xml file• Changes mainly internal, hidden from the user
Status of the project
• fully functional software• new installation/demo tarball available https
://twiki.cern.ch/twiki/bin/view/NA62/ConfigurationDataScheme• preprocessor is provided to generate everything needed except
of the struct containing the configuration data, which, of course, is to be provided by the user
Comments, suggestions for changes, requests for additional features
Mail to: [email protected]
XML format: tagged text file
Essential: human readable, human editable
Example of a simple xml configuration file: LTUconfig.xml
More structured xml file:
<node><version>100</version><idstring>
<readable_string>Demodetector</readable_string>
</idstring><channelcount>5</channelcount><pressure>3.1347002794315403e-317</pressure><channel>
<count>6</count><item>
<channel_no>1</channel_no>
<hvoltage>5001.1999999999998</hvoltage></item><item>
<channel_no>2</channel_no>
<hvoltage>5001.1999999999998</hvoltage></item><item>
<channel_no>3</channel_no>
<hvoltage>5001.1999999999998</hvoltage></item><item>
<channel_no>4</channel_no>
<hvoltage>5001.1999999999998</hvoltage></item><item>
<channel_no>5</channel_no>
<hvoltage>5001.1999999999998</hvoltage></item><item>
<channel_no>-6</channel_no>
<hvoltage>-1e+100</hvoltage>
</item></node>
Operation scheme 1: C calling C++ API
Operation scheme 2: C++
Operation scheme 3: Java
C++ xml-supporting library: boost
What the user should do
• Define your configuration data structure in a c include file• Run xmlconfig preprocessor to create the API c-include file
and other files needed for internal working• insert one line of c-code into your c-program to read the xml
configuration file data into your data structure• if you need output the data contained in your data structure
it is again just one line of c-code
#ifndef __Node_h__#define __Node_h__
#include "xmlstring.h"
#define Node_VERSION 100#define NCHANNELMAX 6 //maximal number of channels
typedef struct __Channel{ int channel_no; double hvoltage; } Channel ;
typedef struct __Node { int version; xmlchar idstring[XMLSTRING]; int channelcount; double pressure; Channel channel[NCHANNELMAX];}Node;
#endif /* __Node_h__ */
Data-structure-defining include file Node.h
<node><version>100</version><idstring>
<readable_string>Demodetector</readable_string>
</idstring><channelcount>5</channelcount><pressure>3.1347002794315403e-317</pressure><channel>
<count>6</count><item>
<channel_no>1</channel_no>
<hvoltage>5001.1999999999998</hvoltage></item><item>
<channel_no>2</channel_no>
<hvoltage>5001.1999999999998</hvoltage></item><item>
<channel_no>3</channel_no>
<hvoltage>5001.1999999999998</hvoltage></item><item>
<channel_no>4</channel_no>
<hvoltage>5001.1999999999998</hvoltage></item><item>
<channel_no>5</channel_no>
<hvoltage>5001.1999999999998</hvoltage></item><item>
<channel_no>-6</channel_no>
<hvoltage>-1e+100</hvoltage>
</item></node>
Corresponding xml file node.xml
#include "Node.h"#include "xmlconfig_Node.h" /* include file prepared by the xmlpp preprocessor */
int main(){
Node node; /* in realistic example you make the variable node global to be seen by any part of your code */ INXML_Node(node); /*serialization by macro defined in xmlconfig_Node.h*/ /* now the struct node contains all the data from the xml file and you can do anything needed */ return 0;}
#ifndef __Node_h__#define __Node_h__#include "xmlstring.h"#define Node_VERSION 100#define NCHANNELMAX 10 //maximal number of channelstypedef struct __Channel{ int channel_no; double hvoltage; } Channel ;typedef struct __Node { int version; xmlchar idstring[XMLSTRING]; int channelcount; double pressure; Channel channel[NCHANNELMAX];}Node;#endif /* __Node_h__ */
User’s tasks1. Write data-defining include file2. Write one line of input code
wherever needed
XMLconfig to be merged with Run Control?
What has been presented up to now is a standalone XMLconfig project. The xml files were expected to be designed and stored by particular subdetector groups.
This would be ok if the configuration data were fixed for a long time. It may happen, however, that the experimental node has to run in different configurations for, say, different triggers. So there would be more than one configuration xml file for the same node and a proper one should be loaded as needed.
Then the appropriate capabilities should be included in the run-control system.
New node states should be designed controlling which xml configuration is/should be loaded. Possibly a central database of xml configuration files should be maintained so that the run-control log-book would contain just links to the xml files.