Skip to content
Snippets Groups Projects
Commit 3e283185 authored by Sonia Minolli's avatar Sonia Minolli
Browse files

Integration tests II

parent 6faf7da2
No related branches found
No related tags found
No related merge requests found
......@@ -82,6 +82,14 @@ Revision: - Author: pascal_verdier
<Td><Font Size=-1>Tango::DEV_DOUBLE</Font></Td>
<Td><Font Size=-1>Wave length threshold for MOVING state, in operational unit.</Font></Td></Tr>
<Tr><Td><b><a href=#Dev_DefaultValues>PollingPeriod </a></b></Td>
<Td><Font Size=-1>Tango::DEV_DOUBLE</Font></Td>
<Td><Font Size=-1>Polling period, in ms.</Font></Td></Tr>
<Tr><Td><b><a href=#Dev_DefaultValues>ReadDelay </a></b></Td>
<Td><Font Size=-1>Tango::DEV_DOUBLE</Font></Td>
<Td><Font Size=-1>Read command delay, in ms. For expert only.</Font></Td></Tr>
</Table>
</Center>
......@@ -115,6 +123,14 @@ Revision: - Author: pascal_verdier
<Td>WavelengthThreshold</Td>
<td>0.1</td>
</Tr>
<Tr>
<Td>PollingPeriod</Td>
<td>1000</td>
</Tr>
<Tr>
<Td>ReadDelay</Td>
<td>100</td>
</Tr>
</Table>
<Br><Br><Br>
......
......@@ -217,7 +217,8 @@ void CornerStone130::init_device()
DEBUG_STREAM << "CornerStone130::init_device - create hardware interface..." << std::endl;
//- Instanciate the hardware interface
m_hwInterface = new HardwareInterface(this, gpibDeviceUrl, wavelengthThreshold);
m_hwInterface = new HardwareInterface(this, gpibDeviceUrl, wavelengthThreshold,
pollingPeriod, readDelay);
if (!m_hwInterface)
{
......@@ -316,6 +317,27 @@ void CornerStone130::init_device()
return;
}
// start device task
try
{
DEBUG_STREAM << "CornerStone130::init_device - starting task..." << std::endl;
this->m_hwInterface->go();
}
catch (Tango::DevFailed & Err)
{
ERROR_STREAM << Err << std::endl;
m_curr_status = string(Err.errors[0].desc);
m_curr_state = Tango::FAULT;
return;
}
catch (...)
{
ERROR_STREAM << "CornerStone130::init_device - failed to start task!" << std::endl;
m_curr_state = Tango::FAULT;
m_curr_status = "Failed to start task, caught[...]!";
return;
}
//- initialization ok
//------------------------
m_init_device_done = true;
......@@ -341,6 +363,8 @@ void CornerStone130::get_device_property()
dev_prop.push_back(Tango::DbDatum("OperationalUnit"));
dev_prop.push_back(Tango::DbDatum("GpibDeviceUrl"));
dev_prop.push_back(Tango::DbDatum("WavelengthThreshold"));
dev_prop.push_back(Tango::DbDatum("PollingPeriod"));
dev_prop.push_back(Tango::DbDatum("ReadDelay"));
// Call database and extract values
//--------------------------------------------
......@@ -406,6 +430,28 @@ void CornerStone130::get_device_property()
// And try to extract WavelengthThreshold value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> wavelengthThreshold;
// Try to initialize PollingPeriod from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> pollingPeriod;
else {
// Try to initialize PollingPeriod from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> pollingPeriod;
}
// And try to extract PollingPeriod value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> pollingPeriod;
// Try to initialize ReadDelay from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> readDelay;
else {
// Try to initialize ReadDelay from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> readDelay;
}
// And try to extract ReadDelay value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> readDelay;
// End of Automatic code generation
......@@ -1086,4 +1132,5 @@ void CornerStone130::parse_filters_prop()
}
}
} // namespace CornerStone130_ns
} // namespace
......@@ -129,6 +129,14 @@ public :
* Wave length threshold for MOVING state, in operational unit.
*/
Tango::DevDouble wavelengthThreshold;
/**
* Polling period, in ms.
*/
Tango::DevDouble pollingPeriod;
/**
* Read command delay, in ms. For expert only.
*/
Tango::DevDouble readDelay;
//@}
/**
......
......@@ -489,6 +489,36 @@ void CornerStone130Class::set_default_property()
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "PollingPeriod";
prop_desc = "Polling period, in ms.";
prop_def = "1000";
vect_data.clear();
vect_data.push_back("1000");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "ReadDelay";
prop_desc = "Read command delay, in ms. For expert only.";
prop_def = "100";
vect_data.clear();
vect_data.push_back("100");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
}
//+----------------------------------------------------------------------------
//
......
This diff is collapsed.
......@@ -13,10 +13,10 @@
// DEPENDENCIES
//============================================================================
#include <tango.h>
#include <yat4tango/ExceptionHelper.h>
#include <yat4tango/LogHelper.h>
#include <yat4tango/DeviceTask.h>
#include "TypesAndConsts.h"
namespace CornerStone130_ns {
// ============================================================================
......@@ -85,9 +85,10 @@ typedef struct cs130ErrDataType
std::string csErrDesc; // error description
} cs130ErrDataType;
const size_t kERRORS_SIZE = 9;
const size_t kERRORS_SIZE = 10;
static const cs130ErrDataType error_tab[kERRORS_SIZE] =
{
{0, "System error"},
{1, "Command not understood"},
{2, "Bad parameter used in Command"},
{3, "Destination position for wavelength motion not allowed."},
......@@ -99,16 +100,30 @@ static const cs130ErrDataType error_tab[kERRORS_SIZE] =
{9, "Label too long"}
};
// ============================================================================
// SOME USER DEFINED MESSAGES FOR THE TASK
// ============================================================================
#define kSET_WAVE_LENGTH_MSG (yat::FIRST_USER_MSG + 1001)
#define kSET_FILTER_MSG (yat::FIRST_USER_MSG + 1002)
#define kSET_GRATING_MSG (yat::FIRST_USER_MSG + 1003)
#define kSHUTTER_STATE_MSG (yat::FIRST_USER_MSG + 1004)
#define kABORT_MSG (yat::FIRST_USER_MSG + 1005)
//-----------------------------------------------------------------------------
//- Default timeout value for task messages (in ms):
#define kDEFAULT_CMD_TMO 1000
// ============================================================================
// class: HardwareInterface
// ============================================================================
class HardwareInterface : public Tango::LogAdapter
class HardwareInterface : public yat4tango::DeviceTask
{
public:
//- Constructor
HardwareInterface (Tango::DeviceImpl * host_device, std::string gpib_device, double wl_threashold);
HardwareInterface (Tango::DeviceImpl * host_device, std::string gpib_device,
double wl_threashold, double polling_period, double read_delay);
//- Destructor
~HardwareInterface ();
......@@ -129,24 +144,20 @@ public:
throw (Tango::DevFailed);
//- Gets current grating label
std::string get_grating_label()
throw (Tango::DevFailed);
std::string get_grating_label();
//- Gets current grating number
yat::uint16 get_grating_nb()
throw (Tango::DevFailed);
yat::uint16 get_grating_nb();
//- Sets new grating number
void set_grating_nb(yat::uint16 gratNb)
throw (Tango::DevFailed);
//- Gets current filter label
std::string get_filter_label()
throw (Tango::DevFailed);
std::string get_filter_label();
//- Gets current filter number
yat::uint16 get_filter_nb()
throw (Tango::DevFailed);
yat::uint16 get_filter_nb();
//- Sets new filter number
void set_filter_nb(yat::uint16 filterNb)
......@@ -160,13 +171,11 @@ public:
void set_wavelength(double wl)
throw (Tango::DevFailed);
//- Gets the wavelength
double get_wavelength()
throw (Tango::DevFailed);
//- Gets the current wavelength
double get_wavelength();
//- Gets the shutter state
E_shutter_state_t get_shutter_state()
throw (Tango::DevFailed);
//- Gets the current shutter state
E_shutter_state_t get_shutter_state();
//- Sets the shutter state
void set_shutter_state(E_shutter_state_t st)
......@@ -176,6 +185,11 @@ public:
void abort()
throw (Tango::DevFailed);
protected:
//- process_message (implements yat4tango::DeviceTask pure virtual method)
virtual void process_message (yat::Message& msg)
throw (Tango::DevFailed);
private:
//- Gpib device proxy
Tango::DeviceProxy * m_gpibProxy;
......@@ -190,17 +204,32 @@ private:
//- com ok flag
bool m_init_ok;
//- current grating number
//- current grating number & label
yat::uint16 m_grating_number;
std::string m_grating_label;
//- current filter number
yat::uint16 m_filter_nb;
//- current filter number & label
yat::uint16 m_filter_number;
std::string m_filter_label;
//- wavelength parameters for MOVING state computation
double m_wavelength_setpoint; // setpoint
double m_wavelength_readback; // readback value
double m_wavelength_threshold; // threshold
//- current shutter state
E_shutter_state_t m_shutter_st;
//- polling period in ms
double m_polling_period;
//- read delay in ms
double m_read_delay;
//- mutex protection
yat::Mutex m_dataLock;
//- internal functions
//-----------------------
......@@ -209,6 +238,44 @@ private:
//- else, returns false
bool check_error(std::string& err_msg);
//- periodic job
void periodic_job_i();
//- Sets new grating number
void set_grating_nb_i(yat::uint16 gratNb)
throw (Tango::DevFailed);
//- Sets new filter number
void set_filter_nb_i(yat::uint16 filterNb)
throw (Tango::DevFailed);
//- Sets the new wavelength value
void set_wavelength_i(double wl)
throw (Tango::DevFailed);
//- Sets the shutter state
void set_shutter_state_i(E_shutter_state_t st)
throw (Tango::DevFailed);
//- abort command
void abort_i()
throw (Tango::DevFailed);
//- update functions
void update_grating_label()
throw (Tango::DevFailed);
void update_grating_nb()
throw (Tango::DevFailed);
void update_filter_label()
throw (Tango::DevFailed);
void update_filter_nb()
throw (Tango::DevFailed);
void update_wavelength()
throw (Tango::DevFailed);
void update_shutter_state()
throw (Tango::DevFailed);
void update_state_and_status();
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment