Commit 55d7a5a1 authored by Alessandro Abrami's avatar Alessandro Abrami
Browse files

2021/10/15:

	Aggiunto History
parent 0ac7e85f
.gitignore
MYNOTES.txt
MSG.txt
ken-pespccdstage-srv_mag_pesp.txt
......
[submodule "deps/libhist"]
path = deps/libhist
url = git@gitlab.elettra.eu:cs/lib/libhist.git
CXXFLAGS += -I deps/libhist/include/
CFLAGS += -I deps/libhist/include/
LIBHIST_DEPSRCDIR = deps/libhist/src
LIBHIST_ALL_LIB_SRCS += $(wildcard $(LIBHIST_DEPSRCDIR)/*.cpp)
##LIB_SRCS = $(filter-out \ $(DEPSRCDIR)/CB_main.cpp \ , $(ALL_LIB_SRCS))
LIBHIST_LIB_SRCS = $(LIBHIST_ALL_LIB_SRCS)
LIBHIST_LIB_OBJS += $(addprefix obj/,$(notdir $(LIBHIST_LIB_SRCS:.cpp=.o)))
EXTRA_SRCS += $(LIBHIST_LIB_SRCS)
EXTRA_OBJS += $(LIBHIST_LIB_OBJS)
#------------------------------------------------------
SUBMODULES += GIT:: deps/libhist:$(shell cd deps/libhist; git describe --dirty)
CXXFLAGS += -D'SUBMODULES="$(SUBMODULES)"'
CFLAGS += -D'SUBMODULES="$(SUBMODULES)"'
#------------------------------------------------------
obj/%.o: $(LIBHIST_DEPSRCDIR)/%.cpp
@echo "CC " -o $@ $<
$(Q)$(CXX) $(CXXFLAGS) -c -o $@ $<
......@@ -3,7 +3,6 @@ NAME_SRV = pespccdstage-srv
CXXFLAGS =
LDFLAGS = -litpp
CXXFLAGS += -D_SIMUL_
#CXXFLAGS += -D_DBG_INIT
#CXXFLAGS += -D_DBG_PARAMETERS
......@@ -78,6 +77,9 @@ REPO := GIT:: $(shell git config --get remote.origin.url)
LOC_REPO := GIT:: $(shell git rev-parse --show-toplevel)
CXXFLAGS += -D'REPO="$(LOC_REPO)"'
include Make-libhist.in
OBJ_FILES += $(EXTRA_OBJS)
include ../makefiles/Make-9.3.3.in
LDFLAGS += -laxisutils
......
Subproject commit aa168b88b97782290c5aca935958e050927c0f46
......@@ -76,6 +76,7 @@
// BeamOnYagDisplacement | Tango::DevDouble Scalar
// UpdateOnDisplacement | Tango::DevBoolean Scalar
// FilterTrackEnable | Tango::DevBoolean Scalar
// History | Tango::DevString Spectrum ( max = 2000)
//================================================================
namespace PespCCDStage_ns
......@@ -136,6 +137,22 @@ void PespCCDStage::delete_device()
//
INFO_STREAM << "PespCCDStage::PespCCDStage() delete device " << device_name << endl;
for (int i=0; i<2000; i++){
if (attr_History_read[i] != NULL){
#ifdef _DBG_HISTORY
cout << "Going to delete attr_History_read[" << i << "]" << endl;
#endif
delete[] attr_History_read[i];
attr_History_read[i] = NULL;
}
}
if (hist) {
delete hist;
hist = NULL;
}
if (gridX.dp!= NULL) {delete gridX.dp; gridX.dp=NULL;};
if (gridZ.dp!= NULL) {delete gridZ.dp; gridZ.dp=NULL;};
if (gridpic.dp!= NULL) {delete gridpic.dp; gridpic.dp=NULL;};
......@@ -203,6 +220,7 @@ void PespCCDStage::delete_device()
delete[] attr_BeamOnYagDisplacement_read;
delete[] attr_UpdateOnDisplacement_read;
delete[] attr_FilterTrackEnable_read;
delete[] attr_History_read;
}
//--------------------------------------------------------
......@@ -307,6 +325,7 @@ typedef struct {
attr_BeamOnYagDisplacement_read = new Tango::DevDouble[1];
attr_UpdateOnDisplacement_read = new Tango::DevBoolean[1];
attr_FilterTrackEnable_read = new Tango::DevBoolean[1];
attr_History_read = new Tango::DevString[2000];
// No longer if mandatory property not set.
if (mandatoryNotDefined)
return;
......@@ -315,6 +334,18 @@ typedef struct {
// Initialize device
hist = new History_ns::history(this);
hist->set_max_sample(2000);
for (int i=0; i<2000; i++){
attr_History_read[i] = new char[2];
sprintf(attr_History_read[i], "-");
#ifdef _DBG_HISTORY
cout << "attr_History_read[" << i << "]=" << attr_History_read[i] << "|" << endl;
#endif /* _DBG_HISTORY*/
}
#if 1
chamber.set_size(2,false);
ccd.set_size(2,false);
......@@ -618,7 +649,9 @@ typedef struct {
set_status("Error in init_device()!");
}
std::stringstream ss;
ss << __func__ << "(done)";
hist->push_end(ss.str());
#ifdef _DBG_PARAMETERS
std::cout << "END -------- PespCCDStage::init_device(" << device_name << ") --------" << std::endl;
......@@ -960,6 +993,10 @@ void PespCCDStage::write_FocusX(Tango::WAttribute &attr)
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(PespCCDStage::write_FocusX) ENABLED START -----*/
std::stringstream ss;
ss << __func__ << "(" << w_val << ")";
hist->push_end(ss.str());
if (get_state() == Tango::FAULT) return;
itpp::vec newXZ(2);
......@@ -1028,6 +1065,10 @@ void PespCCDStage::write_FocusZ(Tango::WAttribute &attr)
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(PespCCDStage::write_FocusZ) ENABLED START -----*/
std::stringstream ss;
ss << __func__ << "(" << w_val << ")";
hist->push_end(ss.str());
if (get_state() == Tango::FAULT) return;
itpp::vec newXZ(2);
......@@ -1095,6 +1136,10 @@ void PespCCDStage::write_FocusDistance(Tango::WAttribute &attr)
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(PespCCDStage::write_FocusDistance) ENABLED START -----*/
std::stringstream ss;
ss << __func__ << "(" << w_val << ")";
hist->push_end(ss.str());
if (get_state() == Tango::FAULT) return;
itpp::vec newXZ(2);
......@@ -1168,6 +1213,10 @@ void PespCCDStage::write_FocusAngle(Tango::WAttribute &attr)
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(PespCCDStage::write_FocusAngle) ENABLED START -----*/
std::stringstream ss;
ss << __func__ << "(" << w_val << ")";
hist->push_end(ss.str());
if (get_state() == Tango::FAULT) return;
itpp::vec newXZ(2);
......@@ -1261,6 +1310,10 @@ void PespCCDStage::write_BeamOnYagDisplacement(Tango::WAttribute &attr)
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(PespCCDStage::write_BeamOnYagDisplacement) ENABLED START -----*/
std::stringstream ss;
ss << __func__ << "(" << w_val << ")";
hist->push_end(ss.str());
// dall'ultimo updateattributes() grazie all'always_exe_hook()
// sono aggiornati:
itpp::vec oldXZ(2);
......@@ -1346,6 +1399,10 @@ void PespCCDStage::write_UpdateOnDisplacement(Tango::WAttribute &attr)
Tango::DevBoolean w_val;
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(PespCCDStage::write_UpdateOnDisplacement) ENABLED START -----*/
std::stringstream ss;
ss << __func__ << "(" << w_val << ")";
hist->push_end(ss.str());
attr_UpdateOnDisplacement_read[0] = w_val;
......@@ -1386,11 +1443,37 @@ void PespCCDStage::write_FilterTrackEnable(Tango::WAttribute &attr)
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(PespCCDStage::write_FilterTrackEnable) ENABLED START -----*/
std::stringstream ss;
ss << __func__ << "(" << w_val << ")";
hist->push_end(ss.str());
// FF
attr_FilterTrackEnable_read[0] = w_val;
/*----- PROTECTED REGION END -----*/ // PespCCDStage::write_FilterTrackEnable
}
//--------------------------------------------------------
/**
* Read attribute History related method
* Description:
*
* Data type: Tango::DevString
* Attr type: Spectrum max = 2000
*/
//--------------------------------------------------------
void PespCCDStage::read_History(Tango::Attribute &attr)
{
DEBUG_STREAM << "PespCCDStage::read_History(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(PespCCDStage::read_History) ENABLED START -----*/
int howmany = hist->copyto(attr_History_read);
if (howmany > 0) attr.set_value(attr_History_read, howmany);
// Set the attribute value
//attr.set_value(attr_History_read, 2000);
/*----- PROTECTED REGION END -----*/ // PespCCDStage::read_History
}
//--------------------------------------------------------
/**
......@@ -1440,6 +1523,10 @@ void PespCCDStage::write_YagSelector(Tango::WAttribute &attr)
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(PespCCDStage::write_YagSelector) ENABLED START -----*/
std::stringstream ss;
ss << __func__ << "(" << w_val << ")";
hist->push_end(ss.str());
// dall'ultimo updateattributes() grazie all'always_exe_hook()
// sono aggiornati:
itpp::vec oldXZ(2);
......@@ -1553,6 +1640,10 @@ void PespCCDStage::write_UpdateOnSelector(Tango::WAttribute &attr)
attr.get_write_value(w_val);
/*----- PROTECTED REGION ID(PespCCDStage::write_UpdateOnSelector) ENABLED START -----*/
std::stringstream ss;
ss << __func__ << "(" << w_val << ")";
hist->push_end(ss.str());
attr_UpdateOnSelector = w_val;
......@@ -1608,9 +1699,13 @@ Tango::DevBoolean PespCCDStage::set_angle_distance(const Tango::DevVarDoubleArra
// Add your own code to control device here
if (get_state() == Tango::FAULT) return false;
double _angle = (*argin)[0];
double _distance = (*argin)[1];
std::stringstream ss;
ss << __func__ << "(" << _angle << "," << _distance << ")";
hist->push_end(ss.str());
if (get_state() == Tango::FAULT) return false;
itpp::vec newccd;
double angle = (*argin)[0];
......@@ -1671,6 +1766,10 @@ void PespCCDStage::stop()
// Add your own code
std::stringstream ss;
ss << __func__ << "()";
hist->push_end(ss.str());
if (get_state() == Tango::FAULT) return;
try {
......@@ -1701,6 +1800,10 @@ Tango::DevVarStringArray *PespCCDStage::get_instrument_list()
Tango::DevVarStringArray *argout;
DEBUG_STREAM << "PespCCDStage::GetInstrumentList() - " << device_name << endl;
/*----- PROTECTED REGION ID(PespCCDStage::get_instrument_list) ENABLED START -----*/
std::stringstream ss;
ss << __func__ << "()";
hist->push_end(ss.str());
argout = new Tango::DevVarStringArray();
......
......@@ -62,6 +62,8 @@ typedef struct {
#include "Stage2Filter.h"
#include "History.h"
/*----- PROTECTED REGION END -----*/ // PespCCDStage.h
......@@ -89,6 +91,8 @@ private:
bool need_newpos_afterstop;
Tango::DevShort olds;
History_ns::history* hist;
public:
mover_t ccdstageN;
mover_t ccdstageL;
......@@ -174,6 +178,7 @@ public:
Tango::DevDouble *attr_BeamOnYagDisplacement_read;
Tango::DevBoolean *attr_UpdateOnDisplacement_read;
Tango::DevBoolean *attr_FilterTrackEnable_read;
Tango::DevString *attr_History_read;
// Constructors and destructors
public:
......@@ -334,6 +339,15 @@ public:
virtual void read_FilterTrackEnable(Tango::Attribute &attr);
virtual void write_FilterTrackEnable(Tango::WAttribute &attr);
virtual bool is_FilterTrackEnable_allowed(Tango::AttReqType type);
/**
* Attribute History related methods
* Description:
*
* Data type: Tango::DevString
* Attr type: Spectrum max = 2000
*/
virtual void read_History(Tango::Attribute &attr);
virtual bool is_History_allowed(Tango::AttReqType type);
// Dynamic attribute methods
public:
......
......@@ -171,6 +171,14 @@
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<attributes name="History" attType="Spectrum" rwType="READ" displayLevel="EXPERT" polledPeriod="0" maxX="2000" maxY="" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:StringType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
<dataReadyEvent fire="false" libCheckCriteria="true"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
</attributes>
<dynamicAttributes name="YagSelector" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" memorizedAtInit="true" allocReadMember="true" isDynamic="true">
<dataType xsi:type="pogoDsl:UShortType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
......
......@@ -769,6 +769,30 @@ void PespCCDStageClass::attribute_factory(vector<Tango::Attr *> &att_list)
filtertrackenable->set_memorized_init(true);
att_list.push_back(filtertrackenable);
// Attribute : History
HistoryAttrib *history = new HistoryAttrib();
Tango::UserDefaultAttrProp history_prop;
// description not set for History
// label not set for History
// unit not set for History
// standard_unit not set for History
// display_unit not set for History
// format not set for History
// max_value not set for History
// min_value not set for History
// max_alarm not set for History
// min_alarm not set for History
// max_warning not set for History
// min_warning not set for History
// delta_t not set for History
// delta_val not set for History
history->set_default_properties(history_prop);
// Not Polled
history->set_disp_level(Tango::EXPERT);
// Not Memorized
att_list.push_back(history);
// Create a list of static attributes
create_static_attribute_list(get_class_attr()->get_attr_list());
......
......@@ -185,6 +185,19 @@ public:
{return (static_cast<PespCCDStage *>(dev))->is_FilterTrackEnable_allowed(ty);}
};
// Attribute History class definition
class HistoryAttrib: public Tango::SpectrumAttr
{
public:
HistoryAttrib():SpectrumAttr("History",
Tango::DEV_STRING, Tango::READ, 2000) {};
~HistoryAttrib() {};
virtual void read(Tango::DeviceImpl *dev,Tango::Attribute &att)
{(static_cast<PespCCDStage *>(dev))->read_History(att);}
virtual bool is_allowed(Tango::DeviceImpl *dev,Tango::AttReqType ty)
{return (static_cast<PespCCDStage *>(dev))->is_History_allowed(ty);}
};
//=========================================
// Define classes for dynamic attributes
......
......@@ -217,6 +217,22 @@ bool PespCCDStage::is_FilterTrackEnable_allowed(TANGO_UNUSED(Tango::AttReqType t
return true;
}
//--------------------------------------------------------
/**
* Method : PespCCDStage::is_History_allowed()
* Description : Execution allowed for History attribute
*/
//--------------------------------------------------------
bool PespCCDStage::is_History_allowed(TANGO_UNUSED(Tango::AttReqType type))
{
// Not any excluded states for History attribute in read access.
/*----- PROTECTED REGION ID(PespCCDStage::HistoryStateAllowed_READ) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // PespCCDStage::HistoryStateAllowed_READ
return true;
}
//--------------------------------------------------------
/**
* Method : PespCCDStage::is_YagSelector_allowed()
......
Markdown is supported
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