Index: /trunk/Ohana/doc/dvo2.txt
===================================================================
--- /trunk/Ohana/doc/dvo2.txt	(revision 3335)
+++ /trunk/Ohana/doc/dvo2.txt	(revision 3335)
@@ -0,0 +1,92 @@
+
+DVO-2 upgrades the DVO concepts to meet the needs of Pan-STARRS.  The
+main constraints that Pan-STARRS has that DVO-1 cannot satisfy are:
+
+- throughput  : upload ~1e6 stars per image, allowing 5 seconds
+- precision   : DVO tables have a restricted number of bits for some
+	        entries which need to be extended for Pan-STARRS
+- flexibility : DVO uses a rigid concept for the sky layout 
+- parallel    : DVO interfaces are poorly designed for parallel I/O
+
+
+Here are the code changes I envision to get from DVO to DVO-2:
+
+- clean the elixir code organization to unify as many DVO things as
+  possible under a single library used by the related programs.
+
+  * this change would be somewhat productive for reducing the number
+    of APIs and generally clarifying the scope of the existing DVO
+    code. 
+
+- add the concept of the mosaic image which groups a set of chips
+  together.  this will include the concept of astrometric information
+  about the focal plane independent of the individual chips
+
+  * this particular change can be a stop gap to get me working with
+    mosaic astrometry within the DVO-1 framework.  Other changes,
+    listed below, will require a variety of fairly fundamental
+    changes.
+
+  * there is no additional cost to adding the mosaic files to the
+    current system, except that 'addstar' requires NSTARS > 0 (or at
+    least NASTRO > 0).  Everything else will work fine with images
+    that have distortion in them (already demonstrated in the past)
+    and the new work on coordops.c makes reverse lookup of RD_to_XY
+    accurate for Npolyterms > 1.
+
+  * chips within a mosaic framework need to have a matched mosaic
+    image.  the coordinates of the mosaic need to be registered
+    somehow with coordops (as a static entry?  not very robust, but an
+    option.  As an implied coords[0], coords[1] passed to the
+    functions?  this can be merged with the existing definitions by
+    only requiring it for entries with one ctype, but not for another
+    cartesian polynomial term (WRP vs PLY? this would make PLY mean
+    Cartesian, not Zenithal).  This is probably safe since only LONEOS
+    data has used the PLY terms in the past.  on the other hand, why
+    break it.  I could use the term PLY for the mosaic term and WRP vs
+    DIS for the two cartesian concepts.  Not very good naming.
+    Another point is that the old LONOES code uses the older style
+    tables, and probably need to be translated anyway.  I could just
+    define a loneos conversion function which converts PLY to DIS and
+    fixes the data format... (this would also let me remove the old
+    table entries from 'loneos.h', or maybe keep them there and move
+    the loneos.h file to a better name.  dvo.h?  elixir.h? 
+
+    - needed functions:
+
+      * int FindMosaicForImage (Image *images, int entry) 
+
+	returns the matching DIS entry for the given WRP entry
+	(matches by time and photcode? would need to define mosaic
+	photcodes that match the chip photcodes.  define an instrument
+	(camera) code in the Image entry?  does not exist at the
+	moment, but would need to be added (space exists in dummy[20],
+	which is surprisingly unused).
+
+- skydb library APIs : we need a collection of functions to define and
+  work with the sky tiling pattern.  These APIs need to specify things
+  like "given RA,DEC, find all overlapping tables"
+
+- convert all tables to FITS tables (currently only average/measure
+  tables are FITS).  this includes migrating the photcode and other
+  external photometry / astrometry tables into the single database
+  repository, rather than having a global table.
+
+- update the average / measure tables to include enough dynamic range.
+
+- place all tables, including average / measure under the FITS db
+  autocoder 
+
+- add proper motion velocity vectors to the average parameters
+
+- add the concept of orphans as a separate table in addition to the
+  measures
+
+- remove any average mag from the average table / place all average
+  magnitudes in their own table (ie, equivalent to secfilt, but with a
+  new name)
+
+- define a client / server interaction.  each server runs on a
+  specific host, associated with specific data tables through the
+  sky.db tables.  servers on a specific host are only responsible for
+  their own data
Index: /trunk/Ohana/src/gastro/src/gheader.c
===================================================================
--- /trunk/Ohana/src/gastro/src/gheader.c	(revision 3334)
+++ /trunk/Ohana/src/gastro/src/gheader.c	(revision 3335)
@@ -38,4 +38,5 @@
   fits_modify (&header, "NASTRO", "%C", 1, "number of stars used for astrometry");
 
+  /*** use PutCoords to update header ***/
   if (coords.Npolyterms > 1) {
     fits_modify (&header, "CTYPE1",   "%s",  1, "RA---PLY");
Index: /trunk/Ohana/src/gastro2/src/gheader2.c
===================================================================
--- /trunk/Ohana/src/gastro2/src/gheader2.c	(revision 3334)
+++ /trunk/Ohana/src/gastro2/src/gheader2.c	(revision 3335)
@@ -24,4 +24,5 @@
   fits_modify (&header, "NASTRO", "%C", 1, "number of stars used for astrometry");
 
+  /*** use PutCoords to update header ***/
   if (Target[0].coords.Npolyterms > 1) {
     fits_modify (&header, "CTYPE1",   "%s",  1, "RA---PLY");
Index: /trunk/Ohana/src/imclean/src/AdjustHeader.c
===================================================================
--- /trunk/Ohana/src/imclean/src/AdjustHeader.c	(revision 3334)
+++ /trunk/Ohana/src/imclean/src/AdjustHeader.c	(revision 3335)
@@ -62,4 +62,5 @@
       exit (1);
     }
+    /*** use PutCoords to update header ***/
     if (coords.Npolyterms > 1) {
       fits_modify (header, "CTYPE1",   "%s",  1, "RA---PLY");
Index: /trunk/Ohana/src/opihi/doc/pcontrol.txt
===================================================================
--- /trunk/Ohana/src/opihi/doc/pcontrol.txt	(revision 3335)
+++ /trunk/Ohana/src/opihi/doc/pcontrol.txt	(revision 3335)
@@ -0,0 +1,179 @@
+
+typedef struct {
+  char *buffer;
+  int   Nalloc;
+  int   Nmaxread;
+  int   Nextra;
+  int   Nlast;
+  int   Nbuffer;
+} Fifo;
+
+typedef struct {
+  int argc; char **argv; /* a list of words that define this object */
+  struct timeval start, accum, timer;
+  int   status;
+  char *logfile;
+  char *lastproc;
+} Object;
+
+typedef struct {
+  Object **object;
+  int    Nobject;
+  int    NOBJECT;
+} Queue;
+
+typedef struct {
+  char   *hostname;
+  int     rsock, wsock;
+  int     status; /* idle, busy, etc... */
+  struct  timeval start, accum, timer;
+  Fifo    fifo;
+  int     code;
+  Object *object;
+} Machine;
+
+
+currently, the transport is /usr/bin/rsh, defined in InitMachines.c 
+
+the shell on the remote machines is /bin/tcsh, defined by rconnect.c
+
+---
+
+pcontrol.client:
+
+ - remote process initiated by pcontrol
+
+ - accepts jobs, returns status, stdout and stderr
+
+ - valid commands:
+
+   - job (argv)
+     returns PID or -1 (0?) on failure
+
+   - status
+     returns current job status:
+     BUSY
+     EXIT n 
+     CRASH n
+     
+   - stderr
+     returns the current stderr buffer:
+     NBYTES n
+     (DATA)
+
+   - stdout
+     returns the current stdout buffer:
+     NBYTES n
+     (DATA)
+
+   
+---
+
+the client needs to accept commands from the server (via
+stdin/stdout), but it also needs to monitor its process.  I can use
+the opihi structure to implement the command-line interpretation with
+readline.  I can use the readline function rl_event_hook to set the
+background functions to check and rl_set_keyboard_input_timeout to set
+the polling period.
+
+this same method can be used with the scheduler:  the command 'run'
+can set the CheckTask function to this hook (& unset it).
+
+
+---
+
+rl_event_hook -> CheckChild
+
+  - needs to handle the case when no child process yet exists
+  - needs to examine the child status,
+  - needs to read from child stderr and store
+  - needs to read from child stdout and store
+
+  * no warnings (will not do anything clever if buffers get too large)
+
+---
+
+ pcontrol commands:
+
+ job [options] argv0 argv1 argv2 ...
+  -host name : run job on specified host, or any other if not available
+  +host name : run job on specified host, error if not available (error when attempted, not when submitted)
+  -timeout N : seconds before controller gives up on job (once started)
+
+  * priority information?
+  * returns JobID
+  * adds job to pending queue
+
+ host (hostname) [-delete]
+ (may have multiple entries to the same machine, these are not distinguished)
+
+ stdout ID [-file name]
+ stderr ID [-file name]
+ delete ID
+
+ status -job ID
+ status -machine hostname
+ status -queues
+
+ 
+---
+
+write message
+read until MESSAGE END
+
+
+Job States:
+
+PENDING
+BUSY
+EXIT
+CRASH
+NEW
+DEL
+
+Job State Transitions:
+
+NEW     -> PENDING : AddJob
+PENDING -> BUSY    : StartJob
+PENDING -> DEL     : DelJob
+BUSY    -> EXIT    : CheckJob
+BUSY    -> CRASH   : CheckJob | KillJob
+BUSY    -> PENDING : CheckJob | CheckHost
+EXIT    -> DEL     : DelJob
+CRASH   -> DEL     : DelJob
+
+Host States:
+
+IDLE
+BUSY
+DOWN
+OFF
+NEW
+DEL
+
+Host State Transitions:
+
+NEW      -> OFF      : AddHost
+OFF      -> DEL      : DelHost
+OFF      -> DOWN     : OnHost
+DOWN     -> OFF      : OffHost
+IDLE     -> OFF      : OffHost
+DOWN     -> IDLE     : StartHost
+IDLE     -> BUSY     : StartJob
+BUSY     -> IDLE     : CheckJob | KillJob
+BUSY     -> BUSY-OFF : OffHost
+BUSY     -> DOWN     : CheckJob | CheckHost
+BUSY-OFF -> OFF      : CheckJob
+
+AddJob    - U
+DelJob    - U
+StartJob  - P
+CheckJob  - P
+KillJob   - U
+
+AddHost   - U
+DelHost   - U
+OnHost    - U
+OffHost   - U
+StartHost - P
+CheckHost - P
Index: /trunk/Ohana/src/opihi/doc/scheduler.txt
===================================================================
--- /trunk/Ohana/src/opihi/doc/scheduler.txt	(revision 3335)
+++ /trunk/Ohana/src/opihi/doc/scheduler.txt	(revision 3335)
@@ -0,0 +1,106 @@
+
+scheduler commands:
+
+task (taskname)
+ - define a new task
+ - loads task-related commands from list / readline
+ - commands are parsed on load
+ - end with end (like if / for)
+
+task.exit (value)
+ - define a new task macro for this exit condition
+   (value) may be an exit status (number)
+   (value) may be 'timeout'
+   (value) may be 'crash' ?
+ - commands are parsed on execution (not on definition)
+
+task.exec
+ - define a task macro for exec condition
+ - commands are parsed on execution (not on definition)
+
+command (args) (args)
+ - defines command associated with task
+ - may be in task or in task.macro (exit/exec)
+   (in task, command line is static; in task.macro, command line is expanded for each instance)
+
+host (machine)
+ - defines preferred host
+ - may be in task or in task.macro (exit/exec)
+   (in task, value is static; in task.macro, value is defined for each instance)
+
+stderr (file / variable)
+ - defines destination for stderr capture from task
+ - written to destination at end of execution?
+
+stdout (file / variable)
+ - defines destination for stdout capture from task
+ - written to destination at end of execution?
+
+periods -poll 1
+periods -exec 30
+periods -timeout 2
+ - defines relevant time-scale for the task
+
+schedule
+ - runs the scheduler loop, executing the various tasks
+
+scheduler functions:
+
+InitTasks ();
+FindTask ();
+CreateTask ();
+
+---
+
+local jobs vs controller jobs
+
+if 'host' is 'local', task is run as background fork (ie, not on controller)
+if 'host' is NULL or 'any', task is run on controller without specified host
+if 'host' is (machine), task is run on controller with specified host
+
+---
+
+controller interaction:
+
+controller accepts the following commands:
+
+job [options] argv0 argv1 argv2 ...
+  -host name : run job on specified host, or any other if not available
+  +host name : run job on specified host, error if not available
+  -timeout N : seconds before controller gives up on job (once started)
+  -stdout name : redirect job stdout to file directly
+  -stderr name : redirect job stderr to file directly
+  * priority information?
+  * returns JobID
+
+status (JobID)
+
+stdout (JobID)
+
+stderr (JobID)
+
+stop (JobID)
+  
+delete (JobID)
+
+---
+
+possible errors which the scheduler may encounter when executing a
+job:
+
+  - controller is not responding
+  - controller says machine is DOWN
+  - controller says command not found
+  - controller has too many processes
+  - controller takes to long to start job (scheduler timeout)
+  - controller says job timed out
+  - controller says job crashed
+  - controller says job exited with status
+
+---
+
+notes:
+
+ - watch for NFS lags / blocking.  if NFS has file visibility lags, we
+   may need to add blocking as an option to the job (-block filename)
+
