From e16048f8622c9d4423eac3949edf7968b8eda871 Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 1 Oct 2024 17:47:01 -0400 Subject: [PATCH] Updates --- .../ExamplePlugin/CMakeLists.txt | 19 ++++++++++++++++++- .../README.md | 0 .../ExamplePlugin/manifest.json | 7 ++++++- .../ExamplePlugin/src/ExamplePlugin.cpp | 12 ++++++------ src/v2i-hub/docs/Programming_Guide.md | 2 +- 5 files changed, 31 insertions(+), 9 deletions(-) rename examples/tmx-exampleapps/{SampleBSMPlugin => ExamplePlugin}/README.md (100%) diff --git a/examples/tmx-exampleapps/ExamplePlugin/CMakeLists.txt b/examples/tmx-exampleapps/ExamplePlugin/CMakeLists.txt index 7ec0ed6a9..c8de2a723 100644 --- a/examples/tmx-exampleapps/ExamplePlugin/CMakeLists.txt +++ b/examples/tmx-exampleapps/ExamplePlugin/CMakeLists.txt @@ -1,7 +1,24 @@ -PROJECT ( ExamplePlugin VERSION 3.0.0 LANGUAGES CXX ) +PROJECT ( ExamplePlugin VERSION 7.6.0 LANGUAGES CXX ) SET (TMX_PLUGIN_NAME "Example") BuildTmxPlugin ( ) TARGET_LINK_LIBRARIES (${PROJECT_NAME} tmxutils) +############# +## Testing ## +############# +enable_testing() +add_library(${PROJECT_NAME}_lib src/SampleData.cpp) +TARGET_LINK_LIBRARIES(${PROJECT_NAME}_lib PUBLIC tmxutils ) + +set(BINARY ${PROJECT_NAME}_test) +file(GLOB_RECURSE TEST_SOURCES LIST_DIRECTORIES false test/*.h test/*.cpp) +set(SOURCES ${TEST_SOURCES} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test) +add_executable(${BINARY} ${TEST_SOURCES}) +add_test(NAME ${BINARY} COMMAND ${BINARY}) +TARGET_INCLUDE_DIRECTORIES(${BINARY} PUBLIC src/) + +target_link_libraries(${BINARY} PUBLIC + ${PROJECT_NAME}_lib + gtest) \ No newline at end of file diff --git a/examples/tmx-exampleapps/SampleBSMPlugin/README.md b/examples/tmx-exampleapps/ExamplePlugin/README.md similarity index 100% rename from examples/tmx-exampleapps/SampleBSMPlugin/README.md rename to examples/tmx-exampleapps/ExamplePlugin/README.md diff --git a/examples/tmx-exampleapps/ExamplePlugin/manifest.json b/examples/tmx-exampleapps/ExamplePlugin/manifest.json index 48ed9ea4c..d711a2983 100644 --- a/examples/tmx-exampleapps/ExamplePlugin/manifest.json +++ b/examples/tmx-exampleapps/ExamplePlugin/manifest.json @@ -1,6 +1,6 @@ { "name":"@TMX_PLUGIN_NAME@", - "description":"An example plugin for the IVP system.", + "description":"An example plugin for the V2X Hub.", "version":"@PROJECT_VERSION@", "exeLocation":"/bin/@PROJECT_NAME@", "coreIpAddr":"127.0.0.1", @@ -13,6 +13,11 @@ } ], "configuration":[ + { + "key":"LogLevel", + "default":"INFO", + "description":"The log level for this plugin" + }, { "key":"Frequency", "default":"1000", diff --git a/examples/tmx-exampleapps/ExamplePlugin/src/ExamplePlugin.cpp b/examples/tmx-exampleapps/ExamplePlugin/src/ExamplePlugin.cpp index 58150db9b..f1e0aa9bb 100644 --- a/examples/tmx-exampleapps/ExamplePlugin/src/ExamplePlugin.cpp +++ b/examples/tmx-exampleapps/ExamplePlugin/src/ExamplePlugin.cpp @@ -6,7 +6,7 @@ // Description : Example Plugin //========================================================================== -#include "PluginClient.h" +#include "PluginClientClockAware.h" #include "PluginDataMonitor.h" #include @@ -25,7 +25,7 @@ namespace ExamplePlugin /** * This plugin is an example to demonstrate the capabilities of a TMX plugin. */ -class ExamplePlugin: public PluginClient +class ExamplePlugin: public PluginClientClockAware { public: ExamplePlugin(std::string); @@ -51,7 +51,7 @@ class ExamplePlugin: public PluginClient * * @param name The name to give the plugin for identification purposes. */ -ExamplePlugin::ExamplePlugin(string name): PluginClient(name) +ExamplePlugin::ExamplePlugin(string name): PluginClientClockAware(name) { // The log level can be changed from the default here. FILELog::ReportingLevel() = FILELog::FromString("DEBUG"); @@ -115,7 +115,7 @@ void ExamplePlugin::HandleMapDataMessage(MapDataMessage &msg, routeable_message void ExamplePlugin::HandleDecodedBsmMessage(DecodedBsmMessage &msg, routeable_message &routeableMsg) { - //PLOG(logDEBUG) << "Received Decoded BSM: " << msg; + PLOG(logDEBUG) << "Received Decoded BSM: " << msg; // Determine if location, speed, and heading are valid. bool isValid = msg.get_IsLocationValid() && msg.get_IsSpeedValid() && msg.get_IsHeadingValid(); @@ -148,9 +148,9 @@ int ExamplePlugin::Main() uint msCount = 0; while (_plugin->state != IvpPluginState_error) { - PLOG(logDEBUG4) << "Sleeping 1 ms" << endl; + PLOG(logDEBUG4) << "Sleeping 10 ms" << endl; - this_thread::sleep_for(chrono::milliseconds(10)); + PluginClientClockAware::getClock()->sleep_for(10); msCount += 10; diff --git a/src/v2i-hub/docs/Programming_Guide.md b/src/v2i-hub/docs/Programming_Guide.md index 2c21a9496..fe293e55f 100644 --- a/src/v2i-hub/docs/Programming_Guide.md +++ b/src/v2i-hub/docs/Programming_Guide.md @@ -18,7 +18,7 @@ Additional information on the V2X Hub can be found in the following documents. I ## Example Plugin -The Example Plugin showcases the basic functionality needed by a V2X Hub plugin. The plugin has simple API calls to create, route, and decode messages from the V2X Hub Core. Examples for setting status values, retrieving configuration values and writing logs are also in the example. The Example Plugin is a good foundation to modify when creating our own plugin for the V2X Hub. See [SampleBSMPlugin](../../../examples/tmx-exampleapps/SampleBSMPlugin/) for example plugin +The Example Plugin showcases the basic functionality needed by a V2X Hub plugin. The plugin has simple API calls to create, route, and decode messages from the V2X Hub Core. Examples for setting status values, retrieving configuration values and writing logs are also in the example. The Example Plugin is a good foundation to modify when creating our own plugin for the V2X Hub. See [ExamplePlugin](../../../examples/tmx-exampleapps/ExamplePlugin/) for example plugin > [!NOTE] > We are currently working to migrate,update and consolidate the SampleBSMPlugin and ExamplePlugin. Both are located under `/examples/tmx-exampleapps` under project root, but this document and the example plugins may currently contain inaccurate/outdated information.