entities

package
v0.0.0-...-7d1d753 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

*

  • Captor model *
  • @description :: A model definition of a CAPTOR.

*

  • CaptorMeasure model *
  • @description :: A model definition of a captor measure.

*

  • Configuration model *
  • @description :: A model definition of a config.

*

  • MQTTMessage model *
  • @description :: A model definition of a MQTT message.

*

  • MQTT TOOLS *
  • @description :: Utils function for MQTT client

*

  • RedisEntry model *
  • @description :: A model definition of a REDIS Entry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSliceMean

func GetSliceMean(captors []Captor) (float64, error)

Types

type Broker

type Broker struct {
	Url  string
	Port string
}

type Capteur

type Capteur struct {
	Id   int
	IATA string
	Type string
	QoS  int
}

func (*Capteur) GetValue

func (c *Capteur) GetValue() int

type Captor

type Captor struct {
	IdCaptor  int
	IdAirport string
	Measure   string
	Values    []*CaptorValue
}

func CreateACaptor

func CreateACaptor(jsonEntry []byte) *Captor

func MergeEqualsCaptors

func MergeEqualsCaptors(captors []Captor) []Captor

func (*Captor) AddValuesFromJson

func (c *Captor) AddValuesFromJson(jsonValues []byte) (*Captor, error)

func (*Captor) CaptorToJson

func (c *Captor) CaptorToJson() string

func (*Captor) CaptorToSliceByte

func (c *Captor) CaptorToSliceByte() []byte

func (*Captor) CaptorToString

func (c *Captor) CaptorToString() string

func (*Captor) GetCaptorValues

func (c *Captor) GetCaptorValues() []string

func (*Captor) GetDayDate

func (c *Captor) GetDayDate(idVal int) string

func (*Captor) GetDayDateAsInt

func (c *Captor) GetDayDateAsInt(idVal int) int

func (*Captor) GetIdAirportToString

func (c *Captor) GetIdAirportToString() string

func (*Captor) GetIdCaptorToString

func (c *Captor) GetIdCaptorToString() string

func (*Captor) GetMean

func (c *Captor) GetMean() (float64, error)

func (*Captor) GetMeasureToString

func (c *Captor) GetMeasureToString() string

func (*Captor) GetValuesToString

func (c *Captor) GetValuesToString() string

func (*Captor) IsEmpty

func (c *Captor) IsEmpty() bool

type CaptorValue

type CaptorValue struct {
	Value     float64
	Timestamp time.Time
}

func CreateACaptorValue

func CreateACaptorValue(jsonEntry []byte) (*CaptorValue, error)

func (*CaptorValue) GetCaptorValueToJson

func (c *CaptorValue) GetCaptorValueToJson() []byte

func (*CaptorValue) GetCaptorValueToString

func (c *CaptorValue) GetCaptorValueToString() string
func (c *CaptorValue) GetCaptorValueToString () string {
	return  `{` +
		`"value":` 		+ c.GetValueToString() 		+ `,` 	+
		`"timestamp":"` + c.GetTimestampToString() 	+ `"` 	+
		`}`
}

func (*CaptorValue) GetDayDate

func (c *CaptorValue) GetDayDate() string

func (*CaptorValue) GetDayDateAsInt

func (c *CaptorValue) GetDayDateAsInt() int

func (*CaptorValue) GetTimestampToString

func (c *CaptorValue) GetTimestampToString() string

func (*CaptorValue) GetValueToString

func (c *CaptorValue) GetValueToString() string

func (*CaptorValue) IsEmpty

func (c *CaptorValue) IsEmpty() bool

type Configuration

type Configuration struct {
	Broker   Broker
	Capteurs []Capteur
	Redis    RedisDB
}

func GetConfig

func GetConfig() *Configuration

type Mean

type Mean struct {
	TemperatureMean float64
	PressureMean    float64
	WindMean        float64
}

func CreateMean

func CreateMean(meanT float64, meanP float64, meanW float64) *Mean

type MqttClient

type MqttClient struct {
	Configuration  *Configuration
	MqttClientOpts mqtt.ClientOptions
	MqttClient     mqtt.Client
	Token          mqtt.Token
}

func CreateAMqttClientFromConfig

func CreateAMqttClientFromConfig(config *Configuration) *MqttClient

func (*MqttClient) ConnectClient

func (m *MqttClient) ConnectClient() *MqttClient

func (*MqttClient) PublishAMessage

func (m *MqttClient) PublishAMessage(topic string, message string) *MqttClient

func (*MqttClient) SetOptions

func (m *MqttClient) SetOptions(broker *Broker) *mqtt.ClientOptions

func (*MqttClient) SubscribeAToATopic

func (m *MqttClient) SubscribeAToATopic(topic string) *MqttClient

type MqttMessage

type MqttMessage struct {
	Captor *Captor
}

## Structure des messages MQTT ```json

{
 "idCaptor":  1,
 "idAirport": "BIA",
 "measure":   "Temperature",
 "values":     [
       {
        "value": 27.8,
        "time":  "2007-03-01T13:00:00Z"
       }
     ]
}

Une seule value dans values pour les messages MQTT ```

func CreateAMqttMessage

func CreateAMqttMessage(captor *Captor) *MqttMessage

func CreateAMqttMessageFromByte

func CreateAMqttMessageFromByte(json []byte) *MqttMessage

func CreateAMqttMessageFromPublish

func CreateAMqttMessageFromPublish(topic string, payload []byte) (*MqttMessage, error)

func (*MqttMessage) MqttMessageToJson

func (m *MqttMessage) MqttMessageToJson() []byte

func (*MqttMessage) MqttMessageToSliceString

func (m *MqttMessage) MqttMessageToSliceString() [][]string

func (*MqttMessage) MqttMessageToString

func (m *MqttMessage) MqttMessageToString() string

type RedisClient

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

func CreateARedisClient

func CreateARedisClient(network string, address string) *RedisClient

func CreateARedisClientFromConfig

func CreateARedisClientFromConfig(config *Configuration) *RedisClient

func (*RedisClient) AddCaptorEntryToDB

func (r *RedisClient) AddCaptorEntryToDB(entry *RedisEntry) error

func (*RedisClient) Find

func (r *RedisClient) Find(query string) ([]Captor, error)

func (*RedisClient) GetACaptorValuesEntriesInInterval

func (r *RedisClient) GetACaptorValuesEntriesInInterval(key string, start time.Time, end time.Time) ([]string, error)

func (*RedisClient) GetACaptorValuesKeyInInterval

func (r *RedisClient) GetACaptorValuesKeyInInterval(key string, start time.Time, end time.Time) ([]string, error)

func (*RedisClient) GetAllCaptorValuesOfADay

func (r *RedisClient) GetAllCaptorValuesOfADay(key string) (Captor, error)

func (*RedisClient) GetAllCaptorValuesOfATypeInInterval

func (r *RedisClient) GetAllCaptorValuesOfATypeInInterval(measure string, startDate time.Time, endDate time.Time) ([]Captor, error)

func (*RedisClient) GetAllCaptorValuesOfMeasureForADay

func (r *RedisClient) GetAllCaptorValuesOfMeasureForADay(measure string, dayDate time.Time) ([]Captor, error)

func (*RedisClient) GetAllCaptorValuesOfPresForADay

func (r *RedisClient) GetAllCaptorValuesOfPresForADay(dayDate time.Time) ([]Captor, error)

func (*RedisClient) GetAllCaptorValuesOfTempForADay

func (r *RedisClient) GetAllCaptorValuesOfTempForADay(dayDate time.Time) ([]Captor, error)

func (*RedisClient) GetAllCaptorValuesOfWindForADay

func (r *RedisClient) GetAllCaptorValuesOfWindForADay(dayDate time.Time) ([]Captor, error)

func (*RedisClient) GetCaptorValuesEntriesInInterval

func (r *RedisClient) GetCaptorValuesEntriesInInterval(key string, start time.Time, end time.Time) ([]string, error)

func (*RedisClient) GetCaptorValuesKeysInInterval

func (r *RedisClient) GetCaptorValuesKeysInInterval(keys []string, start time.Time, end time.Time) ([]string, error)

type RedisDB

type RedisDB struct {
	Network string
	Address string
}

type RedisEntry

type RedisEntry struct {
	Captor *Captor
}

func CreateARedisEntryFromByte

func CreateARedisEntryFromByte(jsonEntry []byte) *RedisEntry

func CreateARedisEntryFromCaptor

func CreateARedisEntryFromCaptor(captor *Captor) *RedisEntry

func CreateARedisEntryFromMqtt

func CreateARedisEntryFromMqtt(mqtt *MqttMessage) *RedisEntry

func (*RedisEntry) CaptorKey

func (r *RedisEntry) CaptorKey() string

func (*RedisEntry) CaptorValuesKey

func (r *RedisEntry) CaptorValuesKey(idVal int) string

func (*RedisEntry) GetCaptorLeftKey

func (r *RedisEntry) GetCaptorLeftKey() string

func (*RedisEntry) GetCaptorValueAsJson

func (r *RedisEntry) GetCaptorValueAsJson(idVal int) string

func (*RedisEntry) GetCaptorValues

func (r *RedisEntry) GetCaptorValues() []string

func (*RedisEntry) GetDayDate

func (r *RedisEntry) GetDayDate(idVal int) string

func (*RedisEntry) GetDayDateAsInt

func (r *RedisEntry) GetDayDateAsInt(idVal int) int

func (*RedisEntry) GetTimestampAsInt

func (r *RedisEntry) GetTimestampAsInt(idVal int) int

func (*RedisEntry) PrintAll

func (r *RedisEntry) PrintAll()

func (*RedisEntry) RedisEntryToJson

func (r *RedisEntry) RedisEntryToJson() string

func (*RedisEntry) RedisEntryToSliceByte

func (r *RedisEntry) RedisEntryToSliceByte() []byte

func (*RedisEntry) RedisEntryToString

func (r *RedisEntry) RedisEntryToString() string

Jump to

Keyboard shortcuts

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