Versions in this module Expand all Collapse all v0 v0.0.3 May 24, 2024 Changes in this version + const AdminPermission + const ReadPermission + const SuperPermission + const WritePermission + var ErrArgParse = errors.New("could not parse argument") + var ErrDeviceNotEnabled = errors.New("device not enabled") + var ErrDeviceNotFound = errors.New("device not found") + var ErrEvaluableExpression = &errEvaluableExpression + var ErrEvaluate = &errEvaluate + var ErrIdenticalTimestamps = errors.New("too many identical timestamps") + var ErrInvalidDeviceKey = errors.New("invalid device key") + var ErrInvalidKeyName = errors.New("malformed MtsMedia key name") + var ErrInvalidMACAddress = errors.New("invalid MAC address") + var ErrInvalidMID = errors.New("invalid MID") + var ErrInvalidMtsPackets = errors.New("clip contains invalid MTS packets") + var ErrInvalidRanges = errors.New("cannot have both geohash and timestamp ranges") + var ErrInvalidTime = errors.New("invalid time") + var ErrMalformedDeviceKey = errors.New("malformed device key") + var ErrMediaNotFound = errors.New("media not found") + var ErrMissingDeviceKey = errors.New("missing device key") + var ErrNoMediaPID = errors.New("no media PID found") + var ErrNoMtsPackets = errors.New("clip contains no MTS packets") + var ErrSKeyParse = errors.New("cannot parse site key for actuator") + var ErrUnexpectedArgs = errors.New("unexpected number of args") + var ErrUnrecognisedFunc = errors.New("unrecognised function key") + var ErrWrongNumParts = errors.New("wrong number of values for actuator") + func ComputeVarSum(vars []Variable) int64 + func CreateSite(ctx context.Context, store datastore.Store, site *Site) error + func DeleteActuator(ctx context.Context, store datastore.Store, aid string) error + func DeleteActuatorV2(ctx context.Context, store datastore.Store, mac int64, pin string) error + func DeleteCredential(ctx context.Context, store datastore.Store, mid int64, name string) error + func DeleteCredentials(ctx context.Context, store datastore.Store, name string) error + func DeleteCron(ctx context.Context, store datastore.Store, skey int64, id string) error + func DeleteDevice(ctx context.Context, store datastore.Store, mac int64) error + func DeleteMtsMedia(ctx context.Context, store datastore.Store, mid int64) error + func DeleteScalars(ctx context.Context, store datastore.Store, id int64) error + func DeleteSensor(ctx context.Context, store datastore.Store, sKey int64, sid string) error + func DeleteSensorV2(ctx context.Context, store datastore.Store, mac int64, pin string) error + func DeleteSite(ctx context.Context, store datastore.Store, skey int64) error + func DeleteText(ctx context.Context, store datastore.Store, mid int64) error + func DeleteUser(ctx context.Context, store datastore.Store, skey int64, email string) error + func DeleteVariable(ctx context.Context, store datastore.Store, skey int64, name string) error + func DeleteVariables(ctx context.Context, store datastore.Store, skey int64, scope string) error + func FromMID(mid int64) (string, string) + func FromSID(id int64) (string, string) + func GetMtsMediaKeys(ctx context.Context, store datastore.Store, mid int64, gh []string, ts []int64) ([]*datastore.Key, error) + func GetScalarKeys(ctx context.Context, store datastore.Store, id int64, ts []int64) ([]*datastore.Key, error) + func GetSiteName(ctx context.Context, store datastore.Store, skey int64) (string, error) + func GetTextKeys(ctx context.Context, store datastore.Store, mid int64, ts []int64) ([]*datastore.Key, error) + func GetVarSum(ctx context.Context, store datastore.Store, skey int64, scope string) (int64, error) + func HasPermission(ctx context.Context, store datastore.Store, mid int64, email string, ...) bool + func IsMacAddress(mac string) bool + func MacDecode(enc int64) string + func MacEncode(mac string) int64 + func PTSToSeconds(pts int64) float64 + func PutActuator(ctx context.Context, store datastore.Store, act *Actuator) error + func PutActuatorV2(ctx context.Context, store datastore.Store, act *ActuatorV2) error + func PutCredential(ctx context.Context, store datastore.Store, c *Credential) error + func PutCron(ctx context.Context, store datastore.Store, c *Cron) error + func PutDevice(ctx context.Context, store datastore.Store, dev *Device) error + func PutMedia(ctx context.Context, store datastore.Store, m *Media) error + func PutScalar(ctx context.Context, store datastore.Store, s *Scalar) error + func PutSensor(ctx context.Context, store datastore.Store, s *Sensor) error + func PutSensorV2(ctx context.Context, store datastore.Store, s *SensorV2) error + func PutSite(ctx context.Context, store datastore.Store, site *Site) error + func PutUser(ctx context.Context, store datastore.Store, user *User) error + func PutVariable(ctx context.Context, store datastore.Store, skey int64, name, value string) error + func RegisterEntities() + func SensorFormats() []string + func SensorFuncs() []string + func ToMID(mac, pin string) int64 + func ToSID(mac, pin string) int64 + func UpdateMtsMedia(ctx context.Context, store datastore.Store, m MtsMedia, pid uint16) error + func WriteMtsMedia(ctx context.Context, store datastore.Store, m *MtsMedia) error + func WriteText(ctx context.Context, store datastore.Store, t *Text) error + type Actuator struct + AID string + Pin string + SKey int64 + Var string + func GetActuatorByPin(ctx context.Context, store datastore.Store, skey int64, did string, pin string) ([]Actuator, error) + func GetActuatorsBySite(ctx context.Context, store datastore.Store, sKey int64, devID string) ([]Actuator, error) + func (a *Actuator) Copy(datastore.Entity) (datastore.Entity, error) + func (a *Actuator) Decode(b []byte) error + func (a *Actuator) Encode() []byte + func (a *Actuator) GetCache() datastore.Cache + type ActuatorV2 struct + Mac int64 + Name string + Pin string + Var string + func GetActuatorV2(ctx context.Context, store datastore.Store, mac int64, pin string) (*ActuatorV2, error) + func GetActuatorsV2(ctx context.Context, store datastore.Store, mac int64) ([]ActuatorV2, error) + func (a *ActuatorV2) Copy(dst datastore.Entity) (datastore.Entity, error) + func (a *ActuatorV2) Decode(b []byte) error + func (a *ActuatorV2) Encode() []byte + func (s *ActuatorV2) GetCache() datastore.Cache + type BinaryData struct + Data []byte + Date time.Time + Fmt string + Mac int64 + Pin string + Timestamp int64 + func GetBinaryData(ctx context.Context, store datastore.Store, mid int64, ts []int64) ([]BinaryData, error) + type Credential struct + Created time.Time + MID int64 + Name string + Perm int64 + func GetCredential(ctx context.Context, store datastore.Store, mid int64, name string) (*Credential, error) + func GetCredentialsByMID(ctx context.Context, store datastore.Store, mid int64) ([]Credential, error) + func GetCredentialsByName(ctx context.Context, store datastore.Store, name string) ([]Credential, error) + func (c *Credential) Copy(datastore.Entity) (datastore.Entity, error) + func (c *Credential) Decode(b []byte) error + func (c *Credential) Encode() []byte + func (c *Credential) GetCache() datastore.Cache + func (c *Credential) IsAdmin() bool + func (c *Credential) IsReadable() bool + func (c *Credential) IsSuper() bool + func (c *Credential) IsWritable() bool + type Cron struct + Action string + Data string + Enabled bool + ID string + Minutes int64 + Repeat bool + Skey int64 + TOD string + Time time.Time + Var string + func GetCron(ctx context.Context, store datastore.Store, skey int64, id string) (*Cron, error) + func GetCronsBySite(ctx context.Context, store datastore.Store, skey int64) ([]Cron, error) + func (c *Cron) Copy(datastore.Entity) (datastore.Entity, error) + func (c *Cron) Decode(b []byte) error + func (c *Cron) Encode() []byte + func (c *Cron) FormatTime(tz float64) string + func (c *Cron) GetCache() datastore.Cache + func (c *Cron) ParseTime(s string, tz float64) error + type Device struct + ActPeriod int64 + Dkey int64 + Enabled bool + Inputs string + Latitude float64 + Longitude float64 + Mac int64 + MonitorPeriod int64 + Name string + Outputs string + Protocol string + Skey int64 + Status int64 + Type string + Updated time.Time + Version string + Wifi string + func CheckDevice(ctx context.Context, store datastore.Store, mac string, dk string) (*Device, error) + func GetDevice(ctx context.Context, store datastore.Store, mac int64) (*Device, error) + func GetDevicesBySite(ctx context.Context, store datastore.Store, skey int64) ([]Device, error) + func (dev *Device) Copy(dst datastore.Entity) (datastore.Entity, error) + func (dev *Device) Decode(b []byte) error + func (dev *Device) Encode() []byte + func (dev *Device) GetCache() datastore.Cache + func (dev *Device) Hex() string + func (dev *Device) InputList() []string + func (dev *Device) InputListWithID() []string + func (dev *Device) MAC() string + func (dev *Device) Other(key string) string + func (dev *Device) OutputList() []string + func (dev *Device) OutputListWithID() []string + func (dev *Device) SetOther(key, value string) + func (dev *Device) StatusText() string + type MTSFragment struct + Continues bool + Duration int64 + DurationSec int64 + Medias []*MtsMedia + TSRange [2]int64 + Type string + func FragmentMTSMedia(in []MtsMedia, period, tolerance int64) (out []*MTSFragment) + type Media struct + Description string + MID int64 + Updated time.Time + func GetMedia(ctx context.Context, store datastore.Store, mid int64) (*Media, error) + func (m *Media) Copy(datastore.Entity) (datastore.Entity, error) + func (m *Media) Decode(b []byte) error + func (m *Media) Encode() []byte + func (m *Media) GetCache() datastore.Cache + type MtsMedia struct + Clip []byte + Continues bool + Date time.Time + Duration int64 + FramePTS int64 + Geohash string + Key *datastore.Key + MID int64 + Metadata string + PTS int64 + Timestamp int64 + Type string + func GetMtsMedia(ctx context.Context, store datastore.Store, mid int64, gh []string, ts []int64) ([]MtsMedia, error) + func GetMtsMediaByKey(ctx context.Context, store datastore.Store, ky uint64) (*MtsMedia, error) + func GetMtsMediaByKeys(ctx context.Context, store datastore.Store, ky []uint64) ([]MtsMedia, error) + func (m *MtsMedia) Copy(datastore.Entity) (datastore.Entity, error) + func (m *MtsMedia) Decode(b []byte) error + func (m *MtsMedia) Encode() []byte + func (m *MtsMedia) GetCache() datastore.Cache + func (m *MtsMedia) KeyID() uint64 + type Scalar struct + ID int64 + Key *datastore.Key + Timestamp int64 + Value float64 + func GetScalar(ctx context.Context, store datastore.Store, id int64, ts int64) (*Scalar, error) + func GetScalars(ctx context.Context, store datastore.Store, id int64, ts []int64) ([]Scalar, error) + func (s *Scalar) Copy(datastore.Entity) (datastore.Entity, error) + func (s *Scalar) Decode(b []byte) error + func (s *Scalar) Encode() []byte + func (s *Scalar) FormatValue(prec int) string + func (s *Scalar) GetCache() datastore.Cache + func (s *Scalar) KeyID() uint64 + type Sensor struct + Args string + Format string + Func string + Offset float64 + Pin string + Quantity string + SID string + SKey int64 + Scale float64 + Units string + func GetSensor(ctx context.Context, store datastore.Store, sKey int64, sid string) (*Sensor, error) + func GetSensorByPin(ctx context.Context, store datastore.Store, sKey int64, did, pin string) (*Sensor, error) + func GetSensorsBySite(ctx context.Context, store datastore.Store, skey int64, devID string) ([]Sensor, error) + func (s *Sensor) Copy(datastore.Entity) (datastore.Entity, error) + func (s *Sensor) Decode(b []byte) error + func (s *Sensor) Encode() []byte + func (s *Sensor) GetCache() datastore.Cache + func (s *Sensor) Transform(v float64) (float64, error) + type SensorV2 struct + Args string + Format string + Func string + Mac int64 + Name string + Offset float64 + Pin string + Quantity string + Scale float64 + Units string + func GetSensorV2(ctx context.Context, store datastore.Store, mac int64, pin string) (*SensorV2, error) + func GetSensorsV2(ctx context.Context, store datastore.Store, mac int64) ([]SensorV2, error) + func (s *SensorV2) Copy(dst datastore.Entity) (datastore.Entity, error) + func (s *SensorV2) Decode(b []byte) error + func (s *SensorV2) Encode() []byte + func (s *SensorV2) GetCache() datastore.Cache + func (s *SensorV2) Transform(v float64) (float64, error) + type Site struct + Confirmed bool + Created time.Time + Enabled bool + Latitude float64 + Longitude float64 + Name string + NotifyPeriod int64 + OwnerEmail string + Premium bool + Public bool + Skey int64 + Timezone float64 + func GetAllSites(ctx context.Context, store datastore.Store) ([]Site, error) + func GetPublicSites(ctx context.Context, store datastore.Store) ([]Site, error) + func GetSite(ctx context.Context, store datastore.Store, skey int64) (*Site, error) + func (site *Site) Copy(dst datastore.Entity) (datastore.Entity, error) + func (site *Site) Decode(b []byte) error + func (site *Site) Encode() []byte + func (site *Site) GetCache() datastore.Cache + type Text struct + Data string + Date time.Time + Key *datastore.Key + MID int64 + Timestamp int64 + Type string + func GetText(ctx context.Context, store datastore.Store, mid int64, ts []int64) ([]Text, error) + func (t *Text) Copy(datastore.Entity) (datastore.Entity, error) + func (t *Text) Decode(b []byte) error + func (t *Text) Encode() []byte + func (t *Text) GetCache() datastore.Cache + func (t *Text) KeyID() uint64 + type User struct + Created time.Time + Email string + Perm int64 + Skey int64 + UserID string + func GetUser(ctx context.Context, store datastore.Store, skey int64, email string) (*User, error) + func GetUsers(ctx context.Context, store datastore.Store, email string) ([]User, error) + func GetUsersBySite(ctx context.Context, store datastore.Store, skey int64) ([]User, error) + func (user *User) Copy(dst datastore.Entity) (datastore.Entity, error) + func (user *User) Decode(b []byte) error + func (user *User) Encode() []byte + func (user *User) GetCache() datastore.Cache + func (user *User) PermissionText() string + type Variable struct + Name string + Scope string + Skey int64 + Updated time.Time + Value string + func GetVariable(ctx context.Context, store datastore.Store, skey int64, name string) (*Variable, error) + func GetVariablesBySite(ctx context.Context, store datastore.Store, skey int64, scope string) ([]Variable, error) + func (v *Variable) Basename() string + func (v *Variable) Copy(datastore.Entity) (datastore.Entity, error) + func (v *Variable) Decode(b []byte) error + func (v *Variable) Encode() []byte + func (v *Variable) GetCache() datastore.Cache + func (v *Variable) IsLink() bool + func (v *Variable) IsSystemVariable() bool