handler

package
v0.0.0-...-3d3156d Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DatabaseGenerator

func DatabaseGenerator(src uint8, path string) error

Types

type Data

type Data struct {
	Iter  uint32
	SendT uint32
	Value []float64
}

type Handler

type Handler struct {
	utils.JsonStandard
	DBName string

	DBPointer    *sql.DB
	Tables       []string
	InteTable    uint8
	RelaTable    uint8
	InfoTable    uint8
	RecordTables []uint16

	DataShapes map[uint16]uint8
	DataBuffer map[uint16]chan *Data
}

Handler is the main struct for the handler

func (*Handler) Init

func (handler *Handler) Init(id uint8) error

func (*Handler) QueryFirstSynt

func (handler *Handler) QueryFirstSynt(id uint16) uint32

QueryFirstSynt query the first time of the data Args:

id: the id of the data

Return:

time: the first time of the data

func (*Handler) QueryInfo

func (handler *Handler) QueryInfo(id uint16, column string) (int, error)

QueryInfo query the information of the data Args:

id: the id of the data
column: the column name of the data

Return:

para: the value of the column
err: the error of the query

func (*Handler) QueryLastSynt

func (handler *Handler) QueryLastSynt(id uint16) uint32

QueryLastSynt query the last time of the data Args:

id: the id of the data

Return:

time: the last time of the data

func (*Handler) ReadRange

func (handler *Handler) ReadRange(id uint16, start uint32, end uint32) ([]uint32, []uint64, [][]float64, error)

Read multiple rows of data from database

Args:

  • id: data id
  • start: start simulation timestamp
  • end: end simulation timestamp

Return:

  • simulation time 1D vector
  • physical time 1D vector
  • data matrix (2D)
  • err: error

func (*Handler) ReadSynt

func (handler *Handler) ReadSynt(id uint16, synt uint32) (uint64, []float64, error)

func (*Handler) WriteRange

func (handler *Handler) WriteRange(id uint16, dataVec []*Data) error

func (*Handler) WriteSynt

func (handler *Handler) WriteSynt(id uint16, data *Data) error

func (*Handler) WriteToBuffer

func (handler *Handler) WriteToBuffer(id uint16, data *Data) error

type TableInfo

type TableInfo struct {
	utils.JsonStandard
	Id       uint16 `json:"data_id"`
	Name     string `json:"data_name"`
	Type     uint16 `json:"data_type"`
	Subtype1 uint16 `json:"data_subtype1"`
	Subtype2 uint16 `json:"data_subtype2"`
	Rate     uint16 `json:"data_rate"`
	Size     uint16 `json:"data_size"`
	Unit     string `json:"data_unit"`
	Notes    string `json:"data_notes"`
}

TableInfo struct defines the structure of the data information table

func ReadDataInfo

func ReadDataInfo(path string) ([]TableInfo, error)

ReadDataInfo function reads the data information from the specified file path Args:

path: the path of the data information file

Returns:

dataList: the list of data information

Jump to

Keyboard shortcuts

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