From 82c78868be2567fc0399379497288892fc6d0506 Mon Sep 17 00:00:00 2001 From: William Joye Date: Fri, 8 Jun 2018 15:19:26 -0400 Subject: add ds9 blink send parser --- ds9/library/cube.tcl | 6 ------ ds9/library/frame.tcl | 32 ++++++++++++++++++++++---------- ds9/library/source.tcl | 2 ++ ds9/parsers/blinksendlex.fcl | 12 ++++++++++++ ds9/parsers/blinksendparser.tac | 22 ++++++++++++++++++++++ ds9/parsers/cubesendparser.tac | 2 +- 6 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 ds9/parsers/blinksendlex.fcl create mode 100644 ds9/parsers/blinksendparser.tac diff --git a/ds9/library/cube.tcl b/ds9/library/cube.tcl index d94955c..062271a 100644 --- a/ds9/library/cube.tcl +++ b/ds9/library/cube.tcl @@ -736,9 +736,3 @@ proc ProcessSendCubeCmd {proc id param {sock {}} {fn {}}} { cubesend::yyparse } -proc CubeSendCmdInterval {} { - global parse - global blink - - $parse(proc) $parse(id) "[expr $blink(interval)/1000.]\n" -} diff --git a/ds9/library/frame.tcl b/ds9/library/frame.tcl index b1fc945..efd630b 100644 --- a/ds9/library/frame.tcl +++ b/ds9/library/frame.tcl @@ -2200,19 +2200,31 @@ proc ProcessBlinkCmd {varname iname} { } proc ProcessSendBlinkCmd {proc id param {sock {}} {fn {}}} { + global parse + set parse(proc) $proc + set parse(id) $id + + blinksend::YY_FLUSH_BUFFER + blinksend::yy_scan_string $param + blinksend::yyparse +} + +proc BlinkSendCmd {} { + global parse global current + + if {$current(display)=="blink"} { + $parse(proc) $parse(id) "yes\n" + } else { + $parse(proc) $parse(id) "no\n" + } +} + +proc BlinkSendCmdInterval {} { + global parse global blink - switch -- [lindex $param 0] { - interval {$proc $id "[expr $blink(interval)/1000.]\n"} - default { - if {$current(display) == {blink}} { - $proc $id [ToYesNo 1] - } else { - $proc $id [ToYesNo 0] - } - } - } + $parse(proc) $parse(id) "[expr $blink(interval)/1000.]\n" } proc ProcessLockCmd {varname iname} { diff --git a/ds9/library/source.tcl b/ds9/library/source.tcl index a2cf94f..2addccd 100644 --- a/ds9/library/source.tcl +++ b/ds9/library/source.tcl @@ -204,6 +204,8 @@ source $ds9(root)/library/bgparser.tcl source $ds9(root)/library/bglex.tcl source $ds9(root)/library/blinkparser.tcl source $ds9(root)/library/blinklex.tcl +source $ds9(root)/library/blinksendparser.tcl +source $ds9(root)/library/blinksendlex.tcl source $ds9(root)/library/blockparser.tcl source $ds9(root)/library/blocklex.tcl source $ds9(root)/library/blocksendparser.tcl diff --git a/ds9/parsers/blinksendlex.fcl b/ds9/parsers/blinksendlex.fcl new file mode 100644 index 0000000..26a3093 --- /dev/null +++ b/ds9/parsers/blinksendlex.fcl @@ -0,0 +1,12 @@ +#tab blinksendparser.tab.tcl + +%{ +%} + +#include defs.fin + +%% + +interval {return $INTERVAL_} + +%% diff --git a/ds9/parsers/blinksendparser.tac b/ds9/parsers/blinksendparser.tac new file mode 100644 index 0000000..2b02b3c --- /dev/null +++ b/ds9/parsers/blinksendparser.tac @@ -0,0 +1,22 @@ +%{ +%} + +%start blinksend + +%token INTERVAL_ + +%% + +blinksend : {BlinkSendCmd} + | INTERVAL_ {BlinkSendCmdInterval} + ; + +%% + +proc blinksend::yyerror {msg} { + variable yycnt + variable yy_current_buffer + variable index_ + + ParserError $msg $yycnt $yy_current_buffer $index_ +} diff --git a/ds9/parsers/cubesendparser.tac b/ds9/parsers/cubesendparser.tac index 2f854fb..328770d 100644 --- a/ds9/parsers/cubesendparser.tac +++ b/ds9/parsers/cubesendparser.tac @@ -13,7 +13,7 @@ cubesend : {global cube; ProcessSendCmdCurrent frame "get fits slice $cube(axis)"} | LOCK_ {ProcessSendCmdGet cube lock} - | INTERVAL_ {CubeSendCmdInterval} + | INTERVAL_ {BlinkSendCmdInterval} | AXIS_ {ProcessSendCmdGet cube axis} | AXES_ order | ORDER_ order -- cgit v0.12