You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ Otherwise, I will then take care of the issue as soon as possible.
47
47
Developers are always welcome to contribute to the code base. If you want to tackle any issues, un-existing features, let me know (at my email), I can create some open issues and features which I was never able to solve or did not have the time. You can also suggest what else can be contributed functionally or conceptually or also simply code-refactoring. The lack of issues or features in the [Issues](https://github.com/VigneshVSV/hololinked/issues) section of github does not mean the project is considered feature complete or I dont have ideas what to do next. On the contrary, there is tons of work to do.
48
48
49
49
There are also repositories which can use your skills:
50
-
- An [admin client](https://github.com/VigneshVSV/hololinked-portal) in react
50
+
- An [admin client](https://github.com/VigneshVSV/thing-control-panel) in react
51
51
-[Documentation](https://github.com/VigneshVSV/hololinked-docs) in sphinx which needs significant improvement in How-To's, beginner level docs which may teach people concepts of data acquisition or IoT, Docstring or API documentation of this repository itself
52
52
-[Examples](https://github.com/VigneshVSV/hololinked-examples) in nodeJS, Dashboard/PyQt GUIs or server implementations using this package. Hardware implementations of unexisting examples are also welcome, I can open a directory where people can search for code based on hardware and just download your code.
Copy file name to clipboardExpand all lines: README.md
+33-24Lines changed: 33 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
# hololinked - Pythonic Supervisory Control & Data Acquisition / Internet of Things
1
+
# hololinked - Pythonic Object-Oriented Supervisory Control & Data Acquisition / Internet of Things
2
2
3
3
### Description
4
4
5
-
For beginners - `hololinked` is a server side pythonic package suited for instrumentation control and data acquisition over network, especially with HTTP. If you have a requirement to control and capture data from your hardware/instrumentation, show the data in a browser/dashboard, provide a GUI or run automated scripts, `hololinked` can help. Even for isolated applications or a small lab setup without networking concepts, one can still separate the concerns of the tools that interact with the hardware & the hardware itself.
6
-
<br/> <br/>
7
-
For those familiar with RPC & web development - This package is an implementation of a ZeroMQ-based Object Oriented RPC with customizable HTTP end-points. A dual transport in both ZMQ and HTTP is provided to maximize flexibility in data type, serialization and speed, although HTTP is preferred for networked applications. If one is looking for an object oriented approach towards creating components within a control or data acquisition system, or an IoT device, one may consider this package.
5
+
`hololinked` is a server side pythonic tool suited for instrumentation control and data acquisition over network, especially with HTTP. If you have a requirement to control and capture data from your hardware/instrumentation, show the data in a browser/dashboard, provide a GUI or run automated scripts, `hololinked` can help. Even for isolated applications or a small lab setup without networking concepts, one can still separate the concerns of the tools that interact with the hardware & the hardware itself.
[](mailto:vignesh.vaidyanathan@hololinked.dev)[](https://discord.com/users/1178428338746966066)
10
10
11
11
### To Install
12
12
@@ -19,16 +19,14 @@ Or, clone the repository (develop branch for latest codebase) and install `pip i
19
19
`hololinked` is compatible with the [Web of Things](https://www.w3.org/WoT/) recommended pattern for developing hardware/instrumentation control software.
20
20
Each device or thing can be controlled systematically when their design in software is segregated into properties, actions and events. In object oriented terms:
21
21
- the hardware is (generally) represented by a class
22
-
- properties are validated get-set attributes of the class which may be used to model hardware settings, hold captured/computed data or generic network accessible quantities
22
+
- properties are validated get-set attributes of the class which may be used to model settings, hold captured/computed data or generic network accessible quantities
23
23
- actions are methods which issue commands like connect/disconnect, execute a control routine, start/stop measurement, or run arbitray python logic
24
24
- events can asynchronously communicate/push (arbitrary) data to a client (say, a GUI), like alarm messages, streaming measured quantities etc.
25
25
26
-
It does not even matter whether you are controlling your hardware locally or remotely, what protocol you use, what is the nature of the client etc.,
27
-
one has to provide these three interactions with the hardware. In this package, the base class which enables this classification is the `Thing` class. Any class that inherits the `Thing` class
28
-
can instantiate properties, actions and events which
29
-
become visible to a client in this segragated manner. For example, consider an optical spectrometer, the following code is possible:
26
+
In this package, the base class which enables this classification is the `Thing` class. Any class that inherits the `Thing` class
27
+
can instantiate properties, actions and events which become visible to a client in this segragated manner. For example, consider an optical spectrometer, the following code is possible:
30
28
31
-
> This is a fairly mid-level intro, if you are beginner, for another variant check [How-To](https://hololinked.readthedocs.io/en/latest/howto/index.html)
29
+
> This is a fairly mid-level intro focussed on HTTP. If you are beginner or looking for ZMQ which can be used with no networking knowledge, check [How-To](https://hololinked.readthedocs.io/en/latest/howto/index.html)
32
30
33
31
#### Import Statements
34
32
@@ -64,8 +62,8 @@ class OceanOpticsSpectrometer(Thing):
@@ -81,10 +79,9 @@ class OceanOpticsSpectrometer(Thing):
81
79
```
82
80
83
81
In non-expert terms, properties look like class attributes however their data containers are instantiated at object instance level by default.
84
-
For example, the `integratime_time` property defined above as `Number`, whenever set/written, will be validated as a float or int, cropped to bounds and assigned as an attribute to each instance of the `OceanOpticsSpectrometer` class with an internally generated name. It is not necessary to know this internally generated name as the property value can be accessed again in any python logic, say, `print(self.integration_time)`.
82
+
For example, the `integration_time` property defined above as `Number`, whenever set/written, will be validated as a float or int, cropped to bounds and assigned as an attribute to each instance of the `OceanOpticsSpectrometer` class with an internally generated name. It is not necessary to know this internally generated name as the property value can be accessed again in any python logic, say, `print(self.integration_time)`.
85
83
86
84
To overload the get-set (or read-write) of properties, one may do the following:
87
-
88
85
```python
89
86
classOceanOpticsSpectrometer(Thing):
90
87
@@ -132,8 +129,7 @@ Those familiar with Web of Things (WoT) terminology may note that these properti
132
129
```
133
130
If you are not familiar with Web of Things or the term "property affordance", consider the above JSON as a description of
134
131
what the property represents and how to interact with it from somewhere else. Such a JSON is both human-readable, yet consumable
135
-
by a client provider to create a client object to interact with the property in the way the property demands. You, as the developer,
136
-
only need to use the client.
132
+
by a client provider to create a client object to interact with the property.
137
133
138
134
The URL path segment `../spectrometer/..` in href field is taken from the `instance_name` which was specified in the `__init__`.
139
135
This is a mandatory key word argument to the parent class `Thing` to generate a unique name/id for the instance. One should use URI compatible strings.
@@ -153,6 +149,13 @@ class OceanOpticsSpectrometer(Thing):
# So you can leave it out, especially if you are going to use ZMQ and dont understand HTTP
154
+
@action()
155
+
defdisconnect(self):
156
+
"""disconnect from the spectrometer"""
157
+
self.device.close()
158
+
156
159
```
157
160
158
161
Methods that are neither decorated with action decorator nor acting as getters-setters of properties remain as plain python methods and are **not** accessible on the network.
@@ -266,6 +269,8 @@ what the event represents and how to subscribe to it) with subprotocol SSE (HTTP
266
269
```
267
270
> data schema ("data" field above which describes the event payload) are optional and discussed later
268
271
272
+
Events follow a pub-sub model with '1 publisher to N subscribers' per `Event` object, both through ZMQ and HTTP SSE.
273
+
269
274
Although the code is the very familiar & age-old RPC server style, one can directly specify HTTP methods and URL path for each property, action and event. A configurable HTTP Server is already available (from `hololinked.server.HTTPServer`) which redirects HTTP requests to the object according to the specified HTTP API on the properties, actions and events. To plug in a HTTP server:
270
275
271
276
```python
@@ -284,14 +289,17 @@ if __name__ == '__main__':
284
289
log_level=logging.DEBUG
285
290
)
286
291
O.run_with_http_server(ssl_context=ssl_context)
292
+
# or O.run(zmq_protocols='IPC') - interprocess communication and no HTTP
293
+
# or O.run(zmq_protocols=['IPC', 'TCP'], tcp_socket_address='tcp://*:9999')
294
+
# both interprocess communication & TCP, no HTTP
287
295
```
288
296
289
297
Here one can see the use of `instance_name` and why it turns up in the URL path. See the detailed example of the above code [here](https://gitlab.com/hololinked-examples/oceanoptics-spectrometer/-/blob/simple/oceanoptics_spectrometer/device.py?ref_type=heads).
290
298
291
-
##### NOTE - The package is under active development. Contributors welcome, please check CONTRIBUTING.md.
299
+
##### NOTE - The package is under active development. Contributors welcome, please check CONTRIBUTING.md and the open issues. Some issues can also be independently dealt without much knowledge of this package.
292
300
293
301
-[example repository](https://github.com/VigneshVSV/hololinked-examples) - detailed examples for both clients and servers
294
-
-[helper GUI](https://github.com/VigneshVSV/hololinked-portal) - view & interact with your object's methods, properties and events.
302
+
-[helper GUI](https://github.com/VigneshVSV/thing-control-panel) - view & interact with your object's actions, properties and events.
295
303
296
304
See a list of currently supported possibilities while using this package [below](#currently-supported).
297
305
@@ -306,24 +314,25 @@ One may use the HTTP API according to one's beliefs (including letting the packa
306
314
- auto-generate Thing Description for Web of Things applications.
307
315
- use serializer of your choice (except for HTTP) - MessagePack, JSON, pickle etc. & extend serialization to suit your requirement. HTTP Server will support only JSON serializer to maintain compatibility with node-wot. Default is JSON serializer based on msgspec.
308
316
- asyncio compatible - async RPC server event-loop and async HTTP Server - write methods in async
309
-
- choose from multiple ZeroMQ transport methods. Some of the possibilities one can achieve by choosing ZMQ transport methods:
317
+
- choose from multiple ZeroMQ transport methods which offers some possibilities like the following without changing the code:
310
318
- run HTTP Server & python object in separate processes or the same process
311
319
- serve multiple objects with the same HTTP server
312
320
- run direct ZMQ-TCP server without HTTP details
313
321
- expose only a dashboard or web page on the network without exposing the hardware itself
314
-
322
+
315
323
Again, please check examples or the code for explanations. Documentation is being activety improved.
316
324
317
325
### Currently being worked
318
326
319
327
- improving accuracy of Thing Descriptions
320
328
- cookie credentials for authentication - as a workaround until credentials are supported, use `allowed_clients` argument on HTTP server which restricts access based on remote IP supplied with the HTTP headers.
321
329
330
+
### Internals
331
+
332
+
This package is an implementation of a ZeroMQ-based Object Oriented RPC with customizable HTTP end-points. A dual transport in both ZMQ and HTTP is provided to maximize flexibility in data type, serialization and speed, although HTTP is preferred for networked applications. If one is looking for an object oriented approach towards creating components within a control or data acquisition system, or an IoT device, one may consider this package.
333
+
322
334
### Some Day In Future
323
335
324
336
- mongo DB support for DB operations
325
337
- HTTP 2.0
326
338
327
-
### Contact
328
-
329
-
Contributors welcome for all my projects related to hololinked including web apps. Please write to my contact email available at my [website](https://hololinked.dev).
0 commit comments