Skip to content
Snippets Groups Projects
Commit 509211fa authored by Jean Coquet's avatar Jean Coquet
Browse files

test with HW to be continued

parent 998f60f1
Branches
Tags
No related merge requests found
......@@ -68,14 +68,23 @@ namespace HWProxy_ns
this->set_periodic_msg_period(this->conf.periodic_timeout_ms);
this->comproxy = 0;
this->command_ok = 0;
this->command_error = 0;
this->consecutive_command_error = 0;
com_state_enum_str.push_back (std::string ("HWP_UNKNOWN_ERROR"));
com_state_enum_str.push_back (std::string ("HWP_INITIALIZATION_ERROR"));
com_state_enum_str.push_back (std::string ("HWP_COMMUNICATION_ERROR"));
com_state_enum_str.push_back (std::string ("HWP_COMMAND_ERROR"));
com_state_enum_str.push_back (std::string ("HWP_HARDWARE_ERROR"));
com_state_enum_str.push_back (std::string ("HWP_SOFTWARE_ERROR"));
com_state_enum_str.push_back (std::string ("HWP_NO_ERROR"));
//- check that Loop Number is correct
if (conf.loop_number != 1 && conf.loop_number != 2)
{
ERROR_STREAM << "USER ERROR Loop Number must be [1|2]" << std::endl;
ERROR_STREAM << "USER ERROR Loop Number <" << conf.loop_number << "> must be [1|2]" << std::endl;
this->com_state = HWP_INITIALIZATION_ERROR;
this->last_error = "USER ERROR Loop Number must be [1|2]\n";
}
......@@ -125,9 +134,9 @@ namespace HWProxy_ns
}
catch (...)
{
ERROR_STREAM << "HWProxy::HWProxy Error trying to allocate Ramp State Manager" << std::endl;
this->com_state = HWP_INITIALIZATION_ERROR;
this->last_error = "Error trying to allocate Ramp State Manager\n";
ERROR_STREAM << "HWProxy::HWProxy Error trying to allocate Ramp State Manager" << std::endl;
}
//- initialize the variables
......@@ -177,17 +186,20 @@ namespace HWProxy_ns
//- THREAD_INIT =======================
case yat::TASK_INIT:
{
DEBUG_STREAM << "HWProxy::handle_message::THREAD_INIT::thread is starting up" << std::endl;
DEBUG_STREAM << "HWProxy::handle_message::TASK_INIT::thread is starting up" << std::endl;
//- "initialization" code goes here
last_error = "No Error\n";
if (com_state == HWP_INITIALIZATION_ERROR)
if (this->com_state == HWP_INITIALIZATION_ERROR)
{
ERROR_STREAM << "HWProxy::handle_message::TASK_PERIODIC DO NOTHING REASON : INITIALIZATION_ERROR" << std::endl;
ERROR_STREAM << "HWProxy::handle_message::TASK_INIT DO NOTHING REASON : INITIALIZATION_ERROR" << std::endl;
INFO_STREAM << "HWProxy::handle_message::TASK_INIT::com_state = " << int (com_state) << " str = " << com_state_enum_str [com_state] << com_state<< std::endl;
return;
}
//- initialize variables by reading HW
DEBUG_STREAM << "HWProxy::handle_message::TASK_INIT::initializing variables" << std::endl;
try
{
this->read_temperatures ();
......@@ -197,7 +209,7 @@ namespace HWProxy_ns
}
catch (...)
{
this->com_state = HWP_INITIALIZATION_ERROR;
this->com_state = HWP_COMMUNICATION_ERROR;
this->last_error = "Error TASK_INIT Error trying to read HW parameters [try to restart devicce]\n";
ERROR_STREAM << "HWProxy::process_message::TASK_INIT Error trying read HW parameters" << std::endl;
}
......@@ -890,8 +902,8 @@ namespace HWProxy_ns
if (com_state == HWP_INITIALIZATION_ERROR || this->comproxy == 0)
return false;
Tango::DeviceData cmd_argout;
Tango::DeviceData cmd_argin;
Tango::DeviceData dd_in;
Tango::DeviceData dd_out;
try
{
......@@ -902,8 +914,11 @@ namespace HWProxy_ns
response.clear ();
DEBUG_STREAM << "HWProxy::write_read try to send command [" << cmd << "]" << std::endl;
cmd_argout = this->comproxy->command_inout("WriteRead", cmd_argin);
cmd_argout >> response;
Tango::DevString ds;
ds = CORBA::string_dup (cmd.c_str ());
dd_in << ds;
dd_out = this->comproxy->command_inout("WriteRead", dd_in);
dd_out >> response;
DEBUG_STREAM << "HWProxy::write_read response to command [" << cmd << "] received [" << response << "]" << std::endl;
}
//- response empty
......@@ -949,7 +964,7 @@ namespace HWProxy_ns
if (com_state == HWP_INITIALIZATION_ERROR || this->comproxy == 0)
return false;
Tango::DeviceData cmd_argin;
Tango::DeviceData dd_in;
try
{
......@@ -957,7 +972,10 @@ namespace HWProxy_ns
yat::AutoMutex<> guard(this->lock);
DEBUG_STREAM << "HWProxy::write try to send command [" << cmd << "]" << std::endl;
this->comproxy->command_inout("Write", cmd_argin);
Tango::DevString ds;
ds = CORBA::string_dup (cmd.c_str ());
dd_in << ds;
this->comproxy->command_inout("Write", dd_in);
}
}
catch (Tango::DevFailed &e)
......
......@@ -10,7 +10,7 @@
#include <tango.h>
#include <yat4tango/DeviceTask.h>
#include <yat/Timer.h>
#include <yat/time/Timer.h>
#include <yat4tango/ThreadSafeDeviceProxy.h>
#include "RampingStateManager.h"
......@@ -151,7 +151,7 @@ namespace HWProxy_ns
//- access temperature (the input configured for this loop)
double get_temperature (void) throw (Tango::DevFailed)
{
if (this->com_state = HWP_INITIALIZATION_ERROR)
if (this->com_state == HWP_INITIALIZATION_ERROR)
{
Tango::Except::throw_exception ("DATA_OUT_OF_RANGE",
" temperature index must be in [0...3]",
......@@ -334,6 +334,9 @@ namespace HWProxy_ns
//- The regulation (Ramp) State Manager
rsm_ns::RampingStateMachine * reg_manager;
std::vector <std::string> com_state_enum_str;
};
}//- namespace
......
......@@ -7,7 +7,7 @@
//////////////////////////////////////////////////////////////////////
#include "StringTokenizer.h"
#include <yat/XString.h>
#include <yat/utils/XString.h>
//- Ctor with initialisation---------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment