// Called whenever the connection state of any PV changes: emits valuesChanged(), sizeChanged(), and stateChanged() as required.
void REIXSXESMCPDataSourcePre2013::onConnectionStateChanged() {
	bool wasConnected = isConnected_;

	isConnected_ = imagePV_->isConnected() &&
				   resolutionXPV_->hasValues() &&
				   resolutionYPV_->hasValues();

	// becoming disconnected...
	if(wasConnected && !isConnected_) {
		pixelsX_ = axes_[0].size = 0;
		pixelsY_ = axes_[1].size = 0;
		emitValuesChanged();
		emitSizeChanged();
		emitStateChanged(AMDataSource::InvalidFlag);

		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -2, "Lost connection to MCP Detector " + imagePV_->pvName()));
	}

	// becoming connected...
	if(!wasConnected && isConnected_) {
		pixelsX_ = axes_[0].size = int(pow(2.0, double(resolutionXPV_->getInt())));
		pixelsY_ = axes_[1].size = int(pow(2.0, double(resolutionYPV_->getInt())));
		emitValuesChanged();
		emitSizeChanged();
		emitStateChanged(AMDataSource::ProcessingFlag);
	}
}
// Connected to be called when the size of the input source changes
void AM2DDeadTimeAB::onInputSourceSizeChanged()
{
	if(axes_.at(0).size != spectra_->size(0)){

		axes_[0].size = spectra_->size(0);
		emitSizeChanged(0);
	}

	if(axes_.at(1).size != spectra_->size(1)){

		axes_[1].size = spectra_->size(1);
		emitSizeChanged(1);
	}
}
Exemple #3
0
// Connected to be called when the size of the input source changes
void AM2DAdditionAB::onInputSourceSizeChanged()
{
	if(axes_.at(0).size != sources_.at(0)->size(0)){

		axes_[0].size = sources_.at(0)->size(0);
		emitSizeChanged(0);
	}

	if(axes_.at(1).size != sources_.at(0)->size(1)){

		axes_[1].size = sources_.at(0)->size(1);
		emitSizeChanged(1);
	}
}
Exemple #4
0
// Set the data source inputs.
void AM2DAdditionAB::setInputDataSourcesImplementation(const QList<AMDataSource*>& dataSources)
{
	// disconnect connections from old sources, if they exist.
	if(!sources_.isEmpty()) {

		for (int i = 0; i < sources_.size(); i++){

			disconnect(sources_.at(i)->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex)));
			disconnect(sources_.at(i)->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged()));
			disconnect(sources_.at(i)->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged()));
		}
	}

	if(dataSources.isEmpty()) {

		sources_.clear();
		axes_[0] = AMAxisInfo("invalid", 0, "No input data");
		axes_[1] = AMAxisInfo("invalid", 0, "No input data");

		setDescription("-- No input data --");
	}

	// we know that this will only be called with valid input source
	else {

		sources_ = dataSources;

		axes_[0] = sources_.at(0)->axisInfoAt(0);
		axes_[1] = sources_.at(0)->axisInfoAt(1);

		setDescription(QString("Sum of %1").arg(sources_.at(0)->description()));

		for (int i = 0; i < sources_.size(); i++){

			connect(sources_.at(i)->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex)));
			connect(sources_.at(i)->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged()));
			connect(sources_.at(i)->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged()));
		}
	}

	reviewState();

	emitSizeChanged(0);
	emitSizeChanged(1);
	emitValuesChanged();
	emitAxisInfoChanged(0);
	emitAxisInfoChanged(1);
	emitInfoChanged();
}
void AMnDDeadTimeAB::onInputSourceSizeChanged()
{
	for (int i = 0, size = rank(); i < size; i++){

			axes_[i] = spectrum_->axisInfoAt(i);
			emitSizeChanged(i);
	}
}
void AMNormalizationAB::onInputSourceSizeChanged()
{
	for (int i = 0, size = rank(); i < size; i++)
		axes_[i].size = sources_.at(0)->size(i);

	cacheUpdateRequired_ = true;
	cachedData_ = QVector<double>(size().product());
	emitSizeChanged();
}
bool AMExternalScanDataSourceAB::refreshData()
{
	AMDbObject* dbObject = 0;
	AMnDIndex oldSize = size();

	try {
		// We might have a scan_ loaded already from the constructor. If not, attempt to load ourselves.
		if(!scan_) {
			dbObject = AMDbObjectSupport::s()->createAndLoadObjectAt(sourceDb_,
															 AMDbObjectSupport::s()->tableNameForClass<AMScan>(),
															 sourceScanId_);
			scan_ = qobject_cast<AMScan*>(dbObject);
			if(!scan_)
				throw -1;
		}
		scan_->retain(this);

		int dataSourceIndex = scan_->indexOfDataSource(sourceDataSourceName_);
		if(dataSourceIndex < 0)
			throw -2;

		// get the axes from the source data. Since we're using AMStandardAnalysisBlock, this will automatically expose everything we need.
		axes_ = scan_->dataSourceAt(dataSourceIndex)->axes();

		// grab the data
		copyValues(dataSourceIndex);
		copyAxisValues(dataSourceIndex);

		setState(scan_->dataSourceAt(dataSourceIndex)->state());

		// delete the scan
		scan_->release(this);
		scan_ = 0;

		// signalling:

		emitAxisInfoChanged();
		if(oldSize != size())
			emitSizeChanged();
		emitValuesChanged();

		return true;
	}
	catch(int errCode) {
		if(dbObject)
			delete dbObject;
		if(scan_) {
			scan_->release(this);
			scan_ = 0;
		}
		setState(AMDataSource::InvalidFlag);
		AMErrorMon::report(AMErrorReport(this, AMErrorReport::Serious, errCode, "Could not load external scan data."));
		return false;
	}
}
void AMNormalizationAB::setInputDataSourcesImplementation(const QList<AMDataSource *> &dataSources)
{
	// disconnect connections from old sources, if they exist.
	if(!sources_.isEmpty()) {

		for (int i = 0; i < sources_.size(); i++){

			disconnect(sources_.at(i)->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex)));
			disconnect(sources_.at(i)->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged()));
			disconnect(sources_.at(i)->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged()));
		}
	}

	if(dataSources.isEmpty()) {

		sources_.clear();
		axes_.clear();
		setDescription("-- No input data --");
	}

	// we know that this will only be called with valid input source
	/*
	else {

		sources_ = dataSources;
		axes_.clear();

		for (int i = 0, size = sources_.at(0)->rank(); i < size; i++)
			axes_.append(sources_.at(0)->axisInfoAt(i));

		cacheUpdateRequired_ = true;
		cachedData_ = QVector<double>(size().product());

		setDescription(QString("Sum of spectra from %1 maps").arg(sources_.size()));

		for (int i = 0; i < sources_.size(); i++){

			connect(sources_.at(i)->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex)));
			connect(sources_.at(i)->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged()));
			connect(sources_.at(i)->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged()));
		}
	}
	*/
	else {
		sources_ = dataSources;
		setInputSources();
	}

	reviewState();

	emitSizeChanged();
	emitValuesChanged(AMnDIndex(0), size()-1);
	emitAxisInfoChanged();
	emitInfoChanged();
}
void REIXSXESImageInterpolationAB::setInputDataSourcesImplementation(const QList<AMDataSource *> &dataSources)
{
	// disconnect connections from old source, if it exists.
	if(inputSource_) {
		disconnect(inputSource_->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex)));
		disconnect(inputSource_->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged()));
		disconnect(inputSource_->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged()));
		inputSource_ = 0;
	}

	if(dataSources.isEmpty()) {
		inputSource_ = 0;
		sources_.clear();

		axes_[0] = AMAxisInfo("invalid", 0, "No input data");
	}

	// we know that this will only be called with one valid input source
	else {
		inputSource_ = dataSources.at(0);
		sources_ = dataSources;

		axes_[0] = inputSource_->axisInfoAt(0);	// take the X axis info from the data source.
		axes_[0].description = "Emission Energy";
		axes_[0].units = "eV";
		axes_[0].size /= binningLevel_;

		cacheUpdateRequired_ = true;
		axisValueCacheInvalid_ = true;
		cachedData_ = QVector<double>(axes_.at(0).size);
		cachedAxisValues_ = QVector<double>(axes_.at(0).size);

		if(shiftValues1_.isEmpty()) {
			for(int i=0,cc=inputSource_->size(1); i<cc; i++)
				shiftValues1_ << 0;	// make a null shift list, matching the size of the input data. Don't do this if we already have a shift list.
		}
		if(shiftValues2_.isEmpty()) {
			for(int i=0,cc=inputSource_->size(1); i<cc; i++)
				shiftValues2_ << 0;	// make a null shift list, matching the size of the input data. Don't do this if we already have a shift list.
		}


		connect(inputSource_->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex)));
		connect(inputSource_->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged()));
		connect(inputSource_->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged()));

	}

	reviewState();

	emitSizeChanged();
	emitValuesChanged();
	emitAxisInfoChanged();
	emitInfoChanged();
}
void AM3DDeadTimeCorrectionAB::onInputSourceSizeChanged()
{
	if (axes_.at(0).size != spectra_->size(0)){

		axes_[0].size = spectra_->size(0);
		emitSizeChanged(0);
	}

	if (axes_.at(1).size != spectra_->size(1)){

		axes_[1].size = spectra_->size(1);
		emitSizeChanged(1);
	}

	if (axes_.at(2).size != spectra_->size(2)){

		axes_[2].size = spectra_->size(2);
		emitSizeChanged(2);
	}
}
Exemple #11
0
// Connected to be called when the size of the input source changes
void AM3DAdditionAB::onInputSourceSizeChanged()
{
    axes_[0].size = sources_.at(0)->size(0);
    axes_[1].size = sources_.at(0)->size(1);
    axes_[2].size = sources_.at(0)->size(2);

    cacheUpdateRequired_ = true;
    dirtyIndices_.clear();
    cachedData_ = QVector<double>(size().product());
    emitSizeChanged();
}
// Set the data source inputs.
void AM1DRunningAverageFilterAB::setInputDataSourcesImplementation(const QList<AMDataSource*>& dataSources) {

	// disconnect connections from old source, if it exists.
	if(inputSource_) {
		disconnect(inputSource_->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex)));
		disconnect(inputSource_->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged()));
		disconnect(inputSource_->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged()));
	}

	if(dataSources.isEmpty()) {
		inputSource_ = 0;
		sources_.clear();

		axes_[0] = AMAxisInfo("invalid", 0, "No input data");
		setDescription("-- No input data --");
	}

	// we know that this will only be called with valid input source
	else {
		inputSource_ = dataSources.at(0);
		sources_ = dataSources;

		axes_[0] = inputSource_->axisInfoAt(0);

		setDescription(QString("Running Average of %1")
					   .arg(inputSource_->name()));

		connect(inputSource_->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex)));
		connect(inputSource_->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged()));
		connect(inputSource_->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged()));

	}

	reviewState();

	emitSizeChanged(0);
	emitValuesChanged();
	emitAxisInfoChanged(0);
	emitInfoChanged();
}
/// Connected to be called when the size of the input source changes
void AM1DRunningAverageFilterAB::onInputSourceSizeChanged() {
	axes_[0].size = inputSource_->size(0);
	emitSizeChanged(0);
}
Exemple #14
0
// Connected to be called when the size of the input source changes
void AM1DSummingAB::onInputSourceSizeChanged()
{
	axes_[0] = sources_.at(0)->axisInfoAt(0);

	emitSizeChanged();
}
/// Connected to be called when the size of the input source changes
void AM1DInterpolationAB::onInputSourceSizeChanged() {
	axes_[0].size = inputSource_->size(0);
	emitSizeChanged(0);
}
Exemple #16
0
// Connected to be called when the size of the input source changes
void AMDeadTimeAB::onInputSourceSizeChanged()
{
	axes_[0] = spectra_->axisInfoAt(0);
	emitSizeChanged();
}