alarms

package
v0.0.0-...-905d515 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlarmBatteryLevel      string = "batteryLevel"
	AlarmDeviceNotObserved string = "deviceNotObserved"

	AlarmTypeMIN     string = "MIN"
	AlarmTypeMAX     string = "MAX"
	AlarmTypeBETWEEN string = "BETWEEN"
	AlarmTypeTRUE    string = "TRUE"
	AlarmTypeFALSE   string = "FALSE"
	AlarmTypeNOOP    string = "-"
)
View Source
const (
	FuncTypeCounter      string = "counter"
	FuncTypeLevel        string = "level"
	FuncTypeWaterQuality string = "waterquality"
	FuncTypeTimer        string = "timer"
	FuncTypePresence     string = "presence"
)

Variables

This section is empty.

Functions

func BatteryLevelChangedHandler

func BatteryLevelChangedHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler

func DeviceNotObservedHandler

func DeviceNotObservedHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler

func FunctionUpdatedHandler

func FunctionUpdatedHandler(messenger messaging.MsgContext, as AlarmService) messaging.TopicMessageHandler

Types

type AlarmConfig

type AlarmConfig struct {
	ID          string
	Name        string
	Type        string
	Min         float64
	Max         float64
	Severity    int
	Description string
}

type AlarmService

type AlarmService interface {
	Start()
	Stop()

	GetAlarms(ctx context.Context, tenants ...string) ([]db.Alarm, error)
	GetAlarmsByID(ctx context.Context, id int) (db.Alarm, error)
	GetAlarmsByRefID(ctx context.Context, refID string, tenants ...string) ([]db.Alarm, error)
	AddAlarm(ctx context.Context, alarm db.Alarm) error
	CloseAlarm(ctx context.Context, alarmID int) error

	GetConfiguration() Configuration
}

type AlarmServiceMock

type AlarmServiceMock struct {
	// AddAlarmFunc mocks the AddAlarm method.
	AddAlarmFunc func(ctx context.Context, alarm db.Alarm) error

	// CloseAlarmFunc mocks the CloseAlarm method.
	CloseAlarmFunc func(ctx context.Context, alarmID int) error

	// GetAlarmsFunc mocks the GetAlarms method.
	GetAlarmsFunc func(ctx context.Context, tenants ...string) ([]db.Alarm, error)

	// GetAlarmsByIDFunc mocks the GetAlarmsByID method.
	GetAlarmsByIDFunc func(ctx context.Context, id int) (db.Alarm, error)

	// GetAlarmsByRefIDFunc mocks the GetAlarmsByRefID method.
	GetAlarmsByRefIDFunc func(ctx context.Context, refID string, tenants ...string) ([]db.Alarm, error)

	// GetConfigurationFunc mocks the GetConfiguration method.
	GetConfigurationFunc func() Configuration

	// StartFunc mocks the Start method.
	StartFunc func()

	// StopFunc mocks the Stop method.
	StopFunc func()
	// contains filtered or unexported fields
}

AlarmServiceMock is a mock implementation of AlarmService.

func TestSomethingThatUsesAlarmService(t *testing.T) {

	// make and configure a mocked AlarmService
	mockedAlarmService := &AlarmServiceMock{
		AddAlarmFunc: func(ctx context.Context, alarm db.Alarm) error {
			panic("mock out the AddAlarm method")
		},
		CloseAlarmFunc: func(ctx context.Context, alarmID int) error {
			panic("mock out the CloseAlarm method")
		},
		GetAlarmsFunc: func(ctx context.Context, tenants ...string) ([]db.Alarm, error) {
			panic("mock out the GetAlarms method")
		},
		GetAlarmsByIDFunc: func(ctx context.Context, id int) (db.Alarm, error) {
			panic("mock out the GetAlarmsByID method")
		},
		GetAlarmsByRefIDFunc: func(ctx context.Context, refID string, tenants ...string) ([]db.Alarm, error) {
			panic("mock out the GetAlarmsByRefID method")
		},
		GetConfigurationFunc: func() Configuration {
			panic("mock out the GetConfiguration method")
		},
		StartFunc: func()  {
			panic("mock out the Start method")
		},
		StopFunc: func()  {
			panic("mock out the Stop method")
		},
	}

	// use mockedAlarmService in code that requires AlarmService
	// and then make assertions.

}

func (*AlarmServiceMock) AddAlarm

func (mock *AlarmServiceMock) AddAlarm(ctx context.Context, alarm db.Alarm) error

AddAlarm calls AddAlarmFunc.

func (*AlarmServiceMock) AddAlarmCalls

func (mock *AlarmServiceMock) AddAlarmCalls() []struct {
	Ctx   context.Context
	Alarm db.Alarm
}

AddAlarmCalls gets all the calls that were made to AddAlarm. Check the length with:

len(mockedAlarmService.AddAlarmCalls())

func (*AlarmServiceMock) CloseAlarm

func (mock *AlarmServiceMock) CloseAlarm(ctx context.Context, alarmID int) error

CloseAlarm calls CloseAlarmFunc.

func (*AlarmServiceMock) CloseAlarmCalls

func (mock *AlarmServiceMock) CloseAlarmCalls() []struct {
	Ctx     context.Context
	AlarmID int
}

CloseAlarmCalls gets all the calls that were made to CloseAlarm. Check the length with:

len(mockedAlarmService.CloseAlarmCalls())

func (*AlarmServiceMock) GetAlarms

func (mock *AlarmServiceMock) GetAlarms(ctx context.Context, tenants ...string) ([]db.Alarm, error)

GetAlarms calls GetAlarmsFunc.

func (*AlarmServiceMock) GetAlarmsByID

func (mock *AlarmServiceMock) GetAlarmsByID(ctx context.Context, id int) (db.Alarm, error)

GetAlarmsByID calls GetAlarmsByIDFunc.

func (*AlarmServiceMock) GetAlarmsByIDCalls

func (mock *AlarmServiceMock) GetAlarmsByIDCalls() []struct {
	Ctx context.Context
	ID  int
}

GetAlarmsByIDCalls gets all the calls that were made to GetAlarmsByID. Check the length with:

len(mockedAlarmService.GetAlarmsByIDCalls())

func (*AlarmServiceMock) GetAlarmsByRefID

func (mock *AlarmServiceMock) GetAlarmsByRefID(ctx context.Context, refID string, tenants ...string) ([]db.Alarm, error)

GetAlarmsByRefID calls GetAlarmsByRefIDFunc.

func (*AlarmServiceMock) GetAlarmsByRefIDCalls

func (mock *AlarmServiceMock) GetAlarmsByRefIDCalls() []struct {
	Ctx     context.Context
	RefID   string
	Tenants []string
}

GetAlarmsByRefIDCalls gets all the calls that were made to GetAlarmsByRefID. Check the length with:

len(mockedAlarmService.GetAlarmsByRefIDCalls())

func (*AlarmServiceMock) GetAlarmsCalls

func (mock *AlarmServiceMock) GetAlarmsCalls() []struct {
	Ctx     context.Context
	Tenants []string
}

GetAlarmsCalls gets all the calls that were made to GetAlarms. Check the length with:

len(mockedAlarmService.GetAlarmsCalls())

func (*AlarmServiceMock) GetConfiguration

func (mock *AlarmServiceMock) GetConfiguration() Configuration

GetConfiguration calls GetConfigurationFunc.

func (*AlarmServiceMock) GetConfigurationCalls

func (mock *AlarmServiceMock) GetConfigurationCalls() []struct {
}

GetConfigurationCalls gets all the calls that were made to GetConfiguration. Check the length with:

len(mockedAlarmService.GetConfigurationCalls())

func (*AlarmServiceMock) Start

func (mock *AlarmServiceMock) Start()

Start calls StartFunc.

func (*AlarmServiceMock) StartCalls

func (mock *AlarmServiceMock) StartCalls() []struct {
}

StartCalls gets all the calls that were made to Start. Check the length with:

len(mockedAlarmService.StartCalls())

func (*AlarmServiceMock) Stop

func (mock *AlarmServiceMock) Stop()

Stop calls StopFunc.

func (*AlarmServiceMock) StopCalls

func (mock *AlarmServiceMock) StopCalls() []struct {
}

StopCalls gets all the calls that were made to Stop. Check the length with:

len(mockedAlarmService.StopCalls())

type Configuration

type Configuration struct {
	AlarmConfigurations []AlarmConfig
}

func LoadConfiguration

func LoadConfiguration(configFile string) *Configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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