コード例 #1
0
AMScanConfiguration* AMBeamlineScanAction::cfg() const {
    if(cfg_)
        return cfg_;

    // turn off automatic raw-day loading for scans... This will make loading the scan to access it's config much faster.
    bool scanAutoLoadingOn = AMScan::autoLoadData();
    AMScan::setAutoLoadData(false);
    // Dynamically create and load a detailed subclass of AMDbObject from the database... whatever type it is.
    AMDbObject* dbo = AMDbObjectSupport::s()->createAndLoadObjectAt(AMDatabase::database("user"), AMDbObjectSupport::s()->tableNameForClass<AMScan>(), scanID_);
    if(!dbo)
        return 0; //NULL
    // restore AMScan's auto-loading of data to whatever it was before.
    AMScan::setAutoLoadData(scanAutoLoadingOn);
    // Is it a scan?
    AMScan* scan = qobject_cast<AMScan*>( dbo );
    if(!scan) {
        delete dbo;
        return 0; //NULL
    }
    // Does the scan have a configuration?
    AMScanConfiguration* config = scan->scanConfiguration();
    if(!config) {
        scan->release();
        return 0; //NULL
    }
    // need to create a copy of the config so we can delete the scan (and hence the config instance owned by the scan). The view will take ownership of the copy.
    config = config->createCopy();
    scan->release();
    if(!config)
        return 0; //NULL
    cfg_ = config;
    return cfg_;
}
コード例 #2
0
AMScanConfiguration *AMScanActionInfo::getConfigurationFromDb() const
{
    // no need to bother if we don't have a scan id to use
    if(scanID_ == -1)
        return 0; //NULL

    // turn off automatic raw-data loading for scans... This will make loading the scan to access it's config much faster.
    bool scanAutoLoadingOn = AMScan::autoLoadData();
    AMScan::setAutoLoadData(false);
    // Dynamically create and load a detailed subclass of AMDbObject from the database... whatever type it is.
    AMDbObject* dbo = AMDbObjectSupport::s()->createAndLoadObjectAt(AMDatabase::database("user"), AMDbObjectSupport::s()->tableNameForClass<AMScan>(), scanID_);
    if(!dbo) {

        AMErrorMon::alert(this, AMSCANACTIONINFO_CANNOT_LOAD_FROM_DB, "Could not load scan from the database.");
        return 0; //NULL
    }

    // restore AMScan's auto-loading of data to whatever it was before.
    AMScan::setAutoLoadData(scanAutoLoadingOn);
    // Is it a scan?
    AMScan* scan = qobject_cast<AMScan*>( dbo );
    if(!scan) {

        AMErrorMon::alert(this, AMSCANACTIONINFO_DB_OBJECT_NOT_A_SCAN, "Object loaded from the database was not a scan.");
        dbo->deleteLater();
        return 0; //NULL
    }
    // Does the scan have a configuration?
    AMScanConfiguration* config = scan->scanConfiguration();
    if(!config) {

        AMErrorMon::alert(this, AMSCANACTIONINFO_SCAN_HAS_NO_CONFIGURATION, "Scan does not have a valid scan configuration.");
        scan->deleteLater();
        return 0; //NULL
    }
    // need to create a copy of the config so we can delete the scan (and hence the config instance owned by the scan). The view will take ownership of the copy.
    config = config->createCopy();
    scan->deleteLater();

    if(!config) {

        AMErrorMon::alert(this, AMSCANACTIONINFO_CREATE_CONFIGURATION_COPY_FAILED, "Failed to create a copy of the scan configuration.");
    }

    return config;
}
コード例 #3
0
void AMAppController::launchScanConfigurationFromDb(const QUrl &url)
{
	// turn off automatic raw-day loading for scans... This will make loading the scan to access it's config much faster.
	bool scanAutoLoadingOn = AMScan::autoLoadData();
	AMScan::setAutoLoadData(false);

	AMScan* scan = AMScan::createFromDatabaseUrl(url, true);

	// restore AMScan's auto-loading of data to whatever it was before.
	AMScan::setAutoLoadData(scanAutoLoadingOn);

	if(!scan)
		return;


	// need to check that this scan actually has a valid config. This hasn't always been guaranteed, especially when scans move between beamlines.
	AMScanConfiguration* config = scan->scanConfiguration();
	if(!config) {
		scan->deleteLater();
		return;
	}
	// need to create a copy of the config so we can delete the scan (and hence the config instance owned by the scan). The view will take ownership of the copy.
	config = config->createCopy();
	scan->deleteLater();
	if(!config)
		return;

	AMScanConfigurationView *view = config->createView();
	if(!view) {
		config->deleteLater();
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -401, "Unable to create view from the scan configuration loaded from the database.  Contact Acquaman developers."));
		return;
	}

	// This is Actions3 stuff.
	AMScanConfigurationViewHolder3 *viewHolder = new AMScanConfigurationViewHolder3(view);
	viewHolder->setAttribute(Qt::WA_DeleteOnClose, true);
	viewHolder->show();
}