diff --git a/site_ansto/action.c b/site_ansto/action.c index 09035966..e3e73e8d 100644 --- a/site_ansto/action.c +++ b/site_ansto/action.c @@ -20,6 +20,7 @@ #include static char *SV_FastShutter = "FastShutter"; +static char *SV_BATPOS = "::beam::attenuator::_fb_BeamAttenuator"; static void setTextSICSVar(char *VarName, char *value) { int privilege = 1; @@ -38,7 +39,7 @@ static void setTextSICSVar(char *VarName, char *value) { void AO_istatus(int input, char *identifier) { int testVal; - if (strcasecmp(identifier, "TI1") == 0) { + if (strcasecmp(identifier, "QKK:TI1") == 0) { testVal = 48 & input; if (testVal == 32) { // Fast shutter open setTextSICSVar(SV_FastShutter, "OPEN"); @@ -49,6 +50,19 @@ void AO_istatus(int input, char *identifier) { } else { // 0 ie both limits activated setTextSICSVar(SV_FastShutter, "FAULT"); } - } else if (strcasecmp(identifier, "TS") == 0) { + } else if (strcasecmp(identifier, "PLP:BAT:POS") == 0) { + // Handle platypus:BAT POS + switch (input) { + case -1: + setTextSICSVar(SV_BATPOS, "OUT"); + break; + case 0: + setTextSICSVar(SV_BATPOS, "IN"); + break; + case 1: + setTextSICSVar(SV_BATPOS, "OSCILLATING"); + default: + break; + } } } diff --git a/site_ansto/instrument/config/environment/temperature/lakeshore340_common.tcl b/site_ansto/instrument/config/environment/temperature/lakeshore340_common.tcl index eebaec4f..999a155c 100644 --- a/site_ansto/instrument/config/environment/temperature/lakeshore340_common.tcl +++ b/site_ansto/instrument/config/environment/temperature/lakeshore340_common.tcl @@ -1,4 +1,15 @@ -namespace eval ::environment::temperature { } +namespace eval ::environment::temperature { +# Default temperature controller parameters + array set tc_dfltPar { + tolerance 1 + settle 30 + range 2 + upperlimit 500 + lowerlimit 4 + } + set tc_dfltURL ca5-[instname] + array set moxaPortMap {1 4001 2 4002 3 4003 4 4004} +} # @brief Make a simulated temperature controller object. # @@ -19,7 +30,7 @@ proc ::environment::temperature::mkls340sim {temp_sobj} { # @param temp_sobj, name for temperature controller object # @param IP, (optional) IP address for temperature controller. # @param port, (optional) port number for temperature controller. -proc ::environment::temperature::mkls340 {temp_sobj {IP 137.157.201.50} {port 4001}} { +proc ::environment::temperature::mkls340 {temp_sobj IP port} { Makeasyncqueue sertemp1 LS340 $IP $port sertemp1 timeout 2000 EvFactory new $temp_sobj ls340 sertemp1 1 D ABCD diff --git a/site_ansto/instrument/hrpd/config/environment/temperature/lakeshore340.tcl b/site_ansto/instrument/hrpd/config/environment/temperature/lakeshore340.tcl index 209d8ad8..2f4aa1d2 100644 --- a/site_ansto/instrument/hrpd/config/environment/temperature/lakeshore340.tcl +++ b/site_ansto/instrument/hrpd/config/environment/temperature/lakeshore340.tcl @@ -5,20 +5,48 @@ source $cfPath(environment)/temperature/lakeshore340_common.tcl # This must be called when the instrument configuration is loaded and before\n # the buildHDB function is called. Currently there is no way to add and remove\n # environment controllers and their hdb paths at runtime. -proc ::environment::temperature::add_ls340 {} { - set sim_mode [SplitReply [environment_simulation]] - if {$sim_mode == "true"} { - ::environment::temperature::mkls340sim tc1 - } else { - ::environment::temperature::mkls340 tc1 - tc1 tolerance 1 - tc1 Settle 30 - tc1 range 2 - tc1 UpperLimit 500 - tc1 LowerLimit 4 - } +# +# @param tcn temperature controller name, the hdb name will be tcn_cntrl +# @param mport, the moxa RS232 port number, ie 1,2,3,4 +# +# Optional parameters, see lakeshore340_common.tcl for defaults in tc_dfltPar +# @param tolerance, temperature controller tolerance +# @param settle, settling time in seconds +# @param range, lakeshore range +# @param upperlimit, upper temperature limit Kelvin +# @param lowerlimit, lower temperature limit Kelvin +proc ::environment::temperature::add_ls340 {tcn mport args} { + variable tc_dfltPar + variable tc_dfltURL + variable moxaPortMap + if [catch { + if {$tcn == "" || $mport == ""} { + error "ERROR: You must provide a temperature controller name and moxa port number" + } - sicslist setatt tc1 environment_name tempone - sicslist setatt tc1 long_name control_sensor_reading - ::environment::mkenvinfo tc1 {heateron {priv user} range {priv manager} } + array set tc_param [array get tc_dfltPar] + + if {$args != ""} { + array set tc_param $args + foreach {nm v} $args { + set tc_param($nm) $v + } + } + set sim_mode [SplitReply [environment_simulation]] + if {$sim_mode == "true"} { + ::environment::temperature::mkls340sim $tcn + } else { + ::environment::temperature::mkls340 $tcn $tc_dfltURL $moxaPortMap($mport) + foreach nm [array names tc_param] { + $tcn $nm $tc_param($nm) + } + } + + sicslist setatt $tcn environment_name ${tcn}_cntrl + sicslist setatt $tcn long_name control_sensor_reading + ::environment::mkenvinfo $tcn {heateron {priv user} range {priv manager} } + } message ] { + if {$::errorCode=="NONE"} {return $message} + return -code error $message + } } diff --git a/site_ansto/instrument/hrpd/echidna_configuration.tcl b/site_ansto/instrument/hrpd/echidna_configuration.tcl index 95e3c173..3e8cf4b4 100644 --- a/site_ansto/instrument/hrpd/echidna_configuration.tcl +++ b/site_ansto/instrument/hrpd/echidna_configuration.tcl @@ -1,5 +1,5 @@ -# $Revision: 1.32 $ -# $Date: 2008-08-07 03:17:28 $ +# $Revision: 1.33 $ +# $Date: 2008-08-19 05:11:55 $ # Author: Ferdi Franceschini (ffr@ansto.gov.au) # Last revision by: $Author: ffr $ @@ -40,7 +40,8 @@ source gumxml.tcl # AN ERROR IF THERE IS NO ../log/status.tcl FILE. restore catch { -# ::environment::temperature::add_ls340 +# ::environment::temperature::add_ls340 tc1 1 +# ::environment::temperature::add_ls340 tc2 2 server_init if [file exists ../extraconfig.tcl] { diff --git a/site_ansto/instrument/reflectometer/config/commands/commands.tcl b/site_ansto/instrument/reflectometer/config/commands/commands.tcl index abdfd2de..8d214c5c 100644 --- a/site_ansto/instrument/reflectometer/config/commands/commands.tcl +++ b/site_ansto/instrument/reflectometer/config/commands/commands.tcl @@ -5,6 +5,26 @@ namespace eval motor { variable is_homing_list "" } +namespace eval beam { + command attenuator {text=in,out,osc pos} { + switch $pos { + "in" { + bat send POS=0 + } + "out" { + bat send POS=-1 + } + "osc" { + bat send POS=1 + } + default { + return -code error "ERROR: valid values are in, out, osc" + } + } + } +} +::beam::attenuator -addfb text BeamAttenuator + namespace eval exp_mode { variable valid_modes variable guide_for_mode ;#guide element for a specific mode diff --git a/site_ansto/instrument/reflectometer/config/motors/motor_configuration.tcl b/site_ansto/instrument/reflectometer/config/motors/motor_configuration.tcl index ae7c763e..b9bd8dce 100644 --- a/site_ansto/instrument/reflectometer/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/reflectometer/config/motors/motor_configuration.tcl @@ -275,6 +275,7 @@ m1ro precision 0.001 # Beam Attenuator (16mm/turn, 200mm travel) Motor bat $motor_driver_type [params \ asyncqueue mc1\ + action MC1\ axis D\ units mm\ hardlowerlim 0\ diff --git a/site_ansto/instrument/sans/config/motors/motor_configuration.tcl b/site_ansto/instrument/sans/config/motors/motor_configuration.tcl index bad0d479..b98b0825 100644 --- a/site_ansto/instrument/sans/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/sans/config/motors/motor_configuration.tcl @@ -1,5 +1,5 @@ -# $Revision: 1.23 $ -# $Date: 2008-08-13 04:16:30 $ +# $Revision: 1.24 $ +# $Date: 2008-08-19 05:11:55 $ # Author: Ferdi Franceschini (ffr@ansto.gov.au) # Last revision by: $Author: ffr $ @@ -371,7 +371,7 @@ Motor det $motor_driver_type [params \ asyncqueue mc1\ host mc1-quokka\ port pmc1-quokka\ - aoid MC1\ + action MC1\ axis G\ units mm\ hardlowerlim 350\ diff --git a/site_ansto/instrument/server_config.tcl b/site_ansto/instrument/server_config.tcl index c34c06bf..63c351a6 100644 --- a/site_ansto/instrument/server_config.tcl +++ b/site_ansto/instrument/server_config.tcl @@ -1,7 +1,7 @@ # SICS common configuration -# $Revision: 1.40 $ -# $Date: 2008-08-18 03:01:29 $ +# $Revision: 1.41 $ +# $Date: 2008-08-19 05:11:55 $ # Author: Ferdi Franceschini (ffr@ansto.gov.au) # Last revision by $Author: ffr $ @@ -138,7 +138,7 @@ sics_release [lindex $tmpstr [expr [llength $tmpstr] - 1]] sics_release lock ::utility::mkVar sics_revision_num Text internal -set tmpstr [string map {"$" ""} {$Revision: 1.40 $}] +set tmpstr [string map {"$" ""} {$Revision: 1.41 $}] sics_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]] sics_revision_num lock @@ -163,6 +163,9 @@ exe syspath ../batch proc server_set_sobj_attributes {} { if [ catch { + foreach m [lrange [sicslist type Motor] 1 end] { + $m movecount 500 + } motor_set_sobj_attributes ::utility::set_motor_attributes ::utility::set_histomem_attributes diff --git a/site_ansto/motor_dmc2280.c b/site_ansto/motor_dmc2280.c index 59e9b1a2..197e4abb 100644 --- a/site_ansto/motor_dmc2280.c +++ b/site_ansto/motor_dmc2280.c @@ -1249,9 +1249,10 @@ static int rspStatus(pDMC2280Driv self, const char* text) { &iStopCode, &iTIzero, &iTIone, &iXQ0); if (iRet != 8) return 0; - /* TODO some kind of callback for builtin status would be better */ + /* TODO Put the following in specialised response handlers */ if (self->ao_id[0] != '\0') { - AO_istatus(iTIone, "TI1"); + AO_istatus(iTIone, "QKK:TI1"); + AO_istatus(iSteps, "PLP:BAT:POS"); } if (self->axisLabel >= 'A' && self->axisLabel <= 'D') iIOByte = iTIzero; @@ -1745,7 +1746,9 @@ static void DMCState_Idle(pDMC2280Driv self, pEvtEvent event) { pAsyncTxn pCmd = event->event.msg.cmd; if (self->subState == 1) { /* Status Response */ int iRet; - long lDelta; + long lDelta, lprecision; + float fprecision; + iRet = rspStatus(self, pCmd->inp_buf); if (iRet == 0) break; @@ -1756,11 +1759,16 @@ static void DMCState_Idle(pDMC2280Driv self, pEvtEvent event) { return; } /* if the motor moved, update any observers */ - if (self->abs_encoder) + MotorGetPar(self->pMot, "precision", &fprecision); + if (self->abs_encoder) { lDelta = fabs(self->currCounts - self->lastCounts); - else + lprecision = (long) (fprecision * self->cntsPerX + 0.5); + } else { lDelta = fabs(self->currSteps - self->lastSteps); - if (lDelta > 10) { + lprecision = (long) (fprecision * self->stepsPerX + 0.5); + } + + if (lDelta > lprecision) { set_lastMotion(self, self->currSteps, self->currCounts); report_motion(self); } @@ -3660,7 +3668,7 @@ MotorDriver *CreateDMC2280(SConnection *pCon, char *motor, char *params) { } pNew->ao_id[0] = '\0'; - if ((pPtr=getParam(pCon, interp, params, "aoid", _OPTIONAL)) != NULL) { + if ((pPtr=getParam(pCon, interp, params, "action", _OPTIONAL)) != NULL) { strncpy(pNew->ao_id, pPtr, sizeof(pNew->ao_id)); pNew->ao_id[sizeof(pNew->ao_id) - 1] = '\0'; }