aboutsummaryrefslogtreecommitdiff
path: root/vo/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'vo/handlers')
-rw-r--r--vo/handlers/README66
-rw-r--r--vo/handlers/overhandler.cl26
-rw-r--r--vo/handlers/tblhandler.cl61
3 files changed, 153 insertions, 0 deletions
diff --git a/vo/handlers/README b/vo/handlers/README
new file mode 100644
index 00000000..ae045cbd
--- /dev/null
+++ b/vo/handlers/README
@@ -0,0 +1,66 @@
+
+ SAMP Message Handlers
+ =====================
+
+ This directory contains scripts that may be used as SAMP message handlers.
+
+
+
+Using SAMP Handlers
+===================
+
+ SAMP handlers in use can be listed with the command:
+
+ cl> samp handler
+
+A handler may be defined using the command
+
+ cl> samp handler <mtype> "<cmd_string>"
+
+where <mtype> is the SAMP MType associated with the handler (e.g. a standard
+"image.load.fits" for images, or a custom "foo.bar" for private use). The
+<cmd_string> is an IRAF command string that will be executed when that mtype
+is received, e.g.
+
+ cl> samp handler image.load.fits "imstat $url"
+
+The '$' operator before an argument will cause the value of the message
+parameter of that name to be substituted in the command string. The list
+of SAMP Mtypes in common use is maintained at
+
+ http://www.ivoa.net/cgi-bin/twiki/bin/view/IVOA/SampMTypes
+
+
+In summary, the mtypes and arguments in use at this writing include:
+
+ MType Arguments
+ ----------------------- --------------------------
+ samp.app.ping sender
+ samp.app.status sender
+
+ table.load.votable url, [table-id], [name]
+ table.load.fits url, [table-id], [name]
+ table.highlight.row url, table-id, row
+ table.select.rowList url, table-id, row-list[]
+
+ image.load.fits url, [image-id], [name]
+
+ coord.pointAt.sky ra, dec
+
+ bibcode.load bibcode
+
+ client.env.get name
+ client.env.set name, value
+
+ client.param.get name
+ client.param.set name, value
+
+ spectrum.load.ssa-generic url, meta, [spectrum-id], [name]
+
+ voresource.loadlist [name], ids
+ voresource.loadlist.cone " "
+ voresource.loadlist.siap " "
+ voresource.loadlist.ssap " "
+ voresource.loadlist.tap " "
+ voresource.loadlist.vospace " "
+
diff --git a/vo/handlers/overhandler.cl b/vo/handlers/overhandler.cl
new file mode 100644
index 00000000..e197a70e
--- /dev/null
+++ b/vo/handlers/overhandler.cl
@@ -0,0 +1,26 @@
+#{ OVERHANDLER -- VOTable SAMP message handler to overlay a catalog on the
+# image display.
+
+procedure overhandler (url)
+
+string url { prompt = "VOTable URL" }
+int fnum = 0 { prompt = "Test number" }
+
+begin
+ string tcat
+
+ # Get the currently displayed image.
+ dispname (1)
+ if (dispname.status != 0)
+ error (0, "No image displayed")
+ else
+ wcsinfo (dispname.name)
+
+
+ tcat = mktemp ("/tmp/cat")
+
+ votpos (url, out="STDOUT", verb-, number+, header-, >& tcat)
+ taboverlay (dispname.name, tcat, lab=1, ra=2, dec=3)
+
+ delete (tcat, verify-, >& "dev$null")
+end
diff --git a/vo/handlers/tblhandler.cl b/vo/handlers/tblhandler.cl
new file mode 100644
index 00000000..7d1d0e9a
--- /dev/null
+++ b/vo/handlers/tblhandler.cl
@@ -0,0 +1,61 @@
+#{ TBLHANDLER -- Utility VOTable SAMP message handler
+
+procedure tblhandler (url)
+
+string url { prompt = "VOTable URL" }
+
+string task1 = "imexam %s 1" { prompt = "Single-row task to execute" }
+string taskn = "" { prompt = "Multi--row task to execute" }
+
+begin
+ string inurl, sname, tname, tab, tsk, t1, tn, root
+ int sia
+
+ inurl = url
+ t1 = task1
+ tn = taskn
+
+
+ iferr {
+ tab = mktemp ("tmp$tbl")
+ # copy (inurl, tab) FIXME
+ urlget (inurl, tab, use_cache-, extn="", verb-)
+ unlearn ("tinfo")
+ tinfo (inurl, >& "dev$null")
+
+ # Check for an SIA result table.
+ match ("Image_AccessReference", tab) | count ("STDIN") | scan (sia)
+
+ if (tinfo.nrows == 1 && sia == 1) # get task to execute
+ tsk = t1
+ else
+ tsk = tn
+
+ # Execute the command depending on the number of rows in the table.
+
+ sections ("@" // osfn (tab)) | scan (tname)
+ root = tname
+ if (imaccess (tname // "[1]") == yes) {
+ if (imaccess (tname // "[SCI]") == yes)
+ tname = tname // "[SCI]"
+ else
+ tname = tname // "[1]"
+ }
+
+ # Execute the command.
+ printf (tsk // "\n", tname) | clbye()
+
+ printf ("Save As (or <cr> to quit)? ") # Save displayed image?
+ scan (sname)
+ if (nscan () == 1) {
+ print (root // " --> " // sname)
+ copy (root, sname)
+ }
+
+ } then {
+ delete (tab, ver-, >& "dev$null")
+ logout
+ }
+
+ delete (tab, ver-, >& "dev$null")
+end