001// Copyright (c) FIRST and other WPILib contributors. 002// Open Source Software; you can modify and/or share it under the terms of 003// the WPILib BSD license file in the root directory of this project. 004 005package edu.wpi.first.util.datalog; 006 007import java.nio.ByteBuffer; 008 009/** Log raw byte array values. */ 010public class RawLogEntry extends DataLogEntry { 011 public static final String kDataType = "raw"; 012 013 public RawLogEntry(DataLog log, String name, String metadata, String type, long timestamp) { 014 super(log, name, type, metadata, timestamp); 015 } 016 017 public RawLogEntry(DataLog log, String name, String metadata, String type) { 018 this(log, name, metadata, type, 0); 019 } 020 021 public RawLogEntry(DataLog log, String name, String metadata, long timestamp) { 022 this(log, name, metadata, kDataType, timestamp); 023 } 024 025 public RawLogEntry(DataLog log, String name, String metadata) { 026 this(log, name, metadata, 0); 027 } 028 029 public RawLogEntry(DataLog log, String name, long timestamp) { 030 this(log, name, "", timestamp); 031 } 032 033 public RawLogEntry(DataLog log, String name) { 034 this(log, name, 0); 035 } 036 037 /** 038 * Appends a record to the log. 039 * 040 * @param value Value to record; will send entire array contents 041 * @param timestamp Time stamp (0 to indicate now) 042 */ 043 public void append(byte[] value, long timestamp) { 044 m_log.appendRaw(m_entry, value, timestamp); 045 } 046 047 /** 048 * Appends a record to the log. 049 * 050 * @param value Value to record; will send entire array contents 051 */ 052 public void append(byte[] value) { 053 append(value, 0); 054 } 055 056 /** 057 * Appends a record to the log. 058 * 059 * @param value Data to record 060 * @param start Start position of data (in byte array) 061 * @param len Length of data (must be less than or equal to value.length - offset) 062 * @param timestamp Time stamp (0 to indicate now) 063 */ 064 public void append(byte[] value, int start, int len, long timestamp) { 065 m_log.appendRaw(m_entry, value, start, len, timestamp); 066 } 067 068 /** 069 * Appends a record to the log. 070 * 071 * @param value Data to record 072 * @param start Start position of data (in byte array) 073 * @param len Length of data (must be less than or equal to value.length - offset) 074 */ 075 public void append(byte[] value, int start, int len) { 076 append(value, start, len, 0); 077 } 078 079 /** 080 * Appends a record to the log. 081 * 082 * @param value Data to record; will send from value.position() to value.capacity() 083 * @param timestamp Time stamp (0 to indicate now) 084 */ 085 public void append(ByteBuffer value, long timestamp) { 086 m_log.appendRaw(m_entry, value, timestamp); 087 } 088 089 /** 090 * Appends a record to the log. 091 * 092 * @param value Data to record; will send from value.position() to value.capacity() 093 */ 094 public void append(ByteBuffer value) { 095 append(value, 0); 096 } 097 098 /** 099 * Appends a record to the log. 100 * 101 * @param value Data to record 102 * @param start Start position of data (in value buffer) 103 * @param len Length of data (must be less than or equal to value.length - offset) 104 * @param timestamp Time stamp (0 to indicate now) 105 */ 106 public void append(ByteBuffer value, int start, int len, long timestamp) { 107 m_log.appendRaw(m_entry, value, start, len, timestamp); 108 } 109 110 /** 111 * Appends a record to the log. 112 * 113 * @param value Data to record 114 * @param start Start position of data (in value buffer) 115 * @param len Length of data (must be less than or equal to value.length - offset) 116 */ 117 public void append(ByteBuffer value, int start, int len) { 118 append(value, start, len, 0); 119 } 120}