AMNumber AMScalerTimeControlDetector::reading(const AMnDIndex &indexes) const
{
	if(!isConnected())
		return AMNumber(AMNumber::Null);
	// We want an "invalid" AMnDIndex for this 0D detector
	if(indexes.isValid())
		return AMNumber(AMNumber::DimensionError);

	return control_->value()/1000;
}
Esempio n. 2
0
AMNumber AM1DInterpolationAB::axisValue(int axisNumber, int index) const{

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	if(axisNumber != 0)
		return AMNumber(AMNumber::DimensionError);

	return inputSource_->axisValue(0, index);

}
AMNumber AM1DRunningAverageFilterAB::axisValue(int axisNumber, int index) const{

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	if(axisNumber != 0)
		return AMNumber(AMNumber::DimensionError);

	return inputSource_->axisValue(0, index);

}
Esempio n. 4
0
AMNumber AM3DAdditionAB::axisValue(int axisNumber, int index) const
{
	if (!isValid())
		return AMNumber(AMNumber::InvalidError);

	if (axisNumber != 0 && axisNumber != 1 && axisNumber != 2)
		return AMNumber(AMNumber::DimensionError);

	if (index >= axes_.at(axisNumber).size)
		return AMNumber(AMNumber::DimensionError);

	return sources_.at(0)->axisValue(axisNumber, index);
}
Esempio n. 5
0
AMNumber AMNormalizationAB::axisValue(int axisNumber, int index) const
{
	if (!isValid())
		return AMNumber(AMNumber::InvalidError);

	if (axisNumber < 0 && axisNumber >= rank())
		return AMNumber(AMNumber::DimensionError);

	if (index >= axes_.at(axisNumber).size)
		return AMNumber(AMNumber::DimensionError);

	return sources_.at(0)->axisValue(axisNumber, index);
}
AMNumber AM3DDeadTimeCorrectionAB::axisValue(int axisNumber, int index) const
{
	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	if(axisNumber != 0 && axisNumber != 1 && axisNumber != 2)
		return AMNumber(AMNumber::DimensionError);

	if (index >= spectra_->size(axisNumber))
		return AMNumber(AMNumber::OutOfBoundsError);

	return spectra_->axisValue(axisNumber, index);
}
Esempio n. 7
0
// Returns the dependent value at a (complete) set of axis indexes. Returns an invalid AMNumber if the indexes are insuffient or any are out of range, or if the data is not ready.
AMNumber AM1DExpressionAB::value(const AMnDIndex& indexes) const {
	if(!isValid())	// will catch most invalid situations: non matching sizes, invalid inputs, invalid expressions.
		return AMNumber(AMNumber::InvalidError);

	if(indexes.rank() != 1)
		return AMNumber(AMNumber::DimensionError);

#ifdef AM_ENABLE_BOUNDS_CHECKING
		if(indexes.i() < 0 || indexes.i() >= size_)
			return AMNumber(AMNumber::OutOfBoundsError);
#endif


	// can we get it directly? Single-value expressions don't require the parser.
	if(direct_) {
		// info on which variable to use is contained in directVar_.
		if(directVar_.useAxisValue)
			return sources_.at(directVar_.sourceIndex)->axisValue(0, indexes.i());
		else
			return sources_.at(directVar_.sourceIndex)->value(indexes);
	}

	// otherwise we need the parser
	else {
		// copy the new input data values into parser storage
		for(int i=0; i<usedVariables_.count(); i++) {
			AMParserVariable* usedVar = usedVariables_.at(i);
			if(usedVar->useAxisValue)
				usedVar->value = sources_.at(usedVar->sourceIndex)->axisValue(0, indexes.i());
			else
				usedVar->value = sources_.at(usedVar->sourceIndex)->value(indexes);
		}

		// evaluate using the parser:
		double rv;
		try {
			rv = parser_.Eval();
		}
		catch(mu::Parser::exception_type& e) {
			QString explanation = QString("AM1DExpressionAB Analysis Block: error evaluating value: %1: '%2'.  We found '%3' at position %4.").arg(QString::fromStdString(e.GetMsg()), QString::fromStdString(e.GetExpr()), QString::fromStdString(e.GetToken())).arg(e.GetPos());
			AMErrorMon::report(AMErrorReport(this, AMErrorReport::Debug, e.GetCode(), explanation));
			return AMNumber(AMNumber::InvalidError);
		}

		if (rv == std::numeric_limits<qreal>::infinity() || rv == -std::numeric_limits<qreal>::infinity() || rv == std::numeric_limits<qreal>::quiet_NaN())
			return 0;

		return rv;
	}
}
Esempio n. 8
0
AMNumber AM1DSummingAB::axisValue(int axisNumber, int index) const
{
	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	if(axisNumber != 0)
		return AMNumber(AMNumber::DimensionError);

#ifdef AM_ENABLE_BOUNDS_CHECKING
	if (index >= sources_.first()->size(0))
		return AMNumber(AMNumber::OutOfBoundsError);
#endif

	return sources_.first()->axisValue(0, index);
}
Esempio n. 9
0
AMNumber AM2DDeadTimeAB::axisValue(int axisNumber, int index) const
{
	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	if(axisNumber != 0 && axisNumber != 1)
		return AMNumber(AMNumber::DimensionError);

#ifdef AM_ENABLE_BOUNDS_CHECKING
	if (index >= spectra_->size(1))
		return AMNumber(AMNumber::OutOfBoundsError);
#endif

	return spectra_->axisValue(axisNumber, index);
}
Esempio n. 10
0
AMNumber CLSQE65000Detector::reading(const AMnDIndex &indexes) const{
	if( (!isConnected()) || (indexes.rank() != 1) || (indexes.i() > 1024) )
		return AMNumber(AMNumber::DimensionError);

	AMReadOnlyPVControl *tmpControl = qobject_cast<AMReadOnlyPVControl*>(spectrumControl_);
	return tmpControl->readPV()->lastIntegerValues().at(indexes.i());
}
AMNumber REIXSXESImageInterpolationAB::axisValue(int axisNumber, int index) const
{
	if((axisNumber != 0))
		return AMNumber(AMNumber::DimensionError);

	if(((unsigned)index >= (unsigned)axes_.at(0).size))
		return AMNumber(AMNumber::OutOfBoundsError);

	if(axisValueCacheInvalid_)
		computeCachedAxisValues();

	if(axisValuesInvalid_)
		return index;

	return cachedAxisValues_.at(index);
}
AMNumber REIXSXESImageInterpolationAB::value(const AMnDIndex &indexes) const
{
	if((indexes.rank() != 1))
		return AMNumber(AMNumber::DimensionError);

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	if(((unsigned long)indexes.i() >= (unsigned long)axes_.at(0).size))
		return AMNumber(AMNumber::OutOfBoundsError);

	if(cacheUpdateRequired_)
		computeCachedValues();

	return AMNumber(cachedData_.at(indexes.i()));
}
Esempio n. 13
0
AMNumber AMDeadTimeAB::value(const AMnDIndex &indexes) const
{
	if(indexes.rank() != 1)
		return AMNumber(AMNumber::DimensionError);

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	if (indexes.i() >= spectra_->size(0))
		return AMNumber(AMNumber::OutOfBoundsError);

	if ((int)spectra_->value(indexes.i()) == 0)
		return 0;
	else
		return double(icr_->value(AMnDIndex()))/double(ocr_->value(AMnDIndex()))*(int)spectra_->value(indexes.i());
}
Esempio n. 14
0
bool AMInMemoryDataStore::beginInsertRowsImplementation(long numRows, long atRowIndex) {

	axes_[0].size += numRows;
	scanSize_[0] += numRows;

	// number of scan points to add:
	int pointsPerRow = 1;
	for(int mu=axes_.count()-1; mu>=1; --mu)
		pointsPerRow *= axes_.at(mu).size;

	// Build a scan point for all of our measurements
	AMIMDSScanPoint sp;
	for(int i=0,cc=measurements_.count(); i<cc; ++i)
		sp.append(AMIMDSMeasurement(measurements_.at(i).spanSize()));

	// insert that scan point (times pointsPerRow) for all rows to insert.
	scanPoints_.insert(atRowIndex*pointsPerRow, numRows*pointsPerRow, sp);

	// add to axis values of first scan axis.
	if(!axes_.at(0).isUniform)
		axisValues_[0].insert(atRowIndex, numRows, AMNumber());

	return true;

}
Esempio n. 15
0
AMNumber AM1DInterpolationAB::value(const AMnDIndex& indexes) const{
	if(indexes.rank() != 1)
		return AMNumber(AMNumber::DimensionError);

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

#ifdef AM_ENABLE_BOUNDS_CHECKING
		if((unsigned)indexes.i() >= (unsigned)axes_.at(0).size)
			return AMNumber(AMNumber::OutOfBoundsError);
#endif

	int index = indexes.i();

	return inputSource_->value(index);
}
VESPERSSingleElementVortexDetector::VESPERSSingleElementVortexDetector(const QString &name, const QString &description, QObject *parent)
	: AMXRFDetector(name, description, parent)
{
	units_ = "Counts";

	AMAxisInfo ai("Energy", 2048, "Energy", "eV");
	ai.start = AMNumber(0);
	ai.increment = 10;
	ai.isUniform = true;
	axes_ << ai;

	// Stuff required by AMXRFDetector.
	acquireControl_ = new AMPVControl("Acquisition Time", "IOC1607-004:mca1EraseStart", "IOC1607-004:mca1EraseStart", "IOC1607-004:mca1Stop", this, 0.5);
	acquisitionStatusControl_ = new AMReadOnlyPVControl("Status", "IOC1607-004:mca1.ACQG", this);
	acquireTimeControl_ = new AMSinglePVControl("Integration Time", "IOC1607-004:mca1.PRTM", this, 0.001);
	elapsedTimeControl_ = new AMReadOnlyPVControl("Elapsed Time", "IOC1607-004:mca1.ERTM", this);

	icrControls_.append(new AMReadOnlyPVControl("Input Counts", "IOC1607-004:dxp1.ICR", this, "The input counts for the single element."));
	ocrControls_.append(new AMReadOnlyPVControl("Output Counts", "IOC1607-004:dxp1.OCR", this, "The output counts for the single element."));
	spectraControls_.append(new AMReadOnlyPVControl("Raw Spectrum", "IOC1607-004:mca1", this));

	allControlsCreated();

	// Our own stuff.
	maximumEnergyControl_ = new AMSinglePVControl("Maximum Energy", "IOC1607-004:dxp1.EMAX", this, 0.01);
	peakingTimeControl_ = new AMSinglePVControl("Peaking Time", "IOC1607-004:dxp1.PKTIM", this, 0.01);

	connect(maximumEnergyControl_, SIGNAL(valueChanged(double)), this, SLOT(onMaximumEnergyChanged(double)));
	connect(peakingTimeControl_, SIGNAL(valueChanged(double)), this, SIGNAL(peakingTimeChanged(double)));
}
SXRMBFourElementVortexDetector::SXRMBFourElementVortexDetector(const QString &name, const QString &description, QObject *parent)
	: AMXRFDetector(name, description, parent)
{
	units_ = "Counts";

	AMAxisInfo ai("Energy", 2048, "Energy", "eV");
	ai.start = AMNumber(0);
	ai.increment = 10;
	ai.isUniform = true;
	axes_ << ai;

	// Stuff required by AMXRFDetector.
	acquireControl_ = new AMPVControl("Acquisition Time", "dxp1606-B10-02:EraseStart", "dxp1606-B10-02:EraseStart", "dxp1606-B10-02:StopAll", this, 0.5);
	acquisitionStatusControl_ = new AMReadOnlyPVControl("Status", "dxp1606-B10-02:Acquiring", this);
	acquireTimeControl_ = new AMSinglePVControl("Integration Time", "dxp1606-B10-02:PresetReal", this, 0.001);
	elapsedTimeControl_ = new AMReadOnlyPVControl("Elapsed Time", "dxp1606-B10-02:ElapsedReal", this);

	for (int i = 0; i < 4; i++){

		icrControls_.append(new AMReadOnlyPVControl(QString("Input Counts %1").arg(i+1), QString("dxp1606-B10-02:dxp%1.ICR").arg(i+1), this, QString("The input counts for element %1 of the four element.").arg(i+1)));
		ocrControls_.append(new AMReadOnlyPVControl(QString("Output Counts %1").arg(i+1), QString("dxp1606-B10-02:dxp%1.OCR").arg(i+1), this, QString("The output counts for element %1 of the four element.").arg(i+1)));
		spectraControls_.append(new AMReadOnlyPVControl(QString("Raw Spectrum %1").arg(i+1), QString("dxp1606-B10-02:mca%1").arg(i+1), this));
	}

	allControlsCreated();

	// Our own stuff.
	maximumEnergyControl_ = new AMSinglePVControl("Maximum Energy", "dxp1606-B10-02:mcaEMax", this, 0.01);
	peakingTimeControl_ = new AMSinglePVControl("Peaking Time", "dxp1606-B10-02:EnergyPkTime", this, 0.01);

	connect(maximumEnergyControl_, SIGNAL(valueChanged(double)), this, SLOT(onMaximumEnergyChanged(double)));
	connect(peakingTimeControl_, SIGNAL(valueChanged(double)), this, SIGNAL(peakingTimeChanged(double)));
}
Esempio n. 18
0
AMNumber CLSQE65000Detector::singleReading() const{
	if(!isConnected())
		return AMNumber(AMNumber::Null);

	AMReadOnlyWaveformBinningPVControl *tmpControl = qobject_cast<AMReadOnlyWaveformBinningPVControl*>(binnedSpectrumControl_);
	return tmpControl->value();

}
AMNumber AM2DDeadTimeCorrectionAB::value(const AMnDIndex &indexes) const
{
	if(indexes.rank() != 2)
		return AMNumber(AMNumber::DimensionError);

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	if (indexes.i() >= spectra_->size(0)
			|| indexes.j() >= spectra_->size(1))
		return AMNumber(AMNumber::OutOfBoundsError);

	if ((int)spectra_->value(indexes) == 0 || double(ocr_->value(indexes)) == 0)
		return 0;
	else
		return double(icr_->value(indexes))/double(ocr_->value(indexes))*(int)spectra_->value(indexes);
}
Esempio n. 20
0
AMNumber AMNormalizationAB::value(const AMnDIndex &indexes) const
{
	if(indexes.rank() != rank())
		return AMNumber(AMNumber::DimensionError);

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	for (int i = 0, size = indexes.rank(); i < size; i++)
		if((unsigned)indexes.at(i) >= (unsigned)axes_.at(i).size)
			return AMNumber(AMNumber::OutOfBoundsError);

	if (cacheUpdateRequired_)
		computeCachedValues();

	return cachedData_.at(indexes.flatIndexInArrayOfSize(size()));
}
Esempio n. 21
0
AMNumber AMInMemoryDataStore::axisValue(int axisId, long axisIndex) const {

	if((unsigned)axisId >= (unsigned)axes_.count())
		return AMNumber(AMNumber::InvalidError);	// invalid axis specified.

#ifdef AM_ENABLE_BOUNDS_CHECKING
	if((unsigned)axisIndex >= (unsigned)axes_.at(axisId).size)
		return AMNumber(AMNumber::OutOfBoundsError);
#endif

	const AMAxisInfo& ai = axes_.at(axisId);
	if(ai.isUniform)
		return (double)ai.start + axisIndex*(double)ai.increment;
	else
		return axisValues_.at(axisId).at(axisIndex);

}
Esempio n. 22
0
AMNumber AM3DAdditionAB::value(const AMnDIndex &indexes) const
{
	if(indexes.rank() != 3)
		return AMNumber(AMNumber::DimensionError);

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

	for (int i = 0; i < sources_.size(); i++)
		if (indexes.i() >= sources_.at(i)->size(0) || indexes.j() >= sources_.at(i)->size(1) || indexes.k() >= sources_.at(i)->size(2))
			return AMNumber(AMNumber::OutOfBoundsError);

    if (cacheUpdateRequired_)
        computeCachedValues();

    return cachedData_.at(indexes.i()*size(1)*size(2)+indexes.j()*size(2)+indexes.k());
}
Esempio n. 23
0
// When the independent values along an axis is not simply the axis index, this returns the independent value along an axis (specified by axis number and index)
AMNumber AM1DExpressionAB::axisValue(int axisNumber, int index) const  {
	if(!isValid())	// will catch most invalid situations: non matching sizes, invalid inputs, invalid expressions.
		return AMNumber(AMNumber::InvalidError);

	if(axisNumber != 0)	// someone gave us a multi-dim index for a 1D dataset
		return AMNumber(AMNumber::DimensionError);

#ifdef AM_ENABLE_BOUNDS_CHECKING
		if(index < 0 || index >= size_)
			return AMNumber(AMNumber::OutOfBoundsError);
#endif


	// can we get it directly? Single-value expressions don't require the parser.
	if(xDirect_) {
		// info on which variable to use is contained in xDirectVar_.
		if(xDirectVar_.useAxisValue)
			return sources_.at(xDirectVar_.sourceIndex)->axisValue(0, index);
		else
			return sources_.at(xDirectVar_.sourceIndex)->value(index);
	}

	// otherwise we need the parser
	else {
		// copy the new input data values into parser storage
		for(int i=0; i<xUsedVariables_.count(); i++) {
			AMParserVariable* usedVar = xUsedVariables_.at(i);
			if(usedVar->useAxisValue)
				usedVar->value = sources_.at(usedVar->sourceIndex)->axisValue(0, index);
			else
				usedVar->value = sources_.at(usedVar->sourceIndex)->value(index);
		}

		// evaluate using the parser:
		double rv;
		try {
			rv = xParser_.Eval();
		}
		catch(mu::Parser::exception_type& e) {
			QString explanation = QString("AM1DExpressionAB Analysis Block: error evaluating value: %1: '%2'.  We found '%3' at position %4.").arg(QString::fromStdString(e.GetMsg()), QString::fromStdString(e.GetExpr()), QString::fromStdString(e.GetToken())).arg(e.GetPos());
			AMErrorMon::report(AMErrorReport(this, AMErrorReport::Debug, e.GetCode(), explanation));
			return AMNumber(AMNumber::InvalidError);
		}
		return rv;
	}
}
Esempio n. 24
0
QList<AMAxisInfo> CLSPGTDetectorV2::axes() const{
	QList<AMAxisInfo> axisInfo;
	AMAxisInfo ai("Energy", 1024, "Energy", "eV");
	ai.start = AMNumber(0);
	ai.isUniform = true;
	axisInfo << ai;
	return axisInfo;
}
Esempio n. 25
0
QList<AMAxisInfo> CLSQE65000Detector::axes() const{
	QList<AMAxisInfo> axisInfo;
	AMAxisInfo ai("Wavelength", 1024, "Wavelength", "nm");
	ai.start = AMNumber(0);
	ai.isUniform = true;
	axisInfo << ai;
	return axisInfo;
}
Esempio n. 26
0
AMNumber CLSValueEditor::getEnumValue()
{
	AMNumber result = AMNumber(AMNumber::InvalidError);

	QString dialogTitle = (title_.isEmpty()) ? QString("Edit value") : QString("Editing %1").arg(title_.toLower());

	CLSValueSetpointEditorDialog inputDialog(this);
	inputDialog.setValues(moveValues_);
	inputDialog.setValue(value_);
	inputDialog.setWindowTitle(dialogTitle);
	inputDialog.move(mapToGlobal(QPoint(width()/2, height()/2)));

	if (inputDialog.exec())
		result = AMNumber(inputDialog.value());

	return result;
}
Esempio n. 27
0
AMNumber AMMockDetector::reading(const AMnDIndex &indexes) const
{
	// We want an "invalid" AMnDIndex for this 0D detector
	if (indexes.isValid()) {
		return AMNumber(AMNumber::DimensionError);
	}

	return generateRandomNumber();
}
Esempio n. 28
0
AMNumber AM2DDeadTimeAB::value(const AMnDIndex &indexes) const
{
	if(indexes.rank() != 2)
		return AMNumber(AMNumber::DimensionError);

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

#ifdef AM_ENABLE_BOUNDS_CHECKING
	if (indexes.i() >= spectra_->size(0)
			|| indexes.j() >= spectra_->size(1))
		return AMNumber(AMNumber::OutOfBoundsError);
#endif

	if ((int)spectra_->value(indexes) == 0 || double(ocr_->value(indexes.i())) == 0)
		return 0;
	else
		return double(icr_->value(indexes.i()))/double(ocr_->value(indexes.i()))*(int)spectra_->value(indexes);
}
Esempio n. 29
0
AMNumber AMnDDeadTimeAB::value(const AMnDIndex &indexes) const
{
	if(indexes.rank() != rank())
		return AMNumber(AMNumber::DimensionError);

	if(!isValid())
		return AMNumber(AMNumber::InvalidError);

#ifdef AM_ENABLE_BOUNDS_CHECKING
	for (int i = 0, size = axes_.size(); i < size; i++)
		if (indexes.at(i) >= axes_.at(i).size)
			return AMNumber(AMNumber::OutOfBoundsError);
#endif

	if ((int)spectrum_->value(indexes) == 0 || double(outputCounts_->value(indexes.i())) == 0)
		return 0;
	else
		return double(inputCounts_->value(indexes.i()))/double(outputCounts_->value(indexes.i()))*(int)spectrum_->value(indexes);
}
Esempio n. 30
0
QList<AMAxisInfo> AMBasicXRFDetectorInfo::axes() const
{
	QList<AMAxisInfo> axisInfo;
	AMAxisInfo ai("Energy", channels(), "Energy", "eV");
	//ai.increment = AMNumber(scale());
	ai.start = AMNumber(0);
	ai.isUniform = true;
	axisInfo << ai;
	return axisInfo;
}