GM6000 Digital Heater Controller Build: 16 (Branch = develop)
SDX-1330
Numeric.h
Go to the documentation of this file.
1#ifndef Cpl_Dm_Mp_Numeric_h_
2#define Cpl_Dm_Mp_Numeric_h_
3/*-----------------------------------------------------------------------------
4 * This file is part of the Colony.Core Project. The Colony.Core Project is an
5 * open source project with a BSD type of licensing agreement. See the license
6 * agreement (license.txt) in the top/ directory or on the Internet at
7 * http://integerfox.com/colony.core/license.txt
8 *
9 * Copyright (c) 2014-2025 John T. Taylor
10 *
11 * Redistributions of the source code must retain the above copyright notice.
12 *----------------------------------------------------------------------------*/
13/** @file */
14
15
17#include "Cpl/Text/atob.h"
18#include "Cpl/Text/format.h"
19#include "Cpl/Text/FString.h"
20#include <string.h>
21#include <stdint.h>
22
23/// Hack to get around that NOT all compilers support the "%llx" notation for printf
24#if INTPTR_MAX == INT32_MAX
25/// print format max integer
26#define PRINTF_SIZET_FMT "%lx"
27/// type for max integer
28#define PRINTF_SIZET_TYPE unsigned long
29
30#elif INTPTR_MAX == INT64_MAX
31/// print format max integer
32#define PRINTF_SIZET_FMT "%llx"
33/// print format max integer
34#define PRINTF_SIZET_TYPE unsigned long long
35#else
36#error "Environment not 32 or 64-bit."
37#endif
38
39/// Endianess of a Bit array. For little endian set to true; else set to false
40#ifndef OPTION_CPL_DM_MP_BITARRAY_IS_LITTLE_ENDIAN
41#define OPTION_CPL_DM_MP_BITARRAY_IS_LITTLE_ENDIAN true
42#endif
43
44
45///
46namespace Cpl {
47///
48namespace Dm {
49///
50namespace Mp {
51
52
53/** This template class provides a mostly concrete implementation for a Model
54 Point who's data is a C numeric primitive type of type: 'ELEMTYPE'.
55
56 NOTES:
57 1) All methods in this class are NOT thread Safe unless explicitly
58 documented otherwise.
59 */
60template <class ELEMTYPE, class MPTYPE>
62{
63protected:
64 /// The element's value
65 ELEMTYPE m_data;
66
67protected:
68 /// Constructor: Invalid MP
69 Numeric( Cpl::Dm::ModelDatabase& myModelBase, const char* symbolicName )
70 : Cpl::Dm::ModelPointCommon_( myModelBase, symbolicName, &m_data, sizeof( m_data ), false )
71 {
72 }
73
74 /// Constructor: Valid MP (requires initial value)
75 Numeric( Cpl::Dm::ModelDatabase& myModelBase, const char* symbolicName, ELEMTYPE initialValue )
76 : Cpl::Dm::ModelPointCommon_( myModelBase, symbolicName, &m_data, sizeof( m_data ), true )
77 {
78 m_data = initialValue;
79 }
80
81public:
82 /// Type safe read. See Cpl::Dm::ModelPoint
83 inline bool read( ELEMTYPE& dstData, uint16_t* seqNumPtr = nullptr ) const noexcept
84 {
85 return Cpl::Dm::ModelPointCommon_::readData( &dstData, sizeof( ELEMTYPE ), seqNumPtr );
86 }
87
88 /** Atomic Read and then clear bits operation.
89 NOTES:
90 1. The return data value is BEFORE the clear operation.
91 2. If the MP is invalid then NO clear operation occurs.
92 3. When the MP is in the valid state, the returned sequence number
93 (if requested) is the AFTER the clear operation.
94 */
95 inline uint16_t readThenClearBits( ELEMTYPE& dstData, ELEMTYPE maskToClear, uint16_t* seqNumPtr = nullptr ) noexcept
96 {
98 bool result = Cpl::Dm::ModelPointCommon_::readData( &dstData, sizeof( ELEMTYPE ), seqNumPtr );
99 if ( result )
100 {
101 ELEMTYPE newData = m_data & ~maskToClear;
102 uint16_t seqNum = Cpl::Dm::ModelPointCommon_::writeData( &newData, sizeof( ELEMTYPE ), Cpl::Dm::ModelPoint::eNO_REQUEST );
103 if ( seqNumPtr )
104 {
105 *seqNumPtr = seqNum;
106 }
107 }
109 return result;
110 }
111
112 /// Atomic Read and then clear (i.e. set to 0) operation.
113 inline uint16_t readThenClear( ELEMTYPE& dstData, uint16_t* seqNumPtr = nullptr ) noexcept
114 {
115 return readThenClearBits( dstData, (ELEMTYPE)-1, seqNumPtr );
116 }
117
118 /// Type safe write. See Cpl::Dm::ModelPoint
119 inline uint16_t write( ELEMTYPE newValue, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
120 {
121 return Cpl::Dm::ModelPointCommon_::writeData( &newValue, sizeof( ELEMTYPE ), lockRequest );
122 }
123
124 /// Atomic increment
125 inline uint16_t increment( ELEMTYPE incSize = 1, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
126 {
128 uint16_t result = write( m_data + incSize, lockRequest );
130 return result;
131 }
132
133 /// Atomic decrement
134 inline uint16_t decrement( ELEMTYPE decSize = 1, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
135 {
137 uint16_t result = write( m_data - decSize, lockRequest );
139 return result;
140 }
141
142 /// Atomic bitwise OR operation
143 inline uint16_t bitwiseOR( ELEMTYPE maskToOR, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
144 {
146 uint16_t result = write( m_data | maskToOR, lockRequest );
148 return result;
149 }
150
151 /// Atomic bitwise XOR operation
152 inline uint16_t bitwiseXOR( ELEMTYPE maskToXOR, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
153 {
155 uint16_t result = write( m_data ^ maskToXOR, lockRequest );
157 return result;
158 }
159
160 /// Atomic bitwise AND operation
161 inline uint16_t bitwiseAND( ELEMTYPE maskToAND, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
162 {
164 uint16_t result = write( m_data & maskToAND, lockRequest );
166 return result;
167 }
168
169 /// Atomic bitwise AND operation
170 inline uint16_t bitwiseClearAndSet( ELEMTYPE maskToClear, ELEMTYPE maskToSet, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
171 {
173 uint16_t result = write( ( m_data & ~maskToClear ) | maskToSet, lockRequest );
175 return result;
176 }
177
178 /// Updates the MP with the valid-state/data from 'src'. Note: the src.lock state is NOT copied
179 inline uint16_t copyFrom( const MPTYPE& src, LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
180 {
181 return copyDataAndStateFrom( src, lockRequest );
182 }
183
184 /// Type safe register observer
185 inline void attach( Cpl::Dm::Subscriber<MPTYPE>& observer, uint16_t initialSeqNumber = SEQUENCE_NUMBER_UNKNOWN ) noexcept
186 {
187 attachSubscriber( observer, initialSeqNumber );
188 }
189
190 /// Type safe un-register observer
191 inline void detach( Cpl::Dm::Subscriber<MPTYPE>& observer ) noexcept
192 {
193 detachSubscriber( observer );
194 }
195
196 /// See Cpl::Dm::ModelPointCommon
197 inline bool readAndSync( ELEMTYPE& dstData, SubscriberApi& observerToSync )
198 {
199 uint16_t seqNum;
200 return ModelPointCommon_::readAndSync( &dstData, sizeof( ELEMTYPE ), seqNum, observerToSync );
201 }
202
203 /// See Cpl::Dm::ModelPointCommon
204 inline bool readAndSync( ELEMTYPE& dstData, uint16_t& seqNum, SubscriberApi& observerToSync )
205 {
206 return ModelPointCommon_::readAndSync( &dstData, sizeof( ELEMTYPE ), seqNum, observerToSync );
207 }
208
209protected:
210 /// See Cpl::Dm::Point.
211 void setJSONVal( JsonDocument& doc ) noexcept
212 {
213 doc["val"] = m_data;
214 }
215
216public:
217 /// See Cpl::Dm::Point.
218 bool fromJSON_( JsonVariant& src, Cpl::Dm::ModelPoint::LockRequest_T lockRequest, uint16_t& retSequenceNumber, Cpl::Text::String* errorMsg ) noexcept
219 {
220 if ( src.is<ELEMTYPE>() )
221 {
222 retSequenceNumber = write( src.as<ELEMTYPE>(), lockRequest );
223 return true;
224 }
225 if ( errorMsg )
226 {
227 *errorMsg = "Invalid syntax for the 'val' key/value pair";
228 }
229 return false;
230 }
231};
232
233
234/** This template class extends the Numeric<> class to provide bit operation
235 on the numeric value. The datatype of the numeric MUST be an integer
236 type.
237
238 The underlying storage of the bit array is N bit integers. A side effect of
239 this storage mechanism the bit ordering in the JSON 'val' string is dependent on the
240 target platform's Endian architecture.
241
242 The toJSON()/fromJSON format is:
243 \code
244
245 { name:"<mpname>", type:"<mptypestring>", valid:true|false, seqnum:nnnn, locked:true|false, val:"<bits>" }
246
247 where <bits> is a string of N digits ('1' or '0') where the left most digit is
248 is the MSb of byte[0] and the right most digit is the LSb of byte[N].
249 Whether byte[0] is the MSB or LSB is dependent on the big/little Endian
250 architecture of the target platform.
251
252 For example a 16bit Array (as binary hex: dataword[0]=0x30, dataword[1]=0x09)
253
254 val:"0011000000001001"
255
256 \endcode
257
258 NOTE: All methods in this class ARE thread Safe unless explicitly
259 documented otherwise.
260
261 */
262template <class WORDSIZE, class MPTYPE>
263class BitArray_ : public Numeric<WORDSIZE, MPTYPE>
264{
265protected:
266 /// Constructor. Invalid MP.
267 BitArray_( Cpl::Dm::ModelDatabase& myModelBase, const char* symbolicName )
268 : Numeric<WORDSIZE, MPTYPE>( myModelBase, symbolicName )
269 {
270 }
271
272 /// Constructor. Valid MP. Requires an initial value
273 BitArray_( Cpl::Dm::ModelDatabase& myModelBase, const char* symbolicName, WORDSIZE initialValue )
274 : Numeric<WORDSIZE, MPTYPE>( myModelBase, symbolicName, initialValue )
275 {
276 }
277
278public:
279 /// Atomic operation to set the zero indexed bit to a 1.
280 inline uint16_t setBit( uint8_t bitPosition, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
281 {
283 uint16_t result = Numeric<WORDSIZE, MPTYPE>::write( Numeric<WORDSIZE, MPTYPE>::m_data | ( 1 << bitPosition ), lockRequest );
285 return result;
286 }
287
288 /// Atomic operation to set the zero indexed bit to a 0.
289 inline uint16_t clearBit( uint8_t bitPosition, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
290 {
292 uint16_t result = Numeric<WORDSIZE, MPTYPE>::write( Numeric<WORDSIZE, MPTYPE>::m_data & ( ~( 1 << bitPosition ) ), lockRequest );
294 return result;
295 }
296
297 /// Atomic operation to toggle the zero indexed bit.
298 inline uint16_t flipBit( uint8_t bitPosition, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
299 {
301 uint16_t result = Numeric<WORDSIZE, MPTYPE>::write( Numeric<WORDSIZE, MPTYPE>::m_data ^ ( 1 << bitPosition ), lockRequest );
303 return result;
304 }
305
306
307public:
308 /// Atomic operation to clear ONLY the bits as specified by the bit mask.
309 inline uint16_t clearBitsByMask( WORDSIZE bitMask, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
310 {
311 return Numeric<WORDSIZE, MPTYPE>::bitwiseAND( ~bitMask, lockRequest );
312 }
313
314 /// Atomic operation to set the bits specified by the bit mask
315 inline uint16_t setBitsByMask( WORDSIZE bitMask, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
316 {
317 return Numeric<WORDSIZE, MPTYPE>::bitwiseOR( bitMask, lockRequest );
318 }
319
320 /// Atomic operation to flip/toggle ONLY the bits as specified the bit mask
321 inline uint16_t flipBitsByMask( WORDSIZE bitMask, Cpl::Dm::ModelPoint::LockRequest_T lockRequest = Cpl::Dm::ModelPoint::eNO_REQUEST ) noexcept
322 {
323 return Numeric<WORDSIZE, MPTYPE>::bitwiseXOR( bitMask, lockRequest );
324 }
325
326
327
328protected:
329 /// See Cpl::Dm::Point.
330 void setJSONVal( JsonDocument& doc ) noexcept
331 {
333 const void* dataPtr = &( Numeric<WORDSIZE, MPTYPE>::m_data );
335 doc["val"] = (char*)tmp.getString();
336 }
337
338
339public:
340 /// See Cpl::Dm::Point.
341 bool fromJSON_( JsonVariant& src, Cpl::Dm::ModelPoint::LockRequest_T lockRequest, uint16_t& retSequenceNumber, Cpl::Text::String* errorMsg ) noexcept
342 {
343 if ( src.is<const char*>() )
344 {
345 const char* val = src.as<const char*>();
346 WORDSIZE value = 0;
347 if ( Cpl::Text::asciiBinaryToBuffer( &value, val, sizeof( value ), OPTION_CPL_DM_MP_BITARRAY_IS_LITTLE_ENDIAN ) > 0 )
348 {
349 retSequenceNumber = Numeric<WORDSIZE, MPTYPE>::write( value, lockRequest );
350 return true;
351 }
352 }
353
354 if ( errorMsg )
355 {
356 *errorMsg = "Invalid syntax for the 'val' key/value pair";
357 }
358 return false;
359 }
360};
361
362
363/** This template class extends the implementation of Numeric<> class to support
364 the pointers instead of integers
365
366 NOTES:
367 1) All methods in this class are NOT thread Safe unless explicitly
368 documented otherwise.
369 */
370template <class MPTYPE>
371class Pointer_ : public Numeric<size_t, MPTYPE>
372{
373protected:
374 /// Constructor. Invalid MP.
375 Pointer_( Cpl::Dm::ModelDatabase& myModelBase, const char* symbolicName )
376 : Numeric<size_t, MPTYPE>( myModelBase, symbolicName )
377 {
378 }
379
380 /// Constructor. Valid MP. Requires an initial value
381 Pointer_( Cpl::Dm::ModelDatabase& myModelBase, const char* symbolicName, void* initialValue )
382 : Numeric<size_t, MPTYPE>( myModelBase, symbolicName, (size_t)initialValue )
383 {
384 }
385
386public:
387 /// See Cpl::Dm::Point.
388 void setJSONVal( JsonDocument& doc ) noexcept
389 {
392 doc["val"] = (char*)tmp.getString();
393 }
394
395 /// See Cpl::Dm::Point.
396 bool fromJSON_( JsonVariant& src, Cpl::Dm::ModelPoint::LockRequest_T lockRequest, uint16_t& retSequenceNumber, Cpl::Text::String* errorMsg ) noexcept
397 {
398 if ( src.is<const char*>() )
399 {
400 const char* val = src.as<const char*>();
401 unsigned long long value = 0;
402 if ( Cpl::Text::a2ull( value, val, 16 ) )
403 {
404 retSequenceNumber = Numeric<size_t, MPTYPE>::write( (size_t)value, lockRequest );
405 return true;
406 }
407 }
408
409 if ( errorMsg )
410 {
411 *errorMsg = "Invalid syntax for the 'val' key/value pair";
412 }
413 return false;
414 }
415};
416
417}; // end namespaces
418};
419};
420#endif // end header latch
#define PRINTF_SIZET_FMT
Hack to get around that NOT all compilers support the "%llx" notation for printf.
Definition Numeric.h:26
#define PRINTF_SIZET_TYPE
type for max integer
Definition Numeric.h:28
#define OPTION_CPL_DM_MP_BITARRAY_IS_LITTLE_ENDIAN
Endianess of a Bit array. For little endian set to true; else set to false.
Definition Numeric.h:41
This file contains a collection of methods that wrap the standard C library functions for converting ...
This concrete class implements a simple Model Database.
Definition ModelDatabase.h:56
void lock_() noexcept
This method has 'PACKAGE Scope' in that is should only be called by other classes in the Cpl::Dm name...
void unlock_() noexcept
This method has 'PACKAGE Scope' in that is should only be called by other classes in the Cpl::Dm name...
This concrete class provide common infrastructure for a Model Point.
Definition ModelPointCommon_.h:32
void attachSubscriber(SubscriberApi &observer, uint16_t initialSeqNumber=SEQUENCE_NUMBER_UNKNOWN) noexcept
See Cpl::Dm::ModelPoint.
bool readAndSync(void *dstData, size_t dstSize, uint16_t &seqNum, SubscriberApi &observerToSync)
This method is used to read the MP contents and synchronize the observer with the current MP contents...
Definition ModelPointCommon_.h:93
void detachSubscriber(SubscriberApi &observer) noexcept
See Cpl::Dm::ModelPoint.
ModelDatabase & m_modelDatabase
Reference to the containing Model Base.
Definition ModelPointCommon_.h:223
virtual uint16_t copyDataAndStateFrom(const ModelPointCommon_ &src, LockRequest_T lockRequest) noexcept
Updates the MP with the valid-state/data from 'src'. Note: the src.lock state is NOT copied.
bool readData(void *dstData, size_t dstSize, uint16_t *seqNumPtr=0) const noexcept
See Cpl::Dm::ModelPoint.
uint16_t writeData(const void *srcData, size_t srcSize, LockRequest_T lockRequest=eNO_REQUEST) noexcept
See Cpl::Dm::ModelPoint.
LockRequest_T
Options related to the Model Point's locked state.
Definition ModelPoint.h:50
@ eNO_REQUEST
No change in the MP's lock state is requested.
Definition ModelPoint.h:51
static const uint16_t SEQUENCE_NUMBER_UNKNOWN
Magic value to use when registering for a change notification and application does not 'know' the cur...
Definition ModelPoint.h:62
This template class extends the Numeric<> class to provide bit operation on the numeric value.
Definition Numeric.h:264
uint16_t flipBitsByMask(WORDSIZE bitMask, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic operation to flip/toggle ONLY the bits as specified the bit mask.
Definition Numeric.h:321
bool fromJSON_(JsonVariant &src, Cpl::Dm::ModelPoint::LockRequest_T lockRequest, uint16_t &retSequenceNumber, Cpl::Text::String *errorMsg) noexcept
See Cpl::Dm::Point.
Definition Numeric.h:341
uint16_t setBit(uint8_t bitPosition, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic operation to set the zero indexed bit to a 1.
Definition Numeric.h:280
uint16_t flipBit(uint8_t bitPosition, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic operation to toggle the zero indexed bit.
Definition Numeric.h:298
uint16_t clearBitsByMask(WORDSIZE bitMask, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic operation to clear ONLY the bits as specified by the bit mask.
Definition Numeric.h:309
BitArray_(Cpl::Dm::ModelDatabase &myModelBase, const char *symbolicName, WORDSIZE initialValue)
Constructor. Valid MP. Requires an initial value.
Definition Numeric.h:273
uint16_t clearBit(uint8_t bitPosition, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic operation to set the zero indexed bit to a 0.
Definition Numeric.h:289
void setJSONVal(JsonDocument &doc) noexcept
See Cpl::Dm::Point.
Definition Numeric.h:330
BitArray_(Cpl::Dm::ModelDatabase &myModelBase, const char *symbolicName)
Constructor. Invalid MP.
Definition Numeric.h:267
uint16_t setBitsByMask(WORDSIZE bitMask, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic operation to set the bits specified by the bit mask.
Definition Numeric.h:315
This template class provides a mostly concrete implementation for a Model Point who's data is a C num...
Definition Numeric.h:62
uint16_t write(ELEMTYPE newValue, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Type safe write. See Cpl::Dm::ModelPoint.
Definition Numeric.h:119
bool fromJSON_(JsonVariant &src, Cpl::Dm::ModelPoint::LockRequest_T lockRequest, uint16_t &retSequenceNumber, Cpl::Text::String *errorMsg) noexcept
See Cpl::Dm::Point.
Definition Numeric.h:218
uint16_t bitwiseClearAndSet(ELEMTYPE maskToClear, ELEMTYPE maskToSet, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic bitwise AND operation.
Definition Numeric.h:170
bool readAndSync(ELEMTYPE &dstData, uint16_t &seqNum, SubscriberApi &observerToSync)
See Cpl::Dm::ModelPointCommon.
Definition Numeric.h:204
bool readAndSync(ELEMTYPE &dstData, SubscriberApi &observerToSync)
See Cpl::Dm::ModelPointCommon.
Definition Numeric.h:197
Numeric(Cpl::Dm::ModelDatabase &myModelBase, const char *symbolicName)
Constructor: Invalid MP.
Definition Numeric.h:69
bool read(ELEMTYPE &dstData, uint16_t *seqNumPtr=nullptr) const noexcept
Type safe read. See Cpl::Dm::ModelPoint.
Definition Numeric.h:83
uint16_t decrement(ELEMTYPE decSize=1, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic decrement.
Definition Numeric.h:134
uint16_t readThenClearBits(ELEMTYPE &dstData, ELEMTYPE maskToClear, uint16_t *seqNumPtr=nullptr) noexcept
Atomic Read and then clear bits operation.
Definition Numeric.h:95
Numeric(Cpl::Dm::ModelDatabase &myModelBase, const char *symbolicName, ELEMTYPE initialValue)
Constructor: Valid MP (requires initial value)
Definition Numeric.h:75
uint16_t readThenClear(ELEMTYPE &dstData, uint16_t *seqNumPtr=nullptr) noexcept
Atomic Read and then clear (i.e. set to 0) operation.
Definition Numeric.h:113
uint16_t copyFrom(const MPTYPE &src, LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Updates the MP with the valid-state/data from 'src'. Note: the src.lock state is NOT copied.
Definition Numeric.h:179
void setJSONVal(JsonDocument &doc) noexcept
See Cpl::Dm::Point.
Definition Numeric.h:211
uint16_t bitwiseOR(ELEMTYPE maskToOR, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic bitwise OR operation.
Definition Numeric.h:143
ELEMTYPE m_data
The element's value.
Definition Numeric.h:65
uint16_t bitwiseAND(ELEMTYPE maskToAND, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic bitwise AND operation.
Definition Numeric.h:161
uint16_t increment(ELEMTYPE incSize=1, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic increment.
Definition Numeric.h:125
uint16_t bitwiseXOR(ELEMTYPE maskToXOR, Cpl::Dm::ModelPoint::LockRequest_T lockRequest=Cpl::Dm::ModelPoint::eNO_REQUEST) noexcept
Atomic bitwise XOR operation.
Definition Numeric.h:152
void attach(Cpl::Dm::Subscriber< MPTYPE > &observer, uint16_t initialSeqNumber=SEQUENCE_NUMBER_UNKNOWN) noexcept
Type safe register observer.
Definition Numeric.h:185
void detach(Cpl::Dm::Subscriber< MPTYPE > &observer) noexcept
Type safe un-register observer.
Definition Numeric.h:191
This template class extends the implementation of Numeric<> class to support the pointers instead of ...
Definition Numeric.h:372
Pointer_(Cpl::Dm::ModelDatabase &myModelBase, const char *symbolicName, void *initialValue)
Constructor. Valid MP. Requires an initial value.
Definition Numeric.h:381
bool fromJSON_(JsonVariant &src, Cpl::Dm::ModelPoint::LockRequest_T lockRequest, uint16_t &retSequenceNumber, Cpl::Text::String *errorMsg) noexcept
See Cpl::Dm::Point.
Definition Numeric.h:396
void setJSONVal(JsonDocument &doc) noexcept
See Cpl::Dm::Point.
Definition Numeric.h:388
Pointer_(Cpl::Dm::ModelDatabase &myModelBase, const char *symbolicName)
Constructor. Invalid MP.
Definition Numeric.h:375
This abstract class defines the Subscriber interface - for change notifications - to a Model Points d...
Definition SubscriberApi.h:34
This template class defines a type safe Subscriber.
Definition Subscriber.h:82
This template class represents a NULL terminated string of a specific length.
Definition FString.h:38
const char * getString() const
See Cpl::Text::String.
void format(const char *format,...)
See Cpl::Text::String.
This abstract class defines the operations that can be before on a NULL terminated string.
Definition String.h:40
This file contains some general purpose string formatting functions.
long asciiBinaryToBuffer(void *dstBinary, const char *srcString, size_t dstMaxLen, bool reverse=false)
This method will convert an 'ASCII BINARY' string to an equivalent binary buffer, i....
bool a2ull(unsigned long long &convertedValue, const char *string, int base=10, const char *validStopChars=0, const char **endptr=0)
This method is the same as a2i() except that it converts unsigned long long integer.
bool bufferToAsciiBinary(const void *binaryData, int len, Cpl::Text::String &destString, bool appendToString=false, bool reverse=false)
This method converts the binary buffer to a single string that is ASCII BINARY.
The 'Cpl' namespace is the root name space for the Colony.
Definition Api16.h:20