dbay 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
dbay-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.1
2
+ Name: dbay
3
+ Version: 0.1.0
4
+ Summary: A python library for interacting with the Device Bay VME racks. This library communicates with the local Device Bay webserver, which runs the user interface and keeps it in sync with changes made by this library
5
+ Author-email: Andrew Mueller <andrewstermueller@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/bkorzh/dbay
8
+ Project-URL: Documentation, https://bkorzh.github.io/dbay/
9
+ Keywords: dbay,client,api
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: pydantic>=2.10.6
20
+ Requires-Dist: requests>=2.32.3
21
+
22
+ # dbay-client/README.md
23
+
24
+ # DBay Client
25
+
26
+ DBay is a Python client for interacting with the DBay web server. This client allows you to manage and control various modules such as `dac4D` and `dac16D` through a simple interface.
27
+
28
+ ## Installation
29
+
30
+ To install the DBay client, clone the repository and install the required dependencies:
31
+
32
+ ```bash
33
+ git clone <repository-url>
34
+ cd dbay-client
35
+ pip install -e .
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ To use the DBay client, you need to create an instance of the `DBay` class with the server address (IP address and port). The client will automatically call the `/full-state` endpoint to retrieve the current state of the server.
41
+
42
+ ```python
43
+ from src.client import DBay
44
+
45
+ # Initialize the client with the server address
46
+ client = DBay("0.0.0.0", port=8345)
47
+
48
+ # Access the modules
49
+ modules = client.modules
50
+ ```
51
+
52
+ ## Modules
53
+
54
+ The client supports the following modules:
55
+
56
+ - **dac4D**: Represents a DAC4D module and includes methods for controlling its functionality.
57
+ - **dac16D**: Represents a DAC16D module and includes methods for controlling its functionality.
58
+ - **Empty**: Represents an empty module.
59
+
60
+ ## Contributing
61
+
62
+ Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.
63
+
64
+ ## License
65
+
66
+ This project is licensed under the MIT License. See the LICENSE file for more details.
dbay-0.1.0/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # dbay-client/README.md
2
+
3
+ # DBay Client
4
+
5
+ DBay is a Python client for interacting with the DBay web server. This client allows you to manage and control various modules such as `dac4D` and `dac16D` through a simple interface.
6
+
7
+ ## Installation
8
+
9
+ To install the DBay client, clone the repository and install the required dependencies:
10
+
11
+ ```bash
12
+ git clone <repository-url>
13
+ cd dbay-client
14
+ pip install -e .
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ To use the DBay client, you need to create an instance of the `DBay` class with the server address (IP address and port). The client will automatically call the `/full-state` endpoint to retrieve the current state of the server.
20
+
21
+ ```python
22
+ from src.client import DBay
23
+
24
+ # Initialize the client with the server address
25
+ client = DBay("0.0.0.0", port=8345)
26
+
27
+ # Access the modules
28
+ modules = client.modules
29
+ ```
30
+
31
+ ## Modules
32
+
33
+ The client supports the following modules:
34
+
35
+ - **dac4D**: Represents a DAC4D module and includes methods for controlling its functionality.
36
+ - **dac16D**: Represents a DAC16D module and includes methods for controlling its functionality.
37
+ - **Empty**: Represents an empty module.
38
+
39
+ ## Contributing
40
+
41
+ Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.
42
+
43
+ ## License
44
+
45
+ This project is licensed under the MIT License. See the LICENSE file for more details.
@@ -0,0 +1,2 @@
1
+ # filepath: /Users/andrew/Documents/PROGRAM_LOCAL/dbay/software/backend/dbay-client/src/__init__.py
2
+ # This file is intentionally left blank.
@@ -0,0 +1,35 @@
1
+ from dbay.modules.dac4d import dac4D
2
+ from dbay.modules.dac16d import dac16D
3
+ from dbay.modules.empty import Empty
4
+ from dbay.http import Http
5
+ import time
6
+ from typing import List, Union
7
+
8
+
9
+ class DBay:
10
+ def __init__(self, server_address: str, port: int = 8345):
11
+ self.server_address = server_address
12
+ self.port = port
13
+ self.modules: List[Union[dac4D, dac16D, Empty]] = [None] * 8
14
+ self.http = Http(server_address, port)
15
+ self.load_full_state()
16
+
17
+ def load_full_state(self):
18
+ response = self.http.get("full-state")
19
+ self.instantiate_modules(response["data"])
20
+
21
+ def instantiate_modules(self, module_data: list):
22
+ for i, module_info in enumerate(module_data):
23
+ module_type = module_info["core"]["type"]
24
+ if module_type == "dac4D":
25
+ # print("info about dac4D class:"
26
+ self.modules[i] = dac4D(module_info, self.http)
27
+ elif module_type == "dac16D":
28
+ self.modules[i] = dac16D(module_info, self.http)
29
+ else:
30
+ self.modules[i] = Empty()
31
+
32
+ def get_modules(self):
33
+ return self.modules
34
+
35
+ # Additional methods to interact with the modules can be added here.
@@ -0,0 +1,23 @@
1
+ import requests
2
+
3
+
4
+ class Http:
5
+ def __init__(self, server_address: str, port: int):
6
+ self.server_address = server_address
7
+ self.port = port
8
+
9
+ def get(self, endpoint: str):
10
+ response = requests.get(f"http://{self.server_address}:{self.port}/{endpoint}")
11
+ if response.status_code == 200:
12
+ return response.json()
13
+ else:
14
+ raise Exception(f"Failed to get data from {endpoint}")
15
+
16
+ def put(self, endpoint: str, data: dict):
17
+ response = requests.put(
18
+ f"http://{self.server_address}:{self.port}/{endpoint}", json=data
19
+ )
20
+ if response.status_code == 200:
21
+ return response.json()
22
+ else:
23
+ raise Exception(f"Failed to put data to {endpoint}")
@@ -0,0 +1,17 @@
1
+ from pydantic import BaseModel
2
+ from typing import Literal
3
+
4
+
5
+ class Core(BaseModel):
6
+ slot: int
7
+ type: str
8
+ name: str
9
+
10
+
11
+ class IModule(BaseModel):
12
+ core: Core
13
+
14
+
15
+ class Empty(IModule):
16
+ module_type: Literal["empty"] = "empty"
17
+ core: Core
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.1
2
+ Name: dbay
3
+ Version: 0.1.0
4
+ Summary: A python library for interacting with the Device Bay VME racks. This library communicates with the local Device Bay webserver, which runs the user interface and keeps it in sync with changes made by this library
5
+ Author-email: Andrew Mueller <andrewstermueller@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/bkorzh/dbay
8
+ Project-URL: Documentation, https://bkorzh.github.io/dbay/
9
+ Keywords: dbay,client,api
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: pydantic>=2.10.6
20
+ Requires-Dist: requests>=2.32.3
21
+
22
+ # dbay-client/README.md
23
+
24
+ # DBay Client
25
+
26
+ DBay is a Python client for interacting with the DBay web server. This client allows you to manage and control various modules such as `dac4D` and `dac16D` through a simple interface.
27
+
28
+ ## Installation
29
+
30
+ To install the DBay client, clone the repository and install the required dependencies:
31
+
32
+ ```bash
33
+ git clone <repository-url>
34
+ cd dbay-client
35
+ pip install -e .
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ To use the DBay client, you need to create an instance of the `DBay` class with the server address (IP address and port). The client will automatically call the `/full-state` endpoint to retrieve the current state of the server.
41
+
42
+ ```python
43
+ from src.client import DBay
44
+
45
+ # Initialize the client with the server address
46
+ client = DBay("0.0.0.0", port=8345)
47
+
48
+ # Access the modules
49
+ modules = client.modules
50
+ ```
51
+
52
+ ## Modules
53
+
54
+ The client supports the following modules:
55
+
56
+ - **dac4D**: Represents a DAC4D module and includes methods for controlling its functionality.
57
+ - **dac16D**: Represents a DAC16D module and includes methods for controlling its functionality.
58
+ - **Empty**: Represents an empty module.
59
+
60
+ ## Contributing
61
+
62
+ Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.
63
+
64
+ ## License
65
+
66
+ This project is licensed under the MIT License. See the LICENSE file for more details.
@@ -0,0 +1,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ dbay/__init__.py
4
+ dbay/client.py
5
+ dbay/http.py
6
+ dbay/state.py
7
+ dbay.egg-info/PKG-INFO
8
+ dbay.egg-info/SOURCES.txt
9
+ dbay.egg-info/dependency_links.txt
10
+ dbay.egg-info/requires.txt
11
+ dbay.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ pydantic>=2.10.6
2
+ requests>=2.32.3
@@ -0,0 +1 @@
1
+ dbay
@@ -0,0 +1,35 @@
1
+ [project]
2
+ name = "dbay"
3
+ version = "0.1.0"
4
+ description = "A python library for interacting with the Device Bay VME racks. This library communicates with the local Device Bay webserver, which runs the user interface and keeps it in sync with changes made by this library"
5
+
6
+
7
+ readme = "README.md"
8
+ requires-python = ">=3.8"
9
+ dependencies = [
10
+ "pydantic>=2.10.6",
11
+ "requests>=2.32.3",
12
+ ]
13
+ authors = [
14
+ {name = "Andrew Mueller", email = "andrewstermueller@gmail.com"},
15
+ ]
16
+ license = {text = "MIT"}
17
+ keywords = ["dbay", "client", "api"]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Intended Audience :: Developers",
21
+ "License :: OSI Approved :: MIT License",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ ]
27
+ urls = {Homepage = "https://github.com/bkorzh/dbay", Documentation = "https://bkorzh.github.io/dbay/"}
28
+
29
+ [build-system]
30
+ requires = ["setuptools>=61.0", "wheel"]
31
+ build-backend = "setuptools.build_meta"
32
+
33
+ [tool.setuptools]
34
+ packages = ["dbay"]
35
+
dbay-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+