Esempio n. 1
0
 int peek() {
     if (!_available) {
         if (!_readAll())
             return -1;
     }
     return _read_ptr[0];
 }
Esempio n. 2
0
 int available() {
     auto cb = _available;
     if (cb == 0) {
         cb = _readAll();
     } else {
         optimistic_yield(100);
     }
     return cb;
 }
Esempio n. 3
0
    size_t peekBytes(char *dst, size_t size) {
        if(!_available) {
            if(!_readAll())
                return -1;
        }

        size_t will_copy = (_available < size) ? _available : size;
        memcpy(dst, _read_ptr, will_copy);
        return will_copy;
    }
Esempio n. 4
0
/* CONSTRUCTOR */
CPV::CPV ( sSimCnf*  sSimCnf , XMLElement* cnf , TVFloat* pv_gen , TVFloat* pv_frc ){
	/* General Simulator Configuration */
	m_sSimCnf = sSimCnf;
	/* Get input files (hourly data) */
	if ( cnf->Attribute("gen") ){
		m_sPwGenFile = cnf->Attribute("gen");
		/* Get profile only one time */
		if ( pv_gen->size() == 0 ){
			_readAll( &m_sPwGenFile , pv_gen );
		}
	}
	if ( cnf->Attribute("frc") ){
		m_sPwFrcFile = cnf->Attribute("frc");
		/* Get profile only one time */
		if ( pv_frc->size() == 0 ){
			_readAll( &m_sPwFrcFile , pv_frc );
		}
	}
	if ( cnf->Attribute("type") ){ // Two available types: 0 (from file) and 1 (from model)
		m_nType = atoi(cnf->Attribute("type"));
	}
	else{
		m_nType = 0;
	}
	if ( cnf->Attribute("power") ){
		m_fPAmp      = atof(cnf->Attribute("power"));
	}
	else{
		m_fPAmp      = 0.0;
	}
	/* Get profiles for the node */	
	m_vPwGen = pv_gen;
	m_vPwFrc = pv_frc;
	/* Create PV model if required */
	if ( m_nType == 1 ){
		m_pcPVmodel = new CPVmodel  ( sSimCnf , cnf );

	}
	return;
};
Esempio n. 5
0
 int read() {
     if (!_available) {
         if (!_readAll())
             return -1;
     }
     int result = _read_ptr[0];
     ++_read_ptr;
     --_available;
     if (_available == 0) {
         _read_ptr = nullptr;
     }
     return result;
 }
Esempio n. 6
0
 int read(uint8_t* dst, size_t size) {
     if (!_available) {
         if (!_readAll())
             return 0;
     }
     size_t will_copy = (_available < size) ? _available : size;
     memcpy(dst, _read_ptr, will_copy);
     _read_ptr += will_copy;
     _available -= will_copy;
     if (_available == 0) {
         _read_ptr = nullptr;
     }
     return will_copy;
 }