#include "datapoint_value.h"
#include "json.h"
#include <stdbool.h>
#include <stdint.h>
Go to the source code of this file.
|
| typedef enum eGCLogLevel | GCLogLevel |
| |
| typedef const struct sGCPluginInfo * | GCPluginInfo |
| |
| typedef struct sGCEthernetInterface * | GCEthernetInterface |
| |
| typedef struct sGCSerialInterface * | GCSerialInterface |
| |
| typedef const struct sGCDatapoint | GCDatapoint |
| |
| typedef void * | GCCoreCtx |
| |
| typedef void * | GCInstanceHandle |
| | The handle to the plugin instance.
|
| |
| typedef bool(* | tPublishDatapointValue) (GCCoreCtx, GCDatapointValue) |
| |
| typedef void(* | tStoreDatapointValue) (GCCoreCtx, GCDatapointValue) |
| |
| typedef GCDatapointValue(* | tGetLastDatapointValue) (GCCoreCtx, GCDatapointIdentifier) |
| |
| typedef void(* | tSystemLog) (GCCoreCtx, GCLogLevel, const char *) |
| |
| typedef void(* | tAuditLog) (GCCoreCtx, const char *) |
| |
| typedef bool(* | tReleaseDatapointValue) (GCDatapointValue) |
| |
| typedef bool(* | tGetEthernetInterface) (GCCoreCtx, const char *name, GCEthernetInterface out) |
| |
| typedef bool(* | tGetSerialInterface) (GCCoreCtx, const char *name, GCSerialInterface out) |
| |
| typedef const struct sPluginConfig | GCPluginConfig |
| |
| typedef const struct sGCPluginInterface * | GCPluginInterface |
| |
|
| enum | eGCLogLevel {
CRITICAL
, ERROR
, WARNING
, INFO
,
DEBUG
} |
| | The log levels available. More...
|
| |
| enum | GCStopBits { GC_STOP_BITS_ONE = 1
, GC_STOP_BITS_TWO = 2
} |
| | Serial port stop bits configuration. More...
|
| |
| enum | GCParity { GC_PARITY_NONE = 0
, GC_PARITY_ODD = 1
, GC_PARITY_EVEN = 2
} |
| | Serial port parity configuration. More...
|
| |
| enum | GCDataBits { GC_DATA_BITS_FIVE = 5
, GC_DATA_BITS_SIX = 6
, GC_DATA_BITS_SEVEN = 7
, GC_DATA_BITS_EIGHT = 8
} |
| | Serial port data bits configuration. More...
|
| |
|
| GCInstanceHandle | gc_plugin_init (GCPluginInterface interface) |
| | Initializes the plugin.
|
| |
| void | gc_plugin_shutdown (GCInstanceHandle instance) |
| | Safely shuts down the plugin instance.
|
| |
| GCPluginInfo | gc_plugin_get_info () |
| | Retrieves the plugin information.
|
| |
| bool | gc_plugin_receive_datapoint (GCInstanceHandle instance, const GCDatapointValue dataValue) |
| | Receives a datapoint value.
|
| |
| void | gcSystemLog (GCPluginInterface interface, GCLogLevel level, const char *message,...) |
| | Logs a message to the system log.
|
| |
| void | gcAuditLog (GCPluginInterface interface, const char *message,...) |
| | Logs a message to the audit log.
|
| |
| void | gcReleaseDatapointValue (GCPluginInterface interface, GCDatapointValue dataValue) |
| | Releases a datapoint value This function is a wrapper around the releaseDatapointValueCallback callback provided by the core. It is used to release a datapoint value that was previously returned by the core.
|
| |
| bool | gcPublishDatapointValue (GCPluginInterface interface, GCDatapointValue dataValue) |
| | Publishes a datapoint value This function is a wrapper around the publishDatapointValueCallback callback provided by the core. It is used to publish a new datapoint value to the core.
|
| |
| bool | gcGetEthernetInterface (GCPluginInterface interface, const char *name, GCEthernetInterface out) |
| | Retrieves an Ethernet interface configuration by name.
|
| |
| bool | gcGetSerialInterface (GCPluginInterface interface, const char *name, GCSerialInterface out) |
| | Retrieves a serial interface configuration by name.
|
| |
| void | gcStoreDatapointValue (GCPluginInterface interface, GCDatapointValue dataValue) |
| | Stores a datapoint value This function us a wrapper around the StoreDatapointValueCallback callback provided by the core. It is used to store a new datapoint to the timeseries database.
|
| |
◆ GC_INTERFACE_NAME_MAX
| #define GC_INTERFACE_NAME_MAX 50 |
Maximum length for interface names (including null terminator)
◆ GCCoreCtx
◆ GCDatapoint
◆ GCEthernetInterface
◆ GCInstanceHandle
The handle to the plugin instance.
The handle that the core provides to the plugin, this is for stateful plugins so they can keep track of their own state. It is meant to be casted to the plugin instance struct defined by it.
◆ GCLogLevel
◆ GCPluginConfig
◆ GCPluginInfo
◆ GCPluginInterface
◆ GCSerialInterface
◆ tAuditLog
| typedef void(* tAuditLog) (GCCoreCtx, const char *) |
◆ tGetEthernetInterface
◆ tGetLastDatapointValue
◆ tGetSerialInterface
◆ tPublishDatapointValue
◆ tReleaseDatapointValue
◆ tStoreDatapointValue
◆ tSystemLog
◆ eGCLogLevel
The log levels available.
| Enumerator |
|---|
| CRITICAL | |
| ERROR | |
| WARNING | |
| INFO | |
| DEBUG | |
◆ GCDataBits
Serial port data bits configuration.
| Enumerator |
|---|
| GC_DATA_BITS_FIVE | |
| GC_DATA_BITS_SIX | 5 data bits
|
| GC_DATA_BITS_SEVEN | 6 data bits
|
| GC_DATA_BITS_EIGHT | 7 data bits
|
◆ GCParity
Serial port parity configuration.
| Enumerator |
|---|
| GC_PARITY_NONE | |
| GC_PARITY_ODD | No parity.
|
| GC_PARITY_EVEN | Odd parity.
|
◆ GCStopBits
Serial port stop bits configuration.
| Enumerator |
|---|
| GC_STOP_BITS_ONE | |
| GC_STOP_BITS_TWO | 1 stop bit
|
◆ gc_plugin_get_info()
Retrieves the plugin information.
This is the only exported function that does not require a plugin instance handle since every plugin instance will have the same information.
- Returns
- GCPluginInfo The information about the plugin
◆ gc_plugin_init()
Initializes the plugin.
This function is called by the core to initialize the plugin. This is the entrypoint of the plugin, and it will be called once for every plugin instance. It may also be called multiple times for the same plugin instance in the case of a restart for example, but in this case it is guaranteed that the plugin instance will be shutdown before (when the core issues a shutdown command). The core will only call other plugin exported functions after this function returns.
- Parameters
-
| interface | The interface that the core provides to the plugin |
- Returns
- The handle to the plugin instance, this maybe any pointer to memory and can be use to keep track of the instance state as it will be forwarded to all other plugin exported functions.
◆ gc_plugin_receive_datapoint()
Receives a datapoint value.
This function is called by the core to deliver a new datapoint value to the plugin via the subscription system. The plugin should process the value and return true if the value was successfully processed, false otherwise.
It is very important that the plugin releases the datapoint passed as an argument after it is done with it. This is done by calling the releaseDatapointValue callback. Failing to do so will result in a memory leak.
- Parameters
-
| instance | The handle to the plugin instance |
| dataValue | A shared reference to a datapoint value |
- Returns
- true if the value was successfully processed, false otherwise
◆ gc_plugin_shutdown()
Safely shuts down the plugin instance.
This function is invoked by the core to terminate the plugin instance. The following points should be taken into consideration regarding concurrency:
- After this function completes, no other functions exported by the plugin will be called for this instance.
- During the execution of
gc_plugin_shutdown, other plugin functions may still be running concurrently if their calls were initiated before gc_plugin_shutdown was invoked. It is therefore the plugin's responsibility to handle any potential race conditions while releasing resources.
- All resources allocated by the plugin should be released by the time this function returns.
- Parameters
-
| instance | A pointer to the plugin instance being shut down. |
◆ gcAuditLog()
Logs a message to the audit log.
This function is a wrapper around the logAuditCallback callback provided by the core. It is used to log messages to the audit log. It works similarly to the printf function. It has a maximum buffer size of 1000 bytes, any message exceeding this size will be truncated.
- Parameters
-
| interface | The interface that the core provides to the plugin |
| message | The message to be logged |
◆ gcGetEthernetInterface()
Retrieves an Ethernet interface configuration by name.
This function is used to retrieve the configuration of an Ethernet interface by its logical name.
- Parameters
-
| interface | The interface that the core provides to the plugin |
| name | The logical name of the Ethernet interface (e.g., "primary_eth") |
| out | Pointer to the output structure (allocated by the plugin) |
- Returns
- true if the interface was found and the output structure was filled, false otherwise
◆ gcGetSerialInterface()
Retrieves a serial interface configuration by name.
This function is used to retrieve the configuration of a serial interface by its logical name.
- Parameters
-
| interface | The interface that the core provides to the plugin |
| name | The logical name of the serial interface (e.g., "moxa_port_1") |
| out | Pointer to the output structure (allocated by the plugin) |
- Returns
- true if the interface was found and the output structure was filled, false otherwise
◆ gcPublishDatapointValue()
Publishes a datapoint value This function is a wrapper around the publishDatapointValueCallback callback provided by the core. It is used to publish a new datapoint value to the core.
- Parameters
-
| interface | The interface that the core provides to the plugin |
| dataValue | The datapoint value to be published |
- Returns
- true if the value was published successfully, false if an error occurred while publishing the value
◆ gcReleaseDatapointValue()
Releases a datapoint value This function is a wrapper around the releaseDatapointValueCallback callback provided by the core. It is used to release a datapoint value that was previously returned by the core.
- Parameters
-
| interface | The interface that the core provides to the plugin |
| dataValue | The datapoint value to be released |
◆ gcStoreDatapointValue()
Stores a datapoint value This function us a wrapper around the StoreDatapointValueCallback callback provided by the core. It is used to store a new datapoint to the timeseries database.
- Parameters
-
| interface | The interface that the core provides to the plugin |
| dataValue | the datapoint value to be stored |
◆ gcSystemLog()
Logs a message to the system log.
This function is a wrapper around the logSystemCallback callback provided by the core. It is used to log messages to the system log. It works similarly to the printf function. It has a maximum buffer size of 1000 bytes, any message exceeding this size will be truncated.
- Parameters
-
| interface | The interface that the core provides to the plugin |
| level | The log level of the message from the GCLogLevel enum |
| message | The message to be logged |