Skip to content

Commit 495e4eb

Browse files
Copilotsgbaird
andcommitted
Add step-by-step guide showing workflow building process
Co-authored-by: sgbaird <45469701+sgbaird@users.noreply.github.com>
1 parent a9265b2 commit 495e4eb

File tree

2 files changed

+470
-0
lines changed

2 files changed

+470
-0
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# Building a Blockly Workflow: Step-by-Step Guide
2+
3+
This guide demonstrates how to build an OT-2 automation workflow using Blockly's visual programming interface, from an empty workspace to a complete workflow with generated Python code.
4+
5+
## Step-by-Step Process
6+
7+
### Step 1: Start with Empty Workspace
8+
9+
![Empty Workspace](https://github.com/user-attachments/assets/PLACEHOLDER-step1)
10+
11+
- Open the Blockly application
12+
- The workspace is empty and ready for blocks
13+
- Toolbox on the left shows available block categories:
14+
- OT-2 Commands
15+
- Logic
16+
- Loops
17+
- Math
18+
- Text
19+
- Variables
20+
21+
**Generated Code:**
22+
```python
23+
# No blocks yet...
24+
```
25+
26+
---
27+
28+
### Step 2: Add "OT-2: Home Robot" Block
29+
30+
![Adding Home Block](https://github.com/user-attachments/assets/PLACEHOLDER-step2)
31+
32+
1. Click on **"OT-2 Commands"** category in toolbox
33+
2. Drag the **"🏠 OT-2: Home Robot"** block to workspace
34+
3. Place it at the top of your workflow
35+
36+
**Generated Code:**
37+
```python
38+
from OT2mqtt import protocol
39+
40+
protocol.home()
41+
```
42+
43+
---
44+
45+
### Step 3: Add "Repeat 3 Times" Loop
46+
47+
![Adding Loop Block](https://github.com/user-attachments/assets/PLACEHOLDER-step3)
48+
49+
1. Click on **"Loops"** category in toolbox
50+
2. Drag the **"repeat _ times"** block to workspace
51+
3. Change the number to `3`
52+
4. Place it below the Home Robot block
53+
54+
**Generated Code:**
55+
```python
56+
from OT2mqtt import protocol
57+
58+
protocol.home()
59+
60+
for count in range(3):
61+
pass # Loop body empty for now
62+
```
63+
64+
---
65+
66+
### Step 4: Add "OT-2: Mix Color" Block Inside Loop
67+
68+
![Adding Mix Color Block](https://github.com/user-attachments/assets/PLACEHOLDER-step4)
69+
70+
1. From **"OT-2 Commands"**, drag **"🎨 OT-2: Mix Color"** block
71+
2. Drop it inside the loop's "do" section
72+
3. Fill in the parameters:
73+
- **Red (µL):** 100
74+
- **Yellow (µL):** 50
75+
- **Blue (µL):** 75
76+
- **Well:** A1
77+
- **Session ID:** session_001
78+
- **Experiment ID:** exp_001
79+
80+
**Generated Code:**
81+
```python
82+
from OT2mqtt import mix_color, protocol
83+
84+
protocol.home()
85+
86+
for count in range(3):
87+
payload = {
88+
"command": {
89+
"R": 100,
90+
"Y": 50,
91+
"B": 75,
92+
"well": "A1"
93+
},
94+
"session_id": "session_001",
95+
"experiment_id": "exp_001"
96+
}
97+
mix_color(payload)
98+
```
99+
100+
---
101+
102+
### Step 5: Add "OT-2: Move Sensor Back" Block
103+
104+
![Adding Sensor Block](https://github.com/user-attachments/assets/PLACEHOLDER-step5)
105+
106+
1. From **"OT-2 Commands"**, drag **"↩️ OT-2: Move Sensor Back"** block
107+
2. Attach it below the Mix Color block (still inside the loop)
108+
3. Fill in the parameters:
109+
- **Sensor Status:** complete
110+
- **Session ID:** session_001
111+
- **Experiment ID:** exp_001
112+
113+
**Generated Code:**
114+
```python
115+
from OT2mqtt import mix_color, move_sensor_back, protocol
116+
117+
protocol.home()
118+
119+
for count in range(3):
120+
payload = {
121+
"command": {
122+
"R": 100,
123+
"Y": 50,
124+
"B": 75,
125+
"well": "A1"
126+
},
127+
"session_id": "session_001",
128+
"experiment_id": "exp_001"
129+
}
130+
mix_color(payload)
131+
132+
payload = {
133+
"command": {
134+
"sensor_status": "complete"
135+
},
136+
"session_id": "session_001",
137+
"experiment_id": "exp_001"
138+
}
139+
move_sensor_back(payload)
140+
```
141+
142+
---
143+
144+
### Step 6: Complete Workflow
145+
146+
![Complete Workflow](https://github.com/user-attachments/assets/e03bf195-edc8-4926-9980-170590c5fc24)
147+
148+
The workflow is now complete! The visual blocks on the left automatically generate the Python code on the right.
149+
150+
**Final Generated Code:**
151+
```python
152+
# Generated from Blockly visual programming
153+
# This code uses functions from OT2mqtt.py
154+
155+
from OT2mqtt import mix_color, move_sensor_back, protocol
156+
157+
# Main workflow
158+
protocol.home()
159+
160+
for count in range(3):
161+
payload = {
162+
"command": {
163+
"R": 100,
164+
"Y": 50,
165+
"B": 75,
166+
"well": 'A1'
167+
},
168+
"session_id": 'session_001',
169+
"experiment_id": 'exp_001'
170+
}
171+
mix_color(payload)
172+
173+
payload = {
174+
"command": {
175+
"sensor_status": 'complete'
176+
},
177+
"session_id": 'session_001',
178+
"experiment_id": 'exp_001'
179+
}
180+
move_sensor_back(payload)
181+
```
182+
183+
---
184+
185+
## Workflow Summary
186+
187+
This workflow demonstrates:
188+
189+
1. **Starting Simple**: Begin with a Home command
190+
2. **Adding Control Flow**: Use loops to repeat actions
191+
3. **Custom Functions**: Integrate OT-2 specific operations
192+
4. **Parameter Configuration**: Set values for each operation
193+
5. **Sequential Operations**: Chain multiple actions together
194+
6. **Automatic Code Generation**: Python code is generated in real-time
195+
196+
## Key Features
197+
198+
**Drag and Drop**: Build workflows visually without writing code
199+
🔄 **Real-time Updates**: Code updates as you modify blocks
200+
🎯 **One-to-One Mapping**: Each block directly corresponds to Python code
201+
🎓 **Educational**: Learn Python by seeing how blocks translate to code
202+
🔧 **Customizable**: Easy to modify parameters and extend with new blocks
203+
204+
## Try It Yourself
205+
206+
```bash
207+
cd scripts/blockly_app
208+
npm install
209+
npm start
210+
```
211+
212+
Then open http://localhost:8080 and start building your own workflow!

0 commit comments

Comments
 (0)