/*******************************************************************************
*                                                                              *
* Société de Transports de Montréal.                                    	   *
* 2012                                                                         *
*                                                                              *
* Projet Zones Tests                                                           *
*                                                                              *
*                                                                              *
*                                                                              *
*******************************************************************************/
/*
    Description:
    Description du fichier si nécessaire.
    
*/

/* ************************************************************************** */
/* Revision:
### 20121220 JFM
    Verision d'origine.
    
### YYYYMMDD Description du besoin ou du bug
    Description du changement.
 */

/* ************************************************************************** */

#ifndef COTEVERTU_H
#define COTEVERTU_H
#include "Station.h"

#define COTEVERTU_STATION_KEY 0x0020000
#define COTEVERTU_NB_EXTERNAL_INPUT_430_MODULES 1
#define COTEVERTU_NB_EXTERNAL_OUTPUT_440_MODULES 1
#define COTEVERTU_NB_EXTERNAL_MIXED_470_MODULES 0

//Since it's necessary to execute a very fast acquisition and analysis
//of magnetic sensors through the PCI I/O adapter, we will use masks
//instead of bitfields for those sensors.  This will accelerate
//treatment by avoiding the use of a memcpy().
#define COTEVERTU_ZT1_S1_MASK 0x00000001
#define COTEVERTU_ZT1_S2_MASK 0x00000002
#define COTEVERTU_ZT1_PI_MASK 0x00000004
#define COTEVERTU_ZT1_PE_MASK 0x00000008
#define COTEVERTU_ZT1_FN_MASK 0x00000010
#define COTEVERTU_ZT2_S1_MASK 0x00000020
#define COTEVERTU_ZT2_PI_MASK 0x00000040
#define COTEVERTU_ZT2_PE_MASK 0x00000080

//External (ethernet) input module masks for Cote Vertu
#define COTEVERTU_IN_CDV_12A_MASK	 0x00000001
#define COTEVERTU_IN_CDV_12B_MASK	 0x00000002
#define COTEVERTU_IN_CDV_11B_MASK	 0x00000004
#define COTEVERTU_IN_CDV_11A_MASK	 0x00000008
#define COTEVERTU_IN_CDV_10B_MASK	 0x00000010
#define COTEVERTU_IN_CDV_13A_MASK	 0x00000020
#define COTEVERTU_IN_CDV_14A_MASK	 0x00000040
#define COTEVERTU_IN_CDV_13B_MASK    0x00000080
#define COTEVERTU_IN_CDV_14B_MASK	 0x00000100
#define COTEVERTU_IN_ZT1_10_12_ITI_MASK	 0x00000200
#define COTEVERTU_IN_ZT2_ITI_MASK	 0x00000400
#define COTEVERTU_IN_ZT1_AN_MASK	 0x00000800
#define COTEVERTU_IN_ZT2_AN_MASK	 0x00001000
#define COTEVERTU_IN_ZT1_ARF_MASK	 0x00002000
#define COTEVERTU_IN_ZT2_ARF_MASK	 0x00004000
#define COTEVERTU_IN_CDV_21B_MASK    0x00080000     //22.1
#define COTEVERTU_IN_CDV_22A_MASK    0x00100000     //22.2
#define COTEVERTU_IN_CDV_22B_MASK    0x00200000     //23.1
#define COTEVERTU_IN_ZT1_10_22_ITI_MASK  0x00400000     //23.2
#define COTEVERTU_IN_CDV_2S177_179_MASK  0x00800000     //24.1
#define COTEVERTU_IN_RES_24_2        0x01000000
#define COTEVERTU_IN_CDV_11C_MASK    0x02000000     //25.1
#define COTEVERTU_IN_CDV_21A_MASK    0x04000000     //25.2
#define COTEVERTU_IN_CDV_21C_MASK    0x08000000     //26.1
#define COTEVERTU_IN_RES_26_2        0x10000000
#define COTEVERTU_IN_RES_27_1        0x20000000
#define COTEVERTU_IN_RES_27_2        0x40000000
#define COTEVERTU_IN_RES_28_1        0x80000000

#define COTEVERTU_IN_STATION_ID_MASK 0x00078000


//External (ethernet) output module masks for Cote Vertu
#define COTEVERTU_OUT_VP1_MASK		0x00000001
#define COTEVERTU_OUT_VP2_MASK		0x00000002
#define COTEVERTU_OUT_VP3_MASK		0x00000004
#define COTEVERTU_OUT_VP4_MASK		0x00000008
#define COTEVERTU_OUT_VP5_MASK		0x00000010
#define COTEVERTU_OUT_VP6_MASK		0x00000020
#define COTEVERTU_OUT_VF1_MASK		0x00000040
#define COTEVERTU_OUT_VF2_MASK		0x00000080
#define COTEVERTU_OUT_VF3_MASK		0x00000100
#define COTEVERTU_OUT_VF4_MASK		0x00000200
#define COTEVERTU_OUT_VF5_MASK		0x00000400
#define COTEVERTU_OUT_WP1_MASK		0x00000800
#define COTEVERTU_OUT_WP2_MASK		0x00001000
#define COTEVERTU_OUT_WP3_MASK		0x00002000
#define COTEVERTU_OUT_WP4_MASK		0x00004000
#define COTEVERTU_OUT_WP5_MASK		0x00008000
#define COTEVERTU_OUT_WP6_MASK		0x00010000
#define COTEVERTU_OUT_DPE_MASK		0x00020000
#define COTEVERTU_OUT_DPI_MASK		0x00040000
#define COTEVERTU_OUT_V00_MASK		0x00080000
#define COTEVERTU_OUT_DPG_MASK		0x00100000
#define COTEVERTU_OUT_DFR_MASK		0x00200000
#define COTEVERTU_OUT_RF_MASK		0x00400000
#define COTEVERTU_OUT_RF2_MASK		0x00800000
#define COTEVERTU_OUT_VEL_MASK		0x01000000
#define COTEVERTU_OUT_VEL2_MASK		0x02000000
#define COTEVERTU_OUT_DPI2_MASK		0x04000000
#define COTEVERTU_OUT_DPE2_MASK		0x08000000
#define COTEVERTU_OUT_V002_MASK		0x10000000
#define COTEVERTU_OUT_PEQ1_MASK     0x20000000
#define COTEVERTU_OUT_PEQ2_MASK     0x40000000
#define COTEVERTU_OUT_WATCHDOG_MASK 0x80000000

#define COTEVERTU_SDF_ACQUISITION_CHANNEL 0

class CCoteVertuStation : public CStation
{
public:

    CCoteVertuStation();
    virtual GenericInputMasks_t *GetInputMasks(void);
    virtual unsigned int UpdateStationMasks(unsigned int ExtInputData);
    virtual int GetCurrentITI();
    virtual bool IsZT1AlarmAutoAcquireCDVOccupied();


private:

    virtual unsigned int BuildStationCDVList();

    int mCurZT1Itinerary;
    CCDV *m10_12AlarmAutoAcquireCDV_1,*m10_12AlarmAutoAcquireCDV_2, *m10_22AlarmAutoAcquireCDV_1, *m10_22AlarmAutoAcquireCDV_2;
    CCDV *m10_12SubsequentCDV, *m10_22SubsequentCDV;

    enum eCoteVertuZT1Itineraries
    {
        COTEVERTU_ZT1_10_12_ITINERARY,
        COTEVERTU_ZT1_10_22_ITINERARY,
        COTEVERTU_ZT1_NO_ITINERARY
    };
};

#endif // COTEVERTU_H

