- .NET API: added methods GetEntryID/SetEntryID to ReportControlBlock

- client API: added function ClientReport_getDataSetName
- common API: added function MmsValue_getStringSize
- API: changed some char* to const char*
pull/6/head
Michael Zillgith 10 years ago
parent d9c8d9cc1b
commit 386d2acd32

@ -429,6 +429,42 @@ namespace IEC61850
return retVal.AddMilliseconds (entryTime); return retVal.AddMilliseconds (entryTime);
} }
/// <summary>
/// Gets the entryID of RCB
/// </summary>
/// Returns the EntryID of the last received GetRCBValues service response.
/// The EntryID is only present in buffered RCBs (BRCBs).
///
/// <returns>The entry ID</returns>
public byte[] GetEntryID()
{
IntPtr entryIdRef = ClientReportControlBlock_getEntryId (self);
if (entryIdRef == IntPtr.Zero)
return null;
else {
MmsValue entryId = new MmsValue (entryIdRef);
return entryId.getOctetString ();
}
}
public void SetEntryID(byte[] entryId)
{
flagEntryId = true;
MmsValue entryID = MmsValue.NewOctetString (entryId.Length);
entryID.setOctetString (entryId);
ClientReportControlBlock_setEntryId (self, entryID.valueReference);
}
/// <summary> /// <summary>
/// Gets the data set reference of the associated data set /// Gets the data set reference of the associated data set
/// </summary> /// </summary>

@ -90,7 +90,7 @@ ClientGooseControlBlock_setGoEna(ClientGooseControlBlock self, bool goEna)
MmsValue_setBoolean(self->goEna, goEna); MmsValue_setBoolean(self->goEna, goEna);
} }
char* const char*
ClientGooseControlBlock_getGoID(ClientGooseControlBlock self) ClientGooseControlBlock_getGoID(ClientGooseControlBlock self)
{ {
if (self->goID != NULL) if (self->goID != NULL)
@ -108,7 +108,7 @@ ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, const char* goID)
MmsValue_setVisibleString(self->goID, goID); MmsValue_setVisibleString(self->goID, goID);
} }
char* const char*
ClientGooseControlBlock_getDatSet(ClientGooseControlBlock self) ClientGooseControlBlock_getDatSet(ClientGooseControlBlock self)
{ {
if (self->datSet != NULL) if (self->datSet != NULL)

@ -37,6 +37,10 @@ struct sClientReport
void* callbackParameter; void* callbackParameter;
char* rcbReference; char* rcbReference;
char* rptId; char* rptId;
char* dataSetName;
int dataSetNameSize; /* size of the dataSetName buffer */
MmsValue* entryId; MmsValue* entryId;
MmsValue* dataReferences; MmsValue* dataReferences;
MmsValue* dataSetValues; MmsValue* dataSetValues;
@ -106,6 +110,9 @@ ClientReport_destroy(ClientReport self)
if (self->reasonForInclusion != NULL) if (self->reasonForInclusion != NULL)
GLOBAL_FREEMEM(self->reasonForInclusion); GLOBAL_FREEMEM(self->reasonForInclusion);
if (self->dataSetName != NULL)
GLOBAL_FREEMEM((void*) self->dataSetName);
GLOBAL_FREEMEM(self); GLOBAL_FREEMEM(self);
} }
@ -221,6 +228,12 @@ ClientReport_getDataReference(ClientReport self, int elementIndex)
return dataReference; return dataReference;
} }
const char*
ClientReport_getDataSetName(ClientReport self)
{
return self->dataSetName;
}
MmsValue* MmsValue*
ClientReport_getDataSetValues(ClientReport self) ClientReport_getDataSetValues(ClientReport self)
{ {
@ -397,6 +410,26 @@ private_IedConnection_handleReport(IedConnection self, MmsValue* value)
/* check if data set name is present */ /* check if data set name is present */
if (MmsValue_getBitStringBit(optFlds, 4) == true) { if (MmsValue_getBitStringBit(optFlds, 4) == true) {
matchingReport->hasDataSetName = true; matchingReport->hasDataSetName = true;
MmsValue* dataSetName = MmsValue_getElement(value, inclusionIndex);
const char* dataSetNameStr = MmsValue_toString(dataSetName);
if (matchingReport->dataSetName == NULL) {
matchingReport->dataSetName = (char*) GLOBAL_MALLOC(MmsValue_getStringSize(dataSetName) + 1);
matchingReport->dataSetNameSize = MmsValue_getStringSize(dataSetName) + 1;
}
else {
if (matchingReport->dataSetNameSize < MmsValue_getStringSize(dataSetName) + 1) {
GLOBAL_FREEMEM((void*) matchingReport->dataSetName);
matchingReport->dataSetName = (char*) GLOBAL_MALLOC(MmsValue_getStringSize(dataSetName) + 1);
matchingReport->dataSetNameSize = MmsValue_getStringSize(dataSetName) + 1;
}
}
strcpy(matchingReport->dataSetName, dataSetNameStr);
inclusionIndex++; inclusionIndex++;
} }

@ -93,7 +93,7 @@ ClientReportControlBlock_isBuffered(ClientReportControlBlock self)
return self->isBuffered; return self->isBuffered;
} }
char* const char*
ClientReportControlBlock_getRptId(ClientReportControlBlock self) ClientReportControlBlock_getRptId(ClientReportControlBlock self)
{ {
if (self->rptId != NULL) if (self->rptId != NULL)
@ -150,7 +150,7 @@ ClientReportControlBlock_setResv(ClientReportControlBlock self, bool resv)
MmsValue_setBoolean(self->resv, resv); MmsValue_setBoolean(self->resv, resv);
} }
char* const char*
ClientReportControlBlock_getDataSetReference(ClientReportControlBlock self) ClientReportControlBlock_getDataSetReference(ClientReportControlBlock self)
{ {
if (self->datSet != NULL) if (self->datSet != NULL)

@ -238,7 +238,7 @@ ClientDataSet_getDataSetSize(ClientDataSet self)
} }
bool bool
private_IedConnection_doesControlObjectMatch(char* objRef, char* cntrlObj) private_IedConnection_doesControlObjectMatch(const char* objRef, const char* cntrlObj)
{ {
int i = 0; int i = 0;
@ -420,7 +420,7 @@ handleLastApplErrorMessage(IedConnection self, MmsValue* lastApplError)
while (control != NULL) { while (control != NULL) {
ControlObjectClient object = (ControlObjectClient) control->data; ControlObjectClient object = (ControlObjectClient) control->data;
char* objectRef = ControlObjectClient_getObjectReference(object); const char* objectRef = ControlObjectClient_getObjectReference(object);
if (private_IedConnection_doesControlObjectMatch(objectRef, MmsValue_toString(cntrlObj))) { if (private_IedConnection_doesControlObjectMatch(objectRef, MmsValue_toString(cntrlObj))) {
ControlObjectClient_setLastApplError(object, self->lastApplError); ControlObjectClient_setLastApplError(object, self->lastApplError);

@ -363,13 +363,13 @@ ClientGooseControlBlock_getGoEna(ClientGooseControlBlock self);
void void
ClientGooseControlBlock_setGoEna(ClientGooseControlBlock self, bool goEna); ClientGooseControlBlock_setGoEna(ClientGooseControlBlock self, bool goEna);
char* const char*
ClientGooseControlBlock_getGoID(ClientGooseControlBlock self); ClientGooseControlBlock_getGoID(ClientGooseControlBlock self);
void void
ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, const char* goID); ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, const char* goID);
char* const char*
ClientGooseControlBlock_getDatSet(ClientGooseControlBlock self); ClientGooseControlBlock_getDatSet(ClientGooseControlBlock self);
void void
@ -679,6 +679,17 @@ IedConnection_triggerGIReport(IedConnection self, IedClientError* error, const c
* Access to received reports * Access to received reports
****************************************/ ****************************************/
/**
* \brief Get the name of the report data set
*
* NOTE: the returned string is only valid as long as the ClientReport instance exists!
*
* \param self the ClientReport instance
* \return report data set name as 0 terminated string
*/
const char*
ClientReport_getDataSetName(ClientReport self);
/** /**
* \brief return the received data set values of the report * \brief return the received data set values of the report
* *
@ -843,7 +854,7 @@ ClientReportControlBlock_getObjectReference(ClientReportControlBlock self);
bool bool
ClientReportControlBlock_isBuffered(ClientReportControlBlock self); ClientReportControlBlock_isBuffered(ClientReportControlBlock self);
char* const char*
ClientReportControlBlock_getRptId(ClientReportControlBlock self); ClientReportControlBlock_getRptId(ClientReportControlBlock self);
void void
@ -861,7 +872,7 @@ ClientReportControlBlock_getResv(ClientReportControlBlock self);
void void
ClientReportControlBlock_setResv(ClientReportControlBlock self, bool resv); ClientReportControlBlock_setResv(ClientReportControlBlock self, bool resv);
char* const char*
ClientReportControlBlock_getDataSetReference(ClientReportControlBlock self); ClientReportControlBlock_getDataSetReference(ClientReportControlBlock self);
/** /**

@ -454,7 +454,7 @@ IedServer_getBitStringAttributeValue(IedServer self, const DataAttribute* dataAt
* *
* \return the value as a C string (null terminated string) * \return the value as a C string (null terminated string)
*/ */
char* const char*
IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute); IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute);

@ -73,7 +73,7 @@ IedClientError
private_IedConnection_mapMmsErrorToIedError(MmsError mmsError); private_IedConnection_mapMmsErrorToIedError(MmsError mmsError);
bool bool
private_IedConnection_doesControlObjectMatch(char* objRef, char* cntrlObj); private_IedConnection_doesControlObjectMatch(const char* objRef, const char* cntrlObj);
void void
private_IedConnection_addControlClient(IedConnection self, ControlObjectClient control); private_IedConnection_addControlClient(IedConnection self, ControlObjectClient control);

@ -118,10 +118,10 @@ ControlObject*
MmsMapping_getControlObject(MmsMapping* self, MmsDomain* domain, char* lnName, char* coName); MmsMapping_getControlObject(MmsMapping* self, MmsDomain* domain, char* lnName, char* coName);
MmsNamedVariableList MmsNamedVariableList
MmsMapping_getDomainSpecificVariableList(MmsMapping* self, char* variableListReference); MmsMapping_getDomainSpecificVariableList(MmsMapping* self, const char* variableListReference);
DataSet* DataSet*
MmsMapping_getDomainSpecificDataSet(MmsMapping* self, char* dataSetName); MmsMapping_getDomainSpecificDataSet(MmsMapping* self, const char* dataSetName);
void void
MmsMapping_freeDynamicallyCreatedDataSet(DataSet* dataSet); MmsMapping_freeDynamicallyCreatedDataSet(DataSet* dataSet);

@ -742,7 +742,7 @@ IedServer_getBitStringAttributeValue(IedServer self, const DataAttribute* dataAt
return MmsValue_getBitStringAsInteger(dataAttribute->mmsValue); return MmsValue_getBitStringAsInteger(dataAttribute->mmsValue);
} }
char* const char*
IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute) IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute)
{ {
assert(self != NULL); assert(self != NULL);
@ -933,7 +933,7 @@ IedServer_updateVisibleStringAttributeValue(IedServer self, DataAttribute* dataA
assert(dataAttribute != NULL); assert(dataAttribute != NULL);
assert(self != NULL); assert(self != NULL);
char *currentValue = MmsValue_toString(dataAttribute->mmsValue); const char *currentValue = MmsValue_toString(dataAttribute->mmsValue);
if (!strcmp(currentValue ,value)) { if (!strcmp(currentValue ,value)) {
checkForUpdateTrigger(self, dataAttribute); checkForUpdateTrigger(self, dataAttribute);

@ -187,7 +187,7 @@ MmsGooseControlBlock_enable(MmsGooseControlBlock self)
self->dataSet = NULL; self->dataSet = NULL;
char* dataSetRef = MmsValue_toString(MmsValue_getElement(self->mmsValue, 2)); const char* dataSetRef = MmsValue_toString(MmsValue_getElement(self->mmsValue, 2));
if (dataSetRef != NULL) { if (dataSetRef != NULL) {

@ -2744,7 +2744,7 @@ MmsMapping_createDataSetByNamedVariableList(MmsMapping* self, MmsNamedVariableLi
} }
MmsNamedVariableList MmsNamedVariableList
MmsMapping_getDomainSpecificVariableList(MmsMapping* self, char* variableListReference) MmsMapping_getDomainSpecificVariableList(MmsMapping* self, const char* variableListReference)
{ {
char variableListReferenceCopy[193]; char variableListReferenceCopy[193];
@ -2773,7 +2773,7 @@ MmsMapping_getDomainSpecificVariableList(MmsMapping* self, char* variableListRef
} }
DataSet* DataSet*
MmsMapping_getDomainSpecificDataSet(MmsMapping* self, char* dataSetName) MmsMapping_getDomainSpecificDataSet(MmsMapping* self, const char* dataSetName)
{ {
MmsNamedVariableList variableList = MmsMapping_getDomainSpecificVariableList(self, dataSetName); MmsNamedVariableList variableList = MmsMapping_getDomainSpecificVariableList(self, dataSetName);

@ -489,7 +489,7 @@ updateReportDataset(MmsMapping* mapping, ReportControl* rc, MmsValue* newDatSet,
} }
if (dataSetValue != NULL) { if (dataSetValue != NULL) {
char* dataSetName = MmsValue_toString(dataSetValue); const char* dataSetName = MmsValue_toString(dataSetValue);
DataSet* dataSet = IedModel_lookupDataSet(mapping->model, dataSetName); DataSet* dataSet = IedModel_lookupDataSet(mapping->model, dataSetName);

@ -292,9 +292,26 @@ MmsValue_setBoolean(MmsValue* value, bool boolValue);
bool bool
MmsValue_getBoolean(const MmsValue* value); MmsValue_getBoolean(const MmsValue* value);
char* /**
* \brief Returns the value of an MMS_VISIBLE_STRING object as C string
*
* \param self MmsValue instance to operate on. Has to be of a type MMS_VISIBLE_STRING or MMS_STRING.
*
* \returns the string value as 0 terminated C string
*/
const char*
MmsValue_toString(MmsValue* self); MmsValue_toString(MmsValue* self);
/**
* \brief Returns the (maximum) length of the string
*
* NOTE: this function return the amount of memory allocated for the string buffer - 1.
*
* \param self MmsValue instance to operate on. Has to be of a type MMS_VISIBLE_STRING or MMS_STRING.
*/
int
MmsValue_getStringSize(MmsValue* self);
void void
MmsValue_setVisibleString(MmsValue* self, const char* string); MmsValue_setVisibleString(MmsValue* self, const char* string);

@ -49,7 +49,7 @@ bool
MmsServerConnection_addNamedVariableList(MmsServerConnection self, MmsNamedVariableList variableList); MmsServerConnection_addNamedVariableList(MmsServerConnection self, MmsNamedVariableList variableList);
MmsNamedVariableList MmsNamedVariableList
MmsServerConnection_getNamedVariableList(MmsServerConnection self, char* variableListName); MmsServerConnection_getNamedVariableList(MmsServerConnection self, const char* variableListName);
LinkedList LinkedList
MmsServerConnection_getNamedVariableLists(MmsServerConnection self); MmsServerConnection_getNamedVariableLists(MmsServerConnection self);

@ -1727,7 +1727,7 @@ MmsValue_setVisibleString(MmsValue* self, const char* string)
} }
} }
char* const char*
MmsValue_toString(MmsValue* self) MmsValue_toString(MmsValue* self)
{ {
if ((self->type == MMS_VISIBLE_STRING) || (self->type == MMS_STRING)) if ((self->type == MMS_VISIBLE_STRING) || (self->type == MMS_STRING))
@ -1736,6 +1736,15 @@ MmsValue_toString(MmsValue* self)
return NULL; return NULL;
} }
int
MmsValue_getStringSize(MmsValue* self)
{
if ((self->type == MMS_VISIBLE_STRING) || (self->type == MMS_STRING))
return self->value.visibleString.size;
else
return 0;
}
MmsValue* MmsValue*
MmsValue_newUtcTime(uint32_t timeval) MmsValue_newUtcTime(uint32_t timeval)
{ {

@ -353,7 +353,7 @@ MmsServerConnection_deleteNamedVariableList(MmsServerConnection self, char* list
} }
MmsNamedVariableList MmsNamedVariableList
MmsServerConnection_getNamedVariableList(MmsServerConnection self, char* variableListName) MmsServerConnection_getNamedVariableList(MmsServerConnection self, const char* variableListName)
{ {
//TODO remove code duplication - similar to MmsDomain_getNamedVariableList ! //TODO remove code duplication - similar to MmsDomain_getNamedVariableList !
MmsNamedVariableList variableList = NULL; MmsNamedVariableList variableList = NULL;

@ -492,4 +492,6 @@ EXPORTS
ControlObjectClient_useConstantT ControlObjectClient_useConstantT
ControlObjectClient_setOrigin ControlObjectClient_setOrigin
LogicalDevice_getChildByMmsVariableName LogicalDevice_getChildByMmsVariableName
LogicalNode_getDataSet LogicalNode_getDataSet
ClientReport_getDataSetName
MmsValue_getStringSize

@ -517,3 +517,5 @@ EXPORTS
ControlObjectClient_setOrigin ControlObjectClient_setOrigin
LogicalDevice_getChildByMmsVariableName LogicalDevice_getChildByMmsVariableName
LogicalNode_getDataSet LogicalNode_getDataSet
ClientReport_getDataSetName
MmsValue_getStringSize

Loading…
Cancel
Save