bool PhaseMatrixDevice::readChannel(unsigned short channel, const MixedValue& valueIn, MixedData& dataOut)
{
	bool success = false;

	if(channel == 2) {	//Read Frequency
		std::stringstream command;
		double frequency;

		success = measureFrequency(frequency);

		if(success) {
			dataOut.setValue(frequency / 1000);		//Phase Matrix returns milli Hz; return value in Hz
			currentFreqHz = frequency / 1000;
		}
	}

	if(channel == 3) {	//Read Power
		double power;

		success = measurePower(power);

		if(success) {
			dataOut.setValue(power);
			currentPower = power;
		}
	}

	return success;
}
Example #2
0
bool hp83711bDevice::readChannel(unsigned short channel, const MixedValue& valueIn, MixedData& dataOut)
{
	//
	
	bool measureSuccess;
	std::string measurementResult;

	if(channel == 0)
	{
		measurementResult = queryDevice("FREQ:CW?");
		std::cerr << measurementResult << std::endl;
		//measurementResult.erase(0,2);
		measureSuccess = stringToValue(measurementResult, frequency, std::ios::dec, 10);
		//wavelength = wavelength * 1000000000; // multiply by 10^9
		std::cerr.precision(10);
		std::cerr << "The output frequency is:" << frequency << " Hz" << std::endl;
		dataOut.setValue(frequency);
		return measureSuccess;
	}
	else if(channel == 1)
	{
		measurementResult = queryDevice("POW:LEV?");
		std::cerr << measurementResult << std::endl;
		//measurementResult.erase(0,2);
		measureSuccess = stringToValue(measurementResult, power);
		std::cerr << "The output power is: " << power << "dBm" << std::endl;
		dataOut.setValue(power);
		return measureSuccess;
	}

	std::cerr << "Expecting either Channel 0 or 1" << std::endl;
	return false;
}
Example #3
0
bool Novatech409B::readChannel(unsigned short channel, const MixedValue& valueIn, MixedData& dataOut)
{
	std::vector <std::vector<double> > freqAmpPhases;
	std::vector <double> freqAmpPhase;

	std::string state;

	if (channel > 9 && channel < 14)
	{
//		for (unsigned int i = 0; i < frequencyChannels.size(); i++)
//		{
//			freqAmpPhase.clear();

		if(refreshLocallyStoredFrequencyChannels()) {

			freqAmpPhase.push_back(frequencyChannels.at(channel - 10).frequency);
			freqAmpPhase.push_back(frequencyChannels.at(channel - 10).amplitude);
			freqAmpPhase.push_back(frequencyChannels.at(channel - 10).phase);
			freqAmpPhases.push_back(freqAmpPhase);
	
			dataOut.setValue(freqAmpPhase);
		}
		else {
			std::cerr << "Failed to read channel." << endl;
			return false;
		}
	}
	else
	{
		std::cerr << "Expecting channel 10 - 13 for a read command" << std::endl;
		return false;
	}

	return true;
}
Example #4
0
bool RemoteDevice::read(unsigned short channel, const MixedValue& valueIn, MixedData& dataOut)
{
	bool success = false;

	STI::Types::TDataMixed_var tData;

	try {
		success = getCommandLineRef()->readChannel(channel, valueIn.getTValMixed(), tData.out());
	}
	catch(CORBA::TRANSIENT& ex) {
		cerr << printExceptionMessage(ex, "RemoteDevice::execute(...)");
	}
	catch(CORBA::SystemException& ex) {
		cerr << printExceptionMessage(ex, "RemoteDevice::execute(...)");
	}
	catch(CORBA::Exception&) {
	}
	catch(...) {
	}

	if( success )
	{
		dataOut.setValue( tData.in() );
	}

	return success;
}
Example #5
0
void LoggedMeasurement::makeMeasurement()
{
//	measurementTimer.reset();

	MixedData newResult;
	MixedData delta;
	MixedData sigmaSqrd;
	
	getDeviceData(newResult);
	if(measurement == 0)
		delta.setValue(newResult);
	else
		delta.setValue(newResult - measurement);

	thresholdExceeded = false;

	//Does the -1 have to be on the rhs?
	if(sigma != 0 && ((delta < sigma*threshold*(-1)) || (delta > sigma*threshold) ) )
	{
		//spurious data point detected
		thresholdExceeded = true;
		std::cerr << "Threshold Exceeded" << std::endl;
		measurement.setValue(newResult);
		numberAveragedMeasurements = 0;
	}
	else
	{
		//the measurement average resets after each save interval
		measurement.setValue((measurement * numberAveragedMeasurements + newResult) / (numberAveragedMeasurements + 1));
	}

	numberAveragedMeasurements++;

	//standard deviation sigma always includes a contribution from the previous sigma (before numberAveragedMeasurements is reset).
	sigmaSqrd.setValue(
		(sigma*sigma * numberAveragedMeasurements + delta*delta) / (numberAveragedMeasurements + 1) 
		);
	sigma.setValue(sigmaSqrd.sqroot());

	if (numberAveragedMeasurements >= maxNumberToAverage || thresholdExceeded)
	{
		resultIsReady = true;
	}
}
Example #6
0
bool STI_Application::readChannel(unsigned short channel, const MixedValue& valueIn, MixedData& dataOut) {
	if(channel == 0) {
		dataOut.setValue(
			handleFunctionCall(
			valueIn.getVector().at(0).getString(), valueIn.getVector().at(1).getVector())
			);
		return true;
	}
	return readAppChannel(channel, valueIn, dataOut);
}
Example #7
0
bool MccUSBDAQDevice::readChannel(unsigned short channel, const MixedValue& valueIn, MixedData& dataOut)
{
	double result;

	if( readInputChannel(channel, result) )
	{
		dataOut.setValue( result );
		return true;
	}
	else
	{
		return false;
	}
}
Example #8
0
void LoggedMeasurement::getDeviceData(MixedData& data)
{
	double value = 0;

	if(type == Attribute)
	{
		device->refreshDeviceAttributes();
		STI_Device::stringToValue(device->getAttribute(measurementKey), value);
		data.setValue(value);
	}
	else if(type == Channel)
	{
		device->read(this->getChannel(), valueIn, data);
		// Debugging only; broken for vectors
//		value = data.getNumber();
//		std::cerr << "Logged: " << value << std::endl;
	}
}