diff options
Diffstat (limited to 'Master/Masterarbeit/src/XorayaTestPlugin/xoraya_test_plugin.cpp')
| -rw-r--r-- | Master/Masterarbeit/src/XorayaTestPlugin/xoraya_test_plugin.cpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/Master/Masterarbeit/src/XorayaTestPlugin/xoraya_test_plugin.cpp b/Master/Masterarbeit/src/XorayaTestPlugin/xoraya_test_plugin.cpp new file mode 100644 index 0000000..c2b0165 --- /dev/null +++ b/Master/Masterarbeit/src/XorayaTestPlugin/xoraya_test_plugin.cpp @@ -0,0 +1,127 @@ +/*
+ * xoraya_test_plugin.cpp
+ *
+ * Created on: 31.08.2011
+ * Author: Eisenhauer
+ */
+
+#include "plugin_api.h"
+#include "global.h"
+#include "interface_manager.h"
+
+class XorayaTestPlugin : public IPlugin
+{
+private:
+ IInterfaceManager& m_xInterfaceManager;
+ int32_t m_i32InterfaceHandle;
+ uint32_t m_u32TxMsgId;
+ tCanTxMessageList m_axCanTxMessages;
+ uint32_t m_u32PluginId;
+ uint32_t m_u32Loopcounter;
+
+ static uint32_t su32InstanceCount;
+
+public:
+
+ XorayaTestPlugin( IInterfaceManager& xIfMan,
+ int32_t i32Interface,
+ uint32_t u32PluginId
+ )
+ :m_xInterfaceManager( xIfMan ),
+ m_i32InterfaceHandle( i32Interface ),
+ m_u32TxMsgId(0x100*(1+XorayaTestPlugin::su32InstanceCount)),
+ m_u32PluginId(u32PluginId),
+ m_u32Loopcounter(0)
+ {
+ DEBUG_PRINT("constructor");
+ boost::shared_ptr<tstCanTxMessage> pstCanMsg1(new tstCanTxMessage);
+ pstCanMsg1->u32CanId = m_u32TxMsgId+2;
+ pstCanMsg1->u8Dlc = 5;
+ pstCanMsg1->u32TxCycleMilliseconds = 500;
+ pstCanMsg1->u32MillisecondCounter = 0;
+ pstCanMsg1->au8Data = {0,0,0,0,0,0,0,0};
+ m_axCanTxMessages.push_back(pstCanMsg1);
+ boost::shared_ptr<tstCanTxMessage> pstCanMsg2(new tstCanTxMessage);
+ pstCanMsg2->u32CanId = m_u32TxMsgId+1;
+ pstCanMsg2->u8Dlc = 5;
+ pstCanMsg2->u32TxCycleMilliseconds = 1000;
+ pstCanMsg2->u32MillisecondCounter = 0;
+ pstCanMsg2->au8Data = {0,0,0,0,0,0,0,0};
+ m_axCanTxMessages.push_back(pstCanMsg2);
+ boost::shared_ptr<tstCanTxMessage> pstCanMsg3(new tstCanTxMessage);
+ pstCanMsg3->u32CanId = m_u32TxMsgId;
+ pstCanMsg3->u8Dlc = 5;
+ pstCanMsg3->u32TxCycleMilliseconds = 500;
+ pstCanMsg3->u32MillisecondCounter = 0;
+ pstCanMsg3->au8Data = {0,0,0,0,0,0,0,0};
+ m_axCanTxMessages.push_back(pstCanMsg3);
+ DEBUG_PRINT("Plg Id: %d msg 1: 0x%X", m_u32PluginId, (uint32_t) pstCanMsg1.get());
+ DEBUG_PRINT("Plg Id: %d msg 2: 0x%X", m_u32PluginId, (uint32_t) pstCanMsg2.get());
+ DEBUG_PRINT("Plg Id: %d msg 3: 0x%X", m_u32PluginId, (uint32_t) pstCanMsg3.get());
+ XorayaTestPlugin::su32InstanceCount++;
+ }
+
+ virtual ~XorayaTestPlugin()
+ {
+ DEBUG_PRINT("destructor");
+ XorayaTestPlugin::su32InstanceCount--;
+ }
+
+
+
+ virtual void vRun( void )
+ {
+// DEBUG_PRINT("entry");
+ m_u32Loopcounter++;
+ tCanTxMessageList::iterator xMsgIter;
+ for( xMsgIter = m_axCanTxMessages.begin(); xMsgIter != m_axCanTxMessages.end(); xMsgIter++ )
+ {
+ tpstCanTxMessage pxMsg = *xMsgIter;
+ pxMsg->au8Data[0] = m_u32PluginId;
+ if( xMsgIter == m_axCanTxMessages.begin() )
+ {
+ pxMsg->au8Data[4] = (uint8_t) (m_u32Loopcounter>>24);
+ pxMsg->au8Data[3] = (uint8_t) (m_u32Loopcounter>>16);
+ pxMsg->au8Data[2] = (uint8_t) (m_u32Loopcounter>>8);
+ pxMsg->au8Data[1] = (uint8_t) m_u32Loopcounter;
+ }
+ else
+ {
+ pxMsg->au8Data[1] = (uint8_t) (m_u32Loopcounter>>24);
+ pxMsg->au8Data[2] = (uint8_t) (m_u32Loopcounter>>16);
+ pxMsg->au8Data[3] = (uint8_t) (m_u32Loopcounter>>8);
+ pxMsg->au8Data[4] = (uint8_t) m_u32Loopcounter;
+ }
+ }
+// DEBUG_PRINT("exit");
+ }
+
+ virtual tCanTxMessageList& xGetCanTxMessages( void )
+ {
+ return m_axCanTxMessages;
+ }
+
+ virtual int32_t i32GetCanInterfaceHandle( void )
+ {
+ return m_i32InterfaceHandle;
+ }
+};
+
+uint32_t XorayaTestPlugin::su32InstanceCount = 0;
+
+extern "C" IPlugin* pxCreatePlugin(
+ IInterfaceManager& xIfMan,
+ int32_t i32Interface,
+ uint32_t u32PluginId
+ )
+{
+ DEBUG_PRINT("entry");
+ return new XorayaTestPlugin(xIfMan, i32Interface, u32PluginId);
+}
+
+extern "C" void vDestroyPlugin(IPlugin* pxPlugin)
+{
+ DEBUG_PRINT("entry");
+ delete pxPlugin;
+ DEBUG_PRINT("exit");
+}
|
