text edit of ADE ouputs

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

/* _______________________________________________________ */
 
Here is a version that works with ic446.


/*
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=CmAEOasiTosev(session)
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(CmAEOasiTosev(asiSession)
member('sevSession asiSession->data->?) && asiSession->data->sevSession || car(
setof(sevses artUnique(setof(x hiGetWindowList()~>sevSession x))
sevEnvironment(sevses)==asiSession
)
)
);proc

procedure(CmAEOmainIPC()
let( (session sevSession outputs fname fp edtr command dataHandler errHandler
postFunc slid)
session=asiGetCurrentSession()
sevSession=CmAEOasiTosev(session)
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=CmAEOasiTosev(session)
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

/* _______________________________________________________ */

/*********tests

procedure(tryme()
session=asiGetCurrentSession()
sevSession=CmAEOasiTosev(session)
outputs=sevOutputs(sevSession)
fname="./AEOtst.txt"
fp=outfile(fname)
CmAEODumpExpressions(outputs fp)
close(fp)
fp=infile(fname)
CmAEOReadExpressions(outputs fp)
)

setSkillPath(
'("/sys/cadappl1_paris/ictools/cadence_ic/5.0.33.500.1.8/tools.hppa/dfII/local"
"." "~" "/cadappl/iclibs/catena/il" "/cadappl/iclibs/catena/il/dev/il"
"/user/p_sidwin/.caddata/calibre/lv_micro.hpu/shared/pkgs/icv/tools/queryskl")
)

procedure( l() load("CmADEEditOutputs.il")

bad example
hiRegisterBindKeyPrefix(sevAppType() "form")
hiSetBindKey(sevAppType() "<Ctrl>o" "CmAEOmainIPC()")
hiSetBindKey("Command Interpreter" "<Ctrl>o" "sh(\"oclock\")" )
good example
hiSetBindKey("Schematics" "<Ctrl>o" "CmAEOmainIPC()")

********/


fogh wrote:

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 ?
 
On Thu, 07 Apr 2005 17:28:03 +0200, fogh
<cad_support@skipthisandunderscores.catena.nl> wrote:

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 ?
You can't. Bindkeys are only available in editor windows with a specific
viewtype. The ADE window is a form, and no bindkeys are available on forms.

Sorry.

Andrew.
 
Andrew Beckett wrote:
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 ?
You can't. Bindkeys are only available in editor windows with a specific
viewtype. The ADE window is a form, and no bindkeys are available on forms.
I noticed. Of course my first try was to do
hiRegisterBindKeyPrefix(sevAppType() "form")
hiSetBindKey(sevAppType() "<Ctrl>o" "CmAEOmainIPC()")
and I saw that it did not work at all. In the form definition itself, you seem
to have nothing more than the doubleclick callback and modification callback.

In any case, there must be an IPC way, with an external program that detects
certain events (button3 double click && current window is artist), and then send
some SKILL code. But I was wondering if there is somthing less ugly within dfII
that could do the same.
 
Hi All,

Here is a quick intro on how to use it:

hiSetBindKey("Schematics" "<Ctrl>o" "CmAEOmainIPC()")

- have an analog artists with outputs that are expressions (as opposed to plain
signals for currents and potentials)
- put the mouse in the associated schematic window
- press Control o
- edit outputs or add them at the end with one line exactly for the
title and one or more lines for the expression. The expression can span
multiple lines as long as it is only 1 syntactic form.
- close the editor, and your modifications/additions are now in the analog artist.


This for instance is just one syntactic form that will return only last ratio
(the normalised white noise) :
( let ()
R0=-1 /real(i("/V0/PLUS" ?result "ac-ac"))
IN0=sqrt( 4 * boltzmann * (1/R0) * (273.15 + VAR("temp")) )
N0=sqrt(pv( "R0.R1" "total" ?result "noise-noise" ))
NN_R0=N0/IN0
)

it is cleaner with local vars:
( let (R0 IN0 N0 NNR0)
R0=-1 /real(i("/V0/PLUS" ?result "ac-ac"))
IN0=sqrt( 4 * boltzmann * (1/R0) * (273.15 + VAR("temp")) )
N0=sqrt(pv( "R0.R1" "total" ?result "noise-noise" ))
NNR0=N0/IN0
)


fogh wrote:
Here is a version that works with ic446.


/*
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=CmAEOasiTosev(session)
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(CmAEOasiTosev(asiSession)
member('sevSession asiSession->data->?) && asiSession->data->sevSession
|| car(
setof(sevses artUnique(setof(x hiGetWindowList()~>sevSession x))
sevEnvironment(sevses)==asiSession
)
)
);proc

procedure(CmAEOmainIPC()
let( (session sevSession outputs fname fp edtr command dataHandler
errHandler postFunc slid)
session=asiGetCurrentSession()
sevSession=CmAEOasiTosev(session)
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=CmAEOasiTosev(session)
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

/* _______________________________________________________ */


********/


fogh wrote:

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 ?
 

Welcome to EDABoard.com

Sponsor

Back
Top