F
fogh
Guest
Hi All,
grey weather here for easter, so I made a SKILL toy. It will plot a
waveform to the xterm Tek window. I had always wondered what this xterm
"tek" mode was. I tried to plot families too, but that doesn t work. It
should work OK if you plot a real valued waveform (probably fails on AC
or PSS freq domain 's complex waves).
;; fun with xterm's tektronix 4014 emulator
;; for a phosphor alike color, "xterm -fg green -bg black"
;; run icfb from the xterm , load this file
;; open some simulation result, browse, put the a real wave expression
in the clipboard
;; enter in CIW:
;; TKplotwave( <paste wave expression> )
;;voila.
/*
#get info on terminal capabilities and control codes
man ascii
man console_codes
man reset
man termcap
man terminfo
man tic
man xterm
gv /usr/share/doc/x*doc*.?/xterm/ctlseqs.PS.gz
less $(locate tek.trm) #or use google/gnuplot source
wget http://www.tug.org/cgi-bin/dirarchive/tex-archive/dviware/dvgt.tgz
; tar xzvf dvgt.tgz; less dvgt/dvgt/src/tek4010*
mozilla http://www.gnu.org/software/plotutils/plotutils.html
mozilla http://www.update.uu.se/~fstx/1/tekscope/
wget http://vt100.net/tektronix/4014-um/4014-um.pdf
#read from page 92 , appendix G
######## try it out
#ECMA-48 Set Graphics Rendition
echo -en "\033[32m"
echo -en "\033[40m"
#SGR code ; inverse video
echo -e "\033[7m oediv esrever \033[0m"
#Digital Equipment Corp. private mode set
##enter tektronix
echo -en "\033[?38h"
###### what to do
#-send "enter tek mode ; clear & init " control codes
#-send graph commands from a dfII waveform
*/
;;;;;;;;;;;;;;;;;;;;;;;;;tek4010 definitions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ESC="\033"
TK='(nil)
TK->entertek="\033[?38h" ; esc [ ? 38 h
TK->reset="\033[?38l" ; esc [ ? 38 l
TK->page="\033\014" ;esc ff
TK->alpha="\037" ; ascii US , text mode
TK->graph="\035" ; ascii GS , graphic mode
TK->point="\034" ; ascii FS , point plot mode
TK->incplot="\036" ; ascii RS , incremental plot mode
TK->xmax=1024
TK->ymax=780
TK->xlast=TK->xmax-1
TK->ylast=TK->ymax-1
TK->vchar=25
TK->hchar=14
TK->vtic=TK->htic=11
TK->hx=TK->hy=0x20
TK->lx=0x40
TK->ly=0x60
;TK->lower5= 2**5 - 1
TK->lower5=0b11111
TK->upper5=TK->lower5<<5
TK->port=outfile("/dev/stdin")
TK->linetypes = "`abcdhijkl"
TK->last_vt_linetype = nil ;;this is a global. keeps state info: nil is
uninitialised, 0 to 9 is build-in line type
procedure(TKsnd(x)
;fprintf(TK->port "%s\n" x )
fprintf(TK->port "%s" x )
drain(TK->port)
)
procedure(TKascTostr(asc)
;;sending a beep
;;fprintf(outfile("/dev/stdout") "%s\n"
symbolToString(intToChar(charToInt(stringToSymbol("\007") ))))
symbolToString(intToChar(asc))
)
procedure( TKvector(x y)
;; (0 0) is lowerleft ; x is horizontal
TKsnd( strcat(
TKascTostr(TK->hy | (y & TK->upper5) >> 5)
TKascTostr(TK->ly | (y & TK->lower5))
TKascTostr(TK->hx | (x & TK->upper5) >> 5)
TKascTostr(TK->lx | (x & TK->lower5))
))
)
procedure( TKmove(x y)
let(()
TKsnd(TK->graph)
TKvector(x y)
))
/* linetypes for VT-type terminals in tektronix emulator mode
0 `=solid, 1 a=fine dots, 2 b=short dashes, 3 c=dash dot,
4 d=long dash dot, 5 h=bold solid, 6 i=bold fine dots, 7 j=bold short
dashes,
8 k=bold dash dot, 9 l=bold long dash dot */
procedure( TKlinetype(linetype)
linetype = mod(linetype 10)
TKsnd(strcat(ESC getchar(TK->linetypes linetype+1)))
TK->last_vt_linetype = linetype
)
procedure( TKput_text(x, y, str)
let( (lt)
lt=TK->last_vt_linetype
TKlinetype(0)
TKmove(x, y - TK->vtic)
TKsnd(strcat(TK->alpha str))
TKlinetype(lt)
))
procedure(TK_xterm_tekinit()
;;green foreground black background, ansi codes.
TKsnd(strcat(ESC "[32m")) TKsnd(strcat(ESC "[40m"))
TKsnd(TK->reset)
TKsnd(TK->entertek)
;sh("sleep 1")
;hiRegTimer(
TKsnd(TK->page)
TKmove(0 0) ;;this also sets graph mode
TKlinetype(5) ;;this also sets the "initialised" flag
);proc
;;;;;;;;;;;;;;;;;;;;;;;;;waveform definitions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure( TKplotwave(w)
let( (xmin xmax ymin ymax yspan xspan Tx Ty)
unless(TK->last_vt_linetype TK_xterm_tekinit() ) ;initialise if necessary
xmin=drGetElem(x=drGetWaveformXVec(w) 0)
xmax=drGetElem(x drVectorLength(x)-1 )
ymin=ymin(w) ymax=ymax(w)
xspan=1.0/(xmax-xmin) yspan=1.0/(ymax-ymin)
;;get first point
x=xmin
y=drGetElem(drGetWaveformYVec(w) 0)
Tx=round( TK->xlast*(x-xmin)*xspan )
Ty=round( TK->ylast*(y-ymin)*yspan )
;;TxPrev=Tx TyPrev=Ty
TKmove(Tx Ty)
;;loop through points
foreach( mapcar lXY artWaveformToList(w)
x=car(lXY) y=cadr(lXY)
Tx=round( TK->xlast*(x-xmin)*xspan )
Ty=round( TK->ylast*(y-ymin)*yspan )
;TKmove(Tx Ty)
TKvector(Tx Ty)
;TxPrev=Tx TyPrev=Ty
);foreach point
t
);let
);proc
procedure(TKplot(x)
cond(
(numberp(x) TKplotwave(artListToWaveform(list( list(x x) list(x x)))
) ) ;;
(drIsWaveform(x) TKplotwave(x) ) ;;
(famIsFamily(x) famMap('TKplot x ) ) ;;
);cond
);proc
/************************************************
procedure(TKX() ;;run examples
let(
nil
; (w l xl xv xrange urange F )
defmacro( l () load("TektronixPlot.il") )
; l
awvSetWaveformToolName( "awd" )
w=artListToWaveform('((0 0) (1 1) (2 4) (3 9)))
xl=linRg(-1 15 0.01)
xv=drCreateVec( 'double xl )
w=expr(x exp(x/3)*sin(5*x) xl)
;TKplotwave(w)
procedure(myfunc(u x) exp(x/(3*u))*sin(x*5*u) ) ;myfunc
xrange=linRg(-1 12 0.05)
urange=logRg(0.9 1.5 10)
VRL=;gives nil as second name
list(
list("U" urange )
list("X" xrange )
)
F=famFuncApply('myfunc VRL)
plot( F )
TKplot( F )
);let
);proc examples
************************************************/
grey weather here for easter, so I made a SKILL toy. It will plot a
waveform to the xterm Tek window. I had always wondered what this xterm
"tek" mode was. I tried to plot families too, but that doesn t work. It
should work OK if you plot a real valued waveform (probably fails on AC
or PSS freq domain 's complex waves).
;; fun with xterm's tektronix 4014 emulator
;; for a phosphor alike color, "xterm -fg green -bg black"
;; run icfb from the xterm , load this file
;; open some simulation result, browse, put the a real wave expression
in the clipboard
;; enter in CIW:
;; TKplotwave( <paste wave expression> )
;;voila.
/*
#get info on terminal capabilities and control codes
man ascii
man console_codes
man reset
man termcap
man terminfo
man tic
man xterm
gv /usr/share/doc/x*doc*.?/xterm/ctlseqs.PS.gz
less $(locate tek.trm) #or use google/gnuplot source
wget http://www.tug.org/cgi-bin/dirarchive/tex-archive/dviware/dvgt.tgz
; tar xzvf dvgt.tgz; less dvgt/dvgt/src/tek4010*
mozilla http://www.gnu.org/software/plotutils/plotutils.html
mozilla http://www.update.uu.se/~fstx/1/tekscope/
wget http://vt100.net/tektronix/4014-um/4014-um.pdf
#read from page 92 , appendix G
######## try it out
#ECMA-48 Set Graphics Rendition
echo -en "\033[32m"
echo -en "\033[40m"
#SGR code ; inverse video
echo -e "\033[7m oediv esrever \033[0m"
#Digital Equipment Corp. private mode set
##enter tektronix
echo -en "\033[?38h"
###### what to do
#-send "enter tek mode ; clear & init " control codes
#-send graph commands from a dfII waveform
*/
;;;;;;;;;;;;;;;;;;;;;;;;;tek4010 definitions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ESC="\033"
TK='(nil)
TK->entertek="\033[?38h" ; esc [ ? 38 h
TK->reset="\033[?38l" ; esc [ ? 38 l
TK->page="\033\014" ;esc ff
TK->alpha="\037" ; ascii US , text mode
TK->graph="\035" ; ascii GS , graphic mode
TK->point="\034" ; ascii FS , point plot mode
TK->incplot="\036" ; ascii RS , incremental plot mode
TK->xmax=1024
TK->ymax=780
TK->xlast=TK->xmax-1
TK->ylast=TK->ymax-1
TK->vchar=25
TK->hchar=14
TK->vtic=TK->htic=11
TK->hx=TK->hy=0x20
TK->lx=0x40
TK->ly=0x60
;TK->lower5= 2**5 - 1
TK->lower5=0b11111
TK->upper5=TK->lower5<<5
TK->port=outfile("/dev/stdin")
TK->linetypes = "`abcdhijkl"
TK->last_vt_linetype = nil ;;this is a global. keeps state info: nil is
uninitialised, 0 to 9 is build-in line type
procedure(TKsnd(x)
;fprintf(TK->port "%s\n" x )
fprintf(TK->port "%s" x )
drain(TK->port)
)
procedure(TKascTostr(asc)
;;sending a beep
;;fprintf(outfile("/dev/stdout") "%s\n"
symbolToString(intToChar(charToInt(stringToSymbol("\007") ))))
symbolToString(intToChar(asc))
)
procedure( TKvector(x y)
;; (0 0) is lowerleft ; x is horizontal
TKsnd( strcat(
TKascTostr(TK->hy | (y & TK->upper5) >> 5)
TKascTostr(TK->ly | (y & TK->lower5))
TKascTostr(TK->hx | (x & TK->upper5) >> 5)
TKascTostr(TK->lx | (x & TK->lower5))
))
)
procedure( TKmove(x y)
let(()
TKsnd(TK->graph)
TKvector(x y)
))
/* linetypes for VT-type terminals in tektronix emulator mode
0 `=solid, 1 a=fine dots, 2 b=short dashes, 3 c=dash dot,
4 d=long dash dot, 5 h=bold solid, 6 i=bold fine dots, 7 j=bold short
dashes,
8 k=bold dash dot, 9 l=bold long dash dot */
procedure( TKlinetype(linetype)
linetype = mod(linetype 10)
TKsnd(strcat(ESC getchar(TK->linetypes linetype+1)))
TK->last_vt_linetype = linetype
)
procedure( TKput_text(x, y, str)
let( (lt)
lt=TK->last_vt_linetype
TKlinetype(0)
TKmove(x, y - TK->vtic)
TKsnd(strcat(TK->alpha str))
TKlinetype(lt)
))
procedure(TK_xterm_tekinit()
;;green foreground black background, ansi codes.
TKsnd(strcat(ESC "[32m")) TKsnd(strcat(ESC "[40m"))
TKsnd(TK->reset)
TKsnd(TK->entertek)
;sh("sleep 1")
;hiRegTimer(
TKsnd(TK->page)
TKmove(0 0) ;;this also sets graph mode
TKlinetype(5) ;;this also sets the "initialised" flag
);proc
;;;;;;;;;;;;;;;;;;;;;;;;;waveform definitions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
procedure( TKplotwave(w)
let( (xmin xmax ymin ymax yspan xspan Tx Ty)
unless(TK->last_vt_linetype TK_xterm_tekinit() ) ;initialise if necessary
xmin=drGetElem(x=drGetWaveformXVec(w) 0)
xmax=drGetElem(x drVectorLength(x)-1 )
ymin=ymin(w) ymax=ymax(w)
xspan=1.0/(xmax-xmin) yspan=1.0/(ymax-ymin)
;;get first point
x=xmin
y=drGetElem(drGetWaveformYVec(w) 0)
Tx=round( TK->xlast*(x-xmin)*xspan )
Ty=round( TK->ylast*(y-ymin)*yspan )
;;TxPrev=Tx TyPrev=Ty
TKmove(Tx Ty)
;;loop through points
foreach( mapcar lXY artWaveformToList(w)
x=car(lXY) y=cadr(lXY)
Tx=round( TK->xlast*(x-xmin)*xspan )
Ty=round( TK->ylast*(y-ymin)*yspan )
;TKmove(Tx Ty)
TKvector(Tx Ty)
;TxPrev=Tx TyPrev=Ty
);foreach point
t
);let
);proc
procedure(TKplot(x)
cond(
(numberp(x) TKplotwave(artListToWaveform(list( list(x x) list(x x)))
) ) ;;
(drIsWaveform(x) TKplotwave(x) ) ;;
(famIsFamily(x) famMap('TKplot x ) ) ;;
);cond
);proc
/************************************************
procedure(TKX() ;;run examples
let(
nil
; (w l xl xv xrange urange F )
defmacro( l () load("TektronixPlot.il") )
; l
awvSetWaveformToolName( "awd" )
w=artListToWaveform('((0 0) (1 1) (2 4) (3 9)))
xl=linRg(-1 15 0.01)
xv=drCreateVec( 'double xl )
w=expr(x exp(x/3)*sin(5*x) xl)
;TKplotwave(w)
procedure(myfunc(u x) exp(x/(3*u))*sin(x*5*u) ) ;myfunc
xrange=linRg(-1 12 0.05)
urange=logRg(0.9 1.5 10)
VRL=;gives nil as second name
list(
list("U" urange )
list("X" xrange )
)
F=famFuncApply('myfunc VRL)
plot( F )
TKplot( F )
);let
);proc examples
************************************************/