In my UML model I have a system and its subcomponents that talk to each other. For Example, I have a computer and a RC robot where they talk via Bluetooth. Currently in the diagrams the flow is something like:
"Computer" triggers "setVelocity()" function of "RC car".
At this point, I want to refine the communication by saying that
How do I do that?
EDIT : Clarification
Normally this is what my diagram looks like without protocol details:
But when I tried to add messages, there are at least 2 problems:
Thanks for the responses. You are gold!
There are two main ways of doing it. A first way is to have a movement()
operation, with parameters for the velocity and direction. The ACK would be realized by the return message. You can just label it ACK. You would typically show the exchange in a sequence diagram. Sequence diagrams even allow to represent delay in reception.
Another approach is to use signals. Signals correspond to event messages. In a class diagram, they are represented like a class but with the «signal»
keyword, and velocity and direction would be attributes of that signal. ACK
would be another signal. The classes that are able to receive the signals show it as reception (looks like an operation, but again with «signal» keyword).
In both cases, you would show the interactions of your communication protocol with an almost identical sequence diagram. But signals are meant for asynchronous communication and better reflect imho the nature of the communication.
Return messages can only be shown in sequence diagrams (no equivalent notation in a communication diagram ). The signal approach doesn't rely on return messages and can show the full protocol either in a sequence or communication diagram. The numbering would be in front of the message name.
Not related, but you may be interested in making protocol state machines, to represent the state of each communication party, based on the reception of signals and/or timing.
If you really want to display this level of detail in a sequence diagram, it would look like this:
Notes:
But be careful about which level of detail you want to show. Often, a sequence diagram becomes too complex if you display every operation in the call stack.
I was dealing with the same issue. I searched online and couldn't find something that I like. Hence I come up with this solution. I show the communication ports on the sequence diagram and I draw communication dependent steps among port lines. Here is a screenshot: my version of your problem.
Note: I haven't used bluetooth before so I am not sure about the acknowledge step. If this is something done automatically by the hardware( Like in the CAN Bus) I wouldn't draw it like this. I probabily wouldn't show it or I wouldn't add the function acknowledge(); and just draw the line between bluetooth port life lines.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.