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

State Machine for INIT and Fix Initrefpos for C-884

parent aab76a57
Branches
Tags
1 merge request!3[PIController] Add PIAxis commands and attributes
......@@ -337,6 +337,11 @@ void AxisController::initialise_reference_position()
}
else
{
Serializer::pull_from_server(&m_on, m_axis_id);
if (m_on.get_value() == 0)
{
Serializer::push_to_server(&m_on, m_axis_id);
}
msg = yat::Message::allocate(CTRL_RON_MSG, DEFAULT_MSG_PRIORITY, true);
msg->attach_data<bool>(false);
post(msg);
......
......@@ -122,7 +122,7 @@ PIAxis::PIAxis(Tango::DeviceClass *cl, const char *s, const char *d)
//--------------------------------------------------------
void PIAxis::delete_device()
{
//DEBUG_STREAM << "PIAxis::delete_device() " << device_name << endl;
DEBUG_STREAM << "PIAxis::delete_device() " << device_name << endl;
/*----- PROTECTED REGION ID(PIAxis::delete_device) ENABLED START -----*/
INFO_STREAM << "PIAxis::delete_device() " << device_name << std::endl;
......@@ -147,7 +147,7 @@ void PIAxis::delete_device()
//--------------------------------------------------------
void PIAxis::init_device()
{
//DEBUG_STREAM << "PIAxis::init_device() create device " << device_name << endl;
DEBUG_STREAM << "PIAxis::init_device() create device " << device_name << endl;
/*----- PROTECTED REGION ID(PIAxis::init_device_before) ENABLED START -----*/
INFO_STREAM << "PIAxis::init_device() create device " << device_name << std::endl;
......@@ -329,7 +329,7 @@ void PIAxis::get_device_property()
//--------------------------------------------------------
void PIAxis::always_executed_hook()
{
//DEBUG_STREAM << "PIAxis::always_executed_hook() " << device_name << endl;
DEBUG_STREAM << "PIAxis::always_executed_hook() " << device_name << endl;
/*----- PROTECTED REGION ID(PIAxis::always_executed_hook) ENABLED START -----*/
// code always executed before all requests
......@@ -361,7 +361,7 @@ void PIAxis::always_executed_hook()
//--------------------------------------------------------
void PIAxis::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list))
{
//DEBUG_STREAM << "PIAxis::read_attr_hardware(vector<long> &attr_list) entering... " << endl;
DEBUG_STREAM << "PIAxis::read_attr_hardware(vector<long> &attr_list) entering... " << endl;
/*----- PROTECTED REGION ID(PIAxis::read_attr_hardware) ENABLED START -----*/
// Add your own code
......@@ -376,7 +376,7 @@ void PIAxis::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list))
//--------------------------------------------------------
void PIAxis::write_attr_hardware(TANGO_UNUSED(vector<long> &attr_list))
{
//DEBUG_STREAM << "PIAxis::write_attr_hardware(vector<long> &attr_list) entering... " << endl;
DEBUG_STREAM << "PIAxis::write_attr_hardware(vector<long> &attr_list) entering... " << endl;
/*----- PROTECTED REGION ID(PIAxis::write_attr_hardware) ENABLED START -----*/
// Add your own code
......@@ -395,7 +395,7 @@ void PIAxis::write_attr_hardware(TANGO_UNUSED(vector<long> &attr_list))
//--------------------------------------------------------
void PIAxis::read_position(Tango::Attribute &attr)
{
//DEBUG_STREAM << "PIAxis::read_position(Tango::Attribute &attr) entering... " << endl;
DEBUG_STREAM << "PIAxis::read_position(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(PIAxis::read_position) ENABLED START -----*/
// Set the attribute value
*attr_position_read = m_axis_controller->read_position();
......@@ -435,7 +435,7 @@ void PIAxis::write_position(Tango::WAttribute &attr)
//--------------------------------------------------------
void PIAxis::read_velocity(Tango::Attribute &attr)
{
//DEBUG_STREAM << "PIAxis::read_velocity(Tango::Attribute &attr) entering... " << endl;
DEBUG_STREAM << "PIAxis::read_velocity(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(PIAxis::read_velocity) ENABLED START -----*/
// Set the attribute value
*attr_velocity_read = m_axis_controller->read_velocity();
......@@ -474,7 +474,7 @@ void PIAxis::write_velocity(Tango::WAttribute &attr)
//--------------------------------------------------------
void PIAxis::read_acceleration(Tango::Attribute &attr)
{
//DEBUG_STREAM << "PIAxis::read_acceleration(Tango::Attribute &attr) entering... " << endl;
DEBUG_STREAM << "PIAxis::read_acceleration(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(PIAxis::read_acceleration) ENABLED START -----*/
// Set the attribute value
if (m_axis_controller->get_model() == "C-884" || m_axis_controller->get_model() == "SIMULATOR")
......@@ -519,7 +519,7 @@ void PIAxis::write_acceleration(Tango::WAttribute &attr)
//--------------------------------------------------------
void PIAxis::read_deceleration(Tango::Attribute &attr)
{
//DEBUG_STREAM << "PIAxis::read_deceleration(Tango::Attribute &attr) entering... " << endl;
DEBUG_STREAM << "PIAxis::read_deceleration(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(PIAxis::read_deceleration) ENABLED START -----*/
// Set the attribute value
......@@ -565,7 +565,7 @@ void PIAxis::write_deceleration(Tango::WAttribute &attr)
//--------------------------------------------------------
void PIAxis::read_backwardLimitSwitch(Tango::Attribute &attr)
{
//DEBUG_STREAM << "PIAxis::read_backwardLimitSwitch(Tango::Attribute &attr) entering... " << endl;
DEBUG_STREAM << "PIAxis::read_backwardLimitSwitch(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(PIAxis::read_backwardLimitSwitch) ENABLED START -----*/
// Set the attribute value
*attr_backwardLimitSwitch_read = m_axis_controller->backward_limit();
......@@ -584,7 +584,7 @@ void PIAxis::read_backwardLimitSwitch(Tango::Attribute &attr)
//--------------------------------------------------------
void PIAxis::read_forwardLimitSwitch(Tango::Attribute &attr)
{
//DEBUG_STREAM << "PIAxis::read_forwardLimitSwitch(Tango::Attribute &attr) entering... " << endl;
DEBUG_STREAM << "PIAxis::read_forwardLimitSwitch(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(PIAxis::read_forwardLimitSwitch) ENABLED START -----*/
// Set the attribute value
*attr_forwardLimitSwitch_read = m_axis_controller->forward_limit();
......@@ -619,7 +619,7 @@ void PIAxis::add_dynamic_attributes()
//--------------------------------------------------------
Tango::DevState PIAxis::dev_state()
{
//DEBUG_STREAM << "PIAxis::State() - " << device_name << endl;
DEBUG_STREAM << "PIAxis::State() - " << device_name << endl;
/*----- PROTECTED REGION ID(PIAxis::dev_state) ENABLED START -----*/
Tango::DevState argout = Tango::UNKNOWN; // replace by your own algorithm
......@@ -649,7 +649,7 @@ Tango::DevState PIAxis::dev_state()
//--------------------------------------------------------
void PIAxis::on()
{
//DEBUG_STREAM << "PIAxis::On() - " << device_name << endl;
DEBUG_STREAM << "PIAxis::On() - " << device_name << endl;
/*----- PROTECTED REGION ID(PIAxis::on) ENABLED START -----*/
INFO_STREAM << "PIAxis::on() - " << device_name << endl;
......@@ -682,7 +682,7 @@ void PIAxis::on()
//--------------------------------------------------------
void PIAxis::off()
{
//DEBUG_STREAM << "PIAxis::Off() - " << device_name << endl;
DEBUG_STREAM << "PIAxis::Off() - " << device_name << endl;
/*----- PROTECTED REGION ID(PIAxis::off) ENABLED START -----*/
INFO_STREAM << "PIAxis::off() - " << device_name << endl;
......@@ -714,7 +714,7 @@ void PIAxis::off()
//--------------------------------------------------------
void PIAxis::stop()
{
//DEBUG_STREAM << "PIAxis::Stop() - " << device_name << endl;
DEBUG_STREAM << "PIAxis::Stop() - " << device_name << endl;
/*----- PROTECTED REGION ID(PIAxis::stop) ENABLED START -----*/
INFO_STREAM << "PIAxis::stop() - " << device_name << endl;
......@@ -745,7 +745,7 @@ void PIAxis::stop()
//--------------------------------------------------------
void PIAxis::backward()
{
//DEBUG_STREAM << "PIAxis::Backward() - " << device_name << endl;
DEBUG_STREAM << "PIAxis::Backward() - " << device_name << endl;
/*----- PROTECTED REGION ID(PIAxis::backward) ENABLED START -----*/
INFO_STREAM << "PIAxis::backward() - " << device_name << endl;
......@@ -776,7 +776,7 @@ void PIAxis::backward()
//--------------------------------------------------------
void PIAxis::forward()
{
//DEBUG_STREAM << "PIAxis::Forward() - " << device_name << endl;
DEBUG_STREAM << "PIAxis::Forward() - " << device_name << endl;
/*----- PROTECTED REGION ID(PIAxis::forward) ENABLED START -----*/
INFO_STREAM << "PIAxis::forward() - " << device_name << endl;
......
......@@ -54,6 +54,7 @@
<excludedStates>ON</excludedStates>
<excludedStates>MOVING</excludedStates>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<commands name="Off" description="Turn motor off" execMethod="off" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
......@@ -66,6 +67,7 @@
<excludedStates>OFF</excludedStates>
<excludedStates>MOVING</excludedStates>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<commands name="Stop" description="Command to stop the axe motion" execMethod="stop" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
......@@ -78,6 +80,7 @@
<excludedStates>ON</excludedStates>
<excludedStates>OFF</excludedStates>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<commands name="Backward" description="Move To Negative Limit" execMethod="backward" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
......@@ -90,6 +93,7 @@
<excludedStates>OFF</excludedStates>
<excludedStates>MOVING</excludedStates>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<commands name="Forward" description="Move to positive limit." execMethod="forward" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
......@@ -102,6 +106,7 @@
<excludedStates>OFF</excludedStates>
<excludedStates>MOVING</excludedStates>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<commands name="InitialiseReferencePosition" description="Define the reference position" execMethod="initialise_reference_position" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
......@@ -111,6 +116,7 @@
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>MOVING</excludedStates>
</commands>
<attributes name="position" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
......@@ -123,6 +129,7 @@
<writeExcludedStates>OFF</writeExcludedStates>
<writeExcludedStates>MOVING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
<writeExcludedStates>INIT</writeExcludedStates>
</attributes>
<attributes name="velocity" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
......@@ -135,6 +142,7 @@
<writeExcludedStates>OFF</writeExcludedStates>
<writeExcludedStates>MOVING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
<writeExcludedStates>INIT</writeExcludedStates>
</attributes>
<attributes name="acceleration" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
......@@ -147,6 +155,7 @@
<writeExcludedStates>OFF</writeExcludedStates>
<writeExcludedStates>MOVING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
<writeExcludedStates>INIT</writeExcludedStates>
</attributes>
<attributes name="deceleration" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
......@@ -159,6 +168,7 @@
<writeExcludedStates>OFF</writeExcludedStates>
<writeExcludedStates>MOVING</writeExcludedStates>
<writeExcludedStates>FAULT</writeExcludedStates>
<writeExcludedStates>INIT</writeExcludedStates>
</attributes>
<attributes name="backwardLimitSwitch" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
<dataType xsi:type="pogoDsl:BooleanType"/>
......@@ -190,6 +200,9 @@
<states name="FAULT" description="Motor is in fault">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="INIT" description="Waiting for InitialiseReferencePosition to be done">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<preferences docHome="../doc/doc_html" makefileHome="$(TANGO_HOME)"/>
</classes>
</pogoDsl:PogoSystem>
......@@ -40,6 +40,7 @@
// OFF | Motor Off
// MOVING | Motor is moving
// FAULT | Motor is in fault
// INIT | Waiting for InitialiseReferencePosition to be done
namespace PIAxis_ns
......@@ -62,7 +63,8 @@ bool PIAxis::is_position_allowed(TANGO_UNUSED(Tango::AttReqType type))
// Compare device state with not allowed states for WRITE
if (get_state()==Tango::OFF ||
get_state()==Tango::MOVING ||
get_state()==Tango::FAULT)
get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PIAxis::positionStateAllowed_WRITE) ENABLED START -----*/
if (get_state()==Tango::FAULT && is_device_initialized())
......@@ -109,7 +111,8 @@ bool PIAxis::is_velocity_allowed(TANGO_UNUSED(Tango::AttReqType type))
// Compare device state with not allowed states for WRITE
if (get_state()==Tango::OFF ||
get_state()==Tango::MOVING ||
get_state()==Tango::FAULT)
get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PIAxis::velocityStateAllowed_WRITE) ENABLED START -----*/
if (get_state()==Tango::FAULT && is_device_initialized())
......@@ -156,7 +159,8 @@ bool PIAxis::is_acceleration_allowed(TANGO_UNUSED(Tango::AttReqType type))
// Compare device state with not allowed states for WRITE
if (get_state()==Tango::OFF ||
get_state()==Tango::MOVING ||
get_state()==Tango::FAULT)
get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PIAxis::accelerationStateAllowed_WRITE) ENABLED START -----*/
if (get_state()==Tango::FAULT && is_device_initialized())
......@@ -203,7 +207,8 @@ bool PIAxis::is_deceleration_allowed(TANGO_UNUSED(Tango::AttReqType type))
// Compare device state with not allowed states for WRITE
if (get_state()==Tango::OFF ||
get_state()==Tango::MOVING ||
get_state()==Tango::FAULT)
get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PIAxis::decelerationStateAllowed_WRITE) ENABLED START -----*/
if (get_state()==Tango::FAULT && is_device_initialized())
......@@ -308,7 +313,8 @@ bool PIAxis::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any))
// Compare device state with not allowed states.
if (get_state()==Tango::ON ||
get_state()==Tango::MOVING ||
get_state()==Tango::FAULT)
get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PIAxis::OnStateAllowed) ENABLED START -----*/
if (get_state()==Tango::FAULT && is_device_initialized())
......@@ -332,7 +338,8 @@ bool PIAxis::is_Off_allowed(TANGO_UNUSED(const CORBA::Any &any))
// Compare device state with not allowed states.
if (get_state()==Tango::OFF ||
get_state()==Tango::MOVING ||
get_state()==Tango::FAULT)
get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PIAxis::OffStateAllowed) ENABLED START -----*/
if (get_state()==Tango::FAULT && is_device_initialized())
......@@ -356,7 +363,8 @@ bool PIAxis::is_Stop_allowed(TANGO_UNUSED(const CORBA::Any &any))
// Compare device state with not allowed states.
if (get_state()==Tango::ON ||
get_state()==Tango::OFF ||
get_state()==Tango::FAULT)
get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PIAxis::StopStateAllowed) ENABLED START -----*/
if (get_state()==Tango::FAULT && is_device_initialized())
......@@ -380,7 +388,8 @@ bool PIAxis::is_Backward_allowed(TANGO_UNUSED(const CORBA::Any &any))
// Compare device state with not allowed states.
if (get_state()==Tango::OFF ||
get_state()==Tango::MOVING ||
get_state()==Tango::FAULT)
get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PIAxis::BackwardStateAllowed) ENABLED START -----*/
if (get_state()==Tango::FAULT && is_device_initialized())
......@@ -404,7 +413,8 @@ bool PIAxis::is_Forward_allowed(TANGO_UNUSED(const CORBA::Any &any))
// Compare device state with not allowed states.
if (get_state()==Tango::OFF ||
get_state()==Tango::MOVING ||
get_state()==Tango::FAULT)
get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PIAxis::ForwardStateAllowed) ENABLED START -----*/
if (get_state()==Tango::FAULT && is_device_initialized())
......@@ -425,10 +435,14 @@ bool PIAxis::is_Forward_allowed(TANGO_UNUSED(const CORBA::Any &any))
//--------------------------------------------------------
bool PIAxis::is_InitialiseReferencePosition_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for InitialiseReferencePosition command.
// Compare device state with not allowed states.
if (get_state()==Tango::MOVING)
{
/*----- PROTECTED REGION ID(PIAxis::InitialiseReferencePositionStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // PIAxis::InitialiseReferencePositionStateAllowed
return false;
}
return true;
}
......
......@@ -23,14 +23,14 @@
#this i a special section to declare user variables, the syntaxe is xxx=yyy
model=(c)MOCK, SIMULATOR, 111111111, 1.0.0.0
servo=1
pos=0
pos=3.000000
vel=0.500000
accel=2.000000
decel=2.000000
moving=0
ron=1
err=0
limit_switch=0x9001
limit_switch=0x9000
is_initialized=1
[END]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment