Commit fc802b1c authored by Alexander Steffens's avatar Alexander Steffens

[WIP] Current status of TANGO server copied from frmgit (devel)

parent 1843767d
/*----- PROTECTED REGION ID(MAROCDetector::ClassFactory.cpp) ENABLED START -----*/
static const char *RcsId = "$Id: $";
//=============================================================================
//
// file : ClassFactory.cpp
//
// description : C++ source for the class_factory method of the DServer
// device class. This method is responsible for the creation of
// all class singleton for a device server. It is called
// at device server startup.
//
// project : MAROC project
//
// 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: $
// *****************************************************************************
// MLZ library of Tango servers
// Copyright (c) 2015-2017 by the authors, see LICENSE
// This program 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 2 of the License, or (at your option) any later
// version.
//
// This program 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
// this program; if not, write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Module authors:
// Uwe Clemens <u.clemens@fz-juelich.de>
// Alexander Steffens <a.steffens@fz-juelich.de>
// *****************************************************************************
//
// $Revision: $
// $Date: $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#include <tango.h>
#include <MAROCDetectorClass.h>
// Add class header files if needed
/**
* Create MAROCDetector Class singleton and store it in DServer object.
*/
void Tango::DServer::class_factory()
{
// Add method class init if needed
add_class(MAROCDetector_ns::MAROCDetectorClass::init("MAROCDetector"));
}
/*----- PROTECTED REGION END -----*/ // MAROCDetector::ClassFactory.cpp
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
<multiClasses pogoRevision="9.2" name="MAROC" sourcePath="/home/jcns/tango/server/maroc-det/Real" description="" filestogenerate="XMI file,Code files,Makefile,Protected Regions">
<classes classname="MAROCDebug" sourcePath="./.">
<inheritances classname="Device_Impl" sourcePath=""/>
</classes>
<classes classname="MAROCDetector" sourcePath="./.">
<inheritances classname="Device_Impl" sourcePath=""/>
<inheritances classname="MLZDevice" sourcePath="./"/>
<inheritances classname="DetectorChannel" sourcePath="/home/jcns/tango/server/maroc-det/Real"/>
<inheritances classname="ImageChannel" sourcePath="/home/jcns/tango/server/maroc-det/Real"/>
<inheritances classname="TOFChannel" sourcePath="/home/jcns/tango/server/maroc-det/Real"/>
</classes>
<preferences makefileHome="/usr/local/share/pogo/preferences"/>
</multiClasses>
</pogoDsl:PogoSystem>
/*----- PROTECTED REGION ID(MAROCDebug.cpp) ENABLED START -----*/
static const char *RcsId = "$Id: $";
//=============================================================================
//
// file : MAROCDebug.cpp
//
// description : C++ source for the MAROCDebug class 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
// MAROCDebug are implemented in this file.
//
// project :
//
// 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: $
//
// $Revision: $
// $Date: $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#include <MAROCDebug.h>
#include <MAROCDebugClass.h>
/*----- PROTECTED REGION END -----*/ // MAROCDebug.cpp
/**
* MAROCDebug class description:
*
*/
//================================================================
// The following table gives the correspondence
// between command and method names.
//
// Command name | Method name
//================================================================
// State | dev_state
// Status | dev_status
// WorkerTest | worker_test
//================================================================
//================================================================
// Attributes managed are:
//================================================================
// daqTime | Tango::DevDouble Scalar
// dataPath | Tango::DevString Scalar
// lastFilename | Tango::DevString Scalar
// readAllData | Tango::DevBoolean Scalar
// remainingTime | Tango::DevDouble Scalar
//================================================================
namespace MAROCDebug_ns
{
/*----- PROTECTED REGION ID(MAROCDebug::namespace_starting) ENABLED START -----*/
// static initializations
/*----- PROTECTED REGION END -----*/ // MAROCDebug::namespace_starting
//--------------------------------------------------------
/**
* Method : MAROCDebug::MAROCDebug()
* Description : Constructors for a Tango device
* implementing the classMAROCDebug
*/
//--------------------------------------------------------
MAROCDebug::MAROCDebug(Tango::DeviceClass *cl, string &s)
: TANGO_BASE_CLASS(cl, s.c_str())
{
/*----- PROTECTED REGION ID(MAROCDebug::constructor_1) ENABLED START -----*/
init_device();
/*----- PROTECTED REGION END -----*/ // MAROCDebug::constructor_1
}
//--------------------------------------------------------
MAROCDebug::MAROCDebug(Tango::DeviceClass *cl, const char *s)
: TANGO_BASE_CLASS(cl, s)
{
/*----- PROTECTED REGION ID(MAROCDebug::constructor_2) ENABLED START -----*/
init_device();
/*----- PROTECTED REGION END -----*/ // MAROCDebug::constructor_2
}
//--------------------------------------------------------
MAROCDebug::MAROCDebug(Tango::DeviceClass *cl, const char *s, const char *d)
: TANGO_BASE_CLASS(cl, s, d)
{
/*----- PROTECTED REGION ID(MAROCDebug::constructor_3) ENABLED START -----*/
init_device();
/*----- PROTECTED REGION END -----*/ // MAROCDebug::constructor_3
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::delete_device()
* Description : will be called at device destruction or at init command
*/
//--------------------------------------------------------
void MAROCDebug::delete_device()
{
DEBUG_STREAM << "MAROCDebug::delete_device() " << device_name << endl;
/*----- PROTECTED REGION ID(MAROCDebug::delete_device) ENABLED START -----*/
// Delete device allocated objects
/* if (workerList.size() > 0) {
try {
MAROC_ns::Worker::destroy(workerList);
} catch(exception const ex) {
cout << ex.what() << endl;
}
}
workerList.clear();
*/
/*----- PROTECTED REGION END -----*/ // MAROCDebug::delete_device
delete[] attr_daqTime_read;
delete[] attr_dataPath_read;
delete[] attr_lastFilename_read;
delete[] attr_readAllData_read;
delete[] attr_remainingTime_read;
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::init_device()
* Description : will be called at device initialization.
*/
//--------------------------------------------------------
void MAROCDebug::init_device()
{
DEBUG_STREAM << "MAROCDebug::init_device() create device " << device_name << endl;
/*----- PROTECTED REGION ID(MAROCDebug::init_device_before) ENABLED START -----*/
// Initialization before get_device_property() call
/*----- PROTECTED REGION END -----*/ // MAROCDebug::init_device_before
// No device property to be read from database
attr_daqTime_read = new Tango::DevDouble[1];
attr_dataPath_read = new Tango::DevString[1];
attr_lastFilename_read = new Tango::DevString[1];
attr_readAllData_read = new Tango::DevBoolean[1];
attr_remainingTime_read = new Tango::DevDouble[1];
/*----- PROTECTED REGION ID(MAROCDebug::init_device) ENABLED START -----*/
// Initialize device
/* try {
workerList = MAROC_ns::Worker::create();
} catch(exception const &ex) {
cout << ex.what() << endl
<< "Trying to deallocate existing instances...\n\n";
if (workerList.size() > 0) {
MAROC_ns::Worker::destroy(workerList);
}
set_state(Tango::FAULT);
}
*/
/*----- PROTECTED REGION END -----*/ // MAROCDebug::init_device
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::always_executed_hook()
* Description : method always executed before any command is executed
*/
//--------------------------------------------------------
void MAROCDebug::always_executed_hook()
{
DEBUG_STREAM << "MAROCDebug::always_executed_hook() " << device_name << endl;
/*----- PROTECTED REGION ID(MAROCDebug::always_executed_hook) ENABLED START -----*/
// code always executed before all requests
/*----- PROTECTED REGION END -----*/ // MAROCDebug::always_executed_hook
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::read_attr_hardware()
* Description : Hardware acquisition for attributes
*/
//--------------------------------------------------------
void MAROCDebug::read_attr_hardware(TANGO_UNUSED(vector<long> &attr_list))
{
DEBUG_STREAM << "MAROCDebug::read_attr_hardware(vector<long> &attr_list) entering... " << endl;
/*----- PROTECTED REGION ID(MAROCDebug::read_attr_hardware) ENABLED START -----*/
// Add your own code
/*----- PROTECTED REGION END -----*/ // MAROCDebug::read_attr_hardware
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::write_attr_hardware()
* Description : Hardware writing for attributes
*/
//--------------------------------------------------------
void MAROCDebug::write_attr_hardware(TANGO_UNUSED(vector<long> &attr_list))
{
DEBUG_STREAM << "MAROCDebug::write_attr_hardware(vector<long> &attr_list) entering... " << endl;
/*----- PROTECTED REGION ID(MAROCDebug::write_attr_hardware) ENABLED START -----*/
// Add your own code
/*----- PROTECTED REGION END -----*/ // MAROCDebug::write_attr_hardware
}
//--------------------------------------------------------
/**
* Read attribute daqTime related method
* Description: Preset DAQ time value.
*
* Data type: Tango::DevDouble
* Attr type: Scalar
*/
//--------------------------------------------------------
void MAROCDebug::read_daqTime(Tango::Attribute &attr)
{
DEBUG_STREAM << "MAROCDebug::read_daqTime(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(MAROCDebug::read_daqTime) ENABLED START -----*/
// Set the attribute value
attr.set_value(attr_daqTime_read);
/*----- PROTECTED REGION END -----*/ // MAROCDebug::read_daqTime
}
//--------------------------------------------------------
/**
* Write attribute daqTime related method
* Description: Preset DAQ time value.
*
* Data type: Tango::DevDouble
* Attr type: Scalar
*/
//--------------------------------------------------------
void MAROCDebug::write_daqTime(Tango::WAttribute &attr)
{
DEBUG_STREAM << "MAROCDebug::write_daqTime(Tango::WAttribute &attr) entering... " << endl;
// Retrieve write value
Tango::DevDouble w_val;
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(MAROCDebug::write_daqTime) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // MAROCDebug::write_daqTime
}
//--------------------------------------------------------
/**
* Read attribute dataPath related method
* Description: Directory where DAQ data is stored.
*
* Data type: Tango::DevString
* Attr type: Scalar
*/
//--------------------------------------------------------
void MAROCDebug::read_dataPath(Tango::Attribute &attr)
{
DEBUG_STREAM << "MAROCDebug::read_dataPath(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(MAROCDebug::read_dataPath) ENABLED START -----*/
// Set the attribute value
attr.set_value(attr_dataPath_read);
/*----- PROTECTED REGION END -----*/ // MAROCDebug::read_dataPath
}
//--------------------------------------------------------
/**
* Write attribute dataPath related method
* Description: Directory where DAQ data is stored.
*
* Data type: Tango::DevString
* Attr type: Scalar
*/
//--------------------------------------------------------
void MAROCDebug::write_dataPath(Tango::WAttribute &attr)
{
DEBUG_STREAM << "MAROCDebug::write_dataPath(Tango::WAttribute &attr) entering... " << endl;
// Retrieve write value
Tango::DevString w_val;
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(MAROCDebug::write_dataPath) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // MAROCDebug::write_dataPath
}
//--------------------------------------------------------
/**
* Read attribute lastFilename related method
* Description: Name of last DAQ data file.
*
* Data type: Tango::DevString
* Attr type: Scalar
*/
//--------------------------------------------------------
void MAROCDebug::read_lastFilename(Tango::Attribute &attr)
{
DEBUG_STREAM << "MAROCDebug::read_lastFilename(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(MAROCDebug::read_lastFilename) ENABLED START -----*/
// Set the attribute value
attr.set_value(attr_lastFilename_read);
/*----- PROTECTED REGION END -----*/ // MAROCDebug::read_lastFilename
}
//--------------------------------------------------------
/**
* Read attribute readAllData related method
* Description: Indicates whether all FIFO data is read immediately or blockwise.
*
* Data type: Tango::DevBoolean
* Attr type: Scalar
*/
//--------------------------------------------------------
void MAROCDebug::read_readAllData(Tango::Attribute &attr)
{
DEBUG_STREAM << "MAROCDebug::read_readAllData(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(MAROCDebug::read_readAllData) ENABLED START -----*/
// Set the attribute value
attr.set_value(attr_readAllData_read);
/*----- PROTECTED REGION END -----*/ // MAROCDebug::read_readAllData
}
//--------------------------------------------------------
/**
* Write attribute readAllData related method
* Description: Indicates whether all FIFO data is read immediately or blockwise.
*
* Data type: Tango::DevBoolean
* Attr type: Scalar
*/
//--------------------------------------------------------
void MAROCDebug::write_readAllData(Tango::WAttribute &attr)
{
DEBUG_STREAM << "MAROCDebug::write_readAllData(Tango::WAttribute &attr) entering... " << endl;
// Retrieve write value
Tango::DevBoolean w_val;
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(MAROCDebug::write_readAllData) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // MAROCDebug::write_readAllData
}
//--------------------------------------------------------
/**
* Read attribute remainingTime related method
* Description: Current remaining time value.
*
* Data type: Tango::DevDouble
* Attr type: Scalar
*/
//--------------------------------------------------------
void MAROCDebug::read_remainingTime(Tango::Attribute &attr)
{
DEBUG_STREAM << "MAROCDebug::read_remainingTime(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(MAROCDebug::read_remainingTime) ENABLED START -----*/
// Set the attribute value
attr.set_value(attr_remainingTime_read);
/*----- PROTECTED REGION END -----*/ // MAROCDebug::read_remainingTime
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::add_dynamic_attributes()
* Description : Create the dynamic attributes if any
* for specified device.
*/
//--------------------------------------------------------
void MAROCDebug::add_dynamic_attributes()
{
/*----- PROTECTED REGION ID(MAROCDebug::add_dynamic_attributes) ENABLED START -----*/
// Add your own code to create and add dynamic attributes if any
/*----- PROTECTED REGION END -----*/ // MAROCDebug::add_dynamic_attributes
}
//--------------------------------------------------------
/**
* Command State related method
* Description: This command gets the device state (stored in its device_state data member) and returns it to the caller.
*
* @returns Device state
*/
//--------------------------------------------------------
Tango::DevState MAROCDebug::dev_state()
{
DEBUG_STREAM << "MAROCDebug::State() - " << device_name << endl;
/*----- PROTECTED REGION ID(MAROCDebug::dev_state) ENABLED START -----*/
Tango::DevState argout = Tango::UNKNOWN; // replace by your own algorithm
// Add your own code
/*----- PROTECTED REGION END -----*/ // MAROCDebug::dev_state
set_state(argout); // Give the state to Tango.
if (argout!=Tango::ALARM)
DeviceImpl::dev_state();
return get_state(); // Return it after Tango management.
}
//--------------------------------------------------------
/**
* Command Status related method
* Description: This command gets the device status (stored in its device_status data member) and returns it to the caller.
*
* @returns Device status
*/
//--------------------------------------------------------
Tango::ConstDevString MAROCDebug::dev_status()
{
DEBUG_STREAM << "MAROCDebug::Status() - " << device_name << endl;
/*----- PROTECTED REGION ID(MAROCDebug::dev_status) ENABLED START -----*/
string status = "Device is OK";
// Add your own code
/*----- PROTECTED REGION END -----*/ // MAROCDebug::dev_status
set_status(status); // Give the status to Tango.
return DeviceImpl::dev_status(); // Return it.
}
//--------------------------------------------------------
/**
* Command WorkerTest related method
* Description:
*
* @returns
*/
//--------------------------------------------------------
Tango::DevString MAROCDebug::worker_test()
{
Tango::DevString argout;
DEBUG_STREAM << "MAROCDebug::WorkerTest() - " << device_name << endl;
/*----- PROTECTED REGION ID(MAROCDebug::worker_test) ENABLED START -----*/
// Add your own code
stringstream ss;
array<MAROC_ns::WorkerMaroc*, CONC_MAROCS> marocs;
U32 sn, csn;
U32 msn[5];
/*
for (unsigned int i = 0; i < workerList.size(); ++i) {
workerList[i]->getSerialNumber(&sn);
workerList[i]->getConcentrator()->getSerialNumber(&csn);
marocs = workerList[i]->getMarocs();
for (unsigned int i = 0; i < marocs.size(); ++i) {
marocs[i]->getSerialNumber(&msn[i]);
}
ss << "Worker #" << workerList[i]->getDeviceData()->deviceNumber << " - "
<< "Vendor ID: 0x" << hex << workerList[i]->getDeviceData()->deviceKey.VendorId << " - "
<< "Device ID: 0x" << hex << workerList[i]->getDeviceData()->deviceKey.DeviceId << " - "
<< "Serial No: 0x" << uppercase << hex << sn << " - "
<< "Serial No (Conc): 0x" << uppercase << hex << csn << "\n"
<< "Serial No (Maroc 0): 0x" << uppercase << hex << msn[0] << " - "
<< "Serial No (Maroc 1): 0x" << uppercase << hex << msn[1] << " - "
<< "Serial No (Maroc 2): 0x" << uppercase << hex << msn[2] << " - "
<< "Serial No (Maroc 3): 0x" << uppercase << hex << msn[3] << " - "
<< "Serial No (Maroc 4): 0x" << uppercase << hex << msn[4]
<< endl;
}
*/
// Duplicate stringstream and convert to Tango::DevString
argout = CORBA::string_dup(ss.str().c_str());
/*----- PROTECTED REGION END -----*/ // MAROCDebug::worker_test
return argout;
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::add_dynamic_commands()
* Description : Create the dynamic commands if any
* for specified device.
*/
//--------------------------------------------------------
void MAROCDebug::add_dynamic_commands()
{
/*----- PROTECTED REGION ID(MAROCDebug::add_dynamic_commands) ENABLED START -----*/
// Add your own code to create and add dynamic commands if any
/*----- PROTECTED REGION END -----*/ // MAROCDebug::add_dynamic_commands
}
/*----- PROTECTED REGION ID(MAROCDebug::namespace_ending) ENABLED START -----*/
// Additional Methods
// //--------------------------------------------------------
// /**
// * Read attribute daqMode related method
// * Description: Indicates whether next DAQ is started by all MAROC board or only one of them.
// *
// * Data type: Tango::DevEnum (daqModeEnum)
// * Attr type: Scalar
// */
// //--------------------------------------------------------
// void MAROCDebug::read_daqMode(Tango::Attribute &attr)
// {
// DEBUG_STREAM << "MAROCDebug::read_daqMode(Tango::Attribute &attr) entering... " << endl;
// // Set the attribute value
// attr.set_value(attr_daqMode_read);
//
// }
// //--------------------------------------------------------
// /**
// * Write attribute daqMode related method
// * Description: Indicates whether next DAQ is started by all MAROC board or only one of them.
// *
// * Data type: Tango::DevEnum (daqModeEnum)
// * Attr type: Scalar
// */
// //--------------------------------------------------------
// void MAROCDebug::write_daqMode(Tango::WAttribute &attr)
// {
// DEBUG_STREAM << "MAROCDebug::write_daqMode(Tango::WAttribute &attr) entering... " << endl;
// // Retrieve write value
// daqModeEnum w_val;
// attr.get_write_value(w_val);
//
//
// }
/*----- PROTECTED REGION END -----*/ // MAROCDebug::namespace_ending
} // namespace
/*----- PROTECTED REGION ID(MAROCDebug.h) ENABLED START -----*/