// Import data from the specified file bool DLP4TrajectoryPlugin::importData() { // Read header information from trajectory file, if there is any QString name; if ( !fileParser_.readLine ( name ) ) { return false; } targetModel()->setName ( name ); if ( !fileParser_.skipLines ( 1 ) ) { return false; } // Read the first trajectory frame. // The model where we should put the frame data will have been set in the FileParser (in parentModel()). // Calling FilePluginInterface::importPart(0) will set the file positions we need, and read in the first frame. Model* frame = createFrame(); if (!importPart(0)) { discardFrame(frame); return false; } if (standardOptions_.isSetAndOn(FilePluginStandardImportOptions::CacheAllSwitch)) { Messenger::print("Caching all frames from HISTORY file (%i %s)...", nDataParts(), isNPartialDataEstimated() ? "estimated" : "actual"); int count = 0; bool frameResult; do { // Add a new trajectory frame Model* frame = createFrame(); // Attempt to read in the next data part in the file frameResult = importPart(++count); if (!frameResult) discardFrame(frame); } while (frameResult && (!fileParser_.eofOrBlank())); closeFiles(); } return true; }
//***** void DtmfDataLinkLayer::processFrame(Frame incoming) { if(incoming.checkParity()==0) { if(incoming.receiver == MY_ADDRESS) //if frame is for me and parity is ok { switch(incoming.type) { case 3: //if frame type is dataframe { acceptFrame(incoming); break; } case 2: //if frame is station accepting token { passToken(); break; } case 1: //if frame is station offering token { tokenOffered(); break; } case 0: //if frame is reply from receiver { if(hasToken == 1) replyFromReceiver(incoming); else { #ifdef DEBUG DEBUG_OUT << " reply to tokenholder " ; #endif discardFrame(); } break; } default: //impossible frame type { fatalError(); break; } } } else //frame is not for me { if(incoming.type == 0 && hasToken == 1) //if frame is reply from receiver and tokenholder is me replyFromReceiver(incoming); else if(incoming.type == 2 && hasToken == 1) //if frame is accept token and I have token passToken(); else { #ifdef DEBUG DEBUG_OUT << " wrong receiver " ; #endif discardFrame(); } } } else { #ifdef DEBUG DEBUG_OUT << " bad parity " ; #endif discardFrame(); } }