Commit b8364fad authored by Alessio Igor Bogani's avatar Alessio Igor Bogani
Browse files

Initial import

parent 1d9dd290
CMakeCache.txt
cmake_install.cmake
Makefile
CMakeFiles
bin
cscope.out
core*
//+=============================================================================
//
// file : ClassFactory.cpp
//
// description : C++ source for the class_factory method of the DServer
// device class. This method is responsible to create
// all class singletin for a device server. It is called
// at device server startup
//
// project : TANGO Device Server
//
// $Author: alessio $
//
// $Revision: 1.2 $
//
// $Log: ClassFactory.cpp,v $
// Revision 1.2 2011-02-08 15:35:28 alessio
// Fix some build warnings
//
// Revision 1.1 2011/02/01 08:15:27 alessio
// Move source files to src/
//
// Revision 1.2 2008/07/02 15:11:22 enrico
// Added Parameter command to allow request custom parameter data (P1-P4)
// Added attributes for wave parameters such as NominalBits, VerticalScaledData
// ecc.
//
//
// copyleft : European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
#include <tango.h>
#include <LecroyInterfaceClass.h>
/**
* Create LecroyInterfaceClass singleton and store it in DServer object.
*/
void Tango::DServer::class_factory()
{
add_class(LecroyInterface_ns::LecroyInterfaceClass::init("LecroyInterface"));
}
//******************************************************************************************
//
//
// september 13, 2004 : Source file for the communication exceptions in socket mode
//
// with a Lecroy scope (avaiable for all models)
//
//
// author : X.Elattaoui
//
// LecroyException.cpp: interface for the socket & waveform exceptions class.
//
//******************************************************************************************
// ============================================================================
// DEPENDENCIES
#include "LecroyException.h"
namespace lecroy {
// ============================================================================
// Error::Error
// ============================================================================
Error::Error (void)
: reason ("unknown"),
desc ("unknown error"),
origin ("unknown"),
severity (lecroy::ERR)
{
}
// ============================================================================
// Error::Error
// ============================================================================
Error::Error (const char *_reason,
const char *_desc,
const char *_origin,
int _severity)
: reason (_reason),
desc (_desc),
origin (_origin),
severity (_severity)
{
}
// ============================================================================
// Error::Error
// ============================================================================
Error::Error (const std::string& _reason,
const std::string& _desc,
const std::string& _origin,
int _severity)
: reason (_reason),
desc (_desc),
origin (_origin),
severity (_severity)
{
}
// ============================================================================
// Error::Error
// ============================================================================
Error::Error (const Error& _src)
: reason (_src.reason),
desc (_src.desc),
origin (_src.origin),
severity (_src.severity)
{
}
// ============================================================================
// Error::~Error
// ============================================================================
Error::~Error (void)
{
}
// ============================================================================
// Error::operator=
// ============================================================================
Error& Error::operator= (const Error& _src)
{
//- no self assign
if (this == &_src) {
return *this;
}
this->reason = _src.reason;
this->desc = _src.desc;
this->origin = _src.origin;
this->severity = _src.severity;
return *this;
}
// ============================================================================
// LecroyException::LecroyException
// ============================================================================
LecroyException::LecroyException (void)
: errors(0)
{
this->push_error(Error());
}
// ============================================================================
// LecroyException::LecroyException
// ============================================================================
LecroyException::LecroyException (const char *_reason,
const char *_desc,
const char *_origin,
int _severity)
: errors(0)
{
this->push_error(Error(_reason, _desc, _origin, _severity));
}
// ============================================================================
// LecroyException::LecroyException
// ============================================================================
LecroyException::LecroyException (const std::string& _reason,
const std::string& _desc,
const std::string& _origin,
int _severity)
: errors(0)
{
this->push_error(_reason, _desc, _origin,_severity);
}
// ============================================================================
// LecroyException::LecroyException
// ============================================================================
LecroyException::LecroyException (const LecroyException& _src)
: errors(0)
{
for (unsigned int i = 0; i < _src.errors.size(); i++) {
this->push_error(_src.errors[i]);
}
}
// ============================================================================
// LecroyException::LecroyException
// ============================================================================
LecroyException& LecroyException::operator= (const LecroyException& _src)
{
//- no self assign
if (this == &_src) {
return *this;
}
this->errors.clear();
for (unsigned int i = 0; i < _src.errors.size(); i++) {
this->push_error(_src.errors[i]);
}
return *this;
}
// ============================================================================
// LecroyException::~LecroyException
// ============================================================================
LecroyException::~LecroyException (void)
{
this->errors.clear();
}
// ============================================================================
// LecroyException::push_error
// ============================================================================
void LecroyException::push_error (const char *_reason,
const char *_desc,
const char *_origin,
int _severity)
{
this->errors.push_back(Error(_reason, _desc, _origin, _severity));
}
// ============================================================================
// LecroyException::push_error
// ============================================================================
void LecroyException::push_error (const std::string& _reason,
const std::string& _desc,
const std::string& _origin,
int _severity)
{
this->errors.push_back(Error(_reason, _desc, _origin, _severity));
}
// ============================================================================
// LecroyException::push_error
// ============================================================================
void LecroyException::push_error (const Error& _error)
{
this->errors.push_back(_error);
}
} // namespace lecroy
#ifndef _LECROYEXCEPTION
#define _LECROYEXCEPTION
#include <string>
#include <vector>
namespace lecroy{
// ============================================================================
// lecroy Errors severities
// ============================================================================
typedef enum {
WARN,
ERR,
PANIC
} ErrorSeverity;
// ============================================================================
//! The lecroy exception abstraction base class.
// ============================================================================
//!
//! detailed description to be written
//!
// ============================================================================
class Error
{
public:
/**
* Initialization.
*/
Error (void);
/**
* Initialization.
*/
Error (const char *reason,
const char *desc,
const char *origin,
int severity = lecroy::ERR);
/**
* Initialization.
*/
Error (const std::string& reason,
const std::string& desc,
const std::string& origin,
int severity = lecroy::ERR);
/**
* Copy constructor.
*/
Error (const Error& src);
/**
* Error details: code
*/
virtual ~Error (void);
/**
* operator=
*/
Error& operator= (const Error& _src);
/**
* Error details: reason
*/
std::string reason;
/**
* Error details: description
*/
std::string desc;
/**
* Error details: origin
*/
std::string origin;
/**
* Error details: severity
*/
int severity;
};
// ============================================================================
// The lecroy error list.
// ============================================================================
typedef std::vector<Error> ErrorList;
// ============================================================================
//! The lecroy exception abstraction base class.
// ============================================================================
//!
//! detailed description to be written
//!
// ============================================================================
class LecroyException
{
public:
/**
* Initialization.
*/
LecroyException (void);
/**
* Initialization.
*/
LecroyException (const char *reason,
const char *desc,
const char *origin,
int severity = lecroy::ERR);
/**
* Initialization.
*/
LecroyException (const std::string& reason,
const std::string& desc,
const std::string& origin,
int severity = lecroy::ERR);
/**
* Initialization.
*/
LecroyException (const Error& error);
/**
* Copy constructor.
*/
LecroyException (const LecroyException& src);
/**
* operator=
*/
LecroyException& operator= (const LecroyException& _src);
/**
* Release resources.
*/
virtual ~LecroyException (void);
/**
* Push the specified error into the errors list.
*/
void push_error (const char *reason,
const char *desc,
const char *origin,
int severity = lecroy::ERR);
/**
* Push the specified error into the errors list.
*/
void push_error (const std::string& reason,
const std::string& desc,
const std::string& origin,
int severity = lecroy::ERR);
/**
* Push the specified error into the errors list.
*/
void push_error (const Error& error);
/**
* The errors list
*/
ErrorList errors;
};
} // end namspace lecroy
#endif //__LECROYEXCEPTION
//+=============================================================================
//
// file : LecroyInterface.cpp
//
// description : C++ source for the LecroyInterface and its commands.
// The class is derived from Device. It represents the
// CORBA servant object which will be accessed from the
// network. All commands which can be executed on the
// LecroyInterface are implemented in this file.
//
// project : TANGO Device Server
//
// $Author: claudio $
//
// $Revision: 1.6 $
//
// $Log: LecroyInterface.cpp,v $
// Revision 1.6 2020-01-13 14:06:27 claudio
// use TANG_BASE_CLASS
//
// Revision 1.5 2019-06-13 07:35:44 alessio
// Move to Tango 9
//
// Revision 1.4 2013-05-31 09:01:01 alessio
// Fix some build warnings
//
// Revision 1.3 2013-05-31 08:27:28 alessio
// Move to Tango8, use the new Makefile fixing build warnings
//
// Revision 1.2 2011/02/08 15:35:28 alessio
// Fix some build warnings
//
// Revision 1.1 2011/02/01 08:15:27 alessio
// Move source files to src/
//
// Revision 1.8 2011/01/26 08:14:52 alessio
// Remove redundant connection loop
//
// Revision 1.7 2009/05/08 10:41:54 enrico
// Compiles under Ubuntu 8.10. ME
//
// Revision 1.6 2009/01/14 11:06:09 enrico
// Completed comments and descriptions; generated documents.
// ME
//
// Revision 1.5 2008/09/26 15:03:48 enrico
// Added commands to read counters in Pass/Fail mode
// (i.e. GetPassFailTotCounter and GetPassFailPassedCounter)
// ME
//
// Revision 1.4 2008/09/25 09:49:52 enrico
// Added Normal/Stop trigger mode/Clear sweeps commands.
// ...waiting for Lecroy engineers about misfunction of MTPC? command.
// ME
//
// Revision 1.3 2008/07/09 10:45:11 enrico
// Memory leak resolved. ME
//
// Revision 1.2 2008/07/02 15:11:22 enrico
// Added Parameter command to allow request custom parameter data (P1-P4)
// Added attributes for wave parameters such as NominalBits, VerticalScaledData
// ecc.
//
//
// copyleft : Sincrotrone Trieste S.C.p.A.
// Strada Statale 14 - km 163,5 in AREA Science Park
// 34012 Basovizza, Trieste
// ITALY
//
//-=============================================================================
//
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//
// (c) - Software Engineering Group - ESRF
//=============================================================================
//===================================================================
//
// The following table gives the correspondence
// between commands and method name.
//
// Command name | Method name
// ----------------------------------------
// State | dev_state()
// Status | dev_status()
// Test | test()
// GetRawWaveform | get_raw_waveform()
// SetChannel | set_channel()
// GetParameter | get_parameter()
// SendCommand | send_command()
// StopAcquisition | stop_acquisition()
// StartAcquisition | start_acquisition()
// ClearSweeps | clear_sweeps()
// GetPassFailTotCounter | get_pass_fail_tot_counter()
// GetPassFailPassedCounter | get_pass_fail_passed_counter()
//
//===================================================================
#include <tango.h>
#include <LecroyInterface.h>
#include <LecroyInterfaceClass.h>
#include "MyUtils.h"
#define TCP_PORT 1861
#define STRING_SIZE 256
// 0xA
#define LF 10
// 0xD
#define CR 13
// #define DEBUG
//
// #ifndef DEBUG
// #ifndef dbgprintf
// static void dbgprintf(...) {}
// #endif
// #else
// #define dbgprintf printf
// #endif
namespace LecroyInterface_ns
{
//+----------------------------------------------------------------------------
//
// method : LecroyInterface::LecroyInterface(string &s)
//
// description : constructor for simulated LecroyInterface
//
// in : - cl : Pointer to the DeviceClass object
// - s : Device name
//
//-----------------------------------------------------------------------------
LecroyInterface::LecroyInterface(Tango::DeviceClass *cl,string &s)
:TANGO_BASE_CLASS(cl,s.c_str())
{
init_device();
}
LecroyInterface::LecroyInterface(Tango::DeviceClass *cl,const char *s)
:TANGO_BASE_CLASS(cl,s)
{
init_device();
}
LecroyInterface::LecroyInterface(Tango::DeviceClass *cl,const char *s,const char *d)
:TANGO_BASE_CLASS(cl,s,d)
{
init_device();
}
//+----------------------------------------------------------------------------
//
// method : LecroyInterface::delete_device()
//
// description : will be called at device destruction or at init command.
//
//-----------------------------------------------------------------------------
void LecroyInterface::delete_device()
{
// Delete device's allocated object
//- Delete device's allocated object
if (attr_RawWaveformData_read) {
delete [] attr_RawWaveformData_read;
attr_RawWaveformData_read = 0;
}
if (attr_VerticalScaledData_read) {
delete [] attr_VerticalScaledData_read;
attr_VerticalScaledData_read = 0;
}
if (attr_WaveArray1_read) {
delete attr_WaveArray1_read;
attr_WaveArray1_read = 0;
}
if (attr_WaveArray2_read) {
delete attr_WaveArray2_read;
attr_WaveArray2_read = 0;
}
if (attr_WaveArrayCount_read) {
delete attr_WaveArrayCount_read;
attr_WaveArrayCount_read = 0;
}
if (attr_NominalBits_read) {
delete attr_NominalBits_read;
attr_NominalBits_read = 0;
}