models

package
v0.0.0-...-a9f2f87 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FUNC_CATEGORY_TRANSFORM = FunctionCategory("Transform")
	FUNC_CATEGORY_TOSCALAR  = FunctionCategory("Array to Scalar")
	FUNC_CATEGORY_FILTER    = FunctionCategory("Filter Series")
	FUNC_CATEGORY_SORT      = FunctionCategory("Sort")
	FUNC_CATEGORY_OPTIONS   = FunctionCategory("Options")
)
View Source
const (
	FUNC_OPTION_FIELDNAME       = FunctionOption("fieldName")
	FUNC_OPTION_LIVEONLY        = FunctionOption("liveOnly")
	FUNC_OPTION_MAXNUMPVS       = FunctionOption("maxNumPVs")
	FUNC_OPTION_DISABLEAUTORAW  = FunctionOption("disableAutoRaw")
	FUNC_OPTION_DISABLEEXTRAPOL = FunctionOption("disableExtrapol")
	FUNC_OPTION_BININTERVAL     = FunctionOption("binInterval")
	FUNC_OPTION_ARRAY_FORMAT    = FunctionOption("arrayFormat")
	FUNC_OPTION_IGNOREEMPTYERR  = FunctionOption("ignoreEmptyErr")
	FUNC_OPTION_HIDEINVALID     = FunctionOption("hideInvalid")
)
View Source
const (
	RANKTYPE_AVG         = RankType("Avg")
	RANKTYPE_MIN         = RankType("Min")
	RANKTYPE_MAX         = RankType("Max")
	RANKTYPE_ABSOLUTEMIN = RankType("AbsoluteMin")
	RANKTYPE_ABSOLUTEMAX = RankType("AbsoluteMax")
	RANKTYPE_SUM         = RankType("Sum")
)
View Source
const (
	FORMAT_TIMESERIES = FunctionCategory("timeseries")
	FORMAT_INDEX      = FunctionCategory("index")
	FORMAT_DTSPACE    = FunctionCategory("dt-space")
)

Variables

This section is empty.

Functions

func SingleDataCompareHelper

func SingleDataCompareHelper(result []*SingleData, wanted []*SingleData, t *testing.T)

Types

type ArchiverQueryModel

type ArchiverQueryModel struct {
	// It's not apparent to me where these two originate from but they do appear to be necessary
	Format    string      `json:"format"`
	Constant  json.Number `json:"constant"`  // I don't know what this is for yet
	QueryText string      `json:"queryText"` // deprecated

	// Parameters added in AAQuery's extension of DataQuery
	Target       string                         `json:"target"`       //This will be the PV as entered by the user, or regex searching for PVs
	Alias        string                         `json:"alias"`        // What to refer to the data as in the table - I think this only for the frontend rn
	AliasPattern string                         `json:"aliasPattern"` // use for collecting a large number of returned values
	Operator     string                         `json:"operator"`     // ?
	Regex        bool                           `json:"regex"`        // configured by the user's setting of the "Regex" field in the panel
	Live         bool                           `json:"live"`         // configured by the user's setting of the "Live" field in the panel
	Functions    []FunctionDescriptorQueryModel `json:"functions"`    // collection of functions to be applied to the data by the archiver

	// Only appears for visualization queries
	IntervalMs *int `json:"intervalMs,omitempty"`

	// Parameters from DataQuery
	RefId         string  `json:"refId"`
	Hide          *bool   `json:"hide"`
	Key           *string `json:"string"`
	QueryType     *string `json:"queryType"`
	MaxDataPoints int     `json:"maxDataPoints"`

	// Not from JSON
	TimeRange       backend.TimeRange `json:"-"`
	Interval        int               `json:"-"`
	BackendQuery    bool              `json:"-"`
	FieldName       string            `json:"-"`
	LiveOnly        bool              `json:"-"`
	MaxNumPVs       int               `json:"-"`
	DisableAutoRaw  bool              `json:"-"`
	DisableExtrapol bool              `json:"-"`
	HideInvalid     bool              `json:"-"`
	FormatOption    FormatOption      `json:"-"`
	IgnoreEmptyErr  bool              `json:"-"`
}

func ReadQueryModel

func ReadQueryModel(query backend.DataQuery, config DatasourceSettings) (ArchiverQueryModel, error)

func (ArchiverQueryModel) IdentifyFunctionsByName

func (qm ArchiverQueryModel) IdentifyFunctionsByName(targetName string) []FunctionDescriptorQueryModel

func (ArchiverQueryModel) LoadBooleanOption

func (qm ArchiverQueryModel) LoadBooleanOption(name FunctionOption, defaultv bool) (bool, error)

func (ArchiverQueryModel) LoadIntOption

func (qm ArchiverQueryModel) LoadIntOption(name FunctionOption, defaultv int) (int, error)

func (ArchiverQueryModel) LoadStrOption

func (qm ArchiverQueryModel) LoadStrOption(name FunctionOption, defaultv string) (string, error)

func (ArchiverQueryModel) PickFuncsByCategories

func (qm ArchiverQueryModel) PickFuncsByCategories(categories []FunctionCategory) []FunctionDescriptorQueryModel

type ArchiverResponseModel

type ArchiverResponseModel struct {
	// Structure for unpacking the JSON response from the Archiver
	Meta struct {
		Name     string      `json:"name"`
		Waveform bool        `json:"waveform"`
		EGU      string      `json:"EGU"`
		PREC     json.Number `json:"PREC"`
	} `json:"meta"`
	Data json.RawMessage `json:"data"`
}

type ArrayResponseModel

type ArrayResponseModel []SingleArrayResponseModel

func (ArrayResponseModel) ToSingleDataValues

func (response ArrayResponseModel) ToSingleDataValues() (Values, error)

type Arrays

type Arrays struct {
	Times  []time.Time
	Values [][]float64
}

func NewArrays

func NewArrays(length int) *Arrays

func (*Arrays) Append

func (v *Arrays) Append(val []float64, t time.Time)

func (*Arrays) Extrapolation

func (v *Arrays) Extrapolation(t time.Time)

func (*Arrays) ToFields

func (v *Arrays) ToFields(pvname string, name string, format FormatOption) []*data.Field

type DataResponse

type DataResponse interface {
	ToSingleDataValues() (Values, error)
}

type DatasourceSettings

type DatasourceSettings struct {
	DefaultOperator    string `json:"defaultOperator"`
	DefaultHideInvalid bool   `json:"hideInvalid"`
	UseLiveUpdate      bool   `json:"useLiveUpdate"`
	LiveUpdateURI      string `json:"liveUpdateURI"`

	URL string `json:"-"`
	UID string `json:"-"`
}

type Enums

type Enums struct {
	Times      []time.Time
	Values     []data.EnumItemIndex
	EnumConfig data.EnumFieldConfig
}

func NewEnums

func NewEnums(length int) *Enums

func NewSevirityEnums

func NewSevirityEnums(length int) *Enums

func NewStatusEnums

func NewStatusEnums(length int) *Enums

func (*Enums) Append

func (v *Enums) Append(val int16, t time.Time)

func (*Enums) Extrapolation

func (v *Enums) Extrapolation(t time.Time)

func (*Enums) ToFields

func (v *Enums) ToFields(pvname string, name string, format FormatOption) []*data.Field

type FieldName

type FieldName string
const (
	FIELD_NAME_VAL          FieldName = "VAL"
	FIELD_NAME_SEVR         FieldName = "SEVR"
	FIELD_NAME_STAT         FieldName = "STAT"
	FIELD_NAME_SEVR_AS_ENUM FieldName = "SEVR as Enum"
	FIELD_NAME_STAT_AS_ENUM FieldName = "STAT as Enum"
)

type FormatOption

type FormatOption string

type FuncDefParamQueryModel

type FuncDefParamQueryModel struct {
	Name    string    `json:"name"`
	Options *[]string `json:"options"`
	Type    string    `json:"type"`
}

type FuncDefQueryModel

type FuncDefQueryModel struct {
	// Matched to FuncDef in types.ts
	DefaultParams *json.RawMessage         `json:"defaultParams,omitempty"`
	ShortName     *json.RawMessage         `json:"shortName,omitempty"`
	Version       *json.RawMessage         `json:"version,omitempty"`
	Category      FunctionCategory         `json:"category"`
	Description   *string                  `json:"description,omitempty"`
	Fake          *bool                    `json:"fake,omitempty"`
	Name          string                   `json:"name"`
	Params        []FuncDefParamQueryModel `json:"params"`
}

type FunctionCategory

type FunctionCategory string

type FunctionDescriptorQueryModel

type FunctionDescriptorQueryModel struct {
	// Matched to FunctionDescriptor in types.ts
	Params []string          `json:"params"`
	Def    FuncDefQueryModel `json:"def"`
}

func (FunctionDescriptorQueryModel) ExtractParamBoolean

func (fdqm FunctionDescriptorQueryModel) ExtractParamBoolean(target string) (bool, error)

func (FunctionDescriptorQueryModel) ExtractParamFloat64

func (fdqm FunctionDescriptorQueryModel) ExtractParamFloat64(target string) (float64, error)

func (FunctionDescriptorQueryModel) ExtractParamInt

func (fdqm FunctionDescriptorQueryModel) ExtractParamInt(target string) (int, error)

func (FunctionDescriptorQueryModel) ExtractParamString

func (fdqm FunctionDescriptorQueryModel) ExtractParamString(target string) (string, error)

func (FunctionDescriptorQueryModel) GetParamTypeByName

func (fdqm FunctionDescriptorQueryModel) GetParamTypeByName(target string) (string, error)

func (FunctionDescriptorQueryModel) GetParametersByName

func (fdqm FunctionDescriptorQueryModel) GetParametersByName(target string) (string, error)

type FunctionOption

type FunctionOption string

type RankType

type RankType string

type ScalarResponseModel

type ScalarResponseModel []SingleScalarResponseModel

func (ScalarResponseModel) ToSingleDataValues

func (response ScalarResponseModel) ToSingleDataValues() (Values, error)

type Scalars

type Scalars struct {
	Times  []time.Time
	Values []*float64
}

func NewSclars

func NewSclars(length int) *Scalars

func NewSclarsWithValues

func NewSclarsWithValues(t []time.Time, v []*float64) *Scalars

func (*Scalars) Append

func (v *Scalars) Append(val *float64, t time.Time)

func (*Scalars) AppendConcrete

func (v *Scalars) AppendConcrete(val float64, t time.Time)

func (*Scalars) Delta

func (v *Scalars) Delta()

func (*Scalars) Extrapolation

func (v *Scalars) Extrapolation(t time.Time)

func (*Scalars) Fluctuation

func (v *Scalars) Fluctuation()

func (*Scalars) MovingAverage

func (v *Scalars) MovingAverage(windowSize int)

func (*Scalars) Offset

func (v *Scalars) Offset(delta float64)

func (*Scalars) Rank

func (v *Scalars) Rank(rankType RankType) (float64, error)

func (*Scalars) Scale

func (v *Scalars) Scale(factor float64)

func (*Scalars) SetValConcrete

func (v *Scalars) SetValConcrete(idx int, val float64)

func (*Scalars) ToFields

func (v *Scalars) ToFields(pvname string, name string, format FormatOption) []*data.Field

type SingleArrayResponseModel

type SingleArrayResponseModel struct {
	Millis *json.Number `json:"millis,omitempty"`
	Nanos  *json.Number `json:"nanos,omitempty"`
	Secs   *json.Number `json:"secs,omitempty"`
	Val    []float64    `json:"val"`
}

type SingleData

type SingleData struct {
	Name   string
	PVname string
	Values Values
}

func (*SingleData) ApplyAlias

func (sd *SingleData) ApplyAlias(alias string, rep *regexp.Regexp)

func (*SingleData) Extrapolation

func (sd *SingleData) Extrapolation(t time.Time) *SingleData

func (*SingleData) ToFrame

func (sd *SingleData) ToFrame(format FormatOption) *data.Frame

type SingleScalarResponseModel

type SingleScalarResponseModel struct {
	Millis *json.Number `json:"millis,omitempty"`
	Nanos  *json.Number `json:"nanos,omitempty"`
	Secs   *json.Number `json:"secs,omitempty"`
	Val    json.Number  `json:"val"`
}

type SingleStringResponseModel

type SingleStringResponseModel struct {
	Millis *json.Number `json:"millis,omitempty"`
	Nanos  *json.Number `json:"nanos,omitempty"`
	Secs   *json.Number `json:"secs,omitempty"`
	Val    string       `json:"val"`
}

type StringResponseModel

type StringResponseModel []SingleStringResponseModel

func (StringResponseModel) ToSingleDataValues

func (response StringResponseModel) ToSingleDataValues() (Values, error)

type Strings

type Strings struct {
	Times  []time.Time
	Values []string
}

func NewStrings

func NewStrings(length int) *Strings

func (*Strings) Append

func (v *Strings) Append(val string, t time.Time)

func (*Strings) Extrapolation

func (v *Strings) Extrapolation(t time.Time)

func (*Strings) ToFields

func (v *Strings) ToFields(pvname string, name string, format FormatOption) []*data.Field

type Values

type Values interface {
	Extrapolation(t time.Time)
	ToFields(pvname string, name string, format FormatOption) []*data.Field
}

Jump to

Keyboard shortcuts

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