; 18649 Spring 2010
; group 7
; Justin Ray/justinr2
; other names would go here
; vendpositioncontrol_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_PER 50ms
#DEFINE VEND_CAN_ID 0x08C81400
;period and ID for mVendPosition 
#DEFINE VEND_POS_PER 50ms
#DEFINE VEND_POS_1_CAN_ID 0x08640A00
#DEFINE VEND_POS_5_CAN_ID 0x08640A04
#DEFINE VEND_POS_8_CAN_ID 0x08640A07
;period and ID for mButton 
#DEFINE BUTTON_PER 100ms
#DEFINE BUTTON_1_CAN_ID 0x09902800
#DEFINE BUTTON_5_CAN_ID 0x09902804
#DEFINE BUTTON_8_CAN_ID 0x09902807
 

;definitions for outputs (output periods are determined by the setting in the .cf file)
#DEFINE VEND_MOTOR_CAN_ID 0x092C1E00

;set input initial value
0.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 0
0.0s I VEND_PER N VEND_CAN_ID Vend = false
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 = true
0.0s I VEND_POS_PER N VEND_POS_8_CAN_ID VendPosition 8 = 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
0.0s I BUTTON_PER N BUTTON_8_CAN_ID Button 8 = false

;#state 'S5.1 IDLE'
0.2s A F VendMotor : direction == STOP
0.2s A N VEND_MOTOR_CAN_ID VendMotor : getDirection == STOP

;verify no motion when the button and position are the same
1.0s I BUTTON_PER N BUTTON_5_CAN_ID Button 5 = true
1.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 2
 
;#state 'S5.1 IDLE'
1.2s A F VendMotor : direction == STOP
1.2s A N VEND_MOTOR_CAN_ID VendMotor : getDirection == STOP

;verify no motion when vend is true
2.0s I VEND_PER N VEND_CAN_ID Vend = true
2.2s I BUTTON_PER N BUTTON_5_CAN_ID Button 5 = false
2.2s I BUTTON_PER N BUTTON_1_CAN_ID Button 1 = true
 
;#state 'S5.1 IDLE'
2.4s A F VendMotor : direction == STOP
2.4s A N VEND_MOTOR_CAN_ID VendMotor : getDirection == STOP

;#transition 'T5.1'
3.0s I VEND_PER N VEND_CAN_ID Vend = false
3.0s I BUTTON_PER N BUTTON_5_CAN_ID Button 5 = false
3.0s I BUTTON_PER N BUTTON_1_CAN_ID Button 1 = true

;set position sensor 5 false
3.05s I VEND_POS_PER N VEND_POS_5_CAN_ID VendPosition 5 = false

;#state 'S5.2 MOVE'
3.2s A F VendMotor : direction == LEFT
3.2s A N VEND_MOTOR_CAN_ID VendMotor : getDirection == LEFT

;#transition 'T5.2'
4.0s I VEND_POS_PER N VEND_POS_1_CAN_ID VendPosition 1 = true

;#state 'S5.1 IDLE'
4.2s A F VendMotor : direction == STOP
4.2s A N VEND_MOTOR_CAN_ID VendMotor : getDirection == STOP






