Index: trunk/psModules/src/camera/pmFPACopy.c
===================================================================
--- trunk/psModules/src/camera/pmFPACopy.c	(revision 8848)
+++ trunk/psModules/src/camera/pmFPACopy.c	(revision 9589)
@@ -22,5 +22,5 @@
 // Bin a region down by specified factors in x and y
 static void binRegion(psRegion *region, // Region to be binned
-                      int xBin, int yBin// Binning in x and y
+                      int xBin, int yBin // Binning in x and y
                      )
 {
@@ -38,5 +38,5 @@
 
 // Find the blank (image-less) PHU, given a cell.
-static pmHDU *findBlankPHU(const pmCell *cell// The cell for which to find the PHU
+static pmHDU *findBlankPHU(const pmCell *cell // The cell for which to find the PHU
                           )
 {
@@ -63,6 +63,8 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
+// Common engine for pmCellCopy and pmCellCopyStructure
+// Does the actual splitting/splicing that's required to copy an FPA to a different representation.
 static bool cellCopy(pmCell *target,     // The target cell
-                     pmCell *source,     // The source cell, to be copied
+                     const pmCell *source, // The source cell, to be copied
                      bool pixels,        // Copy the pixels?
                      int xBin, int yBin  // (Relative) binning factors in x and y
@@ -249,5 +251,6 @@
         psTrace("psModules.camera", 3, "CELL.X0: Before: %d After: %d\n", xZero,
                 xZero - (readout->image->numCols - 1) * xParity * xBin);
-        psTrace("psModules.camera", 9, "(xParity: %d xBin: %d numCols: %d)\n", xParity, xBin, readout->image->numCols);
+        psTrace("psModules.camera", 9, "(xParity: %d xBin: %d numCols: %d)\n",
+                xParity, xBin, readout->image->numCols);
         xZero -= (readout->image->numCols - 1) * xParity * xBin; // Change the parity on the X0 position
         psMetadataItem *newItem = psMetadataLookup(target->concepts, "CELL.X0"); // CELL.X0 from target
@@ -261,5 +264,6 @@
         psTrace("psModules.camera", 3, "CELL.Y0: Before: %d After: %d\n", yZero,
                 yZero - (readout->image->numRows - 1) * yParity * yBin);
-        psTrace("psModules.camera", 9, "(yParity: %d yBin: %d numRows: %d)\n", yParity, yBin, readout->image->numRows);
+        psTrace("psModules.camera", 9, "(yParity: %d yBin: %d numRows: %d)\n",
+                yParity, yBin, readout->image->numRows);
         yZero -= (readout->image->numRows - 1) * yParity * yBin; // Change the parity on the Y0 position
         psMetadataItem *newItem = psMetadataLookup(target->concepts, "CELL.Y0"); // CELL.Y0 from target
@@ -294,6 +298,8 @@
 }
 
+// Common engine for pmChipCopy and pmChipCopyStructure
+// Iterate on the components
 static bool chipCopy(pmChip *target,          // The target chip
-                     pmChip *source,          // The source chip, to be copied
+                     const pmChip *source, // The source chip, to be copied
                      bool pixels,             // Copy the pixels?
                      int xBin, int yBin       // (Relative) binning factors in x and y
@@ -308,5 +314,6 @@
     psArray *sourceCells = source->cells; // The source cells
     if (targetCells->n != sourceCells->n) {
-        psError(PS_ERR_IO, true, "Number of source cells (%ld) differs from the number of target cells (%ld)\n",
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "Number of source cells (%ld) differs from the number of target cells (%ld)\n",
                 sourceCells->n, targetCells->n);
         return false;
@@ -331,8 +338,10 @@
 }
 
-static bool fpaCopy(pmFPA *target,            // The target FPA
-                    pmFPA *source,            // The source FPA, to be copied
-                    bool pixels,              // Copy the pixels?
-                    int xBin, int yBin        // (Relative) binning factors in x and y
+// Common engine for pmFPACopy and pmFPACopyStructure.
+// Iterate on the components
+static bool fpaCopy(pmFPA *target,      // The target FPA
+                    const pmFPA *source, // The source FPA, to be copied
+                    bool pixels,        // Copy the pixels?
+                    int xBin, int yBin  // (Relative) binning factors in x and y
                    )
 {
@@ -345,5 +354,6 @@
     psArray *sourceChips = source->chips; // The source chips
     if (targetChips->n != sourceChips->n) {
-        psError(PS_ERR_IO, true, "Number of source chips (%ld) differs from the number of target chips (%ld)\n",
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "Number of source chips (%ld) differs from the number of target chips (%ld)\n",
                 sourceChips->n, targetChips->n);
         return false;
@@ -371,7 +381,5 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-bool pmFPACopy(pmFPA *target,            // The target FPA
-               pmFPA *source             // The source FPA, to be copied
-              )
+bool pmFPACopy(pmFPA *target, const pmFPA *source)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
@@ -380,7 +388,5 @@
 }
 
-bool pmChipCopy(pmChip *target,          // The target chip
-                pmChip *source           // The source chip, to be copied
-               )
+bool pmChipCopy(pmChip *target, const pmChip *source)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
@@ -389,7 +395,5 @@
 }
 
-bool pmCellCopy(pmCell *target,          // The target cell
-                pmCell *source           // The source cell, to be copied
-               )
+bool pmCellCopy(pmCell *target, const pmCell *source)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
@@ -399,8 +403,5 @@
 
 
-bool pmFPACopyStructure(pmFPA *target,   // The target FPA
-                        pmFPA *source,   // The source FPA, to be copied
-                        int xBin, int yBin // Binning factors in x and y
-                       )
+bool pmFPACopyStructure(pmFPA *target, const pmFPA *source, int xBin, int yBin)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
@@ -411,8 +412,5 @@
 }
 
-bool pmChipCopyStructure(pmChip *target, // The target chip
-                         pmChip *source, // The source chip, to be copied
-                         int xBin, int yBin // Binning factors in x and y
-                        )
+bool pmChipCopyStructure(pmChip *target, const pmChip *source, int xBin, int yBin)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
@@ -423,8 +421,5 @@
 }
 
-bool pmCellCopyStructure(pmCell *target, // The target cell
-                         pmCell *source, // The source cell, to be copied
-                         int xBin, int yBin // Binning factors in x and y
-                        )
+bool pmCellCopyStructure(pmCell *target, const pmCell *source, int xBin, int yBin)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
