bool WiimotePipeServerWrapper::sendWiimoteData(WiimoteData *wiimoteData1,WiimoteData *wiimoteData2,int sequenceNumber,DWORD current_time) { if(m_CommandPipeServer->isWiimoteLoggingOn()) { //If is false it indicates that logging was currently off. In that scenario when m_CommandPipeServer->isWiimoteLoggingOn() changes to true //it indicates logging request just came in. So need to initialize //For this case return right away and do not send packet as this packet is not initialized by the client. //The clietnt did not know before sending this message that recording was restarted if(!m_WiimoteLoggingOn) { startLogging(wiimoteData1,wiimoteData2); return true; } else sendDataPacket(wiimoteData1,wiimoteData2,sequenceNumber,current_time,false); } else { if(m_WiimoteLoggingOn) { stopLogging(); return WIIMOTE_LOGGING_STOPPED; } } logWiimoteData(wiimoteData1,wiimoteData2,sequenceNumber,current_time); return false; }
void ExperimentController::stop(const std::string &errorMessage) { { Poco::RWLock::ScopedWriteLock lock(*_machineMutex); if (_machineState == IdleMachineState) return; LidInstance::getInstance()->setEnableMode(false); HeatBlockInstance::getInstance()->setEnableMode(false); OpticsInstance::getInstance()->setCollectData(false); _experiment.setCompletionStatus(Experiment::Failed); _experiment.setCompletionMessage(errorMessage); _experiment.setCompletedAt(boost::posix_time::microsec_clock::local_time()); _dbControl->completeExperiment(_experiment); _machineState = IdleMachineState; _thermalState = IdleThermalState; _experiment = Experiment(); } stopLogging(); _holdStepTimer->stop(); _meltCurveTimer->stop(); }
void ExperimentController::stop() { MachineState state = IdleMachineState; { Poco::RWLock::ScopedWriteLock lock(*_machineMutex); if (_machineState == IdleMachineState) return; else if (_machineState == CompleteMachineState && _experiment.protocol()->currentStage()->type() != Stage::Meltcurve) { //Check if it was infinite hold step Stage *stage = _experiment.protocol()->currentStage(); std::time_t holdTime = stage->currentStep()->holdTime(); if (stage->autoDelta() && stage->currentCycle() > stage->autoDeltaStartCycle()) { holdTime += stage->currentStep()->deltaDuration() * (stage->currentCycle() - stage->autoDeltaStartCycle()); if (holdTime < 0) holdTime = 0; } if (holdTime == 0) _dbControl->addFluorescenceData(_experiment, OpticsInstance::getInstance()->getFluorescenceData()); } LidInstance::getInstance()->setEnableMode(false); HeatBlockInstance::getInstance()->setEnableMode(false); OpticsInstance::getInstance()->setCollectData(false); if (_machineState != CompleteMachineState) { _experiment.setCompletionStatus(Experiment::Aborted); _experiment.setCompletedAt(boost::posix_time::microsec_clock::local_time()); _dbControl->completeExperiment(_experiment); } state = _machineState; _machineState = IdleMachineState; _thermalState = IdleThermalState; _experiment = Experiment(); } if (state != CompleteMachineState) { stopLogging(); _holdStepTimer->stop(); _meltCurveTimer->stop(); } }
/** * Sets the file to use for logging and takes the parent plugin * to connect to stop logging signal * @param[in] file File name to write to * @param[in] parent plugin */ bool LoggingThread::openFile(QString file, LoggingPlugin * parent) { logFile.setFileName(file); logFile.open(QIODevice::WriteOnly); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); uavTalk = new UAVTalk(&logFile, objManager); connect(parent,SIGNAL(stopLoggingSignal()),this,SLOT(stopLogging())); return true; };
void LogSensor::answerReceived( int id, const QList<QByteArray>& answer ) //virtual { QFile mLogFile( mFileName ); if ( !mLogFile.open( QIODevice::ReadWrite | QIODevice::Append ) ) { stopLogging(); return; } switch ( id ) { case 42: { QTextStream stream( &mLogFile ); double value = 0; if ( !answer.isEmpty() ) value = answer[ 0 ].toDouble(); if ( mLowerLimitActive && value < mLowerLimit ) { timerOff(); mLimitReached = true; // send notification KNotification::event( "sensor_alarm", QString( "sensor '%1' at '%2' reached lower limit" ) .arg( mSensorName ).arg( mHostName), QPixmap(), 0 ); timerOn(); } else if ( mUpperLimitActive && value > mUpperLimit ) { timerOff(); mLimitReached = true; // send notification KNotification::event( "sensor_alarm", QString( "sensor '%1' at '%2' reached upper limit" ) .arg( mSensorName).arg( mHostName), QPixmap(), 0 ); timerOn(); } else { mLimitReached = false; } const QDate date = QDateTime::currentDateTime().date(); const QTime time = QDateTime::currentDateTime().time(); stream << QString( "%1 %2 %3 %4 %5: %6\n" ).arg( date.shortMonthName( date.month() ) ) .arg( date.day() ).arg( time.toString() ) .arg( mHostName).arg( mSensorName ).arg( value ); } } emit changed(); mLogFile.close(); }
bool ConsoleLineBuffer::startLogging(QString fileName) { if (logFile_ != nullptr) { stopLogging(); } logFile_ = new QFile(fileName); if (!logFile_->open(QIODevice::WriteOnly | QIODevice::Append)) { return false; } return true; }
void startLogging( unsigned int debugLevel, eLogDestination logDest, const char * logFile ) { gLogLevel = debugLevel; if (logDest != gLogDestination) { stopLogging(); switch (logDest) { case kLogToSyslog: setlogmask( LOG_UPTO (LOG_DEBUG) ); openlog( gLogName, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); gLogString = &_logToSyslog; break; case kLogToFile: gLogString = &_logToStderr; if (logFile != NULL) { gLogFile = fopen( logFile, "a" ); if (gLogFile != NULL) { gLogString = &_logToFile; } else { logDest = kLogToStderr; logError("Unable to log to \"%s\" (%s [%d]), redirecting to stderr", logFile, strerror(errno), errno); } } break; case kLogToStderr: gLogString = &_logToStderr; break; default: gLogString = &_logToTheVoid; break; } gLogDestination = logDest; } }
/** * The action that is triggered by the menu item which opens the * file and begins logging if successful */ void LoggingPlugin::toggleLogging() { if (state == IDLE) { QString fileName = QFileDialog::getSaveFileName(NULL, tr("Start Log"), tr("OP-%0.opl").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss")), tr("OpenPilot Log (*.opl)")); if (fileName.isEmpty()) { return; } startLogging(fileName); cmd->action()->setText(tr("Stop logging")); } else if (state == LOGGING) { stopLogging(); cmd->action()->setText(tr("Start logging...")); } }
void ExperimentController::toggleTempLogs(bool temperatureLogsState, bool debugTemperatureLogsState) { _settings.temperatureLogsState = temperatureLogsState; _settings.debugTemperatureLogsState = debugTemperatureLogsState; if (machineState() == IdleMachineState) { if (_settings.temperatureLogsState || _settings.debugTemperatureLogsState) { if (_settings.startTime == boost::posix_time::not_a_date_time) { _settings.startTime = boost::posix_time::microsec_clock::universal_time(); startLogging(); } } else stopLogging(); } }
AREXPORT bool ArServerSimpleLogRobotDebugPackets::startLogging(const char *fileName) { std::string realFileName; if (myFile != NULL) stopLogging(); if (fileName == NULL || fileName[0] == '\0') { ArLog::log(ArLog::Normal, "ArServerSimpleLogRobotDebugPackets::startLogging: Empty filename given, cannot log"); return false; } if (fileName[0] == '/' || fileName[0] == '\\') { realFileName = fileName; } else { realFileName = myBaseDir; realFileName += fileName; } if ((myFile = ArUtil::fopen(realFileName.c_str(), "w")) == NULL) { ArLog::log(ArLog::Terse, "ArServerSimpleLogRobotDebugPackets::startLogging: Could not open file %s for writing", realFileName.c_str()); return false; } ArLog::log(ArLog::Normal, "ArServerSimpleLogRobotDebugPackets::startLogging: Logging to file %s", realFileName.c_str()); myRobot->lock(); myRobot->comInt(251, 1); myRobot->unlock(); return true; }
/** * The action that is triggered by the menu item which opens the * file and begins logging if successful */ void LoggingPlugin::toggleLogging() { if(state == IDLE) { /*QFileDialog * fd = new QFileDialog(); fd->setAcceptMode(QFileDialog::AcceptSave); fd->setNameFilter("OpenPilot Log (*.opl)"); connect(fd, SIGNAL(fileSelected(QString)), this, SLOT(startLogging(QString))); fd->exec();*/ QString fileName = QFileDialog::getSaveFileName(NULL, tr("Start Log"), tr("OP-%0.opl").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss")), tr("OpenPilot Log (*.opl)")); if(!fileName.isEmpty()) startLogging(fileName); } else if(state == LOGGING) { stopLogging(); } }
void auto_logger_gps_sample_cb(const GpsSample* sample) { if (!auto_logger_state.cfg || !auto_logger_state.cfg->active) return; const tiny_millis_t uptime = getUptime(); if (!auto_logger_state.logging) { if (!should_start_logging(sample, uptime)) return; pr_info(LOG_PFX "Starting logging\r\n"); startLogging(); auto_logger_state.logging = true; } else { if (!should_stop_logging(sample, uptime)) return; pr_info(LOG_PFX "Stopping logging\r\n"); stopLogging(); auto_logger_state.logging = false; } }
ExperimentController::StartingResult ExperimentController::start(int experimentId) { if (OpticsInstance::getInstance()->lidOpen()) return LidIsOpen; Experiment experiment = _dbControl->getExperiment(experimentId); if (experiment.empty() || !experiment.protocol()) return ExperimentNotFound; else if (experiment.startedAt() != boost::posix_time::not_a_date_time) return ExperimentUsed; experiment.setStartedAt(boost::posix_time::microsec_clock::local_time()); if (machineState() != IdleMachineState) return MachineRunning; stopLogging(); { Poco::RWLock::ScopedWriteLock lock(*_machineMutex); _settings.temperatureLogsState = false; _settings.debugTemperatureLogsState = false; LidInstance::getInstance()->setTargetTemperature(experiment.protocol()->lidTemperature()); _dbControl->startExperiment(experiment); _machineState = LidHeatingMachineState; _experiment = std::move(experiment); LidInstance::getInstance()->setEnableMode(true); } startLogging(); return Started; }
void ExperimentController::complete() { { Poco::RWLock::ScopedWriteLock lock(*_machineMutex); if (_machineState != RunningMachineState) return; _machineState = CompleteMachineState; _thermalState = IdleThermalState; LidInstance::getInstance()->setEnableMode(false); OpticsInstance::getInstance()->setCollectData(false); _experiment.setCompletionStatus(Experiment::Success); _experiment.setCompletedAt(boost::posix_time::microsec_clock::local_time()); _dbControl->completeExperiment(_experiment); } stopLogging(); }
void ptpdShutdown(PtpClock * ptpClock) { extern RunTimeOpts rtOpts; /* * go into DISABLED state so the FSM can call any PTP-specific shutdown actions, * such as canceling unicast transmission */ toState(PTP_DISABLED, &rtOpts, ptpClock); netShutdown(&ptpClock->netPath); free(ptpClock->foreign); /* free management and signaling messages, they can have dynamic memory allocated */ if(ptpClock->msgTmpHeader.messageType == MANAGEMENT) freeManagementTLV(&ptpClock->msgTmp.manage); freeManagementTLV(&ptpClock->outgoingManageTmp); if(ptpClock->msgTmpHeader.messageType == SIGNALING) freeSignalingTLV(&ptpClock->msgTmp.signaling); freeSignalingTLV(&ptpClock->outgoingSignalingTmp); #ifdef PTPD_SNMP snmpShutdown(); #endif /* PTPD_SNMP */ #ifndef PTPD_STATISTICS /* Not running statistics code - write observed drift to driftfile if enabled, inform user */ if(ptpClock->slaveOnly && !ptpClock->servo.runningMaxOutput) saveDrift(ptpClock, &rtOpts, FALSE); #else ptpClock->oFilterMS.shutdown(&ptpClock->oFilterMS); ptpClock->oFilterSM.shutdown(&ptpClock->oFilterSM); freeDoubleMovingStatFilter(&ptpClock->filterMS); freeDoubleMovingStatFilter(&ptpClock->filterSM); /* We are running statistics code - save drift on exit only if we're not monitoring servo stability */ if(!rtOpts.servoStabilityDetection && !ptpClock->servo.runningMaxOutput) saveDrift(ptpClock, &rtOpts, FALSE); #endif /* PTPD_STATISTICS */ if (rtOpts.currentConfig != NULL) dictionary_del(&rtOpts.currentConfig); if(rtOpts.cliConfig != NULL) dictionary_del(&rtOpts.cliConfig); timerShutdown(ptpClock->timers); free(ptpClock); ptpClock = NULL; extern PtpClock* G_ptpClock; G_ptpClock = NULL; /* properly clean lockfile (eventough new deaemons can acquire the lock after we die) */ if(!rtOpts.ignore_daemon_lock && G_lockFilePointer != NULL) { fclose(G_lockFilePointer); G_lockFilePointer = NULL; } unlink(rtOpts.lockFile); if(rtOpts.statusLog.logEnabled) { /* close and remove the status file */ if(rtOpts.statusLog.logFP != NULL) { fclose(rtOpts.statusLog.logFP); rtOpts.statusLog.logFP = NULL; } unlink(rtOpts.statusLog.logPath); } stopLogging(&rtOpts); }
void Window::createActions() { quitAction = new QAction(tr("&Quit"), this); quitAction->setIcon(QIcon(":/img/exit.png")); startAction = new QAction(tr("Sta&rt Logging"), this); startAction->setIcon(QIcon(":/img/start.png")); stopAction = new QAction(tr("&Stop Logging"), this); stopAction->setIcon(QIcon(":/img/stop.png")); profileAction = new QAction(tr("&Profile"), this); profileAction->setIcon(QIcon(":/img/profile.png")); histogramAction = new QAction(tr("Norm by &histogram"), this); histogramAction->setIcon(QIcon(":/img/histogram.png")); chiAction = new QAction(tr("&Chi-square probability count"), this); chiAction->setIcon(QIcon(":/img/chisquare.png")); medianAction = new QAction(tr("&Median filtering"), this); medianAction->setIcon(QIcon(":/img/filter16.png")); clearCleanAction = new QAction(tr("Delete clean logs"), this); clearCleanAction->setIcon(QIcon(":/img/filter_delete.png")); stopAction->setEnabled(false); //medianAction->setEnabled(false); quitAction->setShortcut(Qt::ALT + Qt::Key_Q); startAction->setShortcut(Qt::ALT + Qt::Key_R); stopAction->setShortcut(Qt::ALT + Qt::Key_S); profileAction->setShortcut(Qt::ALT + Qt::Key_P); histogramAction->setShortcut(Qt::ALT + Qt::Key_H); chiAction->setShortcut(Qt::ALT + Qt::Key_C); medianAction->setShortcut(Qt::ALT + Qt::Key_M); QObject::connect(profileAction, SIGNAL(triggered()), this, SLOT(changeProfile())); QObject::connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); QObject::connect(startAction, SIGNAL(triggered()), controller, SLOT(startLogging())); QObject::connect(stopAction, SIGNAL(triggered()), controller, SLOT(stopLogging())); QObject::connect(startAction, SIGNAL(triggered()), this, SLOT(startedLogging())); QObject::connect(stopAction, SIGNAL(triggered()), this, SLOT(stoppedLogging())); QObject::connect(controller, SIGNAL(showInfo(Log)), this, SLOT(appendLog(Log))); QObject::connect(controller, SIGNAL(showInfo(const QString&)), this, SLOT(appendLog(const QString&))); QObject::connect(histogramAction, SIGNAL(triggered()), this, SLOT(startHist())); QObject::connect(chiAction, SIGNAL(triggered()), this, SLOT(startChi())); QObject::connect(medianAction, SIGNAL(triggered()), this, SLOT(startMedian())); QObject::connect(clearCleanAction, SIGNAL(triggered()), this, SLOT(clearClean())); }
LoggingThread::~LoggingThread() { stopLogging(); }
void WiimotePipeServerWrapper::setWiimoteConnectionState(WiimoteData *remote1,WiimoteData *remote2) { if(remote1->getConnectionState() == WIIMOTE_DISCONNECTED_STATE || remote1->getConnectionState() == WIIMOTE_BAD_DATA_STATE) stopLogging(); }
int Lua_StopLogging(lua_State *L) { stopLogging(); return 0; }