<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_state_machine(self, state_machine):
 """Add a state machine to the list of managed state machines. If there is no active state machine set yet, then set as active state machine. :param state_machine: State Machine Object :raises exceptions.AttributeError: if the passed state machine was already added of is of a wrong type """

        if not isinstance(state_machine, StateMachine):
            raise AttributeError("State machine must be of type StateMachine")
        if state_machine.file_system_path is not None:
            if self.is_state_machine_open(state_machine.file_system_path):
                raise AttributeError("The state machine is already open {0}".format(state_machine.file_system_path))
        logger.debug("Add new state machine with id {0}".format(state_machine.state_machine_id))
        self._state_machines[state_machine.state_machine_id] = state_machine
        return state_machine.state_machine_id