本文整理汇总了C++中MixedData类的典型用法代码示例。如果您正苦于以下问题:C++ MixedData类的具体用法?C++ MixedData怎么用?C++ MixedData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MixedData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
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: readChannel
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;
}
示例3: stringToValue
std::string hp83711bDevice::execute(int argc, char** argv)
{
//command structure: >analogIn readChannel 1
//returns the value as a string
if(argc < 3)
return "Error: Invalid argument list. Expecting 'channel'.";
int channel;
bool channelSuccess = stringToValue(argv[2], channel);
if(channelSuccess && channel >=0 && channel <= 1)
{
MixedData data;
bool success = readChannel(channel, 0, data);
if(success)
{
cerr << "Result to transfer = " << data.getDouble() << endl;
return valueToString( data.getDouble() );
}
else
return "Error: Failed when attempting to read.";
}
return "Error";
}
示例4: addAttribute
void NovatechChannelPair::defineAttributes()
{
//addAttribute("Center Frequency (MHz)", centerFreq);
//addAttribute("Delta Frequency (MHz)", deltaFreq);
addAttribute("Frequency Ramp Rate (MHz/ms)", freqRampRate);
addAttribute("Min Ramp Resolution (MHz)", maxResolution);
addAttribute("Low Freq Channel", valueToString(lowFreqChannel, ""), "0, 1, 2, 3");
addAttribute("High Freq Channel", valueToString(highFreqChannel, ""), "0, 1, 2, 3");
MixedValue valueIn("");
MixedData dataOut;
double lowFreq = 100, highFreq = 100;
if (partnerDevice("Novatech").read(lowFreqChannel + 10, valueIn, dataOut))
{
lowFreq = dataOut.getVector().at(0).getDouble();
}
else
std::cerr << "Error reading Novatech" << std::endl;
dataOut.clear();
if (partnerDevice("Novatech").read(highFreqChannel + 10, valueIn, dataOut))
{
highFreq = dataOut.getVector().at(0).getDouble();
}
else
std::cerr << "Error reading Novatech" << std::endl;
centerFreq = (lowFreq + highFreq)/2;
deltaFreq = highFreq - lowFreq;
}
示例5: stringToValue
std::string STF_AD_FAST::STF_AD_FAST_Device::execute(int argc, char **argv)
{
//command structure: >analogIn readChannel 1
//returns the value as a string
if(argc < 3)
return "Error: Invalid argument list. Expecting 'channel'.";
int channel;
bool channelSuccess = stringToValue(argv[2], channel);
if(channelSuccess && channel >= 0 && channel <= 1)
{
//RawEvent rawEvent(10000, channel, 0); //time = 1, event number = 0
// DataMeasurement measurement(10000, channel, 0);
// writeChannel(rawEvent); //runs parseDeviceEvents on rawEvent and executes a short timing sequence
MixedData data;
bool success = read(channel, 0, data);
// makeMeasurement( measurement );
//DataMeasurementVector& results = getMeasurements();
// waitForEvent(0)
//int x=0;
//while(x != 3)
//{
//cerr << "Waiting to send..." << endl;
//cin >> x;
//}
if(success)
{
cerr << "Result to transfer = " << data.getDouble() << endl;
return valueToString( data.getDouble() );
}
else
return "Error: Failed when attempting to read.";
}
return "Error";
}
示例6:
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;
}
示例7: defineAttributes
void HPSidebandLockDevice::defineAttributes()
{
//Contact arroyo to determine initial temperature setpoint
//Note that defineAttributes does NOT get called until after all the partners are registered.
//Channel 2 for Arroyos is the read on the temperature, channel 0 allows a general query to get the temperature setpoint
MixedValue valueIn;
valueIn.setValue("TEC:SET:T?");
MixedData dataOut;
bool success = partnerDevice("Arroyo").read(0, valueIn, dataOut);
double tempSetpoint;
if (success && STI::Utils::stringToValue(dataOut.getString(), tempSetpoint))
temperatureSetpoint = tempSetpoint;
else
cout << "Could not contact Arroyo to determine current temperature setpoint" << endl;
//Temperature parameters
addAttribute("Crystal Temp. Setpoint (deg C)", temperatureSetpoint);
addAttribute("Sideband Asymmetry Gain", gainSidebandAsymmetry);
addAttribute("Maximum temperature step (deg C)", maxTemperatureStep);
addAttribute("Enable Asymmetry Lock", (asymmetryLockEnabled ? "True" : "False"), "True, False");
//RF parameters
addAttribute("Calibration Trace RF Setpoint", rfSetpointCalibration);
addAttribute("RF modulation setpoint", rfSetpoint);
//"Sideband/Carrier"
addAttribute("Peak Ratio Gain", gainPeakRatio);
addAttribute("Enable Peak Ratio Lock", (peakRatioLockEnabled ? "True" : "False"), "True, False");
addAttribute("Feedback delay (ms)", feedbackDelay_ms);
//Peak finding algorithm attributes
addAttribute("Calibration Trace FSR (ms)", calibrationFSR_ms);
addAttribute("Calibration Trace Peak Height (V)", calibrationPeakHeight_V);
addAttribute("1st Sideband to Carrier Spacing (ms)", firstSidebandSpacing_ms);
addAttribute("2nd Sideband to Carrier Spacing (ms)", secondSidebandSpacing_ms);
addAttribute("Peak Search Target Range (ms)", peakTargetRange_ms);
addAttribute("Minimum Spectrum X Position (ms)", minSpectrumX_ms);
addAttribute("Maximum Fractional Sideband Splitting Change", maximumFractionalChangeSplitting);
addAttribute("Peak Ratio Selection", "1st sideband/carrier", "1st sideband/carrier, 2nd sidebands/1st sidebands");
addAttribute("Carrier-Calibration Offset (ms)", carrierOffset_ms);
}
示例8: MixedValue
::CORBA::Boolean CommandLine_i::readChannel(::CORBA::UShort channel, const STI::Types::TValMixed& value, STI::Types::TDataMixed_out data)
{
// DataMeasurement measurement(100000, channel, 1);
MixedData mixedData;
bool success = sti_device->read(channel, MixedValue(value), mixedData);
data = new STI::Types::TDataMixed();
if(success)
{
(*data) = mixedData.getTDataMixed();
}
return success;
}
示例9: readChannel
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);
}
示例10: NetworkFileSource
void STI_Application::loadGUI()
{
networkFile = new NetworkFileSource(appGUIpathName);
//Put the GUI into a file
STI::Types::TFile file;
file.description = CORBA::string_dup("");
file.fileName = CORBA::string_dup(appGUIpathName.c_str());
file.fileServerAddress = CORBA::string_dup("");
file.fileServerDirectory = CORBA::string_dup("");
file.networkFile = networkFile->getNetworkFileReference();
//Put the loaded GUI into the labeled data as a File
MixedData guiData;
guiData.addValue(GUIjavaclasspath);
guiData.addValue(file);
setLabeledData("JavaGUI", guiData);
}
示例11:
void HighPowerIntensityLockDevice::HPIntensityLockEvent::collectMeasurementData()
{
//save the current value of the VCA setpoint
MixedData vcaData;
vcaData.addValue(std::string("VCA Setpoint"));
vcaData.addValue(_this->vcaSetpoint);
//Also save the PD voltage:
MixedData pdData;
pdData.addValue(std::string("PD Voltage"));
pdData.addValue(_this->photodiodeVoltage);
MixedData feedbackLoopData;
feedbackLoopData.addValue( vcaData );
feedbackLoopData.addValue( pdData );
//Save feedbackLoopData as a measurement for the HP Intensity Lock device
eventMeasurements.at(0)->setData( feedbackLoopData );
}
示例12: readChannel
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;
}
}
示例13: getDeviceData
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;
}
}
示例14: makeMeasurement
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;
}
}
示例15: WolframRTL_initialize
bool MathematicaPeakFinder::findFirstAndSecondOrderSidebandPeaks(const STI::Types::TDataMixedSeq& rawSidebandData,
const CalibrationResults_ptr& calibration,
double firstOrderSidebandSpacing,
double secondOrderSidebandSpacing,
double minimumX,
double targetRange,
MixedData& peaks,
double carrierOffset)
{
WolframLibraryData libData = 0;
WolframRTL_initialize(WolframLibraryVersion);
libData = WolframLibraryData_new(WolframLibraryVersion);
//Setup arguments
MTensor formatedSidebandData; //List of {x,y} pairs, with gaps when y is below threshold
if(!convertRawScopeData(libData, rawSidebandData, formatedSidebandData)) {
return false;
}
//Initialize calibration tensor
MTensor calTensor;
int err;
mint type = MType_Real;
mint rank = 2;
mint dims[2];
dims[0] = 2;
dims[1] = 2;
err = libData->MTensor_new(type, rank, dims, &calTensor);
if(err != 0)
return false;
if(!calibration->getPeaks(libData, &calTensor))
return false;
//Initialize results tensor
MTensor peakResults;
type = MType_Real;
rank = 2;
dims[2];
dims[0] = 4; //First and second order sidebands: { {+1, -1}, {+2, -2} }
dims[1] = 2; //{time, peak height}
err = libData->MTensor_new(type, rank, dims, &peakResults);
mreal firstOrderSidebandSpacingArg = firstOrderSidebandSpacing;
mreal secondOrderSidebandSpacingArg = secondOrderSidebandSpacing;
mreal minX = minimumX;
mreal targetRangeArg = targetRange;
mreal carrierOffsetArg = carrierOffset;
if(err == 0) {
Initialize_findFirstAndSecondOrderSidebands(libData); //Begin call to Mathematica code
err = findFirstAndSecondOrderSidebands(libData, formatedSidebandData, calTensor, firstOrderSidebandSpacingArg, secondOrderSidebandSpacingArg, minX, targetRangeArg, carrierOffsetArg, &peakResults);
Uninitialize_findFirstAndSecondOrderSidebands(libData); //End call to Mathematica code
}
if( err == 0) {
//Copy results of peak search
double value = 0;
mint pos[2];
peaks.clear();
MixedData peak;
for(int i = 1; i <= 4; i++) {
pos[0] = i;
peak.clear();
for(int j = 1; j <= 2; j++) {
pos[1] = j;
err = libData->MTensor_getReal(peakResults, pos, &value);
peak.addValue(value);
}
peaks.addValue(peak);
}
}
cout << "Peak find results:" << endl;
cout << peaks.print() << endl;
libData->MTensor_free(formatedSidebandData);
libData->MTensor_free(calTensor);
libData->MTensor_free(peakResults);
return (err == 0);
}