IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16344


Ignore:
Timestamp:
Feb 6, 2008, 2:09:40 PM (18 years ago)
Author:
Paul Price
Message:

Adding function to activate single file out of a list.

Location:
trunk/psModules/src/camera
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAfileIO.c

    r16257 r16344  
    914914// set the state of the specified pmFPAfile to active (state == true) or inactive
    915915// if name is NULL, set the state for all pmFPAfiles
    916 bool pmFPAfileActivate (psMetadata *files, bool state, char *name)
     916bool pmFPAfileActivate (psMetadata *files, bool state, const char *name)
    917917{
    918918    PS_ASSERT_PTR_NON_NULL(files, false);
     
    963963    return true;
    964964}
     965
     966
     967pmFPAfile *pmFPAfileActivateSingle(psMetadata *files, bool state, const char *name, int num)
     968{
     969    PS_ASSERT_PTR_NON_NULL(files, NULL);
     970    PS_ASSERT_STRING_NON_EMPTY(name, NULL);
     971    PS_ASSERT_INT_NONNEGATIVE(num, NULL);
     972
     973    psString regex = NULL;              // Regular expression for psMetadataIteratorAlloc
     974    psStringAppend(&regex, "^%s$", name);
     975
     976    int i = 0;                          // Counter
     977    psMetadataItem *item = NULL;        // Item from iteration
     978    psMetadataIterator *iter = psMetadataIteratorAlloc(files, PS_LIST_HEAD, regex); // Iterator
     979    psFree(regex);
     980    while ((item = psMetadataGetAndIncrement(iter))) {
     981        if (i++ == num) {
     982            pmFPAfile *file = item->data.V; // File of interest
     983            if (state) {
     984                file->state &= PS_NOT_U8(PM_FPA_STATE_INACTIVE);
     985            } else {
     986                file->state |= PM_FPA_STATE_INACTIVE;
     987            }
     988            psFree(iter);
     989            return file;
     990        }
     991    }
     992    psFree(iter);
     993    return NULL;
     994}
  • trunk/psModules/src/camera/pmFPAfileIO.h

    r12832 r16344  
    33 *
    44 * @author EAM, IfA
     5 * @author PAP, IfA
    56 *
    6  * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    7  * @date $Date: 2007-04-14 03:22:47 $
     7 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     8 * @date $Date: 2008-02-07 00:09:40 $
    89 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
    910 */
     
    3435// set the state of the specified pmFPAfile to active (state == true) or inactive
    3536// if name is NULL, set the state for all pmFPAfiles
    36 bool pmFPAfileActivate (psMetadata *files, bool state, char *name);
     37bool pmFPAfileActivate (psMetadata *files, bool state, const char *name);
     38
     39/// Set the state of a single pmFPAfile (in the case of multiple files with the same name)
     40///
     41/// Returns file activated
     42pmFPAfile *pmFPAfileActivateSingle(psMetadata *files, ///< Files to activate
     43                                   bool state, ///< State to set
     44                                   const char *name, ///< Name of file to activate
     45                                   int num    ///< Sequence numbner of file to activate
     46    );
    3747
    3848// examine all pmFPAfiles listed in the files and perform the needed I/O operations (open,read,write,close)
Note: See TracChangeset for help on using the changeset viewer.