-/* if (!plants[plant]->set_element(host, port)) {
- return new HTTPResponse(HTTPMessage::INTERNAL_SERVER_ERROR,
- string("Error al crear la transmisión a de la planta '")
- + plant + "' a " + host + ":" + args[2] + ".");
- }*/
- return new HTTPResponse(HTTPMessage::OK);
+ bool open = true;
+ if ((value == "false") || (value == "0") || (value == "off")
+ || (value == "no")) {
+ open = false;
+ }
+ if (!plants[plant]->set_open(element, open)) {
+ return new HTTPResponse(HTTPMessage::CONFLICT,
+ string("<response desc=\"No se pudo cambiar el estado del elemento '") + element + "'.\" />");
+ }
+ return new HTTPResponse(HTTPMessage::OK,
+ string("<response desc=\"Se cambió el estado del elemento '") + element + "'.\" />");
+}
+
+HTTPResponse* Server::cmd_plant_set_frequency(const Command& command) {
+ if (command.get_args().size() < 2) {
+ return new HTTPResponse(HTTPMessage::CONFLICT,
+ "<response desc=\"Faltan argumentos.\" />");
+ }
+ Glib::Mutex::Lock lock(plants_mutex);
+ const string name = command.get_args()[0];
+ if (plants.find(name) == plants.end()) {
+ return new HTTPResponse(HTTPMessage::NOT_FOUND,
+ string("<response desc=\"No existe la planta ") + name + "\" />");
+ }
+ unsigned hz;
+ to(command.get_args()[1], hz);
+ plants[name]->set_frequency(hz);
+ return new HTTPResponse(HTTPMessage::OK,
+ string("<response desc=\"La planta '") + name + "' fue pausada.\" />");
+}
+
+HTTPResponse* Server::cmd_plant_start(const Command& command) {
+ if (!command.get_args().size()) {
+ return new HTTPResponse(HTTPMessage::CONFLICT,
+ "<response desc=\"Faltan argumentos.\" />");
+ }
+ Glib::Mutex::Lock lock(plants_mutex);
+ const string name = command.get_args()[0];
+ if (plants.find(name) == plants.end()) {
+ return new HTTPResponse(HTTPMessage::NOT_FOUND,
+ string("<response desc=\"No existe la planta ") + name + "\" />");
+ }
+ plants[name]->set_paused(false);
+ return new HTTPResponse(HTTPMessage::OK,
+ string("<response desc=\"La planta '") + name + "' fue reanudada.\" />");