Skip to content

Commit

Permalink
Save point
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Jun 17, 2024
1 parent cea762d commit 82f76d0
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/v2i-hub/MUSTSensorDriverPlugin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
26 changes: 26 additions & 0 deletions src/v2i-hub/MUSTSensorDriverPlugin/manifest.json
Original file line number Diff line number Diff line change
@@ -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."
}
]
}
52 changes: 52 additions & 0 deletions src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDriverPlugin.cpp
Original file line number Diff line number Diff line change
@@ -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::MUSTSensorDriverPlugin>("MUSTSensorDriverPlugin", argc, argv);
}
56 changes: 56 additions & 0 deletions src/v2i-hub/MUSTSensorDriverPlugin/src/MUSTSensorDriverPlugin.h
Original file line number Diff line number Diff line change
@@ -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 <PluginClientClockAware.h>
#include <UdpServer.h>



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<tmx::utils::UdpServer> 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:

};

}
8 changes: 8 additions & 0 deletions src/v2i-hub/MUSTSensorDriverPlugin/test/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#include <gtest/gtest.h>

int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit 82f76d0

Please sign in to comment.