From d8a46fb55ae9ce363612f91a453413533bbfa307 Mon Sep 17 00:00:00 2001 From: William Joye Date: Wed, 20 Jun 2018 12:48:48 -0400 Subject: add ds9 data send parser --- ds9/library/source.tcl | 2 ++ ds9/library/util.tcl | 72 ++++++++++++++---------------------------- ds9/parsers/datasendlex.fcl | 18 +++++++++++ ds9/parsers/datasendparser.tac | 46 +++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 49 deletions(-) create mode 100644 ds9/parsers/datasendlex.fcl create mode 100644 ds9/parsers/datasendparser.tac diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index 88d3d76..c2a344a 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -240,6 +240,8 @@ source $ds9(root)/library/cubesendparser.tcl source $ds9(root)/library/cubesendlex.tcl source $ds9(root)/library/cursorparser.tcl source $ds9(root)/library/cursorlex.tcl +source $ds9(root)/library/datasendparser.tcl +source $ds9(root)/library/datasendlex.tcl source $ds9(root)/library/dssesoparser.tcl source $ds9(root)/library/dssesolex.tcl source $ds9(root)/library/dssesosendparser.tcl diff --git a/ds9/library/util.tcl b/ds9/library/util.tcl index 5aa9a5f..1bf0be1 100644 --- a/ds9/library/util.tcl +++ b/ds9/library/util.tcl @@ -1495,60 +1495,34 @@ proc CursorCmd {x y} { } proc ProcessSendDataCmd {proc id param sock fn} { - global cube - global blink + global parse + set parse(proc) $proc + set parse(id) $id + set parse(sock) $sock + set parse(fn) $fn + + datasend::YY_FLUSH_BUFFER + datasend::yy_scan_string $param + datasend::yyparse +} + +proc DataSendCmd {sys sky xx yy ww hh strip} { global current - if {$current(frame) != {}} { - set sys [lindex $param 0] - set sky [lindex $param 1] - set x [lindex $param 2] - set y [lindex $param 3] - set w [lindex $param 4] - set h [lindex $param 5] - set strip [lindex $param 6] - switch -- $sys { - image - - physical - - detector - - amplifier { - set strip $h - set h $w - set w $y - set y $x - set x $sky - set sky fk5 - } + if {$current(frame) == {}} { + return + } - fk4 - - b1950 - - fk5 - - j2000 - - icrs - - galactic - - ecliptic { - set strip $h - set h $w - set w $y - set y $x - set x $sky - set sky $sys - set sys wcs - } - } - set strip [FromYesNo $strip] - - $current(frame) get data $sys $sky $x $y $w $h rr - set ss {} - foreach ii [array names rr] { - if {$strip} { - append ss "$rr($ii)\n" - } else { - append ss "$ii = $rr($ii)\n" - } + $current(frame) get data $sys $sky $xx $yy $ww $hh rr + set ss {} + foreach ii [array names rr] { + if {$strip} { + append ss "$rr($ii)\n" + } else { + append ss "$ii = $rr($ii)\n" } - ProcessSend $proc $id $sock $fn {.dat} $ss } + ProcessSendCmdResult {.dat} $ss } proc ProcessIconifyCmd {varname iname} { diff --git a/ds9/parsers/datasendlex.fcl b/ds9/parsers/datasendlex.fcl new file mode 100644 index 0000000..0c632d7 --- /dev/null +++ b/ds9/parsers/datasendlex.fcl @@ -0,0 +1,18 @@ +#tab datasendparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +#include coordsys.fin +#include wcssys.fin +#include skyframe.fin +#include yesno.fin +#include numeric.fin +#include sexstr.fin +#include ws.fin + +%% diff --git a/ds9/parsers/datasendparser.tac b/ds9/parsers/datasendparser.tac new file mode 100644 index 0000000..1ffc9fa --- /dev/null +++ b/ds9/parsers/datasendparser.tac @@ -0,0 +1,46 @@ +%{ +%} + +#include coordsys.tin +#include wcssys.tin +#include skyframe.tin +#include yesno.tin +#include numeric.tin +#include sexstr.tin + +%start datasend + +%% + +#include coordsys.trl +#include wcssys.trl +#include skyframe.trl +#include yesno.trl +#include numeric.trl + +datasend : coordsys numeric numeric INT_ INT_ yesno + {DataSendCmd $1 fk5 $2 $3 $4 $5 $6} + | wcssys numeric numeric numeric numeric yesno + {DataSendCmd $1 fk5 $2 $3 $4 $5 $6} + | skyframe numeric numeric numeric numeric yesno + {DataSendCmd wcs $1 $2 $3 $4 $5 $6} + | wcssys skyframe numeric numeric numeric numeric yesno + {DataSendCmd $1 $2 $3 $4 $5 $6 $7} + + | wcssys SEXSTR_ SEXSTR_ numeric numeric yesno + {DataSendCmd $1 fk5 $2 $3 $4 $5 $6} + | skyframe SEXSTR_ SEXSTR_ numeric numeric yesno + {DataSendCmd wcs $1 $2 $3 $4 $5 $6} + | wcssys skyframe SEXSTR_ SEXSTR_ numeric numeric yesno + {DataSendCmd $1 $2 $3 $4 $5 $6 $7} + ; + +%% + +proc datasend::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} -- cgit v0.12