RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
DataLogJNI.java
1// TODO - RobotCore - modified
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
7package org.wpilib.datalog;
8
9import java.nio.ByteBuffer;
10
11// import java.io.IOException;
12// import java.nio.ByteBuffer;
13// import java.util.concurrent.atomic.AtomicBoolean;
14// import org.wpilib.util.runtime.RuntimeLoader;
15
21public class DataLogJNI {
22 static void bgSetDir(long impl, String dir, long maxSize) {
23 throw new UnsupportedOperationException("Unimplemented method 'flush'");
24 // TODO - Must fix
25 }
26
27 static String bgGetDir(long impl) {
28 throw new UnsupportedOperationException("Unimplemented method 'flush'");
29 // TODO - Must fix
30 }
31 static void flush(long impl) {
32 throw new UnsupportedOperationException("Unimplemented method 'flush'");
33 // TODO - Must fix
34 }
35
36 static void pause(long impl)
37 {
38 throw new UnsupportedOperationException("Unimplemented method 'pause'");
39 // TODO - Must fix
40 }
41
42 static void resume(long impl) {
43 throw new UnsupportedOperationException("Unimplemented method 'resume'");
44 // TODO - Must fix
45 }
46
47 static void stop(long impl)
48 {
49 throw new UnsupportedOperationException("Unimplemented method 'stop'");
50 // TODO - Must fix
51 }
52
53 static void addSchema(long impl, String name, String type, byte[] schema, long timestamp) {
54 throw new UnsupportedOperationException("Unimplemented method 'addSchema'");
55 // TODO - Must fix
56 }
57
58 static void addSchemaString(long impl, String name, String type, String schema, long timestamp)
59 {
60 throw new UnsupportedOperationException("Unimplemented method 'addShemaString'");
61 // TODO - Must fix
62 }
63
64 static int start(long impl, String name, String type, String metadata, long timestamp) {
65 throw new UnsupportedOperationException("Unimplemented method 'start'");
66 // return 0; // TODO - Must fix
67 }
68
69 static void finish(long impl, int entry, long timestamp) {
70 throw new UnsupportedOperationException("Unimplemented method 'finish'");
71 // TODO - Must fix
72 }
73
74 static void setMetadata(long impl, int entry, String metadata, long timestamp) {
75 throw new UnsupportedOperationException("Unimplemented method 'setMetadata'");
76 // TODO - Must fix
77 }
78
79 static void close(long impl) {
80 throw new UnsupportedOperationException("Unimplemented method 'DataLogJNI.close'");
81 // TODO - Must fix
82 }
83
84 static void appendRaw(long impl, int entry, byte[] data, int start, int len, long timestamp) {
85 throw new UnsupportedOperationException("Unimplemented method 'appendRaw'");
86 // TODO - Must fix
87 }
88
89 static void appendRaw(long impl, int entry, ByteBuffer data, int start, int len, long timestamp) {
90 throw new UnsupportedOperationException("Unimplemented method 'appendRaw'");
91 // TODO - Must fix
92 }
93
94 static void appendBoolean(long impl, int entry, boolean value, long timestamp) {
95 throw new UnsupportedOperationException("Unimplemented method 'appendBoolean'");
96 // TODO - Must fix
97 }
98
99 static void appendInteger(long impl, int entry, long value, long timestamp) {
100 throw new UnsupportedOperationException("Unimplemented method 'appendInteger'");
101 // TODO - Must fix
102 }
103
104 static void appendFloat(long impl, int entry, float value, long timestamp) {
105 throw new UnsupportedOperationException("Unimplemented method 'appendFloat'");
106 // TODO - Must fix
107 }
108
109 static void appendDouble(long impl, int entry, double value, long timestamp) {
110 throw new UnsupportedOperationException("Unimplemented method 'appendDouble'");
111 // TODO - Must fix
112 }
113
114 static void appendString(long impl, int entry, String value, long timestamp) {
115 throw new UnsupportedOperationException("Unimplemented method 'appendString'");
116 // TODO - Must fix
117 }
118
119 static void appendBooleanArray(long impl, int entry, boolean[] value, long timestamp) {
120 throw new UnsupportedOperationException("Unimplemented method 'appendBooleanArray'");
121 // TODO - Must fix
122 }
123
124 static void appendIntegerArray(long impl, int entry, long[] value, long timestamp) {
125 throw new UnsupportedOperationException("Unimplemented method 'appendIntegerArray'");
126 // TODO - Must fix
127 }
128
129 static void appendFloatArray(long impl, int entry, float[] value, long timestamp) {
130 throw new UnsupportedOperationException("Unimplemented method 'appendFloatArray'");
131 // TODO - Must fix
132 }
133
134 static void appendDoubleArray(long impl, int entry, double[] value, long timestamp) {
135 throw new UnsupportedOperationException("Unimplemented method 'appendDoubleArray'");
136 // TODO - Must fix
137 }
138
139 static void appendStringArray(long impl, int entry, String[] value, long timestamp) {
140 throw new UnsupportedOperationException("Unimplemented method 'appendStringArray'");
141 // TODO - Must fix
142 }
143
144 static long bgCreate(String dir, String filename, double period, String extraHeader) {
145 throw new UnsupportedOperationException("Unimplemented method 'bgCreate'");
146 // return 0; // TODO - Must fix
147 }
148
149 static void bgSetFilename(long impl, String filename) {
150 throw new UnsupportedOperationException("Unimplemented method 'bgSetFilename'");
151 // TODO - Must fix
152 }
153
154 public static long createFileLogger(String file, long log, String key) {
155 throw new UnsupportedOperationException("Unimplemented method 'createFileLogger'");
156 // return 0; // TODO - Must fix
157 }
158
159 public static void freeFileLogger(long fileTail) {
160 throw new UnsupportedOperationException("Unimplemented method 'freeFileLogger'");
161 // TODO - Must fix
162 }
163
164
165
166 // static boolean libraryLoaded = false;
167
168 // /** Sets whether JNI should be loaded in the static block. */
169 // public static class Helper {
170 // private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
171
172 // /**
173 // * Returns true if the JNI should be loaded in the static block.
174 // *
175 // * @return True if the JNI should be loaded in the static block.
176 // */
177 // public static boolean getExtractOnStaticLoad() {
178 // return extractOnStaticLoad.get();
179 // }
180
181 // /**
182 // * Sets whether the JNI should be loaded in the static block.
183 // *
184 // * @param load Whether the JNI should be loaded in the static block.
185 // */
186 // public static void setExtractOnStaticLoad(boolean load) {
187 // extractOnStaticLoad.set(load);
188 // }
189
190 // /** Utility class. */
191 // private Helper() {}
192 // }
193
194 // static {
195 // if (Helper.getExtractOnStaticLoad()) {
196 // try {
197 // RuntimeLoader.loadLibrary("datalogjni");
198 // } catch (Exception ex) {
199 // ex.printStackTrace();
200 // System.exit(1);
201 // }
202 // libraryLoaded = true;
203 // }
204 // }
205
206 // /**
207 // * Force load the library.
208 // *
209 // * @throws IOException if the library failed to load
210 // */
211 // public static synchronized void forceLoad() throws IOException {
212 // if (libraryLoaded) {
213 // return;
214 // }
215 // RuntimeLoader.loadLibrary("datalogjni");
216 // libraryLoaded = true;
217 // }
218
219 // /**
220 // * Create a new Data Log background writer. The log will be initially created with a temporary
221 // * filename.
222 // *
223 // * @param dir directory to store the log
224 // * @param filename filename to use; if none provided, a random filename is generated of the form
225 // * "wpilog_{}.wpilog"
226 // * @param period time between automatic flushes to disk, in seconds; this is a time/storage
227 // * tradeoff
228 // * @param extraHeader extra header data
229 // * @return data log background writer implementation handle
230 // */
231 // static native long bgCreate(String dir, String filename, double period, String extraHeader);
232
233 // /**
234 // * Change log filename.
235 // *
236 // * @param impl data log background writer implementation handle
237 // * @param filename filename
238 // */
239 // static native void bgSetFilename(long impl, String filename);
240
241 // /**
242 // * Create a new Data Log foreground writer.
243 // *
244 // * @param filename filename to use
245 // * @param extraHeader extra header data
246 // * @return data log writer implementation handle
247 // * @throws IOException if file cannot be opened
248 // */
249 // static native long fgCreate(String filename, String extraHeader) throws IOException;
250
251 // /**
252 // * Create a new Data Log foreground writer to a memory buffer.
253 // *
254 // * @param extraHeader extra header data
255 // * @return data log writer implementation handle
256 // */
257 // static native long fgCreateMemory(String extraHeader);
258
259 // /**
260 // * Explicitly flushes the log data to disk.
261 // *
262 // * @param impl data log background writer implementation handle
263 // */
264 // static native void flush(long impl);
265
266 // /**
267 // * Flushes the log data to a memory buffer (only valid with fgCreateMemory data logs).
268 // *
269 // * @param impl data log background writer implementation handle
270 // * @param buf output data buffer
271 // * @param pos position in write buffer to start copying from
272 // * @return Number of bytes written to buffer; 0 if no more to copy
273 // */
274 // static native int copyWriteBuffer(long impl, byte[] buf, int pos);
275
276 // /**
277 // * Pauses appending of data records to the log. While paused, no data records are saved (e.g.
278 // * AppendX is a no-op). Has no effect on entry starts / finishes / metadata changes.
279 // *
280 // * @param impl data log background writer implementation handle
281 // */
282 // static native void pause(long impl);
283
284 // /**
285 // * Resumes appending of data records to the log. If called after Stop(), opens a new file (with
286 // * random name if SetFilename was not called after Stop()) and appends Start records and schema
287 // * data values for all previously started entries and schemas.
288 // *
289 // * @param impl data log background writer implementation handle
290 // */
291 // static native void resume(long impl);
292
293 // /**
294 // * Stops appending all records to the log, and closes the log file.
295 // *
296 // * @param impl data log background writer implementation handle
297 // */
298 // static native void stop(long impl);
299
300 // /**
301 // * Registers a data schema. Data schemas provide information for how a certain data type string
302 // * can be decoded. The type string of a data schema indicates the type of the schema itself (e.g.
303 // * "protobuf" for protobuf schemas, "struct" for struct schemas, etc). In the data log, schemas
304 // * are saved just like normal records, with the name being generated from the provided name:
305 // * "/.schema/<name>". Duplicate calls to this function with the same name are silently
306 // * ignored.
307 // *
308 // * @param impl data log implementation handle
309 // * @param name Name (the string passed as the data type for records using this schema)
310 // * @param type Type of schema (e.g. "protobuf", "struct", etc)
311 // * @param schema Schema data
312 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
313 // */
314 // static native void addSchema(long impl, String name, String type, byte[] schema, long timestamp);
315
316 // static native void addSchemaString(
317 // long impl, String name, String type, String schema, long timestamp);
318
319 // /**
320 // * Start an entry. Duplicate names are allowed (with the same type), and result in the same index
321 // * being returned (Start/Finish are reference counted). A duplicate name with a different type
322 // * will result in an error message being printed to the console and 0 being returned (which will
323 // * be ignored by the Append functions).
324 // *
325 // * @param impl data log implementation handle
326 // * @param name Name
327 // * @param type Data type
328 // * @param metadata Initial metadata (e.g. data properties)
329 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
330 // * @return Entry index
331 // */
332 // static native int start(long impl, String name, String type, String metadata, long timestamp);
333
334 // /**
335 // * Finish an entry.
336 // *
337 // * @param impl data log implementation handle
338 // * @param entry Entry index
339 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
340 // */
341 // static native void finish(long impl, int entry, long timestamp);
342
343 // /**
344 // * Updates the metadata for an entry.
345 // *
346 // * @param impl data log implementation handle
347 // * @param entry Entry index
348 // * @param metadata New metadata for the entry
349 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
350 // */
351 // static native void setMetadata(long impl, int entry, String metadata, long timestamp);
352
353 // /**
354 // * Closes the data log implementation handle.
355 // *
356 // * @param impl data log implementation handle
357 // */
358 // static native void close(long impl);
359
360 // /**
361 // * Appends a raw record to the log.
362 // *
363 // * @param impl data log implementation handle
364 // * @param entry Entry index, as returned by WPI_DataLog_Start()
365 // * @param data Byte array to record
366 // * @param len Length of byte array
367 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
368 // */
369 // static native void appendRaw(
370 // long impl, int entry, byte[] data, int start, int len, long timestamp);
371
372 // /**
373 // * Appends a raw record to the log.
374 // *
375 // * @param impl data log implementation handle
376 // * @param entry Entry index, as returned by WPI_DataLog_Start()
377 // * @param data ByteBuffer to record
378 // * @param len Length of byte array
379 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
380 // */
381 // static void appendRaw(long impl, int entry, ByteBuffer data, int start, int len, long timestamp) {
382 // if (start < 0) {
383 // throw new IndexOutOfBoundsException("start must be >= 0");
384 // }
385 // if (len < 0) {
386 // throw new IndexOutOfBoundsException("len must be >= 0");
387 // }
388 // int capacity = data.capacity();
389 // if (start > capacity || len > capacity - start) {
390 // throw new IndexOutOfBoundsException("start + len must be within buffer capacity");
391 // }
392 // if (data.isDirect()) {
393 // appendRawBuffer(impl, entry, data, start, len, timestamp);
394 // } else if (data.hasArray()) {
395 // appendRaw(impl, entry, data.array(), data.arrayOffset() + start, len, timestamp);
396 // } else {
397 // throw new UnsupportedOperationException("ByteBuffer must be direct or have a backing array");
398 // }
399 // }
400
401 // static native void appendRawBuffer(
402 // long impl, int entry, ByteBuffer data, int start, int len, long timestamp);
403
404 // /**
405 // * Appends a boolean record to the log.
406 // *
407 // * @param impl data log implementation handle
408 // * @param entry Entry index, as returned by Start()
409 // * @param value Boolean value to record
410 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
411 // */
412 // static native void appendBoolean(long impl, int entry, boolean value, long timestamp);
413
414 // /**
415 // * Appends an integer record to the log.
416 // *
417 // * @param impl data log implementation handle
418 // * @param entry Entry index, as returned by Start()
419 // * @param value Integer value to record
420 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
421 // */
422 // static native void appendInteger(long impl, int entry, long value, long timestamp);
423
424 // /**
425 // * Appends a float record to the log.
426 // *
427 // * @param impl data log implementation handle
428 // * @param entry Entry index, as returned by Start()
429 // * @param value Float value to record
430 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
431 // */
432 // static native void appendFloat(long impl, int entry, float value, long timestamp);
433
434 // /**
435 // * Appends a double record to the log.
436 // *
437 // * @param impl data log implementation handle
438 // * @param entry Entry index, as returned by Start()
439 // * @param value Double value to record
440 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
441 // */
442 // static native void appendDouble(long impl, int entry, double value, long timestamp);
443
444 // /**
445 // * Appends a string record to the log.
446 // *
447 // * @param impl data log implementation handle
448 // * @param entry Entry index, as returned by Start()
449 // * @param value String value to record
450 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
451 // */
452 // static native void appendString(long impl, int entry, String value, long timestamp);
453
454 // /**
455 // * Appends a boolean array record to the log.
456 // *
457 // * @param impl data log implementation handle
458 // * @param entry Entry index, as returned by Start()
459 // * @param value Boolean array to record
460 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
461 // */
462 // static native void appendBooleanArray(long impl, int entry, boolean[] value, long timestamp);
463
464 // /**
465 // * Appends an integer array record to the log.
466 // *
467 // * @param impl data log implementation handle
468 // * @param entry Entry index, as returned by Start()
469 // * @param value Integer array to record
470 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
471 // */
472 // static native void appendIntegerArray(long impl, int entry, long[] value, long timestamp);
473
474 // /**
475 // * Appends a float array record to the log.
476 // *
477 // * @param impl data log implementation handle
478 // * @param entry Entry index, as returned by Start()
479 // * @param value Float array to record
480 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
481 // */
482 // static native void appendFloatArray(long impl, int entry, float[] value, long timestamp);
483
484 // /**
485 // * Appends a double array record to the log.
486 // *
487 // * @param impl data log implementation handle
488 // * @param entry Entry index, as returned by Start()
489 // * @param value Double array to record
490 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
491 // */
492 // static native void appendDoubleArray(long impl, int entry, double[] value, long timestamp);
493
494 // /**
495 // * Appends a string array record to the log.
496 // *
497 // * @param impl data log implementation handle
498 // * @param entry Entry index, as returned by Start()
499 // * @param value String array to record
500 // * @param timestamp Time stamp in nanoseconds (may be 0 to indicate now)
501 // */
502 // static native void appendStringArray(long impl, int entry, String[] value, long timestamp);
503
504 // /**
505 // * Create a native FileLogger. When the specified file is modified, appended data will be appended
506 // * to the specified data log.
507 // *
508 // * @param file path to the file
509 // * @param log data log implementation handle
510 // * @param key log key to append data to
511 // * @return The FileLogger handle.
512 // */
513 // public static native long createFileLogger(String file, long log, String key);
514
515 // /**
516 // * Free a native FileLogger. This causes the FileLogger to stop appending data to the log.
517 // *
518 // * @param fileTail The FileLogger handle.
519 // */
520 // public static native void freeFileLogger(long fileTail);
521
522 // /** Utility class. */
523 // private DataLogJNI() {}
524}