states.py 428 Bytes
Newer Older
1
2
3
4
5
from enum import IntEnum

class TrainState(IntEnum):
    WAITING = 0
    READY_TO_DEPART = 1
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    MALFUNCTION_OFF_MAP = 2
    MOVING = 3
    STOPPED = 4
    MALFUNCTION = 5
    DONE = 6

    @classmethod
    def check_valid_state(cls, state):
        return state in cls._value2member_map_

    @staticmethod
    def is_malfunction_state(state):
        return state in [2, 5] # TODO: Can this be done with names instead?