Пример #1
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;
}
Пример #2
0
KigDocument* KigFilterGeogebra::load( const QString& sFrom )
{
  KZip geogebraFile( sFrom );
  KigDocument * document = new KigDocument();

  if ( geogebraFile.open( QIODevice::ReadOnly ) )
  {
    const KZipFileEntry* geogebraXMLEntry = dynamic_cast<const KZipFileEntry*>( geogebraFile.directory()->entry( "geogebra.xml" ) );

    if ( geogebraXMLEntry )
    {
      QXmlNamePool np;
      QXmlQuery geogebraXSLT( QXmlQuery::XSLT20, np );
      const QString encodedData = QString::fromUtf8( geogebraXMLEntry->data().constData() );
      QFile queryDevice( ":/kig/geogebra/geogebra.xsl" );
      GeogebraTransformer ggbtransform( document, np );

      queryDevice.open( QFile::ReadOnly );
      geogebraXSLT.setFocus( encodedData );
      geogebraXSLT.setQuery( &queryDevice );
      geogebraXSLT.evaluateTo( &ggbtransform );
      queryDevice.close();

      assert( ggbtransform.getNumberOfSections() == 1 );

      const GeogebraSection & gs = ggbtransform.getSection( 0 );
      const std::vector<ObjectCalcer *> & f = gs.getOutputObjects();
      const std::vector<ObjectDrawer *> & d = gs.getDrawers();
      std::vector<ObjectHolder *> holders( f.size() );

      std::transform( f.cbegin(), f.cend(), d.begin(), holders.begin(), holderFromCalcerAndDrawer );

      document->addObjects( holders );
    }
  }
  else
  {
    qWarning() << "Failed to open zip archive";
  }

  return document;
}
std::string agilent54621aOscilloscopeDevice::execute(int argc, char **argv)
{
	string commandString;
	string commandValue;
	
	int query = 0; //true (1) or false (0) if the command is expecting a response
	double measuredValue = 0;
	//bool commandSuccess;
	//double commandValue;
	//bool outputSuccess;
	string result;

	//command comes as "attribute value query?"
	if(argc == 5)
	{
		commandValue = argv[4];
		commandString = ":SOUR:VOLT:PIEZ " + commandValue;
		result = commandDevice(commandString);
	}
	if(argc == 4)
	{
		result = queryDevice(":SOUR:VOLT:PIEZ?");
		return result;
	}
	else
		return "0"; //command needs to contain 2 pieces of information

	/*
	if(commandSuccess)
	{
		outputSuccess = setAttribute(attribute, commandValue); //will only work with attributes that take doubles
		
		if(outputSuccess)
			return "1";
		else
			return "0";
	}
	else
		return "0";	
	*/
}
Пример #4
0
void Backend::listDevices(size_t platform, bool verbose)
{
    for (int i = 0; i < devicesPerPlatform[platform]; i++) {
        queryDevice(platform, i, verbose);
    }
}
bool agilent54621aOscilloscopeDevice::updateAttribute(string key, string value)
{
	//converts desired command into GPIB command string and executes via gpib controller partner device
	double tempDouble;
	bool successDouble = stringToValue(value, tempDouble);
	bool commandSuccess;
	bool success = false;
	string result;

	if(key.compare("GPIB ID") == 0)
	{
		gpibID = queryDevice("*idn?");
		if(gpibID.compare("") == 0)
			success = false;
		else
			success = true;
		std::cerr << "Identification: " << gpibID << std::endl;
	}
	else if(key.compare("Laser Head Operating Hours") == 0)
	{
		laserHeadHours = queryDevice(":SYST:INF:DHO?");
		if(laserHeadHours.compare("") == 0)
			success = false;
		else
			success = true;
		std::cerr << "Laser Head Operating Hours: " << laserHeadHours << std::endl;
	}
	else if(key.compare("Controller Operating Hours") == 0)
	{
		controllerHours = queryDevice(":SYST:INF:SHO?");
		if(controllerHours.compare("") == 0)
			success = false;
		else
			success = true;
		std::cerr << "Controller Operating Hours: " << controllerHours << std::endl;
	}
	else if(key.compare("Laser Wavelength")==0)
	{
		laserWavelength = queryDevice(":SYST:INF:HWAV?");
		if(laserWavelength.compare("") == 0)
			success = false;
		else
			success = true;
		std::cerr << "Laser Wavelength: " << laserWavelength << std::endl;
	}
	else if(key.compare("Piezo Voltage (V)") == 0)
	{
		bool successPiezoVoltage = stringToValue(value, newPiezoVoltage);
		if(successPiezoVoltage && newPiezoVoltage < 117.5 && newPiezoVoltage > 0) 
		{
			std::string piezoCommand = ":SOUR:VOLT:PIEZ " + value;
			std::cerr << "piezo_command_str: " << piezoCommand << std::endl;
			commandSuccess = commandDevice(piezoCommand);
			std::cerr << "device successfully commanded"<< std::endl;
			if(commandSuccess)
			{
				result = queryDevice(":SOUR:VOLT:PIEZ?");
				if(result.compare("") == 0)
					success =  false;
				else
				{	
					successPiezoVoltage = stringToValue(result, piezoVoltage);
					success = true;
				}
			}
			else
				success = false;
			}
		else
		{
			std::cerr << "The desired voltage is outside of the allowed range." << std::endl;
			success = false;
		}
	}
	else if(key.compare("Power") == 0)
	{
		if(value.compare("On") == 0)
		{
			commandSuccess = commandDevice(":OUTP 1");
			powerOn = true;
		}
		else
		{
			commandSuccess = commandDevice(":OUTP 0");
			powerOn = false;
		}
		if(commandSuccess)
			success = true;
	/*	
		if(commandSuccess)
			{
				result = queryDevice(":OUTP?");
				int powerStatus;
				bool successPowerStatus = stringToValue(result, powerStatus);
				if(result.compare("") == 0)
					success =  false;
				else
				{	
					std::cerr << "Power Status is: " << result << std::endl;
					if(powerStatus == 1)
					{
						success = true;
						powerOn = true;
						std::cerr << "Laser Turned On" << std::endl;
					}
					if(powerStatus == 0)
					{
						success = true;
						powerOn = false;
						std::cerr << "Laser Turned Off" << std::endl;
					}
					else
					{
						success = false;
					}
				}
			}
		else
			success = false;
			*/
	}
	else if(key.compare("Piezo Gain") == 0)
	{
		if(value.compare("High") == 0)
		{
			//set gain to high (25x)
			commandSuccess = commandDevice(":CONF:GAIN:HIGH");
			std::cerr << "Gain commanded High (25x)." << std::endl;
		}
		else
		{
			//set gain to low (1x)
			commandSuccess = commandDevice(":CONF:GAIN:LOW");
			std::cerr << "Gain commanded Low (1x)." << std::endl;
		}
		if(commandSuccess)
			{
				std::string testResult;
				result = queryDevice(":CONF:GAIN?");
				if(result.compare("") == 0)
					success =  false;
				else
				{	
					testResult.assign(result, 0, 3);
					std::cerr << "Piezo Gain is: " << "***" << testResult << "***" << std::endl;
					if(testResult.compare("HIG") == 0)
					{
						success = true;
						piezoGainHigh = true;
						std::cerr << "set success to true" << std::endl;

					}
					else if(testResult.compare("LOW") == 0)
					{
						success = true;
						piezoGainHigh = false;
						std::cerr << "set success to true" << std::endl;
					}
					else
					{
						success = false;
						std::cerr << "set success to false" << std::endl;
					}
				}
			}
		else
			success = false;
	}
	else if(key.compare("Laser Current (mA)") == 0)
	{
		bool successLaserCurrent = stringToValue(value, newLaserCurrent);
		if(successLaserCurrent && newLaserCurrent < 50.0 && newLaserCurrent > 0) 
		{
			std::string currentCommand = ":SOUR:CURR " + value;
			std::cerr << "current_command_str: " << currentCommand << std::endl;
			commandSuccess = commandDevice(currentCommand);
			std::cerr << "device successfully commanded"<< std::endl;
			if(commandSuccess)
			{
				result = queryDevice(":SOUR:CURR?");
				if(result.compare("") == 0)
					success =  false;
				else
				{	
					commandSuccess = stringToValue(result, laserCurrent);
					success = true;
				}
			}
			else
				success = false;
			}
		else
		{
			std::cerr << "The desired current is outside of the allowed range." << std::endl;
			success = false;
		}
	}

	return success;
}