Skip to content
Snippets Groups Projects
Commit dd29ae7f authored by Alain BUTEAU's avatar Alain BUTEAU
Browse files

Added Yat Task to thread the gain searching

parent 571f8b07
No related branches found
No related tags found
No related merge requests found
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/Femto/src/AutoSearchGainThread.cpp,v 1.3 2011-02-15 12:15:12 buteau Exp $";
//+=============================================================================
//
// file : AutoSearchGainThread.cpp
//
// description : Thread for automatically searching the good gain
//
// project : TANGO Device Server
//
// $Author: buteau $
//
// $Revision: 1.3 $
//
// $Log: not supported by cvs2svn $
//
// copyleft : Synchrotron SOLEIL
// L'Orme des Merisiers
// Saint-Aubin - BP 48
//
//+=============================================================================
#include <tango.h>
#include <FemtoCurrentAmplifier.h>
namespace FemtoCurrentAmplifier_ns
{
AutoSearchGainThread::AutoSearchGainThread (FemtoCurrentAmplifier* femto_device, omni_mutex* m) :
omni_thread(),mutex(m),Tango::LogAdapter((Tango::DeviceImpl *)femto_device)
{
DEBUG_STREAM << ">>>> AutoSearchGainThread::AutoSearchGainThread(): entering ....!" << endl;
femto_device_ = femto_device;
start_undetached();
}
AutoSearchGainThread::~AutoSearchGainThread ()
{
DEBUG_STREAM << "DTOR: AutoSearchGainThread::~AutoSearchGainThread: entering ....!" << endl;
}
//
// AutoSearchGainThread::run_undetached
//
void *AutoSearchGainThread::run_undetached (void *arg)
{
DEBUG_STREAM << ">>>> AutoSearchGainThread starting up!" << endl;
//- Start the Loop on Gains
for(int i = femto_device_->MAX_GAIN_INDEX;i > -1; i--)
{
//- set the gain
Tango::WAttribute &watt = femto_device_->dev_attr->get_w_attr_by_name("gain");
watt.set_write_value((short)i);
femto_device_->write_gain(watt);
omni_thread::sleep(100);
//- read Overload
Tango::Attribute &att1 = femto_device_->dev_attr->get_attr_by_name("overload");
femto_device_->read_overload(att1);
//- Check if overload happen: 1->overload , 0->not overload
if(*(femto_device_->attr_overload_read) == 0)
{
INFO_STREAM << "Gain Found: gain value= " << i << endl;
femto_device_->set_state(Tango::ON);
femto_device_->set_status("Femto is in NORMAL operation");
return NULL;
}
else
INFO_STREAM << "Gain not Found, try with next one" << endl;
}
WARN_STREAM << "Gain Not Found: Maybe signal is too High" << endl;
//mutex.lock();
femto_device_->set_state(Tango::ON);
femto_device_->set_status("Femto is in NORMAL operation");
//mutex.unlock();
return NULL;
}
} //- FemtoCurrentAmplifier_ns
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment