dsf-python 3.4.5.post2__py3-none-any.whl → 3.4.6.post2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dsf/__init__.py +10 -10
- dsf/commands/__init__.py +2 -2
- dsf/commands/base_command.py +12 -12
- dsf/commands/code.py +161 -170
- dsf/commands/code_channel.py +50 -50
- dsf/commands/code_flags.py +55 -0
- dsf/commands/code_interception.py +31 -31
- dsf/commands/code_parameter.py +209 -208
- dsf/commands/code_type.py +24 -0
- dsf/commands/condition_type.py +41 -0
- dsf/commands/files.py +23 -23
- dsf/commands/generic.py +117 -117
- dsf/commands/http_endpoints.py +53 -53
- dsf/commands/model_subscription.py +9 -9
- dsf/commands/object_model.py +69 -69
- dsf/commands/packages.py +19 -19
- dsf/commands/plugins.py +84 -84
- dsf/commands/responses.py +54 -54
- dsf/commands/user_sessions.py +52 -52
- dsf/connections/__init__.py +52 -51
- dsf/connections/base_command_connection.py +244 -244
- dsf/connections/base_connection.py +151 -153
- dsf/connections/command_connection.py +11 -11
- dsf/connections/exceptions.py +16 -16
- dsf/connections/init_messages/__init__.py +1 -1
- dsf/connections/init_messages/client_init_messages.py +92 -64
- dsf/connections/init_messages/server_init_message.py +44 -44
- dsf/connections/intercept_connection.py +68 -51
- dsf/connections/subscribe_connection.py +65 -57
- dsf/exceptions.py +2 -2
- dsf/http.py +178 -178
- dsf/object_model/__init__.py +20 -20
- dsf/object_model/boards/__init__.py +10 -10
- dsf/object_model/boards/accelerometer.py +29 -29
- dsf/object_model/boards/boards.py +249 -248
- dsf/object_model/boards/closed_loop.py +29 -29
- dsf/object_model/boards/direct_display.py +40 -40
- dsf/object_model/boards/driver.py +15 -15
- dsf/object_model/boards/driver_settings.py +27 -27
- dsf/object_model/boards/min_max_current.py +41 -41
- dsf/object_model/boards/stall_detect_settings.py +62 -62
- dsf/object_model/directories/__init__.py +3 -3
- dsf/object_model/directories/directories.py +97 -97
- dsf/object_model/fans/__init__.py +4 -4
- dsf/object_model/fans/fan_thermostatic_control.py +37 -37
- dsf/object_model/fans/fans.py +105 -105
- dsf/object_model/heat/__init__.py +8 -8
- dsf/object_model/heat/heat.py +57 -57
- dsf/object_model/heat/heater.py +146 -146
- dsf/object_model/heat/heater_model.py +117 -115
- dsf/object_model/heat/heater_model_pid.py +63 -63
- dsf/object_model/heat/heater_monitor.py +85 -84
- dsf/object_model/http_endpoints/__init__.py +4 -4
- dsf/object_model/http_endpoints/http_endpoint_type.py +29 -29
- dsf/object_model/http_endpoints/http_endpoints.py +74 -73
- dsf/object_model/inputs/__init__.py +6 -6
- dsf/object_model/inputs/compatibility.py +26 -26
- dsf/object_model/inputs/distance_unit.py +14 -14
- dsf/object_model/inputs/input_channel.py +168 -164
- dsf/object_model/inputs/input_channel_state.py +20 -20
- dsf/object_model/job/__init__.py +10 -10
- dsf/object_model/job/build.py +55 -55
- dsf/object_model/job/build_object.py +46 -46
- dsf/object_model/job/gcode_fileinfo.py +121 -120
- dsf/object_model/job/job.py +173 -177
- dsf/object_model/job/layer.py +57 -57
- dsf/object_model/job/thumbnail_info.py +97 -96
- dsf/object_model/job/times_left.py +43 -43
- dsf/object_model/limits/__init__.py +3 -3
- dsf/object_model/limits/limits.py +285 -285
- dsf/object_model/messages/__init__.py +3 -3
- dsf/object_model/messages/messages.py +87 -83
- dsf/object_model/model_collection.py +59 -57
- dsf/object_model/model_dictionary.py +57 -55
- dsf/object_model/model_object.py +97 -94
- dsf/object_model/move/__init__.py +17 -16
- dsf/object_model/move/axis.py +259 -258
- dsf/object_model/move/current_move.py +64 -64
- dsf/object_model/move/driver_id.py +73 -72
- dsf/object_model/move/extruder.py +165 -165
- dsf/object_model/move/extruder_non_linear.py +39 -39
- dsf/object_model/move/input_shaping.py +102 -101
- dsf/object_model/move/kinematics/__init__.py +13 -13
- dsf/object_model/move/kinematics/core_kinematics.py +26 -26
- dsf/object_model/move/kinematics/delta_kinematics.py +74 -74
- dsf/object_model/move/kinematics/delta_tower.py +62 -62
- dsf/object_model/move/kinematics/hangprinter_kinematics.py +33 -33
- dsf/object_model/move/kinematics/kinematics.py +85 -85
- dsf/object_model/move/kinematics/kinematics_name.py +19 -19
- dsf/object_model/move/kinematics/polar_kinematics.py +13 -13
- dsf/object_model/move/kinematics/scara_kinematics.py +12 -12
- dsf/object_model/move/kinematics/tilt_correction.py +63 -63
- dsf/object_model/move/kinematics/zleadscrew_kinematics.py +16 -16
- dsf/object_model/move/microstepping.py +29 -29
- dsf/object_model/move/motors_idle_control.py +29 -29
- dsf/object_model/move/move.py +169 -169
- dsf/object_model/move/move_calibration.py +33 -33
- dsf/object_model/move/move_compensation.py +87 -88
- dsf/object_model/move/move_deviations.py +29 -29
- dsf/object_model/move/move_queue_item.py +29 -29
- dsf/object_model/move/move_rotation.py +27 -27
- dsf/object_model/move/move_segmentation.py +27 -27
- dsf/object_model/move/probe_grid.py +48 -48
- dsf/object_model/move/skew.py +52 -52
- dsf/object_model/network/__init__.py +7 -7
- dsf/object_model/network/network.py +59 -59
- dsf/object_model/network/network_interface.py +164 -165
- dsf/object_model/network/network_interface_type.py +11 -11
- dsf/object_model/network/network_protocol.py +23 -23
- dsf/object_model/network/network_state.py +32 -32
- dsf/object_model/object_model.py +170 -172
- dsf/object_model/plugins/__init__.py +3 -3
- dsf/object_model/plugins/plugin_manifest.py +246 -246
- dsf/object_model/plugins/plugins.py +38 -38
- dsf/object_model/plugins/sbc_permissions.py +95 -95
- dsf/object_model/scanner/__init__.py +4 -4
- dsf/object_model/scanner/scanner.py +39 -40
- dsf/object_model/scanner/scanner_status.py +23 -23
- dsf/object_model/sensors/__init__.py +8 -8
- dsf/object_model/sensors/analog_sensor.py +47 -46
- dsf/object_model/sensors/analog_sensor_type.py +50 -50
- dsf/object_model/sensors/endstop.py +47 -44
- dsf/object_model/sensors/endstop_type.py +20 -20
- dsf/object_model/sensors/filament_monitors/__init__.py +14 -14
- dsf/object_model/sensors/filament_monitors/filament_monitor.py +73 -73
- dsf/object_model/sensors/filament_monitors/filament_monitor_status.py +26 -26
- dsf/object_model/sensors/filament_monitors/filament_monitor_type.py +20 -20
- dsf/object_model/sensors/filament_monitors/laser_filament_monitor.py +138 -138
- dsf/object_model/sensors/filament_monitors/pulsed_filament_monitor.py +116 -116
- dsf/object_model/sensors/filament_monitors/rotating_magnet_filament_monitor.py +126 -126
- dsf/object_model/sensors/gp_input_port.py +18 -18
- dsf/object_model/sensors/probe.py +186 -185
- dsf/object_model/sensors/probe_type.py +38 -38
- dsf/object_model/sensors/sensors.py +46 -46
- dsf/object_model/spindles/__init__.py +4 -4
- dsf/object_model/spindles/spindle_state.py +17 -17
- dsf/object_model/spindles/spindles.py +92 -93
- dsf/object_model/state/__init__.py +7 -7
- dsf/object_model/state/beep_request.py +27 -27
- dsf/object_model/state/gp_output_port.py +18 -18
- dsf/object_model/state/log_level.py +17 -17
- dsf/object_model/state/machine_mode.py +14 -14
- dsf/object_model/state/machine_status.py +47 -47
- dsf/object_model/state/message_box.py +99 -100
- dsf/object_model/state/restore_point.py +85 -92
- dsf/object_model/state/state.py +283 -279
- dsf/object_model/tools/__init__.py +5 -5
- dsf/object_model/tools/tool_retraction.py +63 -63
- dsf/object_model/tools/tool_state.py +14 -14
- dsf/object_model/tools/tools.py +183 -184
- dsf/object_model/user_sessions/__init__.py +6 -6
- dsf/object_model/user_sessions/access_level.py +11 -11
- dsf/object_model/user_sessions/session_type.py +14 -14
- dsf/object_model/user_sessions/user_sessions.py +79 -74
- dsf/object_model/utils.py +44 -44
- dsf/object_model/volumes/__init__.py +3 -3
- dsf/object_model/volumes/volumes.py +98 -98
- dsf/utils.py +58 -58
- {dsf_python-3.4.5.post2.dist-info → dsf_python-3.4.6.post2.dist-info}/LICENSE +165 -165
- {dsf_python-3.4.5.post2.dist-info → dsf_python-3.4.6.post2.dist-info}/METADATA +5 -2
- dsf_python-3.4.6.post2.dist-info/RECORD +164 -0
- {dsf_python-3.4.5.post2.dist-info → dsf_python-3.4.6.post2.dist-info}/WHEEL +1 -1
- dsf/commands/result.py +0 -40
- dsf_python-3.4.5.post2.dist-info/RECORD +0 -162
- {dsf_python-3.4.5.post2.dist-info → dsf_python-3.4.6.post2.dist-info}/top_level.txt +0 -0
dsf/__init__.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# path to unix socket file
|
|
2
|
-
SOCKET_FILE = "/run/dsf/dcs.sock"
|
|
3
|
-
|
|
4
|
-
# allowed connection per unix server
|
|
5
|
-
DEFAULT_BACKLOG = 4
|
|
6
|
-
|
|
7
|
-
# DSF protocol version
|
|
8
|
-
PROTOCOL_VERSION = 12
|
|
9
|
-
|
|
10
|
-
from . import commands, connections, http, object_model
|
|
1
|
+
# path to unix socket file
|
|
2
|
+
SOCKET_FILE = "/run/dsf/dcs.sock"
|
|
3
|
+
|
|
4
|
+
# allowed connection per unix server
|
|
5
|
+
DEFAULT_BACKLOG = 4
|
|
6
|
+
|
|
7
|
+
# DSF protocol version
|
|
8
|
+
PROTOCOL_VERSION = 12
|
|
9
|
+
|
|
10
|
+
from . import commands, connections, http, object_model
|
dsf/commands/__init__.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
from . import base_command, code, code_interception, code_channel, code_parameter, files, generic,\
|
|
2
|
-
http_endpoints, model_subscription, object_model, packages, plugins, responses,
|
|
1
|
+
from . import base_command, code, code_interception, code_channel, code_parameter, files, generic,\
|
|
2
|
+
http_endpoints, model_subscription, object_model, packages, plugins, responses, user_sessions
|
dsf/commands/base_command.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
class BaseCommand:
|
|
2
|
-
"""Base class of a command."""
|
|
3
|
-
|
|
4
|
-
@classmethod
|
|
5
|
-
def from_json(cls, data):
|
|
6
|
-
"""Deserialize an instance of this class from a JSON deserialized dictionary"""
|
|
7
|
-
return cls(**data)
|
|
8
|
-
|
|
9
|
-
def __init__(self, command: str, **kwargs):
|
|
10
|
-
self.command = command
|
|
11
|
-
for key, value in kwargs.items():
|
|
12
|
-
self.__dict__[key] = value
|
|
1
|
+
class BaseCommand:
|
|
2
|
+
"""Base class of a command."""
|
|
3
|
+
|
|
4
|
+
@classmethod
|
|
5
|
+
def from_json(cls, data):
|
|
6
|
+
"""Deserialize an instance of this class from a JSON deserialized dictionary"""
|
|
7
|
+
return cls(**data)
|
|
8
|
+
|
|
9
|
+
def __init__(self, command: str, **kwargs):
|
|
10
|
+
self.command = command
|
|
11
|
+
for key, value in kwargs.items():
|
|
12
|
+
self.__dict__[key] = value
|
dsf/commands/code.py
CHANGED
|
@@ -1,170 +1,161 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"""
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
from
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
"""
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
str_list.append(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return f"{prefix}{self.type}{self.majorNumber}.{self.minorNumber}"
|
|
163
|
-
|
|
164
|
-
return f"{prefix}{self.type}{self.majorNumber}"
|
|
165
|
-
|
|
166
|
-
return f"{prefix}{self.type}"
|
|
167
|
-
|
|
168
|
-
def keyword_to_str(self):
|
|
169
|
-
"""Convert the keyword to a str"""
|
|
170
|
-
return keyword_type_names.get(self.keyword)
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
from .base_command import BaseCommand
|
|
5
|
+
from .code_channel import CodeChannel
|
|
6
|
+
from .code_flags import CodeFlags
|
|
7
|
+
from .code_parameter import CodeParameter
|
|
8
|
+
from .code_type import CodeType
|
|
9
|
+
from .condition_type import KeywordType
|
|
10
|
+
from ..object_model.messages import Message
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Code(BaseCommand):
|
|
14
|
+
"""A parsed representation of a generic G/M/T-code"""
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def from_json(cls, data):
|
|
18
|
+
"""Deserialize an instance of this class from JSON deserialized dictionary"""
|
|
19
|
+
data["result"] = None if data["result"] is None else list(map(Message.from_json, data["result"]))
|
|
20
|
+
data["parameters"] = list(map(CodeParameter.from_json, data["parameters"]))
|
|
21
|
+
if "channel" in data:
|
|
22
|
+
data["channel"] = CodeChannel(data["channel"])
|
|
23
|
+
return cls(**data)
|
|
24
|
+
|
|
25
|
+
def __init__(self, **kwargs):
|
|
26
|
+
# The connection ID this code was received from. If this is 0, the code originates from an internal DCS task
|
|
27
|
+
# Usually there is no need to populate this property.
|
|
28
|
+
# It is internally overwritten by the control server on receipt
|
|
29
|
+
self.sourceConnection = 0
|
|
30
|
+
|
|
31
|
+
# Result of this code. This property is only set when the code has finished its execution.
|
|
32
|
+
# It remains None if the code has been cancelled
|
|
33
|
+
self.result: Optional[List[Message]] = None
|
|
34
|
+
|
|
35
|
+
# Type of the code
|
|
36
|
+
self.type = CodeType.CodeNone
|
|
37
|
+
|
|
38
|
+
# Code channel to send this code to
|
|
39
|
+
self.channel = CodeChannel.DEFAULT_CHANNEL
|
|
40
|
+
|
|
41
|
+
# Line number of this code
|
|
42
|
+
self.lineNumber = None
|
|
43
|
+
|
|
44
|
+
# Number of whitespaces prefixing the command content
|
|
45
|
+
self.indent = 0
|
|
46
|
+
|
|
47
|
+
# Type of conditional G-code (if any)
|
|
48
|
+
self.keyword = KeywordType.KeywordNone
|
|
49
|
+
|
|
50
|
+
# Argument of the conditional G-code (if any)
|
|
51
|
+
self.keywordArgument = None
|
|
52
|
+
|
|
53
|
+
# Major code number (e.g. 28 in G28)
|
|
54
|
+
self.majorNumber = None
|
|
55
|
+
|
|
56
|
+
# Minor code number (e.g. 3 in G54.3)
|
|
57
|
+
self.minorNumber = None
|
|
58
|
+
|
|
59
|
+
# Flags of this code
|
|
60
|
+
self.flags = CodeFlags.CodeFlagsNone
|
|
61
|
+
|
|
62
|
+
# Comment of the G/M/T-code. May be null if no comment is present
|
|
63
|
+
# The parser combines different comment segments and concatenates them as a single value.
|
|
64
|
+
# So for example a code like 'G28 (Do homing) ; via G28'
|
|
65
|
+
# causes the Comment field to be filled with 'Do homing via G28'
|
|
66
|
+
self.comment = None
|
|
67
|
+
|
|
68
|
+
# File position of this code in bytes (optional)
|
|
69
|
+
self.filePosition = None
|
|
70
|
+
|
|
71
|
+
# Length of the original code in bytes (optional)
|
|
72
|
+
self.length = None
|
|
73
|
+
|
|
74
|
+
# List of parsed code parameters
|
|
75
|
+
self.parameters: List[CodeParameter] = []
|
|
76
|
+
|
|
77
|
+
super().__init__(**kwargs)
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def is_from_file_channel(self) -> bool:
|
|
81
|
+
"""Check if this code is from a file channel"""
|
|
82
|
+
return self.channel is CodeChannel.File
|
|
83
|
+
|
|
84
|
+
def parameter(self, letter: str, default=None):
|
|
85
|
+
"""Retrieve the parameter whose letter equals c or generate a default parameter"""
|
|
86
|
+
letter = letter.upper()
|
|
87
|
+
param = [param for param in self.parameters if param.letter.upper() == letter]
|
|
88
|
+
if len(param) > 0:
|
|
89
|
+
return param[0]
|
|
90
|
+
if default is not None:
|
|
91
|
+
return CodeParameter.simple_param(letter, default)
|
|
92
|
+
return None
|
|
93
|
+
|
|
94
|
+
def get_unprecedented_string(self, quote: bool = False):
|
|
95
|
+
"""
|
|
96
|
+
Reconstruct an unprecedented string from the parameter list or
|
|
97
|
+
retrieve the parameter which does not have a letter assigned.
|
|
98
|
+
"""
|
|
99
|
+
str_list = []
|
|
100
|
+
for param in self.parameters:
|
|
101
|
+
if quote and param.is_string:
|
|
102
|
+
str_list.append(f'{param.letter}"{param.string_value}"')
|
|
103
|
+
else:
|
|
104
|
+
str_list.append(f"{param.letter}{param.string_value}")
|
|
105
|
+
return " ".join(str_list)
|
|
106
|
+
|
|
107
|
+
def __str__(self):
|
|
108
|
+
"""Convert the parsed code back to a text-based G/M/T-code"""
|
|
109
|
+
if self.keyword != KeywordType.KeywordNone:
|
|
110
|
+
if self.keywordArgument is not None:
|
|
111
|
+
return f"{self.keyword_to_str()} {self.keywordArgument}"
|
|
112
|
+
else:
|
|
113
|
+
return self.keyword_to_str()
|
|
114
|
+
|
|
115
|
+
if self.type == CodeType.Comment:
|
|
116
|
+
return f";{self.comment}"
|
|
117
|
+
|
|
118
|
+
str_list = [self.short_str()]
|
|
119
|
+
|
|
120
|
+
for param in self.parameters:
|
|
121
|
+
str_list.append(f" {param}")
|
|
122
|
+
|
|
123
|
+
if self.comment:
|
|
124
|
+
if len(str_list) > 0:
|
|
125
|
+
str_list.append(" ")
|
|
126
|
+
str_list.append(f";{self.comment}")
|
|
127
|
+
|
|
128
|
+
if self.result and len(self.result) > 0:
|
|
129
|
+
str_list.append(f" => {self.result}")
|
|
130
|
+
|
|
131
|
+
return "".join(str_list)
|
|
132
|
+
|
|
133
|
+
def short_str(self):
|
|
134
|
+
"""Convert only the command portion to a text-based G/M/T-code (e.g. G28)"""
|
|
135
|
+
if self.type == CodeType.Comment:
|
|
136
|
+
return "(comment)"
|
|
137
|
+
|
|
138
|
+
prefix = "G53 " if self.flags & CodeFlags.EnforceAbsolutePosition != 0 else ""
|
|
139
|
+
if self.majorNumber is not None:
|
|
140
|
+
if self.minorNumber is not None:
|
|
141
|
+
return f"{prefix}{self.type}{self.majorNumber}.{self.minorNumber}"
|
|
142
|
+
|
|
143
|
+
return f"{prefix}{self.type}{self.majorNumber}"
|
|
144
|
+
|
|
145
|
+
return f"{prefix}{self.type}"
|
|
146
|
+
|
|
147
|
+
def keyword_to_str(self):
|
|
148
|
+
"""Convert the keyword to a string"""
|
|
149
|
+
return {
|
|
150
|
+
KeywordType.If: "if",
|
|
151
|
+
KeywordType.ElseIf: "elif",
|
|
152
|
+
KeywordType.Else: "else",
|
|
153
|
+
KeywordType.While: "while",
|
|
154
|
+
KeywordType.Break: "break",
|
|
155
|
+
KeywordType.Continue: "continue",
|
|
156
|
+
KeywordType.Abort: "abort",
|
|
157
|
+
KeywordType.Var: "var",
|
|
158
|
+
KeywordType.Set: "set",
|
|
159
|
+
KeywordType.Echo: "echo",
|
|
160
|
+
KeywordType.Global: "global",
|
|
161
|
+
}.get(self.keyword)
|
dsf/commands/code_channel.py
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
from enum import Enum
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class CodeChannel(str, Enum):
|
|
5
|
-
"""Enumeration of every available code channel"""
|
|
6
|
-
|
|
7
|
-
# Code channel for HTTP requests
|
|
8
|
-
HTTP = "HTTP"
|
|
9
|
-
|
|
10
|
-
# Code channel for Telnet requests
|
|
11
|
-
Telnet = "Telnet"
|
|
12
|
-
|
|
13
|
-
# Code channel for primary file prints
|
|
14
|
-
File = "File"
|
|
15
|
-
|
|
16
|
-
# Code channel for USB requests
|
|
17
|
-
USB = "USB"
|
|
18
|
-
|
|
19
|
-
# Code channel for serial devices (e.g. PanelDue)
|
|
20
|
-
Aux = "Aux"
|
|
21
|
-
|
|
22
|
-
# Code channel for running triggers or config.g
|
|
23
|
-
Trigger = "Trigger"
|
|
24
|
-
|
|
25
|
-
# Code channel for the code queue that executes a couple of codes in-sync with moves of the primary print file
|
|
26
|
-
Queue = "Queue"
|
|
27
|
-
|
|
28
|
-
# Code channel for auxiliary LCD devices (e.g. PanelOne)
|
|
29
|
-
LCD = "LCD"
|
|
30
|
-
|
|
31
|
-
# Default code channel for requests over SPI
|
|
32
|
-
SBC = "SBC"
|
|
33
|
-
|
|
34
|
-
# Code channel that executes the daemon process
|
|
35
|
-
Daemon = "Daemon"
|
|
36
|
-
|
|
37
|
-
# Code channel for the second UART port
|
|
38
|
-
Aux2 = "Aux2"
|
|
39
|
-
|
|
40
|
-
# Code channel that executes macros on power fail, heater faults and filament out
|
|
41
|
-
Autopause = "Autopause"
|
|
42
|
-
|
|
43
|
-
# Unknown code channel
|
|
44
|
-
Unknown = "Unknown"
|
|
45
|
-
|
|
46
|
-
DEFAULT_CHANNEL = SBC
|
|
47
|
-
|
|
48
|
-
@staticmethod
|
|
49
|
-
def list():
|
|
50
|
-
return list(map(lambda cc: cc.value, CodeChannel))
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CodeChannel(str, Enum):
|
|
5
|
+
"""Enumeration of every available code channel"""
|
|
6
|
+
|
|
7
|
+
# Code channel for HTTP requests
|
|
8
|
+
HTTP = "HTTP"
|
|
9
|
+
|
|
10
|
+
# Code channel for Telnet requests
|
|
11
|
+
Telnet = "Telnet"
|
|
12
|
+
|
|
13
|
+
# Code channel for primary file prints
|
|
14
|
+
File = "File"
|
|
15
|
+
|
|
16
|
+
# Code channel for USB requests
|
|
17
|
+
USB = "USB"
|
|
18
|
+
|
|
19
|
+
# Code channel for serial devices (e.g. PanelDue)
|
|
20
|
+
Aux = "Aux"
|
|
21
|
+
|
|
22
|
+
# Code channel for running triggers or config.g
|
|
23
|
+
Trigger = "Trigger"
|
|
24
|
+
|
|
25
|
+
# Code channel for the code queue that executes a couple of codes in-sync with moves of the primary print file
|
|
26
|
+
Queue = "Queue"
|
|
27
|
+
|
|
28
|
+
# Code channel for auxiliary LCD devices (e.g. PanelOne)
|
|
29
|
+
LCD = "LCD"
|
|
30
|
+
|
|
31
|
+
# Default code channel for requests over SPI
|
|
32
|
+
SBC = "SBC"
|
|
33
|
+
|
|
34
|
+
# Code channel that executes the daemon process
|
|
35
|
+
Daemon = "Daemon"
|
|
36
|
+
|
|
37
|
+
# Code channel for the second UART port
|
|
38
|
+
Aux2 = "Aux2"
|
|
39
|
+
|
|
40
|
+
# Code channel that executes macros on power fail, heater faults and filament out
|
|
41
|
+
Autopause = "Autopause"
|
|
42
|
+
|
|
43
|
+
# Unknown code channel
|
|
44
|
+
Unknown = "Unknown"
|
|
45
|
+
|
|
46
|
+
DEFAULT_CHANNEL = SBC
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def list():
|
|
50
|
+
return list(map(lambda cc: cc.value, CodeChannel))
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from enum import IntEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CodeFlags(IntEnum):
|
|
5
|
+
"""Code bits to classify G/M/T-codes"""
|
|
6
|
+
|
|
7
|
+
# Placeholder to indicate that no flags are set
|
|
8
|
+
CodeFlagsNone = 0
|
|
9
|
+
|
|
10
|
+
# Code execution finishes as soon as it is enqueued in the code queue
|
|
11
|
+
# If codes are started asynchronously, code replies are normally reported via the object model.
|
|
12
|
+
# In order to keep track of code replies, an <see cref="Connection.ConnectionMode.Intercept"/> connection
|
|
13
|
+
# in <see cref="Connection.InterceptionMode.Executed"/> mode can be used
|
|
14
|
+
Asynchronous = 1
|
|
15
|
+
|
|
16
|
+
# Code has been preprocessed (i.e. it has been processed by the DCS pre-side code interceptors)
|
|
17
|
+
IsPreProcessed = 2
|
|
18
|
+
|
|
19
|
+
# Code has been postprocessed (i.e. it has been processed by the internal DCS code processor)
|
|
20
|
+
IsPostProcessed = 4
|
|
21
|
+
|
|
22
|
+
# Code originates from a macro file
|
|
23
|
+
IsFromMacro = 8
|
|
24
|
+
|
|
25
|
+
# Code originates from a system macro file (i.e. RRF requested it)
|
|
26
|
+
IsNestedMacro = 16
|
|
27
|
+
|
|
28
|
+
# Code comes from config.g or config.g.bak
|
|
29
|
+
IsFromConfig = 32
|
|
30
|
+
|
|
31
|
+
# Code comes from config-override.g
|
|
32
|
+
IsFromConfigOverride = 64
|
|
33
|
+
|
|
34
|
+
# Enforce absolute positioning via prefixed G53 code
|
|
35
|
+
EnforceAbsolutePosition = 128
|
|
36
|
+
|
|
37
|
+
# Execute this code as quickly as possible and skip codes that have the <see cref="Unbuffered"/> flag set
|
|
38
|
+
# In order to execute this code as quickly as possible, DCS attempts to change
|
|
39
|
+
# the <see cref="Code.Channel"/> property to a code channel that is completely idle.
|
|
40
|
+
# If this fails, a warning is logged. This flag should be only used for diagnostics and time-critical codes
|
|
41
|
+
# like M112/M122/M999
|
|
42
|
+
IsPrioritized = 256
|
|
43
|
+
|
|
44
|
+
# Do NOT process another code on the same channel before this code has been fully executed.
|
|
45
|
+
# Note that priority codes may still override codes that have this flag set
|
|
46
|
+
Unbuffered = 512
|
|
47
|
+
|
|
48
|
+
# Indicates if this code was requested from the firmware
|
|
49
|
+
IsFromFirmware = 1024
|
|
50
|
+
|
|
51
|
+
# Indicates if this is the last code on the line
|
|
52
|
+
IsLastCode = 2048
|
|
53
|
+
|
|
54
|
+
# Code has been processed internally (if this is set the internal execution of a code is skipped)
|
|
55
|
+
IsInternallyProcessed = 4096
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
from
|
|
2
|
-
|
|
3
|
-
from .base_command import BaseCommand
|
|
4
|
-
from ..object_model.messages import MessageType
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def cancel():
|
|
8
|
-
"""Cancel a code in Connection.InterceptionMode."""
|
|
9
|
-
return BaseCommand("Cancel")
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def ignore():
|
|
13
|
-
"""
|
|
14
|
-
Ignore the code to intercept and allow it to be processed without any modifications.
|
|
15
|
-
This command is only permitted in ConnectionMode.Intercept mode.
|
|
16
|
-
"""
|
|
17
|
-
return BaseCommand("Ignore")
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def resolve_code(rtype: MessageType, content:
|
|
21
|
-
"""
|
|
22
|
-
Resolve the code to intercept and return the given message details for its completion.
|
|
23
|
-
This command is only permitted in ConnectionMode.Intercept mode.
|
|
24
|
-
:param rtype: Type of the resolving message
|
|
25
|
-
:param content: Content of the resolving message
|
|
26
|
-
"""
|
|
27
|
-
if not isinstance(rtype, MessageType):
|
|
28
|
-
raise TypeError("rtype must be a MessageType")
|
|
29
|
-
if content is not None and not isinstance(content, str):
|
|
30
|
-
raise TypeError("content must be None or a string")
|
|
31
|
-
return BaseCommand("Resolve", **{"Type": rtype, "Content": content})
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from .base_command import BaseCommand
|
|
4
|
+
from ..object_model.messages import MessageType
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def cancel():
|
|
8
|
+
"""Cancel a code in Connection.InterceptionMode."""
|
|
9
|
+
return BaseCommand("Cancel")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def ignore():
|
|
13
|
+
"""
|
|
14
|
+
Ignore the code to intercept and allow it to be processed without any modifications.
|
|
15
|
+
This command is only permitted in ConnectionMode.Intercept mode.
|
|
16
|
+
"""
|
|
17
|
+
return BaseCommand("Ignore")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def resolve_code(rtype: MessageType, content: str | None = None):
|
|
21
|
+
"""
|
|
22
|
+
Resolve the code to intercept and return the given message details for its completion.
|
|
23
|
+
This command is only permitted in ConnectionMode.Intercept mode.
|
|
24
|
+
:param rtype: Type of the resolving message
|
|
25
|
+
:param content: Content of the resolving message
|
|
26
|
+
"""
|
|
27
|
+
if not isinstance(rtype, MessageType):
|
|
28
|
+
raise TypeError("rtype must be a MessageType")
|
|
29
|
+
if content is not None and not isinstance(content, str):
|
|
30
|
+
raise TypeError("content must be None or a string")
|
|
31
|
+
return BaseCommand("Resolve", **{"Type": rtype, "Content": content})
|