ngcp-project / progress-board-tracker

Empty repository only meant for tracking cards inside project boards in NGCP
0 stars 0 forks source link

feat(rabbitmq): Commands subscriber for vehicle-side library #37

Open marked01one opened 1 year ago

marked01one commented 1 year ago

Issue Goal

The main goal is to create a class within the vehicle-side library that can be used to listen for RabbitMQ command messages from a publisher called from GCS.

How It Should Work

On vehicle-side, the code for listening for commands would probably look something like this:

# `integration` is the supposed name of the library
from integration.Commands import CommandsRabbitMQ
from integration.Types import CommandsEnum

def callback(channel, method, properties, body):
    # Insert callback code here
    pass

# Initializing a telemetry object should initiate a connection towards the RabbitMQ broker server
# We use ERU as an example here, but this should work with any vehicle.
commands = CommandsRabbitMQ(vehicleName="ERU")

# A method that allow for the vehicle to subscribe to one queue that deals with all commands
commands.subscribe_all(callback_function=callback)
# A method that can be used to subscribe to specific functions only
# In this example I have manual mode toggle but there should be one for each command.
commands.subscribe(topic=CommandsEnum.MANUAL_MODE, callback_function=callback)

Also a quick reminder of how the Vehicle-to-GCS integration model looks like. Image

marked01one commented 1 year ago

Please lemme know if any of this is confusing. We can set up some sort of coding session to answer any blockers or questions!