Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Jul 29, 2024
1 parent ad9383c commit db47284
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 15 deletions.
4 changes: 3 additions & 1 deletion src/v2i-hub/SpatPlugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ This plugin has several configuration parameters. Below these are listed out as

**TSC_IP**: The IPv4 address of the destination Traffic Signal Controller (TSC).

**TSC_Remote_SNMP_Port**: The destination port on the Traffic Signal Controller (TSC) for SNMP NTCIP 1202 communication."
**TSC_SNMP_Port**: The destination port on the Traffic Signal Controller (TSC) for SNMP NTCIP 1202 communication."

**TSC_SNMP_Community**: The SNMP Community used for sending SNMP NTCIP 1202 communication to Traffic Signal Controller (TSC). Please refer TSC vendor documentation for SNMP Community.

**SPAT_Mode**: The format of received SPAT from Traffic Signal Controller (TSC). Acceptance values are BINARY and J2735_HEX.
> [!NOTE]
Expand Down
17 changes: 11 additions & 6 deletions src/v2i-hub/SpatPlugin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,28 @@
},
{
"key":"Local_IP",
"default":"<local ip address>",
"default":"127.0.0.1",
"description":"The IPv4 address of the local computer for receiving Traffic Signal Controller Broadcast Messages."
},
{
"key":"Local_UDP_Port",
"default":"local port",
"default":"6053",
"description":"The local UDP port for reception of Traffic Signal Controller Broadcast Messages from the TSC."
},
{
"key":"TSC_IP",
"default":"<ip address of signal controller>",
"default":"127.0.0.1",
"description":"The IPv4 address of the destination Traffic Signal Controller (TSC)."
},
{
"key":"TSC_Remote_SNMP_Port",
"default":"<snmp port used in signal controller>",
"description":"The destination port on the Traffic Signal Controller (TSC) for SNMP NTCIP communication."
"key":"TSC_SNMP_Port",
"default":"5050",
"description":"The destination port on the Traffic Signal Controller (TSC) for SNMP NTCIP 1202 communication."
},
{
"key":"TSC_SNMP_Community",
"default":"public",
"description":"The SNMP Community used for sending SNMP NTCIP 1202 communication to Traffic Signal Controller (TSC). Please refer TSC vendor documentation for SNMP Community."
},
{
"key":"SPAT_Mode",
Expand Down
1 change: 0 additions & 1 deletion src/v2i-hub/SpatPlugin/src/NTCIP1202.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/algorithm/string.hpp>
#include "carma-clock/carma_clock.h"

using namespace std;

Expand Down
6 changes: 4 additions & 2 deletions src/v2i-hub/SpatPlugin/src/SignalControllerConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@

namespace SpatPlugin {

SignalControllerConnection::SignalControllerConnection(const std::string &localIp, unsigned int localPort, const std::string &signalGroupMapping, const std::string &scIp, unsigned int scSNMPPort, const std::string &intersectionName, unsigned int intersectionId) : spatPacketReceiver(std::make_shared<tmx::utils::UdpServer>(localIp, localPort)) ,scSNMPClient(std::make_shared<tmx::utils::snmp_client>(scIp, scSNMPPort ,"administrator", "", "", "")), signalGroupMapping(signalGroupMapping), intersectionName(intersectionName), intersectionId(intersectionId) {
SignalControllerConnection::SignalControllerConnection(const std::string &localIp, unsigned int localPort, const std::string &signalGroupMapping, const std::string &scIp, unsigned int scSNMPPort, const std::string &scSNMPCommunity, const std::string &intersectionName, unsigned int intersectionId) : spatPacketReceiver(std::make_shared<tmx::utils::UdpServer>(localIp, localPort)) ,scSNMPClient(std::make_shared<tmx::utils::snmp_client>(scIp, scSNMPPort ,scSNMPCommunity, "", "", "")), signalGroupMapping(signalGroupMapping), intersectionName(intersectionName), intersectionId(intersectionId) {

};
bool SignalControllerConnection::initializeSignalControllerConnection(bool enable_spat, bool set_intersection_id) const {
// TODO : Update to more generic TSC Initialization process that simply follows NTCIP 1202 version guidelines.
bool status = true;
if (enable_spat)
{
{
// For binary SPAT a value of 2 enables original SPAT binary broadcast on the TSC and a value of 6 enables original SPAT plugin additional Pedestrian Information.
// NOTE: Pedestrian information is untested.
tmx::utils::snmp_response_obj enable_spat;
enable_spat.val_int = 2;
enable_spat.type = tmx::utils::snmp_response_obj::response_type::INTEGER;
Expand Down
2 changes: 1 addition & 1 deletion src/v2i-hub/SpatPlugin/src/SignalControllerConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace SpatPlugin {
* @param intersectionName Name of intersection
* @param intersectionID Intersection ID.
*/
SignalControllerConnection(const std::string &localIp, unsigned int localPort, const std::string &signalGroupMapping, const std::string &scIp, unsigned int scSNMPPort, const std::string &intersectionName, unsigned int intersectionID);
SignalControllerConnection(const std::string &localIp, unsigned int localPort, const std::string &signalGroupMapping, const std::string &scIp, unsigned int scSNMPPort, const std::string &scSNMPCommunity, const std::string &intersectionName, unsigned int intersectionID);

/**
* @brief Method attempts to send SNMP SET requests to initialize the TSC. NOTE: Some of the
Expand Down
9 changes: 6 additions & 3 deletions src/v2i-hub/SpatPlugin/src/SpatPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,25 @@ namespace SpatPlugin {
unsigned int port;
std::string signal_controller_ip;
unsigned int signal_controller_snmp_port;
std::string signal_controller_snmp_community;
std::string intersection_name;
unsigned int intersection_id;
GetConfigValue<std::string>("SignalGroupMapping", signal_group_mapping_json, &data_lock);
GetConfigValue<std::string>("Local_IP", ip_address, &data_lock);
GetConfigValue<unsigned int>("Local_UDP_Port", port, &data_lock);
GetConfigValue<std::string>("TSC_IP", signal_controller_ip, &data_lock);
GetConfigValue<unsigned int>("TSC_Remote_SNMP_Port", signal_controller_snmp_port,&data_lock);
GetConfigValue<unsigned int>("TSC_SNMP_Port", signal_controller_snmp_port,&data_lock);
GetConfigValue<std::string>("TSC_SNMP_Community", signal_controller_snmp_community,&data_lock);

GetConfigValue<std::string>("Intersection_Name", intersection_name,&data_lock);
GetConfigValue<unsigned int>("Intersection_Id", intersection_id, &data_lock);
GetConfigValue<std::string>("SPAT_Mode", spatMode, &data_lock);

if (scConnection) {
scConnection.reset(new SignalControllerConnection(ip_address, port, signal_group_mapping_json, signal_controller_ip, signal_controller_snmp_port, intersection_name, intersection_id));
scConnection.reset(new SignalControllerConnection(ip_address, port, signal_group_mapping_json, signal_controller_ip, signal_controller_snmp_port, signal_controller_snmp_community ,intersection_name, intersection_id));
}
else {
scConnection = std::make_unique<SignalControllerConnection>(ip_address, port, signal_group_mapping_json, signal_controller_ip, signal_controller_snmp_port, intersection_name, intersection_id);
scConnection = std::make_unique<SignalControllerConnection>(ip_address, port, signal_group_mapping_json, signal_controller_ip, signal_controller_snmp_port,signal_controller_snmp_community, intersection_name, intersection_id);
}
// Only enable spat broadcast in simulation mode. TFHRC TSCs do not expose this OID so calls to it will fail in hardware deployment
// Only set intersection ID in J2735_HEX SPAT Mode. Is only available for TSCs that support J2735 UPER HEX SPaT broadcast, which are all NTCIP 1202V3 or later.
Expand Down
1 change: 1 addition & 0 deletions src/v2i-hub/SpatPlugin/test/TestNTCIP1202.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <gtest/gtest.h>
#include <tmx/j2735_messages/SpatMessage.hpp>
#include <NTCIP1202.h>
#include <carma-clock/carma_clock.h>

using namespace fwha_stol::lib::time;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace SpatPlugin {
]
}
)";
signalControllerConnection = std::make_unique<SignalControllerConnection>("127.0.0.1", 5000, signalGroupMapping, "", 5020, "someIntersection", 9001);
signalControllerConnection = std::make_unique<SignalControllerConnection>("127.0.0.1", 5000, signalGroupMapping, "", 5020,"administrator", "someIntersection", 9001);
mockSnmpClient = std::make_shared<unit_test::mock_snmp_client>("127.0.0.1", 6045, "administrator", "", "", "");
mockUdpServer = std::make_shared<tmx::utils::MockUpdServer>();
signalControllerConnection->scSNMPClient = mockSnmpClient;
Expand Down

0 comments on commit db47284

Please sign in to comment.