<?xml version="1.0" encoding="UTF-8"?>
<ATB_APP_STATES version="1.1">
    <APP_STATE name="IDLE">
        <EVENT name="BUTTON_START" resultingState="PRODUCT_SELECTION"/>
        <EVENT name="SELL_DISABLE" resultingState="FREE_PARK"/>
        <SCREEN name="START"/>
        <MODE name="IDLE"/>
    </APP_STATE>
    <APP_STATE name="FREE_PARK">
        <EVENT name="SELL_ENABLE" resultingState="IDLE"/>
        <SCREEN name="START"/>
        <MODE name="IDLE"/>
    </APP_STATE>
    
    
    <APP_STATE name="PRODUCT_SELECTION">
        <EVENT name="BUTTON_CANCEL" resultingState="IDLE"/>
        <EVENT name="BUTTON_VEHICLE_1" resultingState="LICENSEPLATE_INPUT" setCashInputMode="PAY_UP"   setProduct="SHORT_TERM_PARKING"/>
        <EVENT name="BUTTON_VEHICLE_2" resultingState="LICENSEPLATE_INPUT_FINE_PAYMENT" setCashInputMode="PAY_DOWN" setProduct="FINE_PAYMENT"/>
        <SCREEN name="PRODUCT_SELECTION"/>
    </APP_STATE>
    
    <APP_STATE name="LICENSEPLATE_INPUT">
        <EVENT name="BUTTON_CANCEL" resultingState="IDLE"/>
        <EVENT name="BUTTON_NEXT" resultingState="PAYMENT_SELECTION_SHORT_TIME"/>
        <SCREEN name="LICENSEPLATE_INPUT"/>
    </APP_STATE>
    
    <APP_STATE name="LICENSEPLATE_INPUT_FINE_PAYMENT">
        <EVENT name="BUTTON_CANCEL" resultingState="IDLE"/>
        <EVENT name="BUTTON_NEXT" resultingState="ENTER_TICKET_NUMBER"/>
        <SCREEN name="LICENSEPLATE_INPUT"/>
    </APP_STATE>
    
    <!-- ************** FINE PAYMENT *************** -->
    
    <APP_STATE name="FINE_PAYMENT_WAIT">
        <ENTRY_TASK name="REQUEST_INITIAL_PRICE"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="ENTER_TICKET_NUMBER"/>
        <EVENT name="BUTTON_CANCEL" resultingState="IDLE"/>
        <SCREEN name="WAIT_2"/>
    </APP_STATE>
    <APP_STATE name="ENTER_TICKET_NUMBER">
        <EVENT name="BUTTON_CANCEL" resultingState="IDLE"/>
        <EVENT name="NEW_PIN" resultingState="FINE_PAYMENT_WAIT_2"/>
        <SCREEN name="RESIDENT"/>
    </APP_STATE>
    <APP_STATE name="FINE_PAYMENT_WAIT_2">
        <ENTRY_TASK name="REQUEST_FINE_PAYMENT_PRICE"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="RECEIVED_FINE_PAYMENT_PRICE_SUCCESS" resultingState="PAYMENT_SELECTION_FINE_PAYMENT"/>
        <EVENT name="RECEIVED_FINE_PAYMENT_PRICE_ERROR" resultingState="ABORT_FINE_PAYMENT_NOT_AVAILABLE"/>
        <EVENT name="RECEIVED_FINE_PAYMENT_PRICE_ERROR_BACKEND" resultingState="ABORT_FINE_PAYMENT_NOT_AVAILABLE"/>
        <EVENT name="RECEIVED_FINE_PAYMENT_PRICE_ERROR_STATUS" resultingState="ABORT_FINE_PAYMENT_STATUS"/>
        <SCREEN name="WAIT_2"/>
    </APP_STATE>   
    
    <APP_STATE name="PRINT_FINE_PAYMENT_RECEIPT">
        <ENTRY_TASK name="REQUEST_PRINT_CUSTOMER_TICKET_2"/>
        <EVENT name="PRINT_TICKET_FINISHED" resultingState="FINE_PAYMENT_SUCCESS"/>
        <EVENT name="PRINT_TICKET_ERROR" resultingState="PRINT_TICKET_FAILED"/>
        <SCREEN name="PRINT_RECEIPT_2"/>
    </APP_STATE>
    <APP_STATE name="FINE_PAYMENT_SUCCESS">
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="GOODBYE_3"/>
    </APP_STATE>

    
    <!-- ************** FINE PAYMENT: ABORT STATES ************** -->  
    
    <APP_STATE name="ABORT_FINE_PAYMENT_NOT_AVAILABLE">
        <ENTRY_TASK name="REQUEST_ISMAS_FAIL_TRANSACTION"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="ABORT_8"/>
    </APP_STATE>   
    <APP_STATE name="ABORT_NOT_ALLOWED">
        <ENTRY_TASK name="REQUEST_ISMAS_FAIL_TRANSACTION"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="ABORT_6"/>
    </APP_STATE> 
    <APP_STATE name="ABORT_FINE_PAYMENT_STATUS">
        <ENTRY_TASK name="REQUEST_ISMAS_FAIL_TRANSACTION"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="ABORT_7"/>
    </APP_STATE>
    
    
    <!-- ************** PAYMENT SELECTION ************** -->
    
    <APP_STATE name="PAYMENT_SELECTION_SHORT_TIME">
        <EVENT name="BUTTON_CANCEL" resultingState="IDLE"/>
        <EVENT name="BUTTON_PAYMETHOD_1" resultingState="IDLE"/>
        <EVENT name="BUTTON_PAYMETHOD_2" resultingState="CASH_PAYMENT" setPaymentType="CASH"/>
        <EVENT name="BUTTON_PAYMETHOD_3" resultingState="PARKTIME_SELECTION" setPaymentType="CARD"/>
        <EVENT name="BUTTON_PAYMETHOD_4" resultingState="IDLE"/>
        <SCREEN name="PAYMENT_SELECTION"/>
    </APP_STATE>   
    <APP_STATE name="PAYMENT_SELECTION_FINE_PAYMENT">
        <EVENT name="BUTTON_CANCEL" resultingState="IDLE"/>
        <EVENT name="BUTTON_PAYMETHOD_1" resultingState="IDLE"/>
        <EVENT name="BUTTON_PAYMETHOD_2" resultingState="CASH_PAYMENT" setPaymentType="CASH"/>
        <EVENT name="BUTTON_PAYMETHOD_3" resultingState="CARD_PAYMENT" setPaymentType="CARD"/>
        <EVENT name="BUTTON_PAYMETHOD_4" resultingState="IDLE"/>
        <SCREEN name="PAYMENT_SELECTION"/>
    </APP_STATE>  
    
    
    <!-- ************** PARKTIME SELECTION ************** -->
    
    <APP_STATE name="PARKTIME_SELECTION">
        <ENTRY_TASK name="REQUEST_INITIAL_PRICE"/>
        <EVENT name="BUTTON_PLUS_STEP"  resultingState="PARKTIME_SELECTION_PLUS"/>
        <EVENT name="BUTTON_MINUS_STEP" resultingState="PARKTIME_SELECTION_MINUS"/>
        <EVENT name="BUTTON_CANCEL" resultingState="IDLE"/>
        <EVENT name="BUTTON_BACK" resultingState="PAYMENT_SELECTION"/>
        <EVENT name="BUTTON_NEXT" resultingState="CARD_PAYMENT"/>
        <SCREEN name="PARKTIME_SELECTION"/>
    </APP_STATE>
    <APP_STATE name="PARKTIME_SELECTION_PLUS">
        <ENTRY_TASK name="REQUEST_STEP_UP_PRICE"/>
        <EVENT name="BUTTON_PLUS_STEP"  resultingState="PARKTIME_SELECTION_PLUS"/>
        <EVENT name="BUTTON_MINUS_STEP" resultingState="PARKTIME_SELECTION_MINUS"/>
        <EVENT name="BUTTON_CANCEL" resultingState="IDLE"/>
        <EVENT name="BUTTON_BACK" resultingState="PAYMENT_SELECTION"/>
        <EVENT name="BUTTON_NEXT" resultingState="CARD_PAYMENT"/>
    </APP_STATE>
    <APP_STATE name="PARKTIME_SELECTION_MINUS">
        <ENTRY_TASK name="REQUEST_STEP_DOWN_PRICE"/>
        <EVENT name="BUTTON_PLUS_STEP"  resultingState="PARKTIME_SELECTION_PLUS"/>
        <EVENT name="BUTTON_MINUS_STEP" resultingState="PARKTIME_SELECTION_MINUS"/>
        <EVENT name="BUTTON_CANCEL" resultingState="IDLE"/>
        <EVENT name="BUTTON_BACK" resultingState="PAYMENT_SELECTION"/>
        <EVENT name="BUTTON_NEXT" resultingState="CARD_PAYMENT"/>
    </APP_STATE>
    
    
    <!-- ************** CASH PAYMENT ************** -->
    
    <APP_STATE name="CASH_PAYMENT">
        <ENTRY_TASK name="REQUEST_CASH_INPUT"/>
        <EVENT name="RECEIVED_CASH_INPUT" resultingState="CASH_PAYMENT_INPUT"/>
        <EVENT name="RECEIVED_CASH_INPUT_ERROR" resultingState="CASH_PAYMENT_ERROR"/>
        <EVENT name="BUTTON_CANCEL" resultingState="CASH_PAYMENT_ABORT"/>
        <SCREEN name="COIN_PAYMENT"/>
    </APP_STATE>
    <APP_STATE name="CASH_PAYMENT_INPUT">
        <ENTRY_TASK name="REQUEST_PARKING_ENDTIME"/>
        <EVENT name="RECEIVED_CASH_INPUT" resultingState="CASH_PAYMENT_INPUT"/>
        <EVENT name="RECEIVED_CASH_INPUT_OVERPAYED" resultingState="CASH_OVERPAYED_ASK"/>
        <EVENT name="RECEIVED_CASH_INPUT_FINISHED" resultingState="PRINT_TICKET_CASH"/>
        <EVENT name="RECEIVED_CASH_INPUT_ERROR" resultingState="CASH_PAYMENT_ERROR"/>
        <EVENT name="BUTTON_CANCEL" resultingState="CASH_PAYMENT_ABORT"/>
        <EVENT name="BUTTON_NEXT" task="PAYMENT_ACCEPTED" resultingState="CASH_PAYMENT_INPUT"/>
    </APP_STATE>
    <APP_STATE name="CASH_PAYMENT_ERROR">
        <ENTRY_TASK name="REQUEST_ISMAS_FAIL_TRANSACTION"/>
        <ENTRY_TASK name="CASH_ABORT"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="CASH_PAYMENT_FAILED" note="screennumber 0x39"/>
    </APP_STATE>
    
    <APP_STATE name="CASH_OVERPAYED_ASK">
        <ENTRY_TASK name="PAYMENT_ACCEPTED"/>
        <EVENT name="BUTTON_YES" resultingState="PRINT_TICKET_CASH"/>
        <EVENT name="BUTTON_NO"  resultingState="CASH_OVERPAYED_ABORT"/> 
        <SCREEN name="CASH_OVERPAYED" note="screennumber 0x3c"/>
    </APP_STATE>   
    
    <APP_STATE name="CASH_OVERPAYED_ABORT">
        <ENTRY_TASK name="REQUEST_ISMAS_FAIL_TRANSACTION"/>
        <ENTRY_TASK name="CASH_ABORT"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="CASH_CHANGE_OVERPAID" note="screennumber 0x8a"/>
    </APP_STATE>
    <APP_STATE name="CASH_PAYMENT_ABORT">
        <ENTRY_TASK name="REQUEST_ISMAS_FAIL_TRANSACTION"/>
        <ENTRY_TASK name="CASH_ABORT"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
    </APP_STATE>
    
    
    <!-- ************** CARD PAYMENT ************** -->
    
    <APP_STATE name="CARD_PAYMENT">
        <ENTRY_TASK name="REQUEST_PARKING_ENDTIME" key="PRICE_INFO_GROSS"/>
        <ENTRY_TASK name="REQUEST_CC_START_TRANSACTION"/>
        <EVENT name="RECEIVED_CARD_TRANSACTION_SUCCESS" resultingState="PRINT_TICKET_CARD"/>
        <EVENT name="RECEIVED_CARD_TRANSACTION_ERROR" resultingState="CC_PAYMENT_ERROR"/>
        <EVENT name="BUTTON_CANCEL" resultingState="USER_CC_ABORT"/>
        <SCREEN name="CC_PAYMENT"/>
    </APP_STATE>
    
    
    <!-- ************** PRINT TICKET / GOOD ISSUE ************** -->
    
    <APP_STATE name="PRINT_TICKET_CASH">
        <ENTRY_TASK name="REQUEST_PRINT_TICKET"/>
        <EVENT name="PRINT_TICKET_FINISHED" resultingState="GOODBYE_PAYMENT_OK"/>
        <EVENT name="PRINT_TICKET_ERROR" resultingState="PRINT_TICKET_FAILED"/>
        <SCREEN name="SCREEN_WAITFOR"/>
    </APP_STATE>
    <APP_STATE name="PRINT_TICKET_CARD">
        <ENTRY_TASK name="REQUEST_PRINT_TICKET"/>
        <EVENT name="PRINT_TICKET_FINISHED" resultingState="CARD_PAYMENT_CONFIRM"/>
        <EVENT name="PRINT_TICKET_ERROR" resultingState="PRINT_TICKET_FAILED"/>
        <SCREEN name="SCREEN_WAITFOR"/>
    </APP_STATE>     
    <APP_STATE name="PRINT_TICKET_FAILED">
        <ENTRY_TASK name="REQUEST_CC_CANCEL_TRANSACTION"/>
        <ENTRY_TASK name="REQUEST_ISMAS_FAIL_TRANSACTION"/>
        <ENTRY_TASK name="CASH_ABORT"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="PRINT_TICKET_FAILED"/>
    </APP_STATE>   
    
    
    <!-- ************** CONFIRM CARD PAYMENT ************** -->
    
    <APP_STATE name="CARD_PAYMENT_CONFIRM">
        <ENTRY_TASK name="REQUEST_CC_CONFIRM_TRANSACTION"/>
        <EVENT name="RECEIVED_CARD_CONFIRM_TRANSACTION_SUCCESS" resultingState="ASK_RECEIPT"/>
        <EVENT name="RECEIVED_CARD_CONFIRM_TRANSACTION_ERROR"   resultingState="CC_PAYMENT_ERROR"/>
    </APP_STATE>
    
    <APP_STATE name="ASK_RECEIPT">
        <ENTRY_TASK name="TIMER" timeout="8000"/>
        <EVENT name="TIMEOUT" resultingState="GOODBYE_PAYMENT_OK"/>
        <EVENT name="BUTTON_YES" resultingState="PRINT_RECEIPT"/>
        <EVENT name="BUTTON_NO"  resultingState="GOODBYE_PAYMENT_OK"/>
        <SCREEN name="ASK_RECEIPT"/>
    </APP_STATE>
    
    <APP_STATE name="PRINT_RECEIPT">
        <ENTRY_TASK name="REQUEST_PRINT_RECEIPT"/>
        <EVENT name="PRINT_RECEIPT_FINISHED" resultingState="GOODBYE_PAYMENT_OK"/>
        <EVENT name="PRINT_RECEIPT_ERROR" resultingState="PRINT_TICKET_FAILED"/>
    </APP_STATE>   
    
    
    <!-- ************** GOODBYE ************** -->
    
    <APP_STATE name="GOODBYE_PAYMENT_OK">
        <ENTRY_TASK name="CASH_COLLECT"/>
        <ENTRY_TASK name="REQUEST_ISMAS_TRANSACTION"/>
        <ENTRY_TASK name="TIMER" timeout="5000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="GOODBYE_PAYMENT_OK"/>
    </APP_STATE>
    
    
    <!-- ************** CARD PAYMENT ERROR / ABORT ************** -->
    
    <APP_STATE name="CC_PAYMENT_ERROR">
        <ENTRY_TASK name="REQUEST_ISMAS_FAIL_TRANSACTION"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="CC_PAYMENT_ERROR"/>
    </APP_STATE>
    <APP_STATE name="USER_CC_ABORT">
        <ENTRY_TASK name="REQUEST_ISMAS_FAIL_TRANSACTION"/>
        <ENTRY_TASK name="REQUEST_CC_CANCEL_TRANSACTION"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="USER_ABORT"/>
    </APP_STATE>  
    
 
    <!-- ************** ABORT STATES ************** -->  
    
    <APP_STATE name="ABORT_NOCONNECTION">
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="ABORT_2"/>
    </APP_STATE>   
    <APP_STATE name="ABORT_NOCARD">
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="ABORT_4"/>
    </APP_STATE>    
    <APP_STATE name="ABORT_CARD_DENIED">
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="ABORT_5"/>
    </APP_STATE>     
    <APP_STATE name="ABORT_NOT_ALLOWED">
        <ENTRY_TASK name="REQUEST_ISMAS_FAIL_TRANSACTION"/>
        <ENTRY_TASK name="TIMER" timeout="3000"/>
        <EVENT name="TIMEOUT" resultingState="IDLE"/>
        <SCREEN name="ABORT_6"/>
    </APP_STATE>
    
    
</ATB_APP_STATES>