本文整理汇总了C++中ConvertPtr::fromDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ ConvertPtr::fromDouble方法的具体用法?C++ ConvertPtr::fromDouble怎么用?C++ ConvertPtr::fromDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConvertPtr
的用法示例。
在下文中一共展示了ConvertPtr::fromDouble方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: examplePVFieldPut
static void examplePVFieldPut(PvaClientPtr const &pva,string const & channelName,string const & providerName)
{
cout << "__examplePVFieldPut__ channelName " << channelName << " providerName " << providerName << endl;
PvaClientChannelPtr channel = pva->channel(channelName,providerName,2.0);
PvaClientPutPtr put = channel->put();
PvaClientPutDataPtr putData = put->getData();
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(putData->getValue());
convert->fromDouble(pvScalar,1.0); put->put();
cout << channel->get("field(value)")->getData()->showChanged(cout) << endl;
convert->fromDouble(pvScalar,2.0); put->put();
cout << channel->get("field(value)")->getData()->showChanged(cout) << endl;
}
示例2: examplePVFieldPut
static void examplePVFieldPut(PvaClientPtr const &pva)
{
cout << "example put\n";
PvaClientChannelPtr channel = pva->channel("exampleDouble");
PvaClientPutPtr put = channel->put();
PvaClientPutDataPtr putData = put->getData();
PVFieldPtr pvField = putData->getValue();
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(pvField);
try {
convert->fromDouble(pvScalar,1.0); put->put();
cout << channel->get("field()")->getData()->showChanged(cout) << endl;
convert->fromDouble(pvScalar,2.0); put->put();
cout << channel->get("field()")->getData()->showChanged(cout) << endl;
} catch (std::runtime_error e) {
cout << "exception " << e.what() << endl;
}
}
示例3: putDouble
void PvaClientPutData::putDouble(double value)
{
PVScalarPtr pvScalar = getScalarValue();
ScalarType scalarType = pvScalar->getScalar()->getScalarType();
if(scalarType==pvDouble) {
PVDoublePtr pvDouble = static_pointer_cast<PVDouble>(pvScalar);
pvDouble->put(value);
return;
}
if(!ScalarTypeFunc::isNumeric(scalarType)) {
throw std::runtime_error(messagePrefix + notCompatibleScalar);
}
convert->fromDouble(pvScalar,value);
}
示例4: put
void PvaClientMultiPutDouble::put(epics::pvData::shared_vector<double> const &data)
{
if(!isPutConnected) connect();
if(data.size()!=nchannel) {
throw std::runtime_error("data has wrong size");
}
shared_vector<epics::pvData::boolean> isConnected = pvaClientMultiChannel->getIsConnected();
for(size_t i=0; i<nchannel; ++i)
{
if(isConnected[i]) {
PVStructurePtr pvTop = pvaClientPut[i]->getData()->getPVStructure();
PVScalarPtr pvValue = pvTop->getSubField<PVScalar>("value");
convert->fromDouble(pvValue,data[i]);
pvaClientPut[i]->issuePut();
}
if(isConnected[i]) {
Status status = pvaClientPut[i]->waitPut();
if(status.isOK()) continue;
string message = string("channel ") + pvaClientChannelArray[i]->getChannelName()
+ " PvaChannelPut::waitPut " + status.getMessage();
throw std::runtime_error(message);
}
}
}
示例5: testPVScalar
static void testPVScalar(
string const & valueNameMaster,
string const & valueNameCopy,
PVStructurePtr const & pvMaster,
PVCopyPtr const & pvCopy)
{
PVStructurePtr pvStructureCopy;
PVScalarPtr pvValueMaster;
PVScalarPtr pvValueCopy;
BitSetPtr bitSet;
size_t offset;
ConvertPtr convert = getConvert();
pvValueMaster = pvMaster->getSubField<PVScalar>(valueNameMaster);
convert->fromDouble(pvValueMaster,.04);
StructureConstPtr structure = pvCopy->getStructure();
if(debug) { cout << "structure from copy" << endl << *structure << endl; }
pvStructureCopy = pvCopy->createPVStructure();
pvValueCopy = pvStructureCopy->getSubField<PVScalar>(valueNameCopy);
bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
pvCopy->initCopy(pvStructureCopy, bitSet);
if(debug) { cout << "after initCopy pvValueCopy " << convert->toDouble(pvValueCopy); }
if(debug) { cout << endl; }
convert->fromDouble(pvValueMaster,.06);
testOk1(convert->toDouble(pvValueCopy)==.04);
pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
testOk1(convert->toDouble(pvValueCopy)==.06);
testOk1(bitSet->get(pvValueCopy->getFieldOffset()));
if(debug) { cout << "after put(.06) pvValueCopy " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
offset = pvCopy->getCopyOffset(pvValueMaster);
if(debug) { cout << "getCopyOffset() " << offset; }
if(debug) { cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset(); }
if(debug) { cout << " pvValueMaster->getOffset() " << pvValueMaster->getFieldOffset(); }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
bitSet->clear();
convert->fromDouble(pvValueMaster,1.0);
if(debug) { cout << "before updateCopyFromBitSet"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
bitSet->set(0);
testOk1(convert->toDouble(pvValueCopy)==0.06);
pvCopy->updateCopyFromBitSet(pvStructureCopy,bitSet);
testOk1(convert->toDouble(pvValueCopy)==1.0);
if(debug) { cout << "after updateCopyFromBitSet"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
convert->fromDouble(pvValueCopy,2.0);
bitSet->set(0);
if(debug) { cout << "before updateMaster"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
testOk1(convert->toDouble(pvValueMaster)==1.0);
pvCopy->updateMaster(pvStructureCopy,bitSet);
testOk1(convert->toDouble(pvValueMaster)==2.0);
if(debug) { cout << "after updateMaster"; }
if(debug) { cout << " masterValue " << convert->toDouble(pvValueMaster); }
if(debug) { cout << " copyValue " << convert->toDouble(pvValueCopy); }
if(debug) { cout << " bitSet " << *bitSet; }
if(debug) { cout << endl; }
}
示例6: testPVScalar
static void testPVScalar(
string const & valueNameRecord,
string const & valueNameCopy,
PVRecordPtr const & pvRecord,
PVCopyPtr const & pvCopy)
{
PVStructurePtr pvStructureRecord;
PVStructurePtr pvStructureCopy;
PVFieldPtr pvField;
PVScalarPtr pvValueRecord;
PVScalarPtr pvValueCopy;
BitSetPtr bitSet;
size_t offset;
ConvertPtr convert = getConvert();
cout << endl;
pvStructureRecord = pvRecord->getPVRecordStructure()->getPVStructure();
pvField = pvStructureRecord->getSubField(valueNameRecord);
pvValueRecord = static_pointer_cast<PVScalar>(pvField);
convert->fromDouble(pvValueRecord,.04);
StructureConstPtr structure = pvCopy->getStructure();
cout << "structure from copy" << endl << *structure << endl;
pvStructureCopy = pvCopy->createPVStructure();
pvField = pvStructureCopy->getSubField(valueNameCopy);
pvValueCopy = static_pointer_cast<PVScalar>(pvField);
bitSet = BitSetPtr(new BitSet(pvStructureCopy->getNumberFields()));
pvCopy->initCopy(pvStructureCopy, bitSet);
cout << "after initCopy pvValueCopy " << convert->toDouble(pvValueCopy);
cout << endl;
convert->fromDouble(pvValueRecord,.06);
pvCopy->updateCopySetBitSet(pvStructureCopy,bitSet);
cout << "after put(.06) pvValueCopy " << convert->toDouble(pvValueCopy);
cout << " bitSet " << *bitSet;
cout << endl;
offset = pvCopy->getCopyOffset(pvValueRecord);
cout << "getCopyOffset() " << offset;
cout << " pvValueCopy->getOffset() " << pvValueCopy->getFieldOffset();
cout << " pvValueRecord->getOffset() " << pvValueRecord->getFieldOffset();
cout << " bitSet " << *bitSet;
cout << endl;
bitSet->clear();
convert->fromDouble(pvValueRecord,1.0);
cout << "before updateCopyFromBitSet";
cout << " recordValue " << convert->toDouble(pvValueRecord);
cout << " copyValue " << convert->toDouble(pvValueCopy);
cout << " bitSet " << *bitSet;
cout << endl;
bitSet->set(0);
pvCopy->updateCopyFromBitSet(pvStructureCopy,bitSet);
cout << "after updateCopyFromBitSet";
cout << " recordValue " << convert->toDouble(pvValueRecord);
cout << " copyValue " << convert->toDouble(pvValueCopy);
cout << " bitSet " << *bitSet;
cout << endl;
convert->fromDouble(pvValueCopy,2.0);
bitSet->set(0);
cout << "before updateMaster";
cout << " recordValue " << convert->toDouble(pvValueRecord);
cout << " copyValue " << convert->toDouble(pvValueCopy);
cout << " bitSet " << *bitSet;
cout << endl;
pvCopy->updateMaster(pvStructureCopy,bitSet);
cout << "after updateMaster";
cout << " recordValue " << convert->toDouble(pvValueRecord);
cout << " copyValue " << convert->toDouble(pvValueCopy);
cout << " bitSet " << *bitSet;
cout << endl;
}
示例7: testPVScalarWithProperties
//.........这里部分代码省略.........
}
case pvDouble: {
pvStructure = standardPVField->scalar(
stype,allProperties);
hasValueAlarm = true;
hasDisplayControl = true;
PVDoublePtr pvField = pvStructure->getSubField<PVDouble>("value");
pvField->put(1.123e35);
break;
}
case pvString: {
pvStructure = standardPVField->scalar(
stype,alarmTimeStamp);
PVStringPtr pvField = pvStructure->getSubField<PVString>("value");
pvField->put(string("this is a string"));
break;
}
}
PVLongPtr seconds = pvStructure->getSubField<PVLong>(
string("timeStamp.secondsPastEpoch"));
testOk1(seconds.get()!=0);
seconds->put(123456789);
PVIntPtr nano = pvStructure->getSubField<PVInt>(string("timeStamp.nanoseconds"));
testOk1(nano.get()!=0);
nano->put(1000000);
PVIntPtr severity = pvStructure->getSubField<PVInt>(string("alarm.severity"));
testOk1(severity.get()!=0);
severity->put(2);
PVStringPtr message = pvStructure->getSubField<PVString>(string("alarm.message"));
testOk1(message.get()!=0);
message->put(string("messageForAlarm"));
if(hasDisplayControl) {
PVStringPtr desc = pvStructure->getSubField<PVString>(
string("display.description"));
testOk1(desc.get()!=0);
desc->put(string("this is a description"));
PVStringPtr format = pvStructure->getSubField<PVString>(
string("display.format"));
testOk1(format.get()!=0);
format->put(string("f10.2"));
PVStringPtr units = pvStructure->getSubField<PVString>(
string("display.units"));
testOk1(units.get()!=0);
units->put(string("SomeUnits"));
PVDoublePtr limit = pvStructure->getSubField<PVDouble>(
string("display.limitLow"));
testOk1(limit.get()!=0);
limit->put(0.0);
limit = pvStructure->getSubField<PVDouble>(
string("display.limitHigh"));
testOk1(limit.get()!=0);
limit->put(10.0);
limit = pvStructure->getSubField<PVDouble>(
string("control.limitLow"));
testOk1(limit.get()!=0);
limit->put(1.0);
limit = pvStructure->getSubField<PVDouble>(
string("control.limitHigh"));
testOk1(limit.get()!=0);
limit->put(9.0);
}
if(hasValueAlarm) {
PVBooleanPtr pvBoolean = pvStructure->getSubField<PVBoolean>("valueAlarm.active");
pvBoolean->put(true);
PVScalarPtr pvtemp = pvStructure->getSubField<PVScalar>("valueAlarm.lowAlarmLimit");
testOk1(pvtemp.get()!=0);
convert->fromDouble(pvtemp,1.0);
pvtemp = pvStructure->getSubField<PVScalar>("valueAlarm.highAlarmLimit");
testOk1(pvtemp.get()!=0);
convert->fromDouble(pvtemp,9.0);
severity = pvStructure->getSubField<PVInt>(
string("valueAlarm.lowAlarmSeverity"));
testOk1(severity.get()!=0);
severity->put(2);
severity = pvStructure->getSubField<PVInt>(
string("valueAlarm.highAlarmSeverity"));
testOk1(severity.get()!=0);
severity->put(2);
PVBooleanPtr active = pvStructure->getSubField<PVBoolean>(
string("valueAlarm.active"));
testOk1(active.get()!=0);
active->put(true);
}
if(hasBooleanAlarm) {
PVBooleanPtr pvBoolean = pvStructure->getSubField<PVBoolean>("valueAlarm.active");
pvBoolean->put(true);
severity = pvStructure->getSubField<PVInt>(
string("valueAlarm.falseSeverity"));
testOk1(severity.get()!=0);
severity->put(0);
severity = pvStructure->getSubField<PVInt>(
string("valueAlarm.trueSeverity"));
testOk1(severity.get()!=0);
severity->put(2);
severity = pvStructure->getSubField<PVInt>(
string("valueAlarm.changeStateSeverity"));
testOk1(severity.get()!=0);
severity->put(1);
}
}