pull/444/merge
Nikunj Patel 11 months ago committed by GitHub
commit eaf435dbe4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -160,3 +160,45 @@ void CommParameters_setDstAddress(CommParameters *gooseCommParameters,
#include "servicePythonWrapper.hpp"
%}
%include "servicePythonWrapper.hpp"
/* SV Subscriber section */
%{
struct sSVSubscriber;
typedef struct sSVSubscriber* SVSubscriber;
struct sSVSubscriber_ASDU {
char* svId;
char* datSet;
uint8_t* smpCnt;
uint8_t* confRev;
uint8_t* refrTm;
uint8_t* smpSynch;
uint8_t* smpMod;
uint8_t* smpRate;
int dataBufferLength;
uint8_t* dataBuffer;
};
typedef struct sSVSubscriber_ASDU* SVSubscriber_ASDU;
#include "sv_subscriber.h"
#include "sv_publisher.h"
%}
%include "sv_publisher.h"
%include "sv_subscriber.h"
struct sSVSubscriber_ASDU {
char* svId;
char* datSet;
uint8_t* smpCnt;
uint8_t* confRev;
uint8_t* refrTm;
uint8_t* smpSynch;
uint8_t* smpMod;
uint8_t* smpRate;
int dataBufferLength;
uint8_t* dataBuffer;
};
typedef struct sSVSubscriber_ASDU* SVSubscriber_ASDU;

@ -1108,6 +1108,59 @@ createCancelParameters(ControlObjectClient self)
return cancelParameters;
}
static MmsValue*
createCancelwParameters(ControlObjectClient self, MmsValue* ctlVal)
{
MmsValue* cancelParameters;
if (self->hasTimeActivatedMode)
cancelParameters = MmsValue_createEmptyStructure(6);
else
cancelParameters = MmsValue_createEmptyStructure(5);
MmsValue_setElement(cancelParameters, 0, ctlVal);
int index = 1;
if (self->hasTimeActivatedMode) {
MmsValue* operTm = MmsValue_newUtcTimeByMsTime(self->opertime);
MmsValue_setElement(cancelParameters, index++, operTm);
}
MmsValue* origin = createOriginValue(self);
MmsValue_setElement(cancelParameters, index++, origin);
MmsValue* ctlNum = MmsValue_newUnsignedFromUint32(self->ctlNum);
MmsValue_setElement(cancelParameters, index++, ctlNum);
uint64_t timestamp;
if (self->useConstantT)
timestamp = self->constantT;
else
timestamp = Hal_getTimeInMs();
MmsValue* ctlTime;
if (self->edition == 2) {
ctlTime = MmsValue_newUtcTimeByMsTime(timestamp);
if (self->connection)
MmsValue_setUtcTimeQuality(ctlTime, self->connection->timeQuality);
}
else {
ctlTime = MmsValue_newBinaryTime(false);
MmsValue_setBinaryTime(ctlTime, timestamp);
}
MmsValue_setElement(cancelParameters, index++, ctlTime);
MmsValue* ctlTest = MmsValue_newBoolean(self->test);
MmsValue_setElement(cancelParameters, index++, ctlTest);
return cancelParameters;
}
bool
ControlObjectClient_cancel(ControlObjectClient self)
{
@ -1154,6 +1207,52 @@ ControlObjectClient_cancel(ControlObjectClient self)
return true;
}
bool
ControlObjectClient_cancelWithValue(ControlObjectClient self, MmsValue* ctlVal)
{
resetLastApplError(self);
MmsValue* cancelParameters = createCancelwParameters(self, ctlVal);
char domainId[65];
char itemId[65];
MmsMapping_getMmsDomainFromObjectReference(self->objectReference, domainId);
convertToMmsAndInsertFC(itemId, self->objectReference + strlen(domainId) + 1, "CO");
strncat(itemId, "$Cancel", 64);
if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: cancel: %s/%s\n", domainId, itemId);
MmsError mmsError;
MmsDataAccessError writeResult = MmsConnection_writeVariable(IedConnection_getMmsConnection(self->connection),
&mmsError, domainId, itemId, cancelParameters);
self->lastMmsError = mmsError;
self->lastAccessError = writeResult;
MmsValue_setElement(cancelParameters, 0, NULL);
MmsValue_delete(cancelParameters);
if (mmsError != MMS_ERROR_NONE) {
if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: cancel failed!\n");
return false;
}
else {
if (writeResult != DATA_ACCESS_ERROR_SUCCESS) {
if (DEBUG_IED_CLIENT)
printf("IED_CLIENT: cancel failed!\n");
return false;
}
}
return true;
}
static void
internalCancelHandler(uint32_t invokeId, void* parameter, MmsError err, MmsDataAccessError accessError)
{

@ -2215,6 +2215,19 @@ ControlObjectClient_selectWithValue(ControlObjectClient self, MmsValue* ctlVal);
LIB61850_API bool
ControlObjectClient_cancel(ControlObjectClient self);
/**
* \brief Send a cancel command to the server
*
* The cancel command can be used to stop an ongoing operation (when the server and application
* support this) and to cancel a former select command.
*
* \param self the control object instance to use
* \param ctlVal the control value (for APC the value may be either AnalogueValue (MMS_STRUCT) or MMS_FLOAT/MMS_INTEGER
*
* \return true if operation has been successful, false otherwise.
*/
LIB61850_API bool
ControlObjectClient_cancelWithValue(ControlObjectClient self, MmsValue* ctlVal);
/**
* \brief Send an operate command to the server - async version

Loading…
Cancel
Save