mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-05 21:20:40 +02:00
Updating Readme: adding rpyc usage section
This commit is contained in:
parent
cb7dcb625e
commit
713ef3170f
20
README.md
20
README.md
@ -26,7 +26,7 @@ pip install git+https://github.com/tiqi-group/pydase.git
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Using `pydase` involves two main steps: defining a `DataService` subclass and then running the server.
|
Using `pydase` involves three main steps: defining a `DataService` subclass, running the server, and then connecting to the service either programmatically using `rpyc` or through the web interface.
|
||||||
|
|
||||||
### Defining a DataService
|
### Defining a DataService
|
||||||
|
|
||||||
@ -103,6 +103,24 @@ Once the server is running, you can access the web interface in a browser:
|
|||||||
|
|
||||||
In this interface, you can interact with the properties of your `Device` service.
|
In this interface, you can interact with the properties of your `Device` service.
|
||||||
|
|
||||||
|
### Connecting to the Service using rpyc
|
||||||
|
|
||||||
|
You can also connect to the service using `rpyc`. Here's an example on how to establish a connection and interact with the service:
|
||||||
|
|
||||||
|
```python
|
||||||
|
import rpyc
|
||||||
|
|
||||||
|
# Connect to the service
|
||||||
|
conn = rpyc.connect("<ip_addr>", 18871)
|
||||||
|
client = conn.root
|
||||||
|
|
||||||
|
# Interact with the service
|
||||||
|
client.voltage = 5.0
|
||||||
|
print(client.voltage) # prints 5.0
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, replace `<ip_addr>` with the IP address of the machine where the service is running. After establishing a connection, you can interact with the service attributes as if they were local attributes.
|
||||||
|
|
||||||
## Understanding Tasks in pydase
|
## Understanding Tasks in pydase
|
||||||
|
|
||||||
In `pydase`, a task is defined as an asynchronous function contained in a class that inherits from `DataService`. These tasks usually contain a while loop and are designed to carry out periodic functions.
|
In `pydase`, a task is defined as an asynchronous function contained in a class that inherits from `DataService`. These tasks usually contain a while loop and are designed to carry out periodic functions.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user