From b78c95500b95ecb80e41f5cf974268a5acaf4776 Mon Sep 17 00:00:00 2001 From: Alessandro Abrami <alessandro.abrami@elettra.eu> Date: Thu, 9 Sep 2021 10:16:41 +0200 Subject: [PATCH] 2021/09/09: BRANCH(withFilters): piccola modifica per il segno di d2, verificato Mag/Andor vs dati di Fava: OK. --- src/PespCCDStage.cpp | 30 +++++++++++++++++++++++++++++- src/PespCCDStage.h | 3 +++ src/Stage2Filter.cpp | 8 +++++++- src/Stage2Filter.h | 3 +++ 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/PespCCDStage.cpp b/src/PespCCDStage.cpp index 5726885..aaf8b9b 100644 --- a/src/PespCCDStage.cpp +++ b/src/PespCCDStage.cpp @@ -328,6 +328,7 @@ typedef struct { qr.set_size(2,false); #endif + need_newpos_afterstop = false; rot(0,0)=cos(rotationXN); rot(0,1)=-sin(rotationXN); @@ -397,6 +398,7 @@ typedef struct { #endif else p_stage2flt = NULL; + //=============================================================== } else { pstage = NULL; @@ -409,6 +411,9 @@ typedef struct { init_ok = false; } + if (p_stage2flt != NULL) { + olds = p_stage2flt->currSelector(); + }; ccdstageN.dev = cCDStageAxis[0]; ccdstageN.move_attr = cCDStageAxis[1]; @@ -1824,9 +1829,32 @@ void PespCCDStage::updateattributes(){ *attr_FocusDistance_read = br[1]; +//FFFF if (p_stage2flt != NULL) { + //Tango::DevShort olds = p_stage2flt->currSelector(); if (!p_stage2flt->update()) { - ERROR_STREAM << "Read filters FAILED !!!" << endl; + ERROR_STREAM << "Read filters FAILED !!!" << endl; + } else { + Tango::DevShort currs = p_stage2flt->currSelector(); + if ( currs != olds ) { + cout << "OLD selector:" << olds << " | NEW selector:" << currs << endl; + olds = currs; + need_newpos_afterstop = true; + } + } + if (need_newpos_afterstop){ + // quando si fermera' si fara' un correct pos + if ( p_stage2flt->stateSelector() != Tango::MOVING ){ + if ( attr_FilterTrackEnable_read[0] ) { + itpp::vec Focus(2); + Focus(0) = *attr_FocusX_read; + Focus(1) = *attr_FocusZ_read; + if (!p_stage2flt->correct_position(Focus)){ + INFO_STREAM << "PespCCDStage::write_FocusX() error on filters"<< endl; + } + need_newpos_afterstop = false; + } + } } } else { cout << "p_stage2flt NULL !!!" << endl; diff --git a/src/PespCCDStage.h b/src/PespCCDStage.h index 4e2fab9..20ad96b 100644 --- a/src/PespCCDStage.h +++ b/src/PespCCDStage.h @@ -86,6 +86,9 @@ class PespCCDStage : public TANGO_BASE_CLASS // Add your own data members private: PespStage_ns::Stage2Filter* p_stage2flt; + + bool need_newpos_afterstop; + Tango::DevShort olds; public: mover_t ccdstageN; mover_t ccdstageL; diff --git a/src/Stage2Filter.cpp b/src/Stage2Filter.cpp index e062b99..33ce271 100644 --- a/src/Stage2Filter.cpp +++ b/src/Stage2Filter.cpp @@ -273,8 +273,14 @@ bool Stage2Filter::correct_position(itpp::vec Focus){ // sposto di D2 la posizione del filtro // la direzione di d2 e' da asse tubo verso x,z >0,>0 // mentre l'asse filtro e inverso + //!! + //!! pero' d2, distanza e' sempre positiva, + //!! mentre devo spostare in positivo o negativo + //!! ovvero devo capire se I2 sta' al di la' o al di qua' dell'asse tubo + //!! I2(x) - I1(x) < 0 allora d2<0 // - double newpos = _sel.nominal_pos[_sel.selector].pos - d2; + if ( (i2(0) - i1(0)) < 0 ) d2 *= (-1.0); + double newpos = _sel.nominal_pos[_sel.selector].pos + d2; #ifdef _DBG_STAGE2FILTER cout << ">>>>> " << __func__ << " newpos=" << newpos << endl; diff --git a/src/Stage2Filter.h b/src/Stage2Filter.h index aaa573b..17f2151 100644 --- a/src/Stage2Filter.h +++ b/src/Stage2Filter.h @@ -60,6 +60,9 @@ public: bool correct_position(itpp::vec Focus); + Tango::DevShort currSelector() { return _sel.selector; }; + Tango::DevState stateSelector() { return _sel.state; }; + }; } // namespace -- GitLab