- .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);
}
/// <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>
/// Gets the data set reference of the associated data set
/// </summary>

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

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

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

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

@ -363,13 +363,13 @@ ClientGooseControlBlock_getGoEna(ClientGooseControlBlock self);
void
ClientGooseControlBlock_setGoEna(ClientGooseControlBlock self, bool goEna);
char*
const char*
ClientGooseControlBlock_getGoID(ClientGooseControlBlock self);
void
ClientGooseControlBlock_setGoID(ClientGooseControlBlock self, const char* goID);
char*
const char*
ClientGooseControlBlock_getDatSet(ClientGooseControlBlock self);
void
@ -679,6 +679,17 @@ IedConnection_triggerGIReport(IedConnection self, IedClientError* error, const c
* 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
*
@ -843,7 +854,7 @@ ClientReportControlBlock_getObjectReference(ClientReportControlBlock self);
bool
ClientReportControlBlock_isBuffered(ClientReportControlBlock self);
char*
const char*
ClientReportControlBlock_getRptId(ClientReportControlBlock self);
void
@ -861,7 +872,7 @@ ClientReportControlBlock_getResv(ClientReportControlBlock self);
void
ClientReportControlBlock_setResv(ClientReportControlBlock self, bool resv);
char*
const char*
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)
*/
char*
const char*
IedServer_getStringAttributeValue(IedServer self, const DataAttribute* dataAttribute);

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

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

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

@ -187,7 +187,7 @@ MmsGooseControlBlock_enable(MmsGooseControlBlock self)
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) {

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

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

@ -292,9 +292,26 @@ MmsValue_setBoolean(MmsValue* value, bool boolValue);
bool
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);
/**
* \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
MmsValue_setVisibleString(MmsValue* self, const char* string);

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

@ -1727,7 +1727,7 @@ MmsValue_setVisibleString(MmsValue* self, const char* string)
}
}
char*
const char*
MmsValue_toString(MmsValue* self)
{
if ((self->type == MMS_VISIBLE_STRING) || (self->type == MMS_STRING))
@ -1736,6 +1736,15 @@ MmsValue_toString(MmsValue* self)
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_newUtcTime(uint32_t timeval)
{

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

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

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

Loading…
Cancel
Save