Index: trunk/ippTools/src/chiptool.c
===================================================================
--- trunk/ippTools/src/chiptool.c	(revision 14120)
+++ trunk/ippTools/src/chiptool.c	(revision 14214)
@@ -93,5 +93,5 @@
 }
 
-#define ADDRENAMEPARAMSTR(from, to, oldname, newname) \
+#define ADDRENAMEPARAMSTR(from, to, oldname, newname, comment) \
 { \
     bool status = false; \
@@ -102,5 +102,5 @@
     } \
     if (str) { \
-        if (!psMetadataAddStr(to, PS_LIST_TAIL, newname, 0, "==", str)) { \
+        if (!psMetadataAddStr(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, str)) { \
             psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
             psFree(to); \
@@ -110,17 +110,18 @@
 }
 
-#define ADDPARAMSTR(from, to, name) ADDRENAMEPARAMSTR(from, to, name, name)
-
-#define ADDPARAMF(from, to, type, name) \
+#define ADDPARAMSTR(from, to, name) \
+  ADDRENAMEPARAMSTR(from, to, name, name, "==")
+
+#define ADDRENAMEPARAMF(from, to, type, oldname, newname, comment) \
 { \
     bool status = false; \
-    ps##type var = psMetadataLookup##type(&status, from, "-" name); \
+    ps##type var = psMetadataLookup##type(&status, from, "-" oldname); \
     if (!status) { \
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" name); \
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -" oldname); \
         return false; \
     } \
     if (!isnan(var)) { \
-        if (!psMetadataAdd##type(to, PS_LIST_TAIL, #name, 0, "==", var)) { \
-            psError(PS_ERR_UNKNOWN, false, "failed to add item " name); \
+        if (!psMetadataAdd##type(to, PS_LIST_TAIL, newname, PS_META_DUPLICATE_OK, comment, var)) { \
+            psError(PS_ERR_UNKNOWN, false, "failed to add item " newname); \
             psFree(to); \
             return false; \
@@ -129,4 +130,7 @@
 }
 
+#define ADDPARAMF(from, to, type, name) \
+  ADDRENAMEPARAMF(from, to, type, name, name, "==")
+
 static bool queueMode(pxConfig *config)
 {
@@ -134,25 +138,57 @@
 
     psMetadata *where = psMetadataAlloc();
-    ADDPARAMSTR(config->args, where, "exp_id");
+    // convert exp_id into a psS64
+{
+    bool status = false;
+    psString var = psMetadataLookupStr(&status, config->args, "-exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
+        return false;
+    }
+    if (var) {
+        if (!psMetadataAddS64(where, PS_LIST_TAIL, "exp_id", 0, "==", (psS64)atoll(var))) {
+            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
+            psFree(where);
+            return false; 
+        }
+    }
+}
     ADDPARAMSTR(config->args, where, "exp_name");
-    ADDRENAMEPARAMSTR(config->args, where, "inst", "camera");
+    ADDRENAMEPARAMSTR(config->args, where, "inst", "camera", "==");
     ADDPARAMSTR(config->args, where, "telescope");
-    ADDPARAMSTR(config->args, where, "dateobs");
+    ADDPARAMSTR(config->args, where, "dateobs_begin");
+    ADDPARAMSTR(config->args, where, "dateobs_end");
+    ADDPARAMSTR(config->args, where, "exp_tag");
     ADDPARAMSTR(config->args, where, "exp_type");
-    ADDPARAMSTR(config->args, where, "imfiles");
-    ADDPARAMSTR(config->args, where, "workdir");
+    ADDPARAMSTR(config->args, where, "filelevel");
+    ADDPARAMSTR(config->args, where, "reduction");
     ADDPARAMSTR(config->args, where, "filter");
-    ADDPARAMF(config->args, where, F32, "airmass");
-    ADDPARAMF(config->args, where, F32, "ra");
-    ADDPARAMF(config->args, where, F32, "decl");
-    ADDPARAMF(config->args, where, F32, "exp_time");
-    ADDPARAMF(config->args, where, F32, "bg");
-    ADDPARAMF(config->args, where, F32, "bg_stdev");
-    ADDPARAMF(config->args, where, F32, "bg_mean_stdev");
-    ADDPARAMF(config->args, where, F64, "alt");
-    ADDPARAMF(config->args, where, F64, "az");
-    ADDPARAMF(config->args, where, F32, "ccd_temp");
-    ADDPARAMF(config->args, where, F64, "posang");
+    ADDRENAMEPARAMF(config->args, where, F64, "airmass_min", "airmass", ">=");
+    ADDRENAMEPARAMF(config->args, where, F64, "airmass_max", "airmass", "<");
+    ADDRENAMEPARAMF(config->args, where, F64, "ra_min", "ra", ">=");
+    ADDRENAMEPARAMF(config->args, where, F64, "ra_max", "ra", "<");
+    ADDRENAMEPARAMF(config->args, where, F64, "decl_min", "decl", ">=");
+    ADDRENAMEPARAMF(config->args, where, F64, "decl_max", "decl", "<");
+    ADDRENAMEPARAMF(config->args, where, F32, "exp_time_min", "exp_time", ">=");
+    ADDRENAMEPARAMF(config->args, where, F32, "exp_time_max", "exp_time", "<");
+    ADDRENAMEPARAMF(config->args, where, F32, "sat_pixel_frac_min", "sat_pixel_frac", ">=");
+    ADDRENAMEPARAMF(config->args, where, F32, "sat_pixel_frac_max", "sat_pixel_frac", "<");
+    ADDRENAMEPARAMF(config->args, where, F64, "bg_min", "bt", ">=");
+    ADDRENAMEPARAMF(config->args, where, F64, "bg_max", "bt", "<");
+    ADDRENAMEPARAMF(config->args, where, F64, "bg_stdev_min", "bg_stdev", ">=");
+    ADDRENAMEPARAMF(config->args, where, F64, "bg_stdev_max", "bg_stdev", "<");
+    ADDRENAMEPARAMF(config->args, where, F64, "bg_mean_stdev_min", "bg_mean_stdev", ">=");
+    ADDRENAMEPARAMF(config->args, where, F64, "bg_mean_stdev_max", "bg_mean_stdev", "<");
+    ADDRENAMEPARAMF(config->args, where, F64, "alt_min", "alt", ">=");
+    ADDRENAMEPARAMF(config->args, where, F64, "alt_max", "alt", "<");
+    ADDRENAMEPARAMF(config->args, where, F64, "az_min", "az", ">=");
+    ADDRENAMEPARAMF(config->args, where, F64, "az_max", "az", "<");
+    ADDRENAMEPARAMF(config->args, where, F32, "ccd_temp_min", "ccd_temp", ">=");
+    ADDRENAMEPARAMF(config->args, where, F32, "ccd_temp_max", "ccd_temp", "<");
+    ADDRENAMEPARAMF(config->args, where, F64, "posang_min", "posang", ">=");
+    ADDRENAMEPARAMF(config->args, where, F64, "posang_max", "posang", "<");
     ADDPARAMSTR(config->args, where, "object");
+    ADDRENAMEPARAMF(config->args, where, F32, "solang_min", "solang", ">=");
+    ADDRENAMEPARAMF(config->args, where, F32, "solang_max", "solang", "<");
 
     if (where->list->n < 1) {
@@ -236,5 +272,5 @@
         psMetadata *md = output->data[i];
 
-        psString exp_id = psMetadataLookupStr(&status, md, "exp_id");
+        psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id");
         if (!status) {
             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_id");
@@ -249,5 +285,5 @@
             }
             psError(PS_ERR_UNKNOWN, false,
-                    "failed to trying to queue exp_id: %s", exp_id);
+                    "failed to trying to queue exp_id: %" PRId64, exp_id);
             psFree(output);
             return false;
