Skip to content
Snippets Groups Projects
Commit 63f9b266 authored by Alain BUTEAU's avatar Alain BUTEAU
Browse files

- tests DIFFABS du 28/08

parent 0ef6a24a
No related branches found
No related tags found
No related merge requests found
import PyTango
import time
cyberstar = PyTango.DeviceProxy("d13-1-cx1/dt/cyberstar.1")
cyberstar.set_timeout_millis(3000)
lower = cyberstar.read_attribute("scaLowerThreshold")
upper = cyberstar.read_attribute("scaUpperThreshold")
width = cyberstar.read_attribute("windowWidth")
center = cyberstar.read_attribute("windowCenterPosition")
center.value=1
#cyberstar.write_attribute(center)
width.value = 1
cyberstar.write_attribute(width)
error_lower=0
error_upper=0
for i in range(1000):
print "step %i" % i
for j in (9., 5., 1.):
center.value = j
cyberstar.write_attribute(center)
print "-->" , j
print cyberstar.read_attribute("scaLowerThreshold").value
print cyberstar.read_attribute("scaUpperThreshold").value
lower_read= cyberstar.read_attribute("scaLowerThreshold").value
upper_read= cyberstar.read_attribute("scaUpperThreshold").value
if lower_read != (j-width.value/2.) :
print "error setting lower %f instead of %f %d" % (lower_read, (j-width.value/2.), error_lower)
error_lower=error_lower+1
if upper_read != (j+width.value/2.) :
print "error setting upper %f instead of %f %d" % (upper_read, (j+width.value/2.), error_upper)
#print "error setting upper", error_lower
error_upper=error_upper+1
"""
upper.value = 10
cyberstar.write_attribute(upper)
error_lower=0
for i in range(1000):
for j in (9, 5, 1):
lower.value = j
cyberstar.write_attribute(lower)
print cyberstar.read_attribute("scaLowerThreshold").value
lower_read= cyberstar.read_attribute("scaLowerThreshold").value
if lower_read != j :
print "error setting lower", error_lower
error_lower=error_lower+1
lower.value = 0.5
cyberstar.write_attribute(lower)
for i in range(1000):
print i
debut = time.time()
for j in (9, 5, 1):
upper.value = j
cyberstar.write_attribute(upper)
print cyberstar.read_attribute("scaUpperThreshold").value
fin = time.time()
print "t = %f" % (fin - debut)
"""
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/CYBERSTAR/src/CYBERSTARx1000.cpp,v 1.19 2008-02-27 17:35:31 buteau Exp $"; static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/CYBERSTAR/src/CYBERSTARx1000.cpp,v 1.20 2008-02-28 11:35:00 buteau Exp $";
//+============================================================================= //+=============================================================================
// //
// file : CYBERSTARx1000.cpp // file : CYBERSTARx1000.cpp
...@@ -13,9 +13,12 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio ...@@ -13,9 +13,12 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
// //
// $Author: buteau $ // $Author: buteau $
// //
// $Revision: 1.19 $ // $Revision: 1.20 $
// //
// $Log: not supported by cvs2svn $ // $Log: not supported by cvs2svn $
// Revision 1.19 2008/02/27 17:35:31 buteau
// - tests DIFFABS du 27/08
//
// Revision 1.17 2008/02/26 17:56:58 buteau // Revision 1.17 2008/02/26 17:56:58 buteau
// - code a relire // - code a relire
// //
...@@ -110,8 +113,9 @@ const double PEAKING_TIME_VALUE2= 500.0; ...@@ -110,8 +113,9 @@ const double PEAKING_TIME_VALUE2= 500.0;
const double PEAKING_TIME_VALUE3= 1000.0; const double PEAKING_TIME_VALUE3= 1000.0;
const double PEAKING_TIME_VALUE4= 3000.0; const double PEAKING_TIME_VALUE4= 3000.0;
const double MAX_THRESHOLD_SIZE=2.0 ; //dont move threshold by more than 1 Volts otherwiser instrument doesnt apply voltages const double MAX_THRESHOLD_SIZE=10.0 ; //dont move threshold by more than x Volts otherwise instrument doesnt apply voltages
const double SLEEPING_TIME_BETWEEN_THRESHOLD_INCREMENTS=300000000; // 300 ms const double SLEEPING_TIME_BETWEEN_THRESHOLD_INCREMENTS=00000000; // After last tests it seems that it is useless to wait
const double ERROR_MARGIN_In_VOLTS =0.01 ; // rounded errors between set and read points due to electronic rounding value to 3.1%f format
namespace CYBERSTARx1000_ns namespace CYBERSTARx1000_ns
{ {
...@@ -710,7 +714,6 @@ namespace CYBERSTARx1000_ns ...@@ -710,7 +714,6 @@ namespace CYBERSTARx1000_ns
// get rid of ACK characters in the response // get rid of ACK characters in the response
response = process_string(response); response = process_string(response);
//cout << "**** response=" << response <<endl;
} }
...@@ -798,7 +801,7 @@ namespace CYBERSTARx1000_ns ...@@ -798,7 +801,7 @@ namespace CYBERSTARx1000_ns
catch(...) catch(...)
{ {
ERROR_STREAM<<"Unknwown exception caught in CYBERSTARx1000::process_string()"<<endl; ERROR_STREAM<<"Unknown exception caught in CYBERSTARx1000::process_string()"<<endl;
Tango::Except::throw_exception( Tango::Except::throw_exception(
(const char*) "CONNECTION_ERROR", (const char*) "CONNECTION_ERROR",
...@@ -829,7 +832,7 @@ namespace CYBERSTARx1000_ns ...@@ -829,7 +832,7 @@ namespace CYBERSTARx1000_ns
} }
//+------------------------------------------------------------------ //+------------------------------------------------------------------
/** /**
* method: CYBERSTARx1000::update_lower * method: CYBERSTARx1000::write_step_lower
* *
* description: write the lower setpoint * description: write the lower setpoint
* *
...@@ -963,9 +966,11 @@ namespace CYBERSTARx1000_ns ...@@ -963,9 +966,11 @@ namespace CYBERSTARx1000_ns
// check upper and lower values before writing on hardware // check upper and lower values before writing on hardware
if(attr_scaUpperThreshold_write<=SCA_UPPER_THRESHOLD_MAX && attr_scaLowerThreshold_write>=SCA_LOWER_THRESHOLD_MIN ) if(attr_scaUpperThreshold_write<=SCA_UPPER_THRESHOLD_MAX && attr_scaLowerThreshold_write>=SCA_LOWER_THRESHOLD_MIN )
{ {
update_lower(attr_scaLowerThreshold_write); update_lower(attr_scaLowerThreshold_write);
update_upper(attr_scaUpperThreshold_write); update_upper(attr_scaUpperThreshold_write);
// Absurd behaviour of the Cyberstar . We must reapply volatges on lower threshold again !! //ATTENTION : Absurd behaviour of the Cyberstar . We must reapply volatges on lower threshold again !!
// DONT suppress following line event if it seems stupid
update_lower(attr_scaLowerThreshold_write); update_lower(attr_scaLowerThreshold_write);
} }
...@@ -1004,23 +1009,24 @@ namespace CYBERSTARx1000_ns ...@@ -1004,23 +1009,24 @@ namespace CYBERSTARx1000_ns
Tango::DevState argout; Tango::DevState argout;
// update attributes SCA thresholds // update attributes SCA thresholds
read_upper(); read_upper();
read_lower(); read_lower();
// value read on the hardware is troncated so test must take into account small difference between read and setpoint
if ((attr_scaUpperThreshold_write != (*attr_scaUpperThreshold_read)) || if ( (fabs(attr_scaUpperThreshold_write -(*attr_scaUpperThreshold_read)) > ERROR_MARGIN_In_VOLTS) ||
(attr_scaLowerThreshold_write != (*attr_scaLowerThreshold_read)) ) (fabs(attr_scaLowerThreshold_write -(*attr_scaLowerThreshold_read))> ERROR_MARGIN_In_VOLTS) )
{ {
argout=Tango::RUNNING; argout=Tango::RUNNING;
set_status("SCA threshold voltages are changing"); set_status("SCA threshold voltages are changing");
cout << "SCA threshold voltages are changing" <<endl;
} }
else else
{ {
argout=Tango::STANDBY; argout=Tango::STANDBY;
set_status("CYBERSTAR is waiting for request"); set_status("CYBERSTAR is waiting for request");
cout << "CYBERSTAR is waiting for request" <<endl;
} }
return argout; return argout;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment