diff --git a/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py b/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py index ea7f30b..5ea64a6 100644 --- a/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py +++ b/csaxs_bec/bec_ipython_client/plugins/omny/omny_sample_transfer_mixin.py @@ -954,7 +954,7 @@ class OMNYSampleTransferMixin: # }' - def _otransfer_check_sample_available_at_position(self, _osampleposition, _picked_it): + def _otransfer_check_sample_available_at_position(self, _osampleposition:int, _picked_it:bool) -> bool: #called with _picked_it == 0 prior transfer. This checks that the gripper is empty and that there #is a sample to get from that position #called with _picked_it == 1 after the gripper action. then the storage is modified accordingly to the action @@ -973,18 +973,18 @@ class OMNYSampleTransferMixin: if installedshuttle == "A" or installedshuttle == "B" or installedshuttle == "C": #is there a sample available? if dev.omny_samples.is_sample_slot_used(installedshuttle,_osampleposition): - if(_picked_it==1): + if _picked_it==1: samplename = dev.omny_samples.get_sample_name(installedshuttle, _osampleposition) #remove sample from slot and put to gripper dev.omny_samples.unset_sample_slot(installedshuttle, _osampleposition) dev.omny_samples.set_sample_in_gripper(samplename) - return(1) + return True else: print("There is no sample availabe at that position.") - return(0) + return False else: print("There is no sample shuttle installed at the current parkz position.") - return(0) + return False # # _osampleposition 7 for FZPs # if (_osampleposition==7) { @@ -1059,7 +1059,7 @@ class OMNYSampleTransferMixin: # _osampleposition for fixed positions elif (_osampleposition>9 and _osampleposition<15) or (_osampleposition>31 and _osampleposition<35) or _osampleposition==100 or _osampleposition==101: if dev.omny_samples.is_sample_slot_used('O',_osampleposition): - if(_picked_it==1): + if _picked_it: samplename = dev.omny_samples.get_sample_name('O', _osampleposition) dev.omny_samples.unset_sample_slot('O', _osampleposition) dev.omny_samples.set_sample_in_gripper(samplename) @@ -1073,14 +1073,14 @@ class OMNYSampleTransferMixin: #if (_osampleposition == 0 || _osampleposition == 12 || _osampleposition == 13 || _osampleposition == 14 || \\ # _osampleposition == 32 || _osampleposition == 33 || _osampleposition == 34) # _otransfer_modify_sample("omny",110,1,samplename) - return(1) + return True else: - printf("There is nothing to get from this position.") - return(0) + print("There is nothing to get from this position.") + return False #sample stage elif _osampleposition==0: if dev.omny_samples.is_sample_in_samplestage(): - if(_picked_it==1): + if _picked_it: samplename = dev.omny_samples.get_sample_name_in_samplestage() dev.omny_samples.unset_sample_in_samplestage() dev.omny_samples.set_sample_in_gripper(samplename) @@ -1094,16 +1094,16 @@ class OMNYSampleTransferMixin: #if (_osampleposition == 0 || _osampleposition == 12 || _osampleposition == 13 || _osampleposition == 14 || \\ # _osampleposition == 32 || _osampleposition == 33 || _osampleposition == 34) # _otransfer_modify_sample("omny",110,1,samplename) - return(1) + return True else: - printf("There is no sample in the sample stage.") - return(0) + print("There is no sample in the sample stage.") + return False return(0) - def _otransfer_check_free_slot_available_at_position(self, _osampleposition, _put_it): + def _otransfer_check_free_slot_available_at_position(self, _osampleposition:int, _put_it:bool) -> bool: #called with _put_it == 0 prior transfer. This checks that the gripper has a sample and that there #is a free sample position available that position #called with _put_it == 1 after the gripper action. then the storage is modified accordingly to the action @@ -1112,15 +1112,19 @@ class OMNYSampleTransferMixin: if not dev.omny_samples.is_sample_in_gripper(): raise OMNYTransferError("There is no sample in the gripper.") - #sample pin - if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==1) - if ((_osampleposition>-1 && _osampleposition<7) || (_osampleposition>11 && _osampleposition<15) || (_osampleposition>31 && _osampleposition<35)) - { } - else - { - printf("There is a sample pin in the gripper, which is not compatible with position %d\n", _osampleposition) - exit - } + # this was from early omny when automatic changing of samples, fzps and osas was expected + # the idea was that it is distinguished wich kind of holder is currently in the gripper. turns out not to be needed. + # special transfer is always very manual with a lot of attention. + # + # #sample pin + # if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==1) + # if ((_osampleposition>-1 && _osampleposition<7) || (_osampleposition>11 && _osampleposition<15) || (_osampleposition>31 && _osampleposition<35)) + # { } + # else + # { + # printf("There is a sample pin in the gripper, which is not compatible with position %d\n", _osampleposition) + # exit + # } # #FZP holder # if (epics_get("XOMNY-SAMPLE_DB_omny:110.VAL")==2) # if (_osampleposition == 7 || _osampleposition == 10 || _osampleposition == 11 || _osampleposition == 100) @@ -1141,234 +1145,129 @@ class OMNYSampleTransferMixin: # } -# _osampleposition 1 to 6 are in shuttles -if ((_osampleposition>0 && _osampleposition<7)) { - local activeparkingposition - local installedshuttle - activeparkingposition = _oparkz_slot_check() - if(activeparkingposition==10) - exit - installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) - #is there a samle shuttle at this position? - if(installedshuttle == "A" || installedshuttle == "B" || installedshuttle == "C") - { - #is there free position available? - if (epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_%s:%d.VAL",installedshuttle,_osampleposition))==0) - { - if(_put_it==1) - { - samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:110.DESC")) - _otransfer_modify_sample(installedshuttle, _osampleposition, 1, samplename) - _otransfer_modify_sample("omny",110,0,"-") - } - return(1) - } - else - { - printf("There is no free sample slot availabe at that position.\n") - return(0) - } - } - else - { - printf("There is no sample shuttle installed at the current parkz position.\n") - return(0) - } -} + # _osampleposition 1 to 6 are in shuttles + if _osampleposition>0 and _osampleposition<7: + activeparkingposition = self._oparkz_slot_check() + if(activeparkingposition==10): + raise OMNYTransferError("Parking stage is not at an active parking position.") + installedshuttle = dev.omny_samples.get_shuttle_name_slot(activeparkingposition) + #is there a samle shuttle at this position? + if installedshuttle == "A" or installedshuttle == "B" or installedshuttle == "C": + #is there free position available? + if not dev.omny_samples.is_sample_slot_used(installedshuttle,_osampleposition): + if _put_it: + samplename = dev.omny_samples.get_sample_in_gripper() + dev.omny_samples.unset_sample_in_gripper() + dev.omny_samples.set_sample_slot(installedshuttle, _osampleposition, samplename) + return True + else: + print("There is no free sample slot availabe at that position.") + return False + else: + print("There is no sample shuttle installed at the current parkz position.") + return False -# _osampleposition 7 for FZPs -if (_osampleposition==7) { - local activeparkingposition - local installedshuttle - activeparkingposition = _oparkz_slot_check() - if(activeparkingposition==10) - exit - installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) - #is there a samle shuttle at this position? - if(installedshuttle == "FZP") - { - #is there a free FZP slot available? - if (epics_get("XOMNY-SAMPLE_DB_shuttle_FZP:0.VAL")==0) - { - if(_put_it==1) - { - samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:110.DESC")) - _otransfer_modify_sample(installedshuttle, 0, 1, samplename) - _otransfer_modify_sample("omny",110,0,"-") - } - return(1) - } - else - { - printf("There is no free FZP position available.\n") - return(0) - } - } - else - { - printf("There is no FZP shuttle installed at the current parkz position.\n") - return(0) - } -} + # OSA and FZP section, needs commissioning, was never + # _osampleposition 7 for FZPs + # if _osampleposition==7: + # activeparkingposition = _oparkz_slot_check() + # if(activeparkingposition==10) + # exit + # installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) + # #is there a samle shuttle at this position? + # if(installedshuttle == "FZP") + # { + # #is there a free FZP slot available? + # if (epics_get("XOMNY-SAMPLE_DB_shuttle_FZP:0.VAL")==0) + # { + # if(_put_it==1) + # { + # samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:110.DESC")) + # _otransfer_modify_sample(installedshuttle, 0, 1, samplename) + # _otransfer_modify_sample("omny",110,0,"-") + # } + # return(1) + # } + # else + # { + # printf("There is no free FZP position available.\n") + # return(0) + # } + # } + # else + # { + # printf("There is no FZP shuttle installed at the current parkz position.\n") + # return(0) + # } + # } -# _osampleposition 8, 9 for OSAs -if (_osampleposition==8||_osampleposition==9) { - local activeparkingposition - local installedshuttle - activeparkingposition = _oparkz_slot_check() - if(activeparkingposition==10) - exit - installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) - #is there a samle shuttle at this position? - if(installedshuttle == "OSA") - { - #is there a free OSA slot available? - if (epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_OSA:%d.VAL",(_osampleposition-8)))==0) - { - if(_put_it==1) - { - samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:110.DESC")) - _otransfer_modify_sample(installedshuttle, (_osampleposition-8), 1, samplename) - _otransfer_modify_sample("omny",110,0,"-") - } - return(1) - } - else - { - printf("There is no free OSA position available.\n") - return(0) - } - } - else - { - printf("There is no OSA shuttle installed at the current parkz position.\n") - return(0) - } -} + # # _osampleposition 8, 9 for OSAs + # if (_osampleposition==8||_osampleposition==9) { + # local activeparkingposition + # local installedshuttle + # activeparkingposition = _oparkz_slot_check() + # if(activeparkingposition==10) + # exit + # installedshuttle = epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", activeparkingposition)) + # #is there a samle shuttle at this position? + # if(installedshuttle == "OSA") + # { + # #is there a free OSA slot available? + # if (epics_get(sprintf("XOMNY-SAMPLE_DB_shuttle_OSA:%d.VAL",(_osampleposition-8)))==0) + # { + # if(_put_it==1) + # { + # samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:110.DESC")) + # _otransfer_modify_sample(installedshuttle, (_osampleposition-8), 1, samplename) + # _otransfer_modify_sample("omny",110,0,"-") + # } + # return(1) + # } + # else + # { + # printf("There is no free OSA position available.\n") + # return(0) + # } + # } + # else + # { + # printf("There is no OSA shuttle installed at the current parkz position.\n") + # return(0) + # } + # } -# _osampleposition for fixed positions -if ((_osampleposition==0)||(_osampleposition>9&&_osampleposition<15)||(_osampleposition>31&&_osampleposition<35)||_osampleposition == 100||_osampleposition == 101) { - #is there a free slot available? - if (epics_get(sprintf("XOMNY-SAMPLE_DB_omny:%d.VAL", _osampleposition))==0) - { - if(_put_it==1) - { - samplename = epics_get(sprintf("XOMNY-SAMPLE_DB_omny:110.DESC")) - _otransfer_modify_sample("omny",110,0,"-") - _otransfer_modify_sample("omny",_osampleposition,1,samplename) - } - return(1) - } - else - { - printf("There is no free space at this position.\n") - return(0) - } + # _osampleposition for fixed positions + if (_osampleposition>9 and _osampleposition<15) or (_osampleposition>31 and _osampleposition<35) or _osampleposition == 100 or _osampleposition == 101: + #is there a free slot available? + if not dev.omny_samples.is_sample_slot_used('O',_osampleposition): + if _put_it: + samplename = dev.omny_samples.get_sample_name_in_gripper() + dev.omny_samples.set_sample_slot('O', _osampleposition, samplename) + dev.omny_samples.unset_sample_in_gripper() + return True + else: + print("There is no free space at this position.\n") + return False + + #sample stage + elif _osampleposition==0: + if not dev.omny_samples.is_sample_in_samplestage(): + if _put_it: + samplename = dev.omny_samples.get_sample_name_in_gripper() + dev.omny_samples.set_sample_in_samplestage(samplename) + dev.omny_samples.unset_sample_in_gripper() + return True + else: + print("There is no sample in the sample stage.") + return False -} - -return(0) - -}' + return False -def _otransfer_check_parking(_ocontainer) '{ -#_ocontainer is A, B, C for the pin containers -#it can also be FZP, and OSA -for (k=1;k<7;k++) { - if( epics_get(sprintf("XOMNY-SAMPLE_DB_parking:%d.DESC", k)) == _ocontainer) { - printf("Shuttle %s is already installed at parking position %d.", _ocontainer, k) - exit - } -} -}' + def otransfer_help(self): + printf("omny.transfer.otransfer_park_slot(slot) drive the parking station to transfer from with the gripper\n") + printf("omny.transfer.otransfer_park_loadlock_slot(slot) drive the parking station to transfer from with the loadlock\n") + printf("omny.transfer.otransfer_get_sample(position) pick with the gripper from ") + printf("omny.transfer.otransfer_put_sample(position) put with the gripper to ") + printf("To modify the storage information see dev.omny_samples.help()") -def otransfer_modify_parking '{ - -if ($# != 2 ) { #change singe position status -printf("Wrong number of arguments. otransfer_modify_parking \n") -printf(" ranges from 1 to 6.\n") -printf(" can be 0=empty, 1=A, 2=B, 3=C, 4=OSA, 5=FZP\n") -exit -} - -local _shuttle - -#this is done because the argument cannot be the capital A -if ($2==1) - _shuttle = "A" -if ($2==2) - _shuttle = "B" -if ($2==3) - _shuttle = "C" -if ($2==4) - _shuttle = "OSA" -if ($2==5) - _shuttle = "FZP" - -if ((_shuttle=="A" || _shuttle=="B" || _shuttle=="C" || _shuttle=="FZP" || _shuttle=="OSA" || _shuttle==0 ) && ($1>0 && $1<7)) - _otransfer_modify_parking($1, _shuttle) -else - printf("Error. Position number not available.\n") - -otransfer_storage - - -}' - -def otransfer_modify_samples '{ - -if ($# != 3 ) { #change singe position status -printf("Wrong number of arguments. otransfer_modify_samples <0 for free, 1 for used>\n") -printf(" can be 0=OMNY, 1=A, 2=B, 3=C, 4=OSA, 5=FZP\n") -exit -} - -local _storage - -#this is done because the argument cannot be the capital A -if ($1==0) - _storage = "omny" -if ($1==1) - _storage = "A" -if ($1==2) - _storage = "B" -if ($1==3) - _storage = "C" -if ($1==4) - _storage = "OSA" -if ($1==5) - _storage = "FZP" - -local _oname - -#new position is used. so ask for sample name -if ($3 == 1) - _oname = getsval("What is the name of this sample?","noname") - -if ((_storage=="A" && $2>0 && $2<7) || (_storage=="B" && $2>0 && $2<7) || (_storage=="C" && $2>0 && $2<7) || (_storage=="FZP" && $2==0) || (_storage=="OSA" && $2>=0 && $2<2) || (_storage=="omny")) - _otransfer_modify_sample(_storage, $2, $3, _oname) -else - printf("Error. Position number not available.\n") - -otransfer_storage - -}' - - - - - -def otransfer_help '{ -text_bf -printf("otransfer is not in a -to be used by users- state\n") -text_non_bf -printf("otransfer_park_slot drive the parking station to transfer from with the gripper\n") -printf("otransfer_park_loadlock_slot drive the parking station to transfer from with the loadlock\n") -printf("otransfer_get_sample pick with the gripper from \n") -printf("otransfer_put_sample put with the gripper to \n") -printf("otransfer_storage print the status of the sample storage\n") -printf("otransfer_modify_parking modify the shuttle status in the parking station\n") -printf("otransfer_modify_samples modify the sample status\n") - -}' diff --git a/csaxs_bec/devices/omny/omny_sample_storage.py b/csaxs_bec/devices/omny/omny_sample_storage.py index 5414969..cb52048 100644 --- a/csaxs_bec/devices/omny/omny_sample_storage.py +++ b/csaxs_bec/devices/omny/omny_sample_storage.py @@ -22,6 +22,7 @@ class OMNYSampleStorage(Device): "set_sample_in_samplestage", "unset_sample_in_samplestage", "get_sample_name_in_samplestage", + "get_sample_name_in_gripper", "get_sample_name", "is_sample_in_samplestage", "set_shuttle_slot",