; 18649 Spring 2010
; group 7
; Justin Ray/justinr2
; other names would go here
; button_control_1.mf

;perform the button control test with button 2

;definitions for inputs
;period and ID for mEmpty
#DEFINE EMPTY_PER 500ms
;ID = base + 1 for chute 2
#DEFINE EMPTY_CAN_ID 0x0ABC4601
;physical button period
#DEFINE BTN_PER 50ms
;period and ID for mVend
#DEFINE VEND_PER 50ms
#DEFINE VEND_CAN_ID 0x08C81400
;period and ID for mCoinCount
#DEFINE COIN_COUNT_PER 100ms
#DEFINE COIN_COUNT_CAN_ID 0x0A583C00

;definitions for outputs (output periods are determined by the setting in the .cf file)
;ID = base + 1 for button 2
#DEFINE BUTTON_CAN_ID 0x09902801

;set input initial value
0.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 0
0.0s I BTN_PER F Button 2 = false
0.0s I EMPTY_PER N EMPTY_CAN_ID Empty 2 = false
0.0s I VEND_PER N VEND_CAN_ID Vend = false

;#state 'S2.1 IDLE'
0.2s A F Light 2 : lighted == true
0.2s A N BUTTON_CAN_ID Button 2 : getButtonState == false

;#transition 'T2.1'
1.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 2
1.0s I VEND_PER N VEND_CAN_ID Vend = false
1.0s I BTN_PER F Button 2 = true
;mEmpty already false
;release button
1.2s I BTN_PER F Button 2 = false

;#state 'S2.4 FLASH_OFF'
1.41s A F Light 2 : lighted == false
1.41s A N BUTTON_CAN_ID Button 2 : getButtonState == true

;#transition 'T2.4'
;no state change necessary, transition occurs due to internal state variable - check after 0.5 s

;#state 'S2.5 FLASH_ON'
1.91s A F Light 2 : lighted == true
1.91s A N BUTTON_CAN_ID Button 2 : getButtonState == true

;#transition 'T2.5'
;no state change necessary, transition occurs due to internal state variable - check after 0.5 s

;#state 'S2.4 FLASH_OFF'
2.41s A F Light 2 : lighted == false
2.41s A N BUTTON_CAN_ID Button 2 : getButtonState == true

;#transition 'T2.2'
2.5s I VEND_PER N VEND_CAN_ID Vend = true
;mEmpty already false

;Coin count gets reset during vend
2.s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 0

;#state 'S2.1 IDLE'
2.81s A F Light 2 : lighted == true
2.81s A N BUTTON_CAN_ID Button 2 : getButtonState == false

;release vend
2.9s I VEND_PER N VEND_CAN_ID Vend = false

;#transition 'T2.1'
6.0s I COIN_COUNT_PER N COIN_COUNT_CAN_ID CoinCount = 2
6.0s I VEND_PER N VEND_CAN_ID Vend = false
6.0s I BTN_PER F Button 2 = true
;mEmpty already false
;release button
6.2s I BTN_PER F Button 2 = false

;#state 'S2.4 FLASH_OFF'
6.41s A F Light 2 : lighted == false
6.41s A N BUTTON_CAN_ID Button 2 : getButtonState == true

;#transition 'T2.4'
;no state change necessary, transition occurs due to internal state variable - check after 0.5 s

;#state 'S2.5 FLASH_ON'
6.91s A F Light 2 : lighted == true
6.91s A N BUTTON_CAN_ID Button 2 : getButtonState == true

;#transition 'T2.5'
;no state change necessary, transition occurs due to internal state variable - check after 0.5 s

;#state 'S2.4 FLASH_OFF'
7.41s A F Light 2 : lighted == false
7.41s A N BUTTON_CAN_ID Button 2 : getButtonState == true

;#transition 'T2.3'
7.5s I EMPTY_PER N EMPTY_CAN_ID Empty 2 = true
7.5s I VEND_PER N VEND_CAN_ID Vend = true

;#state 'S2.2 EMPTY'
7.91s A F Light 2 : lighted == false
7.91s A N BUTTON_CAN_ID Button 2 : getButtonState == false

