提交 ea1489cc 编写于 作者: Y Your Name

update documents

上级 e0a46336
......@@ -35,7 +35,22 @@ Many of the classic programming language cookbooks are started from the console
Most modern languages support the creation of child processes, and can take over child processes' standard pipelines through "pipeline redirection" technology. Taskbus technology, which is based on this feature, reads data from the stdout of each child process and forwards it to the required subprocess (stdin).
### 3.1 Input and Output
Taskbus support 2 major module develop methods.
- Quick-mod : simply take advantage of Stdin and Stdout·
- Program can be started without Taskbus platform.
- One input pin(stdin), two output pins.(stdout, stderr)
- Classical bash programs can be involved directly.
- No more data format issus needed.
- Standard-mod
- Some simple data format should be involved.
- Logically Multi In, Multi Out
- Programs can only work in Taskbus platform.
### 3.1 Quick-mod
#### 3.1.1 Standard input and output
A textbook C program that implements XOR operations is generally similar to this:
......@@ -68,10 +83,69 @@ The input and output of the Taskbus module is very similar to the above program.
fwrite(a,sizeof(int),4,stdout);
```
### 3.2 Subjects and Paths
#### 3.1.2 FM radio demod example
Using stdio, a FM demod function can be built with only 50 lines.
```cpp
#include <cstdio>
#include <cmath>
#ifdef WIN32
#include <io.h>
#include <fcntl.h>
#endif
#define Pi 3.14159265354
double angle(int x, int y)
{
double angle = 0;
if (x==0)
angle = (y>0)? Pi/2:-Pi/2;
else if (x >0 )
angle = atan(y*1.0/x);
else if (y >=0)
angle = atan(y*1.0/x)+Pi;
else
angle = atan(y*1.0/x)-Pi;
return angle;
}
int main()
{
#ifdef WIN32
setmode(fileno(stdout), O_BINARY);
setmode(fileno(stdin), O_BINARY);
#endif
short buf[128][2];
short out[128];
int nPts = 0;
int last_i = 0, last_q = 0;
while ((nPts = fread(buf,4,128,stdin)))
{
for (int j=0;j<nPts;++j)
{
//d(phase)/d(t) = freq
int curr_i = buf[j][0];
int curr_q = buf[j][1];
int diff_i = last_i * curr_i + last_q * curr_q;
int diff_q = last_q * curr_i - last_i * curr_q;
last_i = curr_i;
last_q = curr_q;
out[j] = angle(diff_i,diff_q)/Pi*4096;
}
fwrite(out,2,nPts,stdout);
fflush(stdout);
}
return 0;
}
```
### 3.2 Standard-mod
#### 3.2.1 Subjects and Paths
A child process has only one pair of input and output pipelines. By introducing the concept of *Subjects and Paths*, multiple content can be transmited through one channel .
#### 3.2.1 Subjects
##### 3.2.1.1 Subjects
*Subject* indicates a class of data. such as the waveform collected by the sound card, and the stream of bytes read from the file.
......@@ -82,7 +156,7 @@ On the graphical interface, the Subjects is shown as a pin. Each Subjects has a
A Subject producer generates data and gives it to the platform. The platform gives the data to all consumers connected to the Subjects.
**NOTE:** Different pins can produce the same Subject ID, and can also listen to a same ID. For the Producers, the act of doing so is consistent. For consumers, how to deal with the same subject ID, depending on the module implementation.
#### 3.2.2 Paths
##### 3.2.1.2 Paths
Path distinguishes an independent natural sequence in a class of topics. In the example below, the data collected by the two sound cards are remitted into the same FFT converter. For converters, it is necessary to distinguish between two natural timing sequences in order not to cause confusion.
......@@ -90,7 +164,7 @@ Path distinguishes an independent natural sequence in a class of topics. In the
The sound card module in the image above uses its own process ID (2, 6) as the path number, which makes it very convenient to calibrate the source of the data.
### 3.3 IO with Subjects and Paths
#### 3.2.2 IO with Subjects and Paths
Given the above, we can implement stdio-based communication with a slight modification in the preceding code.
```cpp
......@@ -140,7 +214,7 @@ int main(int argc, char *argv[])
The above code lacks context, but clearly illustrates the most basic communication principle of taskbus. Between the different modules, it is through this method of communication.
### 3.4 Function publish
#### 3.2.3 Function publish
taskBus modules are developed independently by the developer. A JSON file is required to publish its own functionality to platform. In this way, the platform knows the types of topics supported by the module, parameter options.
A typical function description file must consist of three parts, namely:
1. Parameter table
......@@ -218,7 +292,7 @@ Within each function, the four sub-items (name, parameters, Input_subject, Outpu
![example_module UI](images/example_module.png)
### 3.5 Command-line arguments
#### 3.2.4 Command-line arguments
The Taskbus platform initiates the process based on the JSON file. When you start each function module, Taskbus feeds all the information through the command line parameters. There are several types of command-line arguments.
......@@ -237,7 +311,7 @@ user@local$ example_helloworld.exe --instance=6 --function=example_bitxor --mask
```
![Paths UI](images/commandline_en.png)
### 3.6 First Hello-world module
####3.2.5 First Hello-world module
We paste the code of the Hellowold module here, using C + +, it is very convenient to implement the above functions.
- The code does not use any features other than the standard C + +
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册