diff --git a/.gitignore b/.gitignore index 89fc1c383e6c16c1b753c2f79fd0382343436026..845a487972f0e86d251baa551ade143ef9e3b60a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.gitignore MYNOTES.txt MSG.txt ken-pespccdstage-srv_mag_pesp.txt diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000000000000000000000000000000000..de6023a4c9ea1125c6d1563c0efa08e4b28fda83 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "deps/libhist"] + path = deps/libhist + url = git@gitlab.elettra.eu:cs/lib/libhist.git diff --git a/Make-libhist.in b/Make-libhist.in new file mode 100644 index 0000000000000000000000000000000000000000..5cac88c3e5945bc195bd1f4ec69a6f73f97bb454 --- /dev/null +++ b/Make-libhist.in @@ -0,0 +1,29 @@ + +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 $@ $< + diff --git a/Makefile b/Makefile index 0d8b54dcb3e4d7ae40fb286afcbd400c9a581b49..6c6764e83b3cf19d1e047496526fadc92a3d27a4 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/deps/libhist b/deps/libhist new file mode 160000 index 0000000000000000000000000000000000000000..aa168b88b97782290c5aca935958e050927c0f46 --- /dev/null +++ b/deps/libhist @@ -0,0 +1 @@ +Subproject commit aa168b88b97782290c5aca935958e050927c0f46 diff --git a/src/PespCCDStage.cpp b/src/PespCCDStage.cpp index 2fd087c04b15276d25c85fd044b5d6581a66d3d0..8ad858e76251d79688771b530f6f8a4ccfcb7b5d 100644 --- a/src/PespCCDStage.cpp +++ b/src/PespCCDStage.cpp @@ -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(); diff --git a/src/PespCCDStage.h b/src/PespCCDStage.h index 6b41f5ca649fe243ed1cc3d364b05c9085420d20..abd04af667f330db604c960d40c90aac4615fc1c 100644 --- a/src/PespCCDStage.h +++ b/src/PespCCDStage.h @@ -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: diff --git a/src/PespCCDStage.xmi b/src/PespCCDStage.xmi index f3ed463957a64b24376fef82b40b6a90e6ea525e..8d7c69752b348775c5f2e77deb3b41fbc8c37012 100644 --- a/src/PespCCDStage.xmi +++ b/src/PespCCDStage.xmi @@ -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"/> diff --git a/src/PespCCDStageClass.cpp b/src/PespCCDStageClass.cpp index e11bd897181873dc54e649d7e4d3f453515d4141..befd17f994ecd430eeb91148b4b099745e0be288 100644 --- a/src/PespCCDStageClass.cpp +++ b/src/PespCCDStageClass.cpp @@ -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()); diff --git a/src/PespCCDStageClass.h b/src/PespCCDStageClass.h index 9ba53e6b2330436981f694496ad4626e7bb57a21..1bff26500555ed8a5b272ae973e2beefe647edb2 100644 --- a/src/PespCCDStageClass.h +++ b/src/PespCCDStageClass.h @@ -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 diff --git a/src/PespCCDStageStateMachine.cpp b/src/PespCCDStageStateMachine.cpp index 7f464bbe724790063208f93b00ab8a9c0c9c03d8..7595b360a5cda047ccdb11b0f8c594b8b1e7d93c 100644 --- a/src/PespCCDStageStateMachine.cpp +++ b/src/PespCCDStageStateMachine.cpp @@ -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()