Skip to content
Snippets Groups Projects
Commit 9585edf8 authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Split loading of config and status into separate methods.

parent 17c58ddb
No related branches found
No related tags found
No related merge requests found
......@@ -92,7 +92,7 @@ namespace AutoTx
}
/// <summary>
/// Loads the initial settings.
/// Load the initial settings.
/// </summary>
private void LoadSettings() {
try {
......@@ -102,7 +102,8 @@ namespace AutoTx
_configPath = Path.Combine(baseDir, "configuration.xml");
_statusPath = Path.Combine(baseDir, "status.xml");
LoadConfigStatusXml();
LoadConfigXml();
LoadStatusXml();
_roboCommand = new RoboCommand();
}
......@@ -116,10 +117,11 @@ namespace AutoTx
CheckConfiguration();
}
/// <summary>
/// Loads the configuration and status xml files.
/// Load the configuration xml file.
/// </summary>
private void LoadConfigStatusXml() {
private void LoadConfigXml() {
try {
_config = ServiceConfig.Deserialize(_configPath);
writeLogDebug("Loaded config from " + _configPath);
......@@ -129,17 +131,27 @@ namespace AutoTx
// this should terminate the service process:
throw new Exception("Error loading config.");
}
}
/// <summary>
/// Load the status xml file.
/// </summary>
private void LoadStatusXml() {
try {
writeLogDebug("Trying to load status from " + _statusPath);
_status = ServiceStatus.Deserialize(_statusPath);
writeLogDebug("Loaded status from " + _statusPath);
}
catch (Exception ex) {
writeLog("Error loading status XML: " + ex.Message, true);
writeLog("Error loading status XML from [" + _statusPath + "]: "
+ ex.Message + "\n" + ex.StackTrace, true);
// this should terminate the service process:
throw new Exception("Error loading status.");
}
}
/// <summary>
/// Check if loaded configuration is valid, print a summary to the log.
/// </summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment