diff --git a/openapi.json b/openapi.json index 79084c19365942249443b02acf2be8da92f1dbcf..f61104047a2c17a9b5ac591190ccf8b297efd7e2 100644 --- a/openapi.json +++ b/openapi.json @@ -3954,6 +3954,9 @@ "type": "integer", "format": "int32", "default": 1 + }, + "invert": { + "type": "boolean" } }, "x-body-name": "line_detector" diff --git a/txtapi/requirements.txt b/txtapi/requirements.txt index da027c37324b7705d06ea646caec3ae42d44ddfb..d20876275c6a7cc4d661b645164783915fce7480 100644 --- a/txtapi/requirements.txt +++ b/txtapi/requirements.txt @@ -4,7 +4,7 @@ python_dateutil==2.6.0 setuptools==41.4.0 Flask-Cors==3.0.6 rpdb==0.1.6 -ft-controllerlib==6.2.1 +ft-controllerlib==6.3.0 Werkzeug==0.16.1 waitress>=1.4.4 psutil==5.7.3 diff --git a/txtapi/setup.py b/txtapi/setup.py index e0ca07727c5680ab3bbc71d324d62f1908032429..c196bca8c572ea48b863d0f4e9a6afe269b598fd 100644 --- a/txtapi/setup.py +++ b/txtapi/setup.py @@ -20,7 +20,7 @@ REQUIRES = [ "Flask-Cors==3.0.6", "rpdb==0.1.6", "websockets==7.0", - "ft-controllerlib==6.2.1", + "ft-controllerlib==6.3.0", "jsonschema==3.2.0", "Werkzeug==0.16.1", "waitress>=1.4.4", diff --git a/txtapi/txtapi/models/line_detector.py b/txtapi/txtapi/models/line_detector.py index f0a5ffa01e310abdf2c4312a124f38a0e3358f5a..f682983e09bb78298c31454d899c426f782ba21a 100644 --- a/txtapi/txtapi/models/line_detector.py +++ b/txtapi/txtapi/models/line_detector.py @@ -17,7 +17,7 @@ class LineDetector(Model): Do not edit the class manually. """ - def __init__(self, name=None, area=None, min_line_width=5, max_line_width=20, start_range_value=-100, end_range_value=100, number_of_lines=1): # noqa: E501 + def __init__(self, name=None, area=None, min_line_width=5, max_line_width=20, start_range_value=-100, end_range_value=100, number_of_lines=1, invert=None): # noqa: E501 """LineDetector - a model defined in OpenAPI :param name: The name of this LineDetector. # noqa: E501 @@ -34,6 +34,8 @@ class LineDetector(Model): :type end_range_value: int :param number_of_lines: The number_of_lines of this LineDetector. # noqa: E501 :type number_of_lines: int + :param invert: The invert of this LineDetector. # noqa: E501 + :type invert: bool """ self.openapi_types = { 'name': str, @@ -42,7 +44,8 @@ class LineDetector(Model): 'max_line_width': int, 'start_range_value': int, 'end_range_value': int, - 'number_of_lines': int + 'number_of_lines': int, + 'invert': bool } self.attribute_map = { @@ -52,7 +55,8 @@ class LineDetector(Model): 'max_line_width': 'max_line_width', 'start_range_value': 'start_range_value', 'end_range_value': 'end_range_value', - 'number_of_lines': 'number_of_lines' + 'number_of_lines': 'number_of_lines', + 'invert': 'invert' } self._name = name @@ -62,6 +66,7 @@ class LineDetector(Model): self._start_range_value = start_range_value self._end_range_value = end_range_value self._number_of_lines = number_of_lines + self._invert = invert @classmethod def from_dict(cls, dikt) -> 'LineDetector': @@ -220,3 +225,24 @@ class LineDetector(Model): """ self._number_of_lines = number_of_lines + + @property + def invert(self): + """Gets the invert of this LineDetector. + + + :return: The invert of this LineDetector. + :rtype: bool + """ + return self._invert + + @invert.setter + def invert(self, invert): + """Sets the invert of this LineDetector. + + + :param invert: The invert of this LineDetector. + :type invert: bool + """ + + self._invert = invert diff --git a/txtapi/txtapi/openapi/openapi.yaml b/txtapi/txtapi/openapi/openapi.yaml index cf028fe0b513a31259b96b5403999f593de62603..f5bf169e01c210a4eaca1c0d633853f85b7d76fd 100644 --- a/txtapi/txtapi/openapi/openapi.yaml +++ b/txtapi/txtapi/openapi/openapi.yaml @@ -3729,6 +3729,8 @@ components: default: 1 format: int32 type: integer + invert: + type: boolean type: object x-body-name: line_detector controller: diff --git a/txtapi/txtapi/txt/txt.py b/txtapi/txtapi/txt/txt.py index 0e0bc681943a0bba709a87dbad0b8f95424bde6f..7b4983ee392d784604e2476c32685f7e37103e10 100644 --- a/txtapi/txtapi/txt/txt.py +++ b/txtapi/txtapi/txt/txt.py @@ -191,7 +191,8 @@ class Txt: line_config.max_line_width, line_config.start_range_value, line_config.end_range_value, - line_config.number_of_lines + line_config.number_of_lines, + line_config.invert ) line_detector.set_identifier(line_config.name) camera.add_detector(line_detector) diff --git a/txtapi/txtapi/utility/debugger/response_converter.py b/txtapi/txtapi/utility/debugger/response_converter.py index 25fe80bced940d6f92e5d4afd7cef9827577b093..a5040ac1620b725a67f1629484dce26cb0e098ae 100644 --- a/txtapi/txtapi/utility/debugger/response_converter.py +++ b/txtapi/txtapi/utility/debugger/response_converter.py @@ -112,15 +112,21 @@ def convert_add_breakpoint_response(response: str) -> Breakpoint: pattern_entire_line = r"\ABreakpoint \d+ at " + re.escape(WORKSPACE_ABSPATH) + r".+:\d+" match = re.search(pattern_entire_line, response) if not match: - raise Exception("Could not set breakpoint: " + response) + return None response = match.group(0) - i_d = re.search(r"\d+", response)[0] + match = re.search(r"\d+", response) + if not match: + return None + i_d = match.group(0) pattern = r"(?<=" + re.escape(WORKSPACE_ABSPATH) + r").+" # matches everything after WORKSPACE_ABSPATH - filename_and_line = re.search(pattern, response)[0] - filename, line = extract_filename_line(filename_and_line) + match = re.search(pattern, response) + if not match: + return None + filename_and_line = match.group(0) + filename, line = extract_filename_line(filename_and_line) bp = Breakpoint(id=int(i_d), filename=filename, line=int(line), enabled=True) return bp @@ -142,12 +148,18 @@ def convert_toggle_breakpoint_response(response: str, enabled: bool) -> Breakpoi # get only the matching string without additional lines or line breaks response = match.group(0) - i_d = re.search(r"(?<=abled breakpoint )\d+", response)[0] + match = re.search(r"(?<=abled breakpoint )\d+", response) + if not match: + return None + i_d = match.group(0) # without "(Dis|En)" because look-behind requires fixed-width pattern - filename_and_line = re.search(r"(?<=" + re.escape(WORKSPACE_ABSPATH) + ").+", response)[0] - filename, line = extract_filename_line(filename_and_line) + match = re.search(r"(?<=" + re.escape(WORKSPACE_ABSPATH) + ").+", response) + if not match: + return None + filename_and_line = match.group(0) + filename, line = extract_filename_line(filename_and_line) bp = Breakpoint(id=int(i_d), filename=filename, line=int(line), enabled=enabled) return bp