Commit 95095ab4 authored by Alexander Steffens's avatar Alexander Steffens

commit latest state

parent fc802b1c
# Project Title
One Paragraph of project description goes here
## Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
### Prerequisites
What things you need to install the software and how to install them
```
Give examples
```
### Installing
A step by step series of examples that tell you have to get a development env running
Say what the step will be
```
Give the example
```
And repeat
```
until finished
```
End with an example of getting some data out of the system or using it for a little demo
## Running the tests
Explain how to run the automated tests for this system
### Break down into end to end tests
Explain what these tests test and why
```
Give an example
```
### And coding style tests
Explain what these tests test and why
```
Give an example
```
## Deployment
Add additional notes about how to deploy this on a live system
## Built With
* [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used
* [Maven](https://maven.apache.org/) - Dependency Management
* [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds
## Contributing
Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
## Authors
* **Billie Thompson** - *Initial work* - [PurpleBooth](https://github.com/PurpleBooth)
See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
## Acknowledgments
* Hat tip to anyone who's code was used
* Inspiration
* etc
\ No newline at end of file
/*----- PROTECTED REGION ID(MAROCDetector::ClassFactory.cpp) ENABLED START -----*/
/*----- PROTECTED REGION ID(MAROCDebug::ClassFactory.cpp) ENABLED START -----*/
static const char *RcsId = "$Id: $";
//=============================================================================
//
......@@ -9,7 +9,7 @@ static const char *RcsId = "$Id: $";
// all class singleton for a device server. It is called
// at device server startup.
//
// project : MAROC project
// project :
//
// This file is part of Tango device class.
//
......@@ -27,27 +27,6 @@ static const char *RcsId = "$Id: $";
// 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: $
......@@ -60,18 +39,18 @@ static const char *RcsId = "$Id: $";
//=============================================================================
#include <tango.h>
#include <MAROCDetectorClass.h>
#include <MAROCDebugClass.h>
// Add class header files if needed
/**
* Create MAROCDetector Class singleton and store it in DServer object.
* Create MAROCDebug 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"));
add_class(MAROCDebug_ns::MAROCDebugClass::init("MAROCDebug"));
}
/*----- PROTECTED REGION END -----*/ // MAROCDetector::ClassFactory.cpp
/*----- PROTECTED REGION END -----*/ // MAROCDebug::ClassFactory.cpp
......@@ -59,6 +59,8 @@ static const char *RcsId = "$Id: $";
// State | dev_state
// Status | dev_status
// WorkerTest | worker_test
// loadSettings | load_settings
// saveSettings | save_settings
//================================================================
//================================================================
......@@ -157,7 +159,9 @@ void MAROCDebug::init_device()
/*----- PROTECTED REGION END -----*/ // MAROCDebug::init_device_before
// No device property to be read from database
// Get the device properties from database
get_device_property();
attr_daqTime_read = new Tango::DevDouble[1];
attr_dataPath_read = new Tango::DevString[1];
......@@ -182,6 +186,93 @@ void MAROCDebug::init_device()
/*----- PROTECTED REGION END -----*/ // MAROCDebug::init_device
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::get_device_property()
* Description : Read database to initialize property data members.
*/
//--------------------------------------------------------
void MAROCDebug::get_device_property()
{
/*----- PROTECTED REGION ID(MAROCDebug::get_device_property_before) ENABLED START -----*/
// Initialize property data members
/*----- PROTECTED REGION END -----*/ // MAROCDebug::get_device_property_before
// Read device properties from database.
Tango::DbData dev_prop;
dev_prop.push_back(Tango::DbDatum("coincEnabled"));
dev_prop.push_back(Tango::DbDatum("coincSingle"));
dev_prop.push_back(Tango::DbDatum("coincOnlyXY"));
dev_prop.push_back(Tango::DbDatum("coincMark"));
// is there at least one property to be read ?
if (dev_prop.size()>0)
{
// Call database and extract values
if (Tango::Util::instance()->_UseDb==true)
get_db_device()->get_property(dev_prop);
// get instance on MAROCDebugClass to get class property
Tango::DbDatum def_prop, cl_prop;
MAROCDebugClass *ds_class =
(static_cast<MAROCDebugClass *>(get_device_class()));
int i = -1;
// Try to initialize coincEnabled from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> coincEnabled;
else {
// Try to initialize coincEnabled from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> coincEnabled;
}
// And try to extract coincEnabled value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> coincEnabled;
// Try to initialize coincSingle from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> coincSingle;
else {
// Try to initialize coincSingle from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> coincSingle;
}
// And try to extract coincSingle value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> coincSingle;
// Try to initialize coincOnlyXY from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> coincOnlyXY;
else {
// Try to initialize coincOnlyXY from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> coincOnlyXY;
}
// And try to extract coincOnlyXY value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> coincOnlyXY;
// Try to initialize coincMark from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> coincMark;
else {
// Try to initialize coincMark from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> coincMark;
}
// And try to extract coincMark value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> coincMark;
}
/*----- PROTECTED REGION ID(MAROCDebug::get_device_property_after) ENABLED START -----*/
// Check device property data members init
/*----- PROTECTED REGION END -----*/ // MAROCDebug::get_device_property_after
}
//--------------------------------------------------------
/**
......@@ -454,11 +545,11 @@ Tango::DevString MAROCDebug::worker_test()
/*----- PROTECTED REGION ID(MAROCDebug::worker_test) ENABLED START -----*/
// Add your own code
stringstream ss;
/* 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);
......@@ -480,11 +571,43 @@ Tango::DevString MAROCDebug::worker_test()
}
*/
// Duplicate stringstream and convert to Tango::DevString
argout = CORBA::string_dup(ss.str().c_str());
// argout = CORBA::string_dup(ss.str().c_str());
/*----- PROTECTED REGION END -----*/ // MAROCDebug::worker_test
return argout;
}
//--------------------------------------------------------
/**
* Command loadSettings related method
* Description: Load settings from configuration files. Will overwrite current hardware values.
*
*/
//--------------------------------------------------------
void MAROCDebug::load_settings()
{
DEBUG_STREAM << "MAROCDebug::loadSettings() - " << device_name << endl;
/*----- PROTECTED REGION ID(MAROCDebug::load_settings) ENABLED START -----*/
// Add your own code
/*----- PROTECTED REGION END -----*/ // MAROCDebug::load_settings
}
//--------------------------------------------------------
/**
* Command saveSettings related method
* Description: Write current settings to configuration files.
*
*/
//--------------------------------------------------------
void MAROCDebug::save_settings()
{
DEBUG_STREAM << "MAROCDebug::saveSettings() - " << device_name << endl;
/*----- PROTECTED REGION ID(MAROCDebug::save_settings) ENABLED START -----*/
// Add your own code
/*----- PROTECTED REGION END -----*/ // MAROCDebug::save_settings
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::add_dynamic_commands()
* Description : Create the dynamic commands if any
......
......@@ -67,6 +67,16 @@ class MAROCDebug : public TANGO_BASE_CLASS
/*----- PROTECTED REGION END -----*/ // MAROCDebug::Data Members
// Device property data members
public:
// coincEnabled: Toggles coincidence logic. When disabled, raw data of entire MAROC boards will be transmitted, sorted by time.
Tango::DevBoolean coincEnabled;
// coincSingle: Use only one single coincidence entity
Tango::DevBoolean coincSingle;
// coincOnlyXY: Transfer only first X/Y pair (event + location). Do not set during aquisition because additional information will be discarded due to lack of additional coincidence data.
Tango::DevBoolean coincOnlyXY;
// coincMark:
Tango::DevBoolean coincMark;
// Attribute data members
public:
......@@ -116,6 +126,10 @@ public:
* Initialize the device
*/
virtual void init_device();
/*
* Read the device properties from database
*/
void get_device_property();
/*
* Always executed method before execution command method.
*/
......@@ -224,6 +238,20 @@ public:
*/
virtual Tango::DevString worker_test();
virtual bool is_WorkerTest_allowed(const CORBA::Any &any);
/**
* Command loadSettings related method
* Description: Load settings from configuration files. Will overwrite current hardware values.
*
*/
virtual void load_settings();
virtual bool is_loadSettings_allowed(const CORBA::Any &any);
/**
* Command saveSettings related method
* Description: Write current settings to configuration files.
*
*/
virtual void save_settings();
virtual bool is_saveSettings_allowed(const CORBA::Any &any);
//--------------------------------------------------------
......
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
<classes name="MAROCDebug" pogoRevision="9.2">
<description description="" title="" sourcePath="/home/jcns/tango/server/maroc-det/Real" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false">
<description description="" title="" sourcePath="/home/jcns/tango/server/maroc-det/Real" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_Impl" sourcePath=""/>
<identification contact="at fz-juelich.de - a.steffens" author="a.steffens" emailDomain="fz-juelich.de" classFamily="Acquisition" siteSpecific="" platform="Unix Like" bus="PCI" manufacturer="ZEA-2" reference=""/>
</description>
<deviceProperties name="coincEnabled" description="Toggles coincidence logic. When disabled, raw data of entire MAROC boards will be transmitted, sorted by time.">
<type xsi:type="pogoDsl:BooleanType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>true</DefaultPropValue>
</deviceProperties>
<deviceProperties name="coincSingle" description="Use only one single coincidence entity">
<type xsi:type="pogoDsl:BooleanType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>false</DefaultPropValue>
</deviceProperties>
<deviceProperties name="coincOnlyXY" description="Transfer only first X/Y pair (event + location). Do not set during aquisition because additional information will be discarded due to lack of additional coincidence data.">
<type xsi:type="pogoDsl:BooleanType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>false</DefaultPropValue>
</deviceProperties>
<deviceProperties name="coincMark" description="">
<type xsi:type="pogoDsl:BooleanType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>false</DefaultPropValue>
</deviceProperties>
<commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="none">
<type xsi:type="pogoDsl:VoidType"/>
......@@ -32,6 +52,24 @@
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="loadSettings" description="Load settings from configuration files. Will overwrite current hardware values." execMethod="load_settings" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<commands name="saveSettings" description="Write current settings to configuration files." execMethod="save_settings" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="">
<type xsi:type="pogoDsl:VoidType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<attributes name="daqTime" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:DoubleType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
......
......@@ -175,6 +175,42 @@ CORBA::Any *WorkerTestClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(con
return insert((static_cast<MAROCDebug *>(device))->worker_test());
}
//--------------------------------------------------------
/**
* method : loadSettingsClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *loadSettingsClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
cout2 << "loadSettingsClass::execute(): arrived" << endl;
((static_cast<MAROCDebug *>(device))->load_settings());
return new CORBA::Any();
}
//--------------------------------------------------------
/**
* method : saveSettingsClass::execute()
* description : method to trigger the execution of the command.
*
* @param device The device on which the command must be executed
* @param in_any The command input data
*
* returns The command output data (packed in the Any object)
*/
//--------------------------------------------------------
CORBA::Any *saveSettingsClass::execute(Tango::DeviceImpl *device, TANGO_UNUSED(const CORBA::Any &in_any))
{
cout2 << "saveSettingsClass::execute(): arrived" << endl;
((static_cast<MAROCDebug *>(device))->save_settings());
return new CORBA::Any();
}
//===================================================================
// Properties management
......@@ -244,6 +280,62 @@ void MAROCDebugClass::set_default_property()
// Set Default Class Properties
// Set Default device Properties
prop_name = "coincEnabled";
prop_desc = "Toggles coincidence logic. When disabled, raw data of entire MAROC boards will be transmitted, sorted by time.";
prop_def = "true";
vect_data.clear();
vect_data.push_back("true");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "coincSingle";
prop_desc = "Use only one single coincidence entity";
prop_def = "false";
vect_data.clear();
vect_data.push_back("false");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "coincOnlyXY";
prop_desc = "Transfer only first X/Y pair (event + location). Do not set during aquisition because additional information will be discarded due to lack of additional coincidence data.";
prop_def = "false";
vect_data.clear();
vect_data.push_back("false");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "coincMark";
prop_desc = "";
prop_def = "false";
vect_data.clear();
vect_data.push_back("false");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
}
//--------------------------------------------------------
......@@ -625,6 +717,24 @@ void MAROCDebugClass::command_factory()
Tango::OPERATOR);
command_list.push_back(pWorkerTestCmd);
// Command loadSettings
loadSettingsClass *ploadSettingsCmd =
new loadSettingsClass("loadSettings",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR);
command_list.push_back(ploadSettingsCmd);
// Command saveSettings
saveSettingsClass *psaveSettingsCmd =
new saveSettingsClass("saveSettings",
Tango::DEV_VOID, Tango::DEV_VOID,
"",
"",
Tango::OPERATOR);
command_list.push_back(psaveSettingsCmd);
/*----- PROTECTED REGION ID(MAROCDebugClass::command_factory_after) ENABLED START -----*/
// Add your own code
......
......@@ -157,6 +157,52 @@ public:
{return (static_cast<MAROCDebug *>(dev))->is_WorkerTest_allowed(any);}
};
// Command loadSettings class definition
class loadSettingsClass : public Tango::Command
{
public:
loadSettingsClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(name,in,out,in_desc,out_desc, level) {};
loadSettingsClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~loadSettingsClass() {};
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<MAROCDebug *>(dev))->is_loadSettings_allowed(any);}
};
// Command saveSettings class definition
class saveSettingsClass : public Tango::Command
{
public:
saveSettingsClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out,
const char *in_desc,
const char *out_desc,
Tango::DispLevel level)
:Command(name,in,out,in_desc,out_desc, level) {};
saveSettingsClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~saveSettingsClass() {};
virtual CORBA::Any *execute (Tango::DeviceImpl *dev, const CORBA::Any &any);
virtual bool is_allowed (Tango::DeviceImpl *dev, const CORBA::Any &any)
{return (static_cast<MAROCDebug *>(dev))->is_saveSettings_allowed(any);}
};
/**
* The MAROCDebugClass singleton definition
......
......@@ -162,6 +162,36 @@ bool MAROCDebug::is_WorkerTest_allowed(TANGO_UNUSED(const CORBA::Any &any))
return true;
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::is_loadSettings_allowed()
* Description : Execution allowed for loadSettings attribute
*/
//--------------------------------------------------------
bool MAROCDebug::is_loadSettings_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for loadSettings command.
/*----- PROTECTED REGION ID(MAROCDebug::loadSettingsStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // MAROCDebug::loadSettingsStateAllowed
return true;
}
//--------------------------------------------------------
/**
* Method : MAROCDebug::is_saveSettings_allowed()
* Description : Execution allowed for saveSettings attribute
*/
//--------------------------------------------------------
bool MAROCDebug::is_saveSettings_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for saveSettings command.
/*----- PROTECTED REGION ID(MAROCDebug::saveSettingsStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // MAROCDebug::saveSettingsStateAllowed
return true;
}