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

the command and attribute code has been implemeted

parent 2bb66de2
No related branches found
No related tags found
No related merge requests found
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/SY2527Channel/src/ClassFactory.cpp,v 1.1 2007-08-31 12:31:28 syldup Exp $";
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/SY2527Channel/src/ClassFactory.cpp,v 1.2 2007-09-05 09:41:37 sebleport Exp $";
//+=============================================================================
//
// file : ClassFactory.cpp
......@@ -10,9 +10,9 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
//
// project : TANGO Device Server
//
// $Author: syldup $
// $Author: sebleport $
//
// $Revision: 1.1 $
// $Revision: 1.2 $
//
// $Log: not supported by cvs2svn $
//
......
#
device_server= SY2527Channel
#
# LEs PATHS des includes propres à ce DServer
# Mettre /Ic:\monchemininclude /ID:\monautrechemininclude
#CAEN_HV_WRAPPER_INC = .\..\include
#CAEN_HV_WRAPPER_LIB = .\..\lib
#INCUSER= /I$(CAEN_HV_WRAPPER_INC)
#
# Le chemin complet de vos Librairies
#
# LIBUSER = "x:\moncheminlibrairie\malibrairie.lib"
#LIBUSER= $(CAEN_HV_WRAPPER_LIB)\CAENHVWrapper.lib
# Si vous souhaitez générer une librairie et pas un executable
# decommentez la ligne suivante
#LIBRARY_NAME= d:\temp\hkl\lib\hkl.lib
#
# Le chemin ou j'ai d'autres fichiers sources que ceux du DeviceServer à compiler
CPPDIRUSER=
#
# ------------------Fin des modifications pour le end user -------------------------------------
#
make_dir=$(SOLEIL_ROOT)\env
# Les définitions communes à tous les DeviceServeurs
!include $(make_dir)\tango.opt
exe_device_server= $(EXEDIR)\ds_$(device_server).exe
pdb_name= $(TEMPLIBDIR)\$(device_server).pdb
# --------------------------------------
# Partie spécifique Device Server
# --------------------------------------
# --------------------------------------
# Partie spécifique Device Server
# --------------------------------------
LISTEOBJ = \
$(OBJDIR)\$(device_server).OBJ\
$(OBJDIR)\ClassFactory.OBJ\
$(OBJDIR)\$(device_server)StateMachine.OBJ\
$(OBJDIR)\main.OBJ\
$(OBJDIR)\$(device_server)Class.OBJ
# --------------------------------------
!include $(make_dir)\common_target.opt
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/SY2527Channel/src/SY2527Channel.cpp,v 1.1 2007-08-31 12:31:28 syldup Exp $";
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/SY2527Channel/src/SY2527Channel.cpp,v 1.2 2007-09-05 09:41:37 sebleport Exp $";
//+=============================================================================
//
// file : SY2527Channel.cpp
......@@ -11,9 +11,9 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
//
// project : TANGO Device Server
//
// $Author: syldup $
// $Author: sebleport $
//
// $Revision: 1.1 $
// $Revision: 1.2 $
//
// $Log: not supported by cvs2svn $
//
......@@ -67,18 +67,21 @@ SY2527Channel::SY2527Channel(Tango::DeviceClass *cl,string &s)
:Tango::Device_3Impl(cl,s.c_str())
{
init_device();
SY2527_crate_proxy = 0;
}
SY2527Channel::SY2527Channel(Tango::DeviceClass *cl,const char *s)
:Tango::Device_3Impl(cl,s)
{
init_device();
SY2527_crate_proxy = 0;
}
SY2527Channel::SY2527Channel(Tango::DeviceClass *cl,const char *s,const char *d)
:Tango::Device_3Impl(cl,s,d)
{
init_device();
SY2527_crate_proxy = 0;
}
//+----------------------------------------------------------------------------
//
......@@ -90,6 +93,8 @@ SY2527Channel::SY2527Channel(Tango::DeviceClass *cl,const char *s,const char *d)
void SY2527Channel::delete_device()
{
// Delete device's allocated object
DELETE_SCALAR_ATTRIBUTE(attr_voltage_read);
}
//+----------------------------------------------------------------------------
......@@ -106,6 +111,8 @@ void SY2527Channel::init_device()
// Initialise variables to default values
//--------------------------------------------
get_device_property();
CREATE_SCALAR_ATTRIBUTE(attr_voltage_read);
}
......@@ -121,6 +128,9 @@ void SY2527Channel::get_device_property()
// Initialize your default values here (if not done with POGO).
//------------------------------------------------------------------
long def_slotNumber = 444;
long def_channelNumber = 444;
// Read device properties from database.(Automatic code generation)
//------------------------------------------------------------------
Tango::DbData dev_prop;
......@@ -169,6 +179,52 @@ void SY2527Channel::get_device_property()
// End of Automatic code generation
//------------------------------------------------------------------
// automatic generation property in the database if no declared under jive
Tango::DbData db_d;
Tango::DbDatum SlotNum("SlotNumber");
Tango::DbDatum ChNum("ChannelNumber");
Tango::DbDatum SY2527CratePrName("SY2527CrateProxyName");
// default slot number
if(slotNumber==def_slotNumber)
{
SlotNum << def_slotNumber;
}
else
{
SlotNum << slotNumber;
}
// default channel number
if(channelNumber==def_channelNumber)
{
ChNum << def_channelNumber;
}
else
{
ChNum << channelNumber;
}
// default sY2527Crate Proxy Name
if(sY2527CrateProxyName.empty()==true)
{
SY2527CratePrName << "none";
}
else
{
SY2527CratePrName << sY2527CrateProxyName;
}
db_d.push_back(SlotNum);
db_d.push_back(ChNum);
db_d.push_back(SY2527CratePrName);
get_db_device()->put_property(db_d);
if(sY2527CrateProxyName=="none")
{
ERROR_STREAM<<" sY2527CrateProxyName property is missing "<<endl;
}
}
//+----------------------------------------------------------------------------
//
......@@ -179,7 +235,24 @@ void SY2527Channel::get_device_property()
//-----------------------------------------------------------------------------
void SY2527Channel::always_executed_hook()
{
if(SY2527_crate_proxy==0)
{
try
{
SY2527_crate_proxy = new Tango::DeviceProxyHelper(this->sY2527CrateProxyName,this);
if(SY2527_crate_proxy==0)
throw std::bad_alloc();
}
catch(std::bad_alloc &)
{
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")
);
}
}
}
//+----------------------------------------------------------------------------
//
......@@ -204,6 +277,34 @@ void SY2527Channel::read_attr_hardware(vector<long> &attr_list)
void SY2527Channel::read_voltage(Tango::Attribute &attr)
{
DEBUG_STREAM << "SY2527Channel::read_voltage(Tango::Attribute &attr) entering... "<< endl;
Tango::DevVarShortArray * argin = new Tango::DevVarShortArray[2];
argin[0] = slotNumber;
argin[1] = channelNumber;
try
{
SY2527_crate_proxy->command_inout("GetMeasVoltageOnChannel",argin,*attr_voltage_read);
attr.set_value(attr_voltage_read);
attr.set_quality(Tango::ATTR_VALID);
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
}
attr.set_value(attr_voltage_read);
attr.set_quality(Tango::ATTR_INVALID);
ERROR_STREAM<<df<<endl;
throw df;
}
}
//+----------------------------------------------------------------------------
......@@ -216,6 +317,32 @@ void SY2527Channel::read_voltage(Tango::Attribute &attr)
void SY2527Channel::write_voltage(Tango::WAttribute &attr)
{
DEBUG_STREAM << "SY2527Channel::write_voltage(Tango::WAttribute &attr) entering... "<< endl;
attr.get_write_value(attr_voltage_write);
Tango::DevVarDoubleArray *argin = new Tango::DevVarDoubleArray[3];
argin[0] = slotNumber;
argin[1] = channelNumber;
argin[2] = attr_voltage_write;
try
{
SY2527_crate_proxy->command_in("SetVoltageOnChannel",argin);
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
}
ERROR_STREAM<<df<<endl;
throw df;
}
}
//+----------------------------------------------------------------------------
......@@ -228,6 +355,7 @@ void SY2527Channel::write_voltage(Tango::WAttribute &attr)
void SY2527Channel::read_shiftVoltage(Tango::Attribute &attr)
{
DEBUG_STREAM << "SY2527Channel::read_shiftVoltage(Tango::Attribute &attr) entering... "<< endl;
}
//+----------------------------------------------------------------------------
......@@ -240,8 +368,34 @@ void SY2527Channel::read_shiftVoltage(Tango::Attribute &attr)
void SY2527Channel::write_shiftVoltage(Tango::WAttribute &attr)
{
DEBUG_STREAM << "SY2527Channel::write_shiftVoltage(Tango::WAttribute &attr) entering... "<< endl;
attr.get_write_value(attr_shiftVoltage_write);
double presetVoltage = attr_voltage_write + attr_shiftVoltage_write;
Tango::DevVarDoubleArray *argin = new Tango::DevVarDoubleArray[3];
argin[0] = slotNumber;
argin[1] = channelNumber;
argin[2] = presetVoltage;
try
{
SY2527_crate_proxy->command_in("SetVoltageOnChannel",argin);
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
}
ERROR_STREAM<<df<<endl;
throw df;
}
}
//+------------------------------------------------------------------
/**
......@@ -259,6 +413,26 @@ void SY2527Channel::power_on()
// Add your own code to control device here
Tango::DevVarShortArray *argin = new Tango::DevVarShortArray[2];
argin[0] = slotNumber;
argin[1] = channelNumber;
try
{
SY2527_crate_proxy->command_in("PowerOnChannel",argin);
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
}
ERROR_STREAM<<df<<endl;
throw df;
}
}
//+------------------------------------------------------------------
......@@ -277,6 +451,158 @@ void SY2527Channel::power_off()
// Add your own code to control device here
Tango::DevVarShortArray *argin = new Tango::DevVarShortArray[2];
argin[0] = slotNumber;
argin[1] = channelNumber;
try
{
SY2527_crate_proxy->command_in("PowerOffChannel",argin);
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
}
ERROR_STREAM<<df<<endl;
throw df;
}
}
//+------------------------------------------------------------------
/**
* method: SY2527Channel::dev_state
*
* description: method to execute "State"
* This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
*
* @return State Code
*
*/
//+------------------------------------------------------------------
Tango::DevState SY2527Channel::dev_state()
{
DEBUG_STREAM << "SY2527Channel::dev_state(): entering... !" << endl;
// Add your own code to control device here
Tango::DevState state_to_return;
std::stringstream s;
Tango::DevUShort argout;
short status_byte;
Tango::DevVarUShortArray *argin = new Tango::DevVarUShortArray[2];
argin[0] = slotNumber;
argin[1] = channelNumber;
try
{
SY2527_crate_proxy->command_inout("GetChannelStatus",argin,argout);
}
catch(Tango::DevFailed &df)
{
if(SY2527_crate_proxy!=0)
{
delete SY2527_crate_proxy;
SY2527_crate_proxy = 0;
}
ERROR_STREAM<<df<<endl;
throw df;
}
status_byte = argout;
// RUNNING State
if(status_byte & 0x02) // bit 1
{
s << "Channel is rumping up"<<endl;
state_to_return = Tango::RUNNING;
}
if( status_byte & 0x04) // bit 2
{
s << "Channel is rumping down"<<endl;
state_to_return = Tango::RUNNING;
}
// STANDBY State
if( status_byte & 0x01) // bit 0
{
s << "Channel is on"<<endl;
state_to_return = Tango::STANDBY;
}
else
{
s << "Channel is off"<<endl;
state_to_return = Tango::STANDBY;
}
// ALARM State
if( status_byte & 0x08) // bit 3
{
s << "Channel is over current"<<endl;
state_to_return = Tango::ALARM;
}
if( status_byte & 0x10) // bit 4
{
s << "Channel is over voltage"<<endl;
state_to_return = Tango::ALARM;
}
if( status_byte & 0x20) // bit 5
{
s << "Channel is under voltage"<<endl;
state_to_return = Tango::ALARM;
}
if( status_byte & 0x80) // bit 7
{
s << "Channel is in max V"<<endl;
state_to_return = Tango::ALARM;
}
// FAULT State
if( status_byte & 0x400) // bit 10
{
s << "Channel is in calibration error"<<endl;
state_to_return = Tango::FAULT;
}
if( status_byte & 0x800) // bit 11
{
s << "Channel is unplugged"<<endl;
state_to_return = Tango::FAULT;
}
if(SY2527_crate_proxy==0)
{
s << "No Communication with SY2527Crate, try to init the SY2527Crate DS again"<<endl;
state_to_return = Tango::FAULT;
}
// NO corresponding state
if( status_byte & 0x40) // bit 6
{
s << "Channel is in external trip "<<endl;
}
if( status_byte & 0x100) // bit 8
{
s << "Channel is external disable"<<endl;
}
if( status_byte & 0x200) // bit 9
{
s << "Channel is in internal trip"<<endl;
}
set_status(s.str().c_str());
return state_to_return;
}
} // namespace
......@@ -6,9 +6,9 @@
//
// project : SY2527Channel
//
// $Author: syldup $
// $Author: sebleport $
//
// $Revision: 1.1 $
// $Revision: 1.2 $
//
// $Log: not supported by cvs2svn $
//
......@@ -27,11 +27,21 @@
#define _SY2527CHANNEL_H
#include <tango.h>
#include "DeviceProxyHelper.h"
#include "PogoHelper.h"
//macro
/*#define SEND_COMMAND_TO_CRATE(CrateCommand,ArgNum)
{
}
*/
//using namespace Tango;
/**
* @author $Author: syldup $
* @version $Revision: 1.1 $
* @author $Author: sebleport $
* @version $Revision: 1.2 $
*/
// Add your own constants definitions here.
......@@ -195,6 +205,12 @@ public :
* Execution allowed for PowerOFF command.
*/
virtual bool is_PowerOFF_allowed(const CORBA::Any &any);
/**
* This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller.
* @return State Code
* @exception DevFailed
*/
virtual Tango::DevState dev_state();
/**
* preset voltage is applied on this channel
* @exception DevFailed
......@@ -220,6 +236,8 @@ public :
protected :
// Add your own data members here
//-----------------------------------------
Tango::DeviceProxyHelper * SY2527_crate_proxy;
};
} // namespace_ns
......
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/SY2527Channel/src/SY2527ChannelClass.cpp,v 1.1 2007-08-31 12:31:28 syldup Exp $";
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/SY2527Channel/src/SY2527ChannelClass.cpp,v 1.2 2007-09-05 09:41:37 sebleport Exp $";
static const char *TagName = "$Name: not supported by cvs2svn $";
static const char *HttpServer= "http://www.esrf.fr/computing/cs/tango/tango_doc/ds_doc/";
//+=============================================================================
......@@ -12,9 +12,9 @@ static const char *HttpServer= "http://www.esrf.fr/computing/cs/tango/tango_doc/
//
// project : TANGO Device Server
//
// $Author: syldup $
// $Author: sebleport $
//
// $Revision: 1.1 $
// $Revision: 1.2 $
//
// $Log: not supported by cvs2svn $
//
......
......@@ -10,9 +10,9 @@
//
// project : TANGO Device Server
//
// $Author: syldup $
// $Author: sebleport $
//
// $Revision: 1.1 $
// $Revision: 1.2 $
//
// $Log: not supported by cvs2svn $
//
......
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/SY2527Channel/src/SY2527ChannelStateMachine.cpp,v 1.1 2007-08-31 12:31:28 syldup Exp $";
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/SY2527Channel/src/SY2527ChannelStateMachine.cpp,v 1.2 2007-09-05 09:41:37 sebleport Exp $";
//+=============================================================================
//
// file : SY2527ChannelStateMachine.cpp
......@@ -8,9 +8,9 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
//
// project : TANGO Device Server
//
// $Author: syldup $
// $Author: sebleport $
//
// $Revision: 1.1 $
// $Revision: 1.2 $
//
// $Log: not supported by cvs2svn $
//
......
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/SY2527Channel/src/main.cpp,v 1.1 2007-08-31 12:31:28 syldup Exp $";
static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentation/SY2527Channel/src/main.cpp,v 1.2 2007-09-05 09:41:37 sebleport Exp $";
//+=============================================================================
//
// file : main.cpp
......@@ -10,9 +10,9 @@ static const char *RcsId = "$Header: /users/chaize/newsvn/cvsroot/Instrumentatio
//
// project : TANGO Device Server
//
// $Author: syldup $
// $Author: sebleport $
//
// $Revision: 1.1 $ $
// $Revision: 1.2 $ $
//
// $Log: not supported by cvs2svn $
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment