コード例 #1
0
ファイル: xfemmanager.C プロジェクト: Micket/oofem
contextIOResultType XfemManager :: saveContext(DataStream &stream, ContextMode mode, void *obj)
{
    contextIOResultType iores;

    if ( mode & CM_Definition ) {
        if ( !stream.write(this->numberOfEnrichmentItems) ) {
            THROW_CIOERR(CIO_IOERR);
        }
    }

    for ( int i = 1; i <= this->numberOfEnrichmentItems; i++ ) {
        EnrichmentItem *object = this->giveEnrichmentItem(i);
        if ( ( mode & CM_Definition ) ) {
            if ( !stream.write( object->giveInputRecordName() ) ) {
                THROW_CIOERR(CIO_IOERR);
            }
        }

        if ( ( iores = object->saveContext(stream, mode) ) != CIO_OK ) {
            THROW_CIOERR(iores);
        }
    }

    return CIO_OK;
}
コード例 #2
0
ファイル: masterdof.C プロジェクト: Benjamin-git/OOFEM_Jim
contextIOResultType MasterDof :: saveContext(DataStream &stream, ContextMode mode, void *obj)
//
// saves full node context (saves state variables, that completely describe
// current state)
//
{
    contextIOResultType iores;

    if ( ( iores = Dof :: saveContext(stream, mode, obj) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    if ( mode & CM_Definition ) {
        if ( !stream.write(bc) ) {
            THROW_CIOERR(CIO_IOERR);
        }

        if ( !stream.write(ic) ) {
            THROW_CIOERR(CIO_IOERR);
        }
    }

    // store equation number of receiver
    if ( !stream.write(equationNumber) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    if ( ( mode & CM_UnknownDictState ) || ( dofManager->giveDomain()->giveEngngModel()->requiresUnknownsDictionaryUpdate() ) ) {
        if ( ( iores = unknowns.saveContext(stream, mode, obj) ) != CIO_OK ) {
            THROW_CIOERR(iores);
        }
    }

    return CIO_OK;
}
コード例 #3
0
ファイル: primaryfield.C プロジェクト: rreissnerr/oofem
contextIOResultType
PrimaryField :: restoreContext(DataStream &stream, ContextMode mode)
{
    contextIOResultType iores(CIO_IOERR);

    if ( !stream.read(actualStepNumber) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    if ( !stream.read(actualStepIndx) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    for ( int i = 0; i <= nHistVectors; i++ ) {
        if ( ( iores = solutionVectors[i].restoreYourself(stream) ) != CIO_OK ) {
            THROW_CIOERR(iores);
        }
    }

    for ( int i = 0; i <= nHistVectors; i++ ) {
        solStepList[i] = TimeStep(emodel);
        if ( ( iores = solStepList[i].restoreContext(stream, mode) ) != CIO_OK ) {
            THROW_CIOERR(iores);
        }
    }

    return CIO_OK;
}
コード例 #4
0
ファイル: misesmat.C プロジェクト: rainbowlqs/oofem
// saves full information stored in this status
// temporary variables are NOT stored
contextIOResultType
MisesMatStatus :: saveContext(DataStream &stream, ContextMode mode, void *obj)
{
    contextIOResultType iores;

    // save parent class status
    if ( ( iores = StructuralMaterialStatus :: saveContext(stream, mode, obj) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    // write raw data

    // write plastic strain (vector)
    if ( ( iores = plasticStrain.storeYourself(stream) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    // write cumulative plastic strain (scalar)
    if ( !stream.write(kappa) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    // write damage (scalar)
    if ( !stream.write(damage) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    return CIO_OK;
}
コード例 #5
0
ファイル: misesmat.C プロジェクト: rainbowlqs/oofem
contextIOResultType
MisesMatStatus :: restoreContext(DataStream &stream, ContextMode mode, void *obj)
//
// restores full information stored in stream to this Status
//
{
    contextIOResultType iores;

    // read parent class status
    if ( ( iores = StructuralMaterialStatus :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    // read plastic strain (vector)
    if ( ( iores = plasticStrain.restoreYourself(stream) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    // read cumulative plastic strain (scalar)
    if ( !stream.read(kappa) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    // read damage (scalar)
    if ( !stream.read(damage) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    return CIO_OK; // return succes
}
コード例 #6
0
bool AvatarSimulation::convRequestAvatarOutput( void *vpConv ) {
	DataStream ds;
	spConversation conv = (spConversation)vpConv;
	UUID thread;
	char response;

	if ( conv->response == NULL ) { // request timed out
		Log.log( 0, "AvatarSimulation::convRequestAvatarOutput: request timed out" );
		return 0; // end conversation
	}

	ds.setData( conv->response, conv->responseLen );
	ds.unpackUUID( &thread ); // thread
	
	response = ds.unpackChar();
	this->ds.unlock();

	if ( response == 0 ) { // success
		STATE(AvatarSimulation)->simRegistrationConfirmed = true;

		this->parseAvatarOutput( &ds );
	} else { // failure
		// avatar doesn't exist? nothing to do
	}

	return 0;
}
コード例 #7
0
ファイル: lattice2d.C プロジェクト: Benjamin-git/OOFEM_Jim
contextIOResultType Lattice2d :: restoreContext(DataStream &stream, ContextMode mode, void *obj)
{
    contextIOResultType iores;

    if ( ( iores = LatticeStructuralElement :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    if ( mode & CM_Definition ) {
     
        if ( !stream.read(width) ) {
            THROW_CIOERR(CIO_IOERR);
        }

        if ( !stream.read(thickness) ) {
            THROW_CIOERR(CIO_IOERR);
        }

        if ( !stream.read(couplingFlag) ) {
            THROW_CIOERR(CIO_IOERR);
        }

        if ( ( iores = couplingNumbers.restoreYourself(stream) ) != CIO_OK ) {
            THROW_CIOERR(iores);
        }

        if ( ( iores = gpCoords.restoreYourself(stream) ) != CIO_OK ) {
            THROW_CIOERR(iores);
        }

    }

    return CIO_OK;
}
コード例 #8
0
void loop() {
    static int disconnected;
	console.printf("HELLO?\r\n");
    if (millis() - lastCheck > 3000) {
        digitalWrite(RED_LED,LED_OFF);
        if ((! hasWifiModule) || networkStatus()) {
            digitalWrite(RED_LED,LED_OFF);
            disconnected=0;
        } else {
            digitalWrite(RED_LED,LED_ON);
            if (++disconnected > 10) {
                char tempssid[40];
                strcpy(tempssid,networkSSID);
                digitalWrite(RED_LED,networkJoin(tempssid)?LED_OFF:LED_ON);
            }
        }
        digitalWrite(GRN_LED,SerialUSB.isConnected()?HIGH:LOW);
        lastCheck=millis();
    }
        
    
    while (console.gotLine()) {
        digitalWrite(GRN_LED,LOW);
        handleConsoleInput();
        digitalWrite(GRN_LED,HIGH);
    }
    clearStowedValues();
    Watchdog_Reset();

}
コード例 #9
0
void setup() {

    //spi.begin(SPI_281_250KHZ, MSBFIRST, 0);
	
	pinMode(GRN_LED,OUTPUT);
	pinMode(ORN_LED,OUTPUT);
	pinMode(RED_LED,OUTPUT);
	digitalWrite(GRN_LED,HIGH);
	digitalWrite(ORN_LED,LOW);
	digitalWrite(RED_LED,LOW);

    //iwdg_init(IWDG_PRE_256, WATCHDOG_TIMEOUT);
    Watchdog_Reset();
    delay(3000);
	console.printf("HELLO?\r\n");
	
    setupRadioModule();
    
	digitalWrite(GRN_LED,LOW);
	digitalWrite(RED_LED,HIGH);
	console.printf("LSV:" BOM_VERSION "\r\n");
    console.printf("NST: %s\r\n",networkStatus()?"CONNECTED":"NOT CONNECTED");
	digitalWrite(ORN_LED,HIGH);
	digitalWrite(RED_LED,networkStatus()?HIGH:LOW);
	
}
コード例 #10
0
int LuaScriptEngine::Compiler::writer(lua_State* L, const void* p, size_t size, void* data)
{
    (void)L;
    assert( data );
    DataStream* s = static_cast<DataStream*>(data);
    return (s->write(p, size) != size) && (size != 0);
}
コード例 #11
0
ファイル: DatePackage.cpp プロジェクト: ptryfon/loxim-stats
DatePackage::DatePackage(const sigset_t &mask, const bool &cancel, size_t &length, DataStream &stream):

    year(stream.read_int16(mask, cancel, length)),
    month(stream.read_uint8(mask, cancel, length)),
    day(stream.read_uint8(mask, cancel, length))
{
}
コード例 #12
0
ファイル: xfemmanager.C プロジェクト: Micket/oofem
contextIOResultType XfemManager :: restoreContext(DataStream &stream, ContextMode mode, void *obj)
{
    contextIOResultType iores;

    if ( mode & CM_Definition ) {
        if ( !stream.read(this->numberOfEnrichmentItems) ) {
            THROW_CIOERR(CIO_IOERR);
        }
        this->enrichmentItemList.resize(this->numberOfEnrichmentItems);
    }

    for ( int i = 1; i <= this->numberOfEnrichmentItems; i++ ) {
        EnrichmentItem *obj;
        if ( mode & CM_Definition ) {
            std :: string name;
            if ( !stream.read(name) ) {
                THROW_CIOERR(CIO_IOERR);
            }

            std :: unique_ptr< EnrichmentItem >ei( classFactory.createEnrichmentItem(name.c_str(), i, this, this->domain) );
            obj = ei.get();
            enrichmentItemList.insert( enrichmentItemList.begin() + i - 1, std :: move(ei) );
        } else {
            obj = this->giveEnrichmentItem(i);
        }

        if ( ( iores = obj->restoreContext(stream, mode) ) != CIO_OK ) {
            THROW_CIOERR(CIO_IOERR);
        }
    }

    return CIO_OK;
}
コード例 #13
0
	void ASCPongPackage::serialize(const sigset_t &mask, const bool& cancel, DataStream &stream, bool with_header) const
	{
		if (with_header){
			stream.write_uint8(mask, cancel, get_type());
			stream.write_uint32(mask, cancel, get_ser_size());
		}
	}
コード例 #14
0
contextIOResultType SimpleSlaveDof :: saveContext(DataStream &stream, ContextMode mode, void *obj)
//
// saves full node context (saves state variables, that completely describe
// current state)
//
{
    contextIOResultType iores;
    if ( ( iores = Dof :: saveContext(stream, mode, obj) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    if ( mode & CM_Definition ) {

        if ( mode & CM_DefinitionGlobal ) {
            int _masterGlobNum = dofManager->giveDomain()->giveDofManager(masterDofMngr)->giveGlobalNumber();
            if ( !stream.write(_masterGlobNum) ) {
                THROW_CIOERR(CIO_IOERR);
            }
        } else {
            if ( !stream.write(masterDofMngr) ) {
                THROW_CIOERR(CIO_IOERR);
            }
        }
    }

    return CIO_OK;
}
コード例 #15
0
void typeFile(char *fname) {
    SdFile file2;
    int16_t n;
    char nfname[16];
    char buf[65];
    for (n=0; fname[n] && n<15; n++) {
        if (fname[n]=='\r'||fname[n]=='\n') {
            nfname[n]='\0';
        } else if (fname[n]=='.') {
            nfname[n]='.';
        } else {
            nfname[n]=fname[n];//nfname[n]=toupper(fname[n]);
        }
    }
    if (file2.open (&root,nfname,O_READ)) {
		console.printf("SOD:%s\r\n",nfname);
        while ((n = file2.read(buf, sizeof(buf)-1)) > 0) {
            buf[n]='\0';
            console.puts(buf);
        }
		console.printf("EOD:%s\r\n",nfname);
    } else { 
        console.printf("DBG: Couldnt open '%s'\r\n",nfname);        
    }
    
}
コード例 #16
0
ファイル: plasticmaterial.C プロジェクト: erisve/oofem
contextIOResultType
PlasticMaterialStatus :: saveContext(DataStream &stream, ContextMode mode, void *obj)
//
// saves full information stored in this Status
// no temp variables stored
//
{
    contextIOResultType iores;

    // save parent class status
    if ( ( iores = StructuralMaterialStatus :: saveContext(stream, mode, obj) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    // write a raw data
    if ( ( iores = plasticStrainVector.storeYourself(stream) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    if ( ( iores = strainSpaceHardeningVarsVector.storeYourself(stream) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    if ( !stream.write(state_flag) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    if ( !stream.write(gamma) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    return CIO_OK;
}
コード例 #17
0
ファイル: plasticmaterial.C プロジェクト: erisve/oofem
contextIOResultType
PlasticMaterialStatus :: restoreContext(DataStream &stream, ContextMode mode, void *obj)
//
// restores full information stored in stream to this Status
//
{
    contextIOResultType iores;

    // read parent class status
    if ( ( iores = StructuralMaterialStatus :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    if ( ( iores = plasticStrainVector.restoreYourself(stream) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    if ( ( iores = strainSpaceHardeningVarsVector.restoreYourself(stream) ) != CIO_OK ) {
        THROW_CIOERR(iores);
    }

    if ( !stream.read(state_flag) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    if ( !stream.read(gamma) ) {
        THROW_CIOERR(CIO_IOERR);
    }

    return CIO_OK; // return success
}
コード例 #18
0
int networkJoin(char *ssid) {
    
    int retval=0;
    if (!hasWifiModule) return retval;
    strcpy(networkSSID, ssid);
    console.debug("joining: %s\r\n",networkSSID);
    Watchdog_Reset();
	radio.discard();
	radio.printf("\r\nATE0\r\nAT+WA=%s\r\n",ssid);
	while (!radio.gotLine()); // and some timeout.
	while (!(retval=isErrorOrOK(radio.line()))){
		//console.puts(radio.line());
		while (!radio.gotLine()) { // timeout?
			;	
		}		
	}
    Watchdog_Reset();
	radio.printf("\r\nAT+ndhcp=1\r\n");
    delay(1000); // this should be an idle.
	while (!radio.gotLine()); // and some timeout.
	while (!(isErrorOrOK(radio.line()))){
		console.debug("%s",radio.line());
		while (!radio.gotLine()) {
			;	
		}		
	}
    //console.debug("join %s (%d)\r\n",networkSSID,retval=networkStatus());
	return(networkStatus());	
}
コード例 #19
0
int networkStatus() {
    int retval=0;
    if (!hasWifiModule) return retval;
    radio.discard();
	radio.printf("\r\n");
	radio.discard();
	radio.printf("\r\nAT+WSTATUS\r\n");
	while (!radio.gotLine()); // and some timeout.
	while (!(retval=isErrorOrOK(radio.line()))){
        if ((radio.line()[0]=='N') && (radio.line()[1] == 'O') && (radio.line()[2] == 'T')) {
            //if (strncmp("NOT ASSOCIATED",radio.line(),10) ==0){ //wtf????
            //console.debug("NOT ASSOCIATED\r\n");
            return(0);
        } else {
            //            console.debug("%s",radio.line());
        }
		while (!radio.gotLine()) {
			// and some timeout!!!
            ;	
		}
	}
	//console.puts(radio.line());
	return(retval>=1);
	
}
コード例 #20
0
void loop() {
    static int disconnected;
    if (millis() - lastCheck > 3000) {
        
        if (networkStatus()) {
            digitalWrite(RED_LED,LED_OFF);
            disconnected=0;
        } else {
            digitalWrite(RED_LED,LED_ON);
            if (++disconnected > 10) {
                char tempssid[40];
                strcpy(tempssid,networkSSID);
                digitalWrite(RED_LED,networkJoin(tempssid)?LED_OFF:LED_ON);
            }
        }
        digitalWrite(GRN_LED,SerialUSB.isConnected()?HIGH:LOW);
        lastCheck=millis();
    }
        
    while (device.gotLine()) {
        handleDeviceInput();
    }
    while (console.gotLine()) {
        digitalWrite(GRN_LED,LOW);
        handleConsoleInput();
        digitalWrite(GRN_LED,HIGH);
    }
    
    Watchdog_Reset();

}
コード例 #21
0
void readSettings() {
	int n,cc;
	char ch, buff[24];
	char  buff2[80];
	unsigned int ndx=0;
	int read=0;
    if (!settingsFile.open(&root, settingsFileName, O_READ)) {
        console.printf("DBG: Creating New Settings File\r\n"); console.flush();
        writeSettings();
        return;
	}
    console.printf("DBG: Opened Settings File: %s\r\n",settingsFileName);
	settingsFile.seekSet(0);
	while ((read=settingsFile.read(buff, sizeof(buff))) > 0) {
        //console.printf("DBG: READ %d\r\n",read); console.flush();
        for (cc=0; cc < read ; cc++) {
            
            ch=buff[cc];
            //console.putChar(ch); console.flush();
            buff2[ndx]=ch;
            if (ndx<MAX_INPUT_LINE) {ndx++;}
            if (ch=='\n'){//console.putChar('\r');
                if(ndx) {
                    ndx--; // eat the newline.
                }
                buff2[ndx]='\0';
                //console.puts(buff2);
                if ((ndx>4) && buff2[3]=='!') {//fix this when the files are better
                    buff2[3]='\0';
                    n=lookupIndex(buff2);
                    switch (n) {
                        case _NPW_:
                            networkSetPassword(buff2+4);
                            break;
                        case _NJN_:
                            Watchdog_Reset();
                            networkJoin(buff2 +4);
                            break;
                        case _PKY_:
                            strncpy(pachubeKey, buff2+4, MAX_PATCHUBE_KEY_LENGHT-1);
                            break;
                        case _PFD_:
                            strncpy(pachubeFeed, buff2+4, MAX_PATCHUBE_FEED_LENGHT-1);
                            break;
                        default:
                            break;
                    }
                    
                }
            
                ndx=0; 

            }
        }
    }
    
    console.printf("DBG: Finished with Settings File: %s\r\n",settingsFileName);
    
	settingsFile.close();
}
コード例 #22
0
ファイル: WCModePackage.cpp プロジェクト: ptryfon/loxim-stats
	void WCModePackage::serialize(const sigset_t &mask, const bool& cancel, DataStream &stream, bool with_header) const
	{
		if (with_header){
			stream.write_uint8(mask, cancel, get_type());
			stream.write_uint32(mask, cancel, get_ser_size());
		}
		stream.write_uint64(mask, cancel, new_mode);
	}
コード例 #23
0
	ASCErrorPackage::ASCErrorPackage(const sigset_t &mask, const bool &cancel, size_t &length, DataStream &stream):

		error_code(stream.read_uint32(mask, cancel, length)),
		error_object_id(stream.read_varuint(mask, cancel, length)),
		description(stream.read_string(mask, cancel, length)),
		line(stream.read_uint32(mask, cancel, length)),
		col(stream.read_uint32(mask, cancel, length))
	{
	}
コード例 #24
0
ファイル: TTFFontManager.cpp プロジェクト: OldSnapo/gemrb
unsigned long TTFFontManager::read(FT_Stream		  stream,
								   unsigned long   offset,
								   unsigned char*  buffer,
								   unsigned long   count )
{
	DataStream* dstream = (DataStream*)stream->descriptor.pointer;
	dstream->Seek(offset, GEM_STREAM_START);
	return dstream->Read(buffer, count);
}
コード例 #25
0
ファイル: ASCByePackage.cpp プロジェクト: ptryfon/loxim-stats
	void ASCByePackage::serialize(const sigset_t &mask, const bool& cancel, DataStream &stream, bool with_header) const
	{
		if (with_header){
			stream.write_uint8(mask, cancel, get_type());
			stream.write_uint32(mask, cancel, get_ser_size());
		}
		stream.write_uint32(mask, cancel, reason_code);
		stream.write_string(mask, cancel, reason_description);
	}
コード例 #26
0
	void WCPasswordPackage::serialize(const sigset_t &mask, const bool& cancel, DataStream &stream, bool with_header) const
	{
		if (with_header){
			stream.write_uint8(mask, cancel, get_type());
			stream.write_uint32(mask, cancel, get_ser_size());
		}
		stream.write_string(mask, cancel, login);
		stream.write_string(mask, cancel, password);
	}
コード例 #27
0
ファイル: multiplexer.cpp プロジェクト: iplaydu/OpenCPN
DataStream *Multiplexer::FindStream( wxString port )
{
    for (size_t i = 0; i < m_pdatastreams->Count(); i++)
    {
        DataStream *stream = m_pdatastreams->Item(i);
        if( stream && stream->GetPort() == port )
            return stream;
    }
    return NULL;
}
コード例 #28
0
ファイル: DatePackage.cpp プロジェクト: ptryfon/loxim-stats
void DatePackage::serialize(const sigset_t &mask, const bool& cancel, DataStream &stream, bool with_header) const
{
    if (with_header) {
        stream.write_uint8(mask, cancel, get_type());
        stream.write_uint32(mask, cancel, get_ser_size());
    }
    stream.write_int16(mask, cancel, year);
    stream.write_uint8(mask, cancel, month);
    stream.write_uint8(mask, cancel, day);
}
コード例 #29
0
ファイル: multiplexer.cpp プロジェクト: doublespy/OpenCPN
void Multiplexer::SendNMEAMessage( wxString &msg )
{
    //Send to all the outputs
    for (size_t i = 0; i < m_pdatastreams->Count(); i++)
    {
        DataStream* s = m_pdatastreams->Item(i);
        if ( s->IsOk() && (s->GetIoSelect() == DS_TYPE_INPUT_OUTPUT || s->GetIoSelect() == DS_TYPE_OUTPUT) ) {
            bool bout_filter = true;

            bool bxmit_ok = true;
            if(s->SentencePassesFilter( msg, FILTER_OUTPUT ) ) {
                bxmit_ok = s->SendSentence(msg);
                bout_filter = false;
            }    
            //Send to the Debug Window, if open
            if( !bout_filter ) {
                if( bxmit_ok )
                    LogOutputMessageColor( msg, s->GetPort(), _T("<BLUE>") );
                else
                    LogOutputMessageColor( msg, s->GetPort(), _T("<RED>") );
            }
            else
                LogOutputMessageColor( msg, s->GetPort(), _T("<AMBER>") );
        }
        
    }
    //Send to plugins
    if ( g_pi_manager )
        g_pi_manager->SendNMEASentenceToAllPlugIns( msg );
}
コード例 #30
0
ファイル: File.cpp プロジェクト: erenik/engine
/// Reads x bytes into the file, continuing from previous location (or start if newly opened).
bool File::ReadBytes(DataStream & intoStream, int numBytes)
{
	if (!this->IsOpen())
		return false;
	if (numBytes <= 0)
		return false;
	uchar * bytes = intoStream.GetData();
	this->fileStream.read((char*)bytes, numBytes);
	intoStream.SetBytesUsed(numBytes);
	return true;
}