Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set property data on all gets/monitor updates #49

Merged
merged 1 commit into from
May 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/dbPv/3.14/dbPvGet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ bool DbPvGet::init(PVStructure::shared_pointer const &pvRequest)
propertyMask,
dbAddr));
if (!pvStructure.get()) return false;
dbUtil->getPropertyData(channelGetRequester,propertyMask,dbAddr,pvStructure);
int numFields = pvStructure->getNumberFields();
bitSet.reset(new BitSet(numFields));
if (propertyMask&dbUtil->processBit) {
Expand Down
1 change: 0 additions & 1 deletion src/dbPv/3.14/dbPvMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ bool DbPvMonitor::init(
elements.push_back(element);
}
MonitorElementPtr element = elements[0];
dbUtil->getPropertyData(monitorRequester,propertyMask,dbAddr,element->pvStructurePtr);
StructureConstPtr saveStructure = element->pvStructurePtr->getStructure();
if((propertyMask&dbUtil->enumValueBit)!=0) {
caType = CaEnum;
Expand Down
136 changes: 105 additions & 31 deletions src/dbPv/3.14/dbUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,25 @@ void DbUtil::getPropertyData(
Requester::shared_pointer const &requester,
int propertyMask,DbAddr &dbAddr,
PVStructurePtr const &pvStructure)
{
BitSet::shared_pointer bitSet;
getPropertyDataImpl(requester, propertyMask, dbAddr,
pvStructure, bitSet);
}

void DbUtil::getPropertyDataImpl(
Requester::shared_pointer const &requester,
int propertyMask,DbAddr &dbAddr,
PVStructurePtr const &pvStructure,
BitSet::shared_pointer const &bitSet)
{
if(propertyMask&displayBit) {
Display display;
PVDisplay pvDisplay;
PVStructurePtr displayField = pvStructure->getSubFieldT<PVStructure>(displayString);
pvDisplay.attach(displayField);
pvDisplay.get(display);
bool changed = false;
char units[DB_UNITS_SIZE];
units[0] = 0;
long precision = 0;
Expand All @@ -407,48 +423,82 @@ void DbUtil::getPropertyData(
get_units gunits;
gunits = (get_units)(prset->get_units);
gunits(&dbAddr,units);
display.setUnits(units);
string unitsString = string(units);
if (unitsString != display.getUnits()) {
display.setUnits(units);
changed = true;
}
}
if(prset && prset->get_precision) {
get_precision gprec = (get_precision)(prset->get_precision);
gprec(&dbAddr,&precision);
string format;
if(precision>0) {
char fmt[16];
sprintf(fmt,"%%.%ldf",precision);
display.setFormat(string(fmt));
format = string(fmt);
}
else {
static string defaultFormat("%f");
const static string defaultFormat("%f");
format = defaultFormat;
display.setFormat(defaultFormat);
}
if (format != display.getFormat()) {
display.setFormat(format);
changed = true;
}
}
struct dbr_grDouble graphics;
if(prset && prset->get_graphic_double) {
get_graphic_double gg =
(get_graphic_double)(prset->get_graphic_double);
gg(&dbAddr,&graphics);
display.setHigh(graphics.upper_disp_limit);
display.setLow(graphics.lower_disp_limit);
if (display.getHigh() != graphics.upper_disp_limit) {
display.setHigh(graphics.upper_disp_limit);
changed = true;
}
if (display.getLow() != graphics.lower_disp_limit) {
display.setLow(graphics.lower_disp_limit);
changed = true;
}

}
if (changed) {
pvDisplay.set(display);
if (bitSet.get())
bitSet->set(displayField->getFieldOffset());
else
std::cout << "display: bitset == null" << std::endl;
}
PVDisplay pvDisplay;
pvDisplay.attach(pvStructure->getSubFieldT(displayString));
pvDisplay.set(display);
}
if(propertyMask&controlBit) {
PVControl pvControl;
PVStructurePtr controlField = pvStructure->getSubFieldT<PVStructure>(controlString);
pvControl.attach(controlField);
Control control;
pvControl.get(control);
bool changed = false;
struct rset *prset = dbGetRset(&dbAddr);
struct dbr_ctrlDouble graphics;
memset(&graphics,0,sizeof(graphics));
if(prset && prset->get_control_double) {
get_control_double cc =
(get_control_double)(prset->get_control_double);
cc(&dbAddr,&graphics);
control.setHigh(graphics.upper_ctrl_limit);
control.setLow(graphics.lower_ctrl_limit);
cc(&dbAddr, &graphics);
if (control.getHigh() != graphics.upper_ctrl_limit) {
control.setHigh(graphics.upper_ctrl_limit);
changed = true;
}
if (control.getLow() != graphics.lower_ctrl_limit) {
control.setLow(graphics.lower_ctrl_limit);
changed = true;
}
}
if (changed) {
pvControl.set(control);
if (bitSet.get())
bitSet->set(controlField->getFieldOffset());
}
PVControl pvControl;
pvControl.attach(pvStructure->getSubFieldT(controlString));
pvControl.set(control);
}
if(propertyMask&valueAlarmBit) {
struct rset *prset = dbGetRset(&dbAddr);
Expand All @@ -460,32 +510,53 @@ void DbUtil::getPropertyData(
cc(&dbAddr,&ald);
}
PVStructurePtr pvAlarmLimits =
pvStructure->getSubField<PVStructure>(valueAlarmString);
pvStructure->getSubFieldT<PVStructure>(valueAlarmString);
PVBooleanPtr pvActive = pvAlarmLimits->getSubField<PVBoolean>("active");
if(pvActive.get()!=NULL) pvActive->put(false);
PVFieldPtr pvf = pvAlarmLimits->getSubField(lowAlarmLimitString);
if(pvf.get()!=NULL && pvf->getField()->getType()==scalar) {
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(pvf);
getConvert()->fromDouble(pvScalar,ald.lower_alarm_limit);
PVScalarPtr pvScalar = pvAlarmLimits->getSubField<PVScalar>(lowAlarmLimitString);
if(pvScalar.get()!=NULL) {
double lowerAlarmLimit = getConvert()->toDouble(pvScalar);
if (lowerAlarmLimit != ald.lower_alarm_limit)
{
getConvert()->fromDouble(pvScalar,ald.lower_alarm_limit);
if (bitSet.get())
bitSet->set(pvScalar->getFieldOffset());
}
}
pvf = pvAlarmLimits->getSubField(lowWarningLimitString);
if(pvf.get()!=NULL && pvf->getField()->getType()==scalar) {
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(pvf);
getConvert()->fromDouble(pvScalar,ald.lower_warning_limit);
pvScalar = pvAlarmLimits->getSubField<PVScalar>(lowWarningLimitString);
if(pvScalar.get()!=NULL) {
double lowerWarningLimit = getConvert()->toDouble(pvScalar);
if (lowerWarningLimit != ald.lower_warning_limit)
{
getConvert()->fromDouble(pvScalar,ald.lower_warning_limit);
if (bitSet.get())
bitSet->set(pvScalar->getFieldOffset());
}
}
pvf = pvAlarmLimits->getSubField(highWarningLimitString);
if(pvf.get()!=NULL && pvf->getField()->getType()==scalar) {
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(pvf);
getConvert()->fromDouble(pvScalar,ald.upper_warning_limit);
pvScalar = pvAlarmLimits->getSubField<PVScalar>(highWarningLimitString);
if(pvScalar.get()!=NULL) {
double higherAlarmWarning = getConvert()->toDouble(pvScalar);
if (higherAlarmWarning != ald.upper_warning_limit)
{
getConvert()->fromDouble(pvScalar,ald.upper_warning_limit);
if (bitSet.get())
bitSet->set(pvScalar->getFieldOffset());
}
}
pvf = pvAlarmLimits->getSubField(highAlarmLimitString);
if(pvf.get()!=NULL && pvf->getField()->getType()==scalar) {
PVScalarPtr pvScalar = static_pointer_cast<PVScalar>(pvf);
getConvert()->fromDouble(pvScalar,ald.upper_alarm_limit);
pvScalar = pvAlarmLimits->getSubField<PVScalar>(highAlarmLimitString);
if(pvScalar.get()!=NULL) {
double higherAlarmLimit = getConvert()->toDouble(pvScalar);
if (higherAlarmLimit != ald.upper_alarm_limit)
{
getConvert()->fromDouble(pvScalar,ald.upper_alarm_limit);
if (bitSet.get())
bitSet->set(pvScalar->getFieldOffset());
}
}
}
}


Status DbUtil::get(
Requester::shared_pointer const &requester,
int propertyMask,DbAddr &dbAddr,
Expand Down Expand Up @@ -837,6 +908,9 @@ Status DbUtil::get(
bitSet->set(pvField->getFieldOffset());
}
}
getPropertyDataImpl(requester, propertyMask, dbAddr,
pvStructure, bitSet);

return Status::Ok;
}

Expand Down
6 changes: 6 additions & 0 deletions src/dbPv/3.14/dbUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ class DbUtil {
DbAddr &dbAddr);
private:
DbUtil();
void getPropertyDataImpl(
epics::pvData::Requester::shared_pointer const &requester,
int mask,
DbAddr &dbAddr,
epics::pvData::PVStructurePtr const &pvStructure,
epics::pvData::BitSet::shared_pointer const &bitSet);
epics::pvData::PVStructurePtr nullPVStructure;
std::string recordString;
std::string processString;
Expand Down
4 changes: 0 additions & 4 deletions src/dbPv/3.15/dbPvGet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ bool DbPvGet::init(PVStructure::shared_pointer const &pvRequest)
propertyMask,
dbPv->getDbChannel()));
if (!pvStructure.get()) return false;
dbUtil->getPropertyData(channelGetRequester,
propertyMask,
dbPv->getDbChannel(),
pvStructure);
int numFields = pvStructure->getNumberFields();
bitSet.reset(new BitSet(numFields));
if (propertyMask & dbUtil->processBit) {
Expand Down
2 changes: 0 additions & 2 deletions src/dbPv/3.15/dbPvMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ bool DbPvMonitor::init(
elements.push_back(element);
}
MonitorElementPtr element = elements[0];
dbUtil->getPropertyData(monitorRequester, propertyMask,
dbPv->getDbChannel(), element->pvStructurePtr);
StructureConstPtr saveStructure = element->pvStructurePtr->getStructure();
if((propertyMask&dbUtil->enumValueBit)!=0) {
caType = CaEnum;
Expand Down
Loading