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.
Files changed (165) hide show
  1. dsf/__init__.py +10 -10
  2. dsf/commands/__init__.py +2 -2
  3. dsf/commands/base_command.py +12 -12
  4. dsf/commands/code.py +161 -170
  5. dsf/commands/code_channel.py +50 -50
  6. dsf/commands/code_flags.py +55 -0
  7. dsf/commands/code_interception.py +31 -31
  8. dsf/commands/code_parameter.py +209 -208
  9. dsf/commands/code_type.py +24 -0
  10. dsf/commands/condition_type.py +41 -0
  11. dsf/commands/files.py +23 -23
  12. dsf/commands/generic.py +117 -117
  13. dsf/commands/http_endpoints.py +53 -53
  14. dsf/commands/model_subscription.py +9 -9
  15. dsf/commands/object_model.py +69 -69
  16. dsf/commands/packages.py +19 -19
  17. dsf/commands/plugins.py +84 -84
  18. dsf/commands/responses.py +54 -54
  19. dsf/commands/user_sessions.py +52 -52
  20. dsf/connections/__init__.py +52 -51
  21. dsf/connections/base_command_connection.py +244 -244
  22. dsf/connections/base_connection.py +151 -153
  23. dsf/connections/command_connection.py +11 -11
  24. dsf/connections/exceptions.py +16 -16
  25. dsf/connections/init_messages/__init__.py +1 -1
  26. dsf/connections/init_messages/client_init_messages.py +92 -64
  27. dsf/connections/init_messages/server_init_message.py +44 -44
  28. dsf/connections/intercept_connection.py +68 -51
  29. dsf/connections/subscribe_connection.py +65 -57
  30. dsf/exceptions.py +2 -2
  31. dsf/http.py +178 -178
  32. dsf/object_model/__init__.py +20 -20
  33. dsf/object_model/boards/__init__.py +10 -10
  34. dsf/object_model/boards/accelerometer.py +29 -29
  35. dsf/object_model/boards/boards.py +249 -248
  36. dsf/object_model/boards/closed_loop.py +29 -29
  37. dsf/object_model/boards/direct_display.py +40 -40
  38. dsf/object_model/boards/driver.py +15 -15
  39. dsf/object_model/boards/driver_settings.py +27 -27
  40. dsf/object_model/boards/min_max_current.py +41 -41
  41. dsf/object_model/boards/stall_detect_settings.py +62 -62
  42. dsf/object_model/directories/__init__.py +3 -3
  43. dsf/object_model/directories/directories.py +97 -97
  44. dsf/object_model/fans/__init__.py +4 -4
  45. dsf/object_model/fans/fan_thermostatic_control.py +37 -37
  46. dsf/object_model/fans/fans.py +105 -105
  47. dsf/object_model/heat/__init__.py +8 -8
  48. dsf/object_model/heat/heat.py +57 -57
  49. dsf/object_model/heat/heater.py +146 -146
  50. dsf/object_model/heat/heater_model.py +117 -115
  51. dsf/object_model/heat/heater_model_pid.py +63 -63
  52. dsf/object_model/heat/heater_monitor.py +85 -84
  53. dsf/object_model/http_endpoints/__init__.py +4 -4
  54. dsf/object_model/http_endpoints/http_endpoint_type.py +29 -29
  55. dsf/object_model/http_endpoints/http_endpoints.py +74 -73
  56. dsf/object_model/inputs/__init__.py +6 -6
  57. dsf/object_model/inputs/compatibility.py +26 -26
  58. dsf/object_model/inputs/distance_unit.py +14 -14
  59. dsf/object_model/inputs/input_channel.py +168 -164
  60. dsf/object_model/inputs/input_channel_state.py +20 -20
  61. dsf/object_model/job/__init__.py +10 -10
  62. dsf/object_model/job/build.py +55 -55
  63. dsf/object_model/job/build_object.py +46 -46
  64. dsf/object_model/job/gcode_fileinfo.py +121 -120
  65. dsf/object_model/job/job.py +173 -177
  66. dsf/object_model/job/layer.py +57 -57
  67. dsf/object_model/job/thumbnail_info.py +97 -96
  68. dsf/object_model/job/times_left.py +43 -43
  69. dsf/object_model/limits/__init__.py +3 -3
  70. dsf/object_model/limits/limits.py +285 -285
  71. dsf/object_model/messages/__init__.py +3 -3
  72. dsf/object_model/messages/messages.py +87 -83
  73. dsf/object_model/model_collection.py +59 -57
  74. dsf/object_model/model_dictionary.py +57 -55
  75. dsf/object_model/model_object.py +97 -94
  76. dsf/object_model/move/__init__.py +17 -16
  77. dsf/object_model/move/axis.py +259 -258
  78. dsf/object_model/move/current_move.py +64 -64
  79. dsf/object_model/move/driver_id.py +73 -72
  80. dsf/object_model/move/extruder.py +165 -165
  81. dsf/object_model/move/extruder_non_linear.py +39 -39
  82. dsf/object_model/move/input_shaping.py +102 -101
  83. dsf/object_model/move/kinematics/__init__.py +13 -13
  84. dsf/object_model/move/kinematics/core_kinematics.py +26 -26
  85. dsf/object_model/move/kinematics/delta_kinematics.py +74 -74
  86. dsf/object_model/move/kinematics/delta_tower.py +62 -62
  87. dsf/object_model/move/kinematics/hangprinter_kinematics.py +33 -33
  88. dsf/object_model/move/kinematics/kinematics.py +85 -85
  89. dsf/object_model/move/kinematics/kinematics_name.py +19 -19
  90. dsf/object_model/move/kinematics/polar_kinematics.py +13 -13
  91. dsf/object_model/move/kinematics/scara_kinematics.py +12 -12
  92. dsf/object_model/move/kinematics/tilt_correction.py +63 -63
  93. dsf/object_model/move/kinematics/zleadscrew_kinematics.py +16 -16
  94. dsf/object_model/move/microstepping.py +29 -29
  95. dsf/object_model/move/motors_idle_control.py +29 -29
  96. dsf/object_model/move/move.py +169 -169
  97. dsf/object_model/move/move_calibration.py +33 -33
  98. dsf/object_model/move/move_compensation.py +87 -88
  99. dsf/object_model/move/move_deviations.py +29 -29
  100. dsf/object_model/move/move_queue_item.py +29 -29
  101. dsf/object_model/move/move_rotation.py +27 -27
  102. dsf/object_model/move/move_segmentation.py +27 -27
  103. dsf/object_model/move/probe_grid.py +48 -48
  104. dsf/object_model/move/skew.py +52 -52
  105. dsf/object_model/network/__init__.py +7 -7
  106. dsf/object_model/network/network.py +59 -59
  107. dsf/object_model/network/network_interface.py +164 -165
  108. dsf/object_model/network/network_interface_type.py +11 -11
  109. dsf/object_model/network/network_protocol.py +23 -23
  110. dsf/object_model/network/network_state.py +32 -32
  111. dsf/object_model/object_model.py +170 -172
  112. dsf/object_model/plugins/__init__.py +3 -3
  113. dsf/object_model/plugins/plugin_manifest.py +246 -246
  114. dsf/object_model/plugins/plugins.py +38 -38
  115. dsf/object_model/plugins/sbc_permissions.py +95 -95
  116. dsf/object_model/scanner/__init__.py +4 -4
  117. dsf/object_model/scanner/scanner.py +39 -40
  118. dsf/object_model/scanner/scanner_status.py +23 -23
  119. dsf/object_model/sensors/__init__.py +8 -8
  120. dsf/object_model/sensors/analog_sensor.py +47 -46
  121. dsf/object_model/sensors/analog_sensor_type.py +50 -50
  122. dsf/object_model/sensors/endstop.py +47 -44
  123. dsf/object_model/sensors/endstop_type.py +20 -20
  124. dsf/object_model/sensors/filament_monitors/__init__.py +14 -14
  125. dsf/object_model/sensors/filament_monitors/filament_monitor.py +73 -73
  126. dsf/object_model/sensors/filament_monitors/filament_monitor_status.py +26 -26
  127. dsf/object_model/sensors/filament_monitors/filament_monitor_type.py +20 -20
  128. dsf/object_model/sensors/filament_monitors/laser_filament_monitor.py +138 -138
  129. dsf/object_model/sensors/filament_monitors/pulsed_filament_monitor.py +116 -116
  130. dsf/object_model/sensors/filament_monitors/rotating_magnet_filament_monitor.py +126 -126
  131. dsf/object_model/sensors/gp_input_port.py +18 -18
  132. dsf/object_model/sensors/probe.py +186 -185
  133. dsf/object_model/sensors/probe_type.py +38 -38
  134. dsf/object_model/sensors/sensors.py +46 -46
  135. dsf/object_model/spindles/__init__.py +4 -4
  136. dsf/object_model/spindles/spindle_state.py +17 -17
  137. dsf/object_model/spindles/spindles.py +92 -93
  138. dsf/object_model/state/__init__.py +7 -7
  139. dsf/object_model/state/beep_request.py +27 -27
  140. dsf/object_model/state/gp_output_port.py +18 -18
  141. dsf/object_model/state/log_level.py +17 -17
  142. dsf/object_model/state/machine_mode.py +14 -14
  143. dsf/object_model/state/machine_status.py +47 -47
  144. dsf/object_model/state/message_box.py +99 -100
  145. dsf/object_model/state/restore_point.py +85 -92
  146. dsf/object_model/state/state.py +283 -279
  147. dsf/object_model/tools/__init__.py +5 -5
  148. dsf/object_model/tools/tool_retraction.py +63 -63
  149. dsf/object_model/tools/tool_state.py +14 -14
  150. dsf/object_model/tools/tools.py +183 -184
  151. dsf/object_model/user_sessions/__init__.py +6 -6
  152. dsf/object_model/user_sessions/access_level.py +11 -11
  153. dsf/object_model/user_sessions/session_type.py +14 -14
  154. dsf/object_model/user_sessions/user_sessions.py +79 -74
  155. dsf/object_model/utils.py +44 -44
  156. dsf/object_model/volumes/__init__.py +3 -3
  157. dsf/object_model/volumes/volumes.py +98 -98
  158. dsf/utils.py +58 -58
  159. {dsf_python-3.4.5.post2.dist-info → dsf_python-3.4.6.post2.dist-info}/LICENSE +165 -165
  160. {dsf_python-3.4.5.post2.dist-info → dsf_python-3.4.6.post2.dist-info}/METADATA +5 -2
  161. dsf_python-3.4.6.post2.dist-info/RECORD +164 -0
  162. {dsf_python-3.4.5.post2.dist-info → dsf_python-3.4.6.post2.dist-info}/WHEEL +1 -1
  163. dsf/commands/result.py +0 -40
  164. dsf_python-3.4.5.post2.dist-info/RECORD +0 -162
  165. {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, result, user_sessions
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
@@ -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
- Module code contains relevant classes and enums being received
3
- as well as sent back to the server.
4
-
5
- Python interface to DuetSoftwareFramework
6
- Copyright (C) 2020 Duet3D
7
-
8
- This program is free software: you can redistribute it and/or modify
9
- it under the terms of the GNU Lesser General Public License as published by
10
- the Free Software Foundation, either version 3 of the License, or
11
- (at your option) any later version.
12
-
13
- This program is distributed in the hope that it will be useful,
14
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- GNU Lesser General Public License for more details.
17
-
18
- You should have received a copy of the GNU Lesser General Public License
19
- along with this program. If not, see <https://www.gnu.org/licenses/>.
20
- """
21
- from enum import Enum, IntEnum
22
- from typing import List
23
-
24
- from .base_command import BaseCommand
25
- from .code_channel import CodeChannel
26
- from .code_parameter import CodeParameter
27
- from ..object_model.messages import Message
28
-
29
-
30
- class CodeType(str, Enum):
31
- """Type of generic G/M/T-code. If none is applicable, it is treated as a comment"""
32
-
33
- Comment = "Q"
34
- GCode = "G"
35
- MCode = "M"
36
- TCode = "T"
37
-
38
-
39
- class KeywordType(IntEnum):
40
- """Enumeration of conditional G-code keywords"""
41
-
42
- KeywordNone = 0
43
- If = 1
44
- ElseIf = 2
45
- Else = 3
46
- While = 4
47
- Break = 5
48
- Return = 6 # Deprecated: Was never supported in RRF
49
- Abort = 7
50
- Var = 8
51
- Set = 9
52
- Echo = 10
53
- Continue = 11
54
- Global = 12
55
-
56
-
57
- keyword_type_names = {
58
- KeywordType.Abort: "abort",
59
- KeywordType.Break: "break",
60
- KeywordType.Echo: "echo",
61
- KeywordType.Else: "else",
62
- KeywordType.ElseIf: "elif",
63
- KeywordType.If: "if",
64
- KeywordType.Return: "return",
65
- KeywordType.Set: "set",
66
- KeywordType.Var: "var",
67
- KeywordType.While: "while",
68
- KeywordType.Continue: "continue",
69
- }
70
-
71
-
72
- class CodeFlags(IntEnum):
73
- """Code bits to classify G/M/T-codes"""
74
-
75
- CodeFlagsNone = 0
76
- Asynchronous = 1
77
- IsPreProcessed = 2
78
- IsPostProcessed = 4
79
- IsFromMacro = 8
80
- IsNestedMacro = 16
81
- IsFromConfig = 32
82
- IsFromConfigOverride = 64
83
- EnforceAbsolutePosition = 128
84
- IsPrioritized = 256
85
- Unbuffered = 512
86
- IsFromFirmware = 1024
87
- IsLastCode = 2048
88
-
89
-
90
- class Code(BaseCommand):
91
- """A parsed representation of a generic G/M/T-code"""
92
-
93
- parameters: List
94
- result: List
95
-
96
- @classmethod
97
- def from_json(cls, data):
98
- """Deserialize an instance of this class from JSON deserialized dictionary"""
99
- data["result"] = [] if data["result"] is None else list(map(Message.from_json, data["result"]))
100
- data["parameters"] = list(map(CodeParameter.from_json, data["parameters"]))
101
- if "channel" in data:
102
- data["channel"] = CodeChannel(data["channel"])
103
- return cls(**data)
104
-
105
- def parameter(self, letter: str, default=None):
106
- """Retrieve the parameter whose letter equals c or generate a default parameter"""
107
- letter = letter.upper()
108
- param = [param for param in self.parameters if param.letter.upper() == letter]
109
- if len(param) > 0:
110
- return param[0]
111
- if default is not None:
112
- return CodeParameter.simple_param(letter, default)
113
- return None
114
-
115
- def get_unprecedented_string(self, quote: bool = False):
116
- """
117
- Reconstruct an unprecedented string from the parameter list or
118
- retrieve the parameter which does not have a letter assigned.
119
- """
120
- str_list = []
121
- for param in self.parameters:
122
- if quote and param.is_string:
123
- str_list.append(f'{param.letter}"{param.string_value}"')
124
- else:
125
- str_list.append(f"{param.letter}{param.string_value}")
126
- return " ".join(str_list)
127
-
128
- def __str__(self):
129
- """Convert the parsed code back to a text-based G/M/T-code"""
130
- if self.keyword != KeywordType.KeywordNone:
131
- if self.keywordArgument is not None:
132
- return f"{self.keyword_to_str()} {self.keywordArgument}"
133
- else:
134
- return self.keyword_to_str()
135
-
136
- if self.type == CodeType.Comment:
137
- return f";{self.comment}"
138
-
139
- str_list = [self.short_str()]
140
-
141
- for param in self.parameters:
142
- str_list.append(f" {param}")
143
-
144
- if self.comment:
145
- if len(str_list) > 0:
146
- str_list.append(" ")
147
- str_list.append(f";{self.comment}")
148
-
149
- if len(self.result) > 0:
150
- str_list.append(f" => {self.result}")
151
-
152
- return "".join(str_list)
153
-
154
- def short_str(self):
155
- """Convert only the command portion to a text-based G/M/T-code (e.g. G28)"""
156
- if self.type == CodeType.Comment:
157
- return "(comment)"
158
-
159
- prefix = "G53 " if self.flags & CodeFlags.EnforceAbsolutePosition != 0 else ""
160
- if self.majorNumber is not None:
161
- if self.minorNumber is not None:
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)
@@ -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 typing import Optional
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: Optional[str]):
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})