Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified asyncroscopy/.DS_Store
Binary file not shown.
15 changes: 10 additions & 5 deletions asyncroscopy/instruments/electron_microscope/auto_script.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that SEM's might get confused in this hierarchy.

Shouldnt the parent dir be Transmission_electron_microscope

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are probably right. Future problem I think

Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,20 @@ class AutoScriptMicroscope(ElectronMicroscope):
# ------------------------------------------------------------------
# Device properties — configure in Tango DB per deployment
# ------------------------------------------------------------------
autoscript_host_ip = device_property(
hardware_host = device_property(
dtype=str,
default_value="10.46.217.241",
doc="Hostname or IP of the AutoScript microscope server",
)
autoscript_host_port = device_property(
hardware_port = device_property(
dtype=int,
default_value=9095,
doc="Hostname or IP of the AutoScript microscope server",
doc="Port of the AutoScript microscope server",
)
hardware_timeout_seconds = device_property(
dtype=int,
default_value=120,
doc="Hardware connection timeout in seconds.",
)
acquisition_save_directory = device_property(
dtype=str,
Expand Down Expand Up @@ -156,8 +161,8 @@ def _connect_hardware(self) -> None:
return
try:
self._microscope = TemMicroscopeClient()
self._microscope.connect(self.autoscript_host_ip, self.autoscript_host_port)
self.info_stream(f"Connected to AutoScript at {self.autoscript_host_ip}:{self.autoscript_host_port}")
self._microscope.connect(self.hardware_host, self.hardware_port)
self.info_stream(f"Connected to AutoScript at {self.hardware_host}:{self.hardware_port}")
self.is_autoscript = True
except Exception as e:
self.error_stream(f"AutoScript connection failed: {e}")
Expand Down
9 changes: 7 additions & 2 deletions asyncroscopy/instruments/electron_microscope/jeol.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,21 @@ class JeolMicroscope(ElectronMicroscope):
dedicated detector devices and read via DeviceProxy at acquisition time.
"""

pyjem_host_ip = device_property(
hardware_host = device_property(
dtype=str,
default_value='10.46.217.241',
doc='Hostname or IP of the JEOL microscope control server.',
)
pyjem_host_port = device_property(
hardware_port = device_property(
dtype=int,
default_value=9095,
doc='Port of the JEOL microscope control server.',
)
hardware_timeout_seconds = device_property(
dtype=int,
default_value=120,
doc='Hardware connection timeout in seconds.',
)
acquisition_save_directory = device_property(
dtype=str,
default_value=DEFAULT_ACQUISITION_DIR,
Expand Down
3 changes: 2 additions & 1 deletion configs/hackathon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ devices:
tango:
host: 127.0.0.1
port: 9094
reset_database_file: true
tiled:
host: 127.0.0.1
port: 9091
acquisition_dir: /Users/austin/Downloads/18167694/hackathon_data
acquisition_dir: /Users/austin/Desktop/18167694/hackathon_data
autostart: true
device_timeout_seconds: 120
6 changes: 3 additions & 3 deletions docs/MCP/mcp_server.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Asyncroscopy MCP Server

The MCP server is a FastMCP HTTP bridge over the live Tango database. It should
start after the Tango database, support devices, Tiled, and microscope or
digital twin are ready.
start after the Tango database, support devices, Tiled, and selected instrument
are ready.

## Start It

Start the device stack first:

```bash
uv run startup_scripts/run_servers.py --yaml configs/Spectra300.yaml
uv run startup_scripts/run_servers.py --yaml configs/Spectra300.yaml --microscope dt
uv run startup_scripts/run_servers.py --yaml configs/STEMDigitalTwin.yaml
```
Comment on lines 11 to 14

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I will check with other configs.


Then start MCP in another terminal or on the MCP computer:
Expand Down
32 changes: 15 additions & 17 deletions docs/Operation/run-servers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
`startup_scripts/run_servers.py` starts the Tango/device side of asyncroscopy. It
clears stale processes, starts the Tango database, registers devices, launches
device servers, starts the DATA-managed Tiled HTTP server, and starts the
microscope or digital twin last.
selected instrument last.

MCP is started separately with `startup_scripts/run_mcp.py`; see
[mcp_server.md](../MCP/mcp_server.md).
Expand All @@ -12,10 +12,9 @@ MCP is started separately with `startup_scripts/run_mcp.py`; see

```bash
uv run startup_scripts/run_servers.py
uv run startup_scripts/run_servers.py --microscope dt

uv run startup_scripts/run_servers.py --yaml configs/Spectra300.yaml
uv run startup_scripts/run_servers.py --yaml configs/Spectra300.yaml --microscope dt
uv run startup_scripts/run_servers.py --yaml configs/STEMDigitalTwin.yaml
uv run startup_scripts/run_servers.py --yaml configs/ThinkPad-utkarsh-covalent-setup.yaml
```

Expand All @@ -40,11 +39,11 @@ uv run startup_scripts/run_mcp.py --yaml configs/mcp.yaml
|-------|-----------|------------|
| 1 | support devices | `asyncroscopy/{camera,corrector,data,eds,flucam,scan,stage}/default` |
| 2 | Tiled HTTP server | started through the `data` device |
| 3 | microscope or digital twin | `asyncroscopy/microscope/default` |
| 3 | instrument | `asyncroscopy/instrument/default` |

The microscope starts last because it depends on the support devices. The runner
writes support-device addresses into Tango database properties before the
microscope starts. In `real` mode it also writes the AutoScript host and port.
The instrument starts last because it depends on the support devices. The runner
writes support-device addresses and hardware connection values into Tango
database properties before the instrument starts.

## Server GUI

Expand All @@ -53,7 +52,7 @@ does not start servers directly. It formats the current selections into YAML,
writes that YAML to `outputs/startup_configs/server_gui.yaml`, and runs:

```bash
uv run python startup_scripts/run_servers.py --yaml outputs/startup_configs/server_gui.yaml --microscope <real-or-dt>
uv run python startup_scripts/run_servers.py --yaml outputs/startup_configs/server_gui.yaml
```

The GUI includes:
Expand All @@ -74,16 +73,15 @@ Server startup configs live in [configs/](../../configs):

Each server config has:

- `microscope:` for the real microscope.
- `digital_twin:` for `--microscope dt`.
- `instrument:` for the selected instrument class, Python file, and hardware connection values.
- `devices:` for support device modules.
- `tango:` for the Tango database host, port, and optional database-file reset.
- `tiled:` for the DATA-managed Tiled HTTP server.
- `device_timeout_seconds:` for device readiness waits.

Device `class_name` defaults to the upper-cased key (`scan` becomes `SCAN`).
`microscope.host` and `microscope.port` become the microscope device's
`autoscript_host_ip` and `autoscript_host_port` properties.
`instrument.hardware_host`, `instrument.hardware_port`, and
`instrument.timeout_seconds` become instrument device properties.

Set `tango.reset_database_file: true` to delete a stale local
`tango_database.db` / `Tango_database.db` before starting the Tango database.
Expand Down Expand Up @@ -118,18 +116,18 @@ Interactive mode is used only when `--yaml` is omitted. The defaults come from
| Start Tiled HTTP server | Whether DATA starts its managed Tiled server. |
| Clear old processes first | Frees stale Tango/Tiled ports and old device servers. |
| Start Tango database | Starts the DB or waits for an existing one. |
| Register devices | Adds device entries and microscope properties to the DB. |
| Register devices | Adds device entries and instrument properties to the DB. |
| Device startup timeout seconds | How long to wait for each device to answer `ping()`. |
| AutoScript host IP / port | Real microscope mode only. |
| Hardware host / port / timeout seconds | Connection values for the selected instrument. |

## Startup Stages

1. **Clearing old processes** frees the database/Tiled ports and kills old device
server process groups.
2. **Starting Tango database** starts or waits for the database server.
3. **Registering devices** writes device entries and microscope properties.
3. **Registering devices** writes device entries and instrument properties.
4. **Starting device servers** starts support devices, Tiled, and then the
microscope or digital twin.
selected instrument.
5. **Startup summary** prints `TANGO_HOST`, PIDs, ready times, and the Tiled URI.

## Manual Fallback
Expand All @@ -141,7 +139,7 @@ TANGO_HOST=localhost:9094 uv run python -m tango.databaseds.database 2

export TANGO_HOST=localhost:9094
uv run python -m asyncroscopy.instruments.electron_microscope.hardware.scan scan_instance
uv run python -m asyncroscopy.instruments.electron_microscope.auto_script microscope_instance
uv run python -m asyncroscopy.instruments.electron_microscope.auto_script instrument_instance
```

Manual device startup requires the devices to already be registered in Tango.
Expand Down
Loading