- SV subscriber/publisher: add support for Quality type

pull/143/head
Michael Zillgith 8 years ago
parent b00fdfde3d
commit e63abff71c

@ -627,6 +627,24 @@ SVPublisher_ASDU_setTimestamp(SVPublisher_ASDU self, int index, Timestamp value)
} }
} }
int
SVPublisher_ASDU_addQuality(SVPublisher_ASDU self)
{
int index = self->dataSize;
self->dataSize += 4;
return index;
}
void
SVPublisher_ASDU_setQuality(SVPublisher_ASDU self, int index, Quality value)
{
uint8_t* buffer = self->_dataBuffer + index;
buffer[0] = 0;
buffer[1] = 0;
buffer[2] = value / 0x100;
buffer[3] = value % 0x100;
}
uint16_t uint16_t
SVPublisher_ASDU_getSmpCnt(SVPublisher_ASDU self) SVPublisher_ASDU_getSmpCnt(SVPublisher_ASDU self)
{ {

@ -244,6 +244,27 @@ SVPublisher_ASDU_addTimestamp(SVPublisher_ASDU self);
void void
SVPublisher_ASDU_setTimestamp(SVPublisher_ASDU self, int index, Timestamp value); SVPublisher_ASDU_setTimestamp(SVPublisher_ASDU self, int index, Timestamp value);
/**
* \brief Reserve memory for a quality value in the ASDU
*
* NOTE: Quality is encoded as BITSTRING (4 byte)
*
* \param[in] self the Sampled Values ASDU instance.
* \return the offset in bytes of the new element within the ASDU data block.
*/
int
SVPublisher_ASDU_addQuality(SVPublisher_ASDU self);
/**
* \brief Set the value of a quality attribute in the ASDU.
*
* \param[in] self the Sampled Values ASDU instance.
* \param[in] index The offset within the data block of the ASDU in bytes.
* \param[in] value The value which should be set.
*/
void
SVPublisher_ASDU_setQuality(SVPublisher_ASDU self, int index, Quality value);
/** /**
* \brief Set the sample count attribute of the ASDU. * \brief Set the sample count attribute of the ASDU.
* *

@ -842,6 +842,19 @@ SVSubscriber_ASDU_getTimestamp(SVSubscriber_ASDU self, int index)
return retVal; return retVal;
} }
Quality
SVSubscriber_ASDU_getQuality(SVSubscriber_ASDU self, int index)
{
Quality retVal;
uint8_t* buffer = self->dataBuffer + index;
retVal = buffer[3];
retVal += (buffer[2] * 0x100);
return retVal;
}
int int
SVSubscriber_ASDU_getDataSize(SVSubscriber_ASDU self) SVSubscriber_ASDU_getDataSize(SVSubscriber_ASDU self)
{ {

@ -74,6 +74,7 @@ typedef struct sEthernetSocket* EthernetSocket;
* | TimeStamp | 8 byte | * | TimeStamp | 8 byte |
* | EntryTime | 6 byte | * | EntryTime | 6 byte |
* | BITSTRING | 4 byte | * | BITSTRING | 4 byte |
* | Quality | 4 byte |
* *
* The SV subscriber API can be used independent of the IEC 61850 client API. In order to access the SVCB via MMS you * The SV subscriber API can be used independent of the IEC 61850 client API. In order to access the SVCB via MMS you
* have to use the IEC 61850 client API. Please see \ref ClientSVControlBlock object in section \ref IEC61850_CLIENT_SV. * have to use the IEC 61850 client API. Please see \ref ClientSVControlBlock object in section \ref IEC61850_CLIENT_SV.
@ -493,6 +494,19 @@ SVSubscriber_ASDU_getFLOAT64(SVSubscriber_ASDU self, int index);
Timestamp Timestamp
SVSubscriber_ASDU_getTimestamp(SVSubscriber_ASDU self, int index); SVSubscriber_ASDU_getTimestamp(SVSubscriber_ASDU self, int index);
/**
* \brief Get a quality value in the data part of the ASDU
*
* NOTE: Quality is encoded as BITSTRING (4 byte)
*
* \param self ASDU object instance
* \param index the index (byte position of the start) of the data in the data part
*
* \return SV data
*/
Quality
SVSubscriber_ASDU_getQuality(SVSubscriber_ASDU self, int index);
/** /**
* \brief Returns the size of the data part of the ASDU * \brief Returns the size of the data part of the ASDU
* *

@ -701,4 +701,7 @@ EXPORTS
SVReceiver_isRunning SVReceiver_isRunning
SVSubscriber_ASDU_getTimestamp SVSubscriber_ASDU_getTimestamp
SVPublisher_ASDU_addTimestamp SVPublisher_ASDU_addTimestamp
SVPublisher_ASDU_setTimestamp SVPublisher_ASDU_setTimestamp
SVSubscriber_ASDU_getQuality
SVPublisher_ASDU_addQuality
SVPublisher_ASDU_setQuality
Loading…
Cancel
Save