diff --git a/src/sampled_values/sv_publisher.c b/src/sampled_values/sv_publisher.c index d30f4b0f..c6c178d5 100644 --- a/src/sampled_values/sv_publisher.c +++ b/src/sampled_values/sv_publisher.c @@ -42,7 +42,7 @@ #define SV_MAX_MESSAGE_SIZE 1518 -struct sSV_ASDU { +struct sSVPublisher_ASDU { char* svID; char* datset; int dataSize; @@ -63,7 +63,7 @@ struct sSV_ASDU { uint8_t* smpCntBuf; - SV_ASDU _next; + SVPublisher_ASDU _next; }; @@ -79,7 +79,7 @@ struct sSVPublisher { int payloadLength; /* length of payload buffer */ int asduCount; /* number of ASDUs in the APDU */ - SV_ASDU asduLIst; + SVPublisher_ASDU asduLIst; }; @@ -295,10 +295,10 @@ SVPublisher_create(CommParameters* parameters, const char* interfaceId) return self; } -SV_ASDU +SVPublisher_ASDU SVPublisher_addASDU(SVPublisher self, char* svID, char* datset, uint32_t confRev) { - SV_ASDU newAsdu = (SV_ASDU) GLOBAL_CALLOC(1, sizeof(struct sSV_ASDU)); + SVPublisher_ASDU newAsdu = (SVPublisher_ASDU) GLOBAL_CALLOC(1, sizeof(struct sSVPublisher_ASDU)); newAsdu->svID = svID; newAsdu->datset = datset; @@ -310,7 +310,7 @@ SVPublisher_addASDU(SVPublisher self, char* svID, char* datset, uint32_t confRev if (self->asduLIst == NULL) self->asduLIst = newAsdu; else { - SV_ASDU lastAsdu = self->asduLIst; + SVPublisher_ASDU lastAsdu = self->asduLIst; while (lastAsdu->_next != NULL) lastAsdu = lastAsdu->_next; @@ -322,7 +322,7 @@ SVPublisher_addASDU(SVPublisher self, char* svID, char* datset, uint32_t confRev } static int -SV_ASDU_getEncodedSize(SV_ASDU self) +SVPublisher_ASDU_getEncodedSize(SVPublisher_ASDU self) { int encodedSize = 0; @@ -362,9 +362,9 @@ SV_ASDU_getEncodedSize(SV_ASDU self) } static int -SV_ASDU_encodeToBuffer(SV_ASDU self, uint8_t* buffer, int bufPos) +SVPublisher_ASDU_encodeToBuffer(SVPublisher_ASDU self, uint8_t* buffer, int bufPos) { - int encodedSize = SV_ASDU_getEncodedSize(self); + int encodedSize = SVPublisher_ASDU_getEncodedSize(self); /* tag and length field */ bufPos = BerEncoder_encodeTL(0x30, encodedSize, buffer, bufPos); @@ -423,12 +423,12 @@ SVPublisher_setupComplete(SVPublisher self) int numberOfAsdu = 0; /* determine number of ASDUs and length of all ASDUs */ - SV_ASDU nextAsdu = self->asduLIst; + SVPublisher_ASDU nextAsdu = self->asduLIst; int totalASDULength = 0; while (nextAsdu != NULL) { numberOfAsdu++; - int asduLength = SV_ASDU_getEncodedSize(nextAsdu); + int asduLength = SVPublisher_ASDU_getEncodedSize(nextAsdu); /* tag and length field */ asduLength += BerEncoder_determineLengthSize(asduLength); @@ -457,7 +457,7 @@ SVPublisher_setupComplete(SVPublisher self) nextAsdu = self->asduLIst; while (nextAsdu != NULL) { - bufPos = SV_ASDU_encodeToBuffer(nextAsdu, buffer, bufPos); + bufPos = SVPublisher_ASDU_encodeToBuffer(nextAsdu, buffer, bufPos); nextAsdu = nextAsdu->_next; } @@ -496,14 +496,14 @@ SVPublisher_destroy(SVPublisher self) void -SV_ASDU_resetBuffer(SV_ASDU self) +SVPublisher_ASDU_resetBuffer(SVPublisher_ASDU self) { self->dataSize = 0; } int -SV_ASDU_addINT8(SV_ASDU self) +SVPublisher_ASDU_addINT8(SVPublisher_ASDU self) { int index = self->dataSize; @@ -513,13 +513,13 @@ SV_ASDU_addINT8(SV_ASDU self) } void -SV_ASDU_setINT8(SV_ASDU self, int index, int8_t value) +SVPublisher_ASDU_setINT8(SVPublisher_ASDU self, int index, int8_t value) { self->_dataBuffer[index] = value; } int -SV_ASDU_addINT32(SV_ASDU self) +SVPublisher_ASDU_addINT32(SVPublisher_ASDU self) { int index = self->dataSize; @@ -529,13 +529,13 @@ SV_ASDU_addINT32(SV_ASDU self) } void -SV_ASDU_setINT32(SV_ASDU self, int index, int32_t value) +SVPublisher_ASDU_setINT32(SVPublisher_ASDU self, int index, int32_t value) { encodeInt32FixedSize(value, self->_dataBuffer, index); } int -SV_ASDU_addINT64(SV_ASDU self) +SVPublisher_ASDU_addINT64(SVPublisher_ASDU self) { int index = self->dataSize; @@ -545,13 +545,13 @@ SV_ASDU_addINT64(SV_ASDU self) } void -SV_ASDU_setINT64(SV_ASDU self, int index, int64_t value) +SVPublisher_ASDU_setINT64(SVPublisher_ASDU self, int index, int64_t value) { encodeInt64FixedSize(value, self->_dataBuffer, index); } int -SV_ASDU_addFLOAT(SV_ASDU self) +SVPublisher_ASDU_addFLOAT(SVPublisher_ASDU self) { int index = self->dataSize; @@ -561,7 +561,7 @@ SV_ASDU_addFLOAT(SV_ASDU self) } void -SV_ASDU_setFLOAT(SV_ASDU self, int index, float value) +SVPublisher_ASDU_setFLOAT(SVPublisher_ASDU self, int index, float value) { uint8_t* buf = (uint8_t*) &value; @@ -580,7 +580,7 @@ SV_ASDU_setFLOAT(SV_ASDU self, int index, float value) int -SV_ASDU_addFLOAT64(SV_ASDU self) +SVPublisher_ASDU_addFLOAT64(SVPublisher_ASDU self) { int index = self->dataSize; self->dataSize += 8; @@ -588,7 +588,7 @@ SV_ASDU_addFLOAT64(SV_ASDU self) } void -SV_ASDU_setFLOAT64(SV_ASDU self, int index, double value) +SVPublisher_ASDU_setFLOAT64(SVPublisher_ASDU self, int index, double value) { uint8_t* buf = (uint8_t*) &value; @@ -606,13 +606,13 @@ SV_ASDU_setFLOAT64(SV_ASDU self, int index, double value) } uint16_t -SV_ASDU_getSmpCnt(SV_ASDU self) +SVPublisher_ASDU_getSmpCnt(SVPublisher_ASDU self) { return self->smpCnt; } void -SV_ASDU_setSmpCnt(SV_ASDU self, uint16_t value) +SVPublisher_ASDU_setSmpCnt(SVPublisher_ASDU self, uint16_t value) { self->smpCnt = value; @@ -620,7 +620,7 @@ SV_ASDU_setSmpCnt(SV_ASDU self, uint16_t value) } void -SV_ASDU_increaseSmpCnt(SV_ASDU self) +SVPublisher_ASDU_increaseSmpCnt(SVPublisher_ASDU self) { self->smpCnt++; @@ -628,21 +628,21 @@ SV_ASDU_increaseSmpCnt(SV_ASDU self) } void -SV_ASDU_setRefrTm(SV_ASDU self, uint64_t refrTm) +SVPublisher_ASDU_setRefrTm(SVPublisher_ASDU self, uint64_t refrTm) { self->hasRefrTm = true; self->refrTm = refrTm; } void -SV_ASDU_setSmpMod(SV_ASDU self, uint8_t smpMod) +SVPublisher_ASDU_setSmpMod(SVPublisher_ASDU self, uint8_t smpMod) { self->hasSmpMod = true; self->smpMod = smpMod; } void -SV_ASDU_setSmpRate(SV_ASDU self, uint16_t smpRate) +SVPublisher_ASDU_setSmpRate(SVPublisher_ASDU self, uint16_t smpRate) { self->hasSmpRate = true; self->smpRate = smpRate; diff --git a/src/sampled_values/sv_publisher.h b/src/sampled_values/sv_publisher.h index fcf1b2c0..50a9ed6e 100644 --- a/src/sampled_values/sv_publisher.h +++ b/src/sampled_values/sv_publisher.h @@ -64,7 +64,7 @@ typedef struct sSVPublisher* SVPublisher; /** * \brief An opaque type representing an IEC 61850-9-2 Sampled Values Application Service Data Unit (ASDU). */ -typedef struct sSV_ASDU* SV_ASDU; +typedef struct sSVPublisher_ASDU* SVPublisher_ASDU; /** * \brief Create a new IEC61850-9-2 Sampled Values publisher. @@ -84,7 +84,7 @@ SVPublisher_create(CommParameters* parameters, const char* interfaceId); * \param[in] confRev Configuration revision number. Should be incremented each time that the configuration of the logical device changes. * \return the new ASDU instance. */ -SV_ASDU +SVPublisher_ASDU SVPublisher_addASDU(SVPublisher self, char* svID, char* datset, uint32_t confRev); /** @@ -121,13 +121,13 @@ SVPublisher_destroy(SVPublisher self); /** * \brief Reset the internal data buffer of an ASDU. * - * All data elements added by SV_ASDU_add*() functions are removed. + * All data elements added by SVPublisher_ASDU_add*() functions are removed. * SVPublisher_setupComplete() must be called afterwards. * * \param[in] self the Sampled Values ASDU instance. */ void -SV_ASDU_resetBuffer(SV_ASDU self); +SVPublisher_ASDU_resetBuffer(SVPublisher_ASDU self); /** * \brief Reserve memory for a signed 8-bit integer in the ASDU. @@ -136,7 +136,7 @@ SV_ASDU_resetBuffer(SV_ASDU self); * \return the offset in bytes within the ASDU data block. */ int -SV_ASDU_addINT8(SV_ASDU self); +SVPublisher_ASDU_addINT8(SVPublisher_ASDU self); /** * \brief Set the value of a 8-bit integer in the ASDU. @@ -146,7 +146,7 @@ SV_ASDU_addINT8(SV_ASDU self); * \param[in] value The value which should be set. */ void -SV_ASDU_setINT8(SV_ASDU self, int index, int8_t value); +SVPublisher_ASDU_setINT8(SVPublisher_ASDU self, int index, int8_t value); /** * \brief Reserve memory for a signed 32-bit integer in the ASDU. @@ -155,7 +155,7 @@ SV_ASDU_setINT8(SV_ASDU self, int index, int8_t value); * \return the offset in bytes within the ASDU data block. */ int -SV_ASDU_addINT32(SV_ASDU self); +SVPublisher_ASDU_addINT32(SVPublisher_ASDU self); /** * \brief Set the value of a 32-bit integer in the ASDU. @@ -165,7 +165,7 @@ SV_ASDU_addINT32(SV_ASDU self); * \param[in] value The value which should be set. */ void -SV_ASDU_setINT32(SV_ASDU self, int index, int32_t value); +SVPublisher_ASDU_setINT32(SVPublisher_ASDU self, int index, int32_t value); /** * \brief Reserve memory for a signed 64-bit integer in the ASDU. @@ -174,7 +174,7 @@ SV_ASDU_setINT32(SV_ASDU self, int index, int32_t value); * \return the offset in bytes of the new element within the ASDU data block. */ int -SV_ASDU_addINT64(SV_ASDU self); +SVPublisher_ASDU_addINT64(SVPublisher_ASDU self); /** * \brief Set the value of a 64-bit integer in the ASDU. @@ -184,7 +184,7 @@ SV_ASDU_addINT64(SV_ASDU self); * \param[in] value The value which should be set. */ void -SV_ASDU_setINT64(SV_ASDU self, int index, int64_t value); +SVPublisher_ASDU_setINT64(SVPublisher_ASDU self, int index, int64_t value); /** * \brief Reserve memory for a single precission floating point number in the ASDU. @@ -193,7 +193,7 @@ SV_ASDU_setINT64(SV_ASDU self, int index, int64_t value); * \return the offset in bytes of the new element within the ASDU data block. */ int -SV_ASDU_addFLOAT(SV_ASDU self); +SVPublisher_ASDU_addFLOAT(SVPublisher_ASDU self); /** * \brief Set the value of a single precission floating point number in the ASDU. @@ -203,7 +203,7 @@ SV_ASDU_addFLOAT(SV_ASDU self); * \param[in] value The value which should be set. */ void -SV_ASDU_setFLOAT(SV_ASDU self, int index, float value); +SVPublisher_ASDU_setFLOAT(SVPublisher_ASDU self, int index, float value); /** * \brief Reserve memory for a double precission floating point number in the ASDU. @@ -212,7 +212,7 @@ SV_ASDU_setFLOAT(SV_ASDU self, int index, float value); * \return the offset in bytes of the new element within the ASDU data block. */ int -SV_ASDU_addFLOAT64(SV_ASDU self); +SVPublisher_ASDU_addFLOAT64(SVPublisher_ASDU self); /** * \brief Set the value of a double precission floating pointer number in the ASDU. @@ -222,7 +222,7 @@ SV_ASDU_addFLOAT64(SV_ASDU self); * \param[in] value The value which should be set. */ void -SV_ASDU_setFLOAT64(SV_ASDU self, int index, double value); +SVPublisher_ASDU_setFLOAT64(SVPublisher_ASDU self, int index, double value); /** * \brief Set the sample count attribute of the ASDU. @@ -231,7 +231,7 @@ SV_ASDU_setFLOAT64(SV_ASDU self, int index, double value); * \param[in] value the new value of the attribute. */ void -SV_ASDU_setSmpCnt(SV_ASDU self, uint16_t value); +SVPublisher_ASDU_setSmpCnt(SVPublisher_ASDU self, uint16_t value); /** * \brief Get the sample count attribute of the ASDU. @@ -239,7 +239,7 @@ SV_ASDU_setSmpCnt(SV_ASDU self, uint16_t value); * \param[in] self the Sampled Values ASDU instance. */ uint16_t -SV_ASDU_getSmpCnt(SV_ASDU self); +SVPublisher_ASDU_getSmpCnt(SVPublisher_ASDU self); /** * \brief Increment the sample count attribute of the ASDU. @@ -251,7 +251,7 @@ SV_ASDU_getSmpCnt(SV_ASDU self); * \param[in] self the Sampled Values ASDU instance. */ void -SV_ASDU_increaseSmpCnt(SV_ASDU self); +SVPublisher_ASDU_increaseSmpCnt(SVPublisher_ASDU self); /** * \brief Set the refresh time attribute of the ASDU. @@ -259,7 +259,7 @@ SV_ASDU_increaseSmpCnt(SV_ASDU self); * \param[in] self the Sampled Values ASDU instance. */ void -SV_ASDU_setRefrTm(SV_ASDU self, uint64_t refrTm); +SVPublisher_ASDU_setRefrTm(SVPublisher_ASDU self, uint64_t refrTm); /** * \brief Set the sample mode attribute of the ASDU. @@ -271,7 +271,7 @@ SV_ASDU_setRefrTm(SV_ASDU self, uint64_t refrTm); * \param smpMod one of IEC61850_SV_SMPMOD_PER_NOMINAL_PERIOD, IEC61850_SV_SMPMOD_SAMPLES_PER_SECOND or IEC61850_SV_SMPMOD_SECONDS_PER_SAMPLE */ void -SV_ASDU_setSmpMod(SV_ASDU self, uint8_t smpMod); +SVPublisher_ASDU_setSmpMod(SVPublisher_ASDU self, uint8_t smpMod); /** * \brief Set the sample rate attribute of the ASDU. @@ -283,14 +283,14 @@ SV_ASDU_setSmpMod(SV_ASDU self, uint8_t smpMod); * \param smpRate Amount of samples (default per nominal period, see SmpMod). */ void -SV_ASDU_setSmpRate(SV_ASDU self, uint16_t smpRate); +SVPublisher_ASDU_setSmpRate(SVPublisher_ASDU self, uint16_t smpRate); + +/**@} @}*/ #ifdef __cplusplus } #endif -/**@} @}*/ - #include "sv_publisher_deprecated.h" #endif /* LIBIEC61850_SRC_SAMPLED_VALUES_SV_PUBLISHER_H_ */ diff --git a/src/sampled_values/sv_publisher_deprecated.h b/src/sampled_values/sv_publisher_deprecated.h index d463fb68..ea06d98f 100644 --- a/src/sampled_values/sv_publisher_deprecated.h +++ b/src/sampled_values/sv_publisher_deprecated.h @@ -44,18 +44,20 @@ extern "C" { * @{ */ +typedef DEPRECATED struct sSVPublisher* SampledValuesPublisher; + /** - * \brief An opaque type representing an IEC 61850-9-2 Sampled Values publisher. + * \brief An opaque type representing an IEC 61850-9-2 Sampled Values Application Service Data Unit (ASDU). * \deprecated */ -typedef DEPRECATED struct sSVPublisher* SampledValuesPublisher; +typedef DEPRECATED struct sSV_ASDU* SV_ASDU; /** * \brief This function is deprecated and will be removed in the next major release. Use SVPublisher_create() instead. * \deprecated */ static DEPRECATED -SampledValuesPublisher +SVPublisher SampledValuesPublisher_create(CommParameters* parameters, const char* interfaceId) { return SVPublisher_create(parameters, interfaceId); @@ -66,8 +68,8 @@ SampledValuesPublisher_create(CommParameters* parameters, const char* interfaceI * \deprecated */ static DEPRECATED -SV_ASDU -SampledValuesPublisher_addASDU(SampledValuesPublisher self, char* svID, char* datset, uint32_t confRev) +SVPublisher_ASDU +SampledValuesPublisher_addASDU(SVPublisher self, char* svID, char* datset, uint32_t confRev) { return SVPublisher_addASDU(self, svID, datset, confRev); } @@ -78,7 +80,7 @@ SampledValuesPublisher_addASDU(SampledValuesPublisher self, char* svID, char* da */ static DEPRECATED void -SampledValuesPublisher_setupComplete(SampledValuesPublisher self) +SampledValuesPublisher_setupComplete(SVPublisher self) { SVPublisher_setupComplete(self); } @@ -89,7 +91,7 @@ SampledValuesPublisher_setupComplete(SampledValuesPublisher self) */ static DEPRECATED void -SampledValuesPublisher_publish(SampledValuesPublisher self) +SampledValuesPublisher_publish(SVPublisher self) { SVPublisher_publish(self); } @@ -100,14 +102,131 @@ SampledValuesPublisher_publish(SampledValuesPublisher self) */ static DEPRECATED void -SampledValuesPublisher_destroy(SampledValuesPublisher self) +SampledValuesPublisher_destroy(SVPublisher self) { SVPublisher_destroy(self); } -/** - * @} - */ +static DEPRECATED +void +SV_ASDU_resetBuffer(SVPublisher_ASDU self) +{ + SVPublisher_ASDU_resetBuffer(self); +} + +static DEPRECATED +int +SV_ASDU_addINT8(SVPublisher_ASDU self) +{ + return SVPublisher_ASDU_addINT8(self); +} + +static DEPRECATED +void +SV_ASDU_setINT8(SVPublisher_ASDU self, int index, int8_t value) +{ + SVPublisher_ASDU_setINT8(self, index, value); +} + +static DEPRECATED +int +SV_ASDU_addINT32(SVPublisher_ASDU self) +{ + return SVPublisher_ASDU_addINT32(self); +} + +static DEPRECATED +void +SV_ASDU_setINT32(SVPublisher_ASDU self, int index, int32_t value) +{ + SVPublisher_ASDU_setINT32(self, index, value); +} + +static DEPRECATED +int +SV_ASDU_addINT64(SVPublisher_ASDU self) +{ + return SVPublisher_ASDU_addINT64(self); +} + +static DEPRECATED +void +SV_ASDU_setINT64(SVPublisher_ASDU self, int index, int64_t value) +{ + SVPublisher_ASDU_setINT64(self, index, value); +} + +static DEPRECATED +int +SV_ASDU_addFLOAT(SVPublisher_ASDU self) +{ + return SVPublisher_ASDU_addFLOAT(self); +} + +static DEPRECATED +void +SV_ASDU_setFLOAT(SVPublisher_ASDU self, int index, float value) +{ + SVPublisher_ASDU_setFLOAT(self, index, value); +} + +static DEPRECATED +int +SV_ASDU_addFLOAT64(SVPublisher_ASDU self) +{ + return SVPublisher_ASDU_addFLOAT64(self); +} + +static DEPRECATED +void +SV_ASDU_setFLOAT64(SVPublisher_ASDU self, int index, double value) +{ + SVPublisher_ASDU_setFLOAT64(self, index, value); +} + +static DEPRECATED +void +SV_ASDU_setSmpCnt(SVPublisher_ASDU self, uint16_t value) +{ + SVPublisher_ASDU_setSmpCnt(self, value); +} + +static DEPRECATED +uint16_t +SV_ASDU_getSmpCnt(SVPublisher_ASDU self) +{ + return SVPublisher_ASDU_getSmpCnt(self); +} + +static DEPRECATED +void +SV_ASDU_increaseSmpCnt(SVPublisher_ASDU self) +{ + SVPublisher_ASDU_increaseSmpCnt(self); +} + +static DEPRECATED +void +SV_ASDU_setRefrTm(SVPublisher_ASDU self, uint64_t refrTm) +{ + SVPublisher_ASDU_setRefrTm(self, refrTm); +} + +static DEPRECATED +void +SV_ASDU_setSmpMod(SVPublisher_ASDU self, uint8_t smpMod) +{ + SVPublisher_ASDU_setSmpMod(self, smpMod); +} + +static DEPRECATED +void +SV_ASDU_setSmpRate(SVPublisher_ASDU self, uint16_t smpRate) +{ + SVPublisher_ASDU_setSmpRate(self, smpRate); +} + +/**@}*/ #ifdef __cplusplus }