OverrideConfig.cc
Go to the documentation of this file.
1 #include <sstream>
2 
3 #include "OverrideConfig.h"
4 #include <utl/ErrorLogger.h>
5 #include <utl/Reader.h>
6 
7 #include <evt/Event.h>
8 
9 #include <det/Detector.h>
10 #include <fdet/FDetector.h>
11 #include <fdet/Eye.h>
12 #include <fdet/Telescope.h>
13 
14 #include <sdet/SDetector.h>
15 #include <sdet/Station.h>
16 
17 #include <fwk/CentralConfig.h>
18 
19 #include <atm/AttenuationResult.h>
20 #include <atm/ScatteringResult.h>
21 
22 #include <utl/TimeStamp.h>
23 #include <utl/UTCDateTime.h>
24 #include <utl/Point.h>
25 #include <utl/UTMPoint.h>
26 #include <utl/ReferenceEllipsoid.h>
27 #include <fwk/CoordinateSystemRegistry.h>
28 
29 #include <atm/MonthlyAvgDBProfileModel.h>
30 
31 using namespace std;
32 using namespace utl;
33 using namespace fwk;
34 using namespace det;
35 using namespace fdet;
36 using namespace atm;
37 using namespace OverrideConfigNS;
38 
39 
40 OverrideConfig::OverrideConfig()
41 {
42 }
43 
44 
45 OverrideConfig::~OverrideConfig()
46 {
47 }
48 
49 
52 {
53  INFO("OverrideConfig::Init()");
54  return eSuccess;
55 }
56 
57 
59 OverrideConfig::Run(evt::Event& event)
60 {
61  INFO("OverrideConfig::Run()");
62 
63  // Set some time for the detector description
64  //
65  Detector::GetInstance().Update(UTCDateTime(2005,1,1,0,0).GetTimeStamp());
66 
67  // Overriding an entire configuration file
68  // =======================================
69  //
70  // In the bootstrap file in this directory, note the
71  // configLink with id = SStationListXMLManager.
72  // This instructs the CentralConfig to override
73  // the default configuration file for the SStationListXMLManager
74  // with the configuration file in this directory. In this example,
75  // we replace the station list with a list containing
76  // a single station called "My Station". The code below just verifies that
77  // the override worked.
78  //
79  string newName = Detector::GetInstance().GetSDetector().GetStation(1).GetName();
80  cout << "new name for station 1 = " << newName << endl;
81 
82  // Overriding a parameter in a configuration file by
83  // identifying the configLink and the parameter you
84  // want to change in your bootstrap file.
85  // =====================================================
86  //
87  // In the boostrap file in this directory, notice the
88  // XML beneath the <parameterOverrides> tag. XML contained within
89  // this tag can be used to instruct the CentralConfig to override
90  // data in one or more configuration files.
91  // Values you wish to override are specified by providing the
92  // entire XML hierarchy, starting from the top branch of the
93  // configLink whose contents you want to modify, down
94  // to the specific parameter(s) you want to override.
95  // In the example in this directory, we override the altitude of
96  // eye 3 (Loma Amarilla) in the default FTelescopeListXMLManager
97  // configuration file. The original value was 1400 m, and
98  // in the bootstrap we set it to 1500. The code below just
99  // verifies that the override worked.
100 
101  // Get the new altitude for a telescope in eye 3 from the Detector
102  // (note we use UTM coordinates, since we want to see the actual height
103  // we wrote in the telescope list, in which coordinates are specified
104  // in UTM.)
105  //
106 
107  UTMPoint telPointUTM = UTMPoint(Detector::GetInstance().GetFDetector().
108  GetEye("Loma Amarilla").GetTelescope(1).
109  GetPosition(),
110  ReferenceEllipsoid::GetEllipsoidIDFromString("WGS84"));
111  cout << "New height for Loma Amarilla (Detector) = "
112  << telPointUTM.GetHeight()/meter << " meters" << endl;
113 
114  // Get the same configuration data directly from the CentralConfig
115  //
116  Branch telB = CentralConfig::GetInstance()->GetTopBranch("FTelescopeListXMLManager");
117  double newHeightCC;
118  telB.GetChild("eye", "id=3").GetChild("altitude").GetData(newHeightCC);
119  cout << "New height for Loma Amarilla (CentralConfig) = "
120  << newHeightCC/meter << " meters." << endl;
121 
122  return eSuccess;
123 }
124 
125 
127 OverrideConfig::Finish()
128 {
129  INFO("OverrideConfig::Finish()");
130  return eSuccess;
131 }
Branch GetTopBranch() const
Definition: Branch.cc:63
Class to hold and convert a point in geodetic coordinates.
Definition: UTMPoint.h:40
const double meter
Definition: GalacticUnits.h:29
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
Class representing a document branch.
Definition: Branch.h:107
double GetHeight() const
Get the height.
Definition: UTMPoint.h:212
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60

, generated on Tue Sep 26 2023.