storage

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StorageHeaders = map[StorageType][]string{
	MOTION: {
		"time", "altitude", "velocity", "acceleration", "thrust",
	},
	EVENTS: {
		"time", "motor_status", "parachute_status",
	},
	DYNAMICS: {
		"time", "position_x", "position_y", "position_z", "velocity_x", "velocity_y", "velocity_z", "acceleration_x", "acceleration_y", "acceleration_z", "orientation_x", "orientation_y", "orientation_z", "orientation_w",
	},
}

StorageHeaders is a map of columns for storage types

Functions

This section is empty.

Types

type Record

type Record struct {
	Name         string
	Hash         string
	LastModified time.Time
	Path         string
	Motion       *Storage
	Events       *Storage
	Dynamics     *Storage
}

func NewRecord

func NewRecord(baseDir string, hash string) (*Record, error)

NewRecord creates a new simulation record with associated storage services

func (*Record) Close

func (r *Record) Close() error

Close closes all associated storage services

type RecordManager

type RecordManager struct {
	// contains filtered or unexported fields
}

RecordManager manages simulation records

func NewRecordManager

func NewRecordManager(baseDir string) (*RecordManager, error)

func (*RecordManager) CreateRecord

func (rm *RecordManager) CreateRecord() (*Record, error)

CreateRecord creates a new record with a unique hash

func (*RecordManager) DeleteRecord

func (rm *RecordManager) DeleteRecord(hash string) error

DeleteRecord deletes a record by Hash

func (*RecordManager) GetRecord

func (rm *RecordManager) GetRecord(hash string) (*Record, error)

GetRecord retrieves an existing record by hash without creating a new one.

func (*RecordManager) ListRecords

func (rm *RecordManager) ListRecords() ([]*Record, error)

ListRecords lists all existing records in the base directory with their last modified time.

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage is a service that writes csv's to disk

func NewStorage

func NewStorage(baseDir string, dir string, store StorageType) (*Storage, error)

NewStorage creates a new storage service. If the provided baseDir is not absolute, it is prepended with the user's home directory.

func (*Storage) Close

func (s *Storage) Close() error

Close closes the storage service.

func (*Storage) GetFilePath

func (s *Storage) GetFilePath() string

GetFilePath returns the file path of the storage service.

func (*Storage) Init

func (s *Storage) Init() error

Init initializes the storage service with headers.

func (*Storage) ReadAll

func (s *Storage) ReadAll() ([][]string, error)

ReadAll reads all data from the storage file

func (*Storage) ReadHeadersAndData

func (s *Storage) ReadHeadersAndData() ([]string, [][]string, error)

ReadHeadersAndData reads the headers and data separately from the storage file

func (*Storage) Write

func (s *Storage) Write(data []string) error

Write writes a record to the storage service.

type StorageInterface

type StorageInterface interface {
	Init() error
	Write([]string) error
	Close() error
}

type StorageType

type StorageType string

StorageType is the type of storage service (MOTION, EVENTS, etc.)

const (
	// MOTION storage StorageType
	MOTION StorageType = "MOTION"
	// EVENTS storage StorageType
	EVENTS StorageType = "EVENTS"
	// DYNAMICS storage StorageType
	DYNAMICS StorageType = "DYNAMICS"
)

type Stores

type Stores struct {
	Motion   *Storage
	Events   *Storage
	Dynamics *Storage
}

Stores is a collection of storage services

Jump to

Keyboard shortcuts

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