
ControllerBox directs electromechanical equipment in restaurants to display information.
Dependencies: TextLCD MbedJSONValue libMotiv picojson mbed-rtos mbed
Fork of Mbed_MotiVControllerBox by
Diff: library/Controller.cpp
- Revision:
- 3:21c8adb97c8f
- Parent:
- 2:ad4509a9d051
- Child:
- 4:8155d4d6a193
--- a/library/Controller.cpp Tue Dec 02 20:51:18 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -#include <string> -#include <stdlib.h> -#include "TextLCD.h" -#include "Controller.h" -#include "Device.h" -#include "Table.h" -#include "Flower.h" -//#include "MotiVAPI.h" - -//Test endpoint: http://demo.motiv.jvanbaarsen.com/demo/test -using namespace std; - -Controller::Controller(TextLCD *lcd): - status(WAITING) -{ - this->lcd = lcd; - //setStatus(WAITING); -// _mapi = new MotiVAPI("http://demo.motiv.jvanbaarsen.com/demo/test"); - displayStatus(); -// devices.push_back(new <Device>Flower(1)); -// devices.append(new Flower(2)); -// devices.append(new Flower(3)); - -// tables.append(new Table(1)); -// tables.append(new Table(2)); -// tables.append(new Table(3)); - - flower = new Flower(1); - commandList.push_back(flower->makeCommand(flower->fRESET, 0)); - commandList.push_back(flower->makeCommand(flower->fPETAL_SPD, 50)); - commandList.push_back(flower->makeCommand(flower->fPETAL_POS, 50)); - commandList.push_back(flower->makeCommand(flower->fDEMO1, 1)); - printDesc(commandList[1].cmd); -} - -void Controller::printDesc(int c) -{ - string desc = flower->getCommandDesc(c); - lcdWriteLine(2, desc); -} - -Controller::cStatus Controller::getStatus() -{ - return this->status; -} - -string Controller::statusString() -{ - switch(status) { - case READY: - return "ready"; - - case WAITING: - return "waiting"; - - case BUSY: - return "busy"; - - case ERROR: - return "error"; - - case INIT: - return "intializing"; - - default: - return "unknown"; - } -} - -void Controller::setStatus(cStatus status) -{ - this->status = status; - displayStatus(); -} - -void Controller::displayStatus() -{ - this->lcd->locate(0,0); - this->lcd->clearLine(); - this->lcd->locate(0,0); - this->lcd->printf("Status: %s", statusString()); -} - - -void Controller::lcdWriteLine(int row, string str) -{ - this->lcd->locate(0,row); - this->lcd->clearLine(); - this->lcd->locate(0,row); - this->lcd->printf("%s", str); -} - -void Controller::nextCommand() -{ - std::vector<Device::mCommand>::iterator it; - it = commandList.begin(); - it = commandList.insert(it, commandList.back()); - it = commandList.begin(); - commandList.pop_back(); - it = commandList.begin(); - Flower::mCommand command = *it; - printDesc(command.cmd); -} - -void Controller::prevCommand() -{ - - } - -void Controller::sendCommandDem() -{ - - } - \ No newline at end of file