Skip to content
Snippets Groups Projects
Commit c6642830 authored by Graziano Scalamera's avatar Graziano Scalamera
Browse files

First import from CVS

parent 196e3700
No related branches found
Tags 1.0.0 1.0.1 1.0.2
No related merge requests found
.nse_depinfo
bin
obj
# Eclipse
.cproject
.project
.settings
Makefile 0 → 100644
NAME_SRV = oceanoptics-srv
CXXFLAGS = -DRELEASE='""' -I../../lib/libfit2 -I/runtime/include/seabreeze -I../../lib/libseabreeze/include -I../../drv/rnm -I../../drv/rnmshare -L../../lib/libseabreeze/lib -L../../lib/libfit2 -L../../drv/rnm -L../../drv/rnmshare
LDFLAGS = -lseabreeze -lusb -lfit
HAVE_RNM = 1
ifeq ($(HAVE_RNM),1)
CXXFLAGS += -DHAVE_RNM
LDFLAGS += -lrnm -lrnmshare
endif
include ../makefiles/Make-9.3.3.in
/*----- PROTECTED REGION ID(OceanOptics::ClassFactory.cpp) ENABLED START -----*/
static const char *RcsId = "$Header: /home/cvsadm/cvsroot/fermi/servers/oceanoptics/src/ClassFactory.cpp,v 1.1 2015-03-18 10:38:46 graziano Exp $";
//+=============================================================================
//
// 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: graziano $
//
// $Revision: 1.1 $
//
// $Log: ClassFactory.cpp,v $
// Revision 1.1 2015-03-18 10:38:46 graziano
// first commit
//
//
//
// 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 <OceanOpticsClass.h>
/**
* Create OceanOpticsClass singleton and store it in DServer object.
*/
void Tango::DServer::class_factory()
{
add_class(OceanOptics_ns::OceanOpticsClass::init("OceanOptics"));
}
/*----- PROTECTED REGION END -----*/ // OceanOptics::ClassFactory.cpp
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*----- PROTECTED REGION ID(OceanOptics::main.cpp) ENABLED START -----*/
static const char *RcsId = "$Id: main.cpp,v 1.1 2015-03-18 10:38:47 graziano Exp $";
//=============================================================================
//
// file : main.cpp
//
// description : C++ source for the OceanOptics device server main.
// The main rule is to initialise (and create) the Tango
// system and to create the DServerClass singleton.
// The main should be the same for every Tango device server.
//
// project : SolarLaserSystems S100
//
// This file is part of Tango device class.
//
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Tango. If not, see <http://www.gnu.org/licenses/>.
//
// $Author: graziano $
//
// $Revision: 1.1 $
// $Date: 2015-03-18 10:38:47 $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#include <tango.h>
int main(int argc,char *argv[])
{
try
{
// Initialise the device server
//----------------------------------------
Tango::Util *tg = Tango::Util::init(argc,argv);
// Create the device server singleton
// which will create everything
//----------------------------------------
tg->server_init(false);
// Run the endless loop
//----------------------------------------
cout << "Ready to accept request" << endl;
tg->server_run();
}
catch (bad_alloc &)
{
cout << "Can't allocate memory to store device object !!!" << endl;
cout << "Exiting" << endl;
}
catch (CORBA::Exception &e)
{
Tango::Except::print_exception(e);
cout << "Received a CORBA_Exception" << endl;
cout << "Exiting" << endl;
}
Tango::Util::instance()->server_cleanup();
return(0);
}
/*----- PROTECTED REGION END -----*/ // OceanOptics::main.cpp
This diff is collapsed.
//
// file : readthread.h
//
// description : reading thread
//
// project : TANGO Device Server
//
// $Author: graziano $
//
// $Revision: 1.1 $
//
//
//
// copyleft : Sincrotrone Trieste S.C.p.A.
// Strada Statale 14 - km 163,5 in AREA Science Park
// 34012 Basovizza, Trieste ITALY
//
#ifndef READTHREAD_H_
#define READTHREAD_H_
#include <tango.h>
#include <omnithread.h>
#include "OceanOptics.h"
//#include "UsbCDD.h"
class readthread : public omni_thread, public Tango::LogAdapter
{
private:
OceanOptics_ns::OceanOptics *mysolar;
void abort_sleep(double time);
int wait_counter;
bool use_last_fit;
unsigned long old_bunch_number;
bool just_reconnected;
public:
readthread(OceanOptics_ns::OceanOptics *s);
~readthread();
omni_mutex *mutex_sleep;
int pausesec,pausenano;
double min_fit_time;
double max_fit_time;
double tot_fit_time;
double avg_fit_time;
size_t fit_counter;
protected:
void run(void *);
}; /* end class readthread() */
#endif /*READTHREAD_H_*/
This diff is collapsed.
//=============================================================================
//
// file : tcheck_get_rt_buffer.hpp
//
// description : Include with utility to read rt buffers.
//
// project : RT BUFFER
//
// $Author: graziano $
//
// $Revision: 1.1 $
//
// $Log: tcheck_get_rt_buffer.hpp,v $
// Revision 1.1 2015-09-08 09:00:52 graziano
// upgraded to template buffer
//
//
//
//
// copyleft : Sincrotrone Trieste S.C.p.A.
// Strada Statale 14 - km 163,5 in AREA Science Park
// 34012 Basovizza (TS)
// ITALY
//
//=============================================================================
#ifndef _T_CHECK_GET_RT_BUFFER_H
#define _T_CHECK_GET_RT_BUFFER_H
#include <tango.h>
#include <tbuffer.hpp>
namespace tbuffer
{
//+------------------------------------------------------------------
/**
* method: check_get_data_param
*
* description: get data indexes
*
* @param[in] buffer search params
* @param[in] rt buffer
* @param[out] buffer indexes
* @param[out] num samples between indexes
* @param[in] unique
* @return
*
*/
//+------------------------------------------------------------------
template <typename T> void tcheck_get_data_param(const Tango::DevVarLongArray *argin, buffer_t<T> *tbuf, long *buf_idx, long *data_size, unsigned char *unique)
{
long nargin = argin->length();
long ret_num_samples;
//struct _buffer *locbuf;
long mode = (*argin)[0];
if ((*argin)[0] <= BUF_GET_TIME_MODE)
*unique = 0;
else if((*argin)[0] <= BUF_GET_TIME_UNIQUE_MODE)
*unique = 1;
else
*unique = 2;
/* non unique modes (0,1,2); unique modes (3,4,5); bunch modes (6,7,8) */
mode = mode - (*unique) * 3;
/* get last values */
if (nargin == 2)
{
long num_samples = (*argin)[1];
if ((num_samples < 0) || (num_samples > tbuf->get_size()))
{
Tango::Except::throw_exception (
(const char *)"Invalid number of data requested",
(const char *)"Failed to retreive last data",
(const char *)__FUNCTION__);
}
if (mode == BUF_GET_LAST_MODE)
{
ret_num_samples = tbuf->get_last_idx(num_samples, *unique, buf_idx);
}
else
{
Tango::Except::throw_exception (
(const char *)"Wrong get mode parameter (0,1,2)",
(const char *)"Failed to retreive last data",
(const char *)__FUNCTION__);
}
if (ret_num_samples != num_samples && (*unique != 2))
{
stringstream tmp;
tmp << " Can't retreive all data requested: requested="<<num_samples << " received="<<ret_num_samples;
//DEBUG_STREAM << __FUNCTION__ << tmp.str();
Tango::Except::throw_exception (
(const char *)"Can't retreive all data requested",
tmp.str(),
(const char *)__FUNCTION__);
}
else if (ret_num_samples == 0)
{
stringstream tmp;
tmp << " Can't retreive all data requested: requested="<<num_samples << " but buffer empty!";
//DEBUG_STREAM << __FUNCTION__ << tmp.str();
Tango::Except::throw_exception (
(const char *)"Can't retreive all data requested",
tmp.str(),
(const char *)__FUNCTION__);
}
*data_size = ret_num_samples;
if(*unique == 2)
*data_size *= 2; //concatenate bunchnumbers
}
/* get bunch mode values */
else if (nargin == 3)
{
long bunch_start = (*argin)[1], bunch_end = (*argin)[2];
if (((bunch_end-bunch_start) < 0) || ((bunch_end-bunch_start) > tbuf->get_size()))
{
stringstream out_stream;
out_stream << "Invalid bunch numbers: bunch start=" << bunch_start << ", bunch end=" << bunch_end << ends;
//DEBUG_STREAM << __FUNCTION__ << out_stream.str();
Tango::Except::throw_exception (
out_stream.str(),
(const char *)"Failed to retreive bunch data",
(const char *)__FUNCTION__);
}
if (mode == BUF_GET_BUNCH_MODE)
{
ret_num_samples = tbuf->get_bunch_idx(bunch_start, bunch_end, *unique, buf_idx);
}
else
{
stringstream out_stream;
out_stream << "Invalid mode=" << mode << ends;
//DEBUG_STREAM << __FUNCTION__ << out_stream.str();
Tango::Except::throw_exception (
out_stream.str(),
(const char *)"Failed to retrive bunch data",
(const char *)__FUNCTION__);
}
/* check data size */
if ((((ret_num_samples-1) != (bunch_end-bunch_start)) && (*unique ==1)) ||
(((ret_num_samples-1) < (bunch_end-bunch_start)) && (*unique == 0)))
{
stringstream out_stream;
out_stream << "Invalid bunch numbers: bunch start=" << bunch_start << ", bunch end=" << bunch_end << ", ret_num_samples=" <<
(ret_num_samples-1) << ends;
//DEBUG_STREAM << __FUNCTION__ << out_stream.str();
Tango::Except::throw_exception (
(const char *)"Failed to retreive bunch data",
out_stream.str(),
(const char *)__FUNCTION__);
}
else if(ret_num_samples == 0)
{
stringstream out_stream;
out_stream << "Invalid bunch numbers.";
if(buf_idx[0] == -1)
out_stream<< " Bunch start=" << bunch_start << " not valid.";
if(buf_idx[1] == -1)
out_stream<< " Bunch end=" << bunch_end << " not valid.";
out_stream << ends;
//DEBUG_STREAM << __FUNCTION__ << out_stream.str();
Tango::Except::throw_exception (
(const char *)"Failed to retreive bunch data",
out_stream.str(),
(const char *)__FUNCTION__);
}
*data_size = ret_num_samples;
if(*unique == 2)
*data_size *= 2; //concatenate bunchnumbers
}
/* get time mode values */
else if (nargin == 5)
{
struct timeval time_start, time_end;
time_start.tv_sec = (*argin)[1]; time_start.tv_usec = (*argin)[2];
time_end.tv_sec = (*argin)[3]; time_end.tv_usec = (*argin)[4];
if (((time_end.tv_sec-time_start.tv_sec)*1000000+(time_end.tv_usec-time_start.tv_usec)) < 0)
{
Tango::Except::throw_exception (
(const char *)"Invalid time slice requested",
(const char *)"Failed to retreive timed data",
(const char *)__FUNCTION__);
}
if (mode == BUF_GET_TIME_MODE)
{
ret_num_samples = tbuf->get_time_idx(time_start, time_end, *unique, buf_idx);
}
else
{
Tango::Except::throw_exception (
(const char *)"Wrong get mode parameter (0,1,2)",
(const char *)"Failed to retreive timed data",
(const char *)__FUNCTION__);
}
*data_size = ret_num_samples;
if(*unique == 2)
*data_size *= 2; //concatenate bunchnumbers
}
/* invalid number of input parameters */
else
{
Tango::Except::throw_exception (
(const char *)"Invalid number of input parameters",
(const char *)"Failed to get data",
(const char *)__FUNCTION__);
}
}
template <typename T> void tcheck_get_data_param(const Tango::DevVarLongArray *argin, buffer_t<tbuffer::_data_array<T> > *tbuf, long *buf_idx, long *data_size, unsigned char *unique)
{
long nargin = argin->length();
long ret_num_samples;
//struct _buffer *locbuf;
long mode = (*argin)[0];
if ((*argin)[0] <= BUF_GET_TIME_MODE)
*unique = 0;
else if((*argin)[0] <= BUF_GET_TIME_UNIQUE_MODE)
*unique = 1;
else
*unique = 2;
/* non unique modes (0,1,2); unique modes (3,4,5); bunch modes (6,7,8) */
mode = mode - (*unique) * 3;
/* get last values */
if (nargin == 2)
{
long num_samples = (*argin)[1];
if ((num_samples < 0) || (num_samples > tbuf->get_size()))
{
Tango::Except::throw_exception (
(const char *)"Invalid number of data requested",
(const char *)"Failed to retreive last data",
(const char *)__FUNCTION__);
}
if (mode == BUF_GET_LAST_MODE)
{
ret_num_samples = tbuf->get_last_idx(num_samples, *unique, buf_idx);
}
else
{
Tango::Except::throw_exception (
(const char *)"Wrong get mode parameter (0,1,2)",
(const char *)"Failed to retreive last data",
(const char *)__FUNCTION__);
}
if (ret_num_samples != num_samples && (*unique != 2))
{
stringstream tmp;
tmp << " Can't retreive all data requested: requested="<<num_samples << " received="<<ret_num_samples;
//DEBUG_STREAM << __FUNCTION__ << tmp.str();
Tango::Except::throw_exception (
(const char *)"Can't retreive all data requested",
tmp.str(),
(const char *)__FUNCTION__);
}
else if (ret_num_samples == 0)
{
stringstream tmp;
tmp << " Can't retreive all data requested: requested="<<num_samples << " but buffer empty!";
//DEBUG_STREAM << __FUNCTION__ << tmp.str();
Tango::Except::throw_exception (
(const char *)"Can't retreive all data requested",
tmp.str(),
(const char *)__FUNCTION__);
}
*data_size = ret_num_samples;
if(*unique == 2)
*data_size *= 2; //concatenate bunchnumbers
}
/* get bunch mode values */
else if (nargin == 3)
{
long bunch_start = (*argin)[1], bunch_end = (*argin)[2];
if (((bunch_end-bunch_start) < 0) || ((bunch_end-bunch_start) > tbuf->get_size()))
{
stringstream out_stream;
out_stream << "Invalid bunch numbers: bunch start=" << bunch_start << ", bunch end=" << bunch_end << ends;
//DEBUG_STREAM << __FUNCTION__ << out_stream.str();
Tango::Except::throw_exception (
out_stream.str(),
(const char *)"Failed to retreive bunch data",
(const char *)__FUNCTION__);
}
if (mode == BUF_GET_BUNCH_MODE)
{
ret_num_samples = tbuf->get_bunch_idx(bunch_start, bunch_end, *unique, buf_idx);
}
else
{
stringstream out_stream;
out_stream << "Invalid mode=" << mode << ends;
//DEBUG_STREAM << __FUNCTION__ << out_stream.str();
Tango::Except::throw_exception (
out_stream.str(),
(const char *)"Failed to retrive bunch data",
(const char *)__FUNCTION__);
}
/* check data size */
if ((((ret_num_samples-1) != (bunch_end-bunch_start)) && (*unique ==1)) ||
(((ret_num_samples-1) < (bunch_end-bunch_start)) && (*unique == 0)))
{
stringstream out_stream;
out_stream << "Invalid bunch numbers: bunch start=" << bunch_start << ", bunch end=" << bunch_end << ", ret_num_samples=" <<
(ret_num_samples-1) << ends;
//DEBUG_STREAM << __FUNCTION__ << out_stream.str();
Tango::Except::throw_exception (
(const char *)"Failed to retreive bunch data",
out_stream.str(),
(const char *)__FUNCTION__);
}
else if(ret_num_samples == 0)
{
stringstream out_stream;
out_stream << "Invalid bunch numbers.";
if(buf_idx[0] == -1)
out_stream<< " Bunch start=" << bunch_start << " not valid.";
if(buf_idx[1] == -1)
out_stream<< " Bunch end=" << bunch_end << " not valid.";
out_stream << ends;
//DEBUG_STREAM << __FUNCTION__ << out_stream.str();
Tango::Except::throw_exception (
(const char *)"Failed to retreive bunch data",
out_stream.str(),
(const char *)__FUNCTION__);
}
*data_size = ret_num_samples;
if(*unique == 2)
*data_size *= 2; //concatenate bunchnumbers
}
/* get time mode values */
else if (nargin == 5)
{
struct timeval time_start, time_end;
time_start.tv_sec = (*argin)[1]; time_start.tv_usec = (*argin)[2];
time_end.tv_sec = (*argin)[3]; time_end.tv_usec = (*argin)[4];
if (((time_end.tv_sec-time_start.tv_sec)*1000000+(time_end.tv_usec-time_start.tv_usec)) < 0)
{
Tango::Except::throw_exception (
(const char *)"Invalid time slice requested",
(const char *)"Failed to retreive timed data",
(const char *)__FUNCTION__);
}
if (mode == BUF_GET_TIME_MODE)
{
ret_num_samples = tbuf->get_time_idx(time_start, time_end, *unique, buf_idx);
}
else
{
Tango::Except::throw_exception (
(const char *)"Wrong get mode parameter (0,1,2)",
(const char *)"Failed to retreive timed data",
(const char *)__FUNCTION__);
}
*data_size = ret_num_samples;
if(*unique == 2)
*data_size *= 2; //concatenate bunchnumbers
}
/* invalid number of input parameters */
else
{
Tango::Except::throw_exception (
(const char *)"Invalid number of input parameters",
(const char *)"Failed to get data",
(const char *)__FUNCTION__);
}
}
}//namespace
#endif //_T_CHECK_GET_RT_BUFFER_H
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment