Skip to content
Snippets Groups Projects
Commit aab76a57 authored by DESGRANGES's avatar DESGRANGES
Browse files

Fix merge conflict

parents d2d54886 ce2b6d67
No related branches found
No related tags found
1 merge request!3[PIController] Add PIAxis commands and attributes
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
/*************************************************************************/ /*************************************************************************/
#include <yat/utils/Logging.h> #include <yat/utils/Logging.h>
#include <yat/threading/Thread.h>
#include "AxisController.h" #include "AxisController.h"
#include "Serializer.h" #include "Serializer.h"
...@@ -59,7 +60,7 @@ void AxisController::compute_state_status() ...@@ -59,7 +60,7 @@ void AxisController::compute_state_status()
{ {
try try
{ {
if(m_state != Tango::FAULT) if(m_state != Tango::FAULT && m_state != Tango::INIT)
{ {
Serializer::pull_from_server(&m_on, m_axis_id); Serializer::pull_from_server(&m_on, m_axis_id);
if (m_on.get_value() == 1) if (m_on.get_value() == 1)
...@@ -71,6 +72,7 @@ void AxisController::compute_state_status() ...@@ -71,6 +72,7 @@ void AxisController::compute_state_status()
{ {
set_state(Tango::MOVING); set_state(Tango::MOVING);
set_status("Moving"); set_status("Moving");
return;
} }
} }
else else
...@@ -78,15 +80,29 @@ void AxisController::compute_state_status() ...@@ -78,15 +80,29 @@ void AxisController::compute_state_status()
set_state(Tango::OFF); set_state(Tango::OFF);
set_status("Motor off"); set_status("Motor off");
} }
}
}
catch(Tango::DevFailed& df)
{
tango_error_handler(df);
}
catch(const yat::Exception& e)
{
yat_error_handler(e,"Exception from - AxisController::compute_state_status() :\n");
}
}
Serializer::pull_from_server(&m_is_initialized, m_axis_id); //Test void AxisController::is_axis_initialized()
{
try
{
Serializer::pull_from_server(&m_is_initialized, m_axis_id);
if (m_is_initialized.get_value() == 0) if (m_is_initialized.get_value() == 0)
{ {
set_state(Tango::INIT); set_state(Tango::INIT);
set_status("Axis need to be initialized"); set_status("Axis need to be initialized");
} }
} }
}
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
tango_error_handler(df); tango_error_handler(df);
...@@ -311,14 +327,19 @@ void AxisController::auto_zero() ...@@ -311,14 +327,19 @@ void AxisController::auto_zero()
void AxisController::initialise_reference_position() void AxisController::initialise_reference_position()
{ {
yat::Message* msg = yat::Message::allocate(CTRL_RON_MSG, DEFAULT_MSG_PRIORITY, true);
msg->attach_data<bool>(false);
post(msg);
m_velocity.set_value(m_init_velocity); m_velocity.set_value(m_init_velocity);
msg = yat::Message::allocate(CTRL_SETVELOCITY_MSG, DEFAULT_MSG_PRIORITY, true); yat::Message* msg = yat::Message::allocate(CTRL_SETVELOCITY_MSG, DEFAULT_MSG_PRIORITY, true);
post(msg); post(msg);
if (m_model.get_value() == "C-884" || m_model.get_value() == "SIMULATOR") if (m_model.get_value() == "E-754")
{ {
msg = yat::Message::allocate(CTRL_AUTO_ZERO_MSG, DEFAULT_MSG_PRIORITY, true);
post(msg);
}
else
{
msg = yat::Message::allocate(CTRL_RON_MSG, DEFAULT_MSG_PRIORITY, true);
msg->attach_data<bool>(false);
post(msg);
if (m_init_type == "FNL") if (m_init_type == "FNL")
{ {
msg = yat::Message::allocate(CTRL_BACKWARD_MSG, DEFAULT_MSG_PRIORITY, true); msg = yat::Message::allocate(CTRL_BACKWARD_MSG, DEFAULT_MSG_PRIORITY, true);
...@@ -329,23 +350,14 @@ void AxisController::initialise_reference_position() ...@@ -329,23 +350,14 @@ void AxisController::initialise_reference_position()
msg = yat::Message::allocate(CTRL_FORWARD_MSG, DEFAULT_MSG_PRIORITY, true); msg = yat::Message::allocate(CTRL_FORWARD_MSG, DEFAULT_MSG_PRIORITY, true);
post(msg); post(msg);
} }
} /*m_pos.set_value(m_init_position);
else if (m_model.get_value() == "E-754")
{
yat::Message* msg = yat::Message::allocate(CTRL_AUTO_ZERO_MSG, DEFAULT_MSG_PRIORITY, true);
post(msg, 5000);
}
while (get_state() == Tango::MOVING)
{
continue;
}
m_pos.set_value(m_init_position);
msg = yat::Message::allocate(CTRL_POS_MSG, DEFAULT_MSG_PRIORITY, true); msg = yat::Message::allocate(CTRL_POS_MSG, DEFAULT_MSG_PRIORITY, true);
post(msg); post(msg);*/
msg = yat::Message::allocate(CTRL_RON_MSG, DEFAULT_MSG_PRIORITY, true); msg = yat::Message::allocate(CTRL_RON_MSG, DEFAULT_MSG_PRIORITY, true);
msg->attach_data<bool>(true); msg->attach_data<bool>(true);
post(msg); post(msg);
} }
}
//---------------------------------------------------- //----------------------------------------------------
// AxisController::process_message() // AxisController::process_message()
//---------------------------------------------------- //----------------------------------------------------
...@@ -554,6 +566,7 @@ void AxisController::process_message(yat::Message& msg) ...@@ -554,6 +566,7 @@ void AxisController::process_message(yat::Message& msg)
case CTRL_AUTO_ZERO_MSG: case CTRL_AUTO_ZERO_MSG:
{ {
set_state(Tango::MOVING);
Serializer::push_to_server(&m_auto_zero, m_axis_id); Serializer::push_to_server(&m_auto_zero, m_axis_id);
} }
break; break;
......
...@@ -68,6 +68,9 @@ public: ...@@ -68,6 +68,9 @@ public:
//! \brief Get the Hardware Controller model //! \brief Get the Hardware Controller model
std::string get_model(); std::string get_model();
//! \brief Set state and status accordingly
void is_axis_initialized();
//! \brief Turn motor on //! \brief Turn motor on
void on(); void on();
......
...@@ -192,6 +192,7 @@ void PIAxis::init_device() ...@@ -192,6 +192,7 @@ void PIAxis::init_device()
axisInitPosition, axisInitVelocity), yat4tango::DeviceTaskExiter()); axisInitPosition, axisInitVelocity), yat4tango::DeviceTaskExiter());
m_axis_controller->go(); m_axis_controller->go();
m_axis_controller->get_model(); m_axis_controller->get_model();
m_axis_controller->is_axis_initialized();
} }
catch(Tango::DevFailed& df) catch(Tango::DevFailed& df)
{ {
......
...@@ -31,6 +31,7 @@ BoxController::BoxController(yat::String ip_address, int port, yat::StringDictio ...@@ -31,6 +31,7 @@ BoxController::BoxController(yat::String ip_address, int port, yat::StringDictio
try try
{ {
SocketManager::instantiate(ip_address, port, dict_socket_config, dev); SocketManager::instantiate(ip_address, port, dict_socket_config, dev);
PIBox_ns::SocketManager::get_instance()->write_read("ERR?\n"); // Catch the hardware turning on error
} }
catch(const yat::Exception& e) catch(const yat::Exception& e)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment