RobotCore
1.0
WPILib port to raspberry Pi
Toggle main menu visibility
Loading...
Searching...
No Matches
NotifierJNI.java
1
// TODO - robotCore - Modified file
2
3
// Copyright (c) FIRST and other WPILib contributors.
4
// Open Source Software; you can modify and/or share it under the terms of
5
// the WPILib BSD license file in the root directory of this project.
6
7
package
org.wpilib.hardware.hal;
8
9
import
javax.xml.crypto.URIReferenceException;
10
11
import
org.wpilib.util.WPIUtilJNI;
12
import
org.wpilib.hardware.hal.PiNotifier.PiNotifiers;
13
14
import
robotCore.RobotCore;
15
24
25
public
class
NotifierJNI
{
26
// private static class Notifier {
27
// private long m_nextTime;
28
29
// void setNotifierAlarm(long alarmTime) {
30
// m_nextTime = alarmTime;
31
// }
32
33
// void waitForIt() {
34
// long dt = (m_nextTime - WPIUtilJNI.now()) / 1_000_000; // convert to ms
35
36
// if (dt > 0)
37
// {
38
// RobotCore.sleep((int) dt);
39
// }
40
// }
41
// }
42
43
// static Notifier[] m_notifiers = new Notifier[10];
44
// static int m_count = 0;
45
46
// public static void waitForIt(int notifierHandle)
47
// {
48
// if (notifierHandle < 1 || (notifierHandle > m_notifiers.length) || (m_notifiers[notifierHandle-1] == null))
49
// {
50
// System.out.println(String.format("NotifierJNI.waitForIt: Invalid handle: %d", notifierHandle));
51
// throw new UnsupportedOperationException("NotifierJNI.waitFoIt invalid handle");
52
// }
53
54
// m_notifiers[notifierHandle-1].waitForIt();
55
// }
56
57
public
static
void
setNotifierAlarm(
int
notifierHandle,
long
alarmTime,
long
intervalTime,
boolean
absolute,
boolean
ack) {
58
// System.out.println(String.format("NotifierJNI.setNotifierAlarm(%d,%d,%d,%b,%b)", notifierHandle, alarmTime, intervalTime, absolute, ack));
59
// throw new UnsupportedOperationException("Unimplemented method 'setNotifierAlarm'");
60
// if (notifierHandle < 1 || (notifierHandle > m_notifiers.length) || (m_notifiers[notifierHandle-1] == null))
61
// {
62
// System.out.println(String.format("NotifierJNI.setNotifierAlarm: Invalid handle: %d", notifierHandle));
63
// throw new UnsupportedOperationException("NotifierJNI.setNotifierAlarm invalid handle");
64
// }
65
// m_notifiers[notifierHandle-1].setNotifierAlarm(alarmTime);
66
PiNotifiers
.
setNotifierAlarm
(notifierHandle, alarmTime, intervalTime, absolute, ack);
67
// TODO - Must verify
68
}
69
70
public
static
int
createNotifier() {
71
// System.out.println("NotifierJNI.createNotifier");
72
// throw new UnsupportedOperationException("Unimplemented method 'createNotifier'");
73
// if (m_count >= m_notifiers.length)
74
// {
75
// System.out.println("NotifierJNI.createNotifier: Too many notifiers");
76
// throw new UnsupportedOperationException("createNotifier: Only one notifier is allowed");
77
// }
78
// m_notifiers[m_count] = new Notifier();
79
// return ++m_count; // >0 Indicates that this is a notifier handle
80
return
PiNotifiers
.
createNotifier
();
81
}
82
83
public
static
void
setNotifierName(
int
notifierHandle, String name) {
84
// System.out.println(String.format("NotifierJNI.setNotifierName(%d, %s)", notifierHandle, name));
85
// throw new UnsupportedOperationException("Unimplemented method 'setNotifierName'");
86
PiNotifiers
.
setNotifierName
(notifierHandle, name);
87
// TODO - Must verify
88
}
89
90
public
static
void
cancelNotifierAlarm(
int
notifierHandle,
boolean
ack) {
91
// System.out.println(String.format("NotifierJNI.cancelNotifierAlarm(%d, %b)", notifierHandle, ack));
92
// throw new UnsupportedOperationException("Unimplemented method 'cancelNotifierAlarm'");
93
PiNotifiers
.
cancelNotifierAlarm
(notifierHandle, ack);
94
// TODO - Must fix
95
}
96
97
public
static
void
destroyNotifier(
int
notifierHandle) {
98
// throw new UnsupportedOperationException("Unimplemented method 'destroyNotifier'");
99
PiNotifiers
.
destroyNotifier
(notifierHandle);
100
// TODO - Must fix
101
}
102
103
104
// /**
105
// * Creates a notifier.
106
// *
107
// * <p>A notifier is an timer that alarms at an initial and (optionally) repeated intervals. This
108
// * can be used to make precise control loops.
109
// *
110
// * @return the created notifier
111
// * @see "HAL_CreateNotifier"
112
// */
113
// public static native int createNotifier();
114
115
// /**
116
// * Sets the name of the notifier.
117
// *
118
// * @param notifierHandle Notifier handle.
119
// * @param name Notifier name.
120
// * @see "HAL_SetNotifierName"
121
// */
122
// public static native void setNotifierName(int notifierHandle, String name);
123
124
// /**
125
// * Destroys a notifier.
126
// *
127
// * <p>Destruction wakes up any waiters.
128
// *
129
// * @param notifierHandle the notifier handle
130
// * @see "HAL_DestroyNotifier"
131
// */
132
// public static native void destroyNotifier(int notifierHandle);
133
134
// /**
135
// * Updates the initial and interval alarm times for a notifier.
136
// *
137
// * <p>The alarmTime is an absolute time (using the WPI now() time base) if absolute is true, or
138
// * relative to the current time if absolute is false.
139
// *
140
// * <p>If intervalTime is non-zero, the notifier will alarm periodically following alarmTime at the
141
// * given interval.
142
// *
143
// * <p>If an absolute alarmTime is in the past, the notifier will alarm immediately.
144
// *
145
// * @param notifierHandle the notifier handle
146
// * @param alarmTime the first alarm time (in nanoseconds)
147
// * @param intervalTime the periodic interval time (in nanoseconds)
148
// * @param absolute true if the alarm time is absolute
149
// * @param ack true to acknowledge any prior alarm
150
// * @see "HAL_SetNotifierAlarm"
151
// */
152
// public static native void setNotifierAlarm(
153
// int notifierHandle, long alarmTime, long intervalTime, boolean absolute, boolean ack);
154
155
// /**
156
// * Cancels all future notifier alarms for a notifier.
157
// *
158
// * @param notifierHandle the notifier handle
159
// * @param ack true to acknowledge any prior alarm
160
// * @see "HAL_CancelNotifierAlarm"
161
// */
162
// public static native void cancelNotifierAlarm(int notifierHandle, boolean ack);
163
164
// /**
165
// * Indicates the notifier alarm has been serviced. Makes no change to future alarms.
166
// *
167
// * <p>One of setNotifierAlarm (with ack=true), cancelNotifierAlarm (with ack=true), or this
168
// * function must be called before waiting for the next alarm.
169
// *
170
// * @param notifierHandle the notifier handle
171
// * @see "HAL_AcknowledgeNotifierAlarm"
172
// */
173
// public static native void acknowledgeNotifierAlarm(int notifierHandle);
174
175
// /**
176
// * Gets the overrun count for a notifier.
177
// *
178
// * <p>An overrun occurs when a notifier's alarm is not serviced before the next scheduled alarm
179
// * time.
180
// *
181
// * @param notifierHandle the notifier handle
182
// * @return overrun count
183
// */
184
// public static native int getNotifierOverrun(int notifierHandle);
185
186
// /** Utility class. */
187
// private NotifierJNI() {}
188
}
org.wpilib.hardware.hal.NotifierJNI
Definition
NotifierJNI.java:25
org.wpilib.hardware.hal.PiNotifier.PiNotifiers
Definition
PiNotifiers.java:28
org.wpilib.hardware.hal.PiNotifier.PiNotifiers.setNotifierAlarm
static void setNotifierAlarm(int handle, long alarmTime, long intervalTime, boolean absolute, boolean ack)
Definition
PiNotifiers.java:123
org.wpilib.hardware.hal.PiNotifier.PiNotifiers.destroyNotifier
static void destroyNotifier(int handle)
Definition
PiNotifiers.java:101
org.wpilib.hardware.hal.PiNotifier.PiNotifiers.cancelNotifierAlarm
static void cancelNotifierAlarm(int handle, boolean ack)
Definition
PiNotifiers.java:155
org.wpilib.hardware.hal.PiNotifier.PiNotifiers.setNotifierName
static void setNotifierName(int handle, String name)
Definition
PiNotifiers.java:84
org.wpilib.hardware.hal.PiNotifier.PiNotifiers.createNotifier
static int createNotifier()
Definition
PiNotifiers.java:60
org
wpilib
hardware
hal
NotifierJNI.java
Generated by
1.18.0