Skip to content

Commit

Permalink
Merge branch 'main' into syncbox
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvng committed Apr 22, 2024
2 parents 28b4114 + a8a5363 commit fc85f84
Show file tree
Hide file tree
Showing 72 changed files with 5,329 additions and 1,416 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@

version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
reviewers:
- "BrianJKoopman"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
reviewers:
- "BrianJKoopman"
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:

steps:
- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- '.flake8'
- '.pre-commit-config.yaml'
- '.readthedocs.yaml'
- '.github/dependabot.yml'

jobs:
test:
Expand Down Expand Up @@ -61,7 +62,7 @@ jobs:

steps:
- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- '.flake8'
- '.pre-commit-config.yaml'
- '.readthedocs.yaml'
- '.github/dependabot.yml'
workflow_call:

jobs:
Expand All @@ -18,7 +19,7 @@ jobs:

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected].0
uses: styfle/[email protected].1
with:
access_token: ${{ github.token }}

Expand All @@ -27,7 +28,7 @@ jobs:
sudo apt-get install -y socat
- name: Set up Python 3.8
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/skipped-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- '.flake8'
- '.pre-commit-config.yaml'
- '.readthedocs.yaml'
- '.github/dependabot.yml'

jobs:
test:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/skipped-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- '.flake8'
- '.pre-commit-config.yaml'
- '.readthedocs.yaml'
- '.github/dependabot.yml'

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- '.flake8'
- '.pre-commit-config.yaml'
- '.readthedocs.yaml'
- '.github/dependabot.yml'

jobs:
build:
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-ast
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/hhatto/autopep8
rev: v2.0.4
rev: v2.1.0
hooks:
- id: autopep8
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# A container setup with an installation of socs.

# Use the ocs image as a base
FROM simonsobs/ocs:v0.10.2
FROM simonsobs/ocs:v0.10.4

# Set up the cryo/smurf user and group so this can run on smurf-servers
# See link for how all other smurf-containers are set up:
Expand Down
2 changes: 1 addition & 1 deletion docker/pysmurf_controller/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM simonsobs/sodetlib:v0.5.2
FROM simonsobs/sodetlib:v0.5.2-20-gdd529b5

ENV OCS_CONFIG_DIR /config

Expand Down
86 changes: 86 additions & 0 deletions docs/agents/acti_camera.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
.. highlight:: rst

.. _acti_camera:

====================
ACTi Camera Agent
====================

The ACTi Camera Agent is an OCS Agent which grabs screenshots from ACTi cameras
and saves files to a directory.

.. argparse::
:filename: ../socs/agents/acti_camera/agent.py
:func: add_agent_args
:prog: python3 agent.py

Configuration File Examples
---------------------------

Below are configuration examples for the ocs config file and for running the
Agent in a docker container.

OCS Site Config
```````````````

To configure the ACTi Camera Agent we need to add a ACTiCameraAgent
block to our ocs configuration file. Here is an example configuration block
using all of the available arguments::

{'agent-class': 'ACTiCameraAgent',
'instance-id': 'cameras',
'arguments': [['--mode', 'acq'],
['--camera-addresses', ['10.10.10.41', '10.10.10.42', '10.10.10.43']],
['--locations', ['location1', 'location2', 'location3']],
['--resolutions', ['N640x480,100', 'N640x480,100', 'N640x480,100']],
['--user', 'admin'],
['--password', 'password']]},

.. note::
The ``--camera-addresses`` argument should be a list of the IP addresses
of the cameras on the network.
The ``--locations`` argument should be a list of names for camera locations.
This should be in the same order as the list of IP addresses.
The ``--resolutions`` argument should be a list of resolutions for each camera.
For example, ``N640x480,100`` gives a 640x480 image with 100% quality.

Docker Compose
``````````````

The iBootbar Agent should be configured to run in a Docker container. An
example docker-compose service configuration is shown here::

ocs-cameras:
image: simonsobs/socs:latest
hostname: ocs-docker
environment:
- INSTANCE_ID=cameras
- SITE_HUB=ws://127.0.0.1:8001/ws
- SITE_HTTP=http://127.0.0.1:8001/call
- LOGLEVEL=info
volumes:
- ${OCS_CONFIG_DIR}:/config:ro
- /mnt/nfs/data/cameras:/screenshots
user: 9000:9000

The ``LOGLEVEL`` environment variable can be used to set the log level for
debugging. The default level is "info".
The volume must mount to ``/screenshots``. The user must have permissions to write
to the mounted local directory.

Description
-----------

The ACTi cameras will be used to monitor conditions at the SO site.
The ACTi Camera Agent periodically (1 minute) grabs screenshots from each
camera on the network. The images are saved to a location on disk. A webserver
should then be configured to serve this directory to some URL. Then we can use
HTML to access the webserver and display ``latest.jpg`` for an up-to-date
view of the camera. For example, this can be done directly in Grafana
using the Text panel in HTML mode.

Agent API
---------

.. autoclass:: socs.agents.acti_camera.agent.ACTiCameraAgent
:members:
70 changes: 70 additions & 0 deletions docs/agents/acu_agent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ installed to use this Agent. This can be installed via:
$ pip install 'soaculib @ git+https://github.com/simonsobs/soaculib.git@master'
Additionally, ``socs`` should be installed with the ``acu`` group:

.. code-block:: bash
$ pip install -U socs[acu]
Configuration File Examples
---------------------------
Below are configuration examples for the ocs config file and for soaculib.
Expand Down Expand Up @@ -88,6 +94,61 @@ example configuration block is below::
}


Sun Avoidance
-------------

The Sun's position, and the potential danger of the Sun to the
equipment, is monitored and reported by the ``monitor_sun`` Process.
If enabled to do so, this Process can trigger the ``escape_sun_now``
Task, which will cause the platform to move to a Sun-safe position.

The parameters used by an Agent instance for Sun Avoidance are
determined like this:

- Default parameters for each platform (LAT and SATP) are in the Agent
code.
- On start-up the default parameters for platform are modified
according to any command-line parameters passed in by the user.
- Some parameters can be altered using the command line.

The avoidance policy is defined by a few key parameters and concepts;
please see the descriptions of ``sun_dist``, ``sun_time``,
``exclusion_radius``, and more in the :mod:`socs.agents.acu.avoidance`
module documentation.

The ``exclusion_radius`` can be configured from the Agent command
line, and also through the ``update_sun`` Task.

When Sun Avoidance is active (``active_avoidance`` is ``True``), the
following will be enforced:

- When a user initiates the ``go_to`` Task, the target point of the
motion will be checked. If it is not Sun-safe, the Task will exit
immediately with an error. If the Task cannot find a set of moves
that are Sun-safe and that do not violate other requirements
(azimuth and elevation limits; the ``el_dodging`` policy), then the
Task will exit with error. The move may be executed as a series of
separate legs (e.g. the Task may move first to an intermediate
elevation, then slew in azimuth, then continue to the final
elevation) rather than simulataneously commanding az and el motion.
- When a user starts the ``generate_scan`` Process, the sweep of the
scan will be checked for Sun-safety, and the Process will exit with
error if it is not. Furthermore, any movement required prior to
starting the scan will be checked in the same way as for the
``go_to`` Task.
- If the platform, at any time, enters a position that is not
Sun-safe, then an Escape will be Initiated. During an Escape, any
running ``go_to`` or ``generate_scan`` operations will be cancelled,
and further motions are blocked. The platform will be driven to a
position at due North or due South. The current elevation of the
platform will be preserved, unless that is not Sun-safe (in which
case lower elevations will be attempted). The Escape feature is
active, even when motions are not in progress, as long as the
``monitor_sun`` Process is running. However -- the Escape operation
requires that the platform be in Remote operation mode, with no
persistent faults.


Exercisor Mode
--------------

Expand Down Expand Up @@ -149,5 +210,14 @@ acquisition processes are running::
Supporting APIs
---------------

drivers (Scanning support)
``````````````````````````

.. automodule:: socs.agents.acu.drivers
:members:

avoidance (Sun Avoidance)
`````````````````````````

.. automodule:: socs.agents.acu.avoidance
:members:
87 changes: 87 additions & 0 deletions docs/agents/hi6200.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
.. highlight:: rst

.. _Hi6200:

==============
Hi6200 Agent
==============

This agent uses Modbus TCP to communicate with the Hi6200 Weight Sensor.
This agent uses ModbusClient from pyModbusTCP to facilitate the communication.
The agent is able to communicate over ethernet to read and monitor the net and
gross weights of the scale.

.. argparse::
:filename: ../socs/agents/hi6200/agent.py
:func: make_parser
:prog: python3 agent.py


Configuration File Examples
---------------------------
Below are configuration examples for the ocs config file and for running the
Agent in a docker container.

OCS Site Config
```````````````

To configure the Hi6200 Agent we need to add a block to our ocs
configuration file. Here is an example configuration block using all of
the available arguments::

{'agent-class': 'Hi6200Agent',
'instance-id': 'hi6200',
'arguments': [
['--ip-address', '192.168.11.43'],
['--tcp-port', '502']
]},

The Hi6200 Agent requires the IP address and ModbusTCP port of the Hi6200
in order to connect to the Hi6200. The default ModbusTCP port on the Hi6200
is 502.

Docker Compose
``````````````

The SCPI PSU Agent should be configured to run in a Docker container.
An example docker-compose service configuration is shown here::

ocs-hi6200:
image: simonsobs/socs:latest
hostname: ocs-docker
network_mode: "host"
environment:
- INSTANCE_ID=hi6200
volumes:
- ${OCS_CONFIG_DIR}:/config:ro

Agent API
---------

.. autoclass:: socs.agents.hi6200.agent.Hi6200Agent
:members:

Example Clients
---------------

Below is an example client demonstrating full agent functionality.::

from ocs.ocs_client import OCSClient

# Initialize the power supply
scale = OCSClient('hi6200')
scale.init.start()
scale.init.wait()

# Begin Monitoring Weight
scale.monitor_weight.start()

#Stop Monitoring Weight
scale.stop_monitoring.start()

Supporting APIs
---------------

.. autoclass:: socs.agents.hi6200.drivers.Hi6200Interface
:members:
:noindex:
Loading

0 comments on commit fc85f84

Please sign in to comment.