X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=SpeechSynthesis%2FSpeechSynthesis.groovy;h=463a72ba2952934b73281a30be23d9524a6df525;hb=d0b538d93e64c63d2673796db08570953b57f947;hp=1f25d79b5c873edf53c060076b4281ea383c8c5c;hpb=2932def9bb947d617975235763f7338360f0e5a4;p=smartthings-infrastructure.git diff --git a/SpeechSynthesis/SpeechSynthesis.groovy b/SpeechSynthesis/SpeechSynthesis.groovy index 1f25d79..463a72b 100644 --- a/SpeechSynthesis/SpeechSynthesis.groovy +++ b/SpeechSynthesis/SpeechSynthesis.groovy @@ -1,37 +1,49 @@ //Create a class for speech synthesis package SpeechSynthesis -import Timer.SimulatedTimer +import SmartThing.SmartThing -public class SpeechSynthesis { - private String id - private String label - private String displayName - private int level - private boolean oneUser +public class SpeechSynthesis extends SmartThing { + // id, label, and display name of the device + StringBuilder id = new StringBuilder() + StringBuilder label = new StringBuilder() + StringBuilder displayName = new StringBuilder() + // Features with numberical values + MutableInteger currentLevel = new MutableInteger() + // Maps from features to values + HashMap deviceIntValuesMap = new HashMap() + SpeechSynthesis(Closure sendEvent, StringBuilder id, StringBuilder label, StringBuilder displayName, MutableInteger currentLevel) { + deviceIntValuesMap = deviceIntValueSmartThing + idSmartThing = id + labelSmartThing = label + displayNameSmartThing = displayName + sendEventSmartThings = sendEvent - SpeechSynthesis(String id, String label, String displayName, int level, boolean oneUser) { + // Initialization this.id = id this.label = label this.displayName = displayName - this.level = level - this.oneUser = oneUser + this.currentLevel = currentLevel + + deviceIntValuesMap.put("level", currentLevel) } - def setLevel(int level) { - if (level != this.level) { - println("The level of speech synthesis with id:$id is changed to $level") - this.level = level + // Methods to set values + def setLevel(int newValue) { + if (!currentLevel.getValue().equals(newValue)) { + String tmpID = id.toString() + currentLevel.setValue(newValue) + println("The level of speech synthesis with id:$tmpID is changed to $currentLevel") } } def speak(String message) { - println("Speech synthesis with id:$id, SPEAKING:\"$message\"!") - // As a conflict variable - if (oneUser) { - this.oneUser = false - } else { - this.oneUser = true - } + String tmpID = id.toString() + println("Speech synthesis with id:$tmpID, SPEAKING:\"$message\"!") + } + + // Methods to return values + def getCurrentLevel() { + return currentLevel.getValue() } }