Devantech dS378 Agent
This agent is designed to interface with devantech’s dS378 ethernet relay.
usage: python3 agent.py [-h] [--port PORT] [--ip_address IP_ADDRESS]
Agent Options
- --port
Port number for TCP communication.
Default: 17123
- --ip_address
IP address of the device.
Configuration File Examples
Below are configuration examples for the ocs config file and for running the Agent in a docker container.
OCS Site Config
An example site-config-file block:
{'agent-class': 'dS378Agent',
'instance-id': 'ds378',
'arguments': [['--port', 17123],
['--ip_address', '192.168.0.100']]
},
Docker Compose
The dS378 Agent should be configured to run in a Docker container. An example docker-compose service configuration is shown here:
ocs-ds378:
image: simonsobs/socs:latest
hostname: ocs-docker
network_mode: "host"
volumes:
- ${OCS_CONFIG_DIR}:/config:ro
environment:
- INSTANCE_ID=ds378
- LOGLEVEL=info
The LOGLEVEL environment variable can be used to set the log level for
debugging. The default level is “info”.
Description
dS378 is a board with 8 relays that can be cotrolled via ethernet. The relay can be used for both DC (up to 24 V) and AC (up to 250V). The electronics box for the stimulator uses this board to control shutter and powercycling devices such as motor controller or KR260 board.
The driver code assumes the board is configured to communicate with binary codes. This configuration can be changed via web interface (but requires USB connection as well, see documentation provided from the manufacturer). You can also configure the ip address and the port number with the same interface.
The device only accepts 10/100BASE communication.
Agent API
- class socs.agents.devantech_dS378.agent.DS378Agent(agent, ip, port=17123)[source]
OCS agent class for dS378 ethernet relay
- Parameters:
ip (string) – IP address
port (int) – Port number
- acq()[source]
Process - Monitor status of the relay.
- Parameters:
sampling_frequency (float, optional) – Sampling frequency in Hz, defaults to 0.5 Hz.
Notes
An example of the session data:
>>> response.session['data'] {'V_sppl': 11.8, 'T_int': 30.8, 'Relay_1': 0, 'Relay_2': ..., 'timestamp': 1736541796.779634 }
- set_relay(relay_number, on_off, pulse_time=None)[source]
Task - Turns the relay on/off or pulses it.
- Parameters:
relay_number (int) – Relay number to manipulate. Values must be in range [1, 8].
on_off (int) – 1 (0) to turn on (off).
pulse_time (int, optional) – Pulse time in ms. Values must be in range [0, 4294967295].
Notes
This command pulses relay for a given period when
pulse_timeargument is specified, otherwise just turns a relay on or off.
Supporting APIs
- class socs.agents.devantech_dS378.drivers.DS378(ip, port, timeout=10)[source]
dS378 ethernet relay
- get_status()[source]
Get status of the dS378 device.
- Returns:
d_status – Status information
- Return type:
dict
- set_relay(relay_number, on_off, pulse_time=0)[source]
Turns the relay on/off or pulses it
- Parameters:
relay_number (int) – relay_number, 1 – 8
on_off (int or RelayStatus) – 1: on, 0: off
pulse_time (int, 32 bit) – See document
- Returns:
status – 0: ACK otherwise: NACK
- Return type:
int
- set_output(io_num, on_off)[source]
Set output on/off
- Parameters:
io_num (int, 1 -- 7) – I/O port number
on_off (int or RelayStatus) – 1: on, 0: off
- get_relays()[source]
Get relay states
- Returns:
d_status
- Return type:
list of RelayStatus
- get_inputs()[source]
Get input states
- Returns:
d_status
- Return type:
list of RelayStatus