bool SGMSSAAppController::startup() { // Initialize AMBeamline::bl() as an SGMBeamline::sgm() instance. FIRST! SGMBeamline::sgm(); if(AMAppController::startup()) { // Testing and making the first run in the database, if there isn't one already. Make this it's own function if you think startup() is getting too big ; ) //////////////////////////////////////// AMRun existingRun; if(!existingRun.loadFromDb(AMDatabase::database("user"), 1)) { // no run yet... let's create one. AMRun firstRun("SGM", 3); /// \todo For now, we know that 5 is the ID of the REIXS facility, but this is a hardcoded hack. firstRun.storeToDb(AMDatabase::database("user")); } // Create panes in the main window: //////////////////////////////////// mw_->insertHeading("Beamline Control", 0); ////////// /* samplePositionView_ = new AMSampleManagementWidget(new SGMSampleManipulatorView(), QUrl("http://ccd1611-403/axis-cgi/mjpg/video.cgi?resolution=1280x1024&.mjpg"), SGMBeamline::sgm()->currentSamplePlate()); mw_->addPane(samplePositionView_, "Beamline Control", "SGM Sample Position", ":/system-software-update.png"); connect(samplePositionView_, SIGNAL(newSamplePlateSelected(AMSamplePlate*)), SGMBeamline::sgm(), SLOT(setCurrentSamplePlate(AMSamplePlate*))); connect(SGMBeamline::sgm(), SIGNAL(currentSamplePlateChanged(AMSamplePlate*)), workflowManagerView_, SLOT(setCurrentSamplePlate(AMSamplePlate*))); */ sampleManipulatorView_ = new SGMSampleManipulatorView(true); mw_->addPane(sampleManipulatorView_, "Beamline Control", "SGM Sample Position", ":/system-software-update.png"); connect(SGMBeamline::sgm(), SIGNAL(criticalControlsConnectionsChanged()), this, SLOT(onSGMBeamlineConnected())); /*! \todo: hook up bottom-bar signals to the active scan controller. void MainWindow::onScanControllerReady(AMScanController *scanController){ connect(bottomBar_, SIGNAL(pauseScanIssued()), scanController, SLOT(pause())); connect(bottomBar_, SIGNAL(stopScanIssued()), scanController, SLOT(cancel())); connect(scanController, SIGNAL(progress(double,double)), bottomBar_, SLOT(updateScanProgress(double,double))); } */ sgmSidebar_ = new SGMSidebar(); mw_->addRightWidget(sgmSidebar_); mw_->move(0, 0); return true; } else return false; }
void AMScanDatabaseImportController::copyRuns() { if(state_ != Importing) return; emit progressDescription("Copying Runs..."); emit stepProgress(-1); int totalSteps = s2dRunIds_.count(); int currentStep = 0; QMutableMapIterator<int, int> i(s2dRunIds_); while (i.hasNext()) { if(state_ != Importing) return; i.next(); emit stepProgress(int(100.0*(++currentStep)/totalSteps)); // key is id; value is id in destination database, or -1 if not there yet. (if not there, need to insert) int sourceId = i.key(), destinationId = i.value(); if(destinationId<1) { AMRun r; r.loadFromDb(sourceDb_, sourceId); r.setFacilityId(s2dFacilityIds_.value(r.facilityId())); if(r.storeToDb(destinationDb_)) i.setValue(r.id()); else AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -2, "Could not import the run '" % sourceRuns_.value(sourceId) % "' into the database.")); } qApp->sendPostedEvents(); qApp->processEvents(); } }