Fledge
An open source edge computing platform for industrial users
south_plugin.h
1 #ifndef _SOUTH_PLUGIN
2 #define _SOUTH_PLUGIN
3 /*
4  * Fledge south service.
5  *
6  * Copyright (c) 2018 OSisoft, LLC
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_set.h>
18 
19 typedef void (*INGEST_CB)(void *, Reading);
20 typedef void (*INGEST_CB2)(void *, std::vector<Reading *>*);
21 
33 class SouthPlugin : public Plugin {
34 
35 public:
36  SouthPlugin(PLUGIN_HANDLE handle, const ConfigCategory& category);
37  ~SouthPlugin();
38 
39  Reading poll();
40  ReadingSet* pollV2();
41  void start();
42  void reconfigure(const std::string&);
43  void shutdown();
44  void registerIngest(INGEST_CB, void *);
45  void registerIngestV2(INGEST_CB2, void *);
46  bool isAsync() { return info->options & SP_ASYNC; };
47  bool hasControl() { return info->options & SP_CONTROL; };
48  bool persistData() { return info->options & SP_PERSIST_DATA; };
49  void startData(const std::string& pluginData);
50  std::string shutdownSaveData();
51  bool write(const std::string& name, const std::string& value);
52  bool operation(const std::string& name, std::vector<PLUGIN_PARAMETER *>& );
53 private:
54  PLUGIN_HANDLE instance;
55  bool m_started; // Plugin started indicator, for async plugins
56  void (*pluginStartPtr)(PLUGIN_HANDLE);
57  Reading (*pluginPollPtr)(PLUGIN_HANDLE);
58  std::vector<Reading*>* (*pluginPollPtrV2)(PLUGIN_HANDLE);
59  void (*pluginReconfigurePtr)(PLUGIN_HANDLE*,
60  const std::string& newConfig);
61  void (*pluginShutdownPtr)(PLUGIN_HANDLE);
62  void (*pluginRegisterPtr)(PLUGIN_HANDLE, INGEST_CB, void *);
63  void (*pluginRegisterPtrV2)(PLUGIN_HANDLE, INGEST_CB2, void *);
64  std::string (*pluginShutdownDataPtr)(const PLUGIN_HANDLE);
65  void (*pluginStartDataPtr)(PLUGIN_HANDLE,
66  const std::string& pluginData);
67  bool (*pluginWritePtr)(PLUGIN_HANDLE, const std::string& name, const std::string& value);
68  bool (*pluginOperationPtr)(const PLUGIN_HANDLE, const std::string& name, int count,
69  PLUGIN_PARAMETER **parameters);
70 };
71 
72 #endif
void startData(const std::string &pluginData)
Call the start method in the plugin.
Definition: south_plugin.cpp:147
unsigned int options
The set of option flags that apply to this plugin.
Definition: plugin_api.h:29
Definition: config_category.h:56
Class that represents a south plugin.
Definition: south_plugin.h:33
Reading poll()
Call the poll method in the plugin.
Definition: south_plugin.cpp:169
bool operation(const std::string &name, std::vector< PLUGIN_PARAMETER *> &)
Call the plugin operation entry point with the operation to execute.
Definition: south_plugin.cpp:363
std::string shutdownSaveData()
Call the shutdown method in the plugin.
Definition: south_plugin.cpp:264
An asset reading represented as a class.
Definition: reading.h:33
A generic representation of a plugin.
Definition: plugin.h:20
Reading set class.
Definition: reading_set.h:26
void shutdown()
Call the shutdown method in the plugin.
Definition: south_plugin.cpp:244
~SouthPlugin()
South plugin destructor.
Definition: south_plugin.cpp:118
void start()
Call the start method in the plugin.
Definition: south_plugin.cpp:125
void reconfigure(const std::string &)
Call the reconfigure method in the plugin.
Definition: south_plugin.cpp:218
ReadingSet * pollV2()
Call the poll method in the plugin supporting interface ver 2.x.
Definition: south_plugin.cpp:189
SouthPlugin(PLUGIN_HANDLE handle, const ConfigCategory &category)
Constructor for the class that wraps the south plugin.
Definition: south_plugin.cpp:32
bool write(const std::string &name, const std::string &value)
Call the write entry point of the plugin.
Definition: south_plugin.cpp:321
Pass a name/value pair to a plugin.
Definition: plugin_api.h:53