Documentation ¶
Overview ¶
Package datacapture contains tools for interacting with Viam datacapture files.
Index ¶
- Constants
- func BuildCaptureMetadata(compAPI resource.API, compName string, method string, ...) (*v1.DataCaptureMetadata, error)
- func FilePathWithReplacedReservedChars(filepath string) string
- func GetFileExt(dataType v1.DataType, methodName string, parameters map[string]string) string
- func IsDataCaptureFile(f *os.File) bool
- func SensorDataFromFile(f *File) ([]*v1.SensorData, error)
- func SensorDataFromFilePath(filePath string) ([]*v1.SensorData, error)
- type Buffer
- type BufferedWriter
- type File
- func (f *File) Close() error
- func (f *File) Delete() error
- func (f *File) Flush() error
- func (f *File) GetPath() string
- func (f *File) ReadMetadata() *v1.DataCaptureMetadata
- func (f *File) ReadNext() (*v1.SensorData, error)
- func (f *File) Reset()
- func (f *File) Size() int64
- func (f *File) WriteNext(data *v1.SensorData) error
Constants ¶
const ( InProgressFileExt = ".prog" FileExt = ".capture" // GetImages is used for getting simultaneous images from different imagers. GetImages = "GetImages" )
FileExt defines the file extension for Viam data capture files.
Variables ¶
This section is empty.
Functions ¶
func BuildCaptureMetadata ¶
func BuildCaptureMetadata( compAPI resource.API, compName string, method string, additionalParams map[string]string, tags []string, ) (*v1.DataCaptureMetadata, error)
BuildCaptureMetadata builds a DataCaptureMetadata object and returns error if additionalParams fails to convert to anypb map.
func FilePathWithReplacedReservedChars ¶ added in v0.12.0
FilePathWithReplacedReservedChars returns the filepath with substitutions for reserved characters.
func GetFileExt ¶ added in v0.0.9
GetFileExt gets the file extension for a capture file.
func IsDataCaptureFile ¶
IsDataCaptureFile returns whether or not f is a data capture file.
func SensorDataFromFile ¶ added in v0.2.20
func SensorDataFromFile(f *File) ([]*v1.SensorData, error)
SensorDataFromFile returns all readings in f.
func SensorDataFromFilePath ¶ added in v0.2.20
func SensorDataFromFilePath(filePath string) ([]*v1.SensorData, error)
SensorDataFromFilePath returns all readings in the file at filePath.
Types ¶
type Buffer ¶ added in v0.2.9
type Buffer struct { Directory string MetaData *v1.DataCaptureMetadata // contains filtered or unexported fields }
Buffer is a persistent queue of SensorData backed by a series of datacapture.Files.
func NewBuffer ¶ added in v0.2.9
func NewBuffer(dir string, md *v1.DataCaptureMetadata, maxCaptureFileSize int64) *Buffer
NewBuffer returns a new Buffer.
func (*Buffer) Flush ¶ added in v0.2.9
Flush flushes all buffered data to disk and marks any in progress file as complete.
func (*Buffer) Path ¶ added in v0.2.24
Path returns the path to the directory containing the backing data capture files.
func (*Buffer) Write ¶ added in v0.2.9
func (b *Buffer) Write(item *v1.SensorData) error
Write writes item onto b. Binary sensor data is written to its own file. Tabular data is written to disk in maxCaptureFileSize sized files. Files that are still being written to are indicated with the extension InProgressFileExt. Files that have finished being written to are indicated by FileExt.
type BufferedWriter ¶ added in v0.2.24
type BufferedWriter interface { Write(item *v1.SensorData) error Flush() error Path() string }
BufferedWriter is a buffered, persistent queue of SensorData.
type File ¶ added in v0.1.6
type File struct {
// contains filtered or unexported fields
}
File is the data structure containing data captured by collectors. It is backed by a file on disk containing length delimited protobuf messages, where the first message is the CaptureMetadata for the file, and ensuing messages contain the captured data.
func NewFile ¶ added in v0.1.6
func NewFile(dir string, md *v1.DataCaptureMetadata) (*File, error)
NewFile creates a new File with the specified md in the specified directory.
func ReadFile ¶ added in v0.1.6
ReadFile creates a File struct from a passed os.File previously constructed using NewFile.
func (*File) ReadMetadata ¶ added in v0.1.6
func (f *File) ReadMetadata() *v1.DataCaptureMetadata
ReadMetadata reads and returns the metadata in f.