XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions...

10
XMLconfig XML 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

Transcript of XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions...

Page 1: XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions by Aleksey Khudyakov No changes concerning configuration.

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

Page 2: XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions by Aleksey Khudyakov No changes concerning configuration.

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]

Page 3: XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions by Aleksey Khudyakov No changes concerning configuration.

XML format: tagged text file

Essential: human readable, human editable

Example of a simple xml configuration file: LTUconfig.xml

Page 4: XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions by Aleksey Khudyakov No changes concerning configuration.

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>

Page 5: XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions by Aleksey Khudyakov No changes concerning configuration.

Operation scheme 1: C calling C++ API

Operation scheme 2: C++

Operation scheme 3: Java

Page 6: XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions by Aleksey Khudyakov No changes concerning configuration.

C++ xml-supporting library: boost

Page 7: XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions by Aleksey Khudyakov No changes concerning configuration.

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

Page 8: XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions by Aleksey Khudyakov No changes concerning configuration.

#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

Page 9: XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions by Aleksey Khudyakov No changes concerning configuration.

#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

Page 10: XMLconfig XML scheme for configuration data V.Černý Technical improvements thanks to suggestions by Aleksey Khudyakov No changes concerning configuration.

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.