 |
Fledge
An open source edge computing platform for industrial users
|
19 #include <databuffer.h>
20 #include <rapidjson/document.h>
21 #include "string_utils.h"
37 m_value.str =
new std::string(value);
61 m_value.a =
new std::vector<double>(values);
62 m_type = T_FLOAT_ARRAY;
71 m_type = isDict? T_DP_DICT : T_DP_LIST;
79 m_value.image =
new DPImage(value);
89 m_type = T_DATABUFFER;
98 m_value.image = value;
107 m_value.dataBuffer = value;
108 m_type = T_DATABUFFER;
116 m_value.a2d =
new std::vector< std::vector<double>* >;
117 for (
auto row : values)
119 std::vector<double> *nrow =
new std::vector<double>;
124 m_value.a2d->push_back(nrow);
126 m_type = T_2D_FLOAT_ARRAY;
155 m_value.str =
new std::string(value);
186 m_value.image =
new DPImage(value);
203 long toInt()
const {
return m_value.i; };
210 typedef enum DatapointTag
231 std::string getTypeStr()
const
235 case T_STRING:
return std::string(
"STRING");
236 case T_INTEGER:
return std::string(
"INTEGER");
237 case T_FLOAT:
return std::string(
"FLOAT");
238 case T_FLOAT_ARRAY:
return std::string(
"FLOAT_ARRAY");
239 case T_DP_DICT:
return std::string(
"DP_DICT");
240 case T_DP_LIST:
return std::string(
"DP_LIST");
241 case T_IMAGE:
return std::string(
"IMAGE");
242 case T_DATABUFFER:
return std::string(
"DATABUFFER");
243 case T_2D_FLOAT_ARRAY:
return std::string(
"2D_FLOAT_ARRAY");
244 default:
return std::string(
"INVALID");
277 return m_value.image;
285 return m_value.dataBuffer;
289 void deleteNestedDPV();
290 const std::string escape(
const std::string& str)
const;
295 std::vector<double>* a;
296 std::vector<Datapoint*>
300 std::vector< std::vector<double>* >
329 std::string rval =
"\"" + escape(m_name) +
"\":";
371 std::vector<Datapoint*>*
parseJson(
const std::string& json);
372 std::vector<Datapoint*>*
recursiveJson(
const rapidjson::Value& document);
Simple Image class that will be used within data points to store image data.
Definition: dpimage.h:21
void setName(std::string name)
Rename the datapoint.
Definition: datapoint.h:346
std::vector< std::vector< double > * > *& getDp2DArr()
Return 2D array of float.
Definition: datapoint.h:267
DatapointValue(const std::vector< std::vector< double > * > &values)
Construct with a 2 dimentional array of floating point values.
Definition: datapoint.h:114
DatapointValue & getData()
Return reference to Datapoint value.
Definition: datapoint.h:362
Datapoint(const std::string &name, DatapointValue &value)
Construct with a data point value.
Definition: datapoint.h:315
void setValue(long value)
Set the value of a datapoint, this may also cause the type to be changed.
Definition: datapoint.h:164
const DatapointValue getData() const
Return Datapoint value.
Definition: datapoint.h:354
std::string toString() const
Return the value as a string.
Definition: datapoint.cpp:27
DatapointValue & operator=(const DatapointValue &rhs)
Assignment Operator.
Definition: datapoint.cpp:253
void setValue(std::string value)
Set the value of a datapoint, this may also cause the type to be changed.
Definition: datapoint.h:149
std::string toStringValue() const
Return string value without trailing/leading quotes.
Definition: datapoint.h:198
DatapointValue(std::vector< Datapoint * > *&values, bool isDict)
Construct with an array of Datapoints.
Definition: datapoint.h:68
DatapointValue(DPImage *value)
Construct with an Image Pointer, the image becomes owned by the datapointValue.
Definition: datapoint.h:96
dataTagType getType() const
Return the Tag type.
Definition: datapoint.h:226
std::vector< double > *& getDpArr()
Return array of float.
Definition: datapoint.h:259
Name and value pair used to represent a data value within an asset reading.
Definition: datapoint.h:310
std::vector< Datapoint * > * parseJson(const std::string &json)
Parse a json string and generates a corresponding datapoint vector
Definition: datapoint.cpp:374
DatapointValue(const std::string &value)
Construct with a string.
Definition: datapoint.h:35
Buffer type for storage of arbitrary buffers of data within a datapoint.
Definition: databuffer.h:19
DataBuffer * getDataBuffer()
Return the DataBuffer.
Definition: datapoint.h:283
DatapointValue(const DPImage &value)
Construct with an Image.
Definition: datapoint.h:77
std::string toJSONProperty()
Return asset reading data point as a JSON property that can be included within a JSON document.
Definition: datapoint.h:327
std::vector< Datapoint * > * recursiveJson(const rapidjson::Value &document)
Recursive method to convert a JSON string to a datapoint.
Definition: datapoint.cpp:397
std::vector< Datapoint * > *& getDpVec()
Return array of datapoints.
Definition: datapoint.h:251
DatapointValue(DataBuffer *value)
Construct with a DataBuffer.
Definition: datapoint.h:105
DatapointValue(const std::vector< double > &values)
Construct with an array of floating point values.
Definition: datapoint.h:59
void setValue(const DPImage &value)
Set the value of a datapoint to be an image.
Definition: datapoint.h:184
DPImage * getImage()
Return the Image.
Definition: datapoint.h:275
const std::string getName() const
Return the Datapoint name.
Definition: datapoint.h:338
DatapointValue(const DataBuffer &value)
Construct with a DataBuffer.
Definition: datapoint.h:86
DatapointValue(const double value)
Construct with a floating point value.
Definition: datapoint.h:51
long toInt() const
Return long value.
Definition: datapoint.h:203
void setValue(double value)
Set the value of a datapoint, this may also cause the type to be changed.
Definition: datapoint.h:175
double toDouble() const
Return double value.
Definition: datapoint.h:207
Class to hold an actual reading value.
Definition: datapoint.h:30
~DatapointValue()
Destructor.
Definition: datapoint.cpp:189
DatapointValue(const long value)
Construct with an integer value.
Definition: datapoint.h:43