铁路术语
rail 铁轨; compensation 补偿; catenary 重曲线的; detection 检测; sensor 传感器; measurement 测量; frequency 频率; startup 启动;
procedure 过程; snippet 片段; extract 提取; protocol 协议; initial 首次的; release 释放; alqorithm 算法; format 格式;
commonly 常用的; section 章节; throughout 贯穿; accurate 精确地; precision 精度; interface 接口; simplicity 简单; uniformity 统一;
concerns 关注的; consult 查阅; angle 角度; in degree 更深地; single 单一地; mutiples 倍数; ethernet 以太网; 100 Base-T 一种以100Mbps工作的局域网标准;
recommended 推荐 wire 电线; respectively 各自的; component 成分、组件; frame 框架;
----------------------- Page 1-----------------------
OptiCat
TCP/IP
Protocol
V0.4, March 2017
ELAG Elektronik AG l Stegackerstrasse 14 l CH-8409 Winterthur
----------------------- Page 2-----------------------
TCP/IP Protocol OptiCat, V 0.4
Index
1. History ........................................................................................... 3
B9 V1.2 3
B10 V1.3 3
B11 V1.3.1 3
B13 V1.4 Dec13 3
B14 V1.4.1 Feb 14 3
V1.4.3 Dec 15 3
2. Description ..................................................................................... 4
2.1. Commonly used data formats ........................................................ 4
Angle 4
Distance 4
Temperature 4
Date 4
3. Protocol.......................................................................................... 5
3.1. TCP/IP ............................................................................................. 5
3.2. Framing .......................................................................................... 5
3.3. Keys ................................................................................................ 6
GetSerialnumber 'GS' 6
CatenarypositionFloat ‘CF’ 6
CatenarypositionFloat ‘CE’ 6
PowerOnOff 'PO' 7
MeasurementOnOff 'MO' 7
Measurement Frequency 'MF' 7
Status 'ST' 8
Temperatures 'TE' (only response) 8
Rail compensation 'RC' 9
Catenary detection ‘CD’ 9
3.4. Startup procedure ........................................................................ 10
4. Sample Code................................................................................. 11
Checksum calculation 11
Convert string to number 11
Convert catenary position string to float 11
ELAG Elektronik AG /nr - 2 - March 17
----------------------- Page 3-----------------------
TCP/IP Protocol OptiCat, V 0.4
1. History
B9 V1.2
Initial Release
B10 V1.3
-Change: 2D frame dynamically created
-New: New rail detection algorithm, less sensitive to sunlight and noise
B11 V1.3.1
-Fix: signed FloatToInt: Toppoint detection at pos and neg. Y-Values.
-Fix: 2D: smaler fixes.
B13 V1.4 Dec13
-New: New catenyary detection algorithm includes wire on rail
-Change: Performance improvements
-New: Temperature output (TE) at Status.
-New: Option to disable rail compensation
B14 V1.4.1 Feb 14
-New: Catenyary detection can be choosen with command “CD”
-Fix: Wire detection; too much wires detected on diagonals.
V1.4.3 Dec 15
-New: CE Command includes Rail Compensation
ELAG Elektronik AG /nr - 3 - March 17
----------------------- Page 4-----------------------
TCP/IP Protocol OptiCat, V 0.4
2. Description
This paper describes the protocol for the Optimess catenary wire measuring system over
10/100/1000Mbit Ethernet using TCP/IP.
2.1. Commonly used data formats
Some data formats commonly used throughout this document are described in this
section. Although most formats are high precision, the data sources may not be as
accurate. The formats were mainly chosen for simplicity and uniformity throughout all
interfaces. For accuracy concerns, please consult the data sheet.
Angle
Unless otherwise noted, angles are represented in degree, representing 1/360 of a full
rotation.
Distance
Distances can be represented in single precision (32 Bit) float format according to IEEE
754 and are in millimetre (mm).
On the other hand, if it is represented as integer, it will be in micrometre (µm). For
example 1’234’567 would mean 1.234567 m, resp. 1234.567 mm.
Temperature
Temperatures are represented as multiples of 0.1°C.
For example a temperature of 23.4°C is represented by 234.
Date
Dates are represented as unsigned integers, counting the days elapsed since December
30, 1899. This format is commonly used on windows based systems.
For example July 17, 2012 is denoted by the number 41107.
ELAG Elektronik AG /nr - 4 - March 17
----------------------- Page 5-----------------------
TCP/IP Protocol OptiCat, V 0.4
3. Protocol
3.1. TCP/IP
The DPU can be connected over Ethernet 100BASE-T resp. 1000BASE-T. Although
10Base-T is possible, it is not recommended. It should be noted that using Gigabit
Ethernet needs at least Cat 5e cabling.
The DPU acts as a TCP server, listening on port 60060 for incoming connections. For
performance reasons, only one connection/client is allowed. All data is coded in ASCII
and so, no binary data is used.
The IP Address of the DPU is fixed to 192.168.25.1.
A DHCP server is running on the DPU providing an IP address to connected clients.
Although it is also possible to use a fixed IP.
3.2. Framing
Each Message is packed in a frame with the following format:
<LLKKLLLLDDD...DSS>
Symbol Example Description
< < The start and end of a Frame is always marked by angle brackets.
LL 02 The first two characters ( 02) mark the length of the key. Currently
only keys of length 2 are used.
KK GS The length field is followed by the key itself. Normally, it is
composed of letters, but it could also contain numbers. The possible
keys are described later.
LLLL 001C Four characters indicating the length of the data field. Like all
numbers, it is coded as hex value. 001C means 1Ch (0x001C). So 28
bytes of data are expected. It can also be zero, so no data will follow.
DDD.. 0123 Data: Depending on the key, data may be in different formats.
Please see following description.
SS 4A The last two characters (SS) form a checksum over the whole frame
without brackets and the checksum itself. It is a hexadecimal
number formed as the least significant byte of the sum of the ASCII-
Code of each character plus A7h as follows:
Checksum = (0xA7 + L+L + K+K + L+L+L+L + D+D+..+D) mod 256
> > End of frame.
It is not precluded, that any other data (like linefeed ...) are followed
by the frame. The parsing must only rely on the brackets.
ELAG Elektronik AG /nr - 5 - March 17
----------------------- Page 6-----------------------
TCP/IP Protocol OptiCat, V 0.4
3.3. Keys
Please note that the spaces in the examples are only for better readability. There are
no spaces in the real frames.
GetSerialnumber 'GS'
This key returns the serial number and version of the scanner. The frame is formed as
follows:
<02 GS 0000 SS>
The response of this command is
<02 GS 0008 SSSS VVVV SS>
where SSSS is the serial number and VVVV is the version of the scanner.
CatenarypositionFloat ‘CF’
This key is used to send the catenary wire positions according to the middle of the rails .
The format of the values is float. Y is the side position according to the middle between
the rails and Z is the height of the wire above the rails
Up to 8 wires are detected and transmitted. The number of wires is given from data
length divided through 16. In the following example, 2 wires were found.
The frame is formed as follows:
<02 CF 0020 YYYYYYYYZZZZZZZZ YYYYYYYYZZZZZZZZ SS>
CatenarypositionFloat ‘CE’
This is the extended version of CF where the Rail compensation is added. It is the
standard format since Version 1.4.3.
Symbol Example Description
< < The start and end of a Frame is always marked by angle brackets.
LL 02 Key length
KK CE Key
LLLL 0038 Datalength
FFFFFFFF 00000002 Compensation Flag (integer)
0 = Compensation is switched on and active and ok
1 = Compensation is switched on but didn't find a valid Rail
2 = Compensation is switched off
AAAAAAAA Rail Position Y, left side (float)
BBBBBBBB Rail Position Z, left side (float)
CCCCCCCC Rail Position Y, right side (float)
DDDDDDDD Rail Position Z, right side (float)
YYYYYYYY First wire side position (float)
ELAG Elektronik AG /nr - 6 - March 17
----------------------- Page 7-----------------------
TCP/IP Protocol OptiCat, V 0.4
ZZZZZZZZ First wire height position (float)
YYYYYYYY Possibly more wires
ZZZZZZZZ …
SS Checksum
> > End of frame.
PowerOnOff 'PO'
This key turns on the power of all Sensors respectively switches them off.
To turn all on, the following command has to be sent
<02 PO 0002 FF SS>
To turn it off, use the following command
<02 PO 0002 00 SS>
The response is always
<02 PO 0002 OK SS>
MeasurementOnOff 'MO'
This key turns on the measuring of all sensors respectively switches them off.
To turn all on, the following command has to be sent
<02 MO 0002 FF SS>
To turn it off, use the following command
<02 MO 0002 00 SS>
The response is always
<02 MO 0002 OK SS>
Measurement Frequency 'MF'
This key sets the measurement frequency. Set it in Hz (measurements per second).
To set the Frequency to 300Hz, use:
<02 MF 0004 012C SS>
The response is the accepted frequency:
<02 MF 0004 012C SS>
Actual supported frequencies are: 100Hz to 400Hz. If any other frequencies are set, the
closest possible value will be taken.
ELAG Elektronik AG /nr - 7 - March 17
----------------------- Page 8-----------------------
TCP/IP Protocol OptiCat, V 0.4
Status 'ST'
This key gives out the status of the system:
To get the status:
<02 ST 0000 SS>
The DPU will respond with:
<02 ST 0008 DD SS RR LL SS>
and
<02 TE 0008 PCPC SCSC SS>
Every component has 8 bits which represents the status of those.
DD: Status of the DPU
SS : Status of the scanner (on the roof)
RR: Status of the right 2D sensor
LL: Status of the left 2D sensor
Bit Meaning of the bit
0 Component is attached
1 Component is powered
2 Link is OK
3 Component is OK and ready to measure
4 Component is in measuring mode
. ..
Temperatures 'TE' (only response)
This will be sent together with Status.
<02 TE 0008 PCPC SCSC SS>
Two temperetures will be given, the CPU core temperature of the DPU and the case
temperature from the scanner. Each in the format of a signed short value (16bit):
PCPC: Temperature of the CPU of the DPU in 0. 1°C
SCSC : Temperature from the case of the scanner in 0.1°C
If the scanner is not attached or powered, an invalid value of -1000°C will be
given.
ELAG Elektronik AG /nr - 8 - March 17
----------------------- Page 9-----------------------
TCP/IP Protocol OptiCat, V 0.4
Rail compensation 'RC'
Ask or set the function of rail compensation by the 2 Optimess 2D Sensors.
Query
Send:
<02 RC 0000 SS>
And you will get the answer:
<02 RC 0004 00 01 SS>
If rail compensation is switched on or
<02 RC 0004 00 00 SS>
If rail compensation is switched off.
Set
Send:
<02 RC 0004 00 01 SS>
To switch on the rail compensation or
<02 RC 0004 00 00 SS>
To switch off the rail compensation .
Catenary detection ‘CD’
Ask or set the type/s of catenary wire to be detected. More than one can be switched
on. Only the first 2 bits are used so far.
Bit 0 Normal wire
(1)
Bit 1 Conductor Rail
(2)
ELAG Elektronik AG /nr - 9 - March 17
----------------------- Page 10-----------------------
TCP/IP Protocol OptiCat, V 0.4
Query
Send:
<02 CD 0000 SS>
And you will get the answer (normal wire detection is on):
<02 CD 0004 00 01 SS>
Set
Send:
<02 CD 0004 00 01 SS>
to switch on the normal wire detection or
<02 CD 0004 00 03 SS>
to switch on the normal wire detection and the Conductor Rail detection together.
3.4. Startup procedure
1. Establish a TCP/IP connection to 192.168.25.1:60060
2. Test the connection by sending <02GS0000SS> (Get Serialnumber)
3. Power the sensors by sending <02 PO 0002 FF SS>
4. Set the measurement frequency with the key MF
5. Start the measurement by sending the MO key
6. Receive the data.
ELAG Elektronik AG /nr - 10 - March 17
----------------------- Page 11-----------------------
TCP/IP Protocol OptiCat, V 0.4
4. Sample Code
Following some snippets of code in C++ (for Borland compiler):
Checksum calculation
Data contains the string, Length the length of the string, both without brackets (and the
checksum itself).
char chsum = 0xA7;
for (int i = 0; i < Length; i++)
chsum += Data[i];
Convert string to number
This code converts a String of 1 to 8 chars to an integer number; for example to extract
the key-length or the data-length.
int hex2dec(String hexstring, char len){
int dec = 0;
hexstring = hexstring.UpperCase();
for (int u = 1; u <= len; u++){
dec <<= 4;
if (hexstring[u] >= 'A') dec += hexstring[u] + 10 - 'A';
else dec += hexstring[u] - '0';
}
return(dec);
}
Convert catenary position string to float
int Nbr = Len/16;
for(int i=0; i<Nbr; i++){
int iY = hex2dec(String(&Data[i*16],8),8);
int iZ = hex2dec(String(&Data[i*16+8],8),8);
float Y = *(float*)&iY;
float Z = *(float*)&iZ;
…
}
ELAG Elektronik AG l Stegackerstrasse 14 l CH-8409 Winterthur
ELAG Elektronik AG /nr - 11 - March 17

浙公网安备 33010602011771号