Fledge
An open source edge computing platform for industrial users
north_plugin.h
1 #ifndef _NORTH_PLUGIN
2 #define _NORTH_PLUGIN
3 /*
4  * Fledge north service.
5  *
6  * Copyright (c) 2020 Dianomic Systems
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Mark Riddoch
11  */
12 
13 #include <plugin.h>
14 #include <plugin_manager.h>
15 #include <config_category.h>
16 #include <string>
17 #include <reading.h>
18 
19 typedef void (*INGEST_CB)(void *, Reading);
20 typedef void (*INGEST_CB2)(void *, std::vector<Reading *>*);
21 
33 class NorthPlugin : public Plugin {
34 
35 public:
36  NorthPlugin(PLUGIN_HANDLE handle, const ConfigCategory& category);
37  ~NorthPlugin();
38 
39  uint32_t send(const std::vector<Reading *>& readings);
40  void reconfigure(const std::string&);
41  void shutdown();
42  bool persistData() { return info->options & SP_PERSIST_DATA; };
43  void start();
44  void startData(const std::string& pluginData);
45  std::string shutdownSaveData();
46  bool hasControl() { return info->options & SP_CONTROL; };
47  void pluginRegister(bool ( *write)(char *name, char *value, ControlDestination destination, ...),
48  int (* operation)(char *operation, int paramCount, char *names[], char *parameters[], ControlDestination destination, ...));
49 
50 private:
51  PLUGIN_HANDLE m_instance;
52  uint32_t (*pluginSendPtr)(PLUGIN_HANDLE, const std::vector<Reading *>& readings);
53  void (*pluginReconfigurePtr)(PLUGIN_HANDLE*,
54  const std::string& newConfig);
55  void (*pluginShutdownPtr)(PLUGIN_HANDLE);
56  std::string (*pluginShutdownDataPtr)(const PLUGIN_HANDLE);
57  void (*pluginStartPtr)(PLUGIN_HANDLE);
58  void (*pluginStartDataPtr)(PLUGIN_HANDLE,
59  const std::string& pluginData);
60  void (*pluginRegisterPtr)(PLUGIN_HANDLE handle,
61  bool ( *write)(char *name, char *value, ControlDestination destination, ...),
62  int (* operation)(char *operation, int paramCount, char *names[], char *parameters[], ControlDestination destination, ...));
63 
64 };
65 
66 #endif
unsigned int options
The set of option flags that apply to this plugin.
Definition: plugin_api.h:29
uint32_t send(const std::vector< Reading *> &readings)
Call the send method in the plugin.
Definition: north_plugin.cpp:103
Definition: config_category.h:56
NorthPlugin(PLUGIN_HANDLE handle, const ConfigCategory &category)
Constructor for the class that wraps the north plugin.
Definition: north_plugin.cpp:31
An asset reading represented as a class.
Definition: reading.h:33
A generic representation of a plugin.
Definition: plugin.h:20
void shutdown()
Call the shutdown method in the plugin.
Definition: north_plugin.cpp:169
Class that represents a north plugin.
Definition: north_plugin.h:33
void pluginRegister(bool(*write)(char *name, char *value, ControlDestination destination,...), int(*operation)(char *operation, int paramCount, char *names[], char *parameters[], ControlDestination destination,...))
Call the plugin_register entry point of the plugin if one has been defined.
Definition: north_plugin.cpp:206
std::string shutdownSaveData()
Call the shutdown method in the plugin and return plugin data to parsist as JSON string.
Definition: north_plugin.cpp:192
void start()
Call the start method in the plugin with no persisted data.
Definition: north_plugin.cpp:78
void reconfigure(const std::string &)
Call the reconfigure method in the plugin.
Definition: north_plugin.cpp:123