From 713ef3170fb8f7416d7f1e9ee8f9ae90340099f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Wed, 2 Aug 2023 16:23:26 +0200 Subject: [PATCH] Updating Readme: adding rpyc usage section --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 89b116e..59ded80 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ pip install git+https://github.com/tiqi-group/pydase.git ## 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 @@ -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. +### 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("", 18871) +client = conn.root + +# Interact with the service +client.voltage = 5.0 +print(client.voltage) # prints 5.0 +``` + +In this example, replace `` 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 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.