Skip to content
Snippets Groups Projects
Commit 1895eaeb authored by Arafat Nourredine's avatar Arafat Nourredine
Browse files

- Rename commands On()|Of as MotorON|MotorOFF

- Change State Machine to allow executing of MotorON|MotorOFF & reading attributes when state is OFF
parent 0a3f6d81
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,7 @@ AxisSimulatorTask::AxisSimulatorTask(size_t _periodic_timeout_ms, Tango::DeviceI
// ======================================================================
AxisSimulatorTask::~AxisSimulatorTask (void)
{
DEBUG_STREAM << "AxisSimulatorTask::AxisSimulatorTask" << std::endl;
}
// ============================================================================
......
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Motion/Axis/SimulatedDevice/SimulatedMotor/src/SimulatedMotor.cpp,v 1.6 2009-04-13 17:36:45 anoureddine Exp $";
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Motion/Axis/SimulatedDevice/SimulatedMotor/src/SimulatedMotor.cpp,v 1.7 2009-05-29 08:47:16 anoureddine Exp $";
//+=============================================================================
//
// file : SimulatedMotor.cpp
......@@ -13,9 +13,14 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Motion/Axis/Si
//
// $Author: anoureddine $
//
// $Revision: 1.6 $
// $Revision: 1.7 $
//
// $Log: not supported by cvs2svn $
// Revision 1.6 2009/04/13 17:36:45 anoureddine
// - Enhance precision of speed using a high resolution timer in winmm.lib under windows. (~1ms accurate)
// - Correction a bug when using attribute accurate. (same required position value gives us 2 differents real values) !!
// - rename variables members in AxisSimulatorTask class.
//
// Revision 1.5 2009/04/08 09:21:25 anoureddine
// - commentary
//
......@@ -67,12 +72,12 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Motion/Axis/Si
// ----------------------------------------
// State | dev_state()
// Status | dev_status()
// Off | off()
// On | on()
// Forward | forward()
// Backward | backward()
// InitializeReferencePosition | initialize_reference_position()
// Stop | stop()
// MotorON | motor_on()
// MotorOFF | motor_off()
//
//===================================================================
......@@ -259,7 +264,6 @@ void SimulatedMotor::get_device_property()
Tango::DbData dev_prop;
dev_prop.push_back(Tango::DbDatum("PositionConversionRatio"));
dev_prop.push_back(Tango::DbDatum("StepSize"));
dev_prop.push_back(Tango::DbDatum("PositionUnit"));
// Call database and extract values
//--------------------------------------------
......@@ -581,88 +585,13 @@ void SimulatedMotor::write_accuracy(Tango::WAttribute &attr)
}
//+------------------------------------------------------------------
/**
* method: SimulatedMotor::off
*
* description: method to execute "Off"
* Switch OFF the device.
*
*
*/
//+------------------------------------------------------------------
void SimulatedMotor::off()
{
DEBUG_STREAM << "SimulatedMotor::off(): entering... !" << endl;
// Add your own code to control device here
try
{
//- instanciate a message of type kSTOP_MSG
yat::Message * msg = new yat::Message(kSTOP_MSG, DEFAULT_MSG_PRIORITY, false);
if (msg == 0)
{
THROW_DEVFAILED(_CPTC ("OUT_OF_MEMORY"),
_CPTC ("yat::Message allocation failed"),
_CPTC ("SimulatedMotor::off"));
}
//- here we choose to post the message to the task and return immediatly (asynchronous approach)
this->dev_task->post(msg);
power_off = true;
//- update state & status
this->update_state();
}
catch (const std::bad_alloc&)
{
THROW_DEVFAILED(_CPTC ("OUT_OF_MEMORY"),
_CPTC ("Device Task allocation failed"),
_CPTC ("SimulatedMotor::off"));
}
catch (const Tango::DevFailed& df)
{
//- verbose
ERROR_STREAM << "Tango::DevFailed exception caught while trying to execute <off>" << std::endl;
//- verbose
ERROR_STREAM << df << std::endl;
power_off = false;
//- update state & status
this->update_state();
//- rethrow exception
RETHROW_DEVFAILED (const_cast<Tango::DevFailed&>(df),
_CPTC ("TANGO_ERROR"),
_CPTC ("could not turn off the motor [Tango::DevFailed exception caught]"),
_CPTC ("SimulatedMotor::off"));
}
}
//+------------------------------------------------------------------
/**
* method: SimulatedMotor::on
*
* description: method to execute "On"
* Switch ON the device.
*
*
*/
//+------------------------------------------------------------------
void SimulatedMotor::on()
{
DEBUG_STREAM << "SimulatedMotor::on(): entering... !" << endl;
// Add your own code to control device here
power_off = false;
//- update state & status
this->update_state();
}
//+------------------------------------------------------------------
/**
* method: SimulatedMotor::forward
*
* description: method to execute "Forward"
* Increment in a continuous way the position attribute value of the device.
* Increment in a continuous way the position attribute value of the device.<BR>
* Each increment is equal to StepSize.
*
*
*/
......@@ -719,7 +648,8 @@ void SimulatedMotor::forward()
* method: SimulatedMotor::backward
*
* description: method to execute "Backward"
* decrement in a continuous way the position attribute value of the device.
* decrement in a continuous way the position attribute value of the device.<BR>
* Each increment is equal to StepSize.
*
*
*/
......@@ -940,9 +870,81 @@ void SimulatedMotor::get_attribute_property_values(void)
}
//+------------------------------------------------------------------
/**
* method: SimulatedMotor::motor_on
*
* description: method to execute "MotorON"
*
*
*/
//+------------------------------------------------------------------
void SimulatedMotor::motor_on()
{
DEBUG_STREAM << "SimulatedMotor::motor_on(): entering... !" << endl;
// Add your own code to control device here
power_off = false;
//- update state & status
this->update_state();
}
//+------------------------------------------------------------------
/**
* method: SimulatedMotor::motor_off
*
* description: method to execute "MotorOFF"
*
*
*/
//+------------------------------------------------------------------
void SimulatedMotor::motor_off()
{
DEBUG_STREAM << "SimulatedMotor::motor_off(): entering... !" << endl;
// Add your own code to control device here
try
{
//- instanciate a message of type kSTOP_MSG
yat::Message * msg = new yat::Message(kSTOP_MSG, DEFAULT_MSG_PRIORITY, false);
if (msg == 0)
{
THROW_DEVFAILED(_CPTC ("OUT_OF_MEMORY"),
_CPTC ("yat::Message allocation failed"),
_CPTC ("SimulatedMotor::off"));
}
//- here we choose to post the message to the task and return immediatly (asynchronous approach)
this->dev_task->post(msg);
power_off = true;
//- update state & status
this->update_state();
}
catch (const std::bad_alloc&)
{
THROW_DEVFAILED(_CPTC ("OUT_OF_MEMORY"),
_CPTC ("Device Task allocation failed"),
_CPTC ("SimulatedMotor::off"));
}
catch (const Tango::DevFailed& df)
{
//- verbose
ERROR_STREAM << "Tango::DevFailed exception caught while trying to execute <off>" << std::endl;
//- verbose
ERROR_STREAM << df << std::endl;
power_off = false;
//- update state & status
this->update_state();
//- rethrow exception
RETHROW_DEVFAILED (const_cast<Tango::DevFailed&>(df),
_CPTC ("TANGO_ERROR"),
_CPTC ("could not turn off the motor [Tango::DevFailed exception caught]"),
_CPTC ("SimulatedMotor::off"));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment