From d6c180ec38d34700c5caef96418bd761644928b3 Mon Sep 17 00:00:00 2001 From: Ruud Overeem <overeem@astron.nl> Date: Thu, 12 Feb 2009 14:37:12 +0000 Subject: [PATCH] Bug 1317: Bug solved. Conditional Write works fine now. --- MAC/APL/RTDBCommon/src/RTDButilities.cc | 6 +++- .../src/HardwareMonitor/RSPMonitor.cc | 16 +++++----- MAC/GCF/PVSS/src/PVSSservice.cc | 24 ++++++++++---- MAC/GCF/RTDB/src/DPservice.cc | 4 ++- MAC/GCF/RTDB/src/RTDB_PropertySet.cc | 31 ++++++------------- 5 files changed, 44 insertions(+), 37 deletions(-) diff --git a/MAC/APL/RTDBCommon/src/RTDButilities.cc b/MAC/APL/RTDBCommon/src/RTDButilities.cc index 37d448535c7..4678bc561ed 100644 --- a/MAC/APL/RTDBCommon/src/RTDButilities.cc +++ b/MAC/APL/RTDBCommon/src/RTDButilities.cc @@ -83,7 +83,11 @@ bool setObjectState(const string& who, LOG_DEBUG_STR(who << " is setting " << objectName << " to " << objStateTable[newStateIndex].name); - return (aDPservice.setValue("__navObjectState", fields, values, 0.0, false) == SA_NO_ERROR); + PVSSresult result = aDPservice.setValue("__navObjectState", fields, values, 0.0, false); + if (result != SA_NO_ERROR) { + LOG_WARN_STR("Call to PVSS for setObjectState returned: " << result); + } + return (result == SA_NO_ERROR); } // diff --git a/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc b/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc index 78d4f3ff635..6fa2b55d18f 100644 --- a/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc +++ b/MAC/APL/StationCU/src/HardwareMonitor/RSPMonitor.cc @@ -346,30 +346,31 @@ GCFEvent::TResult RSPMonitor::createPropertySets(GCFEvent& event, if (rcu % (NR_RCUS_PER_CABINET) == 0) { cabinet++; string PSname(formatString(cabinetNameMask.c_str(), cabinet)); -// itsCabinets[cabinet] = new RTDBPropertySet(PSname, PST_CABINET, PSAT_WO | PSAT_CW, this); - itsCabinets[cabinet] = new RTDBPropertySet(PSname, PST_CABINET, PSAT_WO, this); + itsCabinets[cabinet] = new RTDBPropertySet(PSname, PST_CABINET, PSAT_WO | PSAT_CW, this); +// itsCabinets[cabinet] = new RTDBPropertySet(PSname, PST_CABINET, PSAT_WO, this); } // new subrack? if (rcu % (NR_RCUS_PER_SUBRACK) == 0) { subrack++; string PSname(formatString(subrackNameMask.c_str(), cabinet, subrack)); -// itsSubracks[subrack] = new RTDBPropertySet(PSname, PST_SUB_RACK, PSAT_WO | PSAT_CW, this); + itsSubracks[subrack] = new RTDBPropertySet(PSname, PST_SUB_RACK, PSAT_WO | PSAT_CW, this); itsSubracks[subrack] = new RTDBPropertySet(PSname, PST_SUB_RACK, PSAT_WO, this); +// } // new RSPboard? if (rcu % (NR_RCUS_PER_RSPBOARD) == 0) { RSP++; string PSname(formatString(rspboardNameMask.c_str(), cabinet, subrack, RSP)); -// itsRSPs[RSP] = new RTDBPropertySet(PSname, PST_RSP_BOARD, PSAT_WO | PSAT_CW, this); - itsRSPs[RSP] = new RTDBPropertySet(PSname, PST_RSP_BOARD, PSAT_WO, this); + itsRSPs[RSP] = new RTDBPropertySet(PSname, PST_RSP_BOARD, PSAT_WO | PSAT_CW, this); +// itsRSPs[RSP] = new RTDBPropertySet(PSname, PST_RSP_BOARD, PSAT_WO, this); } // allocate RCU PS string PSname(formatString(rcuNameMask.c_str(), cabinet, subrack, RSP, rcu)); -// itsRCUs[rcu] = new RTDBPropertySet(PSname, PST_RCU, PSAT_WO | PSAT_CW, this); - itsRCUs[rcu] = new RTDBPropertySet(PSname, PST_RCU, PSAT_WO, this); + itsRCUs[rcu] = new RTDBPropertySet(PSname, PST_RCU, PSAT_WO | PSAT_CW, this); +// itsRCUs[rcu] = new RTDBPropertySet(PSname, PST_RCU, PSAT_WO, this); usleep (2000); // wait 2 ms in order not to overload the system } itsTimerPort->setTimer(5.0); // give database some time to finish the job @@ -1104,6 +1105,7 @@ GCFEvent::TResult RSPMonitor::waitForNextCycle(GCFEvent& event, break; case F_TIMER: { + itsOwnPropertySet->setValue(string(PN_FSM_ERROR),GCFPVString("")); TRAN(RSPMonitor::askRSPinfo); } break; diff --git a/MAC/GCF/PVSS/src/PVSSservice.cc b/MAC/GCF/PVSS/src/PVSSservice.cc index 499f2937877..c2d8c1a05dd 100644 --- a/MAC/GCF/PVSS/src/PVSSservice.cc +++ b/MAC/GCF/PVSS/src/PVSSservice.cc @@ -959,14 +959,18 @@ PVSSresult PVSSservice::dpeSetMultiple(const string& dpName, // DB must be active if ((result = itsSCADAHandler->isOperational()) != SA_NO_ERROR) { LOG_FATAL_STR("Database Down, unable to set value of property: " << dpName); - itsResponse->dpeValueSet(dpName, result); + if (wantAnswer) { + itsResponse->dpeValueSet(dpName, result); + } return (result); } // Property must exist if (!PVSSinfo::propExists(dpName)) { LOG_WARN(formatString("Property: '%s' does not exists", dpName.c_str())); - itsResponse->dpeValueSet(dpName, (result = SA_PROP_DOES_NOT_EXIST)); + if (wantAnswer) { + itsResponse->dpeValueSet(dpName, (result = SA_PROP_DOES_NOT_EXIST)); + } return (result); } @@ -979,18 +983,24 @@ PVSSresult PVSSservice::dpeSetMultiple(const string& dpName, convPropToDpConfig(dpName+"."+*nameIter, pvssDpName, false); // add .:_original.._value if ((result = getDpId(pvssDpName, dpId)) != SA_NO_ERROR) { LOG_ERROR(formatString("Property: '%s' is unknown", pvssDpName.c_str())); - itsResponse->dpeValueSet(dpName, result); + if (wantAnswer) { + itsResponse->dpeValueSet(dpName, result); + } return (result); } if ((result = convertMACToPVSS(**valIter, &pVar, dpId)) != SA_NO_ERROR) { LOG_ERROR(formatString("Property: '%s' can not be converted to PVSS type", pvssDpName.c_str())); - itsResponse->dpeValueSet(dpName, result); + if (wantAnswer) { + itsResponse->dpeValueSet(dpName, result); + } return (result); } if (!dpIdList.appendItem(dpId, *pVar)) { LOG_ERROR_STR("Adding " << *nameIter << " to the argument list failed"); - itsResponse->dpeValueSet(dpName, (result = SA_SETPROP_FAILED)); + if (wantAnswer) { + itsResponse->dpeValueSet(dpName, (result = SA_SETPROP_FAILED)); + } return (result); } if (pVar) { @@ -1056,7 +1066,9 @@ PVSSresult PVSSservice::dpeSetMultiple(const string& dpName, } if (result != SA_NO_ERROR) { - itsResponse->dpeValueSet(dpName, result); + if (wantAnswer) { + itsResponse->dpeValueSet(dpName, result); + } } return (result); diff --git a/MAC/GCF/RTDB/src/DPservice.cc b/MAC/GCF/RTDB/src/DPservice.cc index 2ba77a30f46..978dadc5a53 100644 --- a/MAC/GCF/RTDB/src/DPservice.cc +++ b/MAC/GCF/RTDB/src/DPservice.cc @@ -93,7 +93,9 @@ PVSSresult DPservice::setValue (const string& DPname, // write value to it. if (valueObj->setValue(value) != GCF_NO_ERROR) { LOG_WARN_STR("Could not set value for DP " << DPname); - itsExtResponse->dpeValueSet(DPname, SA_SETPROP_FAILED); + if (wantAnswer) { + itsExtResponse->dpeValueSet(DPname, SA_SETPROP_FAILED); + } return (SA_SETPROP_FAILED); } diff --git a/MAC/GCF/RTDB/src/RTDB_PropertySet.cc b/MAC/GCF/RTDB/src/RTDB_PropertySet.cc index 9ff7b69af48..997771a4c44 100644 --- a/MAC/GCF/RTDB/src/RTDB_PropertySet.cc +++ b/MAC/GCF/RTDB/src/RTDB_PropertySet.cc @@ -101,22 +101,6 @@ RTDBPropertySet::~RTDBPropertySet() delete itsService; } -#if 0 -// -// operator[](propName) -// -RTDBProperty& RTDBPropertySet::operator[] (const string& propName) -{ - RTDBProperty* propPtr = _getProperty(propName); -// TODO -// if (propPtr == 0) { -// propPtr = &dummyPropInfo; -// } - - return (*propPtr); -} -#endif - // // setValue(propName, value, timestamp, immediately) // @@ -133,12 +117,13 @@ PVSSresult RTDBPropertySet::setValue (const string& propName, } // if ConditionWrite=true and value not changed then we are ready. - if ((itsAccessType & PSAT_CW) && (*(propPtr->value) == value)) { - LOG_TRACE_COND_STR("CW: value not changed: " << value.getValueAsString()); + if ((itsAccessType & PSAT_CW) && propPtr->initialized && (*(propPtr->value) == value)) { + LOG_TRACE_COND_STR("CW: value of " << propName << " not changed: " << value.getValueAsString()); return (SA_NO_ERROR); } // adopt value propPtr->value->copy(value); + propPtr->initialized = true; // update admin propPtr->dirty = !immediately; @@ -171,15 +156,17 @@ PVSSresult RTDBPropertySet::setValue (const string& propName, } // if ConditionWrite=true and value not changed then we are ready. -// if ((itsAccessType & PSAT_CW) && propPtr->value->getValue() == value) { -// return (SA_NO_ERROR); -// } + if ((itsAccessType & PSAT_CW) && propPtr->initialized && propPtr->value->getValueAsString() == value) { + LOG_TRACE_COND_STR("CW: value of " << propName << " not changed: " << value); + return (SA_NO_ERROR); + } // adopt value if ((propPtr->value->setValue(value)) != GCF_NO_ERROR) { dpeValueSet(propName, SA_SETPROP_FAILED); return (SA_SETPROP_FAILED); } + propPtr->initialized = true; // update admin propPtr->dirty = !immediately; @@ -292,7 +279,7 @@ void RTDBPropertySet::_createAllProperties() sysNr = PVSSinfo::getLocalSystemId(); } - // allocate a list that can be fille with the PropInfo of all elements + // allocate a list that can be filled with the PropInfo of all elements typedef list<TPropertyInfo> PropInfoList_t; PropInfoList_t itsPropInfoList; -- GitLab