Files
sics/tecs/tecs_client.f
2002-01-24 14:55:05 +00:00

269 lines
6.9 KiB
Fortran

program tecs_client
real temp
character device*32, init*80, line*80, cmd*16, par*80, response*1024
character inst*64, host*64, user*1, pcod*1
integer i,j,k,iret,l
character cmdpar*128
character prompt*32/'tecs>'/
integer promptlen/6/
logical oneCommand
character logarg*4/'25'/
character defcmd*8/'status'/
! functions
integer tecs_get_par, tecs_quit_server, tecs_set_par, tecs_watch_log
integer tecs_get, tecs_rights, show_log, instr_host
call sys_load_env('cho')
call sys_getenv('CHOOSER_GDEV', line)
if (line .ne. ' ') then
call sys_setenv('PGPLOT_DEV', '/'//line)
endif
call sys_getenv('TECS_INIT', init)
call sys_get_cmdpar(line, l)
if (l .ne. 0) then
if (line(1:l) .eq. 'off' .or. line(1:l) .eq. 'OFF') then
call tecs_open(0, ' ', iret)
if (iret .lt. 0) goto 91
iret=tecs_quit_server(0)
if (iret .lt. 0) goto 91
goto 99
endif
oneCommand=.true.
i=instr_host(line, inst, host, user, pcod)
else
oneCommand=.false.
i=0
endif
if (i .ne. 0) then
call tecs_open(0, '#'//host, iret)
oneCommand=.false.
prompt='tecs/'//inst(1:i)//'> '
promptlen=i+7
else if (init .eq. ' ') then
call tecs_open(0, line, iret)
else
call tecs_open(1, init, iret)
endif
if (iret .lt. 0) goto 91
if (oneCommand) goto 11
print *
print *,'Tecs Client'
print *,'-----------'
print *
print *,'set <temp> set temperature'
print *,'send <command> direct command to LSC340'
print *,'device <device> set cryo device'
print *,'<parameter> show parameter'
print *,'<parameter> <value> set parameter'
print *
print *,'<empty line> show summary'
print *,'plot <var> chart for temperature and <var>'
1 ,' var = P (default), He, Aux'
print *,'log <n> show last n lines of logfile'
print *,'remote set to remote mode'
print *,'reset reset alarms'
print *,'kill shut down TecsServer'
print *,'restart restart TecsServer'
print *,'exit,quit exit tecs client'
print *,'help show list of parameters and cryo devices'
print *
l=0
1 if (oneCommand) goto 99
call sys_rd_line(line, l, prompt(1:promptlen))
if (l .lt. 0) goto 99
11 l=l+1
line(l:l)=' '
cmd=' '
k=0
do j=1,l
if (k .gt. 0 .and. line(j:j) .eq. '=') line(j:j)=' '
if (line(j:j) .gt. ' ') then
k=k+1
cmd(k:k)=line(j:j)
if (cmd(k:k) .ge. 'A' .and. cmd(k:k) .le. 'Z') then ! set to lowercase
cmd(k:k)=char(ichar(cmd(k:k))+32)
endif
elseif (k .gt. 0) then ! end of command
par=' '
do i=j,l
if (line(i:i) .gt. ' ') then
par=line(i:l)
goto 3 ! command with parameter
endif
enddo
goto 2 ! parameterless command
endif
enddo
if (k .ne. 0) then
print *,'command too long'
goto 1
endif
! empty command
12 cmd=defcmd
2 continue ! parameterless command
defcmd='status'
i=instr_host(line, inst, host, user, pcod)
if (i .ne. 0) then
call tecs_close
call tecs_open(0, '#'//host, iret)
if (iret .lt. 0) goto 91
prompt='tecs/'//inst(1:i)//'> '
promptlen=i+7
else if (cmd .eq. 'kill') then
iret=tecs_quit_server(1)
if (iret .lt. 0) goto 19
if (iret .gt. 0) then
print *,'tecs server is not running'
endif
else if (cmd .eq. 'restart') then
iret=tecs_quit_server(0)
if (iret .lt. 0) goto 19
if (iret .gt. 0) then
print *,'tecs server is not running'
endif
else if (cmd .eq. 'remote') then
iret=tecs_set_par('remoteMode', '2', 2)
if (iret .lt. 0) goto 19
else if (cmd .eq. 'reset') then
iret=tecs_set_par('relay', '0', 2)
if (iret .lt. 0) goto 19
elseif (cmd .eq. 'rwacs') then
iret=tecs_rights(1)
if (iret .lt. 0) goto 19
elseif (cmd .eq. 'exit' .or. cmd .eq. 'quit') then
goto 99
elseif (cmd .eq. 'status') then
iret=tecs_get_par('status', response, 1)
if (iret .lt. 0) goto 19
elseif (cmd .eq. 'on' .or. cmd .eq. 'off') then
l=0
goto 11
elseif (cmd .eq. 'plot') then
call tecs_plot(' ')
elseif (cmd .eq. 'help') then
print *
print *,'Writeable parameters:'
print *
print *,'set temperature set-point'
print *,'device temperature device'
print *,'controlMode control on: 0: heat exchanger, '
1 ,'1: sample, 2: second loop'
print *,'maxPower heater max. power'
print *,'ramp ramp in K/min. (0: no ramp)'
print *,'prop PID gain'
print *,'int PID integration time: 1000/int sec'
print *,'deriv PID derivation term'
print *,'maxShift maximum (set-tempH) for controlMode=2'
print *,'int2 integration time (sec) for controlMode=2'
! print *,'remoteMode 1: local, 2: remote'
print *
print *,'Read only parameters:'
print *
print *,'Tm main temperature'
print *,'Ts sample temperature'
print *,'Tr set-point on regulation'
print *,'tLimit temperature limit'
print *,'helium helium level'
print *,'htr heater current percentage'
print *,'resist heater resistance'
print *,'logfile name of the logfile'
print *
print *,'Ta,Tb,Tc,Td values of channels A,B,C,D'
print *
print *,'Temperature devices:'
print *
print *,'ill1, ill2, ill3 (cryofurnace), ill4 (focus-cryo), '
1 ,'ill5 (maxi)'
print *,'cti1, cti2, cti3, cti4, cti5 (maxi), cti6 (focus), apd'
print *,'ccr4k (4K closed cycle), hef4c (TriCS 4circle cryo)'
print *,'sup4t (supra.magnet 4T), ft (tantalum furnace)'
print *,'rdr11, rdr12 (LTF dilution 1 & 2, 20kOhm)'
print *
elseif (cmd .eq. 'log') then
if (line(1:l) .eq. ' ') then
print '(x,a)'
1 ,char(27)//'[A'//char(13)//char(27)//'[K'//char(27)//'[2A'
endif
if (show_log(logarg) .le. 0) then
logarg='25'
print *,'-------- end of logfile --------'
goto 12
endif
defcmd='log'
logarg=' '
elseif (cmd .eq. 'watch') then
iret=tecs_watch_log('M')
if (iret .lt. 0) goto 19
else
iret=tecs_get_par(cmd, response, 2)
if (iret .lt. 0) goto 19
endif
goto 1
3 continue ! command with parameter
if (cmd .eq. 'log') then
if (show_log(par) .gt. 0) then
defcmd='log'
endif
logarg=' '
elseif (cmd .eq. 'plot') then
call str_lowcase(par, par)
call str_upcase(par(1:1), par(1:1))
call tecs_plot(par)
elseif (cmd .eq. 'watch') then
iret=tecs_watch_log(par)
if (iret .lt. 0) goto 19
else
iret=tecs_set_par(cmd, par, 2)
if (iret .lt. 0) goto 19
endif
goto 1
19 if (iret .eq. -2) then
call tecs_write_msg(6)
else
call tecs_write_error(6)
endif
goto 1
91 if (iret .lt. 0) then
call tecs_write_error(6)
endif
99 end
integer function show_log(lines)
character*(*) lines
integer i,l
character str*8192
! functions
integer tecs_get_par, tecs_set_par
if (lines .ne. ' ') then
l=tecs_set_par('logstart', lines, 0)
print *,'line: ',lines
print *
endif
show_log=tecs_get_par('logline', str, 1)
end