Index: /trunk/Ohana/src/opihi/include/pantasks.h
===================================================================
--- /trunk/Ohana/src/opihi/include/pantasks.h	(revision 6687)
+++ /trunk/Ohana/src/opihi/include/pantasks.h	(revision 6687)
@@ -0,0 +1,184 @@
+# include "data.h"
+# include "basic.h"
+
+typedef enum {
+  JOB_NONE,
+  JOB_BUSY, 
+  JOB_EXIT, 
+  JOB_HUNG,
+  JOB_CRASH,
+  JOB_PENDING,
+} JobStat;
+
+typedef enum {
+  JOB_LOCAL, 
+  JOB_CONTROLLER, 
+} JobMode;
+
+typedef enum {
+  CONTROLLER_HUNG = -1,
+  CONTROLLER_DOWN = 0,
+  CONTROLLER_GOOD = 1,
+} ControllerStat;
+
+enum {RANGE_ABS, RANGE_DAY, RANGE_WEEK};
+
+enum {TASK_NONE, 
+      TASK_EMPTY, 
+      TASK_COMMENT, 
+      TASK_NMAX, 
+      TASK_TRANGE, 
+      TASK_END, 
+      TASK_HOST, 
+      TASK_COMMAND, 
+      TASK_PERIODS, 
+      TASK_EXIT, 
+      TASK_EXEC
+} TaskHashResults;
+
+typedef struct {
+  time_t start;
+  time_t stop;
+  char type;
+  char keep;
+} TimeRange;
+
+/* a task is a description of the wrapping of a job */
+typedef struct {
+  Macro  *exec;				/* name is 'exec' */
+  Macro  *crash;			/* name is 'crash' */
+  Macro  *timeout;
+  Macro  *defexit;
+
+  int     NEXIT;
+  int     Nexit;
+  Macro **exit;				/* name is exit status */
+
+  int     argc;
+  char  **argv;
+  char   *host;
+  int     host_required;
+
+  char   *name;
+
+  int       Nranges;
+  TimeRange *ranges;
+
+  int     Nmax;  // only construct Ntotal jobs for this task
+  int     Njobs;
+
+  float   poll_period;
+  float   exec_period;
+  float   timeout_period;
+
+  struct timeval last;
+
+  int Nsuccess;
+  int Nfailure;
+  int Ntimeout;
+
+} Task;
+
+// time period include/exclude periods: 
+// date ranges (e_time - e_time) 
+// time ranges (e_time - e_time) (use e_time % 86400)
+// time-of-week ranges  (e_time - e_time
+// -trange Mon Fri (inclusive on days -- end defaults to Fri@23:59:59)
+// -trange 08:00 - 17:00
+// -trange 2005/12/24 2005/12/31
+// be careful of HST!
+// type: day, week, date
+// keep: TRUE: perform action within this time period
+// keep: FALSE: do not perform action within this time period
+  
+typedef struct {
+  int JobID;				/* internal ID for job */
+  int pid;				/* external ID for job */
+
+  struct timeval last;
+  struct timeval start;
+  int state;
+  int exit_status;
+
+  int     argc;
+  char  **argv;
+  Task   *task;
+
+  IOBuffer    stdout;			/* stdout storage buffer */
+  IOBuffer    stderr;			/* stderr storage buffer */
+  JobMode     mode;			/* local or controller? */
+
+  int         stdout_size;		/* size of pending stdout buffer (controller) */
+  int         stderr_size;		/* size of pending stderr buffer (controller) */
+  int         stdout_fd;		/* stdout pipe (local only) */
+  int         stderr_fd;		/* stderr pipe (local only) */
+} Job;
+
+# define CONTROLLER_PROMPT "pcontrol:"
+
+/* scheduler prototypes */
+
+void InitPantasks ();
+void InitTasks ();
+Task *NextTask ();
+Task *FindTask (char *name);
+void ListTasks (int verbose);
+int ShowTask (char *name);
+int FreeTask (Task *task);
+Task *CreateTask (char *name);
+int ValidateTask (Task *task, int RequireStatic);
+int RegisterNewTask ();
+int DeleteNewTask ();
+Task *GetNewTask ();
+Task *GetActiveTask ();
+void SetTaskTimer (struct timeval *timer);
+double GetTaskTimer (struct timeval start);
+void InitTaskTimers ();
+int TaskHash (char *input);
+int RemoveTask (Task *task);
+Task *SetNewTask (Task *task);
+
+int NextJobID ();
+int InitJobIDs ();
+int FreeJobID (int ID);
+
+void InitJobs ();
+Job *NextJob ();
+Job *FindJob (int JobID);
+void ListJobs ();
+Job *CreateJob (Task *task);
+int SubmitJob (Job *job);
+int CheckJob (Job *job);
+int DeleteJob (Job *job);
+void FreeJob (Job *job);
+
+int CheckJobs ();
+int CheckTasks ();
+int CheckSystem ();
+int CheckController ();
+int CheckTimeRanges (TimeRange *ranges, int Nranges);
+int GetJobOutput (char *channel, int pid, IOBuffer *buffer, int Nbytes);
+int CheckControllerJob (Job *job);
+int CheckControllerJobStatus (Job *job);
+int SubmitControllerJob (Job *job);
+int DeleteControllerJob (Job *job);
+Job *FindControllerJob (int JobID);
+int StartController ();
+int ControllerCommand (char *command, char *response, IOBuffer *buffer);
+int SubmitLocalJob (Job *job);
+int CheckLocalJob (Job *job);
+int CheckLocalJobStatus (Job *job);
+void InitTaskTimers ();
+CommandF *FindControllerCommand (char *cmd);
+int QuitController ();
+int StopController ();
+int VerboseMode ();
+int KillLocalJob (Job *job);
+int CheckControllerOutput ();
+int PrintControllerOutput ();
+
+int KillControllerJob (Job *job);
+int CheckControllerStatus ();
+int TestElapsedCheck ();
+void gotsignal (int signum);
+
Index: /trunk/Ohana/src/opihi/pantasks/CheckController.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/CheckController.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/CheckController.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 static struct timeval start;
Index: /trunk/Ohana/src/opihi/pantasks/CheckJobs.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/CheckJobs.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/CheckJobs.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int CheckJobs () {
Index: /trunk/Ohana/src/opihi/pantasks/CheckSystem.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/CheckSystem.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/CheckSystem.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 # define MAX_DELAY 0.1
Index: /trunk/Ohana/src/opihi/pantasks/CheckTasks.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/CheckTasks.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/CheckTasks.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int CheckTasks () {
Index: /trunk/Ohana/src/opihi/pantasks/CheckTimeRanges.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/CheckTimeRanges.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/CheckTimeRanges.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int CheckTimeRanges (TimeRange *ranges, int Nranges) {
Index: /trunk/Ohana/src/opihi/pantasks/ControllerOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 /* adding a new host can delay controller up to a second or so */
 # define CONTROLLER_TIMEOUT 500
Index: /trunk/Ohana/src/opihi/pantasks/JobIDOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/JobIDOps.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/JobIDOps.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 # define MAX_N_JOBS 1000
Index: /trunk/Ohana/src/opihi/pantasks/JobOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/JobOps.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/JobOps.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 static Job **jobs;
Index: /trunk/Ohana/src/opihi/pantasks/LocalJob.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/LocalJob.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/LocalJob.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 /* local jobs are forked in the background 
Index: /trunk/Ohana/src/opihi/pantasks/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/Makefile	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/Makefile	(revision 6687)
@@ -5,5 +5,5 @@
 LIB     =       $(HOME)/lib
 INC     =       $(HOME)/include
-SDIR    =       $(HOME)/psched
+SDIR    =       $(HOME)/pantasks
 #
 DESTBIN =       $(LBIN)
@@ -11,5 +11,5 @@
 DESTINC =       $(LINC)
 DESTMAN =       $(LMAN)
-DESTHLP =       $(LHLP)/psched
+DESTHLP =       $(LHLP)/pantasks
 
 #  compile flags
@@ -26,6 +26,6 @@
 
 funcs = \
+$(SDIR)/pantasks.$(ARCH).o \
 $(SDIR)/init.$(ARCH).o \
-$(SDIR)/psched.$(ARCH).o \
 $(SDIR)/CheckJobs.$(ARCH).o \
 $(SDIR)/CheckSystem.$(ARCH).o \
@@ -70,13 +70,13 @@
 $(DESTLIB)/libdatacmd.a
 
-psched: $(BIN)/psched.$(ARCH)
+pantasks: $(BIN)/pantasks.$(ARCH)
 
-$(BIN)/psched.$(ARCH) : $(funcs) $(cmds) $(libs)
+$(BIN)/pantasks.$(ARCH) : $(funcs) $(cmds) $(libs)
 
-install: $(DESTBIN)/psched help
+install: $(DESTBIN)/pantasks help
 
-help: cmd.basic.help cmd.data.help cmd.astro.help psched.help
+help: cmd.basic.help cmd.data.help cmd.astro.help pantasks.help
 
-.PHONY: psched
+.PHONY: pantasks
 
 include ../Makefile.Common
Index: /trunk/Ohana/src/opihi/pantasks/TaskOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/TaskOps.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/TaskOps.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 static Task **tasks;
Index: /trunk/Ohana/src/opihi/pantasks/controller.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/controller.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int controller_host    PROTO((int, char **));
Index: /trunk/Ohana/src/opihi/pantasks/controller_check.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_check.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/controller_check.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int controller_check (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/controller_exit.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_exit.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/controller_exit.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int controller_exit (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/controller_host.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_host.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/controller_host.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int controller_host (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/controller_output.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_output.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/controller_output.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int controller_output (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/controller_pulse.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_pulse.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/controller_pulse.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int controller_pulse (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/controller_status.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_status.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/controller_status.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int controller_status (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/delete.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/delete.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/delete.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int delete_job (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/init.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/init.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/init.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int controller      PROTO((int, char **));
@@ -51,5 +51,5 @@
 */
 
-void InitPsched () {
+void InitPantasks () {
   
   int i;
Index: /trunk/Ohana/src/opihi/pantasks/job.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/job.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/job.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 /* this will require a bit of care: to define a job, we need
Index: /trunk/Ohana/src/opihi/pantasks/kill.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/kill.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/kill.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int kill_job (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/pantasks.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/pantasks.c	(revision 6687)
+++ /trunk/Ohana/src/opihi/pantasks/pantasks.c	(revision 6687)
@@ -0,0 +1,55 @@
+# include "pantasks.h"
+
+# define opihi_name "pantasks"
+# define opihi_prompt "pantasks: "
+# define opihi_description "parallel task scheduler\n"
+# define opihi_history ".pantasks"
+# define opihi_rcfile ".pantasksrc"
+
+/* program-dependent initialization */
+void program_init (int *argc, char **argv) {
+  
+  auto_break = TRUE;
+
+  /* load the commands used by this implementation */
+  InitBasic ();
+  InitData ();
+  InitPantasks ();
+
+  rl_readline_name = opihi_name;
+  rl_attempted_completion_function = command_completer;
+  rl_event_hook = NULL;
+  rl_set_keyboard_input_timeout (100000); 
+
+  set_str_variable ("HISTORY", opihi_history);
+  set_str_variable ("PROMPT", opihi_prompt);
+  set_str_variable ("RCFILE", opihi_rcfile);
+
+# ifdef HELPDIR_DEFAULT
+  set_str_variable ("HELPDIR", MACRO_NAME(HELPDIR_DEFAULT));
+# endif
+
+  signal (SIGPIPE, gotsignal);
+  signal (SIGTSTP, gotsignal);
+  signal (SIGTTIN, gotsignal);
+  return;
+}
+
+/* standard welcome message */
+void welcome () {
+  fprintf (stderr, "\n");
+  fprintf (stderr, "Welcome to %s - %s\n\n", opihi_name, opihi_description);
+}
+
+/* add program-dependent exit functions here */
+void cleanup () {
+  QuitImage ();
+  QuitGraph ();
+  QuitController ();
+  return;
+}
+
+void gotsignal (int signum) {
+  fprintf (stderr, "got signal : %d\n", signum);
+  return;
+}
Index: /trunk/Ohana/src/opihi/pantasks/pulse.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/pulse.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/pulse.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int pulse (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/run.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/run.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/run.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int run (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/status.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/status.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/status.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int status_sys (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/stop.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/stop.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/stop.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int stop (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/task.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/task.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 # define prompt "> "
 
Index: /trunk/Ohana/src/opihi/pantasks/task_command.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task_command.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/task_command.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int task_command (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/task_host.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task_host.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/task_host.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int task_host (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/task_macros.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task_macros.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/task_macros.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 # define D_NLINES 100
 # define prompt "> "
Index: /trunk/Ohana/src/opihi/pantasks/task_nmax.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task_nmax.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/task_nmax.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int task_nmax (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/task_periods.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task_periods.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/task_periods.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int task_periods (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/task_trange.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/task_trange.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/task_trange.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 int task_trange (int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pantasks/verbose.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/verbose.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/verbose.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 
 static int VERBOSE = FALSE;
Index: /trunk/Ohana/src/opihi/pantasks/version.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/version.c	(revision 6686)
+++ /trunk/Ohana/src/opihi/pantasks/version.c	(revision 6687)
@@ -1,3 +1,3 @@
-# include "psched.h"
+# include "pantasks.h"
 static char *name = "$Name: not supported by cvs2svn $";
 
