diff --git a/src/v2i-hub/MUSTSensorDriverPlugin/CMakeLists.txt b/src/v2i-hub/MUSTSensorDriverPlugin/CMakeLists.txt new file mode 100755 index 000000000..717ec6b71 --- /dev/null +++ b/src/v2i-hub/MUSTSensorDriverPlugin/CMakeLists.txt @@ -0,0 +1,26 @@ +PROJECT(MUSTSensorDriverPlugin VERSION 7.6.0 LANGUAGES CXX) + +set(TMX_PLUGIN_NAME "Must Sensor Driver Plugin") + + +BuildTmxPlugin() + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC tmxutils ) + +############# +## Testing ## +############# +enable_testing() +# add_library(${PROJECT_NAME}_lib ) +# 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_link_libraries(${BINARY} PUBLIC + # ${PROJECT_NAME}_lib + gtest) \ No newline at end of file diff --git a/src/v2i-hub/MUSTSensorDriverPlugin/manifest.json b/src/v2i-hub/MUSTSensorDriverPlugin/manifest.json new file mode 100755 index 000000000..c96601e69 --- /dev/null +++ b/src/v2i-hub/MUSTSensorDriverPlugin/manifest.json @@ -0,0 +1,26 @@ +{ + "name": "RSUHealthMonitor", + "description": "Monitor RSU health status", + "version": "@PROJECT_VERSION@", + "exeLocation": "/bin/RSUHealthMonitorPlugin", + "coreIpAddr":"127.0.0.1", + "corePort":24601, + "messageTypes": [], + "configuration": [ + { + "key": "LogLevel", + "default": "INFO", + "description": "The log level for this plugin" + }, + { + "key":"Interval", + "default":"1", + "description": "Sending RSU SNMP GET request at every configured interval. Default every 1 second. Unit of measure: second." + }, + { + "key":"RSUConfigurationList", + "default":"{ \"RSUS\": [ { \"RSUIp\": \"192.168.XX.XX\", \"SecurityLevel\":\"authPriv\", \"SNMPPort\": \"161\", \"AuthPassPhrase\": \"dummy\", \"User\": \"authOnlyUser\", \"RSUMIBVersion\": \"RSU4.1\" },{ \"RSUIp\": \"192.168.00.XX\", \"SecurityLevel\":\"authPriv\", \"SNMPPort\": \"162\", \"AuthPassPhrase\": \"tester\", \"User\": \"authPrivUser\", \"RSUMIBVersion\": \"RSU4.1\" }] }", + "description":"Configurations of the RSUs the V2X hub is connected to." + } + ] +} \ No newline at end of file diff --git a/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDriverPlugin.cpp b/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDriverPlugin.cpp new file mode 100644 index 000000000..bdf84dd7d --- /dev/null +++ b/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDriverPlugin.cpp @@ -0,0 +1,52 @@ +/** + * Copyright (C) 2024 LEIDOS. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +#include "MUSTSensorDriverPlugin.h" + +using namespace tmx::utils; +using namespace std; + +namespace MUSTSensorDriverPlugin { + + MUSTSensorDriverPlugin::MUSTSensorDriverPlugin(const string &name): PluginClientClockAware(name) + { + + // Subscribe to all messages specified by the filters above. + SubscribeToMessages(); + } + + + + void MUSTSensorDriverPlugin::UpdateConfigSettings() + { + // Configuration settings are retrieved from the API using the GetConfigValue template class. + // This method does NOT execute in the main thread, so variables must be protected + // (e.g. using std::atomic, std::mutex, etc.). + } + + + void MUSTSensorDriverPlugin::OnConfigChanged(const char *key, const char *value) + { + PluginClientClockAware::OnConfigChanged(key, value); + UpdateConfigSettings(); + } + + +} /* namespace MUSTSensorDriver */ + +int main(int argc, char *argv[]) +{ + return run_plugin("MUSTSensorDriverPlugin", argc, argv); +} diff --git a/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDriverPlugin.h b/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDriverPlugin.h new file mode 100644 index 000000000..9e8531a53 --- /dev/null +++ b/src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDriverPlugin.h @@ -0,0 +1,56 @@ +/** + * Copyright (C) 2019 LEIDOS. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +#pragma once + +#include +#include + + + +namespace MUSTSensorDriverPlugin +{ + /** + * @brief TODO Plugin description + */ + class MUSTSensorDriverPlugin : public tmx::utils::PluginClientClockAware + { + private: + std::mutex _configMutex; + /** + * @brief Status label simulation time to be displayed by each plugin. + */ + const char* keySensorConnectionStatus = "Sensor Connection Status"; + + std::unique_ptr mustSensorPacketReceiver; + /** + * @brief Callback triggered on configuration updates + */ + void UpdateConfigSettings(); + void OnConfigChanged(const char *key, const char *value) override; + void initializeMustSensorPacketReceiver(); + + + public: + /** + * @brief Constructor + * @param name Plugin Name + */ + explicit MUSTSensorDriverPlugin(const std::string &name); + protected: + + }; + +} \ No newline at end of file diff --git a/src/v2i-hub/MUSTSensorDriverPlugin/test/main.cpp b/src/v2i-hub/MUSTSensorDriverPlugin/test/main.cpp new file mode 100644 index 000000000..ba7cd2667 --- /dev/null +++ b/src/v2i-hub/MUSTSensorDriverPlugin/test/main.cpp @@ -0,0 +1,8 @@ + +#include + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}