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 ¶
- func GetSliceMean(captors []Captor) (float64, error)
- type Broker
- type Capteur
- type Captor
- func (c *Captor) AddValuesFromJson(jsonValues []byte) (*Captor, error)
- func (c *Captor) CaptorToJson() string
- func (c *Captor) CaptorToSliceByte() []byte
- func (c *Captor) CaptorToString() string
- func (c *Captor) GetCaptorValues() []string
- func (c *Captor) GetDayDate(idVal int) string
- func (c *Captor) GetDayDateAsInt(idVal int) int
- func (c *Captor) GetIdAirportToString() string
- func (c *Captor) GetIdCaptorToString() string
- func (c *Captor) GetMean() (float64, error)
- func (c *Captor) GetMeasureToString() string
- func (c *Captor) GetValuesToString() string
- func (c *Captor) IsEmpty() bool
- type CaptorValue
- func (c *CaptorValue) GetCaptorValueToJson() []byte
- func (c *CaptorValue) GetCaptorValueToString() string
- func (c *CaptorValue) GetDayDate() string
- func (c *CaptorValue) GetDayDateAsInt() int
- func (c *CaptorValue) GetTimestampToString() string
- func (c *CaptorValue) GetValueToString() string
- func (c *CaptorValue) IsEmpty() bool
- type Configuration
- type Mean
- type MqttClient
- type MqttMessage
- type RedisClient
- func (r *RedisClient) AddCaptorEntryToDB(entry *RedisEntry) error
- func (r *RedisClient) Find(query string) ([]Captor, error)
- func (r *RedisClient) GetACaptorValuesEntriesInInterval(key string, start time.Time, end time.Time) ([]string, error)
- func (r *RedisClient) GetACaptorValuesKeyInInterval(key string, start time.Time, end time.Time) ([]string, error)
- func (r *RedisClient) GetAllCaptorValuesOfADay(key string) (Captor, error)
- func (r *RedisClient) GetAllCaptorValuesOfATypeInInterval(measure string, startDate time.Time, endDate time.Time) ([]Captor, error)
- func (r *RedisClient) GetAllCaptorValuesOfMeasureForADay(measure string, dayDate time.Time) ([]Captor, error)
- func (r *RedisClient) GetAllCaptorValuesOfPresForADay(dayDate time.Time) ([]Captor, error)
- func (r *RedisClient) GetAllCaptorValuesOfTempForADay(dayDate time.Time) ([]Captor, error)
- func (r *RedisClient) GetAllCaptorValuesOfWindForADay(dayDate time.Time) ([]Captor, error)
- func (r *RedisClient) GetCaptorValuesEntriesInInterval(key string, start time.Time, end time.Time) ([]string, error)
- func (r *RedisClient) GetCaptorValuesKeysInInterval(keys []string, start time.Time, end time.Time) ([]string, error)
- type RedisDB
- type RedisEntry
- func (r *RedisEntry) CaptorKey() string
- func (r *RedisEntry) CaptorValuesKey(idVal int) string
- func (r *RedisEntry) GetCaptorLeftKey() string
- func (r *RedisEntry) GetCaptorValueAsJson(idVal int) string
- func (r *RedisEntry) GetCaptorValues() []string
- func (r *RedisEntry) GetDayDate(idVal int) string
- func (r *RedisEntry) GetDayDateAsInt(idVal int) int
- func (r *RedisEntry) GetTimestampAsInt(idVal int) int
- func (r *RedisEntry) PrintAll()
- func (r *RedisEntry) RedisEntryToJson() string
- func (r *RedisEntry) RedisEntryToSliceByte() []byte
- func (r *RedisEntry) RedisEntryToString() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSliceMean ¶
Types ¶
type Captor ¶
type Captor struct { IdCaptor int IdAirport string Measure string Values []*CaptorValue }
func CreateACaptor ¶
func MergeEqualsCaptors ¶
func (*Captor) AddValuesFromJson ¶
func (*Captor) CaptorToJson ¶
func (*Captor) CaptorToSliceByte ¶
func (*Captor) CaptorToString ¶
func (*Captor) GetCaptorValues ¶
func (*Captor) GetDayDate ¶
func (*Captor) GetDayDateAsInt ¶
func (*Captor) GetIdAirportToString ¶
func (*Captor) GetIdCaptorToString ¶
func (*Captor) GetMeasureToString ¶
func (*Captor) GetValuesToString ¶
type CaptorValue ¶
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 ¶
func GetConfig ¶
func GetConfig() *Configuration
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) GetACaptorValuesEntriesInInterval ¶
func (*RedisClient) GetACaptorValuesKeyInInterval ¶
func (*RedisClient) GetAllCaptorValuesOfADay ¶
func (r *RedisClient) GetAllCaptorValuesOfADay(key string) (Captor, error)
func (*RedisClient) GetAllCaptorValuesOfATypeInInterval ¶
func (*RedisClient) GetAllCaptorValuesOfMeasureForADay ¶
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 (*RedisClient) GetCaptorValuesKeysInInterval ¶
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
Click to show internal directories.
Click to hide internal directories.