diff options
| author | Comment <tim@gray.(none)> | 2013-03-11 15:28:10 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2013-03-11 15:28:10 +0000 |
| commit | e0b956174a509b2fb3698383017a264e92665347 (patch) | |
| tree | 8f73ca05cf500a935390fcc33a9fe22e6a1f54f0 | |
| parent | d1ad9a5c002aa4fafceb8f9740e37238e404177d (diff) | |
manual sID PUT
| -rw-r--r-- | rotord/rotor.cpp | 2 | ||||
| -rwxr-xr-x | rotord/rotor.h | 14 | ||||
| -rwxr-xr-x | rotord/rotord.cpp | 21 |
3 files changed, 29 insertions, 8 deletions
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index c0b9fc5..7f22a5f 100644 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -1,4 +1,5 @@ #include "rotor.h" +#include <math.h> //float equality bool fequal(const float u,const float v){ @@ -56,7 +57,6 @@ bool Signal_output::render(const float duration, const float framerate,string &x float v=0.0f; for (float f=0.0f;f<duration;f+=step) { float u=get_output(f); - cerr << "Rotor: Signal_output got " << u << "as output" << endl; if (!fequal(u,v)) { xml_out+=("<signal time='"+ofToString(f)+"'>"+ofToString(u)+"</signal>\n"); v=u; diff --git a/rotord/rotor.h b/rotord/rotor.h index 605ae67..96db4f7 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -140,13 +140,16 @@ namespace Rotor { }; class Signal_node: public Node{ public: - float get_output(const float &time) { //default is to pass through first input, if disconnected returns 0 + virtual float get_output(const float &time) {}; + + /*{ //default is to pass through first input, if disconnected returns 0 cerr << "getting output for " << type << "," << ID << endl; if (inputs.size()) { if (inputs[0]->connection) return ((Signal_node*)(inputs[0]->connection))->get_output(time); } return 0.0f; } + */ }; class Image_node: public Node{ public: @@ -188,7 +191,8 @@ namespace Rotor { Is_new_integer* clone(map<string,string> &_settings) { return new Is_new_integer(_settings);}; float get_output(const float &time) { if (inputs[0]->connection) { - if (((int)((Signal_node*)(inputs[0]->connection))->get_output(time))>((int)((Signal_node*)(inputs[0]->connection))->get_output(time-.04))) return 1.0f; + //cerr << "== checking: " << ((int)(((Signal_node*)(inputs[0]->connection))->get_output(time))) << ">" <<((int)(((Signal_node*)(inputs[0]->connection))->get_output(time-.04))) << " ?" << endl; + if (((int)(((Signal_node*)(inputs[0]->connection))->get_output(time)))>((int)(((Signal_node*)(inputs[0]->connection)))->get_output(time-.04))) return 1.0f; } else return 0.0f; } @@ -201,6 +205,12 @@ namespace Rotor { }; Signal_output* clone(map<string,string> &_settings) { return new Signal_output(_settings);}; bool render(const float duration, const float framerate,string &xml_out); + float get_output(const float &time) { + if (inputs[0]->connection) { + return ((Signal_node*)(inputs[0]->connection))->get_output(time); + } + else return 0.0f; + } }; //------------------------------------------------------------------- class Node_factory{ diff --git a/rotord/rotord.cpp b/rotord/rotord.cpp index b69ea4a..f0bcc0d 100755 --- a/rotord/rotord.cpp +++ b/rotord/rotord.cpp @@ -104,6 +104,11 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS string content=""; HTTPResponse::HTTPStatus status=HTTPResponse::HTTP_BAD_REQUEST; //by default + + std::string body; + std::ostringstream os; + os<<request.stream().rdbuf(); + body=os.str(); /* @@ -155,6 +160,15 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS content="<sID>"+sID+"</sID>\n"; status=HTTPResponse::HTTP_OK; } + if (request.getMethod()=="PUT") { //undocumented manual thread name + if (body.size()) { + string sID=body; + cerr << "Rotor: starting thread "<< sID << endl; + manager.start(new Rotor::Render_context(sID)); + content="<sID>"+sID+"</sID>\n"; + status=HTTPResponse::HTTP_OK; + } + } } else if (command[0]=="list") { if (request.getMethod()=="GET") { @@ -218,17 +232,14 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS //some commands need to return error codes //ie where the audio file isn't found //on the other hand, some commands need to know state of the renderer? - std::string s; - std::ostringstream os; - os<<request.stream().rdbuf(); - s=os.str(); + vector<string> sc; //method,id,command1,{command2,}{body} sc.push_back(request.getMethod()); for (auto& i: command){ sc.push_back(i); } - sc.push_back(s); + sc.push_back(body); Rotor::Command_response response=((Poco::AutoPtr<Rotor::Render_context>)task)->session_command(sc); |
