keithley-tempcontrol 0.16.14__tar.gz → 0.17.1__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.
Files changed (22) hide show
  1. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/PKG-INFO +1 -1
  2. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/pyproject.toml +1 -1
  3. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/egse/tempcontrol/keithley/daq6510_cs.py +12 -0
  4. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/egse/tempcontrol/keithley/daq6510_dev.py +21 -15
  5. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/egse/tempcontrol/keithley/daq6510_mon.py +1 -1
  6. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/egse/tempcontrol/keithley/daq6510_sim.py +17 -16
  7. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/keithley_tempcontrol/cgse_services.py +0 -1
  8. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/keithley_tempcontrol/settings.yaml +2 -0
  9. keithley_tempcontrol-0.16.14/temperature_readings.log +0 -1266
  10. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/.gitignore +0 -0
  11. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/README.md +0 -0
  12. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/justfile +0 -0
  13. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/noxfile.py +0 -0
  14. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/service_registry.db +0 -0
  15. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/egse/tempcontrol/keithley/__init__.py +0 -0
  16. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/egse/tempcontrol/keithley/daq6510.py +0 -0
  17. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/egse/tempcontrol/keithley/daq6510.yaml +0 -0
  18. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/egse/tempcontrol/keithley/daq6510_acs.py +0 -0
  19. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/egse/tempcontrol/keithley/daq6510_adev.py +0 -0
  20. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/egse/tempcontrol/keithley/daq6510_protocol.py +0 -0
  21. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/keithley_tempcontrol/__init__.py +0 -0
  22. {keithley_tempcontrol-0.16.14 → keithley_tempcontrol-0.17.1}/src/keithley_tempcontrol/cgse_explore.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: keithley-tempcontrol
3
- Version: 0.16.14
3
+ Version: 0.17.1
4
4
  Summary: Keithley Temperature Control for CGSE
5
5
  Author: IvS KU Leuven
6
6
  Maintainer-email: Rik Huygen <rik.huygen@kuleuven.be>, Sara Regibo <sara.regibo@kuleuven.be>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "keithley-tempcontrol"
3
- version = "0.16.14"
3
+ version = "0.17.1"
4
4
  description = "Keithley Temperature Control for CGSE"
5
5
  authors = [
6
6
  {name = "IvS KU Leuven"}
@@ -165,6 +165,10 @@ def start():
165
165
  multiprocessing.current_process().name = "daq6510_cs (start)"
166
166
 
167
167
  with remote_logging():
168
+ from egse.env import setup_env
169
+
170
+ setup_env()
171
+
168
172
  try:
169
173
  control_server = DAQ6510ControlServer()
170
174
  control_server.serve()
@@ -194,6 +198,10 @@ def stop():
194
198
 
195
199
  multiprocessing.current_process().name = "daq6510_cs (stop)"
196
200
 
201
+ from egse.env import setup_env
202
+
203
+ setup_env()
204
+
197
205
  try:
198
206
  with DAQ6510Proxy() as daq:
199
207
  sp = daq.get_service_proxy()
@@ -210,6 +218,10 @@ def status():
210
218
 
211
219
  multiprocessing.current_process().name = "daq6510_cs (status)"
212
220
 
221
+ from egse.env import setup_env
222
+
223
+ setup_env()
224
+
213
225
  endpoint = get_endpoint(SERVICE_TYPE, PROTOCOL, HOSTNAME, COMMANDING_PORT)
214
226
 
215
227
  if is_control_server_active(endpoint):
@@ -23,6 +23,9 @@ DEV_HOST = dev_settings.get("HOSTNAME")
23
23
  DEV_PORT = dev_settings.get("PORT")
24
24
  READ_TIMEOUT = dev_settings.get("TIMEOUT") # [s], can be smaller than timeout (for DAQ6510Proxy) (e.g. 1s)
25
25
 
26
+ SEPARATOR = b"\n"
27
+ SEPARATOR_STR = SEPARATOR.decode()
28
+
26
29
 
27
30
  class DAQ6510Command(ClientServerCommand):
28
31
  def get_cmd_string(self, *args, **kwargs) -> str:
@@ -36,7 +39,7 @@ class DAQ6510Command(ClientServerCommand):
36
39
  """
37
40
 
38
41
  out = super().get_cmd_string(*args, **kwargs)
39
- return out + "\n"
42
+ return out + SEPARATOR_STR
40
43
 
41
44
 
42
45
  class DAQ6510(DeviceInterface, DeviceTransport):
@@ -59,7 +62,7 @@ class DAQ6510(DeviceInterface, DeviceTransport):
59
62
 
60
63
  self._is_connection_open = False
61
64
 
62
- def initialize(self, commands: list[tuple[str, bool]] = None, reset_device: bool = False):
65
+ def initialize(self, commands: list[tuple[str, bool]] = None, reset_device: bool = False) -> list[str | None]:
63
66
  """Initialize the device with optional reset and command sequence.
64
67
 
65
68
  Performs device initialization by optionally resetting the device and then
@@ -74,21 +77,25 @@ class DAQ6510(DeviceInterface, DeviceTransport):
74
77
  the command sequence. Defaults to False.
75
78
 
76
79
  Returns:
77
- None
80
+ Response for each of the commands, or None when no response was expected.
78
81
 
79
82
  Raises:
80
83
  Any exceptions raised by the underlying write() or trans() methods,
81
84
  typically communication errors or device timeouts.
82
85
 
83
86
  Example:
84
- >>> device.initialize([
85
- ... ("*IDN?", True), # Query device ID, expect response
86
- ... ("SYST:ERR?", True), # Check for errors, expect response
87
- ... ("OUTP ON", False) # Enable output, no response expected
88
- ... ], reset_device=True)
87
+ responses = device.initialize(
88
+ [
89
+ ("*IDN?", True), # Query device ID, expect response
90
+ ("SYST:ERR?", True), # Check for errors, expect response
91
+ ("OUTP ON", False) # Enable output, no response expected
92
+ ],
93
+ reset_device=True
94
+ )
89
95
  """
90
96
 
91
97
  commands = commands or []
98
+ responses = []
92
99
 
93
100
  if reset_device:
94
101
  logger.info(f"Resetting the {self.device_name}...")
@@ -103,6 +110,8 @@ class DAQ6510(DeviceInterface, DeviceTransport):
103
110
  logger.debug(f"Sending {cmd}...")
104
111
  self.write(cmd)
105
112
 
113
+ return responses
114
+
106
115
  def is_simulator(self) -> bool:
107
116
  return False
108
117
 
@@ -239,7 +248,7 @@ class DAQ6510(DeviceInterface, DeviceTransport):
239
248
  """
240
249
 
241
250
  try:
242
- command += "\n" if not command.endswith("\n") else ""
251
+ command += SEPARATOR_STR if not command.endswith(SEPARATOR_STR) else ""
243
252
 
244
253
  self._sock.sendall(command.encode())
245
254
 
@@ -254,7 +263,7 @@ class DAQ6510(DeviceInterface, DeviceTransport):
254
263
  raise DeviceConnectionError(DEVICE_NAME, msg)
255
264
  raise
256
265
 
257
- def trans(self, command: str) -> str:
266
+ def trans(self, command: str) -> bytes:
258
267
  """Sends a single command to the device controller and block until a response from the controller.
259
268
 
260
269
  This is seen as a transaction.
@@ -273,7 +282,7 @@ class DAQ6510(DeviceInterface, DeviceTransport):
273
282
  try:
274
283
  # Attempt to send the complete command
275
284
 
276
- command += "\n" if not command.endswith("\n") else ""
285
+ command += SEPARATOR_STR if not command.endswith(SEPARATOR_STR) else ""
277
286
 
278
287
  self._sock.sendall(command.encode())
279
288
 
@@ -319,10 +328,7 @@ class DAQ6510(DeviceInterface, DeviceTransport):
319
328
  break
320
329
  except socket.timeout:
321
330
  logger.warning(f"Socket timeout error for {self.hostname}:{self.port}")
322
- return b"\r\n"
323
- except TimeoutError as exc:
324
- logger.warning(f"Socket timeout error: {exc}")
325
- return b"\r\n"
331
+ return SEPARATOR
326
332
  finally:
327
333
  self._sock.settimeout(saved_timeout)
328
334
 
@@ -399,7 +399,7 @@ class DAQ6510Monitor:
399
399
 
400
400
 
401
401
  class DAQMonitorClient:
402
- """Simple client for interacting with the DAQ Monitor Service."""
402
+ """A simple client for interacting with the DAQ Monitor Service."""
403
403
 
404
404
  def __init__(self, server_address: str = "localhost", port: int = DAQ_MON_CMD_PORT, timeout: float = 5.0):
405
405
  """Initialize the client.
@@ -1,21 +1,23 @@
1
- from __future__ import annotations
2
-
3
1
  import contextlib
4
2
  import datetime
5
- import logging
6
3
  import re
7
4
  import socket
8
5
  import time
6
+ from typing import Annotated
9
7
 
10
8
  import typer
9
+
10
+ from egse.log import logging
11
11
  from egse.settings import Settings
12
12
  from egse.system import SignalCatcher
13
13
 
14
- logger = logging.getLogger("daq6510-sim")
14
+ logger = logging.getLogger("egse.daq6510-sim")
15
15
 
16
16
  HOST = "localhost"
17
17
  DAQ_SETTINGS = Settings.load("Keithley DAQ6510")
18
18
 
19
+ SEPARATOR = b"\n"
20
+ SEPARATOR_STR = SEPARATOR.decode()
19
21
 
20
22
  device_time = datetime.datetime.now(datetime.timezone.utc)
21
23
  reference_time = device_time
@@ -79,7 +81,7 @@ COMMAND_PATTERNS_ACTIONS_RESPONSES = {
79
81
 
80
82
 
81
83
  def write(conn, response: str):
82
- response = f"{response}\n".encode()
84
+ response = f"{response}{SEPARATOR_STR}".encode()
83
85
  logger.debug(f"write: {response = }")
84
86
  conn.sendall(response)
85
87
 
@@ -196,7 +198,7 @@ def run_simulator():
196
198
  logger.info(f"{exc.__class__.__name__} caught: {exc.args}")
197
199
 
198
200
 
199
- def send_request(cmd: str, type_: str = "query"):
201
+ def send_request(cmd: str, cmd_type: str = "query") -> str | None:
200
202
  from egse.tempcontrol.keithley.daq6510_dev import DAQ6510
201
203
 
202
204
  response = None
@@ -204,12 +206,12 @@ def send_request(cmd: str, type_: str = "query"):
204
206
  daq_dev = DAQ6510(hostname="localhost", port=5025)
205
207
  daq_dev.connect()
206
208
 
207
- if type_.lower().strip() == "query":
209
+ if cmd_type.lower().strip() == "query":
208
210
  response = daq_dev.query(cmd)
209
- elif type_.lower().strip() == "write":
211
+ elif cmd_type.lower().strip() == "write":
210
212
  daq_dev.write(cmd)
211
213
  else:
212
- logger.info(f"Unknown type {type_} for send_request.")
214
+ logger.info(f"Unknown command type {cmd_type} for send_request.")
213
215
 
214
216
  daq_dev.disconnect()
215
217
 
@@ -234,15 +236,14 @@ def stop():
234
236
 
235
237
 
236
238
  @app.command()
237
- def command(type_: str, cmd: str):
238
- response = send_request(cmd, type_)
239
+ def command(
240
+ cmd: str,
241
+ cmd_type: Annotated[str, typer.Argument(help="either 'write', 'query'")] = "query",
242
+ ):
243
+ """Send an SCPI command directly to the simulator. The response will be in the log info."""
244
+ response = send_request(cmd, cmd_type)
239
245
  logger.info(f"{response}")
240
246
 
241
247
 
242
248
  if __name__ == "__main__":
243
- logging.basicConfig(
244
- level=logging.DEBUG,
245
- format="%(asctime)s %(threadName)-12s %(levelname)-8s %(name)-12s %(module)-20s %(message)s",
246
- )
247
-
248
249
  app()
@@ -2,7 +2,6 @@
2
2
  #
3
3
  import subprocess
4
4
  import sys
5
- from pathlib import Path
6
5
 
7
6
  import rich
8
7
  import typer
@@ -13,6 +13,8 @@ Keithley DAQ6510:
13
13
 
14
14
  Keithley Control Server:
15
15
 
16
+ SERVICE_TYPE: DAQ6510
17
+ PROCESS_NAME: daq6510_cs
16
18
  PROTOCOL: tcp
17
19
  HOSTNAME: localhost # The hostname that client shall connect to, e.g. pleiad01 @ KU Leuven
18
20
  COMMANDING_PORT: 6920 # The port on which the controller listens to commands - REQ-REP