public void nextStates() { switch (state) { case IDLE: if (currentCmd != null) state = BUSY; break; case BUSY: if (Constants.CMD_CLOSE.equalsIgnoreCase(currentCmd) || Constants.CMD_CALL.equalsIgnoreCase(currentCmd)) { state = CONFIRM; contact = nlu.getContact(); confirm(currentCmd); } else if (Constants.CMD_SMS.equalsIgnoreCase(currentCmd)) { state = OPTION; option = 0; String msg = ""; int j = 0; contact = nlu.getContact(); for (int i = 0; i < sms_options.length; i++) { j = i + 1; msg += j + ", " + sms_options[i] + ".\n"; } toSay = "Please choose an option." + "\n" + (msg); // toSay = "Please choose an option"; } else { state = RUN; } break; case CONFIRM: // System.out.println("Confirm branch: \nState " + state + "\nAnswer " + answer); if ("yes".equalsIgnoreCase(answer)) { state = RUN; runCmd(currentCmd); } else if ("no".equalsIgnoreCase(answer)) { cancelCmd(); } break; case OPTION: if (option != 0) { state = CONFIRM; contact = nlu.getContact(); message = sms_options[option - 1]; confirm(currentCmd); } break; case RUN: runCmd(currentCmd); break; } // System.out.println("Current state :" + state); }
private void runCmd(String currentCmd) { // TODO Auto-generated method stub if (Constants.CMD_CALL.equalsIgnoreCase(currentCmd)) { toSay = "calling " + contact; } else if (Constants.CMD_SMS.equalsIgnoreCase(currentCmd)) { toSay = "sending " + message + " to " + contact; } else if (Constants.CMD_REPEAT.equalsIgnoreCase(currentCmd)) { toSay = lastUtterance; } else if (Constants.CMD_TIME.equalsIgnoreCase(currentCmd)) { // toSay = "telling the the time"; toSay = mUtil.getTime(); } else if ("close".equalsIgnoreCase(currentCmd)) { toSay = "closing the application"; } else if (Constants.CMD_NAME.equalsIgnoreCase(currentCmd)) { toSay = "my name is mimic"; } else if (Constants.CMD_DATE.equalsIgnoreCase(currentCmd)) { // toSay = "telling the date "; toSay = mUtil.getDate(); } else if (Constants.CMD_WEATHER.equalsIgnoreCase(currentCmd)) { toSay = "telling the weather "; } else if (Constants.CMD_LOCATION.equalsIgnoreCase(currentCmd)) { toSay = "telling the location "; } else if (Constants.CMD_MAP.equalsIgnoreCase(currentCmd)) { toSay = "showing the map "; } else if (Constants.CMD_WAKEUP.equalsIgnoreCase(currentCmd)) { toSay = "what can I do for you? "; } initialise(); }
private void confirm(String currentCmd) { // TODO Auto-generated method stub if (Constants.CMD_CALL.equalsIgnoreCase(currentCmd)) { if (contact != null) { toSay = "Do you want to call " + contact + ". Say Yes or No"; } else { toSay = "Please provide the contact to be called"; // start the command incomplete timer } } else if (Constants.CMD_CLOSE.equalsIgnoreCase(currentCmd)) { toSay = "Do you want to close the application. Say Yes or No"; } else if (Constants.CMD_SMS.equalsIgnoreCase(currentCmd)) { String sms = "Do you want to send the message"; sms += " " + message + " to " + contact; sms += ". Say Yes or No"; toSay = sms; } }