Packages and Layers
plesty-lib is one Python package, plesty.lib, divided into subpackages. This page
says what each subpackage is for, and which ones may import which: the rule that
keeps a change in one part from breaking another.
The subpackages
Package |
What it is for |
|---|---|
|
Small shared tools: logging setup, error handling, |
|
Data types and saving them: |
|
Moving bytes to and from an instrument: serial, VISA, TCP/IP and Thorlabs APT connections, plus USB helpers. Each connection type is a traffic manager. It knows nothing about parameters or operations. |
|
Translating a parameter or operation into the instrument’s own command, and its reply back. Each translator is a solver; |
|
Devices: the base class every device inherits ( |
|
Using a device over the network: the server, the client, and the manager that lets several clients share one instrument. |
|
Experiments: |
|
Analyzers: the |
|
Reports: |
|
Watching a run: |
|
Windows: the main window ( |
|
Stand-ins for hardware: |
|
Ready-made tests that a device, experiment or analyzer module runs on itself, with and without the instrument. See Testing. |
Which package may import which
The subpackages form layers. A package imports only from the layers below it, never from above. This keeps the lower layers usable on their own: a device server does not load anything about experiments or windows, and a change to the viewer cannot break a device.
Layer |
Packages |
Imports from |
|---|---|---|
6 — testing |
|
any layer below |
5 — results |
|
|
4 — viewing |
|
|
3 — experiments |
|
|
2 — devices |
|
|
1 — connections |
|
|
0 — foundation |
|
nothing else in plesty-lib |
analyzer sits high because an analyzer’s report can include figures, which are
drawn with the same drawables as the viewer. The analysis itself uses only data.
Exceptions
A few imports go the other way. Each is deliberate, and each is either confined to one place or made inside a function, so it happens only when that function is called:
From |
To |
Where, and why |
|---|---|---|
|
|
|
|
|
only the classes that describe a parameter or an operation ( |
|
|
inside |
|
|
inside |
|
|
inside |
Inside a device
A device itself is built from six layers, from the instrument up to a client on another computer. Only the bottom two are written for each instrument:
PlestyLib, the first page of these docs, walks through this figure.