Index: trunk/psModules/test/camera/tap_pmFPAMaskW.c
===================================================================
--- trunk/psModules/test/camera/tap_pmFPAMaskW.c	(revision 14882)
+++ trunk/psModules/test/camera/tap_pmFPAMaskW.c	(revision 15987)
@@ -6,8 +6,4 @@
 #include "pstap.h"
 // XXX: Use better name for the temporary FITS file
-// XXX: The code to generate and free the FPA hierarchy was copied from
-// tap-pmFPA.c.  EIther include it directly, or library, or something.
-// Also, get rid of the manual free functions and use psFree() once
-// it correctly frees child members
 // XXX: For the genSimpleFPA() code, add IDs to each function so that
 // the values set in each chip-?cell-?hdu-?image are unique
@@ -98,10 +94,14 @@
     cell->hdu = pmHDUAlloc("cellExtName");
     for (int i = 0 ; i < NUM_READOUTS ; i++) {
-        cell->readouts->data[i] = generateSimpleReadout(cell);
-    }
-
-    bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
+        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
+    }
+
+    // First try to read data from ../dataFiles, then try dataFiles.
+    bool rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     if (!rc) {
-        diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
+        rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
+        if (!rc) {
+            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
+	}
     }
 
@@ -119,7 +119,6 @@
 
     //XXX: Should the region be set some other way?  Like through the various config files?
-//    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
     psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
-    // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
+    // You shouldn't have to remove the key from the metadata.
     psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC");
     psMetadataAddPtr(cell->concepts, PS_LIST_TAIL|PS_META_REPLACE, "CELL.TRIMSEC", PS_DATA_REGION, "I am a region", region);
@@ -139,19 +138,9 @@
     psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
     psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
-//    chip->hdu = pmHDUAlloc("chipExtName");
-//
-//    bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
-//    if (!rc) {
-//        diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
-//    }
-//
+
     psArrayRealloc(chip->cells, NUM_CELLS);
     for (int i = 0 ; i < NUM_CELLS ; i++) {
-        chip->cells->data[i] = generateSimpleCell(chip);
-    }
-
-    // XXX: Add code to initialize chip pmConcepts
-
-
+        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
+    }
     return(chip);
 }
@@ -170,50 +159,11 @@
     psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
     psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
-//    fpa->hdu = pmHDUAlloc("fpaExtName");
-//
-//    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
-//    if (!rc) {
-//        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
-//    }
 
     psArrayRealloc(fpa->chips, NUM_CHIPS);
     for (int i = 0 ; i < NUM_CHIPS ; i++) {
-        fpa->chips->data[i] = generateSimpleChip(fpa);
-    }
-
-    // XXX: Eventually, when you finish the pmConcepts tests, add full concept
-    // reading code from wherever.
+        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
+    }
     pmConceptsBlankFPA(fpa);
-//    bool mdok;
-//    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
-//    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
-//    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
-
     return(fpa);
-}
-
-// XXX: This should only be necessary until the psFree() functions for
-// FPA/chip/cell/readout correctly free all child chips/cells/readouts
-void myFreeCell(pmCell *cell)
-{
-    for (int k = 0 ; k < cell->readouts->n ; k++) {
-        psFree(cell->readouts->data[k]);
-    }
-    psFree(cell);
-}
-
-void myFreeChip(pmChip *chip) {
-    for (int j = 0 ; j < chip->cells->n ; j++) {
-        myFreeCell(chip->cells->data[j]);
-    }
-    psFree(chip);
-}
-
-void myFreeFPA(pmFPA *fpa)
-{
-    for (int i = 0 ; i < fpa->chips->n ; i++) {
-        myFreeChip(fpa->chips->data[i]);
-    }
-    psFree(fpa);
 }
 
@@ -309,5 +259,5 @@
 	}
         ok(!errorFlag, "pmReadoutSetMask() set the mask values correctly");
-        myFreeFPA(fpa);    
+        psFree(fpa);    
         psFree(camera);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -395,5 +345,5 @@
         ok(!errorFlag, "pmReadoutGenerateMask() set the mask values correctly");
 
-        myFreeFPA(fpa);    
+        psFree(fpa);    
         psFree(camera);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
@@ -467,11 +417,8 @@
 
         ok(!errorFlag, "pmReadoutSetWeight() set the weight values correctly (Poisson)");
-        myFreeFPA(fpa);    
+        psFree(fpa);    
         psFree(camera);
         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     }
-
-
-
-}
-
+}
+
