Files
sics/tecs/tecs_client.f
2001-08-16 10:17:09 +00:00

228 lines
5.7 KiB
Fortran

program tecs_client
real temp
character device*32, init*80, line*80, cmd*16, par*80, response*1024
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, show_log
call sys_getenv('TECS_INIT', init)
call sys_get_cmdpar(line, l)
if (l .ne. 0) then
oneCommand=.true.
else
oneCommand=.false.
endif
if (oneCommand .and. line(1:1) .eq. '#') then
call tecs_open(0, line, iret)
oneCommand=.false.
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 *,'<empty line> show temperature and device'
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 *,'plot <var> chart for temperature and <var>'
1 ,' var = P (default), He, Aux'
print *,'log <n> show last n lines of logfile'
print *,'kill close TecsServer and exit'
print *,'exit,quit exit, but do not close TecsServer'
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 (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'
if (cmd(1:1) .eq. '#') then
call tecs_close
call tecs_open(0, cmd, iret)
if (iret .lt. 0) goto 91
prompt='tecs/'//cmd(2:)
promptlen=1
do i=1,len(prompt)-2
if (prompt(i:i) .ne. ' ') promptlen=i
enddo
promptlen=promptlen+1
prompt(promptlen:promptlen)='>'
promptlen=promptlen+1
else if (cmd .eq. 'kill') then
iret=tecs_quit_server()
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('Tm Ts Tr P', 1)
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 *,'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 *
print *,'Read only parameters:'
print *
print *,'Tm main temperature'
print *,'Ts sample temperature'
print *,'setH set-point on regulation'
print *,'tLimit temperature limit'
print *,'htr heater current percentage'
print *,'resist heater resistance'
print *,'logfile name of the logfile'
print *,'remoteMode 1: local, 2: remote '
1 ,'(switch on with device command)'
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)'
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 tecs_plot('Tm Ts Tr '//par, 1)
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