/* ===========================================================================

  slideShowFunc.h    Global variables and functions for  SlideShowFunc 

=============================================================================*/
#ifdef SLIDESHOW_FUNC_ALLOCATE
#define EXTERN
#else
#define EXTERN extern
#endif

struct SlideListReply
{
          struct ymds_time Time;
          UINT2 iSite;
          UINT2 lNewTime;
          UINT4 iPType;
          char  sPName[16];     /* Product name, null terminated */
          UINT4 iDwellTime;
          UINT4 iImageOffset;
          UINT2 lFilled;        /* Slot is filled with an image */
};

#define MAX_SLIDES_IN_SHOW 16

#ifdef SIGMET_PROJECTION_H
class SlideShowFunc 
{
  public:
  
    SlideShowFunc(void);           /* Constructor */
    UINT4 iCurrentVtvMapServer[256];
    void  init(void);         /* Initialize after shared memory is mapped */
    void  notifyPeerEntered( void );         /* Another mode entered */
    void  slideShowStart(void);
    void  slideShowStop(void);
    void  loadSlideShow(void);
    void  enableSlideShow(UINT2 lenable_a);
    void  newImage(void);     /* Call when a new image has arrived */
    void processServerReply            /* LOOP reply from server */
     ( char *stoks_a[8], const char *pdata, SINT4 isize );
    void slideSwitchFrame(void );       /* Do not call from outside file */
    UINT2 getSlideIdxAndPauseTime(UINT4 *islide_show_idx_a, UINT4 *ipause_time_a);
    UINT2   lSlideShowEnabled_c;    /* slide show */

  private:
    /* Note that the private storage must be placed after the public, and
     * ifdef'ed off altogether.  This is to prevent mis allignments if
     * we ifdef off individual elements.
     */
#ifdef SLIDESHOW_FUNC_ALLOCATE
    /* Information about the previous image on the screen */
    UINT2   lPreviousValid_c;
    UINT2   iPreviousSiteNum_c;
    UINT2   iPreviousPType_c;
    char    sPreviousPName_c[12];
    struct ymds_time  PreviousTime_c;

    /* Array of onscreen structures */
    struct on_screen_picture8 OnScreenArray_c[MAX_SLIDES_IN_SHOW];
    /* Array of info about products we may use in the loop. */
    struct SlideListReply slideListReply_c[MAX_SLIDES_IN_SHOW];
    UINT4   iCurSlideLoopIdx_c;       /* Index of where we are in the loop */
    UINT4   iCurSlideLoadIdx_c;       /* Keep Track of slide index loading */
    UINT4   iSlidesInShow_c;          
    UINT4   iTotalDwellTime_c;        
    UINT4   iSlideIdxOfMaxDwellTime_c;

    /* Slide Show */
    struct SlideShowList slideShowList_c[MAX_SLIDES_IN_SHOW];
    UINT2   lDiscardNextFrame_c;    // Discard the next frame (might be loop loading frame)

    SINT4   iLoopFrameSize_c;       /* Size of one frame in the loop in bytes */


    /* These are used to detect whether the loop buffer needs to be erased.  Note
     * that any frame arriving with a size which does not match the iLoopFrameSize_c
     * above must force clearing these variables.
     */
    UINT4   iPreviousLoopPType_c;
    char    sPreviousLoopPName_c[16];

    UINT1   *pImageArray_c;             /* Array of images */
    SINT4   iImageArraySize_c;          /* Size of array in bytes, not pixels */

    /*Either or both bits can be on.  If zero, then the loop is off */
#define SLIDESHOW_OFF     (0)
#define SLIDESHOW_LOADING (0x01)
#define SLIDESHOW_RUNNING (0x02)
    UINT4   iSubMode_c;

    /* Functions: */
    void  LoadAnotherSlide(void);
    SINT4 iLookupNewFrame(void);
    SINT4 iLookupNextFrame(void);

    void  processSlideListReply
      (SPHD_SUM *pData_a,
       SINT4 iSize_a );
    void  RequestSlideShowList(void);

#endif  /* #ifdef SLIDESHOW_FUNC_ALLOCATE */
  
};

EXTERN SlideShowFunc slideShowFunc;
#endif  /* #ifdef SIGMET_PROJECTION_H */

#undef EXTERN
