Skip to content
Snippets Groups Projects
Commit d5bc240c authored by Xavier ELATTAOUI's avatar Xavier ELATTAOUI
Browse files

Failed to write voltage at Init fixed

parent 78619341
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@ from conan import ConanFile
class SY2527ChannelRecipe(ConanFile):
name = "sy2527channel"
executable = "ds_SY2527Channel"
version = "1.0.4"
version = "1.0.5"
package_type = "application"
user = "soleil"
python_requires = "base/[>=1.0]@soleil/stable"
......
......@@ -8,7 +8,7 @@
</parent>
<groupId>fr.soleil.device</groupId>
<artifactId>SY2527Channel-${aol}-${mode}</artifactId>
<version>1.0.5-SNAPSHOT</version>
<version>1.0.5</version>
<packaging>nar</packaging>
<name>SY2527Channel</name>
<description>SY2527Channel device</description>
......
......@@ -29,8 +29,8 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
//=============================================================================
#include <tango.h>
#include <SY2527ChannelClass.h>
// #include <tango.h>
#include "SY2527ChannelClass.h"
/**
* Create SY2527ChannelClass singleton and store it in DServer object.
......
......@@ -24,7 +24,7 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
// - slotNumber and channelNumber are described in status attribute
//
// Revision 1.6 2007/09/07 13:14:56 sebleport
// - add position_in_crate (vector) data member
// - add m_position_in_crate (vector) data member
//
// Revision 1.5 2007/09/06 09:21:12 sebleport
// - shiftVoltage changed by deltaVoltage attribute
......@@ -72,9 +72,9 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
//===================================================================
#include <tango.h>
#include <SY2527Channel.h>
#include <SY2527ChannelClass.h>
// #include <tango.h>
// #include <SY2527Channel.h>
#include "SY2527ChannelClass.h"
namespace SY2527Channel_ns
{
......@@ -118,8 +118,13 @@ namespace SY2527Channel_ns
// Delete device's allocated object
DELETE_SCALAR_ATTRIBUTE(attr_voltage_read);
position_in_crate.clear();
m_position_in_crate.clear();
if(m_crate_proxy)
{
delete m_crate_proxy;
m_crate_proxy = 0;
}
}
//+----------------------------------------------------------------------------
......@@ -135,16 +140,16 @@ namespace SY2527Channel_ns
// Initialise variables to default values
//--------------------------------------------
SY2527_crate_proxy = 0;
message="";
m_crate_proxy = 0;
m_message = "";
get_device_property();
CREATE_SCALAR_ATTRIBUTE(attr_voltage_read);
// initialise array of parameters for Proxy commands
position_in_crate.push_back(slotNumber);
position_in_crate.push_back(channelNumber);
m_position_in_crate.push_back(slotNumber);
m_position_in_crate.push_back(channelNumber);
}
//+----------------------------------------------------------------------------
......@@ -164,7 +169,8 @@ namespace SY2527Channel_ns
const long IMPOSSIBLE_VALUE = -1;
slotNumber = IMPOSSIBLE_VALUE;
slotNumber = IMPOSSIBLE_VALUE;
channelNumber = IMPOSSIBLE_VALUE;
sY2527CrateProxyName = "";
// Read device properties from database.(Automatic code generation)
//------------------------------------------------------------------
......@@ -209,8 +215,6 @@ namespace SY2527Channel_ns
// And try to extract SY2527CrateProxyName value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> sY2527CrateProxyName;
// End of Automatic code generation
//------------------------------------------------------------------
......@@ -226,7 +230,7 @@ namespace SY2527Channel_ns
//the property has not been declared in the database
SlotNum << IMPOSSIBLE_VALUE;
db_d.push_back(SlotNum);
message += "SlotNum property is missing ! \n";
m_message += "SlotNum property is missing ! \n";
}
// default channel number
......@@ -235,7 +239,7 @@ namespace SY2527Channel_ns
// idem
ChNum << IMPOSSIBLE_VALUE;
db_d.push_back(ChNum);
message += " channelNumber property is missing ! \n";
m_message += " channelNumber property is missing ! \n";
}
// default sY2527Crate Proxy Name
......@@ -244,12 +248,16 @@ namespace SY2527Channel_ns
// idem
SY2527CratePrName << "none";
db_d.push_back(SY2527CratePrName);
message += "sY2527CrateProxyName property is missing !\n";
m_message += "sY2527CrateProxyName property is missing !\n";
}
// write not declared propreties in database.
if(db_d.is_empty())
{
get_db_device()->put_property(db_d);
}
}
//+----------------------------------------------------------------------------
//
// method : SY2527Channel::always_executed_hook()
......@@ -259,21 +267,19 @@ namespace SY2527Channel_ns
//-----------------------------------------------------------------------------
void SY2527Channel::always_executed_hook()
{
if(SY2527_crate_proxy==0)
if( !m_crate_proxy )
{
SY2527_crate_proxy = new Tango::DeviceProxyHelper(this->sY2527CrateProxyName,this);
m_crate_proxy = new Tango::DeviceProxyHelper(sY2527CrateProxyName,this);
if(SY2527_crate_proxy==0)
if(!m_crate_proxy)
{
Tango::Except::throw_exception(
static_cast<const char*>("OUT_OF_MEMORY"),
static_cast<const char*>("could not create SY2527 device proxy"),
static_cast<const char*>("SY2527Channel::always_executed_hook")
);
Tango::Except::throw_exception("OUT_OF_MEMORY",
"could not create SY2527 device proxy",
"SY2527Channel::always_executed_hook");
}
}
}
//+----------------------------------------------------------------------------
//
// method : SY2527Channel::read_attr_hardware
......@@ -283,9 +289,10 @@ void SY2527Channel::always_executed_hook()
//-----------------------------------------------------------------------------
void SY2527Channel::read_attr_hardware(vector<long> &attr_list)
{
DEBUG_STREAM << "SY2527Channel::read_attr_hardware(vector<long> &attr_list) entering... "<< endl;
// DEBUG_STREAM << "SY2527Channel::read_attr_hardware(vector<long> &attr_list) entering... "<< endl;
// Add your own code here
}
//+----------------------------------------------------------------------------
//
// method : SY2527Channel::read_deltaVoltage
......@@ -295,7 +302,7 @@ void SY2527Channel::read_attr_hardware(vector<long> &attr_list)
//-----------------------------------------------------------------------------
void SY2527Channel::read_deltaVoltage(Tango::Attribute &attr)
{
DEBUG_STREAM << "SY2527Channel::read_deltaVoltage(Tango::Attribute &attr) entering... "<< endl;
// DEBUG_STREAM << "SY2527Channel::read_deltaVoltage(Tango::Attribute &attr) entering... "<< endl;
}
//+----------------------------------------------------------------------------
......@@ -307,13 +314,13 @@ void SY2527Channel::read_deltaVoltage(Tango::Attribute &attr)
//-----------------------------------------------------------------------------
void SY2527Channel::write_deltaVoltage(Tango::WAttribute &attr)
{
DEBUG_STREAM << "SY2527Channel::write_deltaVoltage(Tango::WAttribute &attr) entering... "<< endl;
// DEBUG_STREAM << "SY2527Channel::write_deltaVoltage(Tango::WAttribute &attr) entering... "<< endl;
attr.get_write_value(attr_deltaVoltage_write);
double presetVoltage = attr_voltage_write + attr_deltaVoltage_write;
vector <double> set_delta_voltage_array;
std::vector <double> set_delta_voltage_array;
set_delta_voltage_array.push_back(slotNumber);
set_delta_voltage_array.push_back(channelNumber);
......@@ -321,22 +328,24 @@ void SY2527Channel::write_deltaVoltage(Tango::WAttribute &attr)
try
{
SY2527_crate_proxy->command_in("SetVoltageOnChannel",set_delta_voltage_array);
if(m_crate_proxy)
{
m_crate_proxy->command_in("SetVoltageOnChannel",set_delta_voltage_array);
}
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
if(m_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
delete m_crate_proxy;
m_crate_proxy = 0;
}
ERROR_STREAM<<df<<endl;
ERROR_STREAM << df << std::endl;
throw df;
}
}
//+----------------------------------------------------------------------------
//
// method : SY2527Channel::read_voltage
......@@ -346,28 +355,29 @@ void SY2527Channel::write_deltaVoltage(Tango::WAttribute &attr)
//-----------------------------------------------------------------------------
void SY2527Channel::read_voltage(Tango::Attribute &attr)
{
DEBUG_STREAM << "SY2527Channel::read_voltage(Tango::Attribute &attr) entering... "<< endl;
// DEBUG_STREAM << "SY2527Channel::read_voltage(Tango::Attribute &attr) entering... "<< endl;
try
{
SY2527_crate_proxy->command_inout("GetMeasVoltageOnChannel",position_in_crate,*attr_voltage_read);
if(m_crate_proxy)
{
m_crate_proxy->command_inout("GetMeasVoltageOnChannel",m_position_in_crate,*attr_voltage_read);
}
attr.set_value(attr_voltage_read);
attr.set_quality(Tango::ATTR_VALID);
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
if(m_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
delete m_crate_proxy;
m_crate_proxy = 0;
}
attr.set_value(attr_voltage_read);
attr.set_quality(Tango::ATTR_INVALID);
ERROR_STREAM<<df<<endl;
ERROR_STREAM << df << std::endl;
throw df;
}
}
......@@ -385,7 +395,7 @@ void SY2527Channel::write_voltage(Tango::WAttribute &attr)
attr.get_write_value(attr_voltage_write);
vector <double> set_voltage_array;
std::vector <double> set_voltage_array;
set_voltage_array.push_back(slotNumber);
set_voltage_array.push_back(channelNumber);
......@@ -393,15 +403,17 @@ void SY2527Channel::write_voltage(Tango::WAttribute &attr)
try
{
SY2527_crate_proxy->command_in("SetVoltageOnChannel",set_voltage_array);
if(m_crate_proxy)
{
m_crate_proxy->command_in("SetVoltageOnChannel",set_voltage_array);
}
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
if(m_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
delete m_crate_proxy;
m_crate_proxy = 0;
}
ERROR_STREAM<<df<<endl;
......@@ -427,14 +439,17 @@ void SY2527Channel::power_on()
try
{
SY2527_crate_proxy->command_in("PowerOnChannel",position_in_crate);
if(m_crate_proxy)
{
m_crate_proxy->command_in("PowerOnChannel",m_position_in_crate);
}
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
if(m_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
delete m_crate_proxy;
m_crate_proxy = 0;
}
ERROR_STREAM<<df<<endl;
......@@ -459,14 +474,17 @@ void SY2527Channel::power_off()
// Add your own code to control device here
try
{
SY2527_crate_proxy->command_in("PowerOffChannel",position_in_crate);
if(m_crate_proxy)
{
m_crate_proxy->command_in("PowerOffChannel",m_position_in_crate);
}
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
if(m_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
delete m_crate_proxy;
m_crate_proxy = 0;
}
ERROR_STREAM<<df<<endl;
......@@ -492,10 +510,10 @@ Tango::DevState SY2527Channel::dev_state()
// Add your own code to control device here
std::stringstream s;
Tango::DevState state_to_return;
Tango::DevState state_to_return = Tango::UNKNOWN;
// concatenate internal message string
s << message << endl;
// concatenate internal m_message string
s << m_message << endl;
s << "Slot Number : " + this->slotNumber << endl;
s << "Channel Number : " + this->channelNumber << endl;
......@@ -505,16 +523,16 @@ Tango::DevState SY2527Channel::dev_state()
// try to get channel status byte
try
{
SY2527_crate_proxy->command_inout("GetChannelStatus",position_in_crate,status_byte);
m_crate_proxy->command_inout("GetChannelStatus",m_position_in_crate,status_byte);
}
catch(Tango::DevFailed &df)
{
ERROR_STREAM<<df<<endl;
if(SY2527_crate_proxy!=0)
if(m_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
delete m_crate_proxy;
m_crate_proxy = 0;
}
s << "No Communication with SY2527Crate, try to init the SY2527Crate DS again"<<endl;
......
......@@ -38,8 +38,8 @@
#define _SY2527CHANNEL_H
#include <tango.h>
#include "DeviceProxyHelper.h"
#include "PogoHelper.h"
#include <DeviceProxyHelper.h>
#include <PogoHelper.h>
//macro
/*#define SEND_COMMAND_TO_CRATE(CrateCommand,ArgNum)
......@@ -249,9 +249,9 @@ protected :
// Add your own data members here
//-----------------------------------------
Tango::DeviceProxyHelper * SY2527_crate_proxy;
std::string message;
vector <unsigned short> position_in_crate;
Tango::DeviceProxyHelper * m_crate_proxy;
std::string m_message;
std::vector <unsigned short> m_position_in_crate;
};
......
......@@ -39,10 +39,10 @@ static const char *HttpServer= "http://www.esrf.fr/computing/cs/tango/tango_doc/
//=============================================================================
#include <tango.h>
// #include <tango.h>
#include <SY2527Channel.h>
#include <SY2527ChannelClass.h>
// #include <SY2527Channel.h>
#include "SY2527ChannelClass.h"
//+----------------------------------------------------------------------------
......
......@@ -34,8 +34,8 @@
#ifndef _SY2527CHANNELCLASS_H
#define _SY2527CHANNELCLASS_H
#include <tango.h>
#include <SY2527Channel.h>
// #include <tango.h>
#include "SY2527Channel.h"
namespace SY2527Channel_ns
......
......@@ -29,9 +29,9 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
// (c) - Software Engineering Group - ESRF
//=============================================================================
#include <tango.h>
#include <SY2527Channel.h>
#include <SY2527ChannelClass.h>
// #include <tango.h>
// #include <SY2527Channel.h>
#include "SY2527ChannelClass.h"
/*====================================================================
* This file contains the methods to allow commands and attributes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment