; 18649 Spring 2010
; group 7
; Justin Ray/justinr2
; other names would go here
; vendcontrol_1.mf

;unit test for coin control

;definitions for inputs
;period and ID for mCoinCount
#DEFINE COIN_COUNT_PER 100ms
#DEFINE COIN_COUNT_CAN_ID 0x0A583C00
;period and ID for mVendMotor
#DEFINE VEND_MOTOR_PER 50ms
#DEFINE VEND_MOTOR_CAN_ID 0x092C1E00
;period and ID for mVendPosition 
#DEFINE VEND_POS_PER 50ms
#DEFINE VEND_POS_1_CAN_ID 0x08640A00
#DEFINE VEND_POS_5_CAN_ID 0x08640A04
;period and ID for mButton 
#DEFINE BUTTON_PER 100ms
#DEFINE BUTTON_1_CAN_ID 0x09902800
#DEFINE BUTTON_5_CAN_ID 0x09902804
 

;definitions for outputs (output periods are determined by the setting in the .cf file)
#DEFINE VEND_CAN_ID 0x08C81400

;set input initial value
0.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 0
0.0s I VEND_MOTOR_PER N VEND_MOTOR_CAN_ID VendMotor = STOP
0.0s I VEND_POS_PER N VEND_POS_1_CAN_ID VendPosition 1 = false
0.0s I VEND_POS_PER N VEND_POS_5_CAN_ID VendPosition 5 = false
0.0s I BUTTON_PER N BUTTON_1_CAN_ID Button 1 = false
0.0s I BUTTON_PER N BUTTON_5_CAN_ID Button 5 = false

;#state 'S4.1 IDLE'
0.2s A F VendActuator : active == false
0.2s A N VEND_CAN_ID Vend : getVendState == false

;****verify no transition if button and position are different
1.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 2
1.0s I VEND_MOTOR_PER N VEND_MOTOR_CAN_ID VendMotor = STOP
1.0s I VEND_POS_PER N VEND_POS_5_CAN_ID VendPosition 5 = true
1.0s I BUTTON_PER N BUTTON_1_CAN_ID Button 1 = true

;#state 'S4.1 IDLE'
1.2s A F VendActuator : active == false
1.2s A N VEND_CAN_ID Vend : getVendState == false

;****verify no transition if button and position are same but coin count is less than 2
2.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 1
2.0s I VEND_MOTOR_PER N VEND_MOTOR_CAN_ID VendMotor = STOP
2.0s I VEND_POS_PER N VEND_POS_5_CAN_ID VendPosition 5 = false
2.3s I VEND_POS_PER N VEND_POS_1_CAN_ID VendPosition 1 = true
2.3s I BUTTON_PER N BUTTON_1_CAN_ID Button 1 = true

;#state 'S4.1 IDLE'
2.6s A F VendActuator : active == false
2.6s A N VEND_CAN_ID Vend : getVendState == false

;****verify no transition if button and position are same but coin count is greater than 2
3.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 3
3.0s I VEND_MOTOR_PER N VEND_MOTOR_CAN_ID VendMotor = STOP
3.0s I VEND_POS_PER N VEND_POS_1_CAN_ID VendPosition 1 = true
3.0s I BUTTON_PER N BUTTON_1_CAN_ID Button 1 = true

;#state 'S4.1 IDLE'
3.2s A F VendActuator : active == false
3.2s A N VEND_CAN_ID Vend : getVendState == false

;#transition 'T4.1'
4.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 2
4.0s I VEND_MOTOR_PER N VEND_MOTOR_CAN_ID VendMotor = STOP
4.0s I VEND_POS_PER N VEND_POS_1_CAN_ID VendPosition 1 = true
4.0s I BUTTON_PER N BUTTON_1_CAN_ID Button 1 = true

;#state 'S4.2 VEND'
4.2s A F VendActuator : active == true
4.2s A N VEND_CAN_ID Vend : getVendState == true

;#transition 'T4.2'
;no variable to set, transition is based on internal state variable.
;but clear the button state so that the T4.1 transition is not re-triggered
4.25s I BUTTON_PER N BUTTON_1_CAN_ID Button 1 = false

;#state 'S4.1 IDLE'
4.7s A F VendActuator : active == false
4.7s A N VEND_CAN_ID Vend : getVendState == false




