- solve client problem with some implementations of LastApplError (missing $Oper as by TMW Anvil)

This commit is contained in:
Michael Zillgith 2015-01-08 14:17:09 +01:00
parent 98ec51346c
commit 83a7e7cfdc
3 changed files with 52 additions and 30 deletions

View file

@ -195,47 +195,70 @@ ClientDataSet_getDataSetSize(ClientDataSet self)
return 0;
}
static bool
doesControlObjectMatch(char* objRef, char* cntrlObj)
bool
private_IedConnection_doesControlObjectMatch(char* objRef, char* cntrlObj)
{
int objRefLen = strlen(objRef);
int i = 0;
char* separator = strchr(cntrlObj, '$');
while (objRef[i] != '/') {
if (objRef[i] != cntrlObj[i])
return false;
if (separator == NULL)
i++;
}
if (cntrlObj[i] != '/')
return false;
int sepLen = separator - cntrlObj;
// --> LD is equal
if (sepLen >= objRefLen)
i++;
while (objRef[i] != '.') {
if (objRef[i] != cntrlObj[i])
return false;
i++;
}
int j = i;
if (cntrlObj[j++] != '$')
return false;
if (memcmp(objRef, cntrlObj, sepLen) != 0)
// --> LN is equal
if (cntrlObj[j++] != 'C')
return false;
if (cntrlObj[j++] != 'O')
return false;
if (cntrlObj[j++] != '$')
return false;
char* cntrlObjName = objRef + sepLen + 1;
// --> FC is ok
if (separator[1] != 'C')
return false;
if (separator[2] != 'O')
return false;
if (separator[3] != '$')
return false;
i++;
char* nextSeparator = strchr(separator + 4, '$');
while (objRef[i] != 0) {
if (cntrlObj[j] == 0)
return false;
if (nextSeparator == NULL)
return false;
if (objRef[i] == '.') {
if (cntrlObj[j] != '$')
return false;
}
else {
if (objRef[i] != cntrlObj[j])
return false;
}
int cntrlObjNameLen = strlen(cntrlObjName);
i++;
j++;
}
if (cntrlObjNameLen != nextSeparator - (separator + 4))
return false;
if (memcmp(cntrlObjName, separator + 4, cntrlObjNameLen) == 0)
if ((cntrlObj[j] == 0) || (cntrlObj[j] == '$'))
return true;
return false;
else
return false;
}
static bool
@ -357,7 +380,7 @@ handleLastApplErrorMessage(IedConnection self, MmsValue* lastApplError)
char* objectRef = ControlObjectClient_getObjectReference(object);
if (doesControlObjectMatch(objectRef, MmsValue_toString(cntrlObj))) {
if (private_IedConnection_doesControlObjectMatch(objectRef, MmsValue_toString(cntrlObj))) {
ControlObjectClient_setLastApplError(object, self->lastApplError);
}

View file

@ -71,6 +71,9 @@ struct sClientReportControlBlock {
IedClientError
private_IedConnection_mapMmsErrorToIedError(MmsError mmsError);
bool
private_IedConnection_doesControlObjectMatch(char* objRef, char* cntrlObj);
void
private_IedConnection_addControlClient(IedConnection self, ControlObjectClient control);

View file

@ -1603,13 +1603,9 @@ mmsWriteHandler(void* parameter, MmsDomain* domain,
if (sg->editSgChangedHandler != NULL) {
printf("has editSgChangedHandler\n");
if (sg->editSgChangedHandler(sg->editSgChangedHandlerParameter, sg->sgcb,
(uint8_t) val, (ClientConnection) connection))
{
printf("handler returned true\n");
sg->sgcb->editSG = val;
sg->editingClient = (ClientConnection) connection;