Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reorganize project structure and add READMEs #21

Draft
wants to merge 23 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
238 changes: 141 additions & 97 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,145 @@
# EBEAM System Dashboard Software

### 1. Development Workflow

![GUI layout diagram](media/GUI_layout.png)

### 1. Core Architecture and Flow

- **High-level Design**: The application is divided into several modules:
- **main.py**: Entry point that initializes the COM port configuration and launches the dashboard
- **dashboard.py**: Core dashboard class that sets up the main GUI layout and manages subsystems
- **instrumentctl/**: Instrument-specific command libraries.
- **subsystem/**: Contains classes and methods to manage individual hardware subsystems (e.g., VTRXSubsystem, EnvironmentalSubsystem).
- **utils.py**: Utility functions and classes that support the main application (Logging, setup scripts, etc.).

```mermaid
flowchart TD
Start([python main.py]) --> PortConfig[Show Port Configuration Dialog]
PortConfig --> SaveConfig[Save Port Configuration]

%% Main Dashboard Setup
SaveConfig --> InitDash[Initialize Dashboard]
InitDash --> SetupPane[Create Main Pane Structure]
SetupPane --> LoadLayout[Load Saved Layout]
LoadLayout --> CreateFrames[Create Frame Structure]

%% Core Components
CreateFrames --> Messages[Messages Frame]
CreateFrames --> Controls[Main Controls]
CreateFrames --> SubSystems[[Subsystem Initialization]]

%% Subsystems Detail
SubSystems --> Vacuum[Vacuum System]
SubSystems --> Environmental[Environmental]
SubSystems --> Gas[Gas Control]
SubSystems --> Interlocks[Interlocks]
SubSystems --> Oil[Oil System]
SubSystems --> Cathode[Cathode Heating]

%% Control Components
Controls --> MainTab[Main Control Tab]
Controls --> ConfigTab[Configuration Tab]

%% Monitoring Loop
CreateFrames --> Monitor[[Start COM Port Monitor Loop]]
Monitor --> CheckChanges{Port Changes?}
CheckChanges -->|Yes| UpdateSys[Update Affected Systems]
UpdateSys --> CheckChanges
CheckChanges -->|No| Continue[Continue Monitoring]
Continue --> CheckChanges
```

### 2. Dashboard (dashboard.py)

- **EBEAMSystemDashboard Class**: The main class that sets up the dashboard interface.
- Implements a flexible, configurable layout system using Tkinter's PanedWindow container widget.
- Allows users to arrange and resize different control sections at run-time.
- Each subsystem occupies its own configurable space

### 3. Subsystems

- **`vtrx/vtrx.py`**:
- Manages the VTRX system, including serial communication and error handling.
- Displays pressure data and switch states, updating the GUI in real-time.
- Logs messages and errors to the messages frame.

- **`environmental/environmental.py`**:
- Monitors and displays temperature data from various thermometers.

- **`interlocks/interlocks.py`**:
- Monitors the status of various safety critical interlocks (e.g., Vacuum, Water, Door sensors).
- Updates GUI indicators based on interlock status.

- **`oil_system/oil_system.py`**:
- Monitors and displays oil temperature and pressure.

- **`cathode_heating/cathode_heating.py`**:
- Manages three independent cathode heating channels
- Power supply control interface
- Real-time temperature plotting with overtemp indication

- **`visualization_gas_control.py`**:
- Controls the Argon bleed system via serial communication.
- TBD


### 4. Utilities (`utils.py`)

- **MessagesFrame Class**:
- A custom Tkinter frame for displaying messages and errors.
- Supports logging messages with timestamps and trimming old messages to maintain a maximum number of lines.

- **TextRedirector Class**:
- Redirects stdout to a Tkinter Text widget.
- Ensures that all print statements in the application are displayed in the messages frame.

- **SetupScripts Class**:
- Manages the selection and execution of configuration scripts.
- Provides a GUI for selecting scripts from a dropdown menu and executing them.

### 5. Directory Structure:
```
EBEAM_DASHBOARD/
├── README.md
├── __init__.py
├── dashboard.py
├── instrumentctl/
│ ├── README.md
│ ├── __init__.py
│ ├── power_supply/
│ │ ├── README.md
│ │ └── power_supply_9014.py
│ ├── G9_driver/
│ │ ├── README.md
│ │ └── G9_driver.py
│ └── E5CN_modbus/
│ ├── README.md
│ └── E5CN_modbus.py
├── main.py
├── subsystem/
│ ├── __init__.py
│ ├── cathode_heating/
│ │ ├── README.md
│ │ └── cathode_heating.py
│ ├── environmental/
│ │ ├── README.md
│ │ └── environmental.py
│ ├── interlocks/
│ │ ├── README.md
│ │ └── interlocks.py
│ ├── oil_system/
│ │ ├── README.md
│ │ └── oil_system.py
│ ├── visualization_gas_control/
│ │ ├── README.md
│ │ └── visualization_gas_control.py
│ └── vtrx/
│ ├── README.md
│ └── vtrx.py
└── utils.py
```

### 6. Development Workflow
![branching](https://github.com/mslaffin/EBEAM_dashboard/blob/main/media/branching_diagram.png)
#### Branching strategy
All code development intended to impact a future release is done on the latest `develop` branch. This applies to new instrument features, bug fixes, etc. The `develop` branch is **not stable**.
Expand Down Expand Up @@ -56,102 +195,7 @@ Fill in the PR template with a description of your changes, any related issues,

Assign reviewers to your PR. Merge.

### 2. Executable Build Instructions
### 6. Executable Build Instructions
```
python -m PyInstaller EBEAM_DASHBOARD.spec
```

### 3. Architecture
![GUI layout diagram](https://github.com/uw-loci/EBEAM_dashboard/blob/main/media/GUI_layout.png)
- **Language & Libraries**: Python, using the [Tkinter](https://docs.python.org/3/library/tkinter.html) interface for the GUI, [matplotlib](https://matplotlib.org/) for plotting, and [Pyserial](https://pythonhosted.org/pyserial/) for communication with external systems through virtual COM ports.
- **High-level Design**: The application is divided into several modules:
- **main.py**: Manages the main application startup and configuration.
- **dashboard.py**: Handles the main user interface and dashboard setup.
- **instrumentctl/**: Instrument specific command libraries.
- **subsystem/**: Contains classes and methods to manage individual subsystems (e.g., VTRXSubsystem, EnvironmentalSubsystem).
- **utils.py**: Utility functions and classes that support the main application (Logging, setup scripts, etc.).
- Core Structure:
```
EBEAM_DASHBOARD/
├── __init__.py
├── dashboard.py
├── instrumentctl/
│ ├── __init__.py
│ ├── apex_mass_flow_controller.py
│ └── power_supply_9014.py
├── main.py
├── subsystem/
│ ├── __init__.py
│ ├── cathode_heating.py
│ ├── environmental.py
│ ├── interlocks.py
│ ├── oil_system.py
│ ├── visualization_gas_control.py
│ └── vtrx.py
└── utils.py
```

### 4. Components

- **Main Application (main.py)**:
- **Configuration Loader**: Responsible for initial configurations, setting up COM ports, and starting the main dashboard.
- **COM Port Configuration**: Dynamically detects and assigns COM ports for various hardware interfaces. TODO: Write dropdowns for additional subsystems.

- **Instrument Control (instrumentctl.py)**:
- **Equipment specific driver libraries**:
- 9104 Cathode Heating Power Supplies [(datasheet)](https://bkpmedia.s3.us-west-1.amazonaws.com/downloads/programming_manuals/en-us/9103_9104_programming_manual.pdf) IN PROGRESS
- E5CN Cathode Temperature Controller [(datasheet)]() IN PROGRESS
- Apex Mass Flow Controller [(datasheet)]() IN PROGRESS
- TODO: Agilent 33120A [(datasheet)]()
- TODO: Quantum 9530
- TODO: G9SP serial option (status door, e-stops, vac, levels, timer)
- VTRX system
- TODO: Temp monitor
- TODO: A655sc
- TODO: BOP-100-2ML

### 5. Dashboard (dashboard.py)

- **EBEAMSystemDashboard Class**: The main class that sets up the dashboard interface.
- **`setup_main_pane`**: Initializes the main layout pane and its rows.
- **`create_frames`**: Creates frames for different systems and controls within the dashboard.
- **`create_messages_frame`**: Creates a frame for displaying messages and errors.
- **`create_subsystems`**: Initializes subsystems in their designated frames using component settings.

### 5. Subsystems

- **`vtrx.py`**:
- Manages the VTRX system, including serial communication and GUI updates.
- Handles pressure data and switch states, updating the GUI in real-time.
- Logs messages and errors to the messages frame.

- **`environmental.py`**:
- Monitors and displays temperature data from various thermometers.
- Uses Matplotlib to create bar charts for temperature visualization.

- **`visualization_gas_control.py`**:
- Controls the Argon bleed system via serial communication.
- Provides GUI buttons for taring flow and absolute pressure.

- **`interlocks.py`**:
- Manages the status of various interlocks (e.g., Vacuum, Water, Door).
- Updates GUI indicators based on interlock status.

- **`oil_system.py`**:
- Monitors and displays oil temperature and pressure.
- Uses a vertical temperature gauge and a dial meter for pressure visualization.

### 6. Utilities (`utils.py`)

- **MessagesFrame Class**:
- A custom Tkinter frame for displaying messages and errors.
- Supports logging messages with timestamps and trimming old messages to maintain a maximum number of lines.

- **TextRedirector Class**:
- Redirects stdout to a Tkinter Text widget.
- Ensures that all print statements in the application are displayed in the messages frame.

- **SetupScripts Class**:
- Manages the selection and execution of configuration scripts.
- Provides a GUI for selecting scripts from a dropdown menu and executing them.

File renamed without changes.
112 changes: 112 additions & 0 deletions instrumentctl/E5CN_modbus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# E5CN Temperature Controller Driver Documentation

### Hardware Specifications
- Manufacturer: Omron
- Model: E5CN-HV2M-500
- Datasheet [(link)](https://mm.digikey.com/Volume0/opasdata/d220001/medias/docus/518/E5CN-H.pdf)
- Communication interface: Modbus RTU over RS485
- Resolution: 0.01 °C
- Sampling cycle: 60 ms

### Serial Port Configuration Settings
| Setting | Value |
|---------|-------|
| Baud rate | 9600 |
| Data bits | 8 |
| Parity | Even |
| Stop bits | 2 |
| Slave Address | 1-3 (supports multiple units) |

### Basic Usage

```python
>>> from instrumentctl import E5CNModbus

# Initialize controller with default settings
>>> controller = E5CNModbus(port="COM4")

# Connect to the device
>>> controller.connect()
True

# Read temperature from a single unit
>>> temp = controller.read_temperature(unit=1)
>>> print(f"Temperature: {temp}°C")
Temperature: 23.5°C

# Clean up
>>> controller.disconnect()
```

### Flowcharts
```mermaid
flowchart TD
%% Connection Management
subgraph Connection_Management[E5CN Modbus Management]
Connect[Connect] --> CheckConnection{Is Socket Open?}
CheckConnection -- Yes --> AlreadyConnected[Return True]
CheckConnection -- No --> AttemptConnect{Attempt Connection}
AttemptConnect -- Success --> UpdateConnected[Set Connected State]
AttemptConnect -- Failure --> HandleError[Log Error]
HandleError --> ReturnFalse[Return False]
end
```

```mermaid
flowchart TD
%% Single Temperature Read
subgraph Single_Read[Single Temperature Read]
ReadTemperature[read_temperature] --> CheckUnit{Valid Unit?}
CheckUnit -- No --> ReturnNone1[Return None]
CheckUnit -- Yes --> InitAttempts[Initialize Attempts]
InitAttempts --> CheckSocket{Socket Open?}
CheckSocket -- No --> ReconnectAttempt[Attempt Reconnect]
CheckSocket -- Yes --> ReadRegisters[Read Registers]

ReconnectAttempt -- Success --> ReadRegisters
ReconnectAttempt -- Failure --> DecrementAttempts1[Decrement Attempts]

ReadRegisters -- Success --> ProcessTemp[Process Temperature]
ReadRegisters -- Error --> DecrementAttempts2[Decrement Attempts]

DecrementAttempts1 --> CheckAttempts1{Attempts<br>left > 0?}
DecrementAttempts2 --> CheckAttempts2{Attempts<br>left > 0?}

CheckAttempts1 -- Yes --> CheckSocket
CheckAttempts1 -- No --> ReturnNone2[Return None]

CheckAttempts2 -- Yes --> CheckSocket
CheckAttempts2 -- No --> ReturnNone3[Return None]

ProcessTemp --> ValidateRange{Temperature in Range?}
ValidateRange -- Yes --> ReturnTemp[Return Temperature]
ValidateRange -- No --> LogWarning[Log Warning]
LogWarning --> ReturnTemp
end
```

```mermaid
flowchart TD
%% Temperature Reading Process
subgraph Temperature_Reading[Temperature Reading Process]
StartReading[start_reading_temperatures] --> ForEachUnit[For Each Unit in UNIT_NUMBERS]
ForEachUnit --> CreateThread[Create Reading Thread]
CreateThread --> StartThread[Start Thread]
StartThread --> AddToThreadList[Add to Thread List]

%% Continuous Reading Loop
ReadContinuously[_read_temperature_continuously] --> CheckStop{Check stop_event}
CheckStop -- Not Set --> ReadTemp[Read Temperature]
CheckStop -- Set --> ExitThread[Exit Thread]

ReadTemp --> ValidateReading{Valid Reading?}
ValidateReading -- Yes --> AcquireLock[Acquire Lock]
AcquireLock --> UpdateTemp[Update Temperature]
UpdateTemp --> ReleaseLock[Release Lock]
ValidateReading -- No --> LogError[Log Error]

ReleaseLock --> Sleep[Sleep 500ms]
LogError --> Sleep
Sleep --> CheckStop
end
```
Loading