17 #define epicsExportSharedSymbols 28 namespace epics {
namespace pvDatabase {
30 ControlSupport::~ControlSupport()
42 ->add(
"outputValue", scalarType)
53 ControlSupport::ControlSupport(
PVRecordPtr const & pvRecord)
68 cout <<
"ControlSupport for record " << pvRecord->getRecordName()
69 <<
" failed because not numeric scalar\n";
75 pvLimitHigh = pvControl->getSubField<
PVDouble>(
"limitHigh");
76 pvMinStep = pvControl->getSubField<
PVDouble>(
"minStep");
77 pvOutputValue = pvControl->getSubField<
PVScalar>(
"outputValue");
79 if(!pvControl || !pvLimitLow || !pvLimitHigh || !pvMinStep || !pvOutputValue) {
80 cout <<
"ControlSupport for record " << pvRecord->getRecordName()
81 <<
" failed because pvSupport not a valid control structure\n";
85 currentValue = convert->toDouble(pvValue);
90 bool ControlSupport::process()
93 double value = convert->toDouble(pvValue);
94 if(!isMinStep && value==currentValue)
return false;
95 double limitLow = pvLimitLow->get();
96 double limitHigh = pvLimitHigh->get();
97 double minStep = pvMinStep->get();
98 bool setValue =
false;
99 if(limitHigh>limitLow) {
100 if(value>limitHigh) {value = limitHigh;setValue=
true;}
101 if(value<limitLow) {value = limitLow;setValue=
true;}
103 if(setValue) convert->fromDouble(pvValue,value);
104 double diff = value - currentValue;
105 double outputValue = value;
108 outputValue = currentValue - minStep;
109 if(limitHigh>limitLow && outputValue<=limitLow) outputValue = limitLow;
111 if(outputValue<value) {
116 outputValue = currentValue + minStep;
117 if(limitHigh>limitLow && outputValue>=limitHigh) outputValue = limitHigh;
119 if(outputValue>value) {
125 if(outputValue==currentValue)
return false;
126 currentValue = outputValue;
127 convert->fromDouble(pvOutputValue,outputValue);
131 void ControlSupport::reset()
FORCE_INLINE std::tr1::shared_ptr< PVField > getSubField(A a)
This class implements introspection object for Scalar.
PVScalar is the base class for each scalar field.
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
TODO only here because of the Lockable.
std::tr1::shared_ptr< const Structure > StructureConstPtr
std::tr1::shared_ptr< const Scalar > ScalarConstPtr
bool isNumeric(ScalarType type)
Data interface for a structure,.
std::tr1::shared_ptr< PVRecord > PVRecordPtr
Class that holds the data for each possible scalar type.
std::tr1::shared_ptr< PVField > PVFieldPtr
Base interface for a ControlSupport.
std::tr1::shared_ptr< ControlSupport > ControlSupportPtr
std::tr1::shared_ptr< Convert > ConvertPtr
static FieldBuilderPtr begin()