Skip to content

Latest commit

 

History

History
169 lines (134 loc) · 4.47 KB

jsontoolpath.md

File metadata and controls

169 lines (134 loc) · 4.47 KB

JsonToolpath (JT) v. 0.0.2

JT is a set of toolpaths that will be used to execute a print. The file extension used will be: ".jsontoolpath" A full example may be found here.

Glossary

Name Definition
Json Serializable Data Any of the following values: int, float, string, bool, list, dict, null
Plain Old Data (POD) Any of the following values: int, float, string, bool, null
Toolpath A set of instructions for a machine to make it produce a desired object, along with any comments/meta-data that make it easier for a human or computer to read and/or understand.

JT File

JT is a valid json file that is an array at its base. Inside the array are a series of json dicts. Those dicts contain all movement/actions necessary to print an object.

File Structure:

[
    {<packet_type>(string): <packet_data>(json_serializable_data)},
    {<packet_type>(string): <packet_data>(json_serializable_data)},
    ...
    {<packet_type>(string): <packet_data>(json_serializable_data)}
]

Toolpath

The "toolpath" contains all movement information in the .jsontoolpath file.
All information is encapsulatd in a packet, where a packet is comprised of a key in the form of a string, and some json serializable data as its value. Packets are assumed to be in order. The JT structure supports any number of packet types in this form:

<packet_type>(string): <packet_data>(json_serializable_data)

There are currently two packet_types supported by this spec: "command" and (as of v3.0) "comment".

Command Packet

A Command Packet contains fields that will result in some action taken by the printer (i.e. move some motors, heat some heaters, etc). All command packets are wrapped in {}, to denote a map.

{ "function": "", "parameters": { : <json_serializable_data>, : <json_serializable_data>, ... }, "metadata": {}, "tags": [], }

The function key will only have a single string as its value. The parameters dict will have a subdict as its value, where each key is in the form of a string and its value is some POD type.

Metadata's value is also a dict. Similar to parameters, values can only be POD types.

Tags are used to keep track of the current type of move. Since any specific command packet can be part of several different categories, we are storing them as a list.
All elements of the list must be strings.

JT will have a small set of understood commands; since the printer will have its own understanding of start/end routines, and JT is not intended to be a scripting language, there is no reason to have many of the superfluous commands (i.e. play_song, display_message, etc).

move
"command": {
    "function": "move",
    "parameters": {
        "x": <float>,          //mm
        "y": <float>,          //mm
        "z": <float>,          //mm
        "a": <float>,          //mm
        "feedrate": <float>,   //mm_per_sec
    },
    "metadata": {
        "relative": {
            "x": <bool>,
            "y": <bool>,
            "z": <bool>,
            "a": <bool>
        },
    }
}
set_toolhead_temperature
"command": {
    "function": "set_toolhead_temperature",
    "parameters": {
        "temperature": <float>,      //C
        "index": <int>,
    },
}
toggle_fan
"command": {
    "function": "toggle_fan",
    "parameters": {
        "value": <bool>,
        "index": <int>,
    }
}
fan_duty
"command": {
    "function": "fan_duty",
    "parameters": {
        "value": <float>,
        "index": <int>,
    }
}
change_toolhead
Not supported before version 3.0

"command": {
    "function": "change_toolhead",
    "parameters": {
        "index": <int>,
    }
}

Comment Packet

A comment packet in version 3.0 should be formatted as

{ "comment": "THIS IS A COMMENT" }

A comment may also be formatted (in versions 2.0 and in 3.0) as:

{   "command": {
        "function": "comment",
        "parameters": {
            "comment": "THIS IS A COMMENT"
        }
    }
}

There is no way to add a comment in version 1.0