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 ...@@ -92,7 +92,7 @@ namespace AutoTx
} }
/// <summary> /// <summary>
/// Loads the initial settings. /// Load the initial settings.
/// </summary> /// </summary>
private void LoadSettings() { private void LoadSettings() {
try { try {
...@@ -102,7 +102,8 @@ namespace AutoTx ...@@ -102,7 +102,8 @@ namespace AutoTx
_configPath = Path.Combine(baseDir, "configuration.xml"); _configPath = Path.Combine(baseDir, "configuration.xml");
_statusPath = Path.Combine(baseDir, "status.xml"); _statusPath = Path.Combine(baseDir, "status.xml");
LoadConfigStatusXml(); LoadConfigXml();
LoadStatusXml();
_roboCommand = new RoboCommand(); _roboCommand = new RoboCommand();
} }
...@@ -116,10 +117,11 @@ namespace AutoTx ...@@ -116,10 +117,11 @@ namespace AutoTx
CheckConfiguration(); CheckConfiguration();
} }
/// <summary> /// <summary>
/// Loads the configuration and status xml files. /// Load the configuration xml file.
/// </summary> /// </summary>
private void LoadConfigStatusXml() { private void LoadConfigXml() {
try { try {
_config = ServiceConfig.Deserialize(_configPath); _config = ServiceConfig.Deserialize(_configPath);
writeLogDebug("Loaded config from " + _configPath); writeLogDebug("Loaded config from " + _configPath);
...@@ -129,17 +131,27 @@ namespace AutoTx ...@@ -129,17 +131,27 @@ namespace AutoTx
// this should terminate the service process: // this should terminate the service process:
throw new Exception("Error loading config."); throw new Exception("Error loading config.");
} }
}
/// <summary>
/// Load the status xml file.
/// </summary>
private void LoadStatusXml() {
try { try {
writeLogDebug("Trying to load status from " + _statusPath);
_status = ServiceStatus.Deserialize(_statusPath); _status = ServiceStatus.Deserialize(_statusPath);
writeLogDebug("Loaded status from " + _statusPath); writeLogDebug("Loaded status from " + _statusPath);
} }
catch (Exception ex) { 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: // this should terminate the service process:
throw new Exception("Error loading status."); throw new Exception("Error loading status.");
} }
} }
/// <summary> /// <summary>
/// Check if loaded configuration is valid, print a summary to the log. /// Check if loaded configuration is valid, print a summary to the log.
/// </summary> /// </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