src
rqt_console
filters
time_filter.py
Go to the documentation of this file.
1
# Software License Agreement (BSD License)
2
#
3
# Copyright (c) 2012, Willow Garage, Inc.
4
# All rights reserved.
5
#
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions
8
# are met:
9
#
10
# * Redistributions of source code must retain the above copyright
11
# notice, this list of conditions and the following disclaimer.
12
# * Redistributions in binary form must reproduce the above
13
# copyright notice, this list of conditions and the following
14
# disclaimer in the documentation and/or other materials provided
15
# with the distribution.
16
# * Neither the name of Willow Garage, Inc. nor the names of its
17
# contributors may be used to stoporse or promote products derived
18
# from this software without specific prior written permission.
19
#
20
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
# POSSIBILITY OF SUCH DAMAGE.
32
33
from
python_qt_binding.QtCore
import
QDateTime
34
from
.base_filter
import
BaseFilter
35
36
37
class
TimeFilter
(
BaseFilter
):
38
39
"""
40
Contains filter logic for a time filter.
41
If _stop_time_enabled is true then the message's time value must be between the dates provided
42
to be considered a match
43
If _stop_time_enabled is false then the time must simply be after _start_time
44
"""
45
46
def
__init__
(self):
47
super(TimeFilter, self).
__init__
()
48
self.
_start_time
= QDateTime()
49
self.
_stop_time
= QDateTime()
50
self.
_stop_time_enabled
=
True
51
52
def
set_start_time
(self, time):
53
"""
54
Setter for _start_time
55
:param time" start datetime for filter ''QDateTime''
56
:emits filter_changed_signal: If _enabled is true
57
"""
58
self.
_start_time
= time
59
if
self.
is_enabled
():
60
self.
start_emit_timer
()
61
62
def
set_stop_time
(self, time):
63
"""
64
Setter for _stop_time
65
:param time" stop datetime for filter ''QDateTime''
66
:emits filter_changed_signal: If _enabled is true
67
"""
68
self.
_stop_time
= time
69
if
self.
is_enabled
():
70
self.
start_emit_timer
()
71
72
def
set_stop_time_enabled
(self, checked):
73
"""
74
Setter for _stop_time_enabled
75
:param checked" boolean flag to set ''bool''
76
:emits filter_changed_signal: If _enabled is true
77
"""
78
self.
_stop_time_enabled
= checked
79
if
self.
is_enabled
():
80
self.
start_emit_timer
()
81
82
def
has_filter
(self):
83
return
True
84
85
def
test_message
(self, message):
86
"""
87
Tests if the message matches the filter.
88
If _stop_time_enabled is true then the message's time value must be between the dates
89
provided to be considered a match
90
If _stop_time_enabled is false then the time must simply be after _start_time
91
:param message: the message to be tested against the filters, ''Message''
92
:returns: True if the message matches, ''bool''
93
"""
94
if
not
self.
is_enabled
():
95
return
False
96
message_time = message.get_stamp_as_qdatetime()
97
if
message_time < self.
_start_time
:
98
return
False
99
if
self.
_stop_time_enabled
and
self.
_stop_time
< message_time:
100
return
False
101
return
True
rqt_console.filters.time_filter.TimeFilter.has_filter
def has_filter(self)
Definition:
time_filter.py:82
rqt_console.filters.time_filter.TimeFilter._stop_time
_stop_time
Definition:
time_filter.py:49
rqt_console.filters.time_filter.TimeFilter._start_time
_start_time
Definition:
time_filter.py:48
rqt_console.filters.time_filter.TimeFilter.__init__
def __init__(self)
Definition:
time_filter.py:46
rqt_console.filters.time_filter.TimeFilter
Definition:
time_filter.py:37
rqt_console.filters.time_filter.TimeFilter._stop_time_enabled
_stop_time_enabled
Definition:
time_filter.py:50
rqt_console.filters.base_filter.BaseFilter
Definition:
base_filter.py:36
rqt_console.filters.time_filter.TimeFilter.set_stop_time
def set_stop_time(self, time)
Definition:
time_filter.py:62
rqt_console.filters.time_filter.TimeFilter.set_start_time
def set_start_time(self, time)
Definition:
time_filter.py:52
rqt_console.filters.base_filter.BaseFilter.is_enabled
def is_enabled(self)
Definition:
base_filter.py:62
rqt_console.filters.base_filter.BaseFilter.start_emit_timer
def start_emit_timer(self, msec=None)
Definition:
base_filter.py:52
rqt_console.filters.time_filter.TimeFilter.test_message
def test_message(self, message)
Definition:
time_filter.py:85
rqt_console.filters.time_filter.TimeFilter.set_stop_time_enabled
def set_stop_time_enabled(self, checked)
Definition:
time_filter.py:72
rqt_console
Author(s): Aaron Blasdel
autogenerated on Sun Oct 15 2023 02:24:45