test_client: Update websocket APIs
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
8eaef1e559
commit
59277f8b7a
|
@ -10,79 +10,81 @@ import JsonRPC from "./json-rpc.js?v=0.1.2";
|
||||||
var api = {
|
var api = {
|
||||||
printer_info: {
|
printer_info: {
|
||||||
url: "/printer/info",
|
url: "/printer/info",
|
||||||
method: "get_printer_info"
|
method: "printer.info"
|
||||||
},
|
},
|
||||||
gcode_script: {
|
gcode_script: {
|
||||||
url: "/printer/gcode/script",
|
url: "/printer/gcode/script",
|
||||||
method: "post_printer_gcode_script"
|
method: "printer.gcode.script"
|
||||||
},
|
},
|
||||||
gcode_help: {
|
gcode_help: {
|
||||||
url: "/printer/gcode/help",
|
url: "/printer/gcode/help",
|
||||||
method: "get_printer_gcode_help"
|
method: "printer.gcode.help"
|
||||||
},
|
},
|
||||||
start_print: {
|
start_print: {
|
||||||
url: "/printer/print/start",
|
url: "/printer/print/start",
|
||||||
method: "post_printer_print_start"
|
method: "printer.print.start"
|
||||||
},
|
},
|
||||||
cancel_print: {
|
cancel_print: {
|
||||||
url: "/printer/print/cancel",
|
url: "/printer/print/cancel",
|
||||||
method: "post_printer_print_cancel"
|
method: "printer.print.cancel"
|
||||||
},
|
},
|
||||||
pause_print: {
|
pause_print: {
|
||||||
url: "/printer/print/pause",
|
url: "/printer/print/pause",
|
||||||
method: "post_printer_print_pause"
|
method: "printer.print.pause"
|
||||||
},
|
},
|
||||||
resume_print: {
|
resume_print: {
|
||||||
url: "/printer/print/resume",
|
url: "/printer/print/resume",
|
||||||
method: "post_printer_print_resume"
|
method: "printer.print.resume"
|
||||||
},
|
},
|
||||||
query_endstops: {
|
query_endstops: {
|
||||||
url: "/printer/query_endstops/status",
|
url: "/printer/query_endstops/status",
|
||||||
method: "get_printer_query_endstops_status"
|
method: "printer.query_endstops.status"
|
||||||
},
|
},
|
||||||
object_list: {
|
object_list: {
|
||||||
url: "/printer/objects/list",
|
url: "/printer/objects/list",
|
||||||
method: "get_printer_objects_list"
|
method: "printer.objects.list"
|
||||||
},
|
},
|
||||||
object_status: {
|
object_status: {
|
||||||
url: "/printer/objects/query",
|
url: "/printer/objects/query",
|
||||||
method: "get_printer_objects_query"
|
method: "printer.objects.query"
|
||||||
},
|
},
|
||||||
object_subscription: {
|
object_subscription: {
|
||||||
url: "/printer/objects/subscribe",
|
url: "/printer/objects/subscribe",
|
||||||
method: {
|
method: "printer.objects.subscribe"
|
||||||
post: "post_printer_objects_subscribe",
|
|
||||||
get: "get_printer_objects_subscribe"
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
temperature_store: {
|
temperature_store: {
|
||||||
url: "/server/temperature_store",
|
url: "/server/temperature_store",
|
||||||
method: "get_server_temperature_store"
|
method: "server.temperature_store"
|
||||||
},
|
},
|
||||||
estop: {
|
estop: {
|
||||||
url: "/printer/emergency_stop",
|
url: "/printer/emergency_stop",
|
||||||
method: "post_printer_emergency_stop"
|
method: "printer.emergency_stop"
|
||||||
},
|
},
|
||||||
restart: {
|
restart: {
|
||||||
url: "/printer/restart",
|
url: "/printer/restart",
|
||||||
method: "post_printer_restart"
|
method: "printer.restart"
|
||||||
},
|
},
|
||||||
firmware_restart: {
|
firmware_restart: {
|
||||||
url: "/printer/firmware_restart",
|
url: "/printer/firmware_restart",
|
||||||
method: "post_printer_firmware_restart"
|
method: "printer.firmware_restart"
|
||||||
},
|
},
|
||||||
|
|
||||||
// File Management Apis
|
// File Management Apis
|
||||||
file_list:{
|
file_list:{
|
||||||
url: "/server/files/list",
|
url: "/server/files/list",
|
||||||
method: "get_file_list"
|
method: "server.files.list"
|
||||||
},
|
},
|
||||||
metadata: {
|
metadata: {
|
||||||
url: "/server/files/metadata",
|
url: "/server/files/metadata",
|
||||||
method: "get_file_metadata"
|
method: "server.files.metadata"
|
||||||
},
|
},
|
||||||
directory: {
|
directory: {
|
||||||
url: "/server/files/directory"
|
url: "/server/files/directory",
|
||||||
|
method: {
|
||||||
|
get: "server.files.get_directory",
|
||||||
|
post: "server.files.post_directory",
|
||||||
|
delete: "server.files.delete_directory"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
upload: {
|
upload: {
|
||||||
url: "/server/files/upload"
|
url: "/server/files/upload"
|
||||||
|
@ -106,11 +108,11 @@ var api = {
|
||||||
// Machine APIs
|
// Machine APIs
|
||||||
reboot: {
|
reboot: {
|
||||||
url: "/machine/reboot",
|
url: "/machine/reboot",
|
||||||
method: "post_machine_reboot"
|
method: "machine.reboot"
|
||||||
},
|
},
|
||||||
shutdown: {
|
shutdown: {
|
||||||
url: "/machine/shutdown",
|
url: "/machine/shutdown",
|
||||||
method: "post_machine_shutdown"
|
method: "machine.shutdown"
|
||||||
},
|
},
|
||||||
|
|
||||||
// Access APIs
|
// Access APIs
|
||||||
|
@ -379,26 +381,26 @@ function get_object_list() {
|
||||||
|
|
||||||
function add_subscription(printer_objects) {
|
function add_subscription(printer_objects) {
|
||||||
json_rpc.call_method_with_kwargs(
|
json_rpc.call_method_with_kwargs(
|
||||||
api.object_subscription.method.post, printer_objects)
|
api.object_subscription.method, printer_objects)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
// result is the the state from all fetched data
|
// result is the the state from all fetched data
|
||||||
handle_status_update(result.status)
|
handle_status_update(result.status)
|
||||||
console.log(result);
|
console.log(result);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
update_error(api.object_subscription.method.post, error);
|
update_error(api.object_subscription.method, error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_subscribed() {
|
function get_subscribed() {
|
||||||
json_rpc.call_method(api.object_subscription.method.get)
|
json_rpc.call_method(api.object_subscription.method)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
// result is a dictionary containing all currently subscribed
|
// result is a dictionary containing all currently subscribed
|
||||||
// printer objects/attributes
|
// printer objects/attributes
|
||||||
console.log(result);
|
console.log(result);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
update_error(api.object_subscription.method.get, error);
|
update_error(api.object_subscription.method, error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -634,7 +636,7 @@ function send_gcode_batch(gcodes) {
|
||||||
for (let gc of gcodes) {
|
for (let gc of gcodes) {
|
||||||
batch.push(
|
batch.push(
|
||||||
{
|
{
|
||||||
method: 'post_printer_gcode_script',
|
method: api.gcode_script.method,
|
||||||
type: 'request',
|
type: 'request',
|
||||||
params: {script: gc}
|
params: {script: gc}
|
||||||
});
|
});
|
||||||
|
@ -675,7 +677,7 @@ async function send_gcode_macro(gcodes) {
|
||||||
for (let gc of gcodes) {
|
for (let gc of gcodes) {
|
||||||
try {
|
try {
|
||||||
let result = await json_rpc.call_method_with_kwargs(
|
let result = await json_rpc.call_method_with_kwargs(
|
||||||
'post_printer_gcode_script', {script: gc});
|
api.gcode_script.method, {script: gc});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Error executing gcode macro: " + err.message);
|
console.log("Error executing gcode macro: " + err.message);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue