This repository has been archived by the owner on Jul 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Science.py
47 lines (37 loc) · 1.67 KB
/
Science.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from robocluster import Device
ScienceDevice = Device('ScienceDevice', 'rover')
ScienceDevice.storage.zero_switch = 0
@ScienceDevice.on('*/move_carousel')
async def move_carousel(event, data):
await ScienceDevice.publish('ScienceArduino', {'move_carousel': int(data)})
@ScienceDevice.on('*/run_emitter')
async def move_carousel(event, data):
await ScienceDevice.publish('ScienceArduino', {'run_emitter': int(data)})
@ScienceDevice.on('*/Stage1')
async def stage_one(event, data):
await ScienceDevice.publish('ScienceArduino', {'move_carousel': 137+10})
await ScienceDevice.sleep(5)
await ScienceDevice.publish('ScienceArduino', {'run_emitter': 1})
await ScienceDevice.sleep(1)
await ScienceDevice.publish('ScienceArduino', {'take_reading': 0})
await ScienceDevice.sleep(0.1)
@ScienceDevice.on('*/Stage2')
async def stage_two(event, data):
await ScienceDevice.publish('ScienceArduino', {'move_carousel': 68+10})
await ScienceDevice.sleep(5)
for i in range(150):
await ScienceDevice.publish('ScienceArduino', {'take_reading': 0})
await ScienceDevice.sleep(0.1)
await ScienceDevice.sleep(0.1)
await ScienceDevice.publish('ScienceArduino', {'run_emitter': 0})
await ScienceDevice.publish('ScienceArduino', {'move_carousel': -207-10})
# @ScienceDevice.every('100ms')
# async def poll_detector():
# await ScienceDevice.publish('ScienceArduino', {'take_reading': 0})
@ScienceDevice.on('*/science_limit_switches')
async def switches(event, data):
# log.debug('Updating limit switches {}'.format(data))
ScienceDevice.storage.zero_switch = data[2]
ScienceDevice.storage.samples = []
ScienceDevice.start()
ScienceDevice.wait()