F
fogh
Guest
Hi All,
I made something so I can edit my analog artist outputs. tested only with
ic5033. You can use it if you bind CmAEOmainIPC() to some key in schematics. If
you improve on it, then repost the improved version to this NG or make it
otherwise publicly available (M'kay , Stephane ?). If for instance you know how
I can get rid of the global variable, or if you know how I can garanty that the
session before edit and the session after are the same, ... I am interested.
BTW, this is probably an old topic, but does any know a way to bind a key or a
mouse button in the analog artist form ?
/*
edit ADE outputs with a text editor
CmADEEditOutputs , short CmAEO
*/
/* _______________________________________________________ */
/* _______________________________________________________ */
procedure(CmAEOSignalsToExpressions(@optional (outputs nil) ) ;;this is rather
useless
let((vsignals isignals buildexpr)
unless(outputs && dtpr(outputs)
session=asiGetCurrentSession()
sevSession=session~>data~>sevSession
outputs=sevOutputs(sevSession)
)
buildexpr=lambda( (t_iorv o)
car(
linereadstring(
strcat(
;;; " { " ;;a progn doesn t help. the v func just complains.
t_iorv "(" sprintf(nil "%L" o->signal) " ?result \"tran-tran\" )"
" || "
t_iorv "(" sprintf(nil "%L" o->signal) " ?result \"ac-ac\" )"
" || "
t_iorv "(" sprintf(nil "%L" o->signal) " ?result \"dc-dc\" )"
" || "
t_iorv "(" sprintf(nil "%L" o->signal) " ?result \"dcOp-dc\" )"
;;;" } "
)
);linereadstring
);car
);lamb
;;convert voltage signals to expressions
vsignals=setof(o outputs o->type=='net)
foreach(o vsignals
o->name=o->signal
o->expression=funcall(buildexpr "v" o)
o->signal=nil
o->type=nil
);foreach
;;convert current signals to expressions
isignals=setof(o outputs o->type=='terminal)
foreach(o isignals
o->name=o->signal
o->expression=funcall(buildexpr "i" o)
o->signal=nil
o->type=nil
);foreach
);let
);proc
/* _______________________________________________________ */
alias gsub CmStrSubstitute
procedure( CmStrSubstitute(old new argstring @key (magic t) )
let( ( (prevmagic rexMagic() ) )
rexMagic(magic)
rexCompile(old)
unless(stringp(argstring) argstring=sprintf(nil "%L" argstring))
when( rexExecute(argstring)
argstring=rexReplace(argstring new -1 )
)
rexMagic(prevmagic)
argstring
));let&proc
procedure(CmAEOmktemp(sevSession)
sprintf(nil "%s/CmEditADEoutputs_%L"
getShellEnvVar("TMPDIR")||"/tmp"
concat(
"user=" getLogin()
",host=" mpsDefaultSessionHost()
",pid=" ipcGetPid()
",session=" sevSession~>number
",date=" gsub("[ ][ ]*" "_" getCurrentTime())
)
);sprintf
);proc
/* _______________________________________________________ */
procedure(CmAEODumpExpressions(outputs fp)
foreach(o setof( x outputs null(x->type) && dtpr(x->expression)) ;;yummy, a
dotted pair.
fprintf(fp "%s\n" o->name )
pprint(o->expression fp)
fprintf(fp "\n" )
);foreach
);proc
procedure(CmAEOReadExpressions(outputs fp)
let( ( (exprindex 0) outindex exprouts o expr name lexpr lname)
exprouts=setof( x outputs null(x->type) && dtpr(x->expression))
outindex=length(outputs)
while(
;lname=lineread(fp)
name=gets(name fp)
lexpr=lineread(fp)
if(name!=""&&dtpr(lexpr)
then
o=nth(exprindex exprouts)
unless(o ;;make an extra output object if we run out of them.
o=make_sevOutputStruct()
o->index=++outindex
o->march=o->save=o->selectionDetail=o->type=o->signal=nil
o->plot=t
outputs=nconc(outputs list(o))
);unless o existed
expr=car(lexpr)
;name=sprintf(nil "%L" car(lname))
name=substring(name 1 strlen(name)-1 )
o->expression=expr
o->name=name
exprindex++
else
info("ADE output edit: error in expression number %L" ++exprindex)
);fi
);while not eof
);let
);proc
/* _______________________________________________________ */
procedure(CmAEOmainIPC()
let( (session sevSession outputs fname fp edtr command dataHandler errHandler
postFunc slid)
session=asiGetCurrentSession()
sevSession=session~>data~>sevSession
outputs=sevOutputs(sevSession)
edtr=if(member(editor '("vi" "vim" "ed"))
strcat("xterm -e " editor)
editor
)
fname=gsub("\\\\" "" CmAEOmktemp(sevSession))
dataHandler=lambda( (cid data) info("ADE output editor %L : %s\n" cid data) )
errHandler=lambda( (cid data) fprintf(stderr "ADE output editor %L : %s\n" cid
data) /* ipcKillProcess(cid) */ )
postFunc=lambda( (cid exitStatus)
if(exitStatus
then
session=asiGetCurrentSession()
sevSession=session~>data~>sevSession
outputs=sevOutputs(sevSession)
slid=get(CmAEO_global concat("sevSession" sevSession->number) )
fname=slid->fname
fp=infile(fname)
CmAEOReadExpressions(outputs fp)
close(fp) deleteFile(fname)
session->data->outputList=sevSession->outputs=outputs
sevUpdateOutListBox(sevSession)
else
info("ADE output editor error. Edit cancelled.") close(fp)
);fi
);lambda
command=strcat(edtr " " fname)
fp=outfile(fname) ||error("could not open %s for write.\n" fname)
CmAEODumpExpressions(outputs fp)
close(fp)
;;seems like a postFunc needs globals
CmAEO_global=list(nil)
putprop(CmAEO_global list(nil) concat("sevSession" sevSession->number) )
slid=get(CmAEO_global concat("sevSession" sevSession->number) )
putprop(slid fname 'fname)
/* */
ipcBeginProcess(command "" dataHandler errHandler postFunc)
);let
);proc
/* _______________________________________________________ */
I made something so I can edit my analog artist outputs. tested only with
ic5033. You can use it if you bind CmAEOmainIPC() to some key in schematics. If
you improve on it, then repost the improved version to this NG or make it
otherwise publicly available (M'kay , Stephane ?). If for instance you know how
I can get rid of the global variable, or if you know how I can garanty that the
session before edit and the session after are the same, ... I am interested.
BTW, this is probably an old topic, but does any know a way to bind a key or a
mouse button in the analog artist form ?
/*
edit ADE outputs with a text editor
CmADEEditOutputs , short CmAEO
*/
/* _______________________________________________________ */
/* _______________________________________________________ */
procedure(CmAEOSignalsToExpressions(@optional (outputs nil) ) ;;this is rather
useless
let((vsignals isignals buildexpr)
unless(outputs && dtpr(outputs)
session=asiGetCurrentSession()
sevSession=session~>data~>sevSession
outputs=sevOutputs(sevSession)
)
buildexpr=lambda( (t_iorv o)
car(
linereadstring(
strcat(
;;; " { " ;;a progn doesn t help. the v func just complains.
t_iorv "(" sprintf(nil "%L" o->signal) " ?result \"tran-tran\" )"
" || "
t_iorv "(" sprintf(nil "%L" o->signal) " ?result \"ac-ac\" )"
" || "
t_iorv "(" sprintf(nil "%L" o->signal) " ?result \"dc-dc\" )"
" || "
t_iorv "(" sprintf(nil "%L" o->signal) " ?result \"dcOp-dc\" )"
;;;" } "
)
);linereadstring
);car
);lamb
;;convert voltage signals to expressions
vsignals=setof(o outputs o->type=='net)
foreach(o vsignals
o->name=o->signal
o->expression=funcall(buildexpr "v" o)
o->signal=nil
o->type=nil
);foreach
;;convert current signals to expressions
isignals=setof(o outputs o->type=='terminal)
foreach(o isignals
o->name=o->signal
o->expression=funcall(buildexpr "i" o)
o->signal=nil
o->type=nil
);foreach
);let
);proc
/* _______________________________________________________ */
alias gsub CmStrSubstitute
procedure( CmStrSubstitute(old new argstring @key (magic t) )
let( ( (prevmagic rexMagic() ) )
rexMagic(magic)
rexCompile(old)
unless(stringp(argstring) argstring=sprintf(nil "%L" argstring))
when( rexExecute(argstring)
argstring=rexReplace(argstring new -1 )
)
rexMagic(prevmagic)
argstring
));let&proc
procedure(CmAEOmktemp(sevSession)
sprintf(nil "%s/CmEditADEoutputs_%L"
getShellEnvVar("TMPDIR")||"/tmp"
concat(
"user=" getLogin()
",host=" mpsDefaultSessionHost()
",pid=" ipcGetPid()
",session=" sevSession~>number
",date=" gsub("[ ][ ]*" "_" getCurrentTime())
)
);sprintf
);proc
/* _______________________________________________________ */
procedure(CmAEODumpExpressions(outputs fp)
foreach(o setof( x outputs null(x->type) && dtpr(x->expression)) ;;yummy, a
dotted pair.
fprintf(fp "%s\n" o->name )
pprint(o->expression fp)
fprintf(fp "\n" )
);foreach
);proc
procedure(CmAEOReadExpressions(outputs fp)
let( ( (exprindex 0) outindex exprouts o expr name lexpr lname)
exprouts=setof( x outputs null(x->type) && dtpr(x->expression))
outindex=length(outputs)
while(
;lname=lineread(fp)
name=gets(name fp)
lexpr=lineread(fp)
if(name!=""&&dtpr(lexpr)
then
o=nth(exprindex exprouts)
unless(o ;;make an extra output object if we run out of them.
o=make_sevOutputStruct()
o->index=++outindex
o->march=o->save=o->selectionDetail=o->type=o->signal=nil
o->plot=t
outputs=nconc(outputs list(o))
);unless o existed
expr=car(lexpr)
;name=sprintf(nil "%L" car(lname))
name=substring(name 1 strlen(name)-1 )
o->expression=expr
o->name=name
exprindex++
else
info("ADE output edit: error in expression number %L" ++exprindex)
);fi
);while not eof
);let
);proc
/* _______________________________________________________ */
procedure(CmAEOmainIPC()
let( (session sevSession outputs fname fp edtr command dataHandler errHandler
postFunc slid)
session=asiGetCurrentSession()
sevSession=session~>data~>sevSession
outputs=sevOutputs(sevSession)
edtr=if(member(editor '("vi" "vim" "ed"))
strcat("xterm -e " editor)
editor
)
fname=gsub("\\\\" "" CmAEOmktemp(sevSession))
dataHandler=lambda( (cid data) info("ADE output editor %L : %s\n" cid data) )
errHandler=lambda( (cid data) fprintf(stderr "ADE output editor %L : %s\n" cid
data) /* ipcKillProcess(cid) */ )
postFunc=lambda( (cid exitStatus)
if(exitStatus
then
session=asiGetCurrentSession()
sevSession=session~>data~>sevSession
outputs=sevOutputs(sevSession)
slid=get(CmAEO_global concat("sevSession" sevSession->number) )
fname=slid->fname
fp=infile(fname)
CmAEOReadExpressions(outputs fp)
close(fp) deleteFile(fname)
session->data->outputList=sevSession->outputs=outputs
sevUpdateOutListBox(sevSession)
else
info("ADE output editor error. Edit cancelled.") close(fp)
);fi
);lambda
command=strcat(edtr " " fname)
fp=outfile(fname) ||error("could not open %s for write.\n" fname)
CmAEODumpExpressions(outputs fp)
close(fp)
;;seems like a postFunc needs globals
CmAEO_global=list(nil)
putprop(CmAEO_global list(nil) concat("sevSession" sevSession->number) )
slid=get(CmAEO_global concat("sevSession" sevSession->number) )
putprop(slid fname 'fname)
/* */
ipcBeginProcess(command "" dataHandler errHandler postFunc)
);let
);proc
/* _______________________________________________________ */