UNPKG

@jamesgopsill/repetier-server-client

Version:
294 lines (293 loc) 9.39 kB
import { Actions } from "../index.js"; export async function listPrinter() { return this._sendAndListen(Actions.LIST_PRINTER); } export async function ping() { return this._sendAndListen(Actions.PING); } export async function extendPing(timeout) { const data = { timeout, }; return this._sendAndListen(Actions.EXTEND_PING, data); } export async function sendGcode(printer, cmd) { const data = { cmd, printer, }; return this._sendAndListen(Actions.SEND, data); } export async function stateList() { return this._sendAndListen(Actions.STATE_LIST); } export async function fetchLog(start = 0, filter = 10) { const data = { start, filter, }; return this._sendAndListen(Actions.RESPONSE, data); } export async function move(x, y, z, e, speed, relative = true) { const data = { x, y, z, e, speed, relative, }; return this._sendAndListen(Actions.MOVE, data); } export async function messages() { return this._sendAndListen(Actions.MESSAGES); } export async function removeMessage(id) { return this._sendAndListen(Actions.REMOVE_MESSAGE, { id, a: "" }); } export async function removeModel(id) { return this._sendAndListen(Actions.REMOVE_MODEL, { id }); } export async function listModels(group = "*") { return this._sendAndListen(Actions.LIST_MODELS, { group }); } export async function copyModel(id, autostart = false) { const data = { id, autostart }; return this._sendAndListen(Actions.COPY_MODEL, data); } export async function listJobs() { return this._sendAndListen(Actions.LIST_JOBS); } export async function modelInfo(id) { return this._sendAndListen(Actions.MODEL_INFO, { id }); } export async function jobInfo(id) { return this._sendAndListen(Actions.JOB_INFO, { id }); } export async function startJob(id) { return this._sendAndListen(Actions.START_JOB, { id }); } export async function stopJob() { return this._sendAndListen(Actions.START_JOB); } export async function continueJob() { return this._sendAndListen(Actions.CONTINUE_JOB); } export async function removeJob() { return this._sendAndListen(Actions.REMOVE_JOB); } export async function getPrinterConfig(printer = "") { return this._sendAndListen(Actions.GET_PRINTER_CONFIG, { printer }); } export async function setPrinterConfig(config) { return this._sendAndListen(Actions.SET_PRINTER_CONFIG, config); } export async function getScript(name) { return this._sendAndListen(Actions.GET_SCRIPT, { name }); } export async function setScript(name, script) { return this._sendAndListen(Actions.SET_SCRIPT, { name, script }); } export async function activate(printer) { return this._sendAndListen(Actions.ACTIVATE, { printer }); } export async function deactivate(printer) { return this._sendAndListen(Actions.DEACTIVATE, { printer }); } export async function communicationData() { return this._sendAndListen(Actions.COMMUNICATION_DATA, {}); } export async function getEeprom() { return this._sendAndListen(Actions.GET_EEPROM); } export async function setEeprom(eeprom) { return this._sendAndListen(Actions.SET_EEPROM, { eeprom }); } export async function listExternalCommands() { return this._sendAndListen(Actions.LIST_EXTERNAL_COMMANDS); } export async function runExternalCommand(id) { return this._sendAndListen(Actions.LIST_EXTERNAL_COMMANDS, { id }); } export async function createConfiguration(printerName, printer) { const data = { name: printerName, slug: printer, }; return this._sendAndListen(Actions.LIST_EXTERNAL_COMMANDS, data); } export async function removeConfiguration(printer) { return this._sendAndListen(Actions.REMOVE_CONFIGURATION, { slug: printer }); } export async function getSettings() { return this._sendAndListen(Actions.GET_SETTINGS); } export async function updateSettings(settings) { return this._sendAndListen(Actions.UPDATE_SETTINGS, settings); } export async function updateUserSettings(settings) { return this._sendAndListen(Actions.UPDATE_USER_SETTINGS, settings); } export async function userlist() { return this._sendAndListen(Actions.USER_LIST); } export async function createUser(login, password, permissions) { return this._sendAndListen(Actions.CREATE_USER, { login, password, permissions, }); } export async function updateUser(login, permissions, password) { return this._sendAndListen(Actions.UPDATE_USER, { login, password, permissions, }); } export async function deleteUser(login) { return this._sendAndListen(Actions.DELETE_USER, { login }); } export async function listPorts() { return this._sendAndListen(Actions.LIST_PORTS); } export async function updateAvailable() { return this._sendAndListen(Actions.UPDATE_AVAILABLE); } export async function ignoreUpdate() { return this._sendAndListen(Actions.IGNORE_UPDATE); } export async function testPushMessage() { return this._sendAndListen(Actions.TEST_PUSH_MESSAGE); } export async function listFirmwareNames() { return this._sendAndListen(Actions.LIST_FIRMWARE_NAMES); } export async function startUpdateFirmwareSettings() { return this._sendAndListen(Actions.START_UPDATE_FIRMWARE_SETTINGS); } export async function getFirmwareSettings() { return this._sendAndListen(Actions.GET_FIRMWARE_SETTINGS); } export async function getFirmwareData() { return this._sendAndListen(Actions.GET_FIRMWARE_DATA); } export async function listLogs() { return this._sendAndListen(Actions.LIST_LOGS); } export async function removeLog(log) { return this._sendAndListen(Actions.REMOVE_LOG, { log }); } export async function setLogLevel(level) { return this._sendAndListen(Actions.REMOVE_LOG, { level }); } export async function sendMoves() { return this._sendAndListen(Actions.SEND_MOVES); } export async function hideMoves() { return this._sendAndListen(Actions.HIDE_MOVES); } export async function setSpeedMultiplier(speed) { return this._sendAndListen(Actions.SET_SPEED_MULTIPLY, { speed }); } export async function setFlowMultiplier(speed) { return this._sendAndListen(Actions.SET_FLOW_MULTIPLY, { speed }); } export async function setFanSpeed(speed, fan = 0) { return this._sendAndListen(Actions.SET_FAN_SPEEED, { speed, fanId: fan }); } export async function setExtruderTemperature(temperature, extruder = 0) { return this._sendAndListen(Actions.SET_FAN_SPEEED, { temperature, extruder }); } export async function setBedTemperature(temperature, bed = 0) { return this._sendAndListen(Actions.SET_BED_TEMPERATURE, { temperature, bedId: bed, }); } export async function setChamberTemperature(temperature, chamber = 0) { return this._sendAndListen(Actions.SET_CHAMBER_TEMPERATURE, { temperature, chamberId: chamber, }); } export async function emergencyStop() { return this._sendAndListen(Actions.EMERGENCY_STOP); } export async function version() { return this._sendAndListen(Actions.VERSION); } export async function getPrinterSetting(key) { return this._sendAndListen(Actions.GET_PRINTER_SETTING, { key }); } export async function setPrinterSetting(key, value) { let data = {}; data[key] = value; return this._sendAndListen(Actions.SET_PRINTER_SETTING, data); } export async function getPrinterSettings() { return this._sendAndListen(Actions.GET_PRINTER_SETTINGS); } export async function listModelGroups() { return this._sendAndListen(Actions.LIST_MODEL_GROUPS); } export async function addModelGroup(groupName) { return this._sendAndListen(Actions.ADD_MODEL_GROUP, { groupName }); } export async function deleteModelGroup(groupName, delFiles) { return this._sendAndListen(Actions.DELETE_MODEL_GROUP, { groupName, delFiles, }); } export async function moveModelFileToGroup(groupName, fileId) { return this._sendAndListen(Actions.MOVE_MODEL_FILE_TO_GROUP, { groupName, fileId, }); } export async function listFilesystemFolders() { return this._sendAndListen(Actions.LIST_FILESYSTEM_FOLDERS); } export async function getFolders() { return this._sendAndListen(Actions.GET_FOLDERS); } export async function setFolders(folders) { return this._sendAndListen(Actions.SET_FOLDERS, folders); } export async function browseFolder(folder, root, next) { return this._sendAndListen(Actions.BROWSE_FOLDERS, { folder, root, next, }); } export async function importUrl(folder, files) { return this._sendAndListen(Actions.IMPORT_URL, { folder, files, }); } export async function canUploadGCodeWithSize(size) { return this._sendAndListen(Actions.CAN_UPLOAD_GCODE_WITH_SIZE, { size }); } export async function cooldown(extruder, bed, chamber) { return this._sendAndListen(Actions.COOLDOWN, { extruder, bed, chamber, }); } export async function preheat(extruder, bed, chamber) { return this._sendAndListen(Actions.PREHEAT, { extruder, bed, chamber, }); } export async function babystep(z) { return this._sendAndListen(Actions.PREHEAT, { z }); } export async function sendQuickCommand(name) { return this._sendAndListen(Actions.SEND_QUICK_COMMAND, { name }); }