function Command({ id, protocol, commandNumber, device, commandType, title, } = {}) { let _id = id; let _protocol = protocol; let _commandNumber = commandNumber; let _device = device; let _commandType = commandType; let _title = title; function getId() { return _id; } function setId(id) { _id = id; } function getProtocol() { return _protocol; } function setProtocol(protocol) { _protocol = protocol; } function getCommandNumber() { return _commandNumber; } function setCommandNumber(commandNumber) { _commandNumber = commandNumber; } function getDevice() { return _device; } function setDevice(device) { _device = device; } function getCommandType() { return _commandType; } function setCommandType(commandType) { _commandType = commandType; } function getTitle() { if (_title) return _title; return `${Command.CommandTypes[commandType]} (${Command.Protocols[protocol]})`; } function setTitle(title) { _title = title; } return { getId, setId, getProtocol, setProtocol, getCommandNumber, setCommandNumber, getDevice, setDevice, getCommandType, setCommandType, getTitle, setTitle, }; } Command.Protocols = { samsung: "Samsung", nec: "NEC", onkyo: "Onkyo", apple: "Apple", denon: "Denon", sharp: "Sharp", panasonic: "Panasonic", kaseikyo: "Kaseikyo", jvc: "JVC", lg: "LG", sony: "Sony", rc5: "RC5", rc6: "RC6", universal_pulse_distance: "Universal Pulse Distance", universal_pulse_width: "Universal Pulse Width", universal_pulse_distance_width: "Universal Pulse Distance Width", hash: "Hash", pronto: "Pronto", bose_wave: "BoseWave", bang_olufsen: "Bang & Olufsen", lego: "Lego", fast: "FAST", whynter: "Whynter", magiquest: "MagiQuest", }; Command.CommandTypes = { power: "Power", input: "Input", one: "1", two: "2", three: "3", four: "4", five: "5", six: "6", seven: "7", eight: "8", nine: "9", zero: "0", volume_up: "Volume Up", volume_down: "Volume Down", mute: "Mute", channel_up: "Channel Up", channel_down: "Channel Down", menu: "Menu", home: "Home", settings: "Settings", options: "Options", up: "Up", down: "Down", left: "Left", right: "Right", enter: "Enter", info: "Info", return: "Return", exit: "Exit", red: "Red", green: "Green", yellow: "Yellow", blue: "Blue", rewind: "Rewind", play: "Play", pause: "Pause", stop: "Stop", forward: "Forward", other: "Other", }; export default Command;