From 7478dea03d5e25c3194f32fa0194edfdc52df208 Mon Sep 17 00:00:00 2001 From: rtrimana Date: Tue, 6 Aug 2019 15:33:26 -0700 Subject: [PATCH] Adding conflict variable in SpeechSynthesis device. --- SpeechSynthesis/SpeechSynthesis.groovy | 10 +++++++++- SpeechSynthesis/SpeechSynthesises.groovy | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/SpeechSynthesis/SpeechSynthesis.groovy b/SpeechSynthesis/SpeechSynthesis.groovy index acc2d80..fb91378 100644 --- a/SpeechSynthesis/SpeechSynthesis.groovy +++ b/SpeechSynthesis/SpeechSynthesis.groovy @@ -7,13 +7,15 @@ public class SpeechSynthesis { private String label private String displayName private int level + private boolean oneUser - SpeechSynthesis(String id, String label, String displayName, int level) { + SpeechSynthesis(String id, String label, String displayName, int level, boolean oneUser) { this.id = id this.label = label this.displayName = displayName this.level = level + this.oneUser = oneUser } def setLevel(int level) { @@ -25,5 +27,11 @@ public class SpeechSynthesis { def speak(String message) { println("Speech synthesis with id:$id, SPEAKING:\"$message\"!") + // As a conflict variable + if (oneUser) { + oneUser = false + } else { + oneUser = true + } } } diff --git a/SpeechSynthesis/SpeechSynthesises.groovy b/SpeechSynthesis/SpeechSynthesises.groovy index 50417cc..69601c4 100644 --- a/SpeechSynthesis/SpeechSynthesises.groovy +++ b/SpeechSynthesis/SpeechSynthesises.groovy @@ -12,6 +12,7 @@ public class SpeechSynthesises { private String label = "speechSynthesis0" private String displayName = "speechSynthesis0" private int level = 50 + private boolean oneUser = true SpeechSynthesises(Closure sendEvent, int deviceNumbers, boolean init) { @@ -21,10 +22,12 @@ public class SpeechSynthesises { if (init) { this.level = 50 + this.oneUser = true } else { this.level = 60 + this.oneUser = false } - speechSynthesises.add(new SpeechSynthesis(id, label, displayName, this.level)) + speechSynthesises.add(new SpeechSynthesis(id, label, displayName, this.level, this.oneUser)) } //Methods for closures @@ -56,6 +59,12 @@ public class SpeechSynthesises { def speak(String message) { speechSynthesises[0].speak(message) + // As a conflict variable + if (oneUser) { + oneUser = false + } else { + oneUser = true + } } def getAt(int ix) { -- 2.34.1