Exemplo n.º 1
0
/* The test requires a db named "test" on localhost and a user "lksm" in
 * "test" database.  The tests are run against a table called "dpak" 
 * which has the following ddl:
 *	create table dpak
 *	(col1 int not null
 *	 col2 char(20) null);
 *	create unique index index1 on dpak(col1);
 */
int main(int argc, char** argv)
{
	if(argc < 3)
	{
		cerr << "usage: pgdbtest mode col1_val col2_val" << endl;
	}
	string mode(argv[1]);
	int col1_val = atoi(argv[2]);
	string col2_val(argv[3]);
	ConnectionPtr conn = DBManager::getConnection("lksm", "", "localhost/test", DBConnection::POSTGRES_CONNECTION);
	try
	{
		if(strcmp(mode.c_str(), "0")==0)
		{
			string query = col2_val;
			PreparedStatementPtr stmt = conn->prepareStatement(query.c_str());
			cerr<<"PSTMT created successfully." << endl;
			executePreparedStatement(stmt);
		}
		else if(strcmp(mode.c_str(), "1")==0)
		{
			begin(conn);
			sleep(5);
			updateVal(conn, col1_val, col2_val.c_str());
			sleep(10);
			commit(conn);
		}
		else if(strcmp(mode.c_str(), "2")==0)
		{
			begin(conn);
			sleep(5);
			updateVal(conn, col1_val, col2_val.c_str());
			sleep(10);
			commit(conn);
		}
		else if(strcmp(mode.c_str(), "3")==0)
		{
			begin(conn);
			sleep(2);
			updateVal(conn, col1_val, col2_val.c_str());
			sleep(5);
			rollback(conn);
		}
	}catch(DBException &e){
		cerr << "DBException: " << e.getMessage() << endl;
	}catch(BaseException &e){
		cerr << "BaseException: " << e.getMessage() << endl;
	}
	return 0;
}
Exemplo n.º 2
0
void BCS_wf::getParmDepVal(Wavefunction_data * wfdata,
                           Sample_point * sample,
                           int e,
                           Array1 <doublevar> & oldval,
                           Wf_return & newval)
{
    updateVal(wfdata,sample);
    getVal(wfdata,e,newval);

}
Exemplo n.º 3
0
void OutputNode::connect(Node *node)
{
    next = node;
    
    // update the new input node with the component value
    lastVal = component->getValue(index);
    updateVal(lastVal, true);
    
    // update the component about the connection
    component->outputConnected(index);
}
Exemplo n.º 4
0
void GAdsr::setState(SoundCompEvent* e)
{
    DASSERT(e!=NULL);
    if(e->empty())return;
    if(e->getSize()!=sizeof(State))
    {
        DERROR("size missmatch");
        if(e->getSize() < sizeof(State))return;
	
        DERROR("trying to read...");
    }
    const State* state = (const State*)e->getData();
         
    //set
    af=state->af;
    ac=state->ac;
    df=state->df;
    dc=state->dc;
    rf=state->rf;
    rc=state->rc;
    s=state->s; 
   
    //update knobs
    coarse[0]->setValue(ac);
    fine[0]->setValue(af);
    coarse[1]->setValue(dc);
    fine[1]->setValue(df);
    coarse[3]->setValue(rc);
    fine[3]->setValue(rf);
   
    sustain->setValue(s);
   
    gate_knob->setValue(state->g);
    smp_t as = gate_knob->getValue();
    sig->setGateLevel(as);
    led->setThreshold(as);
   
    rb->setValue(state->hrd);
    sig->setHardCut(rb->getValue());
   
    //update
    for(int i=0;i<4;i++)
    {
        updateVal(i);
    }
   
    usein->setValue(state->usein);
    if(!usein->getValue())
    {
        out = sig;
        led->setData(sig->gateOn());
    }
    else
    {
        out = sig_gen;
        led->setData(sig_gen->gateOn());
    }
   
   
   
}