bool LCDbWorkEntry::updateStatus( LQuery central, LDbWorkEntry::Stage result ) { String update = "set status = :sts, buddy_read = :brf, time_stamp = 'now'"; if( getResultID() != 0 ) update = update + ", buddy_result_id = " + getResultID(); central.setSQL( "update c_buddy_worklist " + update + " where record_no = :rno" ); switch( result ) { case LDbStage::L0_HELD: central.setParam( "brf", LCDbWorkEntry::HELD ); break; case LDbStage::TRANSMITTED: case LDbStage::DELETED: central.setParam( "brf", LCDbWorkEntry::FINISHED ); break; default: central.setParam( "brf", LCDbWorkEntry::COPIED ); } central.setParam( "rno", getID() ); central.setParam( "sts", makeStatus( result ) ); if( central.execSQL() != 1 ) return false; else { setStage( result ); setTimeStamp( Now() ); return true; } }
void Navigator_Dcm::updateFast(float dt) { if (_board->getMode() != AP_Board::MODE_LIVE) return; setTimeStamp(micros()); // if running in live mode, record new time stamp // use range finder if attached and close to the ground if (_rangeFinderDown != NULL && _rangeFinderDown->distance <= 695) { setAlt(_rangeFinderDown->distance); // otherwise if you have a baro attached, use it } else if (_board->baro) { /** * The altitued is read off the barometer by implementing the following formula: * altitude (in m) = 44330*(1-(p/po)^(1/5.255)), * where, po is pressure in Pa at sea level (101325 Pa). * See http://www.sparkfun.com/tutorials/253 or type this formula * in a search engine for more information. * altInt contains the altitude in meters. * * pressure input is in pascals * temp input is in deg C *10 */ _board->baro->Read(); // Get new data from absolute pressure sensor float reference = 44330 * (1.0 - (pow(_groundPressure.get()/101325.0,0.190295))); setAlt(_baroLowPass.update((44330 * (1.0 - (pow((_board->baro->Press/101325.0),0.190295)))) - reference,dt)); //_board->debug->printf_P(PSTR("Ground Pressure %f\tAltitude = %f\tGround Temperature = %f\tPress = %ld\tTemp = %d\n"),_groundPressure.get(),getAlt(),_groundTemperature.get(),_board->baro->Press,_board->baro->Temp); // last resort, use gps altitude } else if (_board->gps && _board->gps->fix) { setAlt_intM(_board->gps->altitude * 10); // gps in cm, intM in mm } // update dcm calculations and navigator data // _dcm.update_DCM_fast(); setRoll(_dcm.roll); setPitch(_dcm.pitch); setYaw(_dcm.yaw); setRollRate(_dcm.get_gyro().x); setPitchRate(_dcm.get_gyro().y); setYawRate(_dcm.get_gyro().z); setXAccel(_dcm.get_accel().x); setYAccel(_dcm.get_accel().y); setZAccel(_dcm.get_accel().z); /* * accel/gyro debug */ /* Vector3f accel = _board->imu->get_accel(); Vector3f gyro = _board->imu->get_gyro(); Serial.printf_P(PSTR("accel: %f %f %f gyro: %f %f %f\n"), accel.x,accel.y,accel.z,gyro.x,gyro.y,gyro.z); */ }
static void createTestFile(const QString &path) { QFile f(path); if(!f.open(IO_WriteOnly)) kdFatal() << "Can't create " << path << endl; f.writeBlock("Hello world", 11); f.close(); setTimeStamp(path); }
static void createTestDirectory(const QString &path) { QDir dir; bool ok = dir.mkdir(path); if(!ok && !dir.exists()) kdFatal() << "couldn't create " << path << endl; createTestFile(path + "/testfile"); createTestSymlink(path + "/testlink"); setTimeStamp(path); }
void MediaRaw::setTimeBase(Rational* timeBase, Rational::Rounding rounding) { int64_t timeStamp = getTimeStamp(); if (timeBase && timeStamp != Global::NO_PTS && mTimeBase.value()) { timeStamp = timeBase->rescale(timeStamp, mTimeBase.value(), rounding); setTimeStamp(timeStamp); } mTimeBase.reset(timeBase, true); }
// Constructor for parser function Message::Message(XmlStreamReader& xml) : QObject(), m_timeStamp(), m_timeStampPresent( false ), m_code( 0 ), m_codePresent( false ), m_version( "1.0.0" ), // initialize fixed value m_versionPresent( true ), m_changed(true) { QXmlStreamAttributes attr = xml.attributes(); if ( attr.hasAttribute( "TimeStamp" ) ) { if ( !setTimeStamp( QDateTime::fromString(attr.value( "TimeStamp" ).toString(), Qt::ISODate)) ) xml.validationError( "error set TimeStamp = " + attr.value( "TimeStamp" ).toString() ); } if ( attr.hasAttribute( "Code" ) ) { if ( !setCode( attr.value( "Code" ).toString().toInt() ) ) xml.validationError( "error set Code = " + attr.value( "Code" ).toString() ); } if ( attr.hasAttribute( "Version" ) ) { if ( !setVersion( attr.value( "Version" ).toString() ) ) xml.validationError( "error set Version = " + attr.value( "Version" ).toString() ); } bool stop(false); while(!xml.atEnd() && !stop) { QXmlStreamReader::TokenType token = xml.readNext(); switch ( token ) { case QXmlStreamReader::EndElement: if ( xml.name() == "Message" ) stop = true; break; case QXmlStreamReader::StartElement: if ( xml.name() == "Argument" ) { QString val = xml.readElementText(); if ( xml.name() != "Argument" ) xml.raiseError( "tag mismatch Argument" ); else if ( !addArgument( val ) ) xml.validationError( "error add Argument" ); } else { xml.validationError( "unexpected element " + xml.name().toString() ); } break; default: break; } } }
std::ostringstream& Logger<OutputPolicy>::get(logLevel level, const Time *TS) { // Generate a timestamp if needed: if (!TS) { Time timestamp; setTimeStamp(×tamp); TS = ×tamp; } // Write the time stamp and logging level to the buffer: std::string ts; os << timestampToText(TS, ts) << logLevelText[level]; // Return the stringstream so that the caller can append stuff: return os; }
/** * This method copies the pixels values from the input image to the current image. * None of the parameters of the input image are edited. * All the parameters in the two images have to be the same. If not, the copy operation * is interrupted and nothing is done. * * \param img DiVAImage * \return Verification code */ int DiVAImage::copy(DiVAImage *img){ if(this->getWidth() != img->getWidth() || this->getHeight() != img->getHeight() || this->getDepth() != img->getDepth()|| this->getNChannels() != img->getNChannels() ) return -1; setPixels(img->getPixels()); setId(img->getId()); setTimeStamp(img->getTimeStamp()); setVAlign(img->getVAlign()); return 1; }
DragLabel::DragLabel(const QString &text, QWidget* parent, DragWidget* canvasWidget, const QColor &defaultColor, qint64 timeStamp, int x, int y) : QLabel(text, parent), AbstractDragInterface(canvasWidget), m_RightClickMenu(NULL) { setAttribute(Qt::WA_DeleteOnClose); changeColor(defaultColor); setAutoFillBackground(true); setFrameStyle(QFrame::Box | QFrame::Plain); setLineWidth(2); setTimeStamp(timeStamp); move(x,y); show(); }
void TestDir::createFile(const QString& path, const QByteArray& data, const QDateTime& time) { QString absolutePath = path; makePathAbsoluteAndCreateParents(absolutePath); QFile f(absolutePath); f.open(QIODevice::WriteOnly); f.write(data); f.close(); if (time.isValid()) { setTimeStamp(absolutePath, time); } Q_ASSERT(QFile::exists(absolutePath)); }
LBDbWorkEntry::LBDbWorkEntry( const LQuery & cluster ) : LDbWorkEntry( cluster.readString( "barcode" ), cluster.readInt( "project_cid" ), cluster.readInt( "sample_id" ), cluster.readDateTime( "in_date" ), cluster.readInt( "test_id" ) ) { limits.setAnalyserID( cluster.readInt( "machine_cid" ) ); limits.setPrivate( cluster.readString( "private_result" ) == "Y" ); limits.setRange( cluster.readString( "min_value" ), cluster.readString( "max_value" ) ); limits.setWarnLevels( cluster.readString( "lower_warning" ), cluster.readString( "upper_warning" ) ); int trigger = cluster.readInt( "trigger_id" ); if( trigger != 0 ) { limits.setTriggerLimits( trigger, cluster.readString( "trigger_lower_limit" ), cluster.readString( "trigger_upper_limit" ) ); } int pid = 0; const LPDbProfiles & profiles = LPDbProfiles::records( getProjectID() ); if( !profiles.empty() ) { String reason = cluster.readString( "profile_name" ); if( reason.Length() > 3 && reason.Pos( "re-run" ) == 0 ) { const LPDbProfile * pp = profiles.findByName( reason ); if( pp != NULL ) pid = pp -> getID(); } } setProfileID( pid ); resultID = duplicate = cluster.readInt( "duplicate" ); if( duplicate < nextRerun ) nextRerun = duplicate - 1; // try to keep unique setCategoryID( cluster.readInt( "category_id" ) ); setTimeStamp( cluster.readDateTime( "time_stamp" ) ); if( cluster.readChar( "buddy_read" ) == LCDbWorkEntry::FINISHED ) setStage( LDbStage::TRANSMITTED ); else setStage( makeStage( cluster.readChar( "status" ) ) ); }
bool LBDbWorkEntry::updateRecord( LQuery cluster, LDbWorkEntry::Stage result ) { LBDbWorkEntry * cached = LBDbWorkList::records().find( *this ); TDateTime when = Now(); String update = "set status = :sts, time_stamp = :ts"; if( !isQC() && getCategoryID() != 0 ) update = update + ", category_id = " + getCategoryID(); if( resultID != 0 && resultID != duplicate ) update = update + ", duplicate = " + resultID; String condition = "test_id = :tid and duplicate = :did and barcode = :bar"; if( duplicate == 0 ) { int analyser = limits.getAnalyserID(); if( analyser == 0 ) condition += " and machine_cid in (" + listMachineIDs() + ")"; else condition += " and machine_cid = " + String( analyser ); } cluster.setSQL( "update buddy_worklist " + update + " where " + condition ); cluster.setParam( "bar", getBarcode() ); cluster.setParam( "did", duplicate ); cluster.setParam( "tid", limits.getID() ); cluster.setParam( "sts", makeStatus( result ) ); cluster.setParam( "ts", when ); if( cluster.execSQL() != 1 ) { return false; } setStage( result ); setTimeStamp( when ); if( resultID != 0 ) duplicate = resultID; if( cached != NULL ) *cached = *this; else LBDbWorkList::records().insert( *this ); return true; }
void Navigator_Dcm::updateSlow(float dt) { if (_board->getMode() != AP_Board::MODE_LIVE) return; setTimeStamp(micros()); // if running in live mode, record new time stamp if (_board->gps) { _board->gps->update(); updateGpsLight(); if (_board->gps->fix && _board->gps->new_data) { setLat_degInt(_board->gps->latitude); setLon_degInt(_board->gps->longitude); setGroundSpeed(_board->gps->ground_speed / 100.0); // gps is in cm/s } } if (_board->compass) { _board->compass->read(); _board->compass->calculate(_dcm.get_dcm_matrix()); _board->compass->null_offsets(_dcm.get_dcm_matrix()); //_board->debug->printf_P(PSTR("heading: %f"), _board->compass->heading); } }
LCDbWorkEntry::LCDbWorkEntry( const LQuery & central ) : LDbIdBase( central.readInt( "record_no" ) ), LDbWorkEntry( central.readString( "barcode" ), central.readInt( "project_cid" ), central.readInt( "sample_id" ), central.readDateTime( "in_date" ), central.readInt( "test_cid" ) ), groupID( central.readInt( "group_id" ) ), profileName( central.readString( "profile_name" ) ) { const LPDbProfile * pp = NULL; const LPDbProfiles & profiles = LPDbProfiles::records( getProjectID() ); if( !profiles.empty() ) { if( central.fieldExists( "profile_id" ) ) { int ppid = central.readInt( "profile_id" ); if( ppid != 0 ) pp = profiles.findByID( ppid ); } if( pp == NULL && profileName.Length() > 2 ) pp = profiles.findByName( profileName ); } setProfileID( pp == NULL ? 0 : pp -> getID() ); limits.setAnalyserID( central.readInt( "machine_cid" ) ); limits.setPrivate( central.readChar( "private_result" ) == 'Y' ); if( central.fieldExists( "min_value" ) && central.fieldExists( "max_value" ) ) { limits.setRange( central.readDouble( "min_value" ), central.readDouble( "max_value" ) ); } if( central.fieldExists( "lower_warning" ) && central.fieldExists( "upper_warning" ) ) { limits.setWarnLevels( central.readDouble( "lower_warning" ), central.readDouble( "upper_warning" ) ); } int trigger = central.readInt( "trigger_id" ); if( trigger != 0 && central.fieldExists( "lower_trigger_limit" ) && central.fieldExists( "upper_trigger_limit" ) ) { limits.setTriggerLimits( trigger, central.readDouble( "lower_trigger_limit" ), central.readDouble( "upper_trigger_limit" ) ); } setTimeStamp( central.readDateTime( "time_stamp" ) ); setCategoryID( central.readInt( "category_id" ) ); if( central.fieldExists( "buddy_result_id" ) ) setDilution( central.readDouble( "buddy_result_id" ) ); else setDilution( 0 ); if( central.fieldExists( "diluent" ) ) setDilution( central.readDouble( "diluent" ) ); else setDilution( 0 ); switch( central.readChar( "buddy_read" ) ) { case LCDbWorkEntry::COPIED: copied = true; setStage( makeStage( central.readChar( "status" ) ) ); break; case LCDbWorkEntry::HELD: copied = true; setStage( LDbStage::L0_HELD ); break; case LCDbWorkEntry::FINISHED: copied = true; setStage( LDbStage::TRANSMITTED ); break; default: copied = false; setStage( makeStage( central.readChar( "status" ) ) ); } }
bool LBDbWorkEntry::createRecord( LQuery cluster, String reason ) { int machine = limits.getAnalyserID(); if( machine == 0 ) { // QCs should stay on the same analyser; others on cluster machine = LCDbAnalysers::getCurrentID(); const LCDbAnalyser * an = LCDbAnalysers::records().findByID( machine ); if( an != NULL && !isQC() ) { std::set< int > machineIDs = an -> getClusterIDs(); if( !machineIDs.empty() ) machine = *(machineIDs.begin()); } limits.setAnalyserID( machine ); } if( reason.IsEmpty() && getProfileID() != 0 ) { const LPDbProfiles & profiles = LPDbProfiles::records( getProjectID() ); const LPDbProfile * pp = profiles.findByID( getProfileID() ); if( pp != NULL ) reason = pp -> getName(); } setTimeStamp( Now() ); char fromCentral = LCDbWorkEntry::NEW_RECORD; switch( getStage() ) { case NEW_ENTRY: break; case RE_RUN: resultID = nextRerun --; break; case TRIGGERED: resultID = TRIGGER_ID; break; default: fromCentral = LCDbWorkEntry::COPIED; } cluster.setSQL( "Insert into buddy_worklist (machine_cid, barcode, duplicate, test_name, test_id," " sample_id, range_set, min_value, max_value, status, project_cid, profile_name," " buddy_read, in_date, time_stamp, lower_warning, upper_warning, trigger_id," " trigger_lower_limit, trigger_upper_limit, private_result, delete_status, category_id)" " values ( :mid, :bar, :dup, :tnm, :tid, :aid, :rs, :min, :max, :sts, :prj," " :prn, :brd, :ind, :dts, :wlo, :wup, :trd, :tlo, :tup, :prv, 0, :cat )" ); cluster.setParam( "mid", machine ); cluster.setParam( "bar", getBarcode() ); cluster.setParam( "dup", resultID ); std::pair< int, int > specimen = getSpecimen(); cluster.setParam( "prj", specimen.first ); cluster.setParam( "aid", specimen.second ); const LCDbTest & test = LCDbTests::records().get( limits.getID() ); cluster.setParam( "tid", test.getID() ); cluster.setParam( "tnm", test.getName() ); cluster.setParam( "prn", reason ); std::pair< double, double > range = limits.getRange().asDoubles(); cluster.setParam( "min", range.first ); cluster.setParam( "max", range.second ); cluster.setParam( "rs", (range.first == 0 && range.second == 0) ? 'N' : 'Y' ); cluster.setParam( "sts", makeStatus( getStage() ) ); cluster.setParam( "brd", fromCentral ); cluster.setParam( "ind", getInDate() ); cluster.setParam( "dts", getTimeStamp() ); cluster.setParam( "trd", limits.getTriggerProfile() ); if( limits.getTriggerProfile() == 0 ) { cluster.setParam( "tup", "0" ); cluster.setParam( "tlo", "0" ); } else { range = limits.getTriggerLimits().asDoubles(); cluster.setParam( "tlo", range.first ); cluster.setParam( "tup", range.second ); } range = limits.getWarnLevels().asDoubles(); cluster.setParam( "wlo", range.first ); cluster.setParam( "wup", range.second ); cluster.setParam( "prv", limits.isPrivate() ? 'Y' : 'N' ); cluster.setParam( "cat", getCategoryID() ); if( cluster.execSQL() != 1 ) { return false; } duplicate = resultID; LBDbWorkList::records().insert( *this ); return true; }