// 枚举定义
const EnumConnectStatus = {
    connecting: 'connecting',
    connected: 'connected',
    disconnected: 'disconnected',
    connectFail: 'connectFail'
};

// todo 设备实体类
class DeviceBean {
    // 假设 DeviceBean 有以下属性
    constructor({ id, name, type }) {
        this.id = id;
        this.name = name;
        this.type = type;
    }

    toString() {
        return `DeviceBean{id: ${this.id}, name: ${this.name}, type: ${this.type}}`;
    }
}

// 连接事件类
class ConnectEvent {
    constructor({ status, device }) {
        this.status = status;
        this.device = device;
    }

    static connecting() {
        return new ConnectEvent({ status: EnumConnectStatus.connecting });
    }

    static success() {
        return new ConnectEvent({ status: EnumConnectStatus.connected });
    }

    static disconnect() {
        return new ConnectEvent({ status: EnumConnectStatus.disconnected });
    }

    static fail() {
        return new ConnectEvent({ status: EnumConnectStatus.connectFail });
    }

    toString() {
        return `ConnectEvent{status: ${this.status}, device: ${this.device ? this.device.toString() : 'null'}}`;
    }
}