Skip to content
Snippets Groups Projects
Commit ac9ff844 authored by Claudio Scafuri's avatar Claudio Scafuri :speech_balloon:
Browse files

first import from repo fermi/server/pdumapper CVS release_04

parent 6a2f3d49
No related branches found
No related tags found
No related merge requests found
.pydevproject
.project
.cproject
.settings
obj
bin
core*
*~
*.pyc
*.so
*.so*
.pylintrc
.metadata
.idea
.cvsignore
.nse_depinfo
software
oldsrc
CVS
LICENSE 0 → 100644
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
NAME_SRV = pdumapper-srv
include ../makefiles/Make-9.3.3.in
# pdumapper
# Project Name
pdumapper
## Description
tango device server for mapping and and and querying Fermi and Elettra pdu devices
## Installation
See your institue guidelines for deploying and configuring a Tango device server.
## History
2020-05-10 : project created on gitlab, derived from repo fermi/server/pdumapper CVS release_04
original development by Alessandro Olivo
## Credits
Elettra-Sincrotrone Trieste S.C.p.A. di interesse nazionale
Strada Statale 14 - km 163,5 in AREA Science Park
34149 Basovizza, Trieste ITALY
## License
GPL 3
tango device serever for mapping and and and quering Fermi and Elettra pdu devices
\ No newline at end of file
/*----- PROTECTED REGION ID(PduMapper::ClassFactory.cpp) ENABLED START -----*/
//=============================================================================
//
// 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 :
//
// 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: alessandro.olivo $
//
// $Revision: 1.1.1.1 $
// $Date: 2017-10-02 14:01:30 $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#include <tango.h>
#include <PduMapperClass.h>
// Add class header files if needed
/**
* Create PduMapper Class singleton and store it in DServer object.
*/
void Tango::DServer::class_factory()
{
// Add method class init if needed
add_class(PduMapper_ns::PduMapperClass::init("PduMapper"));
}
/*----- PROTECTED REGION END -----*/ // PduMapper::ClassFactory.cpp
#include "PduMap.h"
//PduData class methods
PduData::PduData(size_t outlets_num, string pdu_name, Tango::DeviceProxy *pdu_proxy)
{
outlets_count = outlets_num;
name = pdu_name;
proxy = pdu_proxy;
errors = NULL;
}
void PduData::setOutletsCount(size_t count)
{
outlets_count = count;
}
size_t PduData::getOutletsCount()
{
return outlets_count;
}
string PduData::getDevName()
{
return name;
}
void PduData::setDevName(string pdu_name)
{
name = pdu_name;
}
Tango::DeviceProxy* PduData::getProxy()
{
return proxy;
}
void PduData::setProxy(Tango::DeviceProxy *devPrx)
{
proxy = devPrx;
}
void PduData::setErrors(Tango::DevFailed *errs)
{
if(errors)
delete errors;
errors = errs;
}
Tango::DevFailed* PduData::getErrors()
{
return errors;
}
//ATTRIBUTE NAME
// --> Value
string PduData::getLabelByPos(int pos)
{
validateOutletIdx(pos);
return label_ls[pos].value;
}
string PduData::getLabelByAttr(string attr)
{
validateLabelAttr(attr);
int pos = atoi(attr.substr(4, 2).c_str()) - 1;
return getLabelByPos(pos);
}
void PduData::setLabelByPos(int pos, string value)
{
validateOutletIdx(pos);
label_ls[pos].value = value;
}
void PduData::setLabelByAttr(string attr, string value)
{
validateLabelAttr(attr);
int pos = atoi(attr.substr(4, 2).c_str()) - 1;
setLabelByPos(pos, value);
}
// --> Event
void PduData::setLabelEventId(int pos, int id)
{
validateOutletIdx(pos);
label_ls[pos].event = id;
}
void PduData::setLabelEventId(string attr, int id)
{
validateLabelAttr(attr);
int pos = atoi(attr.substr(4, 2).c_str()) - 1;
setLabelEventId(pos, id);
}
//ATTRIBURTE STATE
// --> Value
string PduData::getStateByPos(int pos)
{
validateOutletIdx(pos);
return state_ls[pos].value;
}
/**
string PduData::getStateByAttr(string attr)
{
validateStateAttr(attr);
int pos = atoi(attr.substr(5, 2).c_str()) - 1;
return getStateByPos(pos);
}
*/
void PduData::setStateByPos(int pos, string value)
{
validateOutletIdx(pos);
state_ls[pos].value = value;
}
void PduData::setStateByAttr(string attr, string value)
{
validateStateAttr(attr);
int pos = atoi(attr.substr(5, 2).c_str()) - 1;
setStateByPos(pos, value);
}
// --> Event
void PduData::setStateEventId(int pos, int id)
{
validateOutletIdx(pos);
state_ls[pos].event = id;
}
void PduData::setStateEventId(string attr, int id)
{
validateStateAttr(attr);
int pos = atoi(attr.substr(5, 2).c_str()) - 1;
setStateEventId(pos, id);
}
vector<int> PduData::getAllEvents()
{
vector<int> events;
size_t len = getOutletsCount();
for(unsigned int i = 0; i < len; i++ )
{
events.push_back(state_ls[i].event);
events.push_back(label_ls[i].event);
}
return events;
}
bool PduData::matchLabelPattern(string label)
{
regex label_pattern(label, regex_constants::icase);
for(unsigned int i = 0; i < outlets_count; i++)
if (regex_match(label_ls[i].value, label_pattern))
return true;
return false;
}
void PduData::addIfMatchLabelPattern(vector<string> &outlets_ls, string label)
{
regex label_pattern(label, regex_constants::icase);
for(unsigned int i = 0; i < outlets_count; i++)
if (regex_match(label_ls[i].value, label_pattern))
outlets_ls.push_back(label_ls[i].value);
}
void PduData::validateOutletIdx(unsigned int idx)
{
if (idx >= outlets_count)
{
stringstream idx_ss;
string idx_s;
idx_ss << idx;
idx_ss >> idx_s;
throw NotValidOutletIndex(name, idx_s);
}
}
void PduData::validateStateAttr(string attr_name)
{
/** Expected "stateXX" ('X' is a digit) in attr_name **/
if (attr_name.size() == 7 && attr_name.substr(0, 5).compare("state") == 0)
if(isdigit(attr_name[5]) && isdigit(attr_name[6]))
return;
throw NotValidAttrName(attr_name);
}
void PduData::validateLabelAttr(string attr_name)
{
/** Expected "nameXX" ('X' is a digit) in attr_name **/
if (attr_name.size() == 6 && attr_name.substr(0, 4).compare("name") == 0)
if(isdigit(attr_name[4]) && isdigit(attr_name[5]))
return;
throw NotValidAttrName(attr_name);
}
// "PduMap" CLASS METHODS
PduMap* PduMap::instance = NULL;
PduMap::PduMap(){}
void PduMap::resetInstance()
{
delete instance;
instance = NULL;
}
PduMap* PduMap::getInstance()
{
if (instance == 0)
{
instance = new PduMap();
}
return instance;
}
void PduMap::addPduData(size_t outletsNum, string pdu_name, Tango::DeviceProxy *pdu_proxy)
{
if(isPduName(pdu_name))
throw PduNameAlreadyExists(pdu_name);
else
pduData_ls.emplace_back(outletsNum, pdu_name, pdu_proxy);
}
void PduMap::deletePduData(string pdu_name)
{
unsigned int idx = getIdxPduData(pdu_name);
Tango::DeviceProxy *prxy = pduData_ls[idx].getProxy();
Tango::DevFailed *errs = pduData_ls[idx].getErrors();
if (prxy)
delete prxy;
if(errs)
delete errs;
pduData_ls.erase(pduData_ls.begin() + idx);
}
void PduMap::getPduInfoFromName(vector<string> &pdu_info, string pdu_name)
{
unsigned int idx = getIdxPduData(pdu_name);
Tango::DevFailed *errors = pduData_ls[idx].getErrors();
if(errors)
throw *errors;
size_t outlets_num = pduData_ls[idx].getOutletsCount();
for(size_t j = 0; j < outlets_num; j++)
{
pdu_info.push_back(pduData_ls[idx].getLabelByPos(j));
pdu_info.push_back(pduData_ls[idx].getStateByPos(j));
}
}
void PduMap::getPduListFromLabel(vector<string> &pdu_ls, string label)
{
size_t len = pduData_ls.size();
for(unsigned int i = 0; i < len; i++)
if(!pduData_ls[i].getErrors())
if(pduData_ls[i].matchLabelPattern(label))
pdu_ls.push_back(pduData_ls[i].getDevName());
}
void PduMap::getPduListFromName(vector<string> &pdu_ls, string pdu_name)
{
regex name_pattern(pdu_name, regex_constants::icase);
size_t len = pduData_ls.size();
for(unsigned int i = 0; i < len; i++)
if(regex_match(pduData_ls[i].getDevName(), name_pattern))
pdu_ls.push_back(pduData_ls[i].getDevName());
}
void PduMap::getOutletsListFromLabel(vector<string> &outlets_ls, string label)
{
size_t len = pduData_ls.size();
for(unsigned int i = 0; i < len; i++)
if(!pduData_ls[i].getErrors())
pduData_ls[i].addIfMatchLabelPattern(outlets_ls, label);
}
void PduMap::getPduInErrorList(string &pdu_ls)
{
size_t len = pduData_ls.size();
pdu_ls = "";
for(unsigned int i = 0; i < len; i++)
if(pduData_ls[i].getErrors())
pdu_ls += "- " + pduData_ls[i].getDevName() + "\n";
}
void PduMap::getAllPduEvents(vector<int> &events, string pdu_name)
{
unsigned int idx = getIdxPduData(pdu_name);
events = pduData_ls[idx].getAllEvents();
}
void PduMap::getAllPduEvents(vector<int> &events, unsigned int pos)
{
validatePduIndex(pos);
events = pduData_ls[pos].getAllEvents();
}
Tango::DeviceProxy* PduMap::getPduProxy(string pdu_name)
{
unsigned int idx = getIdxPduData(pdu_name);
return pduData_ls[idx].getProxy();
}
Tango::DeviceProxy* PduMap::getPduProxy(unsigned int pos)
{
validatePduIndex(pos);
return pduData_ls[pos].getProxy();
}
Tango::DevFailed* PduMap::getPduErrors(string pdu_name)
{
unsigned int idx = getIdxPduData(pdu_name);
return pduData_ls[idx].getErrors();
}
Tango::DevFailed* PduMap::getPduErrors(unsigned int pos)
{
validatePduIndex(pos);
return pduData_ls[pos].getErrors();
}
void PduMap::updateOutletState(string pdu_name, string attr_name, string new_value)
{
unsigned int idx = getIdxPduData(pdu_name);
pduData_ls[idx].setStateByAttr(attr_name, new_value);
}
void PduMap::updateOutletLabel(string pdu_name, string attr_name, string new_value)
{
unsigned int idx = getIdxPduData(pdu_name);
pduData_ls[idx].setLabelByAttr(attr_name, new_value);
}
void PduMap::updateAttrEventId(string pdu_name, string attr_name, int id)
{
unsigned int idx = getIdxPduData(pdu_name);
if (attr_name.substr(0, 5).compare("state") == 0)
{
pduData_ls[idx].setStateEventId(attr_name, id);
return;
}
else if (attr_name.substr(0, 4).compare("name") == 0)
{
pduData_ls[idx].setLabelEventId(attr_name, id);
return;
}
else
{
throw NotValidAttrName(attr_name);
}
}
void PduMap::updatePduError(string pdu_name, Tango::DevFailed *errs)
{
unsigned int idx = getIdxPduData(pdu_name);
pduData_ls[idx].setErrors(errs);
}
string PduMap::toString()
{
stringstream pdu_map_str;
size_t pdu_num = pduData_ls.size();
for(size_t i = 0; i < pdu_num; i++)
{
pdu_map_str << "PDU: " << pduData_ls[i].getDevName() << ": " << endl;
size_t outlest_num = pduData_ls[i].getOutletsCount();
for(size_t j = 0; j < outlest_num; j++)
{
pdu_map_str << "Outlet" << j + 1 << ": [ "
<< pduData_ls[i].getLabelByPos(j) << " | "
<< pduData_ls[i].getStateByPos(j) << " ], "
<< endl << flush;
}
}
return pdu_map_str.str();
}
size_t PduMap::getPduNum()
{
return pduData_ls.size();
}
bool PduMap::inError()
{
size_t len = pduData_ls.size();
for(unsigned int i = 0; i < len; i++)
if(pduData_ls[i].getErrors())
return true;
return false;
}
void PduMap::getCompletePduList(vector<string> pdu_ls)
{
size_t len = pduData_ls.size();
for(unsigned int i = 0; i < len; i++)
pdu_ls.push_back(pduData_ls[i].getDevName());
}
unsigned int PduMap::getIdxPduData(string pdu_name)
{
size_t len = pduData_ls.size();
for(unsigned int i = 0 ; i < len; i++)
if(pdu_name.compare(pduData_ls[i].getDevName()) == 0)
return i;
throw NotValidPduName(pdu_name);
}
bool PduMap::isPduName(string pdu_name)
{
size_t len = pduData_ls.size();
for(unsigned int i = 0 ; i < len; i++)
if(pdu_name.compare(pduData_ls[i].getDevName()) == 0)
return true;
return false;
}
void PduMap::validatePduIndex(unsigned int idx)
{
size_t num = pduData_ls.size();
if (idx >= num)
{
stringstream idx_ss;
string idx_s;
idx_ss << idx;
idx_ss >> idx_s;
throw NotValidPduIndex(idx_s);
}
}
#include <string>
#include <vector>
#include <cctype>
#include <regex>
#include <omnithread.h>
#include <tango.h>
#define MAX_OUTLETS_COUNT 16
struct MapException: runtime_error{
string error_code;
MapException(string msg, string err_code) : runtime_error(msg),
error_code(err_code) {};
};
struct NotValidPduName: MapException{
NotValidPduName(string pdu_name): MapException(
"PDU:\" " + pdu_name + " \" doesn't exist in the pdu map.", "PDU_NOT_EXISTS"){};
};
struct NotValidAttrName : MapException{
NotValidAttrName(string attr_name): MapException(
"Attribute name: \" " + attr_name + " \" doesn't recognized,\
expected \"nameXX\" or \"stateXX\" (X is a digit)", "NOT_VALID_ATTR"){};
};
struct PduNameAlreadyExists : MapException{
PduNameAlreadyExists(string pdu_name): MapException(
"PDU: \" " + pdu_name + " \" already exists in the pdu map", "PDU_ALREADY_EXISTS"){};
};
struct NotValidPduIndex : MapException{
NotValidPduIndex(string pdu_idx): MapException(
"PDU map has not the pdu with index " + pdu_idx, "PDU_INDEX_NOT_VALID"){};
};
struct NotValidOutletIndex : MapException{
NotValidOutletIndex(string pdu_name, string outlet_idx): MapException(
"PDU: \"" + pdu_name + "\" has not outlet " + outlet_idx + ".", "OUTLET_INDEX_NOT_VALID"){};
};
/** AttrData class definition **/
class AttrData
{
public:
/** DATA **/
int event;
string value;
};
/** PduData class definition **/
class PduData
{
private:
/** DATA **/
size_t outlets_count;
string name;
Tango::DeviceProxy *proxy;
Tango::DevFailed *errors;
AttrData state_ls[MAX_OUTLETS_COUNT];
AttrData label_ls[MAX_OUTLETS_COUNT];
/** FUNCTIONS **/
//Validation
void validateOutletIdx(unsigned int i);
void validateLabelAttr(string attr_name);
void validateStateAttr(string attr_name);
public:
/** FUNCTIONS **/
PduData(size_t outletsNum, string dev_name, Tango::DeviceProxy *pdu_proxy);
void setOutletsCount(size_t count);
size_t getOutletsCount();
string getDevName();
void setDevName(string pdu_name);
Tango::DeviceProxy* getProxy();
void setProxy(Tango::DeviceProxy *devPrx);
void setErrors(Tango::DevFailed *errs);
Tango::DevFailed *getErrors();
// Attribute Name
string getLabelByPos(int pos);
string getLabelByAttr(string attr);
void setLabelByPos(int pos, string value);
void setLabelByAttr(string attr, string value);
void setLabelEventId(int pos, int id);
void setLabelEventId(string attr, int id);
// Attribute State
string getStateByPos(int pos);
string getStateByAttr(string attr);
void setStateByPos(int pos, string value);
void setStateByAttr(string attr, string value);
void setStateEventId(int pos, int id);
void setStateEventId(string attr, int id);
vector<int> getAllEvents();
bool matchLabelPattern(string label);
void addIfMatchLabelPattern(vector<string> &outlets_ls, string label);
};
/** PduMap class definition **/
class PduMap
{
private:
/** DATA **/
static PduMap *instance;
vector<PduData> pduData_ls;
/** FUNCTIONS **/
PduMap();
//Validation
unsigned int getIdxPduData(string pdu_name);
bool isPduName(string pdu_name);
void validatePduIndex(unsigned int idx);
public:
/** DATA **/
omni_mutex mutex;
/** FUNCTIONS **/
static void resetInstance();
static PduMap *getInstance();
//Insert and delete PduData
void addPduData(size_t outletsNum, string dev_name, Tango::DeviceProxy *pdu_proxy);
void deletePduData(string dev_name);
//Update data PduData
void updateOutletLabel(string pdu_name, string attr_name, string new_value);
void updateOutletState(string pdu_name, string attr_name, string new_value);
void updateAttrEventId(string pdu_name, string attr_name, int id);
void updatePduError(string pdu_name, Tango::DevFailed *errs);
//Extract data PduData
void getCompletePduList(vector<string> pdu_ls);
void getPduInfoFromName(vector<string> &pdu_info, string pdu_name);
void getPduListFromLabel(vector<string> &pdu_ls, string label);
void getPduListFromName(vector<string> &pdu_ls, string pdu_name);
void getOutletsListFromLabel(vector<string> &outlets_ls, string label_pattern);
void getPduInErrorList(string &pdu_ls);
void getAllPduEvents(vector<int> &events, string pdu_name);
void getAllPduEvents(vector<int> &events, unsigned int pos);
Tango::DeviceProxy* getPduProxy(string pdu_name);
Tango::DeviceProxy* getPduProxy(unsigned int pos);
Tango::DevFailed* getPduErrors(string pdu_name);
Tango::DevFailed* getPduErrors(unsigned int pos);
//Helper
string toString();
size_t getPduNum();
bool inError();
};
This diff is collapsed.
/*----- PROTECTED REGION ID(PduMapper.h) ENABLED START -----*/
//=============================================================================
//
// file : PduMapper.h
//
// description : Include file for the PduMapper class
//
// 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: alessandro.olivo $
//
// $Revision: 1.1.1.1 $
// $Date: 2017-10-02 14:01:30 $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#ifndef PduMapper_H
#define PduMapper_H
#include <tango.h>
#include "PduMap.h"
/*----- PROTECTED REGION END -----*/ // PduMapper.h
/**
* PduMapper class description:
*
*/
namespace PduMapper_ns
{
/*----- PROTECTED REGION ID(PduMapper::Additional Class Declarations) ENABLED START -----*/
// Additional Class Declarations
class AttributeChangeCallBack;
/*----- PROTECTED REGION END -----*/ // PduMapper::Additional Class Declarations
class PduMapper : public TANGO_BASE_CLASS
{
/*----- PROTECTED REGION ID(PduMapper::Data Members) ENABLED START -----*/
// Add your own data members
public:
Tango::DeviceProxy *dbTangoProxy;
AttributeChangeCallBack *attrChngCllBck;
PduMap* pdu_map;
string unmapped_pdu_ls;
size_t tangodb_pdu_count;
/*----- PROTECTED REGION END -----*/ // PduMapper::Data Members
// Device property data members
public:
// pduListPattern: Pattern that allows creation of the list of pdu, e.g. ``*/pdu/*``
string pduListPattern;
bool mandatoryNotDefined;
// Constructors and destructors
public:
/**
* Constructs a newly device object.
*
* @param cl Class.
* @param s Device Name
*/
PduMapper(Tango::DeviceClass *cl,string &s);
/**
* Constructs a newly device object.
*
* @param cl Class.
* @param s Device Name
*/
PduMapper(Tango::DeviceClass *cl,const char *s);
/**
* Constructs a newly device object.
*
* @param cl Class.
* @param s Device name
* @param d Device description.
*/
PduMapper(Tango::DeviceClass *cl,const char *s,const char *d);
/**
* The device object destructor.
*/
~PduMapper() {delete_device();};
// Miscellaneous methods
public:
/*
* will be called at device destruction or at init command.
*/
void delete_device();
/*
* Initialize the device
*/
virtual void init_device();
/*
* Read the device properties from database
*/
void get_device_property();
/*
* Always executed method before execution command method.
*/
virtual void always_executed_hook();
/*
* Check if mandatory property has been set
*/
void check_mandatory_property(Tango::DbDatum &class_prop, Tango::DbDatum &dev_prop);
// Attribute methods
public:
//--------------------------------------------------------
/*
* Method : PduMapper::read_attr_hardware()
* Description : Hardware acquisition for attributes.
*/
//--------------------------------------------------------
virtual void read_attr_hardware(vector<long> &attr_list);
//--------------------------------------------------------
/**
* Method : PduMapper::add_dynamic_attributes()
* Description : Add dynamic attributes if any.
*/
//--------------------------------------------------------
void add_dynamic_attributes();
// Command related methods
public:
/**
* 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
*/
virtual Tango::DevState dev_state();
/**
* 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
*/
virtual Tango::ConstDevString dev_status();
/**
* Command GetPduListFromNamePattern related method
* Description:
*
* @param argin Regex pattern, that indentify part of the Tango name of a pdu (es. uh/pdu/.* )
* @returns List of Tango pdu names matched (could return one or zero pdu name)
*/
virtual Tango::DevVarStringArray *get_pdu_list_from_name_pattern(Tango::DevString argin);
virtual bool is_GetPduListFromNamePattern_allowed(const CORBA::Any &any);
/**
* Command GetPduListFromOutletPattern related method
* Description:
*
* @param argin Regex pattern, that is part of an outlet name (es. .*MSCR.* )
* @returns Tango name list of the pdu whose outlets match the passed argument (could return one or zero pdu name)
*/
virtual Tango::DevVarStringArray *get_pdu_list_from_outlet_pattern(Tango::DevString argin);
virtual bool is_GetPduListFromOutletPattern_allowed(const CORBA::Any &any);
/**
* Command GetPduInfoFromName related method
* Description:
*
* @param argin PDU Tango name : ``domain/family/member``
* @returns List formatted with Name and State value of the pdu like that:
* [``Name01``,``State01``,``Name02``,``State02``,...]
*/
virtual Tango::DevVarStringArray *get_pdu_info_from_name(Tango::DevString argin);
virtual bool is_GetPduInfoFromName_allowed(const CORBA::Any &any);
/**
* Command GetOutletsListFromOutletPattern related method
* Description:
*
* @param argin Regex pattern, that is part of an outlet name (es. .*MSCR.* )
* @returns List of all outlets names matched
*/
virtual Tango::DevVarStringArray *get_outlets_list_from_outlet_pattern(Tango::DevString argin);
virtual bool is_GetOutletsListFromOutletPattern_allowed(const CORBA::Any &any);
//--------------------------------------------------------
/**
* Method : PduMapper::add_dynamic_commands()
* Description : Add dynamic commands if any.
*/
//--------------------------------------------------------
void add_dynamic_commands();
/*----- PROTECTED REGION ID(PduMapper::Additional Method prototypes) ENABLED START -----*/
// Additional Method prototypes
void createPduList(vector<string>&);
void addPduData(string dev_name);
/*----- PROTECTED REGION END -----*/ // PduMapper::Additional Method prototypes
};
/*----- PROTECTED REGION ID(PduMapper::Additional Classes Definitions) ENABLED START -----*/
// Additional Classes Definitions
class AttributeChangeCallBack : public Tango::CallBack
{
void push_event(Tango::EventData *ev);
};
/*----- PROTECTED REGION END -----*/ // PduMapper::Additional Classes Definitions
} // End of namespace
#endif // PduMapper_H
<?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="PduMapper" pogoRevision="9.1">
<description description="" title="" sourcePath="/home/alessandro/devel/fermi/servers/pdumapper/src" language="Cpp" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_Impl" sourcePath=""/>
<identification contact="at gmail.com - alessadro.olivo89" author="alessadro.olivo89" emailDomain="gmail.com" classFamily="SoftwareSystem" siteSpecific="" platform="All Platforms" bus="Data Socket" manufacturer="None" reference=""/>
</description>
<deviceProperties name="pduListPattern" mandatory="true" description="Pattern that allows creation of the list of pdu, e.g. ``*/pdu/*``">
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</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"/>
</argin>
<argout description="Device state">
<type xsi:type="pogoDsl:StateType"/>
</argout>
<status abstract="true" inherited="true" concrete="true" concreteHere="true"/>
</commands>
<commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="none">
<type xsi:type="pogoDsl:VoidType"/>
</argin>
<argout description="Device status">
<type xsi:type="pogoDsl:ConstStringType"/>
</argout>
<status abstract="true" inherited="true" concrete="true" concreteHere="true"/>
</commands>
<commands name="GetPduListFromNamePattern" description="" execMethod="get_pdu_list_from_name_pattern" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="Regex pattern, that indentify part of the Tango name of a pdu (es. uh/pdu/.* )">
<type xsi:type="pogoDsl:StringType"/>
</argin>
<argout description="List of Tango pdu names matched (could return one or zero pdu name)">
<type xsi:type="pogoDsl:StringArrayType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<commands name="GetPduListFromOutletPattern" description="" execMethod="get_pdu_list_from_outlet_pattern" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="Regex pattern, that is part of an outlet name (es. .*MSCR.* )">
<type xsi:type="pogoDsl:StringType"/>
</argin>
<argout description="Tango name list of the pdu whose outlets match the passed argument (could return one or zero pdu name)">
<type xsi:type="pogoDsl:StringArrayType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<commands name="GetPduInfoFromName" description="" execMethod="get_pdu_info_from_name" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="PDU Tango name : ``domain/family/member``">
<type xsi:type="pogoDsl:StringType"/>
</argin>
<argout description="List formatted with Name and State value of the pdu like that:&#xA;[``Name01``,``State01``,``Name02``,``State02``,...]">
<type xsi:type="pogoDsl:StringArrayType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>FAULT</excludedStates>
<excludedStates>INIT</excludedStates>
</commands>
<commands name="GetOutletsListFromOutletPattern" description="" execMethod="get_outlets_list_from_outlet_pattern" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
<argin description="Regex pattern, that is part of an outlet name (es. .*MSCR.* )">
<type xsi:type="pogoDsl:StringType"/>
</argin>
<argout description="List of all outlets names matched">
<type xsi:type="pogoDsl:StringArrayType"/>
</argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</commands>
<states name="FAULT" description="None PDU device server is mapped">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="ON" description="All PDU device servers are mapped and are responsive">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="UNKNOWN" description="One (or more) PDU device server isn`t mapped">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<preferences docHome="./doc_html" makefileHome="/usr/local/tango-9.2.2/share/pogo/preferences"/>
</classes>
</pogoDsl:PogoSystem>
This diff is collapsed.
/*----- PROTECTED REGION ID(PduMapperClass.h) ENABLED START -----*/
//=============================================================================
//
// file : PduMapperClass.h
//
// description : Include for the PduMapper root class.
// This class is the singleton class for
// the PduMapper device class.
// It contains all properties and methods which the
// PduMapper requires only once e.g. the commands.
//
// 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: alessandro.olivo $
//
// $Revision: 1.1.1.1 $
// $Date: 2017-10-02 14:01:30 $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#ifndef PduMapperClass_H
#define PduMapperClass_H
#include <tango.h>
#include <PduMapper.h>
/*----- PROTECTED REGION END -----*/ // PduMapperClass.h
namespace PduMapper_ns
{
/*----- PROTECTED REGION ID(PduMapperClass::classes for dynamic creation) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // PduMapperClass::classes for dynamic creation
//=========================================
// Define classes for commands
//=========================================
// Command GetPduListFromNamePattern class definition
class GetPduListFromNamePatternClass : public Tango::Command
{
public:
GetPduListFromNamePatternClass(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) {};
GetPduListFromNamePatternClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~GetPduListFromNamePatternClass() {};
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<PduMapper *>(dev))->is_GetPduListFromNamePattern_allowed(any);}
};
// Command GetPduListFromOutletPattern class definition
class GetPduListFromOutletPatternClass : public Tango::Command
{
public:
GetPduListFromOutletPatternClass(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) {};
GetPduListFromOutletPatternClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~GetPduListFromOutletPatternClass() {};
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<PduMapper *>(dev))->is_GetPduListFromOutletPattern_allowed(any);}
};
// Command GetPduInfoFromName class definition
class GetPduInfoFromNameClass : public Tango::Command
{
public:
GetPduInfoFromNameClass(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) {};
GetPduInfoFromNameClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~GetPduInfoFromNameClass() {};
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<PduMapper *>(dev))->is_GetPduInfoFromName_allowed(any);}
};
// Command GetOutletsListFromOutletPattern class definition
class GetOutletsListFromOutletPatternClass : public Tango::Command
{
public:
GetOutletsListFromOutletPatternClass(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) {};
GetOutletsListFromOutletPatternClass(const char *name,
Tango::CmdArgType in,
Tango::CmdArgType out)
:Command(name,in,out) {};
~GetOutletsListFromOutletPatternClass() {};
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<PduMapper *>(dev))->is_GetOutletsListFromOutletPattern_allowed(any);}
};
/**
* The PduMapperClass singleton definition
*/
#ifdef _TG_WINDOWS_
class __declspec(dllexport) PduMapperClass : public Tango::DeviceClass
#else
class PduMapperClass : public Tango::DeviceClass
#endif
{
/*----- PROTECTED REGION ID(PduMapperClass::Additionnal DServer data members) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // PduMapperClass::Additionnal DServer data members
public:
// write class properties data members
Tango::DbData cl_prop;
Tango::DbData cl_def_prop;
Tango::DbData dev_def_prop;
// Method prototypes
static PduMapperClass *init(const char *);
static PduMapperClass *instance();
~PduMapperClass();
Tango::DbDatum get_class_property(string &);
Tango::DbDatum get_default_device_property(string &);
Tango::DbDatum get_default_class_property(string &);
protected:
PduMapperClass(string &);
static PduMapperClass *_instance;
void command_factory();
void attribute_factory(vector<Tango::Attr *> &);
void pipe_factory();
void write_class_property();
void set_default_property();
void get_class_property();
string get_cvstag();
string get_cvsroot();
private:
void device_factory(const Tango::DevVarStringArray *);
void create_static_attribute_list(vector<Tango::Attr *> &);
void erase_dynamic_attributes(const Tango::DevVarStringArray *,vector<Tango::Attr *> &);
vector<string> defaultAttList;
Tango::Attr *get_attr_object_by_name(vector<Tango::Attr *> &att_list, string attname);
};
} // End of namespace
#endif // PduMapper_H
/*----- PROTECTED REGION ID(PduMapperStateMachine.cpp) ENABLED START -----*/
//=============================================================================
//
// file : PduMapperStateMachine.cpp
//
// description : State machine file for the PduMapper class
//
// 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: alessandro.olivo $
//
// $Revision: 1.1.1.1 $
// $Date: 2017-10-02 14:01:30 $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#include <PduMapper.h>
/*----- PROTECTED REGION END -----*/ // PduMapper::PduMapperStateMachine.cpp
//================================================================
// States | Description
//================================================================
// FAULT | None PDU device server is mapped
// ON | All PDU device servers are mapped and are responsive
// UNKNOWN | One (or more) PDU device server isn`t mapped
namespace PduMapper_ns
{
//=================================================
// Attributes Allowed Methods
//=================================================
//=================================================
// Commands Allowed Methods
//=================================================
//--------------------------------------------------------
/**
* Method : PduMapper::is_GetPduListFromNamePattern_allowed()
* Description : Execution allowed for GetPduListFromNamePattern attribute
*/
//--------------------------------------------------------
bool PduMapper::is_GetPduListFromNamePattern_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Compare device state with not allowed states.
if (get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PduMapper::GetPduListFromNamePatternStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // PduMapper::GetPduListFromNamePatternStateAllowed
return false;
}
return true;
}
//--------------------------------------------------------
/**
* Method : PduMapper::is_GetPduListFromOutletPattern_allowed()
* Description : Execution allowed for GetPduListFromOutletPattern attribute
*/
//--------------------------------------------------------
bool PduMapper::is_GetPduListFromOutletPattern_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Compare device state with not allowed states.
if (get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PduMapper::GetPduListFromOutletPatternStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // PduMapper::GetPduListFromOutletPatternStateAllowed
return false;
}
return true;
}
//--------------------------------------------------------
/**
* Method : PduMapper::is_GetPduInfoFromName_allowed()
* Description : Execution allowed for GetPduInfoFromName attribute
*/
//--------------------------------------------------------
bool PduMapper::is_GetPduInfoFromName_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Compare device state with not allowed states.
if (get_state()==Tango::FAULT ||
get_state()==Tango::INIT)
{
/*----- PROTECTED REGION ID(PduMapper::GetPduInfoFromNameStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // PduMapper::GetPduInfoFromNameStateAllowed
return false;
}
return true;
}
//--------------------------------------------------------
/**
* Method : PduMapper::is_GetOutletsListFromOutletPattern_allowed()
* Description : Execution allowed for GetOutletsListFromOutletPattern attribute
*/
//--------------------------------------------------------
bool PduMapper::is_GetOutletsListFromOutletPattern_allowed(TANGO_UNUSED(const CORBA::Any &any))
{
// Not any excluded states for GetOutletsListFromOutletPattern command.
/*----- PROTECTED REGION ID(PduMapper::GetOutletsListFromOutletPatternStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // PduMapper::GetOutletsListFromOutletPatternStateAllowed
return true;
}
/*----- PROTECTED REGION ID(PduMapper::PduMapperStateAllowed.AdditionalMethods) ENABLED START -----*/
// Additional Methods
/*----- PROTECTED REGION END -----*/ // PduMapper::PduMapperStateAllowed.AdditionalMethods
} // End of namespace
/*----- PROTECTED REGION ID(PduMapper::main.cpp) ENABLED START -----*/
//=============================================================================
//
// file : main.cpp
//
// description : C++ source for the PduMapper 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 :
//
// 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: alessandro.olivo $
//
// $Revision: 1.1.1.1 $
// $Date: 2017-10-02 14:01:30 $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#include <tango.h>
// Check if crash reporting is used.
#if defined(ENABLE_CRASH_REPORT)
# include <crashreporting/crash_report.h>
#else
# define DECLARE_CRASH_HANDLER
# define INSTALL_CRASH_HANDLER
#endif
DECLARE_CRASH_HANDLER;
int main(int argc,char *argv[])
{
INSTALL_CRASH_HANDLER
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 -----*/ // PduMapper::main.cpp
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