Skip to content

Commit a17987b

Browse files
committed
Thread names reworked
1 parent 2dba071 commit a17987b

File tree

1 file changed

+55
-68
lines changed

1 file changed

+55
-68
lines changed

documentation/theory.md

Lines changed: 55 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,57 @@ The core of the SDS-Framework is a circular buffer handling (`sds.c/h`) that is
1919

2020
## Usage
2121

22-
The following diagram shows the usage of the SDS Recorder and Player functions. Management is a separate thread that controls the overall execution. Algorithm is a thread that executes Signal Conditioning (SC) and ML Model.
22+
The following diagram shows the usage of the SDS Recorder and Player functions (executed in `sdsRecPlayThread`). The `sdsControlThread` controls the overall execution. `AlgorithmThread` is the thread that executes Signal Conditioning (SC) and ML Model.
2323

2424
```mermaid
2525
sequenceDiagram
26-
participant Management
27-
participant SDS Player
28-
participant SDS Recorder
29-
participant Algorithm
30-
Management->>SDS Player: sdsPlayOpen `SCinput`
31-
Management->>SDS Recorder: sdsRecOpen `SCoutput`
32-
Management->>SDS Recorder: sdsRecOpen `MLoutput`
33-
Management->>Algorithm: Activate Algorithm
34-
Activate Algorithm
26+
participant sdsControlThread
27+
participant sdsRecPlayThread
28+
participant AlgorithmThread
29+
sdsControlThread->>sdsRecPlayThread: sdsPlayOpen `SCinput`
30+
sdsControlThread->>sdsRecPlayThread: sdsRecOpen `SCoutput`
31+
sdsControlThread->>sdsRecPlayThread: sdsRecOpen `MLoutput`
32+
sdsControlThread->>AlgorithmThread: Activate Algorithm
33+
Activate AlgorithmThread
3534
loop periodic
36-
SDS Player->>Algorithm: sdsPlayReads `SCinput` (with timestamp)
37-
Note over Algorithm: Execute Signal Conditioning
38-
Algorithm->>SDS Recorder: sdsRecWrite `SCoutput`
39-
Note over Algorithm: Execute ML Model
40-
Algorithm->>SDS Recorder: sdsRecWrite `MLoutput`
35+
sdsRecPlayThread->>AlgorithmThread: sdsPlayRead `SCinput` (with Timestamp)
36+
Note over AlgorithmThread: Execute Signal Conditioning
37+
AlgorithmThread->>sdsRecPlayThread: sdsRecWrite `SCoutput`
38+
Note over AlgorithmThread: Execute ML Model
39+
AlgorithmThread->>sdsRecPlayThread: sdsRecWrite `MLoutput`
4140
end
42-
Management->>Algorithm: Deactivate Algorithm
43-
Deactivate Algorithm
44-
Management->>SDS Player: sdsPlayClose `SCinput`
45-
Management->>SDS Recorder: sdsRecClose `SCoutput`
46-
Management->>SDS Recorder: sdsRecClose `MCoutput`
41+
sdsControlThread->>AlgorithmThread: Deactivate Algorithm
42+
Deactivate AlgorithmThread
43+
sdsControlThread->>sdsRecPlayThread: sdsPlayClose `SCinput`
44+
sdsControlThread->>sdsRecPlayThread: sdsRecClose `SCoutput`
45+
sdsControlThread->>sdsRecPlayThread: sdsRecClose `MCoutput`
4746
```
4847

48+
## SDS Data Files
49+
4950
Each data stream is stored in a separate SDS data file. In the diagram below `SCinput.0.sds` is the input to Signal Conditioning, `SCoutput.0.sds` is the output of Signal Conditioning, and `MLoutput.0.sds` is the output of the ML Model. Each execution of the algorithm is represented in a data block with a `timestamp`. The `timestamp` allows to correlate the blocks of different streams. In the above example, all blocks of one algorithm execution have the same timestamp value.
5051

5152
![SDS Files](images/SDS-Files.png)
5253

53-
ToDo When does sdsRecInit require an event handler?
54+
### Timestamp
5455

55-
**Example:** Recording of an accelerometer data stream
56+
The timestamp is a 32-bit unsigned value and is used for:
5657

57-
The following code snippets show the usage of the **Recorder Interface**.
58+
- Alignment of different data streams that have the same timestamp value.
59+
- Order of the SDS data files captured during execution.
60+
- Combining multiple SDS file records with the same timestamp value.
61+
62+
The same timestamp connects different SDS file records. It is therefore useful to
63+
use the same timestamp for the recording of one iteration of a DSP or ML algorithm.
64+
In most cases the granularity of an RTOS tick (typically 1ms) is a good choice for a timestamp value.
65+
66+
### SDS Data File Format
67+
68+
The SDS data file format is described [here](https://github.com/ARM-software/SDS-Framework/tree/main/schema). Each call to `sdsRecWrite` writes one data block.
69+
70+
## Code Example
71+
72+
The following code snippets show the usage of the **Recorder Interface**. In this case an accelerometer data stream is recorded.
5873

5974
```c
6075
// *** variable definitions ***
@@ -65,7 +80,7 @@ struct { // sensor data stream format
6580
} accelerometer [30]; // number of samples in one data stream record
6681

6782
sdsRecId_t *accel_id, // data stream id
68-
uint8_t accel_buf[1000]; // data stream buffer for circular buffer handling
83+
uint8_t accel_buf[(sizeof(accel_buf)*2)+0x800]; // data stream buffer for circular buffer handling
6984
:
7085
// *** function calls ***
7186
sdsRecInit(NULL); // init SDS Recorder
@@ -91,38 +106,7 @@ The size of the data stream buffer depends on several factors such as:
91106
- the size of the data stream as it is recommended that the buffer is at least three the size of a single data stream.
92107
- the frequency of the algorithm execution. Fast execution speeds may require a larger buffer.
93108
94-
A a guideline, the buffer size should be 3 times the **block size**. As a minimum 0x1000 (4 KB) is recommended.
95-
96-
ToDo: Threshold should be optional
97-
98-
**Recommended Buffer Size:**
99-
100-
The table below contains recommended buffer sizes depending on the communication technology used:
101-
102-
ToDo
103-
104-
Communication | Buffer Size | Description
105-
:--------------|:------------|:----------------
106-
Network | 4096 | Default size of Ethernet record is xxxx bytes
107-
USB Device | xxx | .
108-
FileSystem | xxx | .
109-
110-
## Timestamp
111-
112-
The timestamp is a 32-bit unsigned value and is used for:
113-
114-
- Alignment of different data streams that have the same timestamp value.
115-
- Order of the SDS data files captured during execution.
116-
- Combining multiple SDS file records with the same timestamp value.
117-
118-
The same timestamp connects different SDS file records. It is therefore useful to
119-
use the same timestamp for the recording of one iteration of a DSP or ML algorithm.
120-
In most cases the granularity of an RTOS tick (typically 1ms) is a good choice for a timestamp value.
121-
122-
## SDS File Format
123-
124-
The SDS file format is described [here](https://github.com/ARM-software/SDS-Framework/tree/main/schema). Each call to
125-
`sdsRecWrite` writes one data block.
109+
A a guideline, the buffer size should be 2 times the **block size** + 2KB. As a minimum 0x1000 (4 KB) is recommended.
126110
127111
## SDSIO Server Protocol
128112
@@ -238,24 +222,26 @@ ToDo: I don't understand why this command is needed as **SDSIO_CMD_READ** return
238222
This is the message sequence of the SDS DataTest example when connected to MDK-Middleware Ethernet.
239223
It contains the following threads that executes on the target.
240224

241-
- Management: Overall execution management
225+
- Control: Overall execution Control
242226
- Algorithm: Algorithm under test
243227
- Recorder: SDS Recorder thread (sdsRecThread)
244228
- Playback: SDS Playback thread (sdsPlayThread)
245229

246230
The Server is the SDSIO Server executing on the target system.
247231

232+
ToDo rework this diagram
233+
248234
```mermaid
249235
sequenceDiagram
250-
participant Management
236+
participant Control
251237
participant Algorithm
252238
create participant Recorder as SDS Recorder
253239
participant Server as SDSIO Server
254-
Management->>Recorder: sdsRecInit
255-
Note over Management: sdsRecOpen
256-
Management->>Server: SDSIO_CMD_OPEN
240+
Control->>Recorder: sdsRecInit
241+
Note over Control: sdsRecOpen
242+
Control->>Server: SDSIO_CMD_OPEN
257243
activate Server
258-
Server-->>Management: Response
244+
Server-->>Control: Response
259245
activate Algorithm
260246
loop periodic
261247
Note over Algorithm: sdsRecWrite
@@ -265,13 +251,13 @@ sequenceDiagram
265251
end
266252
end
267253
deactivate Algorithm
268-
Note over Management: sdsRecClose
269-
Management->>Recorder: Close Trigger
254+
Note over Control: sdsRecClose
255+
Control->>Recorder: Close Trigger
270256
loop send all data
271257
Recorder->>Server: SDSIO_CMD_WRITE
272258
end
273-
Recorder->>Management: Close Confirm
274-
Management->>Server: SDSIO_CMD_CLOSE
259+
Recorder->>Control: Close Confirm
260+
Control->>Server: SDSIO_CMD_CLOSE
275261
deactivate Server
276262
```
277263

@@ -293,8 +279,9 @@ but sds_rec.c does not really use this information
293279

294280
- Threshold event is only set when complete write was possible, is this correct? https://github.com/ARM-software/SDS-Framework/blob/main/sds/source/sds_rec.c#L298
295281

296-
https://github.com/Arm-Examples/SDS-Examples/blob/main/Hardware/DataTest/rec_management.c
297-
- do we really need `recdone`?
282+
-----
283+
284+
ToDo review this section
298285

299286
## Guidelines for Stream Buffer sizing and Threshold settings
300287

0 commit comments

Comments
 (0)