OpenCurves  0.9
Real Time Source XML Examples

Serial Example

1 <!--
2  Serial port, text mode example.
3 
4  For a binary serial port, replace the 'comms' section with that of the
5  binary example.
6 -->
7 <connection>
8  <!-- Specify a serial connection, its port and the BAUD rate -->
9  <serial port="COM3" baud="9600">
10  <!--
11  Optional: specify the size of the history buffer in elements. This
12  controls the plot window. May be omitted, or zero to use the default.
13  -->
14  <buffer size="10000" />
15  <!--
16  Optional: Index of the timestamp column. Used to time stamp each plot
17  value. The index is specified by the 'column' attribute and is a
18  one based index (default zero, for no column). The 'scale' attribute
19  is used to scale the read time stamps into seconds. The default is 1.
20  -->
21  <time column="1" scale="1.0e-3"/>
22  <!-- Specify the mode and messages. The default mode is text -->
23  <comms binary="false">
24  <!-- Optional: text message to send on connect. Send once. -->
25  <onconnect>Hello world</onconnect>
26  <!--
27  Optional headings specification for the incoming data. This sets the
28  expected number of samples per line and names them.
29 
30  When omitted, the number of samples per line is inferred from the first
31  line, and headings labeled "Column 1", "Column 2", ...
32  -->
33  <headings>
34  <heading name="timestamp" />
35  <heading name="A" />
36  <heading name="B" />
37  <heading name="C" />
38  <heading name="D" />
39  </headings>
40  <!-- Optional: text message to send on disconnect if possible. Send once. -->
41  <ondisconnect>Goodbye cruel world</ondisconnect>
42  </comms>
43  </serial>
44 </connection>

TCP Example

1 <!--
2  TCP binary example.
3 -->
4 <connection>
5  <network address="127.0.0.1" port="14444" protocol="tcp">
6  <!-- Optional. See first example -->
7  <buffer size="10000" />
8  <!--
9  Optional time column specification.
10 
11  For binary data, we can identify the time value by field name instead
12  of column number. Column number may still be used.
13  -->
14  <time field="timestamp" scale="1.0e-6"/>
15  <comms binary="true">
16  <!-- Optional connection message (binary) -->
17  <onconnect>
18  <!--
19  A binary structure definition for sending. Must provide values for
20  each field.
21 
22  The 'endian' attribute may be 'big', 'little' or 'network' (big).
23  The default is 'network' for network byte order.
24  -->
25  <struct endian="network">
26  <!--
27  The definition of a field. Each field can have the following:
28  attributes
29  - type : required. See below.
30  - name : required. Names the field.
31  - heading : optional. 'true' if the field is to be displayed.
32 
33  Fields are not displayed by default (heading is false) and
34  must have 'heading="true"' to be displayed. The time field
35  does not need to be displayed to be used.
36 
37  Valid types are:
38  - int8, int16, int32, int64
39  - uint8, uint16, uint32, uint64
40  - float, double (32-bit and 64-bit respectively)
41 
42  float and double should have Endian changes applied as for an
43  integer of the same bit width.
44 
45  There are additionally three special field types used for padding:
46  - pad, padto, padtofield
47 
48  The pad and padto types require an unsigned integer value, while
49  padtofield has a string value which matches a preceding field name.
50  They behave as follows:
51  - pad : value specifies the number of bytes to skip.
52  - padto : value indicates where in the stream to skip ahead to.
53  - padbyfield : like pad, but the number of padding bytes is read from
54  a preceding field.
55  - padtofield : like padto, but the number of padding bytes to skip to
56  is read from a preceding field.
57 
58  The padto functionality only works if the value is greater than the
59  current stream position (from the structure start). For example,
60  consider a structure with:
61  - uint32 A
62  - uint16 B
63  - padto 8
64 
65  Without 'padto' the size would be 6 bytes. 'padto' extends it to 8
66  bytes. 'padto' would do nothing if it were 6 or less.
67 
68  The 'padtofield' and 'padbyfield' types only work if the named field
69  appears earlier in the structure. Otherwise no padding value is available.
70  They are intended for use with size fields. For example:
71  padbyfield example:
72  - uint32 messageType
73  - uint16 payloadSize
74  - padbyfield "payloadSize"
75  - uint16 crc
76  Here padbyfield reads payload size and skips that many bytes.
77 
78  padtpfield example:
79  - uint32 messageType
80  - uint16 messageSize
81  - padtofield "messageSize"
82  Here 'messsageSize' is read and the stream position moved to this
83  absolute byte position.
84 
85  The structure may have any number of fields within reason.
86  -->
87  <field type="uint32" name="messageType">42</field>
88  <field type="uint16" name="messageSubtype">1</field>
89  <field type="pad" name="">2</field>
90  </struct>
91  </onconnect>
92  <!-- Define the incoming data structure -->
93  <receive>
94  <!-- Only fields with 'heading'='yes' are displayed. -->
95  <struct endian="network">
96  <field type="uint16" name="messageSize" />
97  <field type="uint64" name="time" />
98  <field type="double" name="A" heading="true"/>
99  <field type="double" name="B" heading="true" />
100  <field type="double" name="C" heading="true" />
101  <field type="double" name="D" heading="true" />
102  <field type="padtofield" name="">messageSize</field>
103  </struct>
104  </receive>
105  <!-- Message to send on disconnect if possible -->
106  <ondisconnect>
107  <struct>
108  <field type="uint32" name="messageType">42</field>
109  <field type="uint16" name="messageSubtype">0</field>
110  <field type="pad" name="">2</field>
111  </struct>
112  </ondisconnect>
113  </comms>
114  </network>
115 </connection>
116 
117 <!--
118  UDP short binary example.
119 -->
120 <connection>
121  <network address="127.0.0.1" port="14444" protocol="udp">
122  <comms binary="true">
123  <onconnect>
124  <struct>
125  <field type="uint32" name="messageType">42</field>
126  <field type="uint16" name="messageSubtype">1</field>
127  <field type="pad" name="">2</field>
128  </struct>
129  </onconnect>
130  <receive>
131  <struct endian="network">
132  <field type="uint16" name="messageSize" />
133  <field type="uint64" name="time" />
134  <field type="double" name="A" heading="true"/>
135  <field type="double" name="B" heading="true" />
136  <field type="double" name="C" heading="true" />
137  <field type="double" name="D" heading="true" />
138  <field type="padtofield" name="">messageSize</field>
139  </struct>
140  </receive>
141  </network>
142 </connection>

UDP Example

1 <!--
2  UDP short binary example.
3 -->
4 <connection>
5  <network address="127.0.0.1" port="14444" protocol="udp">
6  <comms binary="true">
7  <onconnect>
8  <struct>
9  <field type="uint32" name="messageType">42</field>
10  <field type="uint16" name="messageSubtype">1</field>
11  <field type="pad" name="">2</field>
12  </struct>
13  </onconnect>
14  <receive>
15  <struct endian="network">
16  <field type="uint16" name="messageSize" />
17  <field type="uint64" name="time" />
18  <field type="double" name="A" heading="true"/>
19  <field type="double" name="B" heading="true" />
20  <field type="double" name="C" heading="true" />
21  <field type="double" name="D" heading="true" />
22  <field type="padtofield" name="">messageSize</field>
23  </struct>
24  </receive>
25  </network>
26 </connection>