Skip to content
Snippets Groups Projects
Commit 7cdbf2ca authored by Arafat Nourredine's avatar Arafat Nourredine
Browse files

- Update/Rename/Enhance some python scripts for tests in \test folder

parent 908d649a
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
######################################################### #########################################################
#Arafat NOUREDDINE #Arafat NOUREDDINE
#2014/11/19 #2014/11/19
#Purpose : Test LimaDetector state #Purpose : Test XiaDxp - flyscan mode , i.e mapping with pandabox for triggers
######################################################### #########################################################
import os import os
import sys import sys
...@@ -71,7 +71,7 @@ def snap(xia_proxy, panda_proxy): ...@@ -71,7 +71,7 @@ def snap(xia_proxy, panda_proxy):
timeEnd = datetime.datetime.now() timeEnd = datetime.datetime.now()
print '\n', timeEnd.isoformat(), ' - ', xia_proxy.state() print '\n', timeEnd.isoformat(), ' - ', xia_proxy.state()
print '\nDuration = ', ((timeEnd-timeSnap).total_seconds()*1000),'(ms)' print '\nDuration = ', ((timeEnd-timeSnap).total_seconds()*1000),'(ms)'
time.sleep(2) time.sleep(1)
return return
#return xia_proxy.image #return xia_proxy.image
...@@ -81,7 +81,7 @@ def snap(xia_proxy, panda_proxy): ...@@ -81,7 +81,7 @@ def snap(xia_proxy, panda_proxy):
# Usage # Usage
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
def usage(): def usage():
print "Usage: [python] test_xia_memory_leak_snap.py <xia/device/proxy> <panda/device/proxy> <nb_loops>" print "Usage: [python] test_xiadxp_flyscan.py <xia/device/proxy> <panda/device/proxy> <nb_loops>"
sys.exit(1) sys.exit(1)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
######################################################### #########################################################
#Arafat NOUREDDINE #Arafat NOUREDDINE
#2014/11/19 #2014/11/19
#Purpose : Test LimaDetector state #Purpose : Test XiaDxp - command LoadConfigurationFile
######################################################### #########################################################
import os import os
import sys import sys
...@@ -77,7 +77,7 @@ def load(proxy,alias): ...@@ -77,7 +77,7 @@ def load(proxy,alias):
# Usage # Usage
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
def usage(): def usage():
print "Usage: [python] test_xia_memory_leak_load.py <my/device/proxy> <nb_loops>" print "Usage: [python] test_xiadxp_load.py <my/device/proxy> <nb_loops>"
sys.exit(1) sys.exit(1)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
######################################################### #########################################################
#Author : Arafat NOUREDDINE #Author : Arafat NOUREDDINE
#Date : 2016/08/28 #Date : 2016/08/28
#Purpose : Test XiaDxp (Mode MAPPING) #Purpose : Test XiaDxp - Mode MAPPING
######################################################### #########################################################
import os import os
import sys import sys
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
######################################################### #########################################################
#Author : Arafat NOUREDDINE #Author : Arafat NOUREDDINE
#Date : 2016/08/28 #Date : 2016/08/28
#Purpose : Test XiaDxp (Mode MCA) #Purpose : Test XiaDxp - Mode MCA
######################################################### #########################################################
import os import os
import sys import sys
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
######################################################### #########################################################
#Arafat NOUREDDINE #Arafat NOUREDDINE
#2014/11/19 #2014/11/19
#Purpose : Test LimaDetector state #Purpose : Test XiaDxp - command snap/stop & state
######################################################### #########################################################
import os import os
import sys import sys
...@@ -40,34 +40,45 @@ def disable(self): ...@@ -40,34 +40,45 @@ def disable(self):
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
def snap(proxy, integration, latency): def snap(proxy, integration, latency, stop_after):
print '\nSnap() \n------------------' print '\nSnap() \n------------------'
#Configure the device #Configure the device
proxy.presetValue = integration
#Display time when state is STANDBY (just before load()) #Display time when state is STANDBY (just before load())
timeBegin = datetime.datetime.now() timeBegin = datetime.datetime.now()
print timeBegin.isoformat(), ' - ', proxy.state() print timeBegin.isoformat(), ' - ', proxy.state()
#fix preseValue attribute to integration
proxy.presetValue = integration
#start the acquisition
proxy.Snap() proxy.Snap()
#get the t0 when snap is executed
t0_snap = datetime.datetime.now()
#Display time when state is RUNNING (just after timeSnap()) #Display time when state is RUNNING (just after timeSnap())
timeSnap = datetime.datetime.now() timeSnap = datetime.datetime.now()
print timeSnap.isoformat(), ' - ', proxy.state() print timeSnap.isoformat(), ' - ', proxy.state()
#Loop while state is RUNNING (acquisition in progress...) #Display time when state is STANDBY (just after acquisition is finish)
state = proxy.state() state = proxy.state()
while (state==PyTango.DevState.RUNNING): while (state==PyTango.DevState.RUNNING):
#compute elapsed time since t0_snap
t1_snap = datetime.datetime.now()
t_snap = (t1_snap - t0_snap).total_seconds() #in s
state = proxy.state() state = proxy.state()
#if acquiistion is finish, nothing to do got out
if state == PyTango.DevState.STANDBY: if state == PyTango.DevState.STANDBY:
break break
print '\r', '...', #if acquisition is running, force the stop if (stop_after) time is elapsed since t0_snap
time.sleep(0.001) if t_snap >= stop_after and stop_after!=0:
#force stop after (stop_after)
#Display time when state is STANDBY (just after acquisition is finish) print '\nStop() \n------------------'
proxy.Stop()
state = proxy.state()
while (state!=PyTango.DevState.STANDBY):
state = proxy.state()
time.sleep(0)
break
print '\r', 'Acquisition XiaDxp in progress ...',
time.sleep(0)
timeEnd = datetime.datetime.now() timeEnd = datetime.datetime.now()
print '\n', timeEnd.isoformat(), ' - ', proxy.state() print '\n', timeEnd.isoformat(), ' - ', proxy.state()
print '\nDuration = ', ((timeEnd-timeSnap).total_seconds()*1000),'(ms)' print '\nDuration = ', ((timeEnd-timeSnap).total_seconds()*1000),'(ms)'
...@@ -81,19 +92,20 @@ def snap(proxy, integration, latency): ...@@ -81,19 +92,20 @@ def snap(proxy, integration, latency):
# Usage # Usage
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
def usage(): def usage():
print "Usage: [python] test_xia_memory_leak_snap.py <my/device/proxy> <integration time s> <latency in s> <nb_loops>" print "Usage: [python] test_xiadxp_snap_stop.py <my/device/proxy> <integration time s> <latency in s> <stop_after in s> <nb_loops>"
sys.exit(1) sys.exit(1)
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# run # run
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
def run(proxy_name = 'tmp/test/xia_memory_leak', integration = 1, latency = 1, nb_loops = 1): def run(proxy_name = 'tmp/test/xia_memory_leak', integration = 1, latency = 1, stop_after = 1, nb_loops = 1):
# print arguments # print arguments
print '\nProgram inputs :\n--------------' print '\nProgram inputs :\n--------------'
print 'proxy_name\t = ', proxy_name print 'proxy_name\t = ', proxy_name
print 'integration\t = ', integration print 'integration\t = ', integration
print 'latency\t = ', latency print 'latency\t = ', latency
print 'stop_after\t = ', stop_after
print 'nb_loops\t = ', nb_loops print 'nb_loops\t = ', nb_loops
proxy = PyTango.DeviceProxy(proxy_name) proxy = PyTango.DeviceProxy(proxy_name)
#Configure the device #Configure the device
...@@ -102,6 +114,7 @@ def run(proxy_name = 'tmp/test/xia_memory_leak', integration = 1, latency = 1, n ...@@ -102,6 +114,7 @@ def run(proxy_name = 'tmp/test/xia_memory_leak', integration = 1, latency = 1, n
nb_loops = int(nb_loops) nb_loops = int(nb_loops)
integration = float(integration) integration = float(integration)
latency = float(latency) latency = float(latency)
stop_after = float(stop_after)
alias = '1' alias = '1'
print '\n' print '\n'
try: try:
...@@ -110,14 +123,14 @@ def run(proxy_name = 'tmp/test/xia_memory_leak', integration = 1, latency = 1, n ...@@ -110,14 +123,14 @@ def run(proxy_name = 'tmp/test/xia_memory_leak', integration = 1, latency = 1, n
print '\n========================================================' print '\n========================================================'
print '\t' + bcolors.PINK + 'Loop : ', current_loop, bcolors.ENDC, print '\t' + bcolors.PINK + 'Loop : ', current_loop, bcolors.ENDC,
print '\n========================================================' print '\n========================================================'
snap(proxy, integration, latency) snap(proxy, integration, latency, stop_after)
current_loop=current_loop+1 current_loop=current_loop+1
state = proxy.state() state = proxy.state()
if (state!=PyTango.DevState.STANDBY): if (state!=PyTango.DevState.STANDBY):
# raise Exception('FAIL : Acquisition is end with state (%s)' %(state)) # raise Exception('FAIL : Acquisition is end with state (%s)' %(state))
print bcolors.RED + 'Device is in FAULT !',bcolors.ENDC, print bcolors.RED + 'Device is in FAULT !',bcolors.ENDC,
print '\noutput :\n--------------' #print '\noutput :\n--------------'
print '\nProgram outputs :\n--------------' #print '\nProgram outputs :\n--------------'
except Exception as err: except Exception as err:
sys.stderr.write('--------------\nERROR :\n--------------\n%s\n' %err) sys.stderr.write('--------------\nERROR :\n--------------\n%s\n' %err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment