Fledge
An open source edge computing platform for industrial users
pythonreading.h
1 #ifndef _PYTHONREADING_H
2 #define _PYTHONREADING_H
3 /*
4  * Fledge Python Reading
5  *
6  * Copyright (c) 2021 Dianomic Systems
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Mark Riddoch
11  */
12 
13 #include <reading.h>
14 #include <Python.h>
15 
20 class PythonReading : public Reading {
21  public:
22  PythonReading(PyObject *pyReading);
23  ~PythonReading() {};
24  PyObject *toPython(bool changeKeys = false, bool bytesString = false);
25  static std::string errorMessage();
26  static bool isArray(PyObject *);
27  static bool doneNumPyImport;
28 
29  private:
30  PyObject *convertDatapoint(Datapoint *dp, bool bytesString = false);
31  DatapointValue *getDatapointValue(PyObject *object);
32  void fixQuoting(std::string& str);
33  int InitNumPy();
34 };
35 #endif
static bool isArray(PyObject *)
Return true of the Python object is an array.
Definition: pythonreading.cpp:705
A wrapper class for a Reading to convert to and from Python objects.
Definition: pythonreading.h:20
Name and value pair used to represent a data value within an asset reading.
Definition: datapoint.h:310
PythonReading(PyObject *pyReading)
Construct a PythonReading from a DICT object returned by Python code.
Definition: pythonreading.cpp:43
static std::string errorMessage()
Retrieve the error message last raised in Python.
Definition: pythonreading.cpp:634
An asset reading represented as a class.
Definition: reading.h:33
Class to hold an actual reading value.
Definition: datapoint.h:30
PyObject * toPython(bool changeKeys=false, bool bytesString=false)
Convert a PythonReading, which is just a Reading, into a PyObject structure that can be passed to emb...
Definition: pythonreading.cpp:372