//
//  Copyright © 2003, RESON Inc. All Rights Reserved.
//
//  No part of this file may be reproduced or transmitted in any form or by
//  any means, electronic or mechanical, including photocopy, recording, or
//  information storage or retrieval system, without permission in writing
//  from RESON Inc.
//
//  Filename:   7kTrigger.h
//
//  Project:    6046
//
//  Author(s):  W. Arcus
//
//  Purpose:    C7kTrigger 
//
//  Notes:      
//

#if !defined(AFX_7KTRIGGER_H__663843F8_9A34_46B2_9E99_3D5EC43D2AD9__INCLUDED_)
#define AFX_7KTRIGGER_H__663843F8_9A34_46B2_9E99_3D5EC43D2AD9__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#pragma pack( push, C7KTRIGGER_H_PACK, 1 )

typedef struct tagTRIGGERINFO                                                           // 7k remote control trigger command info.
{
    unsigned long       m_ulTriggerId;                                                  // Trigger identifier. 
    unsigned long       m_ulPortId;                                                     // The port to which the trigger maps.
    unsigned short      m_unTriggerType;                                                // 0 – High Z, 1 – TTL, 2 – Software
    BYTE                m_byDirection;                                                  // 0 – IN, 1 – OUT
    BYTE                m_bySense;                                                      // 0 – Positive, 1 – Negative.
    unsigned long       m_ulPulseLength;                                                // Pulse length in microseconds.
}
TRIGGERINFO, *PTRIGGERINFO;

#pragma pack( pop, C7KTRIGGER_H_PACK )

class EXPORT_DLL C7kTrigger : private tagTRIGGERINFO
{
public:

    ////////////////
    // Definitions.

    enum ETRIGGERTYPE
    {
        triggerTypeHighZ        = 0,
        triggerTypeTTL,
        triggerTypeSoftware
    };

    enum ETRIGGERDIRECTION
    {
        triggerDirectionIn      = 0,
        triggerDirectionOut
    };

    enum ETRIGGERSENSE
    {
        triggerSensePositive    = 0,
        triggerSenseNegative
    };

    ////////////////
    // Services.

                        C7kTrigger                      (   void );
                        C7kTrigger                      (   const C7kTrigger           &rRhs );

    virtual            ~C7kTrigger                      (   void );

    C7kTrigger &        operator =                      (   const C7kTrigger           &rRhs );
    bool                operator ==                     (   const unsigned long        &rulTriggerId ) const;
    bool                operator <                      (   const C7kTrigger           &rRhs )         const;
                        operator const TRIGGERINFO *    (   void )                                     const;

    void                Configure                       (   const unsigned long        &rulPortId,
                                                            const ETRIGGERTYPE         &reTriggerType,
                                                            const ETRIGGERDIRECTION    &reDirection,
                                                            const ETRIGGERSENSE        &reSense,
                                                            const unsigned long        &rulPulseLength );

    void                SequenceId                      (   const unsigned long        &rulSequenceId );

    void                Enable                          (   void );
    void                Disable                         (   void );

    // Read only methods.

    bool                IsEnabled                       (   void )  const;
    unsigned long       Id                              (   void )  const;

    unsigned long       PortId                          (   void )  const;
    unsigned short      TriggerType                     (   void )  const;
    BYTE                Direction                       (   void )  const;
    BYTE                Sense                           (   void )  const;
    unsigned long       PulseLength                     (   void )  const;
    unsigned long       SequenceId                      (   void )  const;

private:

    ////////////////
    // Attributes.

    bool                m_bEnabled;
    unsigned long       m_ulSequenceId;

    ////////////////
    // Services.

    void                Id                              (   const unsigned long        &rulTriggerId );         // For the exclusive use by the trigger controller.

};

#endif // !defined(AFX_7KTRIGGER_H__663843F8_9A34_46B2_9E99_3D5EC43D2AD9__INCLUDED_)
