-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy paththreaded_jobs.py
44 lines (35 loc) · 1.17 KB
/
threaded_jobs.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
import threading
import queue
import logging
import time
import math
import random
import yaml
import numpy
"""
def do_cycle(event,pos,wait):
event.clear()
wait = float(wait)
print ("DO CYCLE CALLED P1:{} P2:{}".format(pos,wait))
while not event.is_set():
my_drive.axis0.controller.pos_setpoint = pos
time.sleep(wait)
my_drive.axis0.controller.pos_setpoint = 0
time.sleep(wait)
my_drive.axis0.controller.pos_setpoint = 0 # ensure at zero for next task
print("DO CYCLE CLEARED")
def set_dynamic(pos,wait):
thread_data['dynamic_pos'] = pos
thread_data['dynamic_wait'] = wait
def dynamic_cycle(event,pos=None,wait=None):
event.clear()
print ("DYNAMIC CYCLE CALLED - POS:{} WAIT:{}".format(thread_data['dynamic_pos'], thread_data['dynamic_wait']))
while not event.is_set():
wait = float(thread_data['dynamic_wait'])
my_drive.axis0.controller.pos_setpoint = thread_data['dynamic_pos']
time.sleep(wait)
my_drive.axis0.controller.pos_setpoint = 0
time.sleep(wait)
my_drive.axis0.controller.pos_setpoint = 0 # ensure at zero for next task
print("DYNAMIC CYCLE CLEARED")
"""