Building a new component, when to use commands and when to use ports? #1818
-
Hi All! Very new to using fprime, been following the tutorials and trying to make my own basic component. One thing I'm not clear on when designing a component is when to use a port vs a command for exchanging data between modules. For example, in the system reference for a Camera: There is a port for allocating and deallocating memory, but a command is used to take a photo. Why not add a port called TakeAction that uses CameraAction as the type, or make a command have a command to allocate or deallocate memory? I understand commands are a type of port, I'm just not clear on why you may choose to implement a specific interaction using ports or commands. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Commands typically come from the ground or from a set sequence to run. e.g. "ground commands that the system take a picture". Ports are designed to communicate between components within the system. e.g "I need to allocate memory now". When a component knows when to take an action, we add a port to allow that action. When the ground or a running sequence knows when to take an action, then we use a command. Some projects have commands and ports both do the same thing by delegate to a helper function such that components and the ground can both engage the given action. Does this help? |
Beta Was this translation helpful? Give feedback.
Commands typically come from the ground or from a set sequence to run. e.g. "ground commands that the system take a picture". Ports are designed to communicate between components within the system. e.g "I need to allocate memory now". When a component knows when to take an action, we add a port to allow that action. When the ground or a running sequence knows when to take an action, then we use a command.
Some projects have commands and ports both do the same thing by delegate to a helper function such that components and the ground can both engage the given action.
Does this help?