text:
//*****************************************************************************
//
// timer_a.h - Driver for the TIMER_A Module.
//
//*****************************************************************************

#ifndef __MSP430WARE_TIMER_A_H__
#define __MSP430WARE_TIMER_A_H__

#include "inc/hw_memmap.h"

#ifdef __MSP430_HAS_TxA7__

//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif

#include "inc/hw_memmap.h"
//*****************************************************************************
//
// The following is a parameter used for Timer_A_getCounterValue that
// determines the maximum difference in counts of the TAxR register for a
// majority vote.
//
//*****************************************************************************
#define TIMER_A_THRESHOLD                                                    50

//*****************************************************************************
//
//! \brief Used in the Timer_A_initContinuousMode() function as the param
//! parameter.
//
//*****************************************************************************
typedef struct Timer_A_initContinuousModeParam
{
    //! Selects Clock source.
    //! \n Valid values are:
    //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
    //! - \b TIMER_A_CLOCKSOURCE_ACLK
    //! - \b TIMER_A_CLOCKSOURCE_SMCLK
    //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
    uint16_t clockSource;
    //! Is the desired divider for the clock source
    //! \n Valid values are:
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default]
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_3
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_5
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_6
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_7
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_10
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_12
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_14
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_16
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_20
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_24
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_28
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_32
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_40
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_48
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_56
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_64
    uint16_t clockSourceDivider;
    //! Is to enable or disable Timer_A interrupt
    //! \n Valid values are:
    //! - \b TIMER_A_TAIE_INTERRUPT_ENABLE
    //! - \b TIMER_A_TAIE_INTERRUPT_DISABLE [Default]
    uint16_t timerInterruptEnable_TAIE;
    //! Decides if Timer_A clock divider, count direction, count need to be
    //! reset.
    //! \n Valid values are:
    //! - \b TIMER_A_DO_CLEAR
    //! - \b TIMER_A_SKIP_CLEAR [Default]
    uint16_t timerClear;
    //! Whether to start the timer immediately
    bool startTimer;
} Timer_A_initContinuousModeParam;

//*****************************************************************************
//
//! \brief Used in the Timer_A_initCaptureMode() function as the param
//! parameter.
//
//*****************************************************************************
typedef struct Timer_A_initCaptureModeParam
{
    //! Selects the Capture register being used. Refer to datasheet to ensure
    //! the device has the capture compare register being used.
    //! \n Valid values are:
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
    uint16_t captureRegister;
    //! Is the capture mode selected.
    //! \n Valid values are:
    //! - \b TIMER_A_CAPTUREMODE_NO_CAPTURE [Default]
    //! - \b TIMER_A_CAPTUREMODE_RISING_EDGE
    //! - \b TIMER_A_CAPTUREMODE_FALLING_EDGE
    //! - \b TIMER_A_CAPTUREMODE_RISING_AND_FALLING_EDGE
    uint16_t captureMode;
    //! Decides the Input Select
    //! \n Valid values are:
    //! - \b TIMER_A_CAPTURE_INPUTSELECT_CCIxA
    //! - \b TIMER_A_CAPTURE_INPUTSELECT_CCIxB
    //! - \b TIMER_A_CAPTURE_INPUTSELECT_GND
    //! - \b TIMER_A_CAPTURE_INPUTSELECT_Vcc
    uint16_t captureInputSelect;
    //! Decides if capture source should be synchronized with timer clock
    //! \n Valid values are:
    //! - \b TIMER_A_CAPTURE_ASYNCHRONOUS [Default]
    //! - \b TIMER_A_CAPTURE_SYNCHRONOUS
    uint16_t synchronizeCaptureSource;
    //! Is to enable or disable timer captureComapre interrupt.
    //! \n Valid values are:
    //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE [Default]
    //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE
    uint16_t captureInterruptEnable;
    //! Specifies the output mode.
    //! \n Valid values are:
    //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE [Default]
    //! - \b TIMER_A_OUTPUTMODE_SET
    //! - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET
    //! - \b TIMER_A_OUTPUTMODE_SET_RESET
    //! - \b TIMER_A_OUTPUTMODE_TOGGLE
    //! - \b TIMER_A_OUTPUTMODE_RESET
    //! - \b TIMER_A_OUTPUTMODE_TOGGLE_SET
    //! - \b TIMER_A_OUTPUTMODE_RESET_SET
    uint16_t captureOutputMode;
} Timer_A_initCaptureModeParam;

//*****************************************************************************
//
//! \brief Used in the Timer_A_initUpDownMode() function as the param
//! parameter.
//
//*****************************************************************************
typedef struct Timer_A_initUpDownModeParam
{
    //! Selects Clock source.
    //! \n Valid values are:
    //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
    //! - \b TIMER_A_CLOCKSOURCE_ACLK
    //! - \b TIMER_A_CLOCKSOURCE_SMCLK
    //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
    uint16_t clockSource;
    //! Is the desired divider for the clock source
    //! \n Valid values are:
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default]
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_3
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_5
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_6
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_7
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_10
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_12
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_14
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_16
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_20
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_24
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_28
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_32
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_40
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_48
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_56
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_64
    uint16_t clockSourceDivider;
    //! Is the specified Timer_A period
    uint16_t timerPeriod;
    //! Is to enable or disable Timer_A interrupt
    //! \n Valid values are:
    //! - \b TIMER_A_TAIE_INTERRUPT_ENABLE
    //! - \b TIMER_A_TAIE_INTERRUPT_DISABLE [Default]
    uint16_t timerInterruptEnable_TAIE;
    //! Is to enable or disable Timer_A CCR0 captureComapre interrupt.
    //! \n Valid values are:
    //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE
    //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE [Default]
    uint16_t captureCompareInterruptEnable_CCR0_CCIE;
    //! Decides if Timer_A clock divider, count direction, count need to be
    //! reset.
    //! \n Valid values are:
    //! - \b TIMER_A_DO_CLEAR
    //! - \b TIMER_A_SKIP_CLEAR [Default]
    uint16_t timerClear;
    //! Whether to start the timer immediately
    bool startTimer;
} Timer_A_initUpDownModeParam;

//*****************************************************************************
//
//! \brief Used in the Timer_A_outputPWM() function as the param parameter.
//
//*****************************************************************************
typedef struct Timer_A_outputPWMParam
{
    //! Selects Clock source.
    //! \n Valid values are:
    //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
    //! - \b TIMER_A_CLOCKSOURCE_ACLK
    //! - \b TIMER_A_CLOCKSOURCE_SMCLK
    //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
    uint16_t clockSource;
    //! Is the desired divider for the clock source
    //! \n Valid values are:
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default]
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_3
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_5
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_6
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_7
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_10
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_12
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_14
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_16
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_20
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_24
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_28
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_32
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_40
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_48
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_56
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_64
    uint16_t clockSourceDivider;
    //! Selects the desired timer period
    uint16_t timerPeriod;
    //! Selects the compare register being used. Refer to datasheet to ensure
    //! the device has the capture compare register being used.
    //! \n Valid values are:
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
    uint16_t compareRegister;
    //! Specifies the output mode.
    //! \n Valid values are:
    //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE [Default]
    //! - \b TIMER_A_OUTPUTMODE_SET
    //! - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET
    //! - \b TIMER_A_OUTPUTMODE_SET_RESET
    //! - \b TIMER_A_OUTPUTMODE_TOGGLE
    //! - \b TIMER_A_OUTPUTMODE_RESET
    //! - \b TIMER_A_OUTPUTMODE_TOGGLE_SET
    //! - \b TIMER_A_OUTPUTMODE_RESET_SET
    uint16_t compareOutputMode;
    //! Specifies the dutycycle for the generated waveform
    uint16_t dutyCycle;
} Timer_A_outputPWMParam;

//*****************************************************************************
//
//! \brief Used in the Timer_A_initUpMode() function as the param parameter.
//
//*****************************************************************************
typedef struct Timer_A_initUpModeParam
{
    //! Selects Clock source.
    //! \n Valid values are:
    //! - \b TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK [Default]
    //! - \b TIMER_A_CLOCKSOURCE_ACLK
    //! - \b TIMER_A_CLOCKSOURCE_SMCLK
    //! - \b TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK
    uint16_t clockSource;
    //! Is the desired divider for the clock source
    //! \n Valid values are:
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_1 [Default]
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_2
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_3
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_4
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_5
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_6
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_7
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_8
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_10
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_12
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_14
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_16
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_20
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_24
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_28
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_32
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_40
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_48
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_56
    //! - \b TIMER_A_CLOCKSOURCE_DIVIDER_64
    uint16_t clockSourceDivider;
    //! Is the specified Timer_A period. This is the value that gets written
    //! into the CCR0. Limited to 16 bits[uint16_t]
    uint16_t timerPeriod;
    //! Is to enable or disable Timer_A interrupt
    //! \n Valid values are:
    //! - \b TIMER_A_TAIE_INTERRUPT_ENABLE
    //! - \b TIMER_A_TAIE_INTERRUPT_DISABLE [Default]
    uint16_t timerInterruptEnable_TAIE;
    //! Is to enable or disable Timer_A CCR0 captureComapre interrupt.
    //! \n Valid values are:
    //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE
    //! - \b TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE [Default]
    uint16_t captureCompareInterruptEnable_CCR0_CCIE;
    //! Decides if Timer_A clock divider, count direction, count need to be
    //! reset.
    //! \n Valid values are:
    //! - \b TIMER_A_DO_CLEAR
    //! - \b TIMER_A_SKIP_CLEAR [Default]
    uint16_t timerClear;
    //! Whether to start the timer immediately
    bool startTimer;
} Timer_A_initUpModeParam;

//*****************************************************************************
//
//! \brief Used in the Timer_A_initCompareMode() function as the param
//! parameter.
//
//*****************************************************************************
typedef struct Timer_A_initCompareModeParam
{
    //! Selects the Capture register being used. Refer to datasheet to ensure
    //! the device has the capture compare register being used.
    //! \n Valid values are:
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
    //! - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
    uint16_t compareRegister;
    //! Is to enable or disable timer captureComapre interrupt.
    //! \n Valid values are:
    //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE [Default]
    //! - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE
    uint16_t compareInterruptEnable;
    //! Specifies the output mode.
    //! \n Valid values are:
    //! - \b TIMER_A_OUTPUTMODE_OUTBITVALUE [Default]
    //! - \b TIMER_A_OUTPUTMODE_SET
    //! - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET
    //! - \b TIMER_A_OUTPUTMODE_SET_RESET
    //! - \b TIMER_A_OUTPUTMODE_TOGGLE
    //! - \b TIMER_A_OUTPUTMODE_RESET
    //! - \b TIMER_A_OUTPUTMODE_TOGGLE_SET
    //! - \b TIMER_A_OUTPUTMODE_RESET_SET
    uint16_t compareOutputMode;
    //! Is the count to be compared with in compare mode
    uint16_t compareValue;
} Timer_A_initCompareModeParam;

//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: Timer_A_initContinuousMode(), Timer_A_initUpMode(),
// Timer_A_initUpDownMode(), and Timer_A_outputPWM().
//
//*****************************************************************************
#define TIMER_A_CLOCKSOURCE_DIVIDER_1                                      0x00
#define TIMER_A_CLOCKSOURCE_DIVIDER_2                                      0x08
#define TIMER_A_CLOCKSOURCE_DIVIDER_3                                      0x02
#define TIMER_A_CLOCKSOURCE_DIVIDER_4                                      0x10
#define TIMER_A_CLOCKSOURCE_DIVIDER_5                                      0x04
#define TIMER_A_CLOCKSOURCE_DIVIDER_6                                      0x05
#define TIMER_A_CLOCKSOURCE_DIVIDER_7                                      0x06
#define TIMER_A_CLOCKSOURCE_DIVIDER_8                                      0x18
#define TIMER_A_CLOCKSOURCE_DIVIDER_10                                     0x0C
#define TIMER_A_CLOCKSOURCE_DIVIDER_12                                     0x0D
#define TIMER_A_CLOCKSOURCE_DIVIDER_14                                     0x0E
#define TIMER_A_CLOCKSOURCE_DIVIDER_16                                     0x0F
#define TIMER_A_CLOCKSOURCE_DIVIDER_20                                     0x14
#define TIMER_A_CLOCKSOURCE_DIVIDER_24                                     0x15
#define TIMER_A_CLOCKSOURCE_DIVIDER_28                                     0x16
#define TIMER_A_CLOCKSOURCE_DIVIDER_32                                     0x17
#define TIMER_A_CLOCKSOURCE_DIVIDER_40                                     0x1C
#define TIMER_A_CLOCKSOURCE_DIVIDER_48                                     0x1D
#define TIMER_A_CLOCKSOURCE_DIVIDER_56                                     0x1E
#define TIMER_A_CLOCKSOURCE_DIVIDER_64                                     0x1F

//*****************************************************************************
//
// The following are values that can be passed to the timerMode parameter for
// functions: Timer_A_startCounter().
//
//*****************************************************************************
#define TIMER_A_STOP_MODE                                                  MC_0
#define TIMER_A_UP_MODE                                                    MC_1
#define TIMER_A_CONTINUOUS_MODE                                            MC_2
#define TIMER_A_UPDOWN_MODE                                                MC_3

//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: Timer_A_initContinuousMode(), Timer_A_initUpMode(), and
// Timer_A_initUpDownMode().
//
//*****************************************************************************
#define TIMER_A_DO_CLEAR                                                  TACLR
#define TIMER_A_SKIP_CLEAR                                                 0x00

//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: Timer_A_initContinuousMode(), Timer_A_initUpMode(),
// Timer_A_initUpDownMode(), and Timer_A_outputPWM().
//
//*****************************************************************************
#define TIMER_A_CLOCKSOURCE_EXTERNAL_TXCLK                        TASSEL__TACLK
#define TIMER_A_CLOCKSOURCE_ACLK                                   TASSEL__ACLK
#define TIMER_A_CLOCKSOURCE_SMCLK                                 TASSEL__SMCLK
#define TIMER_A_CLOCKSOURCE_INVERTED_EXTERNAL_TXCLK               TASSEL__INCLK

//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: Timer_A_initContinuousMode(), Timer_A_initUpMode(), and
// Timer_A_initUpDownMode().
//
//*****************************************************************************
#define TIMER_A_TAIE_INTERRUPT_ENABLE                                      TAIE
#define TIMER_A_TAIE_INTERRUPT_DISABLE                                     0x00

//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: Timer_A_initUpMode(), and Timer_A_initUpDownMode().
//
//*****************************************************************************
#define TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE                                 CCIE
#define TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE                                0x00

//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: Timer_A_initCaptureMode(), and Timer_A_initCompareMode().
//
//*****************************************************************************
#define TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE                           0x00
#define TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE                            CCIE

//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: Timer_A_initCaptureMode().
//
//*****************************************************************************
#define TIMER_A_CAPTURE_INPUTSELECT_CCIxA                                CCIS_0
#define TIMER_A_CAPTURE_INPUTSELECT_CCIxB                                CCIS_1
#define TIMER_A_CAPTURE_INPUTSELECT_GND                                  CCIS_2
#define TIMER_A_CAPTURE_INPUTSELECT_Vcc                                  CCIS_3

//*****************************************************************************
//
// The following are values that can be passed to the compareOutputMode
// parameter for functions: Timer_A_setOutputMode(); the param parameter for
// functions: Timer_A_initCaptureMode(), Timer_A_initCompareMode(), and
// Timer_A_outputPWM().
//
//*****************************************************************************
#define TIMER_A_OUTPUTMODE_OUTBITVALUE                                 OUTMOD_0
#define TIMER_A_OUTPUTMODE_SET                                         OUTMOD_1
#define TIMER_A_OUTPUTMODE_TOGGLE_RESET                                OUTMOD_2
#define TIMER_A_OUTPUTMODE_SET_RESET                                   OUTMOD_3
#define TIMER_A_OUTPUTMODE_TOGGLE                                      OUTMOD_4
#define TIMER_A_OUTPUTMODE_RESET                                       OUTMOD_5
#define TIMER_A_OUTPUTMODE_TOGGLE_SET                                  OUTMOD_6
#define TIMER_A_OUTPUTMODE_RESET_SET                                   OUTMOD_7

//*****************************************************************************
//
// The following are values that can be passed to the compareRegister parameter
// for functions: Timer_A_setCompareValue(), and Timer_A_setOutputMode(); the
// captureCompareRegister parameter for functions:
// Timer_A_enableCaptureCompareInterrupt(),
// Timer_A_disableCaptureCompareInterrupt(),
// Timer_A_getCaptureCompareInterruptStatus(),
// Timer_A_getSynchronizedCaptureCompareInput(),
// Timer_A_getOutputForOutputModeOutBitValue(),
// Timer_A_getCaptureCompareCount(),
// Timer_A_setOutputForOutputModeOutBitValue(), and
// Timer_A_clearCaptureCompareInterrupt(); the param parameter for functions:
// Timer_A_initCaptureMode(), Timer_A_initCompareMode(), and
// Timer_A_outputPWM().
//
//*****************************************************************************
#define TIMER_A_CAPTURECOMPARE_REGISTER_0                                  0x02
#define TIMER_A_CAPTURECOMPARE_REGISTER_1                                  0x04
#define TIMER_A_CAPTURECOMPARE_REGISTER_2                                  0x06
#define TIMER_A_CAPTURECOMPARE_REGISTER_3                                  0x08
#define TIMER_A_CAPTURECOMPARE_REGISTER_4                                  0x0A
#define TIMER_A_CAPTURECOMPARE_REGISTER_5                                  0x0C
#define TIMER_A_CAPTURECOMPARE_REGISTER_6                                  0x0E

//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: Timer_A_initCaptureMode().
//
//*****************************************************************************
#define TIMER_A_CAPTUREMODE_NO_CAPTURE                                     CM_0
#define TIMER_A_CAPTUREMODE_RISING_EDGE                                    CM_1
#define TIMER_A_CAPTUREMODE_FALLING_EDGE                                   CM_2
#define TIMER_A_CAPTUREMODE_RISING_AND_FALLING_EDGE                        CM_3

//*****************************************************************************
//
// The following are values that can be passed to the param parameter for
// functions: Timer_A_initCaptureMode().
//
//*****************************************************************************
#define TIMER_A_CAPTURE_ASYNCHRONOUS                                       0x00
#define TIMER_A_CAPTURE_SYNCHRONOUS                                         SCS

//*****************************************************************************
//
// The following are values that can be passed to the mask parameter for
// functions: Timer_A_getCaptureCompareInterruptStatus() as well as returned by
// the Timer_A_getCaptureCompareInterruptStatus() function.
//
//*****************************************************************************
#define TIMER_A_CAPTURE_OVERFLOW                                            COV
#define TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG                             CCIFG

//*****************************************************************************
//
// The following are values that can be passed to the synchronized parameter
// for functions: Timer_A_getSynchronizedCaptureCompareInput().
//
//*****************************************************************************
#define TIMER_A_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT                      SCCI
#define TIMER_A_READ_CAPTURE_COMPARE_INPUT                                  CCI

//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the Timer_A_getSynchronizedCaptureCompareInput()
// function.
//
//*****************************************************************************
#define TIMER_A_CAPTURECOMPARE_INPUT_HIGH                                  0x01
#define TIMER_A_CAPTURECOMPARE_INPUT_LOW                                   0x00

//*****************************************************************************
//
// The following are values that can be passed to the outputModeOutBitValue
// parameter for functions: Timer_A_setOutputForOutputModeOutBitValue() as well
// as returned by the Timer_A_getOutputForOutputModeOutBitValue() function.
//
//*****************************************************************************
#define TIMER_A_OUTPUTMODE_OUTBITVALUE_HIGH                                 OUT
#define TIMER_A_OUTPUTMODE_OUTBITVALUE_LOW                                 0x00

//*****************************************************************************
//
// The following are values that can be passed toThe following are values that
// can be returned by the Timer_A_getInterruptStatus() function.
//
//*****************************************************************************
#define TIMER_A_INTERRUPT_NOT_PENDING                                      0x00
#define TIMER_A_INTERRUPT_PENDING                                          0x01

//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************

//*****************************************************************************
//
//! \brief Starts Timer_A counter
//!
//! This function assumes that the timer has been previously configured using
//! Timer_A_initContinuousMode, Timer_A_initUpMode or Timer_A_initUpDownMode.
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param timerMode mode to put the timer in
//!        Valid values are:
//!        - \b TIMER_A_STOP_MODE
//!        - \b TIMER_A_UP_MODE
//!        - \b TIMER_A_CONTINUOUS_MODE [Default]
//!        - \b TIMER_A_UPDOWN_MODE
//!
//! Modified bits of \b TAxCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_startCounter(uint16_t baseAddress,
                                 uint16_t timerMode);

//*****************************************************************************
//
//! \brief Configures Timer_A in continuous mode.
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param param is the pointer to struct for continuous mode initialization.
//!
//! Modified bits of \b TAxCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_initContinuousMode(uint16_t baseAddress,
                                       Timer_A_initContinuousModeParam *param);

//*****************************************************************************
//
//! \brief Configures Timer_A in up mode.
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param param is the pointer to struct for up mode initialization.
//!
//! Modified bits of \b TAxCTL register, bits of \b TAxCCTL0 register and bits
//! of \b TAxCCR0 register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_initUpMode(uint16_t baseAddress,
                               Timer_A_initUpModeParam *param);

//*****************************************************************************
//
//! \brief Configures Timer_A in up down mode.
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param param is the pointer to struct for up-down mode initialization.
//!
//! Modified bits of \b TAxCTL register, bits of \b TAxCCTL0 register and bits
//! of \b TAxCCR0 register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_initUpDownMode(uint16_t baseAddress,
                                   Timer_A_initUpDownModeParam *param);

//*****************************************************************************
//
//! \brief Initializes Capture Mode
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param param is the pointer to struct for capture mode initialization.
//!
//! Modified bits of \b TAxCCTLn register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_initCaptureMode(uint16_t baseAddress,
                                    Timer_A_initCaptureModeParam *param);

//*****************************************************************************
//
//! \brief Initializes Compare Mode
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param param is the pointer to struct for compare mode initialization.
//!
//! Modified bits of \b TAxCCRn register and bits of \b TAxCCTLn register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_initCompareMode(uint16_t baseAddress,
                                    Timer_A_initCompareModeParam *param);

//*****************************************************************************
//
//! \brief Enable timer interrupt
//!
//! Does not clear interrupt flags
//!
//! \param baseAddress is the base address of the TIMER_A module.
//!
//! Modified bits of \b TAxCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_enableInterrupt(uint16_t baseAddress);

//*****************************************************************************
//
//! \brief Disable timer interrupt
//!
//! \param baseAddress is the base address of the TIMER_A module.
//!
//! Modified bits of \b TAxCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_disableInterrupt(uint16_t baseAddress);

//*****************************************************************************
//
//! \brief Get timer interrupt status
//!
//! \param baseAddress is the base address of the TIMER_A module.
//!
//! \return One of the following:
//!         - \b Timer_A_INTERRUPT_NOT_PENDING
//!         - \b Timer_A_INTERRUPT_PENDING
//!         \n indicating the Timer_A interrupt status
//
//*****************************************************************************
extern uint32_t Timer_A_getInterruptStatus(uint16_t baseAddress);

//*****************************************************************************
//
//! \brief Enable capture compare interrupt
//!
//! Does not clear interrupt flags
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param captureCompareRegister is the selected capture compare register
//!        Valid values are:
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
//!
//! Modified bits of \b TAxCCTLn register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_enableCaptureCompareInterrupt(uint16_t baseAddress,
                                                  uint16_t captureCompareRegister);

//*****************************************************************************
//
//! \brief Disable capture compare interrupt
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param captureCompareRegister is the selected capture compare register
//!        Valid values are:
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
//!
//! Modified bits of \b TAxCCTLn register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_disableCaptureCompareInterrupt(uint16_t baseAddress,
                                                   uint16_t captureCompareRegister);

//*****************************************************************************
//
//! \brief Return capture compare interrupt status
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param captureCompareRegister is the selected capture compare register
//!        Valid values are:
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
//! \param mask is the mask for the interrupt status
//!        Mask value is the logical OR of any of the following:
//!        - \b TIMER_A_CAPTURE_OVERFLOW
//!        - \b TIMER_A_CAPTURECOMPARE_INTERRUPT_FLAG
//!
//! \return Logical OR of any of the following:
//!         - \b Timer_A_CAPTURE_OVERFLOW
//!         - \b Timer_A_CAPTURECOMPARE_INTERRUPT_FLAG
//!         \n indicating the status of the masked interrupts
//
//*****************************************************************************
extern uint32_t Timer_A_getCaptureCompareInterruptStatus(uint16_t baseAddress,
                                                         uint16_t captureCompareRegister,
                                                         uint16_t mask);

//*****************************************************************************
//
//! \brief Reset/Clear the timer clock divider, count direction, count
//!
//! \param baseAddress is the base address of the TIMER_A module.
//!
//! Modified bits of \b TAxCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_clear(uint16_t baseAddress);

//*****************************************************************************
//
//! \brief Get synchronized capturecompare input
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param captureCompareRegister
//!        Valid values are:
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
//! \param synchronized
//!        Valid values are:
//!        - \b TIMER_A_READ_SYNCHRONIZED_CAPTURECOMPAREINPUT
//!        - \b TIMER_A_READ_CAPTURE_COMPARE_INPUT
//!
//! \return One of the following:
//!         - \b Timer_A_CAPTURECOMPARE_INPUT_HIGH
//!         - \b Timer_A_CAPTURECOMPARE_INPUT_LOW
//
//*****************************************************************************
extern uint8_t Timer_A_getSynchronizedCaptureCompareInput(uint16_t baseAddress,
                                                          uint16_t captureCompareRegister,
                                                          uint16_t synchronized);

//*****************************************************************************
//
//! \brief Get output bit for output mode
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param captureCompareRegister
//!        Valid values are:
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
//!
//! \return One of the following:
//!         - \b Timer_A_OUTPUTMODE_OUTBITVALUE_HIGH
//!         - \b Timer_A_OUTPUTMODE_OUTBITVALUE_LOW
//
//*****************************************************************************
extern uint8_t Timer_A_getOutputForOutputModeOutBitValue(uint16_t baseAddress,
                                                         uint16_t captureCompareRegister);

//*****************************************************************************
//
//! \brief Get current capturecompare count
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param captureCompareRegister
//!        Valid values are:
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
//!
//! \return Current count as an uint16_t
//
//*****************************************************************************
extern uint16_t Timer_A_getCaptureCompareCount(uint16_t baseAddress,
                                               uint16_t captureCompareRegister);

//*****************************************************************************
//
//! \brief Set output bit for output mode
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param captureCompareRegister
//!        Valid values are:
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
//! \param outputModeOutBitValue is the value to be set for out bit
//!        Valid values are:
//!        - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_HIGH
//!        - \b TIMER_A_OUTPUTMODE_OUTBITVALUE_LOW
//!
//! Modified bits of \b TAxCCTLn register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_setOutputForOutputModeOutBitValue(uint16_t baseAddress,
                                                      uint16_t captureCompareRegister,
                                                      uint8_t outputModeOutBitValue);

//*****************************************************************************
//
//! \brief Generate a PWM with timer running in up mode
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param param is the pointer to struct for PWM configuration.
//!
//! Modified bits of \b TAxCTL register, bits of \b TAxCCTL0 register, bits of
//! \b TAxCCR0 register and bits of \b TAxCCTLn register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_outputPWM(uint16_t baseAddress,
                              Timer_A_outputPWMParam *param);

//*****************************************************************************
//
//! \brief Stops the timer
//!
//! \param baseAddress is the base address of the TIMER_A module.
//!
//! Modified bits of \b TAxCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_stop(uint16_t baseAddress);

//*****************************************************************************
//
//! \brief Sets the value of the capture-compare register
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param compareRegister selects the Capture register being used. Refer to
//!        datasheet to ensure the device has the capture compare register
//!        being used.
//!        Valid values are:
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
//! \param compareValue is the count to be compared with in compare mode
//!
//! Modified bits of \b TAxCCRn register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_setCompareValue(uint16_t baseAddress,
                                    uint16_t compareRegister,
                                    uint16_t compareValue);

//*****************************************************************************
//
//! \brief Sets the output mode
//!
//! Sets the output mode for the timer even the timer is already running.
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param compareRegister selects the compare register being used.
//!        Valid values are:
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
//! \param compareOutputMode specifies the output mode.
//!        Valid values are:
//!        - \b TIMER_A_OUTPUTMODE_OUTBITVALUE [Default]
//!        - \b TIMER_A_OUTPUTMODE_SET
//!        - \b TIMER_A_OUTPUTMODE_TOGGLE_RESET
//!        - \b TIMER_A_OUTPUTMODE_SET_RESET
//!        - \b TIMER_A_OUTPUTMODE_TOGGLE
//!        - \b TIMER_A_OUTPUTMODE_RESET
//!        - \b TIMER_A_OUTPUTMODE_TOGGLE_SET
//!        - \b TIMER_A_OUTPUTMODE_RESET_SET
//!
//! Modified bits are \b OUTMOD of \b TAxCCTLn register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_setOutputMode(uint16_t baseAddress,
                                  uint16_t compareRegister,
                                  uint16_t compareOutputMode);

//*****************************************************************************
//
//! \brief Clears the Timer TAIFG interrupt flag
//!
//! \param baseAddress is the base address of the TIMER_A module.
//!
//! Modified bits are \b TAIFG of \b TAxCTL register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_clearTimerInterrupt(uint16_t baseAddress);

//*****************************************************************************
//
//! \brief Clears the capture-compare interrupt flag
//!
//! \param baseAddress is the base address of the TIMER_A module.
//! \param captureCompareRegister selects the Capture-compare register being
//!        used.
//!        Valid values are:
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_0
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_1
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_2
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_3
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_4
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_5
//!        - \b TIMER_A_CAPTURECOMPARE_REGISTER_6
//!
//! Modified bits are \b CCIFG of \b TAxCCTLn register.
//!
//! \return None
//
//*****************************************************************************
extern void Timer_A_clearCaptureCompareInterrupt(uint16_t baseAddress,
                                                 uint16_t captureCompareRegister);

//*****************************************************************************
//
//! \brief Reads the current timer count value
//!
//! Reads the current count value of the timer. There is a majority vote system
//! in place to confirm an accurate value is returned. The TIMER_A_THRESHOLD
//! #define in the corresponding header file can be modified so that the votes
//! must be closer together for a consensus to occur.
//!
//! \param baseAddress is the base address of the TIMER_A module.
//!
//! \return Majority vote of timer count value
//
//*****************************************************************************
extern uint16_t Timer_A_getCounterValue(uint16_t baseAddress);

//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif

#endif
#endif // __MSP430WARE_TIMER_A_H__


text:
package com.bergcomputers.bcibintegrationtest.ejb;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import javax.ejb.EJB;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.persistence.Cleanup;
import org.jboss.arquillian.persistence.CleanupStrategy;
import org.jboss.arquillian.persistence.PersistenceTest;
import org.jboss.arquillian.persistence.TestExecutionPhase;
import org.jboss.arquillian.persistence.TransactionMode;
import org.jboss.arquillian.persistence.Transactional;
import org.jboss.arquillian.persistence.UsingDataSet;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.bergcomputers.domain.Account;
import com.bergcomputers.ejb.AccountController;
import com.bergcomputers.ejb.IAccountController;

@RunWith(Arquillian.class)
@PersistenceTest
@Transactional(TransactionMode.ROLLBACK)
public class AccountEjbTest {

	@EJB
	private IAccountController accountController;

	@Deployment
    public static Archive<?> createDeployment() {
        return ShrinkWrap.create(WebArchive.class, "test.war")
            .addPackage(Account.class.getPackage())
            .addPackage(AccountController.class.getPackage())
            .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
    }

    @Before
    public void preparePersistenceTest() throws Exception {
    }
    @After
    public void commitTransaction() throws Exception {
    }

    @Test
    @UsingDataSet("datasets/TwoAccounts.xml")
    @Cleanup(phase = TestExecutionPhase.BEFORE, strategy = CleanupStrategy.USED_TABLES_ONLY)
    public void shouldFindAllGamesUsingJpqlQuery() throws Exception {
    	Account result = accountController.findAccount(6L);
   	    assertNotNull(result);
    	assertEquals("ROBUC01234", result.getIban());
   	    assertEquals(new Double(100.0), result.getAmount());
    }
}

redpajama_set_name: RedPajamaGithub


text:
require "active_support/concern"

module AWS
  module HashSorting
    extend ActiveSupport::Concern

    def sort
      dup.sort!
    end

    def sort!
      replace(Hash[sort_by { |k, v| k }])
    end
  end
end


text:
import os

# http://scikit-learn.org/stable/modules/generated/sklearn.cross_validation.train_test_split.html
from sklearn.cross_validation import train_test_split

from digoie.conf.storage import __elastic_search_dir__
from digoie.core.extractor.reverb import load_data
from digoie.core.ml.dataset.feature import extract
from digoie.core.ml.dataset.vector import vectorize
from digoie.core.ml.dataset.labeling import labeling
from digoie.conf.global_settings import TARGET_PERSON_NAME, TARGET_PHONE_NUMBER

# test only

def generate_dataset(min_df, max_df, target=TARGET_PERSON_NAME):
    print 'generate dataset for machine learning...'

    reverb_data = load_data()
    labels = labeling(reverb_data)
    featured = extract(reverb_data, target=target)
    vectorized, feature_names = vectorize(featured, my_min_df=min_df, my_max_df=max_df)

    X = vectorized
    y = labels
    X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

    # print X
    # print '=========================='
    # print X_train

    """
     Test Only
     - used to analyse results
    """
    """
    from digoie.conf.storage import __ml_datasets_dir__
    from digoie.core.files.file import Xvec2file, yvec2file, features2file

    Xvec2file(X_train, os.path.join(__ml_datasets_dir__, 'X_train'))
    Xvec2file(X_test, os.path.join(__ml_datasets_dir__, 'X_test'))
    yvec2file(y_train, os.path.join(__ml_datasets_dir__, 'y_train'))
    yvec2file(y_test, os.path.join(__ml_datasets_dir__, 'y_test'))

    features2file(X_train, os.path.join(__ml_datasets_dir__, 'X_train_features'), feature_names)
    features2file(X_test, os.path.join(__ml_datasets_dir__, 'X_test_features'), feature_names)
    """

    return feature_names, X_train, X_test, y_train, y_test


text:
OpenErpByXmlRpc
===============

Library to communicate into PHP and OpenERP

[![SensioLabsInsight](https://insight.sensiolabs.com/projects/cbb0511c-4e82-4709-88e5-e080c99fba19/mini.png)](https://insight.sensiolabs.com/projects/cbb0511c-4e82-4709-88e5-e080c99fba19)

Usage
-----

```php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use OpenErpByXmlRpc\OpenErpByXmlRpc;

// Configure Logger (if you want log request and response)
$logger = new Logger('xmlrpc');
$handler = new StreamHandler(__DIR__.'/logs/xmlrpc-'.date('Ymd').'.log', Logger::DEBUG);
$handler->setFormatter(new \Monolog\Formatter\LineFormatter(null, null, true));
$logger->pushHandler($handler);

// Init the communication
$xmlrpc = new OpenErpByXmlRpc('localhost', 8069, 'database', 'username', 'password');
$xmlrpc->setLogger($logger); // Not required

// Search datas
$user = $xmlrpc->search('res.users', array(array('login', '=', 'admin')));
// or
$user = $xmlrpc->search(
    'res.users',
    \OpenErpByXmlRpc\Criteria::create()->equal('login', 'admin')
);

// Get and retrieve data
$user = $xmlrpc->read('res.users', 1, array('login'));
$users = $xmlrpc->read('res.users', array(1, 2), array('login'));

// Call another method
$res = $xmlrpc->call('res.users', 'another_method', 'param1', 'param2', ...);
```

Others methods exists, check in the source code !

Authors
-------

* Simon Leblanc : contact@leblanc-simon.eu

License
-------

[MIT](http://opensource.org/licenses/MIT)


text:
module.exports = function (sequelize, Sequelize) {
    return sequelize.define('play', {
        id: {type: Sequelize.INTEGER.UNSIGNED, primaryKey: true, autoIncrement: true, allowNull:false},
        play_id: {type: Sequelize.STRING, allowNull: false},
        song_id: {type: Sequelize.STRING, allowNull: false},
        user_id: {type: Sequelize.STRING, allowNull: false},
        upvotes: {type: Sequelize.INTEGER.UNSIGNED, defaultValue: 0},
        downvotes: {type: Sequelize.INTEGER.UNSIGNED, defaultValue: 0},
        grabs: {type: Sequelize.INTEGER.UNSIGNED, defaultValue: 0},
        listeners: {type: Sequelize.INTEGER.UNSIGNED, defaultValue: 0},
        time: {type: Sequelize.DATE, allowNull: true},
        skipped: {type: Sequelize.BOOLEAN, defaultValue: false}
    }, {
        underscored: true,
        tableName: 'plays_test'
    });
};


text:
package org.jboss.resteasy.wadl;

import org.jboss.resteasy.logging.Logger;
import org.jboss.resteasy.wadl.i18n.Messages;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.xml.bind.JAXBException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Weinan Li
 */
@Path("/application.xml")
public class ResteasyWadlDefaultResource {

    private final static ResteasyWadlWriter apiWriter = new ResteasyWadlServletWriter();
    private final static Map<String, ResteasyWadlServiceRegistry> services = new HashMap<>();

    private final static Logger LOG = Logger.getLogger(ResteasyWadlDefaultResource.class);

    public static Map<String, ResteasyWadlServiceRegistry> getServices() {
        return services;
    }

    @GET
    @Produces("application/xml")
    public String output() {
        try {
            return this.apiWriter.getStringWriter("", services).toString();
        } catch (JAXBException e) {
            LOG.error(Messages.MESSAGES.cantProcessWadl(), e);
        }
        return null;
    }
}


text:
namespace feature_showcase {

using namespace pomdog;

class HTTPClientTest final : public Game {
public:
    explicit HTTPClientTest(const std::shared_ptr<GameHost>& gameHost);

    [[nodiscard]] std::unique_ptr<Error>
    Initialize() override;

    void Update() override;

    void Draw() override;

private:
    std::shared_ptr<GameHost> gameHost;
    std::shared_ptr<gpu::GraphicsDevice> graphicsDevice;
    std::shared_ptr<gpu::CommandQueue> commandQueue;
    std::shared_ptr<gpu::CommandList> commandList;
    ConnectionList connect;
    std::shared_ptr<SpriteBatch> spriteBatch;
    std::shared_ptr<SpriteFont> spriteFont;

    std::string requestURL;
    std::string webText;
};

} // namespace feature_showcase


text:
simple-puzzle-game
==================

A simple puzzle game that is made with javascript.

This game can be defined as a simple puzzle/brain game, to learn how to play it, go to How to Play or visit http://eminkura.com

This game is developed by Emin KURA by using Javascript and Raphael JS library.

check the original commit in the link
https://code.google.com/p/simple-puzzle-game/

I have updated the code to render the game object inside a dom element (DIV).

Reach me @ sesubash@gmail.com


text:
package user

import (
	"net/url"
	"strings"

	"github.com/macaron-contrib/captcha"

	"github.com/gogits/gogs/models"
	"github.com/gogits/gogs/modules/auth"
	"github.com/gogits/gogs/modules/base"
	"github.com/gogits/gogs/modules/log"
	"github.com/gogits/gogs/modules/mailer"
	"github.com/gogits/gogs/modules/middleware"
	"github.com/gogits/gogs/modules/setting"
)

const (
	SIGNIN          base.TplName = "user/auth/signin"
	SIGNUP          base.TplName = "user/auth/signup"
	ACTIVATE        base.TplName = "user/auth/activate"
	FORGOT_PASSWORD base.TplName = "user/auth/forgot_passwd"
	RESET_PASSWORD  base.TplName = "user/auth/reset_passwd"
)

func SignIn(ctx *middleware.Context) {
	ctx.Data["Title"] = ctx.Tr("sign_in")

	if _, ok := ctx.Session.Get("socialId").(int64); ok {
		ctx.Data["IsSocialLogin"] = true
		ctx.HTML(200, SIGNIN)
		return
	}

	if setting.OauthService != nil {
		ctx.Data["OauthEnabled"] = true
		ctx.Data["OauthService"] = setting.OauthService
	}

	// Check auto-login.
	isSucceed, err := middleware.AutoSignIn(ctx)
	if err != nil {
		ctx.Handle(500, "AutoSignIn", err)
		return
	}

	if isSucceed {
		if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 {
			ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl)
			ctx.Redirect(redirectTo)
		}
		ctx.Redirect(setting.AppSubUrl + "/")
		return
	}

	ctx.HTML(200, SIGNIN)
}

func SignInPost(ctx *middleware.Context, form auth.SignInForm) {
	ctx.Data["Title"] = ctx.Tr("sign_in")

	sid, isOauth := ctx.Session.Get("socialId").(int64)
	if isOauth {
		ctx.Data["IsSocialLogin"] = true
	} else if setting.OauthService != nil {
		ctx.Data["OauthEnabled"] = true
		ctx.Data["OauthService"] = setting.OauthService
	}

	if ctx.HasError() {
		ctx.HTML(200, SIGNIN)
		return
	}

	u, err := models.UserSignIn(form.UserName, form.Password)
	if err != nil {
		if models.IsErrUserNotExist(err) {
			ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), SIGNIN, &form)
		} else {
			ctx.Handle(500, "UserSignIn", err)
		}
		return
	}

	if form.Remember {
		days := 86400 * setting.LogInRememberDays
		ctx.SetCookie(setting.CookieUserName, u.Name, days, setting.AppSubUrl)
		ctx.SetSuperSecureCookie(base.EncodeMd5(u.Rands+u.Passwd),
			setting.CookieRememberName, u.Name, days, setting.AppSubUrl)
	}

	// Bind with social account.
	if isOauth {
		if err = models.BindUserOauth2(u.Id, sid); err != nil {
			if err == models.ErrOauth2RecordNotExist {
				ctx.Handle(404, "GetOauth2ById", err)
			} else {
				ctx.Handle(500, "GetOauth2ById", err)
			}
			return
		}
		ctx.Session.Delete("socialId")
		log.Trace("%s OAuth binded: %s -> %d", ctx.Req.RequestURI, form.UserName, sid)
	}

	ctx.Session.Set("uid", u.Id)
	ctx.Session.Set("uname", u.Name)
	if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 {
		ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl)
		ctx.Redirect(redirectTo)
		return
	}

	ctx.Redirect(setting.AppSubUrl + "/")
}

func SignOut(ctx *middleware.Context) {
	ctx.Session.Delete("uid")
	ctx.Session.Delete("uname")
	ctx.Session.Delete("socialId")
	ctx.Session.Delete("socialName")
	ctx.Session.Delete("socialEmail")
	ctx.SetCookie(setting.CookieUserName, "", -1, setting.AppSubUrl)
	ctx.SetCookie(setting.CookieRememberName, "", -1, setting.AppSubUrl)
	ctx.Redirect(setting.AppSubUrl + "/")
}

func oauthSignUp(ctx *middleware.Context, sid int64) {
	ctx.Data["Title"] = ctx.Tr("sign_up")

	if _, err := models.GetOauth2ById(sid); err != nil {
		if err == models.ErrOauth2RecordNotExist {
			ctx.Handle(404, "GetOauth2ById", err)
		} else {
			ctx.Handle(500, "GetOauth2ById", err)
		}
		return
	}

	ctx.Data["IsSocialLogin"] = true
	ctx.Data["uname"] = strings.Replace(ctx.Session.Get("socialName").(string), " ", "", -1)
	ctx.Data["email"] = ctx.Session.Get("socialEmail")
	log.Trace("social ID: %v", ctx.Session.Get("socialId"))
	ctx.HTML(200, SIGNUP)
}

func SignUp(ctx *middleware.Context) {
	ctx.Data["Title"] = ctx.Tr("sign_up")

	ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha

	if setting.Service.DisableRegistration {
		ctx.Data["DisableRegistration"] = true
		ctx.HTML(200, SIGNUP)
		return
	}

	if sid, ok := ctx.Session.Get("socialId").(int64); ok {
		oauthSignUp(ctx, sid)
		return
	}

	ctx.HTML(200, SIGNUP)
}

func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.RegisterForm) {
	ctx.Data["Title"] = ctx.Tr("sign_up")

	ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha

	if setting.Service.DisableRegistration {
		ctx.Error(403)
		return
	}

	isOauth := false
	sid, isOauth := ctx.Session.Get("socialId").(int64)
	if isOauth {
		ctx.Data["IsSocialLogin"] = true
	}

	if ctx.HasError() {
		ctx.HTML(200, SIGNUP)
		return
	}

	if setting.Service.EnableCaptcha && !cpt.VerifyReq(ctx.Req) {
		ctx.Data["Err_Captcha"] = true
		ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), SIGNUP, &form)
		return
	}

	if form.Password != form.Retype {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(ctx.Tr("form.password_not_match"), SIGNUP, &form)
		return
	}

	u := &models.User{
		Name:     form.UserName,
		Email:    form.Email,
		Passwd:   form.Password,
		IsActive: !setting.Service.RegisterEmailConfirm || isOauth,
	}
	if err := models.CreateUser(u); err != nil {
		switch {
		case models.IsErrUserAlreadyExist(err):
			ctx.Data["Err_UserName"] = true
			ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), SIGNUP, &form)
		case models.IsErrEmailAlreadyUsed(err):
			ctx.Data["Err_Email"] = true
			ctx.RenderWithErr(ctx.Tr("form.email_been_used"), SIGNUP, &form)
		case models.IsErrNameReserved(err):
			ctx.Data["Err_UserName"] = true
			ctx.RenderWithErr(ctx.Tr("user.form.name_reserved", err.(models.ErrNameReserved).Name), SIGNUP, &form)
		case models.IsErrNamePatternNotAllowed(err):
			ctx.Data["Err_UserName"] = true
			ctx.RenderWithErr(ctx.Tr("user.form.name_pattern_not_allowed", err.(models.ErrNamePatternNotAllowed).Pattern), SIGNUP, &form)
		default:
			ctx.Handle(500, "CreateUser", err)
		}
		return
	}
	log.Trace("Account created: %s", u.Name)

	// Auto-set admin for the only user.
	if models.CountUsers() == 1 {
		u.IsAdmin = true
		u.IsActive = true
		if err := models.UpdateUser(u); err != nil {
			ctx.Handle(500, "UpdateUser", err)
			return
		}
	}

	// Bind social account.
	if isOauth {
		if err := models.BindUserOauth2(u.Id, sid); err != nil {
			ctx.Handle(500, "BindUserOauth2", err)
			return
		}
		ctx.Session.Delete("socialId")
		log.Trace("%s OAuth binded: %s -> %d", ctx.Req.RequestURI, form.UserName, sid)
	}

	// Send confirmation e-mail, no need for social account.
	if !isOauth && setting.Service.RegisterEmailConfirm && u.Id > 1 {
		mailer.SendRegisterMail(ctx.Render, u)
		ctx.Data["IsSendRegisterMail"] = true
		ctx.Data["Email"] = u.Email
		ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
		ctx.HTML(200, ACTIVATE)

		if err := ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil {
			log.Error(4, "Set cache(MailResendLimit) fail: %v", err)
		}
		return
	}

	ctx.Redirect(setting.AppSubUrl + "/user/login")
}

func Activate(ctx *middleware.Context) {
	code := ctx.Query("code")
	if len(code) == 0 {
		ctx.Data["IsActivatePage"] = true
		if ctx.User.IsActive {
			ctx.Error(404)
			return
		}
		// Resend confirmation e-mail.
		if setting.Service.RegisterEmailConfirm {
			if ctx.Cache.IsExist("MailResendLimit_" + ctx.User.LowerName) {
				ctx.Data["ResendLimited"] = true
			} else {
				ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
				mailer.SendActiveMail(ctx.Render, ctx.User)

				if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
					log.Error(4, "Set cache(MailResendLimit) fail: %v", err)
				}
			}
		} else {
			ctx.Data["ServiceNotEnabled"] = true
		}
		ctx.HTML(200, ACTIVATE)
		return
	}

	// Verify code.
	if user := models.VerifyUserActiveCode(code); user != nil {
		user.IsActive = true
		user.Rands = models.GetUserSalt()
		if err := models.UpdateUser(user); err != nil {
			if models.IsErrUserNotExist(err) {
				ctx.Error(404)
			} else {
				ctx.Handle(500, "UpdateUser", err)
			}
			return
		}

		log.Trace("User activated: %s", user.Name)

		ctx.Session.Set("uid", user.Id)
		ctx.Session.Set("uname", user.Name)
		ctx.Redirect(setting.AppSubUrl + "/")
		return
	}

	ctx.Data["IsActivateFailed"] = true
	ctx.HTML(200, ACTIVATE)
}

func ActivateEmail(ctx *middleware.Context) {
	code := ctx.Query("code")
	email_string := ctx.Query("email")

	// Verify code.
	if email := models.VerifyActiveEmailCode(code, email_string); email != nil {
		if err := email.Activate(); err != nil {
			ctx.Handle(500, "ActivateEmail", err)
		}

		log.Trace("Email activated: %s", email.Email)
		ctx.Flash.Success(ctx.Tr("settings.activate_email_success"))
	}

	ctx.Redirect(setting.AppSubUrl + "/user/settings/email")
	return
}

func ForgotPasswd(ctx *middleware.Context) {
	ctx.Data["Title"] = ctx.Tr("auth.forgot_password")

	if setting.MailService == nil {
		ctx.Data["IsResetDisable"] = true
		ctx.HTML(200, FORGOT_PASSWORD)
		return
	}

	ctx.Data["IsResetRequest"] = true
	ctx.HTML(200, FORGOT_PASSWORD)
}

func ForgotPasswdPost(ctx *middleware.Context) {
	ctx.Data["Title"] = ctx.Tr("auth.forgot_password")

	if setting.MailService == nil {
		ctx.Handle(403, "user.ForgotPasswdPost", nil)
		return
	}
	ctx.Data["IsResetRequest"] = true

	email := ctx.Query("email")
	u, err := models.GetUserByEmail(email)
	if err != nil {
		if models.IsErrUserNotExist(err) {
			ctx.Data["Err_Email"] = true
			ctx.RenderWithErr(ctx.Tr("auth.email_not_associate"), FORGOT_PASSWORD, nil)
		} else {
			ctx.Handle(500, "user.ResetPasswd(check existence)", err)
		}
		return
	}

	if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) {
		ctx.Data["ResendLimited"] = true
		ctx.HTML(200, FORGOT_PASSWORD)
		return
	}

	mailer.SendResetPasswdMail(ctx.Render, u)
	if err = ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil {
		log.Error(4, "Set cache(MailResendLimit) fail: %v", err)
	}

	ctx.Data["Email"] = email
	ctx.Data["Hours"] = setting.Service.ActiveCodeLives / 60
	ctx.Data["IsResetSent"] = true
	ctx.HTML(200, FORGOT_PASSWORD)
}

func ResetPasswd(ctx *middleware.Context) {
	ctx.Data["Title"] = ctx.Tr("auth.reset_password")

	code := ctx.Query("code")
	if len(code) == 0 {
		ctx.Error(404)
		return
	}
	ctx.Data["Code"] = code
	ctx.Data["IsResetForm"] = true
	ctx.HTML(200, RESET_PASSWORD)
}

func ResetPasswdPost(ctx *middleware.Context) {
	ctx.Data["Title"] = ctx.Tr("auth.reset_password")

	code := ctx.Query("code")
	if len(code) == 0 {
		ctx.Error(404)
		return
	}
	ctx.Data["Code"] = code

	if u := models.VerifyUserActiveCode(code); u != nil {
		// Validate password length.
		passwd := ctx.Query("password")
		if len(passwd) < 6 {
			ctx.Data["IsResetForm"] = true
			ctx.Data["Err_Password"] = true
			ctx.RenderWithErr(ctx.Tr("auth.password_too_short"), RESET_PASSWORD, nil)
			return
		}

		u.Passwd = passwd
		u.Rands = models.GetUserSalt()
		u.Salt = models.GetUserSalt()
		u.EncodePasswd()
		if err := models.UpdateUser(u); err != nil {
			ctx.Handle(500, "UpdateUser", err)
			return
		}

		log.Trace("User password reset: %s", u.Name)
		ctx.Redirect(setting.AppSubUrl + "/user/login")
		return
	}

	ctx.Data["IsResetFailed"] = true
	ctx.HTML(200, RESET_PASSWORD)
}


text:
@echo off
pushd %~dp0
powershell -NoProfile -ExecutionPolicy unrestricted -Command %1 %2 %3 %4
echo.
echo.
pause


text:
function [tra] = transfer_elec(pnt, tri, el);

% TRANSFER_ELEC is the transfermatrix from vertex to electrode potentials
% using bi-linear interpolation over the triangles
%
% tra = transfer_elec(pnt, tri, el)
%
% the Nx3 matrix el shold contain [tri, la, mu] for each electrode
%
% See also PROJECT_ELEC

% Copyright (C) 1998-2002, Robert Oostenveld
%
% This file is part of FieldTrip, see http://www.ru.nl/neuroimaging/fieldtrip
% for the documentation and details.
%
%    FieldTrip is free software: you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation, either version 3 of the License, or
%    (at your option) any later version.
%
%    FieldTrip is distributed in the hope that it will be useful,
%    but WITHOUT ANY WARRANTY; without even the implied warranty of
%    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%    GNU General Public License for more details.
%
%    You should have received a copy of the GNU General Public License
%    along with FieldTrip. If not, see <http://www.gnu.org/licenses/>.
%
% $Id: transfer_elec.m 2885 2011-02-16 09:41:58Z roboos $

Npnt = size(pnt,1);
Ntri = size(tri,1);
Nel  = size(el,1);

tra = zeros(Nel, Npnt);

for i=1:Nel
  tra(i, tri(el(i,1), 1)) = 1 - el(i,2) - el(i,3);
  tra(i, tri(el(i,1), 2)) = el(i,2);
  tra(i, tri(el(i,1), 3)) = el(i,3);
end


text:
Inspired by the classical blockade game, thereafter known as snake game, developed and published by Gremlin Industries back in 1976 and written in ES6. A demo is available [here](http://tsur.github.io/blockade). You may also control it from another client by using WebRTC on those mobile devices supporting it [here](http://tsur.github.io/blockade/peer.html). You may also download the project in zip format, then extract it and open the index.html file located on dist folder.

If running it on webkit based browsers, it also supports webkitSpeechRecognition which will allow you to control the game actions by using your device microphone, words recognised include "up, down, left and right". It's not working fine though.

# Setting up

To deploy it on your local machine, just follow the steps below:

```bash
git clone https://github.com/Tsur/blockade.git
cd blockade && npm run deploy:local
```
Open your browser on localhost:8080 to start developing. You may now modify the source code and the browser will refresh automatically.

** NOTE: You will need LiveReload Plugin from chrome-store to enable live reloading

To deploy it remotely, make sure you commit and/or push all your changes to the develop branch. Once your done, just run either or both of:

```bash
# Heroku app (first time you need to create the heroku app: heroku create)
npm run deploy:heroku
# Github Pages (first time you need to create it: git checkout -b gh-pages develop)
npm run deploy:gh-pages
```

# Building

```bash
# for websockets support
npm run ws
# for webrtc support
npm run webrtc
```

After then, set the start script on package.json to some of the following: start:ws or start:webrtc

# Testing

```bash
npm run test
```


text:
namespace ZLibrary.Machine
{
    public interface IZScreen
    {
        string ReadLine(string aInitial, int aTimeout, ushort aTimeoutCallback, byte[] aTerminatingKeys, out byte aTerminator);
        short ReadKey(int aTimeout, ushort aTimeoutCallback);
        void WriteChar(char aC);
        void WriteString(string aS);
        void ShowStatus();
    }
}


text:
var $bIsClickOnExplorerMenu = false;
var $bIsClickBody = false;
$Behavior.clickExplorerMenuInit =function()
{
    $((getParam('bJsIsMobile') ? '#content' : 'body')).click(function()
    {
        if( $bIsClickBody == false)
        {
            $('.explorer_menu_item').removeClass('active');
            $bIsClickOnExplorerMenu = false;
        }
        else{
            $bIsClickBody = false;
            $bIsClickOnExplorerMenu = true;
        }
    });
    $('.explorer_menu').click(function()
    {
        if($bIsClickOnExplorerMenu == false)
        {
            $('.explorer_menu_item').addClass('active');
            $bIsClickBody = true;
        }
    });
    $('ul.explorer_menu_item li a').click(function()
    {
        $('.explorer_menu_item').removeClass('active');
    });
}
var username;
var password;
$Behavior.loadInitCustomLogin = function()
{
    $('#username_or_email').bind('focus', function(){
        if($(this).val() == username){
            $(this).attr('value','');
        }
    });
    $('#username_or_email').bind('blur', function(){
        if($(this).val() == ''){
            $(this).attr('value',username);
        }
    });
    $('#login_password').bind('focus', function(){
        if($(this).val() == password){
            $(this).attr('value','');
        }
    });
    $('#login_password').bind('blur', function(){
        if($(this).val() == ''){
            $(this).attr('value',password);
        }
    });
}


text:
package org.assertj.core.api.future;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.error.ShouldBeInstance.shouldBeInstance;
import static org.assertj.core.error.future.ShouldHaveFailed.shouldHaveFailed;
import static org.assertj.core.util.AssertionsUtil.assertThatAssertionErrorIsThrownBy;
import static org.assertj.core.util.FailureMessages.actualIsNull;

import java.util.concurrent.CompletableFuture;

import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@SuppressWarnings("deprecation")
@DisplayName("CompletableFutureAssert hasFailedWithThrowableThat")
class CompletableFutureAssert_hasFailedWithThrowableThat_Test {

  @Test
  void should_pass_if_completable_future_has_failed() {
    // GIVEN
    CompletableFuture<String> future = new CompletableFuture<>();
    // WHEN
    future.completeExceptionally(new RuntimeException("some random error"));
    // THEN
    assertThat(future).hasFailedWithThrowableThat()
                      .isInstanceOf(RuntimeException.class)
                      .hasMessage("some random error");
  }

  @Test
  void should_fail_when_completable_future_is_null() {
    // GIVEN
    CompletableFuture<String> future = null;
    // WHEN
    ThrowingCallable code = () -> assertThat(future).hasFailedWithThrowableThat();
    // THEN
    assertThatAssertionErrorIsThrownBy(code).withMessage(actualIsNull());
  }

  @Test
  void should_fail_if_completable_future_has_failed_with_wrong_throwable() {
    // GIVEN
    CompletableFuture<String> future = new CompletableFuture<>();
    RuntimeException exception = new RuntimeException("some random error");
    future.completeExceptionally(exception);
    // WHEN
    ThrowingCallable code = () -> assertThat(future).hasFailedWithThrowableThat().isInstanceOf(IllegalArgumentException.class);
    // THEN
    assertThatAssertionErrorIsThrownBy(code).withMessage(shouldBeInstance(exception, IllegalArgumentException.class).create());
  }

  @Test
  void should_fail_if_completable_future_is_incomplete() {
    // GIVEN
    CompletableFuture<String> future = new CompletableFuture<>();
    // WHEN
    ThrowingCallable code = () -> assertThat(future).hasFailedWithThrowableThat();
    // THEN
    assertThatAssertionErrorIsThrownBy(code).withMessage(shouldHaveFailed(future).create());
  }

  @Test
  void should_fail_if_completable_future_is_completed() {
    // GIVEN
    CompletableFuture<String> future = CompletableFuture.completedFuture("done");
    // WHEN
    ThrowingCallable code = () -> assertThat(future).hasFailedWithThrowableThat();
    // THEN
    assertThatAssertionErrorIsThrownBy(code).withMessage(shouldHaveFailed(future).create());
  }

  @Test
  void should_fail_if_completable_future_was_cancelled() {
    // GIVEN
    CompletableFuture<String> future = new CompletableFuture<>();
    future.cancel(true);
    // WHEN
    ThrowingCallable code = () -> assertThat(future).hasFailedWithThrowableThat();
    // THEN
    assertThatAssertionErrorIsThrownBy(code).withMessage(shouldHaveFailed(future).create());
  }
}


text:
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>
<?php $theme->display ('header'); ?>

<?php foreach ( $posts as $post ) { ?>
		<div id="post-<?php echo $post->id; ?>" class="<?php echo $post->statusname; ?> hentry">

<a href="<?php echo $post->permalink; ?>" title="<?php echo $post->title; ?>"><?php echo $post->title_out; ?>

				<?php $post->pubdate->out(); ?> <?php if ( $show_author ) { _e( 'by %s', array( $post->author->displayname ) ); } ?>
			<?php $theme->comments_link($post); ?>
<?php if ( $loggedin ) { ?>
				<a href="<?php echo $post->editlink; ?>" title="<?php _e('Edit post'); ?>"><?php _e('Edit'); ?>
<?php } ?>
<?php if ( count( $post->tags ) > 0 ) { ?>
				<?php echo $post->tags_out; ?>
<?php } ?>

			<?php echo $post->content_out; ?>

<?php } ?>

		<?php $theme->prev_page_link(); ?> <?php $theme->page_selector( null, array( 'leftSide' => 2, 'rightSide' => 2 ) ); ?> <?php $theme->next_page_link(); ?>

<?php $theme->display ('sidebar'); ?>

<?php $theme->display ( 'footer'); ?>


text:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading;

namespace Deflector
{
    /// <summary>
    ///     Represents the information associated with
    ///     a single method call.
    /// </summary>
    [Serializable]
    public class InvocationInfo : IInvocationInfo
    {
        /// <summary>
        ///     Initializes the <see cref="InvocationInfo" /> instance.
        /// </summary>
        /// <param name="target">The target instance currently being called.</param>
        /// <param name="callingInstance">The object instance that is currently calling the target method.</param>
        /// <param name="callingMethod">The calling method.</param>
        /// <param name="targetMethod">The method currently being called.</param>
        /// <param name="stackTrace"> The <see cref="StackTrace" /> associated with the method call when the call was made.</param>
        /// <param name="parameterTypes">The parameter types for the current target method.</param>
        /// <param name="typeArguments">
        ///     If the <see cref="TargetMethod" /> method is a generic method,
        ///     this will hold the generic type arguments used to construct the
        ///     method.
        /// </param>
        /// <param name="arguments">The arguments used in the method call.</param>
        public InvocationInfo(object target, object callingInstance, MethodBase callingMethod, MethodBase targetMethod,
            StackTrace stackTrace, Type[] parameterTypes,
            Type[] typeArguments, object[] arguments)
        {
            Target = target;
            CallingInstance = callingInstance;
            CallingMethod = callingMethod;
            TargetMethod = targetMethod;
            StackTrace = stackTrace;
            ParameterTypes = parameterTypes;
            TypeArguments = typeArguments;
            Arguments = arguments;
            ManagedThreadId = Thread.CurrentThread.ManagedThreadId;
        }

        /// <summary>
        ///     This is the actual calling method that invoked the <see cref="TargetMethod" />.
        /// </summary>
        public MethodBase CallingMethod { get; }

        public int ManagedThreadId { get; }

        /// <summary>
        ///     The target instance currently being called.
        /// </summary>
        /// <remarks>This typically is a reference to a proxy object.</remarks>
        public object Target { get; }

        /// <summary>
        /// The calling instance that called the current method.
        /// </summary>
        public object CallingInstance { get; }

        /// <summary>
        ///     The method currently being called.
        /// </summary>
        public MethodBase TargetMethod { get; }

        /// <summary>
        ///     The <see cref="StackTrace" /> associated
        ///     with the method call when the call was made.
        /// </summary>
        public StackTrace StackTrace { get; }

        /// <summary>
        ///     The parameter types for the current target method.
        /// </summary>
        /// <remarks>
        ///     <para>
        ///         This could be very useful in cases where the actual target method
        ///         is based on a generic type definition. In such cases,
        ///         the <see cref="IInvocationInfo" /> instance needs to be able
        ///         to describe the actual parameter types being used by the
        ///         current generic type instantiation. This property helps
        ///         users determine which parameter types are actually being used
        ///         at the time of the method call.
        ///     </para>
        /// </remarks>
        public Type[] ParameterTypes { get; }

        /// <summary>
        ///     If the <see cref="TargetMethod" /> method is a generic method,
        ///     this will hold the generic type arguments used to construct the
        ///     method.
        /// </summary>
        public Type[] TypeArguments { get; }

        /// <summary>
        ///     The arguments used in the method call.
        /// </summary>
        public object[] Arguments { get; }

        /// <summary>
        ///     Returns a string that represents the current object.
        /// </summary>
        /// <returns>A string that represents the current object.</returns>
        public override string ToString()
        {
            var writer = new StringWriter();
            var targetMethod = TargetMethod;

            writer.Write("{0}.{1}(", targetMethod.DeclaringType, targetMethod.Name);

            var arguments = new Queue<object>(Arguments);
            while (arguments.Count > 0)
            {
                var argument = arguments.Dequeue();

                if (argument is string)
                    argument = $"\"{argument}\"";

                writer.Write(argument);

                if (arguments.Count > 0)
                    writer.Write(", ");
            }

            writer.WriteLine(")");

            return writer.ToString();
        }
    }
}


text:
class Command < ActiveRecord::Base
	after_initialize :default_values

	validates :button, presence: true
	belongs_to :button
	private
	def default_values
		self.status ||= 1
	end
end


text:
<resources>
    <string name="app_name">esa</string>
</resources>


text:
package com.teamlans.lepta.view.account;

import com.teamlans.lepta.entities.User;
import com.teamlans.lepta.entities.enums.Color;
import com.teamlans.lepta.service.exceptions.LeptaServiceException;
import com.teamlans.lepta.service.user.PasswordEncryptionService;
import com.teamlans.lepta.service.user.UserService;
import com.teamlans.lepta.view.LeptaNotification;
import com.teamlans.lepta.view.ProtectedVerticalView;
import com.vaadin.external.org.slf4j.Logger;
import com.vaadin.external.org.slf4j.LoggerFactory;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.spring.annotation.SpringView;
import com.vaadin.ui.Accordion;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;

/**
 * EditProfileView allows users to change their account details.
 */
@SpringView(name = EditProfileView.VIEW_NAME)
@Scope("request")
public final class EditProfileView extends ProtectedVerticalView {

  public static final String VIEW_NAME = "EditProfile";

  private UserService service;
  private PasswordEncryptionService encryptionService;

  private static Logger logger = LoggerFactory.getLogger(EditProfileView.class);

  private final User user;

  @Autowired
  public EditProfileView(UserService service, PasswordEncryptionService encryptionService) {
    this.service = service; // because of weird bug, issue #32
    this.encryptionService = encryptionService;
    user = getLeptaUi().getLoggedInUser();

    build();
  }

  private void build() {
    final Component title = buildTitle();
    addComponent(title);
    setComponentAlignment(title, Alignment.TOP_LEFT);

    final Component changers = buildChangers();
    addComponent(changers);
    setComponentAlignment(changers, Alignment.TOP_CENTER);
  }

  private Component buildTitle() {
    final Label title = new Label("Hello " + user.getName() + ".");
    title.setSizeUndefined();
    return title;
  }

  private Component buildChangers() {
    final Accordion accordion = new Accordion();
    accordion.setSizeUndefined();
    accordion.setWidth("70%");

    accordion.addTab(buildColorPicker(), "Select a new color");
    accordion.addTab(buildNameChanger(), "Change your username");
    accordion.addTab(buildPasswordForm(), "Change your password");

    return accordion;
  }

  private Component buildColorPicker() {
    HorizontalLayout container = new HorizontalLayout();

    container.addComponent(buildColorButton(Color.DARK_BLUE));
    container.addComponent(buildColorButton(Color.LIGHT_BLUE));
    container.addComponent(buildColorButton(Color.GREEN));
    container.addComponent(buildColorButton(Color.YELLOW));
    container.addComponent(buildColorButton(Color.ORANGE));
    container.addComponent(buildColorButton(Color.RED));

    return container;
  }

  private Button buildColorButton(Color color) {
    Button button = new Button(color.toString().replaceAll("_", " "));
    try {
      boolean taken = service.isTaken(color);
      if (!taken) {
        button.addClickListener(clickEvent -> {
          user.setColor(color);
          try {
            service.updateUser(user);
            LeptaNotification.show("Success"); // feedback; will be removed when css is added
          } catch (LeptaServiceException e) {
            LeptaNotification.showError(e.getMessage());
          }

          //refresh page
          removeAllComponents();
          build();
        });
      }
    } catch (LeptaServiceException e) {
      logger.error("Error", e);
      LeptaNotification.showError(e.getMessage());
    }
    return button;
  }

  private Component buildNameChanger() {
    final HorizontalLayout container = new HorizontalLayout();

    final TextField nameField = new TextField();
    nameField.setInputPrompt("Enter a new name");

    container.addComponent(nameField);
    container.addComponent(buildNameButton(nameField));

    return container;
  }

  private Button buildNameButton(TextField nameField) {
    final Button button = new Button("OK");
    button.addClickListener(clickEvent -> {
      String newName = nameField.getValue();
      if (!newName.isEmpty() && !newName.equals(user.getName())) {
        user.setName(newName);
        try {
          service.updateUser(user);
        } catch (LeptaServiceException e) {
          LeptaNotification.showError(e.getMessage());
        }

        // refresh
        // TODO: add event bus
        removeAllComponents();
        build();
      }
    });
    return button;
  }

  private Component buildPasswordForm() {
    final VerticalLayout container = new VerticalLayout();

    final PasswordField oldField = new PasswordField("Old password:");
    container.addComponent(oldField);

    final PasswordField newField = new PasswordField("New password:");
    container.addComponent(newField);

    final PasswordField confirmationField = new PasswordField("Confirm new password:");
    container.addComponent(confirmationField);

    container.addComponent(buildPasswordButton(oldField, newField, confirmationField));

    return container;
  }

  private Button buildPasswordButton(PasswordField oldField, PasswordField newField,
                                     PasswordField confirmationField) {
    final Button button = new Button("OK");
    button.addClickListener(clickEvent -> {
      try {
        if (encryptionService.isValid(oldField.getValue(), user)) {
          String newPassword = newField.getValue();
          checkPassword(oldField, newField, confirmationField, newPassword);
        } else {
          LeptaNotification.showWarning("Wrong password");
        }
      } catch (LeptaServiceException e) {
        logger.error("Error", e);
        LeptaNotification.showError("Something went wrong");
      }
    });
    return button;
  }

  private void checkPassword(PasswordField oldField, PasswordField newField, PasswordField confirmationField, String newPassword) throws LeptaServiceException {
    if (!newPassword.isEmpty() && newPassword.equals(confirmationField.getValue())) {
      user.setPassword(encryptionService.getEncryptedPassword(newPassword, user.getSalt()));
      service.updateUser(user);

      oldField.clear();
      newField.clear();
      confirmationField.clear();
      LeptaNotification.show("Change successful");
    } else {
      LeptaNotification.showWarning("Two different new passwords");
    }
  }

  @Override
  public void enter(ViewChangeListener.ViewChangeEvent viewChangeEvent) {
    // needed for View implementation
  }

}


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Fix Visual Studio 2015 with Orleans Tools for Visual Studio 1.4.0 installed | Microsoft Orleans Documentation </title>
    <meta name="viewport" content="width=device-width">
    <meta name="title" content="Fix Visual Studio 2015 with Orleans Tools for Visual Studio 1.4.0 installed | Microsoft Orleans Documentation ">
    <meta name="generator" content="docfx 2">

    <link rel="shortcut icon" href="../favicon.ico">
    <link rel="stylesheet" href="../styles/docfx.vendor.css">
    <link rel="stylesheet" href="../styles/docfx.css">
    <link rel="stylesheet" href="../styles/main.css">
    <meta property="docfx:navrel" content="../toc.html">
    <meta property="docfx:tocrel" content="toc.html">

    <meta property="docfx:rel" content="../">

              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
                Toggle navigation

              </button>

              <form class="navbar-form navbar-right" role="search" id="search">

                  <input type="text" class="form-control" id="search-query" placeholder="Search" autocomplete="off">

              </form>

Search Results for

          Show / Hide Table of Contents

Fix Visual Studio 2015 with Orleans Tools for Visual Studio 1.4.0 installed

Attila Hajdrik
3/10/2017 10:06:17 AM

Today two community members was hit by an issue with Visual Studio 2015 if they've installed the 1.4.0 version of the Orleans VSIX package.
We have an open issue to track this on GitHub.
If you installed the extension on Visual Studio 2017, it will work, only 2015 has this problem.
The issue we're seeing is that you cannot open the Tools & Extensions window, VS will show this error dialog:

While we working on the solution we unpublished the problematic version and published an older version of the extension which does not work with Visual Studio 2017, but neither it renders Visual Studio 2015 unusable.
If you were hit by this isse, here are the steps to fix it:

 1) Exit all Visual Studio instances.

 2) Open an Administrator Visual Studio developer command prompt.

 3) cd /D "%USERPROFILE%\Local Settings\Microsoft\VisualStudio\14.0\Extensions"

 4) dir OrleansVSTools.dll /s

You'll get a result like this:

Directory of C:\Users\\Local Settings\Microsoft\VisualStudio\14.0\Extensions\pxzkggpq.50t

03/10/2017 02:36 PM 18,608 OrleansVSTools.dll

1 File(s) 18,608 bytes

5) Copy the full directory path to clipboard.

6) rmdir "" /q /s

Make sure you're still in the Extensions directory.

7) del *.cache

8) devenv /setup

This can run for a few minutes...be patient.

Now you can start Visual Studio 2015 and verify that the Extensions dialog opens and everything works fine.

If you've special root suffixes configured for Visual Studio 2015 then you've to execute these commands for that specific instance, so not in the 14.0, but maybe in the 14.0Exp directory.

UPDATE 3/17/2017

We published an updated VSIX which works correctly with VS2013, VS2015, VS2017: Microsoft Orleans Tools for Visual Studio

                    Improve this Doc

In This Article

              Back to top

            Generated by DocFX


text:
package org.apache.camel.processor;

import org.apache.camel.ContextTestSupport;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;

public class ThreadsCoreAndMaxPoolInvalidTest extends ContextTestSupport {

    @Test
    public void testInvalidSyntax() throws Exception {
        try {
            context.addRoutes(new RouteBuilder() {
                @Override
                public void configure() throws Exception {
                    from("direct:start").threads(5, 2).to("mock:result");
                }
            });

            fail("Should have thrown an exception");
        } catch (Exception e) {
            IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
            assertEquals("MaxPoolSize must be >= corePoolSize, was 2 >= 5", iae.getMessage());
        }
    }
}


text:
package com.ybproject.diarymemo;

import net.daum.adam.publisher.AdView;
import net.daum.adam.publisher.AdView.AnimationType;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.RadioButton;
import android.widget.RadioGroup;

import com.ybproject.diarymemo.R;
import com.ybproject.diarymemo.DrawNotePenPaletteDialog.OnPenSelectedListener;
import com.ybproject.diarymemo.R.id;
import com.ybproject.diarymemo.R.layout;
import com.ybproject.diarymemo.provider.DrawNoteDB;

public class DrawNoteSetting extends Activity implements OnClickListener{

	private View setWidth;
	private View setColor1;
	private View setColor2;
	private View setColor3;
	private RadioGroup radio;
	private int width;
	private int color;
	private int scroll;
	private int color1;
	private int color2;
	private int color3;

	private DrawNoteDB dbCon;
	private static final String ACTION_PICK_COLOR = "com.ybproject.diarymemo.action.PICK_COLOR";
	private static final int REQUEST_CODE_PICK_COLOR = 1;
	private static final int REQUEST_CODE_PICK_COLOR1 = 2;
	private static final int REQUEST_CODE_PICK_COLOR2 = 3;
	private static final int REQUEST_CODE_PICK_COLOR3 = 4;
	//광고
    private AdView adView = null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.setting);
        //아담 광고
		String systemLanguage = getResources().getConfiguration().locale.getLanguage();
		String Ko_lang = "ko";

		//사용언어가 한국어 일경우에만 아담 광고 노출
		if(Ko_lang.equals(systemLanguage)){
			initAdam(); //아담 광고 초기화
		}else{
			//차후 로케이션이 영문일경우 애드몹 광고 추가예정
			Log.i("lang:",systemLanguage);
		}

		setWidth = findViewById(R.id.setWidth);
		setColor1 = findViewById(R.id.color1);
		setColor1.setOnClickListener(this);
		setColor2 = findViewById(R.id.color2);
		setColor2.setOnClickListener(this);
		setColor3 = findViewById(R.id.color3);
		setColor3.setOnClickListener(this);
		findViewById(R.id.btn_save).setOnClickListener(this);
		findViewById(R.id.btn_back).setOnClickListener(this);
		findViewById(R.id.btn_width).setOnClickListener(this);
		findViewById(R.id.btn_color).setOnClickListener(this);
//		radio = (RadioGroup)findViewById(R.id.radiogroup);

		dbCon = new DrawNoteDB(this);

		//현재설정값을 받아옴.
		Integer result[] = dbCon.getDraw();
		width = result[0];
		color = result[1];
		scroll = result[2];

		result = dbCon.getFavoriteColor();
		color1 = result[0];
		color2 = result[1];
		color3 = result[2];

		setPen();
		setColor1.setBackgroundColor(color1);
		setColor2.setBackgroundColor(color2);
		setColor3.setBackgroundColor(color3);

		//스크롤 off 설정
//		if(scroll == 0){
//			RadioButton off = (RadioButton)findViewById(R.id.off);
//			off.setChecked(true);
//		}
	}

	public void onClick(View v) {
		Intent intent;
		switch (v.getId()) {
		case R.id.btn_back:
			finish();
			break;
		case R.id.btn_save:
//			if(radio.getCheckedRadioButtonId() == R.id.on){
//				scroll = 1;
//			}else{
//				scroll = 0;
//			}
			dbCon.setDraw(width, color, scroll);
			dbCon.setFavoriteColor(color1, color2, color3);
			finish();
			break;
		case R.id.btn_width:
			DrawNotePenPaletteDialog.listener = new OnPenSelectedListener() {
				public void onPenSelected(int size) {
					width = size;
					setPen();
				}
			};
			intent = new Intent(DrawNoteSetting.this, DrawNotePenPaletteDialog.class);
			startActivity(intent);
			break;
		case R.id.btn_color:
			intent = new Intent();
			intent.setAction(ACTION_PICK_COLOR);
			intent.putExtra("color", color);
			intent.putExtra("setting", true);
			startActivityForResult(intent, REQUEST_CODE_PICK_COLOR);
			break;
		case R.id.color1:
			intent = new Intent();
			intent.setAction(ACTION_PICK_COLOR);
			intent.putExtra("color", color1);
			intent.putExtra("setting", true);
			startActivityForResult(intent, REQUEST_CODE_PICK_COLOR1);
			break;
		case R.id.color2:
			intent = new Intent();
			intent.setAction(ACTION_PICK_COLOR);
			intent.putExtra("color", color2);
			intent.putExtra("setting", true);
			startActivityForResult(intent, REQUEST_CODE_PICK_COLOR2);
			break;
		case R.id.color3:
			intent = new Intent();
			intent.setAction(ACTION_PICK_COLOR);
			intent.putExtra("color", color3);
			intent.putExtra("setting", true);
			startActivityForResult(intent, REQUEST_CODE_PICK_COLOR3);
			break;
		}
	}

	 @Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			super.onActivityResult(requestCode, resultCode, data);
			switch(requestCode) {
			case REQUEST_CODE_PICK_COLOR:
				if (resultCode == RESULT_OK) {
					color = data.getIntExtra("color", color);
					setPen();
				}
				break;
			case REQUEST_CODE_PICK_COLOR1:
				if (resultCode == RESULT_OK) {
					color1 = data.getIntExtra("color", color);
					setColor1.setBackgroundColor(color1);
				}
				break;
			case REQUEST_CODE_PICK_COLOR2:
				if (resultCode == RESULT_OK) {
					color2 = data.getIntExtra("color", color);
					setColor2.setBackgroundColor(color2);
				}
				break;
			case REQUEST_CODE_PICK_COLOR3:
				if (resultCode == RESULT_OK) {
					color3 = data.getIntExtra("color", color);
					setColor3.setBackgroundColor(color3);;
				}
				break;
			}
		}

	 public void setPen(){
		//펜 두께 설정
			ViewGroup.LayoutParams params = setWidth.getLayoutParams();
			final Bitmap penBitmap = Bitmap.createBitmap(params.width, params.height, Bitmap.Config.ARGB_8888);
			final Canvas penCanvas = new Canvas();
			penCanvas.setBitmap(penBitmap);
			Paint mPaint = new Paint();
			mPaint.setColor(Color.BLACK);
			mPaint.setAntiAlias(true);
			mPaint.setStrokeCap(Paint.Cap.ROUND);
			penCanvas.drawRect(0, 0, params.width, params.height, mPaint);

			mPaint.setColor(color);
			mPaint.setStrokeWidth((float)width);

//			penCanvas.drawCircle(params.width/2, params.height/2, width, mPaint);
			penCanvas.drawLine(10, params.height/2, params.width-10, params.height/2, mPaint);
			BitmapDrawable penDrawable = new BitmapDrawable(this.getResources(), penBitmap);
			setWidth.setBackgroundDrawable(penDrawable);
	 }
	    //광고 모듈
		@Override
		public void onDestroy() {
			super.onDestroy();

			if (adView != null) {
				adView.destroy();
				adView = null;
			}
		}

		private void initAdam() {
			// Ad@m sdk 초기화 시작
			DiaryMemoAppManager AdClientID = new DiaryMemoAppManager();
			String ClientID = AdClientID.ClientID;
			adView = (AdView) findViewById(R.id.adview);
			adView.setRequestInterval(5);

			// 할당 받은 clientId 설정
			adView.setClientId(ClientID);

			adView.setRequestInterval(12);

			// Animation 효과 : 기본 값은 AnimationType.NONE
			adView.setAnimationType(AnimationType.FLIP_HORIZONTAL);

			adView.setVisibility(View.VISIBLE);
		}

		@Override
		public void onConfigurationChanged(Configuration newConfig) {
			super.onConfigurationChanged(newConfig);
		}
}