#ifndef PM_READOUT_MASK_WEIGHT_H
#define PM_READOUT_MASK_WEIGHT_H

#include "pmFPA.h"

// these defines are necessary to yield 8-bit results (use instead of ~)
#define NOT_U8(A)(UCHAR_MAX-(A))
#define NOT_U16(A)(USHORT_MAX-(A))

/** Mask values */
typedef enum {
    PM_MASK_CLEAR   = 0x00,   ///< The pixel is not masked
    PM_MASK_TRAP    = 0x01,   ///< The pixel is a charge trap.
    PM_MASK_BADCOL  = 0x02,   ///< The pixel is a bad column.
    PM_MASK_SAT     = 0x04,   ///< The pixel is saturated.
    PM_MASK_BAD     = 0x08,   ///< The pixel is low
    PM_MASK_FLAT    = 0x10,   ///< The pixel is non-positive in the flat-field.
    PM_MASK_MARK    = 0x20,   ///< The pixel is marked as temporarily ignored
    PM_MASK_EXT1    = 0x40,   ///< This mask value is not used
    PM_MASK_EXT2    = 0x80,   ///< This mask value is not used
} pmMaskValue;

// These functions set an extant mask/weight (or create a throwaway one).
// The throwaway case is intended for when the user is iterating using pmReadoutReadNext, in which case
// the HDU can't be generated
bool pmReadoutSetMask(pmReadout *readout // Readout for which to set mask
                     );
bool pmReadoutSetWeight(pmReadout *readout // Readout for which to set weight
                       );

// These functions generate a mask/weight suitable for output (complete with HDU entry) and then set them.
bool pmReadoutGenerateMask(pmReadout *readout // Readout for which to generate mask
                          );
bool pmReadoutGenerateWeight(pmReadout *readout // Readout for which to generate weight
                            );

// These functions are conveniences for pmReadoutGenerateMask and pmReadoutGenerateWeight.
bool pmCellGenerateMaskWeight(pmCell *cell // Cell for which to generate mask and weights
                             );
bool pmReadoutGenerateMaskWeight(pmReadout *readout // Readout for which to generate mask and weights
                                );


#endif
