本文整理汇总了C++中DVector::append方法的典型用法代码示例。如果您正苦于以下问题:C++ DVector::append方法的具体用法?C++ DVector::append怎么用?C++ DVector::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DVector
的用法示例。
在下文中一共展示了DVector::append方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: delayActuatorInput
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;
}
}
示例2: init
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;
}
示例3: request_raw
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;
}
示例4: main
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();
}