Skip to content

Commit b69305d

Browse files
Merge branch 'pyleco-additions' into pyleco-state
2 parents 12d4589 + 2840252 commit b69305d

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

control_protocol.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The transport layer ensures that a message arrives at its destination.
1616

1717
Each {ref}`Coordinator <components.md#coordinator>` shall offer one {ref}`ROUTER <appendix.md#router-sockets>` socket, bound to an address.
1818
The address consists of a host (this can be the host name, an IP address of the device, or "\*" for all IP addresses of the device) and a port number, for example `*:12345` for all IP addresses at the port `12345`.
19+
The default port number is 12300.
1920

2021
{ref}`Components <components.md#components>` shall have one DEALER socket connecting to one Coordinator's ROUTER socket.
2122

@@ -58,6 +59,9 @@ A message consists of 4 or more frames.
5859
2. The receiver Full name or Component name, as appropriate.
5960
3. The sender Full name.
6061
4. A content header (abbreviated with "H" in examples).
62+
1. UUIDv7 as a `conversation id`
63+
2. A three byte `message id`
64+
3. A one byte `message type`. A value of `0` means "not defined", a value of `1` means JSON encoded.
6165
5. Message content: The optional payload, which can be 0 or more frames.
6266

6367

@@ -304,11 +308,14 @@ sequenceDiagram
304308
Note that the DEALER socket responds with the local Directory and Coordinator addresses to the received Acknowledgment.
305309
:::
306310

311+
If a not signed in Coordinator tries to sign out from a second one, the latter one does ignore that message.
312+
If a Coordinator tries to sign out, but the message arrives via a different identity, the sign-out is rejected.
307313

308314
##### Coordinator updates
309315

310316
Each Coordinator shall keep an up-to-date global {ref}`control_protocol.md#directory` with the Full names of all Components in the Network.
311317
For this, whenever a Component signs in to or out from its Coordinator, the Coordinator shall notify all the other Coordinators regarding this event.
318+
For that, the Coordinators sends the other ones the full directory, i.e. all Components and Coordinators connected to the Coordinator.
312319
The other Coordinators shall update their global Directory according to this message (add or remove an entry).
313320

314321
:::{note}

data_protocol.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Data protocol
2+
3+
The data protocol transmits messages from `publishers` to `subscribers` via a `proxy server` in a broadcasting fashion.
4+
5+
## Transport layer
6+
7+
The transport layer ensures that a message arrives at its destination.
8+
9+
### Socket configuration
10+
11+
A `proxy server` is the transmitting station, it shall offer an XSUBSCRIBER and an XPUBLISHER socket.
12+
The two sockets shall be connected, e.g. via the `zmq.proxy_server` method.
13+
Each of both sockets shall be bound to its own address.
14+
15+
A `Publisher` is a Component, which sends data messages via the data protocol.
16+
It shall have a PUBLISHER socket connecting to the proxy server's XSUBSCRIBER socket.
17+
18+
A `Subscriber` is a Component, which wants to reveice data messages via the data protocol.
19+
It shall have a SUBSCRIBER socket connecting to the proxy server's XPUBLISHER socket.
20+
It should subscribe to the {ref}`Topics <data_protocol.md#topic>` it wants to receive.
21+
22+
:::{note}
23+
Subscribing to a topic in zmq means to subscribe to all topics which **start** with the given topic name!
24+
:::
25+
26+
#### Recommended configuration
27+
28+
It is recommended to have a single program with two proxy servers.
29+
The first one transfers any data and binds its XSUBSCRIBER to port number 11100 and binds its XPUBLISHER to 11099.
30+
The second one transfers log entries and binds to 11098 and 11097, respectively.
31+
32+
33+
## Message format
34+
35+
A Data Protocol Message consists in three or more frames ([#62](https://github.com/pymeasure/leco-protocol/issues/62)):
36+
1. {ref}`data_protocol.md#topic`
37+
2. {ref}`data_protocol.md#header`
38+
3. One or more data frames, the first one is the {ref}`data_protocol.md#content`
39+
40+
### Topic
41+
42+
The topic is the full name of the sending Component. ([#60](https://github.com/pymeasure/leco-protocol/issues/60))
43+
44+
### Header
45+
46+
Similar to the {ref}`control protocol header<control_protocol.md#message_composition>`, the header consists in
47+
1. UUIDv7
48+
2. a one byte `message_type` (`0` not defined, `1` JSON, `>127` user defined)
49+
50+
### Content
51+
52+
#### Log message content
53+
54+
For log messages, the content is a JSON encoded list of:
55+
- `record.asctime`: Timestamp formatted as `'%Y-%m-%d %H:%M:%S'`
56+
- `record.levelname`: Logger level name
57+
- `record.name`: Logger name
58+
- `record.text` (including traceback)

index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
messages
1717
network-structure
1818
control_protocol
19+
data_protocol
1920
glossary
2021
Hello_world
2122
appendix

0 commit comments

Comments
 (0)