Revert "Replace display.format with .form and .precision"

This reverts commit 4ffddfa2f6.
This commit is contained in:
Michael Davidsaver
2019-05-06 10:40:54 -07:00
parent 3ae2d09fe3
commit cd2436342d
6 changed files with 37 additions and 6 deletions

View File

@@ -65,8 +65,7 @@ StandardField::StandardField()
->add("limitLow", pvDouble)
->add("limitHigh", pvDouble)
->add("description", pvString)
->add("precision", pvInt)
->add("form", enumerated())
->add("format", pvString)
->add("units", pvString)
->createStructure())

View File

@@ -42,7 +42,8 @@ public:
* Constructor
*/
Display()
:low(0.0),high(0.0) {}
: description(std::string("")),format(std::string("")),units(std::string("")),
low(0.0),high(0.0) {}
//default constructors and destructor are OK
/**
* Get the current value of limitLow.
@@ -74,6 +75,17 @@ public:
* @param value The value.
*/
void setDescription(std::string const & value) {description = value;}
/**
* Get the current value of format.
* @return The current value.
*/
std::string getFormat() const {return format;}
/**
* Set format to a new value.
* @param value The value.
* The rules for a valid syntax has not been specified.
*/
void setFormat(std::string const & value) {format = value;}
/**
* Get the current value of units.
* @return The current value.
@@ -86,6 +98,7 @@ public:
void setUnits(std::string const & value) {units = value;}
private:
std::string description;
std::string format;
std::string units;
double low;
double high;

View File

@@ -79,6 +79,7 @@ private:
static std::string noDisplayFound;
static std::string notAttached;
PVStringPtr pvDescription;
PVStringPtr pvFormat;
PVStringPtr pvUnits;
PVDoublePtr pvLow;
PVDoublePtr pvHigh;

View File

@@ -29,6 +29,11 @@ bool PVDisplay::attach(PVFieldPtr const & pvField)
PVStructurePtr pvStructure = static_pointer_cast<PVStructure>(pvField);
pvDescription = pvStructure->getSubField<PVString>("description");
if(pvDescription.get()==NULL) return false;
pvFormat = pvStructure->getSubField<PVString>("format");
if(pvFormat.get()==NULL) {
detach();
return false;
}
pvUnits = pvStructure->getSubField<PVString>("units");
if(pvUnits.get()==NULL) {
detach();
@@ -50,6 +55,7 @@ bool PVDisplay::attach(PVFieldPtr const & pvField)
void PVDisplay::detach()
{
pvDescription.reset();
pvFormat.reset();
pvUnits.reset();
pvLow.reset();
pvHigh.reset();
@@ -66,6 +72,7 @@ void PVDisplay::get(Display & display) const
throw std::logic_error(notAttached);
}
display.setDescription(pvDescription->get());
display.setFormat(pvFormat->get());
display.setUnits(pvUnits->get());
display.setLow(pvLow->get());
display.setHigh(pvHigh->get());
@@ -76,7 +83,7 @@ bool PVDisplay::set(Display const & display)
if(pvDescription.get()==NULL) {
throw std::logic_error(notAttached);
}
if(pvDescription->isImmutable()) return false;
if(pvDescription->isImmutable() || pvFormat->isImmutable()) return false;
if(pvUnits->isImmutable() || pvLow->isImmutable() || pvHigh->isImmutable())
{
return false;
@@ -89,6 +96,11 @@ bool PVDisplay::set(Display const & display)
pvDescription->put(display.getDescription());
returnValue = true;
}
if(current.getFormat()!=display.getFormat())
{
pvFormat->put(display.getFormat());
returnValue = true;
}
if(current.getUnits()!=display.getUnits())
{
pvUnits->put(display.getUnits());

View File

@@ -172,6 +172,7 @@ static void testDisplay()
dy.setLow(-10.0);
dy.setHigh(-1.0);
dy.setDescription(string("testDescription"));
dy.setFormat(string("%f10.0"));
dy.setUnits(string("volts"));
result = pvDisplay.set(dy);
testOk1(result);
@@ -179,6 +180,7 @@ static void testDisplay()
testOk1(dy.getLow()==display.getLow());
testOk1(dy.getHigh()==display.getHigh());
testOk1(dy.getDescription().compare(display.getDescription())==0);
testOk1(dy.getFormat().compare(display.getFormat())==0);
testOk1(dy.getUnits().compare(display.getUnits())==0);
double low = display.getLow();
double high = display.getHigh();
@@ -215,7 +217,7 @@ static void testEnumerated()
MAIN(testProperty)
{
testPlan(26);
testPlan(27);
testDiag("Tests property");
fieldCreate = getFieldCreate();
pvDataCreate = getPVDataCreate();

View File

@@ -224,6 +224,10 @@ static void testPVScalarWithProperties(
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);
@@ -736,7 +740,7 @@ static void testSubField()
MAIN(testPVData)
{
testPlan(261);
testPlan(271);
try{
fieldCreate = getFieldCreate();
pvDataCreate = getPVDataCreate();