- changed behaviour of CommandTermination- and LastApplError message

This commit is contained in:
Michael Zillgith 2015-01-08 12:08:57 +01:00
parent 91b9c2c64b
commit 7f1714e4af
10 changed files with 69 additions and 58 deletions

View file

@ -85,10 +85,10 @@ editSgConfirmedHandler(void* parameter, SettingGroupControlBlock* sgcb,
{
printf("Received edit sg confirm for sg %i\n", editSg);
ptoc1Settings[editSg - 1].strVal = MmsValue_toFloat(IEDMODEL_PROT_PTOC1_StrVal_setMag_f->mmsValue);
ptoc1Settings[editSg - 1].opDlTmms = MmsValue_toInt32(IEDMODEL_PROT_PTOC1_OpDlTmms_setVal->mmsValue);
ptoc1Settings[editSg - 1].rsDlTmms = MmsValue_toInt32(IEDMODEL_PROT_PTOC1_RsDlTmms_setVal->mmsValue);
ptoc1Settings[editSg - 1].rstTms = MmsValue_toInt32(IEDMODEL_PROT_PTOC1_RstTms_setVal->mmsValue);
ptoc1Settings[editSg - 1].strVal = MmsValue_toFloat(IEDMODEL_SE_PROT_PTOC1_StrVal_setMag_f->mmsValue);
ptoc1Settings[editSg - 1].opDlTmms = MmsValue_toInt32(IEDMODEL_SE_PROT_PTOC1_OpDlTmms_setVal->mmsValue);
ptoc1Settings[editSg - 1].rsDlTmms = MmsValue_toInt32(IEDMODEL_SE_PROT_PTOC1_RsDlTmms_setVal->mmsValue);
ptoc1Settings[editSg - 1].rstTms = MmsValue_toInt32(IEDMODEL_SE_PROT_PTOC1_RstTms_setVal->mmsValue);
if (IedServer_getActiveSettingGroup(iedServer, sgcb) == editSg) {
loadActiveSgValues(editSg);

View file

@ -231,4 +231,3 @@ StringUtils_startsWith(char* string, char* prefix)
return false;
}

View file

@ -82,7 +82,7 @@ Handleset_addSocket(HandleSet self, const Socket sock);
* The function shall return -1 if a socket error occures.
*
* \param self the HandleSet instance
* \oaram timeout in milliseconds (ms)
* \param timeout in milliseconds (ms)
*/
int
Handleset_waitReady(HandleSet self, unsigned int timeoutMs);

View file

@ -56,7 +56,7 @@ struct sServerSocket {
struct sHandleSet {
fd_set handles;
int maxHandle;
SOCKET maxHandle;
};
HandleSet
@ -66,7 +66,7 @@ Handleset_new(void)
if (result != NULL) {
FD_ZERO(&result->handles);
result->maxHandle = -1;
result->maxHandle = INVALID_SOCKET;
}
return result;
}
@ -74,11 +74,11 @@ Handleset_new(void)
void
Handleset_addSocket(HandleSet self, const Socket sock)
{
if (self != NULL && sock != NULL && sock->fd != -1) {
if (self != NULL && sock != NULL && sock->fd != INVALID_SOCKET) {
FD_SET(sock->fd, &self->handles);
if (sock->fd > self->maxHandle) {
if ((sock->fd > self->maxHandle) || (self->maxHandle == INVALID_SOCKET))
self->maxHandle = sock->fd;
}
}
}
@ -302,16 +302,6 @@ Socket_connect(Socket self, const char* address, int port)
FD_ZERO(&fdSet);
FD_SET(self->fd, &fdSet);
// if (connect(self->fd, (struct sockaddr *) &serverAddress,sizeof(serverAddress)) < 0) {
// if (DEBUG_SOCKET)
// printf("WIN32_SOCKET: Socket failed connecting!\n");
// return false;
// }
// else {
//
// return true;
// }
if (connect(self->fd, (struct sockaddr *) &serverAddress, sizeof(serverAddress)) == SOCKET_ERROR) {
if (WSAGetLastError() != WSAEWOULDBLOCK)
return false;

View file

@ -237,7 +237,7 @@ ClientGooseControlBlock_setDstAddress_vid(ClientGooseControlBlock self, uint16_t
self->dstAddress = newEmptyPhyCommAddress();
MmsValue* vid = MmsValue_getElement(self->dstAddress, 2);
MmsValue_setUint8(vid, vidValue);
MmsValue_setUint16(vid, vidValue);
}
uint16_t
@ -256,7 +256,7 @@ ClientGooseControlBlock_setDstAddress_appid(ClientGooseControlBlock self, uint16
self->dstAddress = newEmptyPhyCommAddress();
MmsValue* appid = MmsValue_getElement(self->dstAddress, 3);
MmsValue_setUint8(appid, appidValue);
MmsValue_setUint16(appid, appidValue);
}
static void

View file

@ -328,6 +328,8 @@ private_IedConnection_handleReport(IedConnection self, MmsValue* value)
char* rptId = report->rptId;
printf("Report ID is null!\n");
if (rptId == NULL)
rptId = report->rcbReference;

View file

@ -198,6 +198,9 @@ ClientDataSet_getDataSetSize(ClientDataSet self)
static bool
doesControlObjectMatch(char* objRef, char* cntrlObj)
{
printf("objRef: (%s) cntrlObj: (%s)\n", objRef, cntrlObj);
int objRefLen = strlen(objRef);
char* separator = strchr(cntrlObj, '$');
@ -222,17 +225,31 @@ doesControlObjectMatch(char* objRef, char* cntrlObj)
if (separator[3] != '$')
return false;
char* nextSeparator = strchr(separator + 4, '$');
printf("Compare strings: (%s) vs (%s)\n", cntrlObjName, separator +4);
if (nextSeparator == NULL)
return false;
// char* nextSeparator = strchr(separator + 4, '$');
// if (nextSeparator == NULL)
// return false;
int cntrlObjNameLen = strlen(cntrlObjName);
if (cntrlObjNameLen != nextSeparator - (separator + 4))
char* secondCntrlObjName = separator + 4;
if (cntrlObjNameLen != strlen(secondCntrlObjName))
return false;
if (memcmp(cntrlObjName, separator + 4, cntrlObjNameLen) == 0)
// if (cntrlObjNameLen != nextSeparator - (separator + 4))
// return false;
// int i;
// for (i = 0; i < cntrlObjNameLen; i++) {
// if (controlObjName )
// }
if (memcmp(cntrlObjName, secondCntrlObjName, cntrlObjNameLen) == 0)
return true;
return false;

View file

@ -115,7 +115,7 @@ struct sControlObject
};
void
ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection* connection, char* ctlVariable, int error,
ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection* connection, int error,
ControlAddCause addCause, MmsValue* ctlNum, MmsValue* origin, bool handlerMode);
void
@ -361,7 +361,7 @@ executeStateMachine:
if (dynamicCheckResult == CONTROL_RESULT_FAILED) {
if (isTimeActivatedControl) {
ControlObject_sendLastApplError(self, self->mmsConnection, "Oper",
ControlObject_sendLastApplError(self, self->mmsConnection,
CONTROL_ERROR_NO_ERROR, ADD_CAUSE_BLOCKED_BY_SYNCHROCHECK,
self->ctlNum, self->origin, false);
}
@ -688,7 +688,7 @@ Control_processControlActions(MmsMapping* self, uint64_t currentTimeInMs)
executeControlTask(controlObject);
}
else {
ControlObject_sendLastApplError(controlObject, controlObject->mmsConnection, "Oper",
ControlObject_sendLastApplError(controlObject, controlObject->mmsConnection,
CONTROL_ERROR_NO_ERROR, ADD_CAUSE_BLOCKED_BY_INTERLOCKING,
controlObject->ctlNum, controlObject->origin, false);
@ -887,16 +887,12 @@ ControlObject_sendCommandTerminationNegative(ControlObject* self)
lastApplError->value.structure.components = componentContainer;
char ctlObj[130];
createStringInBuffer(ctlObj, 2, self->ctlObjectName, "$Oper");
MmsValue ctlObjValueMemory;
MmsValue* ctlObjValue = &ctlObjValueMemory;
ctlObjValue->type = MMS_VISIBLE_STRING;
ctlObjValue->value.visibleString.buf = ctlObj;
ctlObjValue->value.visibleString.size = sizeof(ctlObj);
ctlObjValue->value.visibleString.buf = self->ctlObjectName;
ctlObjValue->value.visibleString.size = sizeof(self->ctlObjectName);
MmsValue_setElement(lastApplError, 0, ctlObjValue);
@ -926,7 +922,6 @@ ControlObject_sendCommandTerminationNegative(ControlObject* self)
operVarSpec.itemId = itemId;
operVarSpec.domainId = domainId;
/* create response */
if (DEBUG_IED_SERVER)
@ -949,7 +944,7 @@ ControlObject_sendCommandTerminationNegative(ControlObject* self)
void
ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection* connection, char* ctlVariable, int error,
ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection* connection, int error,
ControlAddCause addCause, MmsValue* ctlNum, MmsValue* origin, bool handlerMode)
{
MmsValue lastApplErrorMemory;
@ -962,13 +957,9 @@ ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection* connec
lastApplError->value.structure.components =componentContainer;
char ctlObj[130];
createStringInBuffer(ctlObj, 3, self->ctlObjectName, "$", ctlVariable);
if (DEBUG_IED_SERVER) {
printf("IED_SERVER: sendLastApplError:\n");
printf("IED_SERVER: control object: %s\n", ctlObj);
printf("IED_SERVER: control object: %s\n", self->ctlObjectName);
printf("IED_SERVER: ctlNum: %u\n", MmsValue_toUint32(ctlNum));
}
@ -976,8 +967,8 @@ ControlObject_sendLastApplError(ControlObject* self, MmsServerConnection* connec
MmsValue* ctlObjValue = &ctlObjValueMemory;
ctlObjValue->type = MMS_VISIBLE_STRING;
ctlObjValue->value.visibleString.buf = ctlObj;
ctlObjValue->value.visibleString.size = sizeof(ctlObj);
ctlObjValue->value.visibleString.buf = self->ctlObjectName;
ctlObjValue->value.visibleString.size = sizeof(self->ctlObjectName);
MmsValue_setElement(lastApplError, 0, ctlObjValue);
@ -1313,10 +1304,10 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari
indication = DATA_ACCESS_ERROR_TEMPORARILY_UNAVAILABLE;
if (connection != controlObject->mmsConnection)
ControlObject_sendLastApplError(controlObject, connection, "SBOw", 0,
ControlObject_sendLastApplError(controlObject, connection, 0,
ADD_CAUSE_LOCKED_BY_OTHER_CLIENT, ctlNum, origin, true);
else
ControlObject_sendLastApplError(controlObject, connection, "SBOw", 0,
ControlObject_sendLastApplError(controlObject, connection, 0,
ADD_CAUSE_OBJECT_ALREADY_SELECTED, ctlNum, origin, true);
if (DEBUG_IED_SERVER)
@ -1353,7 +1344,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari
else {
indication = getDataAccessErrorFromCheckHandlerResult(checkResult);
ControlObject_sendLastApplError(controlObject, connection, "SBOw", 0,
ControlObject_sendLastApplError(controlObject, connection, 0,
ADD_CAUSE_SELECT_FAILED, ctlNum, origin, true);
if (DEBUG_IED_SERVER)
@ -1398,7 +1389,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari
if (state == STATE_WAIT_FOR_ACTICATION_TIME) {
indication = DATA_ACCESS_ERROR_TEMPORARILY_UNAVAILABLE;
ControlObject_sendLastApplError(controlObject, connection, "Oper",
ControlObject_sendLastApplError(controlObject, connection,
CONTROL_ERROR_NO_ERROR, ADD_CAUSE_COMMAND_ALREADY_IN_EXECUTION,
ctlNum, origin, true);
@ -1428,7 +1419,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari
{
indication = DATA_ACCESS_ERROR_TYPE_INCONSISTENT;
ControlObject_sendLastApplError(controlObject, connection, "Oper",
ControlObject_sendLastApplError(controlObject, connection,
CONTROL_ERROR_NO_ERROR, ADD_CAUSE_INCONSISTENT_PARAMETERS,
ctlNum, origin, true);
@ -1508,7 +1499,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari
printf("IED_SERVER: Oper failed - control not selected!\n");
indication = DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED;
ControlObject_sendLastApplError(controlObject, connection, "Oper",
ControlObject_sendLastApplError(controlObject, connection,
CONTROL_ERROR_NO_ERROR, ADD_CAUSE_OBJECT_NOT_SELECTED,
ctlNum, origin, true);
@ -1540,7 +1531,7 @@ Control_writeAccessControlObject(MmsMapping* self, MmsDomain* domain, char* vari
}
else {
indication = DATA_ACCESS_ERROR_TEMPORARILY_UNAVAILABLE;
ControlObject_sendLastApplError(controlObject, connection, "Cancel",
ControlObject_sendLastApplError(controlObject, connection,
CONTROL_ERROR_NO_ERROR, ADD_CAUSE_LOCKED_BY_OTHER_CLIENT,
ctlNum, origin, true);
}

View file

@ -1602,9 +1602,14 @@ mmsWriteHandler(void* parameter, MmsDomain* domain,
if ((val > 0) && (val <= sg->sgcb->numOfSGs)) {
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;

View file

@ -58,7 +58,6 @@ readLine(FileHandle fileHandle, uint8_t* buffer, int maxSize)
}
}
if (fileReadResult > 0) {
while (fileReadResult > 0) {
fileReadResult = FileSystem_readFile(fileHandle, buffer + bufPos, 1);
@ -238,8 +237,12 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
#if (CONFIG_IEC61850_SETTING_GROUPS == 1)
else if (StringUtils_startsWith((char*) lineBuffer, "SG")) {
if (strcmp(currentLN->name, "LLN0") != 0)
if (strcmp(currentLN->name, "LLN0") != 0) {
if (DEBUG_IED_SERVER)
printf("Setting group control is not defined in LLN0\n");
goto exit_error;
}
int actSG;
int numOfSGs;
@ -253,8 +256,12 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
}
#endif /* (CONFIG_IEC61850_SETTING_GROUPS == 1) */
else
else {
// if (DEBUG_IED_SERVER)
printf("IED_SERVER: Unknown identifier (%s)\n", lineBuffer);
goto exit_error;
}
}
else if (indendation > 3) {
@ -423,8 +430,8 @@ ConfigFileParser_createModelFromConfigFile(FileHandle fileHandle)
return model;
exit_error:
if (DEBUG_IED_SERVER)
printf("error parsing line %i\n", currentLine);
// if (DEBUG_IED_SERVER)
printf("IED_SERVER: error parsing line %i (indendation level = %i)\n", currentLine, indendation);
IedModel_destroy(model);
return NULL;
}