returnValue Actuator::delayActuatorInput( VariablesGrid& _u, VariablesGrid& _p ) { if ( hasDeadTime( ) == BT_FALSE ) { // store last signal DVector tmp = _u.getLastVector( ); if ( _p.isEmpty( ) == BT_FALSE ) tmp.append( _p.getLastVector( ) ); lastSignal.init( tmp ); lastSignal.setTime( 0,_u.getLastTime( ) ); return SUCCESSFUL_RETURN; } else { double startTime = _u.getFirstTime( ); double endTime = _u.getLastTime( ); // determine variables grid of delayed input VariablesGrid uDelayed, pDelayed; if ( getDelayedInputGrids( _u,_p, uDelayed,pDelayed ) != SUCCESSFUL_RETURN ) return ACADOERROR( RET_DELAYING_INPUTS_FAILED ); // store last signal lastSignal = uDelayed.getTimeSubGrid( uDelayed.getFloorIndex( endTime ),uDelayed.getLastIndex( ) ); if ( _p.isEmpty( ) == BT_FALSE ) lastSignal.appendValues( pDelayed.getTimeSubGrid( pDelayed.getFloorIndex( endTime ),pDelayed.getLastIndex( ) ) ); /* printf("u:\n"); _u.print(); printf("p:\n"); _p.print(); printf("uDelayed:\n"); uDelayed.print(); printf("pDelayed:\n"); pDelayed.print();*/ // // printf("last:\n"); // lastSignal.print(); // crop delayed signal to current horizon _u = uDelayed.getTimeSubGrid( uDelayed.getFloorIndex( startTime ),uDelayed.getFloorIndex( endTime ) ); if ( _p.isEmpty( ) == BT_FALSE ) _p = pDelayed.getTimeSubGrid( pDelayed.getFloorIndex( startTime ),pDelayed.getFloorIndex( endTime ) ); // printf("u:\n"); // _u.print(); // printf("p:\n"); // _p.print(); return SUCCESSFUL_RETURN; } }
returnValue Actuator::init( double _startTime, const DVector& _startValueU, const DVector& _startValueP ) { DVector tmp; if ( _startValueU.isEmpty( ) == BT_FALSE ) tmp.append( _startValueU ); if ( _startValueP.isEmpty( ) == BT_FALSE ) tmp.append( _startValueP ); if ( TransferDevice::init( _startTime,tmp ) != SUCCESSFUL_RETURN ) return ACADOERROR( RET_ACTUATOR_INIT_FAILED ); return SUCCESSFUL_RETURN; }
Error HTTPClient::request_raw( Method p_method, const String& p_url, const Vector<String>& p_headers,const DVector<uint8_t>& p_body) { ERR_FAIL_INDEX_V(p_method,METHOD_MAX,ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(status!=STATUS_CONNECTED,ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(connection.is_null(),ERR_INVALID_DATA); static const char* _methods[METHOD_MAX]={ "GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS", "TRACE", "CONNECT"}; String request=String(_methods[p_method])+" "+p_url+" HTTP/1.1\r\n"; request+="Host: "+conn_host+":"+itos(conn_port)+"\r\n"; bool add_clen=p_body.size()>0; for(int i=0;i<p_headers.size();i++) { request+=p_headers[i]+"\r\n"; if (add_clen && p_headers[i].find("Content-Length:")==0) { add_clen=false; } } if (add_clen) { request+="Content-Length: "+itos(p_body.size())+"\r\n"; //should it add utf8 encoding? not sure } request+="\r\n"; CharString cs=request.utf8(); DVector<uint8_t> data; //Maybe this goes faster somehow? for(int i=0;i<cs.length();i++) { data.append( cs[i] ); } data.append_array( p_body ); DVector<uint8_t>::Read r = data.read(); Error err = connection->put_data(&r[0], data.size()); if (err) { close(); status=STATUS_CONNECTION_ERROR; return err; } status=STATUS_REQUESTING; return OK; }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); cout << "/----------------------------\\" << endl; cout << "| |" << endl; cout << "| The Project has just begun |" << endl; cout << "| |" << endl; cout << "\\----------------------------/" << endl; // Tests mit einem Vector DVector<double> dvect; dvect.append(5.4321); dvect.append(3.1415); dvect.append(9.81); dvect.append(2.7); dvect.append(123456); try{ dvect.add(123, 55); } catch (DException &e) { cout << e.what() << endl; } for(unsigned int i=0; i<dvect.getLength(); ++i){ cout << "dvect[" << i << "] = " << dvect.getData(i) << endl; } cout << "\nThe list contains " << dvect.getLength() << " entries." << endl; cout << "add '1' at position '1'." << endl; dvect.add(1, 1); for(unsigned int i=0; i<dvect.getLength(); ++i){ cout << "dvect[" << i << "] = " << dvect.getData(i) << endl; } cout << "\nThe list contains " << dvect.getLength() << " entries." << endl; cout << "add '4' at position '4'." << endl; dvect.add(4, 4); for(unsigned int i=0; i<dvect.getLength(); ++i){ cout << "dvect[" << i << "] = " << dvect.getData(i) << endl; } cout << "\nThe list contains " << dvect.getLength() << " entries." << endl; cout << "add '0' at position '0'." << endl; dvect.add(0, 0); for(unsigned int i=0; i<dvect.getLength(); ++i){ cout << "dvect[" << i << "] = " << dvect.getData(i) << endl; } cout << "\nThe list contains " << dvect.getLength() << " entries." << endl; cout << "add '8' at position '8'." << endl; dvect.add(8, 8); for(unsigned int i=0; i<dvect.getLength(); ++i){ cout << "dvect[" << i << "] = " << dvect.getData(i) << endl; } cout << "\nThe list contains " << dvect.getLength() << " entries." << endl; cout << "add '8' at position '8'." << endl; dvect.add(8, 8); for(unsigned int i=0; i<dvect.getLength(); ++i){ cout << "dvect[" << i << "] = " << dvect.getData(i) << endl; } cout << "\nThe list contains " << dvect.getLength() << " entries." << endl; cout << "add '1' at position '1'." << endl; dvect.add(1, 1); for(unsigned int i=0; i<dvect.getLength(); ++i){ cout << "dvect[" << i << "] = " << dvect.getData(i) << endl; } return a.exec(); }