Exemplo n.º 1
0
/* To be called not faster than 30Hz */
void baro_MS5534A_send(void) {
  if (!SpiCheckAvailable()) {
    SpiOverRun();
    return;
  }

  if (status == STATUS_RESET) {
    uint8_t i;
    for(i = 0; i < 3; i++)
      buf_output[i] = reset[i];
    spi_buffer_length = 3;
  } else {
    if (status_read_data) {
      buf_output[0] = buf_output[1] = 0;
    } else {
      buf_output[0] = (InitStatus() ? CMD_INIT : CMD_MEASUREMENT);
      buf_output[1] = cmds[status];
    }
    spi_buffer_length = 2;
  }

  spi_buffer_input = (uint8_t*)&buf_input;
  spi_buffer_output = (uint8_t*)&buf_output;
  if (status_read_data)
    SpiSetCPHA();
  else
    SpiClrCPHA();
  SpiStart();
}
Exemplo n.º 2
0
void CNetWatcher::SetCallback ( CKAHFW::NETWORKCHANGEPROC proc, void *aux )
{
	//log.WriteFormat (_T("[CNetWatcher] SetCallback begin"), PEL_INFO);

    DestroyThread ();

    if (proc)
    {
        InitStatus ();

        m_callback = proc;
        m_aux = aux;

        CreateThread ();
    }
	//log.WriteFormat (_T("[CNetWatcher] SetCallback end"), PEL_INFO);
}
Exemplo n.º 3
0
NetworkList * CNetWatcher::GetNetworkList ()
{
	//log.WriteFormat (_T("[CNetWatcher] GetNetworkList"), PEL_INFO);

    NetworkList * list = 0;

    Lock ();

    if ( ! InitStatus () )
    {
        Unlock ();

	    //log.WriteFormat (_T("[CNetWatcher] GetNetworkList failed - InitStatus failed"), PEL_INFO);
        return 0;
    }

    if ( ! m_threadstarted )
    {
        GetNewStatus ();
    }

    if ( m_listsize == 0 )
    {
        Unlock ();

	    //log.WriteFormat (_T("[CNetWatcher] GetNetworkList failed - m_listsize == 0"), PEL_INFO);
        return 0;
    }

    if ( ! ( list = (NetworkList *) new unsigned char [ m_listsize ] ) )
    {
        Unlock ();

	    //log.WriteFormat (_T("[CNetWatcher] GetNetworkList failed - no memory"), PEL_INFO);
        return 0;
    }

    memcpy (list, m_list, m_listsize); 

    Unlock ();

	//log.WriteFormat (_T("[CNetWatcher] GetNetworkList succeeded"), PEL_INFO);
    return list;
}
Exemplo n.º 4
0
HttpHelper::HttpHelper(int status, const char* reason)
{
	InitStatus();
	SetStatus(status, reason);
}
Exemplo n.º 5
0
HttpHelper::HttpHelper()
{
	InitStatus();
	SetStatus(200, NULL);
}
Exemplo n.º 6
0
void Adaboost(TrainData *data,int T){
    InitWi(data);
    double temptheta=0.0,theta1=0.0;
    double error,beta;
    int p=0;                            //p=0 <=> '<' p=0 <=> '>'
    double min;
//////////////left is positive & right is nagitive//////////////
    for(int i=0;i<T;i++){
        //get theta first
        p=0;
        min=DBL_MAX;//////Be careful
        nomalization(data);
        for(int j=0;j<Data_Size_G;j++){
            InitStatus(data);
            temptheta=data[j].property;
            for(int k=0;k<Data_Size_G;k++){
                if((data[k].property<=temptheta)&&(data[k].label==0))
                    data[k].status=MISS;
                if((data[k].property>temptheta)&&(data[k].label))
                    data[k].status=MISS;
            }
            error=getError(data);
            if(error<=min&&error<0.5){
                theta1=temptheta;
                min=error;
            
            }
        }
        
//////////////right is positive & left is nagitive//////////////
        temptheta=0.0;
        double theta2=0.0;
        for(int j=0;j<Data_Size_G;j++){
            InitStatus(data);
            temptheta=data[j].property;
            for(int k=0;k<Data_Size_G;k++){
                if((data[k].property>=temptheta)&&(data[k].label==0))
                    data[k].status=MISS;
                if((data[k].property<temptheta)&&(data[k].label))
                    data[k].status=MISS;
            }
            error=getError(data);
            if(error<=min){
                theta2=temptheta;
                min=error;
                p=1;
                
            }
        }
//////////////////////////////////////////////////////////////////////////
        InitStatus(data);
        double theta=p?theta2:theta1;
        if(p)
            for(int k=0;k<Data_Size_G;k++){
                if((data[k].property>=theta)&&(data[k].label==0))
                    data[k].status=MISS;
                if((data[k].property<theta)&&(data[k].label))
                    data[k].status=MISS;
            }
        else
            for(int k=0;k<Data_Size_G;k++){
                if((data[k].property<=theta)&&(data[k].label==0))
                    data[k].status=MISS;
                if((data[k].property>theta)&&(data[k].label))
                    data[k].status=MISS;
            }
        
        
        
        error=getError(data);
        beta=getBeta(error);
        updataWi(data, beta);
        
        if(p)
            printf("|>=|   |Threshold:%9lf|error:%9lf |Alpha:%9lf|\n",theta,error,getAlpha(beta));
        else
            printf("|<=|   |Threshold:%9lf|error:%9lf |Alpha:%9lf|\n",theta,error,getAlpha(beta));
        
      
    }

}
void TransactionStatus::InitStatus(const DB_Table_CHECKINGACCOUNT::Data& data)
{
    InitStatus(&data);
}
TransactionStatus::TransactionStatus(const DB_Table_CHECKINGACCOUNT::Data* data)
{
    InitStatus(data);
}