Commit ae0cf57f authored by Yuelong Yu's avatar Yuelong Yu
Browse files

update upstream to version 1.2

parent 922cfbd2
......@@ -27,7 +27,7 @@ MAKE_ENV = $(TANGO_DIR)/Libraries/cppserver/common
CLASS = MillControl
MAJOR_VERS = 1
MINOR_VERS = 1
MINOR_VERS = 2
RELEASE = Release_$(MAJOR_VERS)_$(MINOR_VERS)
all:
......
......@@ -96,6 +96,7 @@ class MillControl (PyTango.Device_4Impl):
'33' : 'milling stopped', # milling stopped
'55' : 'milling finished'} # milling finished
self.__start = 0
self.__start_time = 0
self.attr_Speed_read = 10.0
self.attr_Time_read = 10.0
......@@ -105,9 +106,9 @@ class MillControl (PyTango.Device_4Impl):
sys.exit(1)
# start receiver thread
# th = threading.Thread(target=self.Runner)
# th.daemon = True
# th.start()
th = threading.Thread(target=self.Runner)
th.daemon = True
th.start()
self.set_state(PyTango.DevState.ON)
self.set_status("mill is on")
......@@ -127,10 +128,6 @@ class MillControl (PyTango.Device_4Impl):
def read_Speed(self, attr):
self.debug_stream("In read_Speed()")
#----- PROTECTED REGION ID(MillControl.Speed_read) ENABLED START -----#
# self.__lock.acquire()
# if self.reply_data is not None:
# self.attr_Speed_read = float(self.reply_data.split('#')[1])
# self.__lock.release()
attr.set_value(self.attr_Speed_read)
......@@ -141,18 +138,11 @@ class MillControl (PyTango.Device_4Impl):
data = attr.get_write_value()
#----- PROTECTED REGION ID(MillControl.Speed_write) ENABLED START -----#
self.attr_Speed_read = data
#self.WriteToServer()
#----- PROTECTED REGION END -----# // MillControl.Speed_write
def read_Time(self, attr):
self.debug_stream("In read_Time()")
#----- PROTECTED REGION ID(MillControl.Time_read) ENABLED START -----#
# self.__lock.acquire()
# if self.reply_data is not None:
# self.attr_Time_read = float(self.reply_data.split('#')[2]
# self.__lock.release()
attr.set_value(self.attr_Time_read)
#----- PROTECTED REGION END -----# // MillControl.Time_read
......@@ -186,10 +176,12 @@ class MillControl (PyTango.Device_4Impl):
#----- PROTECTED REGION ID(MillControl.State) ENABLED START -----#
if self.__start == 1:
#self.__lock.acquire()
self.__lock.acquire()
st = self.__current_state
#self.__lock.release()
if st is not None:
self.__lock.release()
now = time.time()
if (st is not None) and (now - self.__start_time > 1):
self.set_state(self.__devstate[st])
self.set_status(self.__devstatus[st])
else:
......@@ -221,6 +213,7 @@ class MillControl (PyTango.Device_4Impl):
self.debug_stream("In Start()")
#----- PROTECTED REGION ID(MillControl.Start) ENABLED START -----#
self.__start = 1
self.__start_time = time.time()
if not self.WriteToServer():
self.__start = 0
self.set_state(PyTango.DevState.ON)
......@@ -282,11 +275,9 @@ class MillControl (PyTango.Device_4Impl):
def ReadFromServer(self):
self.debug_stream("In ReadFromServer")
print("checking states")
#print("checking states")
try:
self.__lock.acquire()
ba = self.__s.recv(16)
self.__lock.release()
ba = self.__s.recv(32)
self.reply_data = ba.decode('utf-8')
self.info_stream("recv {} bytes:{} data:{}".format(len(self.reply_data),self.reply_data,repr(ba)))
except OSError:
......@@ -297,16 +288,16 @@ class MillControl (PyTango.Device_4Impl):
self.reply_data = None
if self.reply_data is not None:
data = self.reply_data('#')
data = self.reply_data.split('#')
self.__lock.acquire()
self.__current_state = data[3]
self.__lock.release()
self.debug_stream('current state{}'.format(data[3]))
self.info_stream('current state{}'.format(data[3]))
else:
self.__lock.acquire()
self.__current_state = None
self.__lock.release()
self.debug_stream('current state is none')
self.info_stream('current state is none')
def WriteToServer(self):
self.debug_stream("In WriteToServer")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment