summaryrefslogtreecommitdiffstats
path: root/Master/Masterarbeit/src/common/inc/plugin_api.h
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Masterarbeit/src/common/inc/plugin_api.h
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Masterarbeit/src/common/inc/plugin_api.h')
-rw-r--r--Master/Masterarbeit/src/common/inc/plugin_api.h138
1 files changed, 138 insertions, 0 deletions
diff --git a/Master/Masterarbeit/src/common/inc/plugin_api.h b/Master/Masterarbeit/src/common/inc/plugin_api.h
new file mode 100644
index 0000000..a0c9e48
--- /dev/null
+++ b/Master/Masterarbeit/src/common/inc/plugin_api.h
@@ -0,0 +1,138 @@
+/*!
+ * \file plugin_api.h
+ *
+ * \author S. Eisenhauer
+ *
+ * \date 31.08.2011
+ *
+ * \brief Interface of a plugin used by \ref CPluginExecutor
+ *
+ * This file defines the interface which must be provided by a plugin to \ref CPluginExecutor
+ *
+ */
+
+#ifndef PLUGIN_API_H_
+#define PLUGIN_API_H_
+
+#include "global.h"
+
+/*!
+* \brief Definition of a message to be sent on the CAN bus
+*/
+struct tstCanTxMessage
+{
+ uint32_t u32TxCycleMilliseconds; //!< Interval for sending cyclic message in milliseconds
+ uint32_t u32MillisecondCounter; //!< Incremented every millisecond, resetted to zero when message is sent
+ uint32_t u32CanId; //!< CAN ID of the message
+ uint8_t au8Data[8]; //!< data content of the message
+ uint8_t u8Dlc; //!< Data Length Code of the message: bytes of au8Data used by the message
+};
+/*!
+* \brief Type for pointer to a tstCanTxMessage
+*/
+typedef tstCanTxMessage* tpstCanTxMessage;
+
+/*!
+ * \brief Pure virtual interface of a plugin.
+ *
+ * Must be implemented by concrete plugin
+ */
+class IPlugin
+{
+public:
+ /*!
+ * executed every millisecond
+ * \warning Keep this method implementation short. It is executed with Real-Time priority.
+ */
+ virtual void vRun( void ) = 0;
+ /*!
+ * Get a message to be send on CAN bus from plugin
+ * \param[in] u32MsgIndex Index of the message. Call u32GetNumOfCanTxMessages before to get the number of available messages
+ * \return Pointer to the message
+ */
+ virtual tpstCanTxMessage pxGetCanTxMessage( const uint32_t u32MsgIndex ) = 0;
+ /*!
+ * Get the number of CAN TX messages defined in the plugin
+ * \return the number of messages
+ */
+ virtual uint32_t u32GetNumOfCanTxMessages( void ) = 0;
+ /*!
+ * Get the number of the used CAN interface
+ * \return the number of the used CAN interface
+ */
+ virtual int32_t i32GetCanInterfaceHandle( void ) = 0;
+ /*!
+ * Should this plugin be automatically loaded when CPluginExecutor starts up
+ * \return TRUE is the plugin should be autoloaded, FALSE otherwise
+ */
+ virtual bool boAutoload( void ) = 0;
+ /*!
+ * Is this plugin the instance of the Log Plugin
+ * \return TRUE if it is the log plugin, FALSE otherwise
+ */
+ virtual bool boIsLogger( void ) = 0;
+ /*!
+ * get a log file
+ * \param[in] pcRequest pointer to a memory buffer containing the filename of the request
+ * \param[out] pcResponse pointer to a memory buffer where the filename will be stored
+ * \return status
+ */
+ virtual tenRetCodes enGetLog(const char* pcRequest, char* pcResponse) = 0;
+ /*!
+ * initialize the plugin
+ *
+ * \param[in] pvExecutor Pointer to target main application
+ * \param[in] pvIfMan Pointer to an interface manager object
+ * \param[in] i32Interface Number of the interface ti be used by the plugin
+ * \param[in] u32PluginId ID of the Plugin
+ */
+ virtual void vInit(void* pvExecutor, void* pvIfMan, int32_t i32Interface, uint32_t u32PluginId) = 0;
+ /*!
+ * Add a message to the log
+ *
+ * \param[in] stLogMessage the message to log
+ */
+ virtual void vLogMessage(const tstLogMessage& stLogMessage) = 0;
+};
+extern "C"
+{
+ /*!
+ * \brief type for factory function
+ * \param[in] pvExecutor Pointer to target main application
+ * \param[in] pvIfMan Pointer to an interface manager object
+ * \param[in] i32Interface Number of the interface to be used by the plugin
+ * \param[in] u32PluginId ID of the Plugin
+ * \return Pointer to the Plugin object
+ */
+ typedef IPlugin* tfctCreatePlugin(
+ void* pvExecutor,
+ void* pvIfMan,
+ int32_t i32Interface,
+ uint32_t u32PluginId
+ );
+ /*!
+ * \brief type for factory function pointer
+ */
+ typedef tfctCreatePlugin *tpfctCreatePlugin;
+ /*!
+ * \brief type for deinitialization function
+ *
+ * \param[in] pxPlugin Pointer to the plugin to be deinitialized
+ */
+ typedef void tfctDestroyPlugin(IPlugin* pxPlugin);
+ /*!
+ * \brief type for deinitialization function pointer
+ *
+ * \param[in] pxPlugin Pointer to the plugin to be deinitialized
+ */
+ typedef tfctDestroyPlugin *tpfctDestroyPlugin;
+ /*!
+ * C interface for the factory
+ */
+ tfctCreatePlugin pxCreatePlugin;
+ /*!
+ * C interface for the deinitialization
+ */
+ tfctDestroyPlugin vDestroyPlugin;
+}
+#endif /* PLUGIN_API_H_ */