rules

package
v0.0.0-...-9942e84 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionExpression

type ActionExpression struct {
	DeviceId  string
	CommandId string
	Payload   string
}

type BooleanOperator

type BooleanOperator string

type ConditionExpression

type ConditionExpression struct {
	SensorId string
	DeviceId string
	Variable string
	Operator Operator
	Value    string
}

type CreateRuleRequest

type CreateRuleRequest struct {
	Name string `json:"name"`
	When string `json:"when"`
	Then string `json:"then"`
}

type Node

type Node struct {
	Left            *Node
	Right           *Node
	BooleanOperator BooleanOperator
	Expression      *ConditionExpression
}

type Operator

type Operator string

type Rule

type Rule struct {
	Id   int64          `json:"id"`
	Name string         `json:"name"`
	When WhenExpression `json:"when"`
	Then ThenExpression `json:"then"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
	// contains filtered or unexported fields
}

func (*Rule) ReadAction

func (rule *Rule) ReadAction() (*ActionExpression, error)

func (*Rule) ReadConditionAst

func (rule *Rule) ReadConditionAst() (*Node, error)

type RulesController

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

func NewController

func NewController(database RulesDatabase) *RulesController

func (*RulesController) ListRules

func (controller *RulesController) ListRules(context *gin.Context)

func (*RulesController) PostRule

func (controller *RulesController) PostRule(context *gin.Context)

type RulesDatabase

type RulesDatabase interface {
	AddRule(rule *Rule) error
	ListRules() ([]Rule, error)
	GetSensor(deviceId, sensorId string) (*sensor.Sensor, error)
	GetCurrentSensorValue(deviceId, sensorId string) (*value.SensorValue, error)
	GetPreviousSensorValue(deviceId, sensorId string) (*value.SensorValue, error)
	GetCommand(deviceId, commandId string) (*command.Command, error)
	GetDevice(deviceId string) (*device.Device, error)
}

type ThenExpression

type ThenExpression string

type WhenExpression

type WhenExpression string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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