Skip to content

Commit

Permalink
Same changes in simulated service
Browse files Browse the repository at this point in the history
  • Loading branch information
ivalaginja committed May 24, 2024
1 parent f947597 commit 73aa5b2
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
import threading
import numpy as np
from catkit2.testbed.service import Service

Expand All @@ -14,6 +15,7 @@ def __init__(self):
self.motor_positions = self.config['positions']
self.motor_type = 0
self.serial_number = str(self.config['serial_number']).encode("UTF-8")
self.update_interval = self.config['update_interval']

if self.cube_model == 'KDC101':
self.motor_type = 27
Expand Down Expand Up @@ -48,7 +50,10 @@ def open(self):

self.make_command('home', self.home)

def main(self):
self.motor_thread = threading.Thread(target=self.monitor_motor)
self.motor_thread.start()

def monitor_motor(self):
while not self.should_shut_down:
try:
# Get an update for the motor position.
Expand All @@ -59,8 +64,13 @@ def main(self):
# Timed out. This is used to periodically check the shutdown flag.
continue

def main(self):
while not self.should_shut_down:
self.get_current_position()
self.sleep(self.update_interval)

def close(self):
pass
self.motor_thread.join()

def set_current_position(self, position):
"""
Expand Down

0 comments on commit 73aa5b2

Please sign in to comment.