diff --git a/src/EEHGMaster.py b/src/EEHGMaster.py index 9b91293750f37581f6313ad7d65235d502ce483d..237c981a9a7e6641e028d722145ae03637a22c63 100755 --- a/src/EEHGMaster.py +++ b/src/EEHGMaster.py @@ -139,7 +139,7 @@ class EEHGMaster(Device): access=AttrWriteType.READ_WRITE, label="harmonic of the first seed", max_value=0, - min_value=-3, + min_value=-1, memorized=True, doc="The harmonic of the first seed used in EEHG of in HGHG1 and HGHG1*", ) @@ -197,14 +197,6 @@ class EEHGMaster(Device): doc="Give the priority to the solution that has larger bunching", ) - pref_rx = attribute( - dtype='DevBoolean', - access=AttrWriteType.READ_WRITE, - label="pref_rx", - memorized=True, - doc="This is selected to take the rigth peak of EEHG when possible", - ) - bunc_fel = attribute( dtype='DevDouble', label="bunching fel", @@ -644,6 +636,16 @@ class EEHGMaster(Device): memorized=True, ) + picco_pref = attribute( + dtype='DevShort', + access=AttrWriteType.READ_WRITE, + label="picco selection", + max_value=2, + min_value=0, + memorized=True, + doc="This is selection of R56 peak of EEHG: 0 left, 1 rigth, 2 both.", + ) + bunc_sol = attribute( dtype=('DevLong64',), max_dim_x=32, @@ -664,7 +666,7 @@ class EEHGMaster(Device): self.seed_dev_atts_toread = ['State', 'wavelength', 'bandwidth', 'energy', 'energy_max', 'wavelength2', 'bandwidth2', 'energy2', 'energy2_max', - 'wavelength_range'] + 'wavelength_range', 'wavelength2_range'] # definisco delle variabili di servizio per i limiti sup. dell'en. seed self.nrg_s1_range = 50.0 self.nrg_s2_range = 20.0 @@ -683,6 +685,7 @@ class EEHGMaster(Device): self._e_compression = float('Nan') self._e_nrg_lh = 100.0 self._e_dgamma_lh = float('Nan') + self._picco_pref = 0 self._r561 = float('Nan') self._r562 = float('Nan') @@ -725,7 +728,6 @@ class EEHGMaster(Device): self._waist_s2 = 0.2 self._prior_wl_seed = True self._prior_bunch = False - self._pref_rx = True self._bunc_fel = float('Nan') self._b_min = float('Nan') @@ -967,18 +969,6 @@ class EEHGMaster(Device): self._prior_wl_seed = not value # PROTECTED REGION END # // EEHGMaster.prior_bunch_write - def read_pref_rx(self): - # PROTECTED REGION ID(EEHGMaster.pref_rx_read) ENABLED START # - """Return the pref_rx attribute.""" - return self._pref_rx - # PROTECTED REGION END # // EEHGMaster.pref_rx_read - - def write_pref_rx(self, value): - # PROTECTED REGION ID(EEHGMaster.pref_rx_write) ENABLED START # - """Set the pref_rx attribute.""" - pass - # PROTECTED REGION END # // EEHGMaster.pref_rx_write - def read_bunc_fel(self): # PROTECTED REGION ID(EEHGMaster.bunc_fel_read) ENABLED START # """Return the bunc_fel attribute.""" @@ -1629,6 +1619,19 @@ class EEHGMaster(Device): self._lambda_s1_curr = value # PROTECTED REGION END # // EEHGMaster.lambda_s1_curr_write + def read_picco_pref(self): + # PROTECTED REGION ID(EEHGMaster.picco_pref_read) ENABLED START # + """Return the picco_pref attribute.""" + return self._picco_pref + # PROTECTED REGION END # // EEHGMaster.picco_pref_read + + def write_picco_pref(self, value): + # PROTECTED REGION ID(EEHGMaster.picco_pref_write) ENABLED START # + """Set the picco_pref attribute.""" + self._picco_pref = value + pass + # PROTECTED REGION END # // EEHGMaster.picco_pref_write + def read_bunc_sol(self): # PROTECTED REGION ID(EEHGMaster.bunc_sol_read) ENABLED START # """Return the bunc_sol attribute.""" @@ -1657,12 +1660,16 @@ class EEHGMaster(Device): #n_curr = -1 #andrebbe letto dal server EEHG come valore di n #m_curr = 21 #andrebbe letto dal server EEHG come valore di m - n_rng = [-1,0] # puo' essere anche [-n, 0], n = 1, 2, 3 ... ma all' aumentare di n il tempo di calcolo aumenta - m_rng = [1,50] + #n_rng = [-1,0] # puo' essere anche [-n, 0], n = 1, 2, 3 ... ma all' aumentare di n il tempo di calcolo aumenta + #m_rng = [1,50] + n_rng = [int(self.n.get_properties().min_value), int(self.n.get_properties().max_value)] # puo' essere anche [-n, 0], n = 1, 2, 3 ... ma all' aumentare di n il tempo di calcolo aumenta + m_rng = [int(self.m.get_properties().min_value), int(self.m.get_properties().max_value)] + + #picco = 'left' # can be also 'right' or ' both' #picco = 'left' # can be also 'right' or ' both' - picco = 'left' # can be also 'right' or ' both' #i_solution = 0 # indice della soluzione da applicare. per difetto e' la prima trovata - + picchi = ['left', 'right', ' both'] + picco = picchi[self._picco_pref] """ calcola configurazioni usando utili """ @@ -1739,6 +1746,41 @@ class EEHGMaster(Device): self.set_state(tango.DevState.FAULT) self.set_status('Calculation failed.') return + + # variabili locali + A1_sol = solu[0] + A2_sol = solu[1] + R561_sol = solu[2] + R562_sol = solu[3] + Wls1_sol = solu[4] + Wls2_sol = solu[5] + N_sol = solu[6] + M_sol = solu[7] + Bmax_sol = solu[8] + B_var = solu[9] + + indTutto = np.where(Bmax_sol>0.00001) + + indA1 = np.where( (A1_sol>=A1_range[0]) & (A1_sol<=A1_range[1])) + indA2 = np.where( (A2_sol>=A2_range[0]) & (A2_sol<=A2_range[1])) + indR561 = np.where( (R561_sol>=R561_range[0]) & (R561_sol<=R561_range[1])) + indR562 = np.where( (R562_sol>=R562_range[0]) & (R562_sol<=R562_range[1])) + + indOK = np.intersect1d(indTutto,indA1) + indOK = np.intersect1d(indOK,indA2) + indOK = np.intersect1d(indOK,indR561) + indOK = np.intersect1d(indOK,indR562) + + if len(indOK)>0: + #print('\033[92m'+'ho trovato almeno una soluzione valida\n'+'\033[0m') + pass + else: +# print('\033[93m'+'non ho trovato nessuna soluzione valida\n'+'\033[0m') +# solucheck = False + self.set_state(tango.DevState.FAULT) + self.set_status('Calculation do not found solutions.') + return + ''' soluzione da applicare i_solution @@ -1759,9 +1801,10 @@ class EEHGMaster(Device): # M_sol_ap = solu[7][self._i_solution] # da scivere nel server sul valore di m self.write_m(solu[7][self._i_solution]) # Bmax_sol_ap = solu[8][self._i_solution] # da scivere nel server su bunch_fel - bunching_array = solu[8] +# bunching_array = solu[8] # print(bunching_array) - self._bunc_sol = solu[8][self._i_solution] +# self._bunc_sol = solu[8][self._i_solution] + self._bunc_sol = solu[8] # B_var_ap = solu[9][self._i_solution] self.set_state(tango.DevState.ON) @@ -1923,9 +1966,8 @@ class EEHGMaster(Device): else: self.nrg_s2_range = 40.0 - if attrs[9].quality != tango.AttrQuality.ATTR_INVALID: -# print(attrs[9].value) -# print(self.lambda_s2.get_properties().max_value) + if attrs[10].quality != tango.AttrQuality.ATTR_INVALID: +# il n.10 e` per il seed 2, mentre in n.9 e` per il seed 1. att_pl = self.lambda_s2.get_properties() att_pl.min_value = str(attrs[9].value[0]) diff --git a/src/EEHGMaster.xmi b/src/EEHGMaster.xmi index 89cfe586574c7b10f37e50b5ac1d008b15dfb228..84341d6aeaca967f30541fdfe14ce1826d9f3b3d 100644 --- a/src/EEHGMaster.xmi +++ b/src/EEHGMaster.xmi @@ -134,7 +134,7 @@ <archiveEvent fire="false" libCheckCriteria="false"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <properties description="The harmonic of the first seed used in EEHG of in HGHG1 and HGHG1*" label="harmonic of the first seed" unit="" standardUnit="" displayUnit="" format="" maxValue="0" minValue="-3" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + <properties description="The harmonic of the first seed used in EEHG of in HGHG1 and HGHG1*" label="harmonic of the first seed" unit="" standardUnit="" displayUnit="" format="" maxValue="0" minValue="-1" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> <readExcludedStates>RUNNING</readExcludedStates> <readExcludedStates>MOVING</readExcludedStates> <writeExcludedStates>RUNNING</writeExcludedStates> @@ -196,14 +196,6 @@ <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <properties description="Give the priority to the solution that has larger bunching" label="prior_bunch" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> - <attributes name="pref_rx" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" allocReadMember="true" isDynamic="false"> - <dataType xsi:type="pogoDsl:BooleanType"/> - <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="This is selected to take the rigth peak of EEHG when possible" label="pref_rx" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> - </attributes> <attributes name="bunc_fel" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:DoubleType"/> <changeEvent fire="false" libCheckCriteria="false"/> @@ -652,6 +644,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="picco_pref" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" allocReadMember="true" isDynamic="false"> + <dataType xsi:type="pogoDsl:ShortType"/> + <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="This is selection of R56 peak of EEHG: 0 left, 1 rigth, 2 both." label="picco selection" unit="" standardUnit="" displayUnit="" format="" maxValue="2" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + </attributes> <attributes name="bunc_sol" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="32" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:LongType"/> <changeEvent fire="false" libCheckCriteria="false"/>