datacapture

package
v0.27.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package datacapture contains tools for interacting with Viam datacapture files.

Index

Constants

View Source
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

View Source
var MaxFileSize = int64(64 * 1024)

MaxFileSize is the maximum size in bytes of a data capture file.

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

func FilePathWithReplacedReservedChars(filepath string) string

FilePathWithReplacedReservedChars returns the filepath with substitutions for reserved characters.

func GetFileExt added in v0.0.9

func GetFileExt(dataType v1.DataType, methodName string, parameters map[string]string) string

GetFileExt gets the file extension for a capture file.

func IsDataCaptureFile

func IsDataCaptureFile(f *os.File) bool

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) *Buffer

NewBuffer returns a new Buffer.

func (*Buffer) Flush added in v0.2.9

func (b *Buffer) Flush() error

Flush flushes all buffered data to disk and marks any in progress file as complete.

func (*Buffer) Path added in v0.2.24

func (b *Buffer) Path() string

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 MaxFileSize 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

func ReadFile(f *os.File) (*File, error)

ReadFile creates a File struct from a passed os.File previously constructed using NewFile.

func (*File) Close added in v0.1.6

func (f *File) Close() error

Close closes the file.

func (*File) Delete added in v0.1.6

func (f *File) Delete() error

Delete deletes the file.

func (*File) Flush added in v0.2.9

func (f *File) Flush() error

Flush flushes any buffered writes to disk.

func (*File) GetPath added in v0.1.6

func (f *File) GetPath() string

GetPath returns the path of the underlying os.File.

func (*File) ReadMetadata added in v0.1.6

func (f *File) ReadMetadata() *v1.DataCaptureMetadata

ReadMetadata reads and returns the metadata in f.

func (*File) ReadNext added in v0.1.6

func (f *File) ReadNext() (*v1.SensorData, error)

ReadNext returns the next SensorData reading.

func (*File) Reset added in v0.2.9

func (f *File) Reset()

Reset resets the read pointer of f.

func (*File) Size added in v0.1.6

func (f *File) Size() int64

Size returns the size of the file.

func (*File) WriteNext added in v0.1.6

func (f *File) WriteNext(data *v1.SensorData) error

WriteNext writes the next SensorData reading.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL