Skip to content
Snippets Groups Projects
Commit dd0c9e8f authored by Sebastien Leport's avatar Sebastien Leport
Browse files

- calls of read_lowSca() & read-upSca() removed in overloaded dev_state()...

- calls of read_lowSca() &  read-upSca() removed in overloaded dev_state() methods (was usefull for the scanserver interfacing)
- add the call of Serial::DevSerFlush()  in write_read()
parent e8be26ba
Branches
Tags
No related merge requests found
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/CYBERSTAR/src/CYBERSTARx1000.cpp,v 1.13 2007-06-12 15:11:57 flanglois Exp $";
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/CYBERSTAR/src/CYBERSTARx1000.cpp,v 1.14 2007-10-24 14:37:29 sebleport Exp $";
//+=============================================================================
//
// file : CYBERSTARx1000.cpp
......@@ -11,11 +11,14 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
//
// project : TANGO Device Server
//
// $Author: flanglois $
// $Author: sebleport $
//
// $Revision: 1.13 $
// $Revision: 1.14 $
//
// $Log: not supported by cvs2svn $
// Revision 1.13 2007/06/12 15:11:57 flanglois
// - some modifs: cleaning the code+ tests with sleep; still tests to do (with A.B.)
//
// Revision 1.12 2007/05/15 13:00:22 sebleport
// - add OS sleep between reading and writing command in write_read() method
// - some changes in DevState() method
......@@ -322,15 +325,15 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
if(attr_scaUpperThreshold_write<=10 && attr_scaLowerThreshold_write>=0 )
{
//wait for cyberstar to process command
omni_thread::sleep(0,250000000); // in nanoseconds -> 250 ms
omni_thread::sleep(0,100000000); // in nanoseconds -> 250 ms
response = write_read(":SENS0:SCA:UPP "+ high_level,false);
//wait for cyberstar to process command
omni_thread::sleep(0,250000000); // in nanoseconds -> 250 ms
omni_thread::sleep(0,1000000000); // in nanoseconds -> 250 ms
response = write_read(":SENS0:SCA:LOW "+ low_level,false);
//wait for cyberstar to process command
omni_thread::sleep(0,250000000); // in nanoseconds -> 250 ms
//omni_thread::sleep(0,250000000); // in nanoseconds -> 250 ms
}
else
{
......@@ -362,14 +365,7 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
try
{
response = write_read(":SOUR0:VOLT?",true);
response = process_string(response);
*attr_voltage_read = XString<double>::convertFromString(response);
attr.set_value(attr_voltage_read);
}
catch(Tango::DevFailed &df)
{
......@@ -379,6 +375,11 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
(const char*) "CYBERSTARx1000::read_voltage()");
}
response = process_string(response);
*attr_voltage_read = XString<double>::convertFromString(response);
attr.set_value(attr_voltage_read);
}
//+----------------------------------------------------------------------------
//
......@@ -414,23 +415,7 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
try
{
response = write_read(":SYST0:COMM:REM?",true);
response = process_string(response);
char forced_remote = XString<char>::convertFromString(response);
if (forced_remote == '0')
*attr_forcedRemoteMode_read=false;
else if (forced_remote == '1')
*attr_forcedRemoteMode_read=true;
else
ERROR_STREAM<<" communication problem, see in CYBERSTARx1000::read_forcedRemoteMode() "<<endl;
attr.set_value(attr_forcedRemoteMode_read);
}
catch(Tango::DevFailed &df)
{
......@@ -439,8 +424,23 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
(const char*) "reading failure on hardware",
(const char*) "CYBERSTARx1000::read_forcedRemoteMode()");
}
response = process_string(response);
int forced_remote = XString<int>::convertFromString(response);
if (forced_remote == 0)
{
*attr_forcedRemoteMode_read=false;
}
else if (forced_remote == 1)
{
*attr_forcedRemoteMode_read=true;
}
else
{
ERROR_STREAM<<"read forcedRemoveMode has failed, see in CYBERSTARx1000::read_forcedRemoteMode() "<<endl;
}
attr.set_value(attr_forcedRemoteMode_read);
}
//+----------------------------------------------------------------------------
......@@ -475,12 +475,6 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
try
{
response = write_read(":INP0:GAIN?",true);
response = process_string(response);
*attr_amplifierGain_read = XString<double>::convertFromString(response);
attr.set_value(attr_amplifierGain_read);
}
catch(Tango::DevFailed &df)
{
......@@ -491,6 +485,12 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
(const char*) "CYBERSTARx1000::read_amplifierGain()");
}
response = process_string(response);
*attr_amplifierGain_read = XString<double>::convertFromString(response);
attr.set_value(attr_amplifierGain_read);
}
//+----------------------------------------------------------------------------
......@@ -525,12 +525,6 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
try
{
response = write_read(":SENS0:PKT?",true);
response = process_string(response);
*attr_peakingTime_read = XString<double>::convertFromString(response);
attr.set_value(attr_peakingTime_read);
}
catch(Tango::DevFailed &df)
{
......@@ -540,7 +534,11 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
(const char*) "reading failure on hardware",
(const char*) "CYBERSTARx1000::read_peakingTime()");
}
response = process_string(response);
*attr_peakingTime_read = XString<double>::convertFromString(response);
attr.set_value(attr_peakingTime_read);
}
//+----------------------------------------------------------------------------
......@@ -681,7 +679,7 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
DEBUG_STREAM << "write_read(): entering... cmd_to_send =" << cmd_to_send << endl;
string response="";
long nb_char_written;
long nb_char_written,mode=2;
try
{
......@@ -692,13 +690,16 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
(*LF)[0] = 10;
// create a serialline device proxy if it don't exist
if(!mySerial)
if(mySerial==0)
{
init_proxy_Serialline();
}
//DEBUG_STREAM << "write_read(): entering... init_CYBERSTARx1000() " << endl;
if(!init_CYBERSTARx1000_done)
{
init_CYBERSTARx1000();
mySerial->command_in("DevSerFlush",mode);
}
//- send command
mySerial->command_inout("DevSerWriteString", cmd_to_send.c_str(),nb_char_written);
......@@ -783,35 +784,11 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
{
ERROR_STREAM << df << std::endl;
set_state(Tango::FAULT);
set_status("Cannot send or read data on the SerialLine device");
if(mySerial)
{
delete mySerial;
mySerial=0;
}
Tango::Except::re_throw_exception(df,
(const char*) "CONNECTION_ERROR",
(const char*) "OUT_OF_MEMORY",
(const char*) "Cannot send or read data on the SerialLine device",
(const char*) "CYBERSTARx1000::init_proxy_Serialline()");
}
catch(std::bad_alloc)
{
//this->init_device_done = false;
FATAL_STREAM << "CYBERSTARx1000::read() : OUT_OF_MEMORY unable to create proxy on SerialLine " << endl;
set_state(Tango::FAULT);
set_status("OUT_OF_MEMORY unable to create proxy on SerialLine");
if(mySerial)
{
delete mySerial;
mySerial=0;
}
}
}//end function
......@@ -830,25 +807,19 @@ void CYBERSTARx1000::write_windowCenterPosition(Tango::WAttribute &attr)
try
{
int length = origin_string.size();
int index_ACK = origin_string.find_last_of(0x06,length);
processed_string = origin_string.substr(index_ACK+1,length - index_ACK);
// the "ack" character at the begining of the string is removed
processed_string = origin_string.substr(1);
return processed_string;
}
catch(...)
{
set_state(Tango::FAULT);
set_status("Unknwown exception caught in CYBERSTARx1000::process_string()");
ERROR_STREAM<<"Unknwown exception caught in CYBERSTARx1000::process_string()"<<endl;
Tango::Except::throw_exception(
(const char*) "CONNECTION_ERROR",
(const char*) "Cannot send or read data on the SerialLine device ",
(const char*) "parsing string has failed in CYBERSTARx1000::process_string() ",
(const char*) "CYBERSTARx1000::write_read()");
}
}
......@@ -930,20 +901,15 @@ Tango::DevState CYBERSTARx1000::dev_state()
Tango::Attribute &low_threshold = dev_attr->get_attr_by_name("scaLowerThreshold");
Tango::Attribute &high_threshold = dev_attr->get_attr_by_name("scaUpperThreshold");
// update attributes SCA threshold
read_lower();
read_upper();
// update attributes SCA threshold, useful with scan server interfacing
//read_lower();
//read_upper();
double borneLowerPlus = (this->attr_windowCenterPosition_write - this->attr_windowWidth_write/2)*(2 - (tolerance/100));
double borneLowerMoins = (this->attr_windowCenterPosition_write - this->attr_windowWidth_write/2)*tolerance/100 ;
double borneUpperPlus = (this->attr_windowCenterPosition_write + this->attr_windowWidth_write/2)*(2 - (tolerance/100));
double borneUpperMoins = (this->attr_windowCenterPosition_write + this->attr_windowWidth_write/2)*tolerance/100;
/*double borneLowerPlus = (this->attr_windowCenterPosition_write - this->attr_windowWidth_write/2) + tolerance ;
double borneLowerMoins = (this->attr_windowCenterPosition_write - this->attr_windowWidth_write/2)- tolerance ;
double borneUpperPlus = (this->attr_windowCenterPosition_write + this->attr_windowWidth_write/2) + tolerance ;
double borneUpperMoins = (this->attr_windowCenterPosition_write + this->attr_windowWidth_write/2)- tolerance ;*/
INFO_STREAM << "borne lower moins = " << XString<double>::convertToString(borneLowerMoins) << endl;
INFO_STREAM << "borne lower plus = " << XString<double>::convertToString(borneLowerPlus) << endl;
INFO_STREAM << "borne upper moins = " << XString<double>::convertToString(borneUpperMoins) << endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment