File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
lib/jbotsim-core/src/main/java/io/jbotsim/core/event Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2008 - 2020, Arnaud Casteigts and the JBotSim contributors <contact@jbotsim.io>
3+ *
4+ *
5+ * This file is part of JBotSim.
6+ *
7+ * JBotSim is free software: you can redistribute it and/or modify
8+ * it under the terms of the GNU Lesser General Public License as published by
9+ * the Free Software Foundation, either version 3 of the License, or
10+ * (at your option) any later version.
11+ *
12+ * JBotSim is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public License
18+ * along with JBotSim. If not, see <https://www.gnu.org/licenses/>.
19+ *
20+ */
21+
22+ package io .jbotsim .core .event ;
23+
24+ import io .jbotsim .core .Topology ;
25+
26+ public class PeriodicClockListener extends FilteredClockListener {
27+ private int period ;
28+
29+ public PeriodicClockListener (Topology tp , ClockListener listener , int period ) {
30+ super (tp , listener );
31+ this .period = period ;
32+ }
33+
34+ @ Override
35+ protected boolean shouldTriggerListener (Topology tp , int currentTime ) {
36+ return ((currentTime + 1 ) % period == 0 );
37+ }
38+ }
You can’t perform that action at this time.
0 commit comments