summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichiel Schuurmans <michiel@codox.org>2018-12-17 21:13:03 +0100
committerMichiel Schuurmans <michiel@codox.org>2018-12-17 21:13:03 +0100
commit23c408b8fb6e0241bac7dc41d80efc7d5d7f0e59 (patch)
treefdce9d09d2a12140bfd1681b172d770d026fe552
parent433a40107b03b43837496b46e7c743f713714a53 (diff)
CleanupHEADmaster
-rw-r--r--CoCommand/Controllers/Logger.cs2
-rw-r--r--CoCommand/Controllers/SpeechController.cs36
-rw-r--r--CoCommand/Program.cs4
3 files changed, 33 insertions, 9 deletions
diff --git a/CoCommand/Controllers/Logger.cs b/CoCommand/Controllers/Logger.cs
index ed4307e..c316c05 100644
--- a/CoCommand/Controllers/Logger.cs
+++ b/CoCommand/Controllers/Logger.cs
@@ -19,7 +19,7 @@ namespace CoCommand.Controllers
private string _type;
private ConsoleColor _color;
private bool _file_lock = false;
- private bool _show_in_release = true;
+ public bool _show_in_release = true;
/* Public get/setters */
public ConsoleColor Color { get { return _color; } set { _color = value; } }
diff --git a/CoCommand/Controllers/SpeechController.cs b/CoCommand/Controllers/SpeechController.cs
index 537d13f..2b4d97e 100644
--- a/CoCommand/Controllers/SpeechController.cs
+++ b/CoCommand/Controllers/SpeechController.cs
@@ -15,14 +15,15 @@ namespace CoCommand.Controllers
private GrammarBuilder _grammarBuilder;
private Dictionary<String, ISpeechAction> _actions;
private Choices _choices;
- private List<String> _privateActions = new List<String>() { "state", "actions", "lights off", "lights on" };
- public SpeechController(bool init = true)
+ private List<String> _privateActions = new List<String>() { "state", "actions", "lights off", "lights on", "debug on", "debug off"};
+
+ public SpeechController(bool init = true, bool system = true)
{
if (init)
- Init();
+ Init(system);
}
- private void Init(String culture = "en-US")
+ private void Init(bool systemCallsEnabled, String culture = "en-US")
{
if (_engine != null)
return;
@@ -35,10 +36,15 @@ namespace CoCommand.Controllers
_choices = new Choices();
- foreach (var system in _privateActions)
- _choices.Add("system " + system);
+ if (systemCallsEnabled) {
+ foreach (var system in _privateActions)
+ _choices.Add("system " + system);
+ } else {
+ Logger.Info.WriteLine("[Speech] System calls are disabled!");
+ }
+
- _actions = new Dictionary<String, ISpeechAction>();
+ _actions = new Dictionary<String, ISpeechAction>();
_engine.SpeechRecognized += _engine_SpeechRecognized;
@@ -111,13 +117,28 @@ namespace CoCommand.Controllers
case "system lights on":
SystemLightsOn();
break;
+ case "system debug on":
+ ToggleDebug(true);
+ break;
+ case "system debug off":
+ ToggleDebug(false);
+ break;
}
}
+ private void ToggleDebug(bool enabled)
+ {
+ Logger.Debug._show_in_release = enabled;
+
+ Logger.Info.WriteLine("[Speech][System] Set debug enabled to {0}.", enabled);
+ }
+
private void PrintSystemState()
{
List<IAction> done = new List<IAction>();
+ Logger.Info.WriteLine("[System] Debug enabled is set to {0}.", Logger.Debug._show_in_release);
+
foreach (var action in _actions) {
if (done.Contains(action.Value))
continue;
@@ -146,6 +167,7 @@ namespace CoCommand.Controllers
}
}
}
+
private void SystemLightsOn()
{
Logger.Info.WriteLine("[Speech][System] Turning all ights on.");
diff --git a/CoCommand/Program.cs b/CoCommand/Program.cs
index 1b2deda..957f051 100644
--- a/CoCommand/Program.cs
+++ b/CoCommand/Program.cs
@@ -13,13 +13,15 @@ namespace CoCommand
{
static void Main(string[] args)
{
+ Logger.Info.WriteLine("Starting command by Michiel Schuurmans (2074068)");
+
List<IAction> actions = new List<IAction>();
actions.Add(new Door("backdoor"));
actions.Add(new Door("frontdoor"));
actions.Add(new Light("hallway"));
actions.Add(new Light("living room"));
- SpeechController speech = new SpeechController();
+ SpeechController speech = new SpeechController(true, true);
foreach (var action in actions) {
if (action.SupportedActions().HasFlag(ActionType.Speech))