Skip to content

Commit 79dc4ea

Browse files
committed
Added first draft Introduction page
1 parent 05cfbf1 commit 79dc4ea

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Content
4747
:maxdepth: 1
4848

4949
overview
50+
introduction
5051

5152
.. toctree::
5253
:maxdepth: 1

docs/introduction.rst

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
Introduction
2+
============
3+
4+
This page aims to introduce the basic usage, and general concepts of the
5+
package.
6+
7+
Communication
8+
-------------
9+
10+
The primary way of communication with surveying instruments is through
11+
a direct serial connection (RS232). This is available on almost all products.
12+
Newer equipment might also come with built-in, or attachable bluetooth
13+
connection capabilities.
14+
15+
Currently the package only supports serial connections, for which the
16+
necessary primitives are implemented. Other communication formats may be
17+
added later.
18+
19+
Communication related definitions can be found in the
20+
:mod:`~geocompy.communication` module. The main primitive is the
21+
:class:`~geocompy.communication.SerialConnection` class, that acts as a
22+
wrapper around a :class:`~serial.Serial` object that implements the actual
23+
low level serial communication.
24+
25+
.. code-block:: python
26+
:caption: Simple serial connection
27+
:linenos:
28+
29+
from serial import Serial
30+
from geocompy.communication import SerialConnection
31+
32+
33+
port = Serial("COM1", timeout=15)
34+
conn = SerialConnection(port)
35+
conn.send("some message")
36+
conn.close() # Closes the wrapped serial port
37+
38+
.. caution::
39+
40+
It is strongly recommended to set a ``timeout`` on the connection. Without
41+
a ``timeout`` set, the connection may end up in a perpetual waiting state
42+
if the instrument becomes unresponsive.
43+
44+
The :class:`~geocompy.communication.SerialConnection` can also be used as a
45+
context manager, that automatically closes the serial port when the context
46+
is left.
47+
48+
.. code-block:: python
49+
:caption: Serial connection as context manager
50+
:linenos:
51+
52+
from serial import Serial
53+
from geocompy.communication import SerialConnection
54+
55+
56+
port = Serial("COM1", timeout=15)
57+
with SerialConnection(port) as conn:
58+
conn.send("some message")
59+
60+
To make the connection creation simpler, a utility function is also included
61+
that can be used similarly to the :func:`open` function of the standard
62+
library.
63+
64+
.. code-block:: python
65+
:caption: Creating connection with the utility function
66+
:linenos:
67+
68+
from geocompy.communication import open_serial
69+
70+
71+
with open_serial("COM1", timeout=15) as conn:
72+
conn.send("some message")
73+
74+
Protocols
75+
---------
76+
77+
The GeoComPy package (as the name suggests) primarily built around the
78+
GeoCom command protocol. This was developed by Leica and is available on
79+
a wide range of their products. For some older instrument types, that do
80+
not support GeoCom, older systems (like GSI Online) might be implemented
81+
instead. All serial communication based protocols are fundamentally
82+
synchronous systems, consisting of request-response pairs.
83+
84+
.. note::
85+
86+
Leica stopped selling GeoCom robotic licenses for their TPS1200 series
87+
instruments in 2019. Newer instruments have a more complicated
88+
licensing scheme.
89+
90+
The primary goal is to provide methods to call all known GeoCom commands on the
91+
supported instruments. These "low-level" commands can then be used to build
92+
more complex applications.
93+
94+
GeoCom
95+
^^^^^^
96+
97+
GeoCom enabled instruments can communicate with the ASCII version of the
98+
protocol through a stable connection. Each command is a serialized RPC
99+
(Remote Procedure Call) request, that specifies the code of the procedure
100+
to run, and supplies the necessary arguments. The reply is a serialized
101+
RPC response message, containing the return parameters.
102+
103+
.. code-block::
104+
:caption: GeoCom exchange example
105+
106+
%R1Q,9029:1,1,0 # RPC 9029, prism search in window
107+
%R1P,0,0:0 # Standard OK response
108+
109+
All the supported instruments follow a similar API structure. The instrument
110+
object implements the generic request functions. The actual GeoCom commands
111+
are available through their respective subsystems.
112+
113+
The connection to an instrument can be easily set up through a serial
114+
connection. The connection is tested during the initialization, and some
115+
communication parameters are syncronized.
116+
117+
.. code-block:: python
118+
:caption: Initializing instrument connection
119+
:linenos:
120+
121+
from geocompy.communication import open_serial
122+
from geocompy.tps1200p import TPS1200P
123+
124+
125+
with open_serial("COM1", timeout=10) as conn:
126+
tps = TPS1200P(conn)
127+
128+
Once the connection is verified, the commands can be executed through the
129+
various subsystems.
130+
131+
.. code-block:: python
132+
:caption: Querying the system software version through the Central Services
133+
:linenos:
134+
135+
resp = tps.csv.get_sw_version()
136+
print(resp) # GeoComResponse(CSV_GetSWVersion) com: OK, rpc: OK...
137+
138+
All GeoCom commands return a :class:`~geocompy.protocols.GeoComResponse`
139+
object, that encapsulates the return codes, as well as the optional
140+
returned paramters.
141+
142+
.. tip::
143+
144+
The complete list of available commands and their documentations are
145+
available in their respective API documentation categories.
146+
147+
GSI Online
148+
^^^^^^^^^^
149+
150+
The GSI Online protocol is a command system that is older than GeoCom. Many
151+
older instruments either only support this system. Some support both (e.g.
152+
TPS1100 series).

docs/latexindex.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ GeoComPy
1010
:maxdepth: 2
1111

1212
overview
13+
introduction
1314

1415
*****************
1516
API documentation

0 commit comments

Comments
 (0)