tools

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

=========================================================================== MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =========================================================================== FyrMesh gopkg tools ===========================================================================

=========================================================================== MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =========================================================================== FyrMesh gopkg tools ===========================================================================

=========================================================================== MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =========================================================================== FyrMesh gopkg tools ===========================================================================

=========================================================================== MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =========================================================================== FyrMesh gopkg tools ===========================================================================

=========================================================================== MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =========================================================================== FyrMesh gopkg tools ===========================================================================

=========================================================================== MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =========================================================================== FyrMesh gopkg tools ===========================================================================

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckConfig

func CheckConfig() (bool, error)

A function that checks if the config file currently exists in the path specified in the 'FYRMESHCONFIG' env variable and returns the confirmation as a boolean.

func CurrentISOtime

func CurrentISOtime() string

A function that returns the current time as an ISO8601 string without the timezone.

func Deepdeserialize

func Deepdeserialize(str string) map[string]string

A function that deserializes a a string with a format akin to 'key1-value1=key2-value2..' into a map[string]string """

func FormatLog

func FormatLog(log Log) string

A function that simplifies and formats a Log into a string. Every logtype has a different format but the general structure of the string log is - '[source]time[type] message. metadata..'

func GenerateConfig

func GenerateConfig() error

A function that generates the default configuration values and creates a new Config variable with those and writes this struct into a config file located in the path specified by the 'FYRMESHCONFIG' env variable.

func GenerateSensorValue

func GenerateSensorValue(sensorvalue string, sensortype string, meshorchestrator *MeshOrchestrator, enableCorrection bool) float64

A function that generates a sensor value given the the value as an unparsed string and the sensor type. The mesh orchestrator is used to retrieve data from the simulator when it is on. The enableCorrection flag allows the sensor values to be overriden when the sensor is defunct or for debugging.

func LogHandler

func LogHandler(meshorchestrator *MeshOrchestrator)

A function that handles the output of the logs recieved over a given logqueue. Currently only prints to stdout.

func NewFirestoreClient

func NewFirestoreClient() (*firestore.Client, error)

A constructore function that generates and returns a Firestore.Client object that is configures with the Service Account Credentials from cloud config.

func PingHandler

func PingHandler(meshorchestrator *MeshOrchestrator)

A function that handles the output of the SensorPings recieved over the meshorchestrator's AccumulatorQueue. Assigns the recieved to ping to the appropriate MeshPing in the orchestrator's accumulation or creates a new Mesh and assigns it to that new MeshPing and adds the new MeshPing to orchestrator's accumulation.

func WriteConfig

func WriteConfig(config Config) error

A function that writes a Config struct into a config file that is located in the path specified by the 'FYRMESHCONFIG' env variable.

Types

type CloudInterface

type CloudInterface struct {
	// A Firestore Client object
	FirestoreClient firestore.Client

	// A Document Reference to the MeshDocument
	MeshDoc firestore.DocumentRef

	// A Collection Reference to collection of PingDocuments
	PingCollection firestore.CollectionRef
}

A struct that represents the Cloud Interface of the Mesh Orchestrator

func NewCloudInterface

func NewCloudInterface(meshid string) (*CloudInterface, error)

A constructor function that generates a CloudInterface object from a given mesh ID, which is taken from the DeviceID field of the Config struct.

type Config

type Config struct {
	DeviceID          string                   `json:"deviceID"`
	DeviceType        string                   `json:"deviceType"`
	Services          map[string]ServiceConfig `json:"services"`
	SchedulerPingRate int                      `json:"pingrate"`
}

A struct that defines the configuration of the FyrMesh service

func ReadConfig

func ReadConfig() (Config, error)

A function that reads the config file that is located in the path specified in the 'FYRMESHCONFIG' env variable and returns the values in a Config struct.

type ControlNode

type ControlNode struct {
	// The identifier of the node
	NodeID int64 `firestore:"nodeID"`

	// The serial baud rate of the node
	SerialBaud int `firestore:"serialbaud"`

	// The bool indicating if the node has a pinger button
	Pinger bool `firestore:"pinger"`

	// The pin on which the pinger button is attached
	Pingerpin int `firestore:"pinger_pin"`

	// The pin on which the connect LED is attached
	Connectpin int `firestore:"connect_pin"`

	// The SSID of the mesh network
	MeshSSID string `firestore:"MESHSSID"`

	// The password of the mesh network
	MeshPSWD string `firestore:"MESHPSWD"`

	// The port which the mesh network nodes communicate
	MeshPORT int `firestore:"MESHPORT"`
}

A struct that defines a control node with its hardware configuration values along with the configuration values that define the mesh.

func NewControlNode

func NewControlNode(log Log) (*ControlNode, error)

A constructor function that generates and returns a ControlNode. Only accepts a Log of type 'ctrldata'.

type Credentials

type Credentials struct {
	Username string `firestore:"username"`
	Password string `firestore:"password"`
}

A struct that represents the Credentials required to login to the mesh dashboard.

type FireEventSimulator

type FireEventSimulator struct {
	// A bool tht represents if the simulator is on.
	SimulationOn bool
	// A pool of SimulatorSeeds for each sensor type.
	SimulationSeeds map[string]*SimulatorSeed
}

A struct that represents a Fire Event Simulator

func NewFireEventSimulator

func NewFireEventSimulator() *FireEventSimulator

A constructor function that generates and returns a FireEventSimulator Creates the default seeds for each sensor type.

func (*FireEventSimulator) GetSimulatedValue

func (simulator *FireEventSimulator) GetSimulatedValue(sensortype string) float64

A method of FireEventSimulator that returns a simulated value for a given sensor type.

func (*FireEventSimulator) StartFireEvent

func (simulator *FireEventSimulator) StartFireEvent(logqueue chan Log)

A method of FireEventSimulator that starts a Fire Event. Requires a LogQueue to log the start and end of the Fire Event. Uses a wait group to monitor the completion of each individual seed's event curve.

type Log

type Log interface {
	GetLogsource() string
	GetLogtype() string
	GetLogtime() string
	GetLogmessage() string
	GetLogmetadata() map[string]string
}

An interface that defines a common interface that can be used by OrchLog and the ComplexLog proto

type MeshConfiguration

type MeshConfiguration struct {
	Meshssid string `firestore:"MESHSSID"`
	Meshpswd string `firestore:"MESHPSWD"`
	Meshport int    `firestore:"MESHPORT"`
}

A struct that represents the hardware coded configurations of the sensor mesh.

type MeshDocument

type MeshDocument struct {
	Credentials       Credentials           `firestore:"credentials"`
	MeshConfiguration MeshConfiguration     `firestore:"meshconfiguration"`
	ControllerID      string                `firestore:"controllerID"`
	ControlnodeID     string                `firestore:"controlnodeID"`
	ControlnodeConfig ControlNode           `firestore:"controlnode"`
	Nodelist          map[string]SensorNode `firestore:"nodes"`
	NodeIDlist        []int64               `firestore:"nodeids"`
}

A struct that represents the Firestore Document that contains the values that make up a MeshOrchestrator

func NewMeshDocument

func NewMeshDocument(meshorchestrator *MeshOrchestrator) *MeshDocument

A constructor function that generates and returns a MeshDocument object from a given MeshOrchestrator

func (*MeshDocument) Push

func (meshdoc *MeshDocument) Push(cloudinterface *CloudInterface) error

A method of MeshDocument that writes the Document to the Firestore database The MeshDoc of the cloud interface is set with the values from the MeshDocument.

type MeshOrchestrator

type MeshOrchestrator struct {
	// A bool indicating if the connection state to the control node has been set
	MeshConnected bool

	// A string identifier of the controller that is running the orchestrator
	ControllerID string

	// A ControlNode object that contains the configuration of the mesh control node
	Controlnode ControlNode

	// A map of int keys and SensorNode values that contains the list of sensor nodes on the mesh
	Nodelist map[int64]SensorNode

	// A slice of int that contains the list of all node IDs on the mesh
	NodeIDlist []int64

	// A map of string keys and MeshPing values. Maps the Pings to their respective pingIDs
	Accumulation map[string]MeshPing

	// A CloudInterface object for the mesh to connect to the database.
	Cloudinterface CloudInterface

	// A MeshDocument object that represents the mesh.
	MeshDoc MeshDocument

	// A Simulator object that exists in the background of the orchestrator.
	Simulator FireEventSimulator

	// A bool indicating if the scheduler is on or not.
	SchedulerOn bool

	// A channel of Logs that is used by all components to communicate between each other and to the console
	LogQueue chan Log

	// A channel of ObserverLogs thats is streamed to observers of the orchestrator
	ObserverQueue chan ObserverLog

	// A channel of string maps that are used to send commands to the control node
	CommandQueue chan map[string]string

	// A channel of SensorPings that are used to accumulate MeshPings
	AccumulatorQueue chan SensorPing
}

A struct that defines a mesh orchestrator. It contains all the core structures that are shared among its various sub-routines.

func NewMeshOrchestrator

func NewMeshOrchestrator() (*MeshOrchestrator, error)

A constructor function that generates and returns a MeshOrchestrator. All the channels are made with the 'make' function. The value of MeshConnected is false by default. The value of the Controlnode is set to null ControlNode until it is updated. The value of the ControllerID is retrieved from the config file's DeviceID. The value of the NodeList and NodeIDlist are set as empty slices.

func (*MeshOrchestrator) Close

func (meshorchestrator *MeshOrchestrator) Close()

A method of MeshOrchestrator that closes all the channels and clients within it.

func (*MeshOrchestrator) Flush

func (meshorchestrator *MeshOrchestrator) Flush()

A method of MeshOrchestrator that flushes the MeshDoc field to the cloud.

func (*MeshOrchestrator) GetSimpleNodeList

func (meshorchestrator *MeshOrchestrator) GetSimpleNodeList() map[int64]string

A method of MeshOrchestrator that returns a simplified nodelist. The simplified nodelist is mapping of the nodeIDs to their config strings.

func (*MeshOrchestrator) Initialize

func (meshorchestrator *MeshOrchestrator) Initialize()

A method of MeshOrchestrator that sends commands to the commandqueue that will trigger events that configure the Controlnode, the NodeList and the NodeListID fields

func (*MeshOrchestrator) SetControlnode

func (meshorchestrator *MeshOrchestrator) SetControlnode(log Log) error

A method of MeshOrchestrator that sets the value of the Controlnode field. Accepts a log of type 'ctrldata' and constructs a ControlNode from the log.

func (*MeshOrchestrator) SetNode

func (meshorchestrator *MeshOrchestrator) SetNode(log Log) error

A method of MeshOrchestrator that adds/updates the Node on the Nodelist map. Accepts a log og type 'configdata' and constructs a SensorNode from the log. The SensorNode is then added to the Nodelist with the NodeID being the key.

func (*MeshOrchestrator) SetNodeIDlist

func (meshorchestrator *MeshOrchestrator) SetNodeIDlist(log Log) error

A method of MeshOrchestrator that accepts a Log of type 'nodelist' and parses the nodelist sequence on it into a slice of integer nodeIDs and assigns it to the NodeIDlist field. Finally calls the method to update the NodeList based on the new NodeIDlist.

func (*MeshOrchestrator) SetSensorData

func (meshorchestrator *MeshOrchestrator) SetSensorData(log Log) error

A method of MeshOrchestator that constructs a SensorPing object from the log and sends it to the AccumulatorQueue if it is not a userping

func (*MeshOrchestrator) UpdateNodeIDlist

func (meshorchestrator *MeshOrchestrator) UpdateNodeIDlist()

A method of MeshOrchestrator that sends the command to retreieve a new copy of the nodelist from the mesh.

func (*MeshOrchestrator) UpdateNodelist

func (meshorchestrator *MeshOrchestrator) UpdateNodelist()

A method of MeshhOrchestrator that sets updates the NodeList field. Compares the NodeIDlist field with a slice of NodeID integers collected from the NodeList. If they are equal, no updation is performed, otherwise a command is sent to ping the entire mesh for configdata, each of which will accumulate into the NodeList map.

type MeshPing

type MeshPing struct {
	// A slice of int64 node IDs that are expected to respond to the ping
	Nodelist []int64

	// A mapping of int64 nodeIDs to their respective SensorPings
	Pings map[int64]SensorPing

	// A string that represents the shared ping ID of all SensorPings in Pings
	PingID string

	// A string that represents the time of response of the first SensorPing to get accumulated
	Pingtime string
}

A struct represents a collection of SensorPing of the same ping ID

func NewMeshPing

func NewMeshPing(pingid string, pingtime string, nodelist []int64) *MeshPing

A constructor function that generates and returns a MeshPing. Requires a pingID, a ping time and a slice of int64 representing the list of nodes from which to expect response. The value of PingID is set based on the value passed to constructor. The value of Ping time is set based on the value passed to constructor. The value of Nodelist is set based on the value passed to constructor. The value of the Pings is an empty map of int64 -> SensorPing

func (*MeshPing) AddPing

func (meshping *MeshPing) AddPing(sensorping SensorPing, meshorchestrator *MeshOrchestrator)

A method of MeshPing that assigns a SensorPing to the MeshPing and flushes the MeshPing to the cloud if it is completed.

func (*MeshPing) Complete

func (meshping *MeshPing) Complete() bool

A method of MeshPing that returns a bool indicating whether all the nodes in its Nodelist have responded to the ping.

func (*MeshPing) Flush

func (meshping *MeshPing) Flush(meshorchestrator *MeshOrchestrator) error

A method of MeshPing that flushes a completed MeshPing to the cloud.

func (*MeshPing) GenerateAvgProbability

func (meshping *MeshPing) GenerateAvgProbability() float64

A method of MeshPing that generates the average probability value of the meshping by accumulating the probability values of individual nodes and taking their average.

func (*MeshPing) GenerateProbabilitydatamap

func (meshping *MeshPing) GenerateProbabilitydatamap() map[string]float64

A method of MeshPing that generates and a mapping of string node ID to the fire probability value

func (*MeshPing) GenerateSensordatamap

func (meshping *MeshPing) GenerateSensordatamap() map[string]map[string]float64

A method of MeshPing that generates and returns a mappings of the string node ID to its Sensordata map

type ObserverLog

type ObserverLog struct {
	Logsource  string
	Logtype    string
	Logmessage string
}

A struct that defines a log that is sent out of the server for observation. The Logmessage here is a fully stringified Log. The Logsource and Logtype are used for filtering.

func NewObserverLog

func NewObserverLog(log Log) *ObserverLog

A constructore function that generates and returns an ObserverLog that is built using an existing Log. The Logmessage is a stringified version of the Log object being used. The Logsource and Logtype are taken from the Log struct.

type OrchLog

type OrchLog struct {
	Logsource   string
	Logtype     string
	Logtime     string
	Logmessage  string
	Logmetadata map[string]string
}

A struct that defines a log that is generated within the orchestrator.

func NewObsCommand

func NewObsCommand(command string) *OrchLog

A constructor function that generates and returns an OrchLog with the 'obstoggle' type. The command passed is set as the Logmessage.

func NewOrchCloudlog

func NewOrchCloudlog(message string) *OrchLog

A constructor function that generates and returns an OrchLog with the 'cloudlog' type. The message passed is set as the Logmessage.

func NewOrchProtolog

func NewOrchProtolog(message string, server string, service string, err error) *OrchLog

A constructor function that generates and returns an OrchLog with the 'protolog' type. The message passed is set as the Logmessage and the server, service and err values are set in the Logmetadata map.

func NewOrchSchedlog

func NewOrchSchedlog(message string) *OrchLog

A constructor function that generates and returns an OrchLog with the 'schedlog' type. The message passed is set as the Logmessage.

func NewOrchServerlog

func NewOrchServerlog(message string) *OrchLog

A constructor function that generates and returns an OrchLog with the 'serverlog' type. The message passed is set as the Logmessage.

func (*OrchLog) GetLogmessage

func (orchlog *OrchLog) GetLogmessage() string

A getter function for the Logmessage field of OrchLog

func (*OrchLog) GetLogmetadata

func (orchlog *OrchLog) GetLogmetadata() map[string]string

A getter function for the Logmetadata field of OrchLog

func (*OrchLog) GetLogsource

func (orchlog *OrchLog) GetLogsource() string

A getter function for the Logsource field of OrchLog

func (*OrchLog) GetLogtime

func (orchlog *OrchLog) GetLogtime() string

A getter function for the Logtime field of OrchLog

func (*OrchLog) GetLogtype

func (orchlog *OrchLog) GetLogtype() string

A getter function for the Logtype field of OrchLog

type PingDocument

type PingDocument struct {
	PingID          string                        `firestore:"pingid"`
	Pingtime        string                        `firestore:"pingtime"`
	Nodelist        []int64                       `firestore:"nodelist"`
	Sensordata      map[string]map[string]float64 `firestore:"sensordata"`
	Probabilitydata map[string]float64            `firestore:"probability"`
	AvgProbability  float64                       `firestore:"avgprobability"`
}

A struct that represents the Firestore Document that contains the values that make up a MeshPing

func NewPingDocument

func NewPingDocument(meshping *MeshPing) *PingDocument

A constructor function that generates and returns a PingDocument object from a given MeshPing.

func (*PingDocument) Push

func (pingdoc *PingDocument) Push(cloudinterface *CloudInterface) error

A method of PingDocument that writes the Document to the Firestore database A document is created with the Pingtime as the ID and the values of the PingDocument are written.

type SensorNode

type SensorNode struct {
	// The identifier of the node
	NodeID int64 `firestore:"nodeID"`

	// The serial baud rate of the node
	SerialBaud int `firestore:"serialbaud"`

	// The type of DHT sensor attached
	DHTtype int `firestore:"dht_type"`

	// The pin on which the DHT sensor is attached
	DHTpin int `firestore:"dht_pin"`

	// The type of FLM sensor attached
	FLMtype int `firestore:"flm_type"`

	// The pin on which the FLM sensor is attached
	FLMpin int `firestore:"flm_pin"`

	// The type of GAS sensor attached
	GAStype int `firestore:"gas_type"`

	// The pin on which the GAS sensor is attached
	GASpin int `firestore:"gas_pin"`

	// The bool indicating if the node has a pinger button
	Pinger bool `firestore:"pinger"`

	// The pin on which the pinger button is attached
	Pingerpin int `firestore:"pinger_pin"`

	// The pin on which the connect LED is attached
	Connectpin int `firestore:"connect_pin"`
}

A struct that defines a sensor node and its hardware configuration values.

func NewSensorNode

func NewSensorNode(log Log) (*SensorNode, error)

A constructor function that generates and returns a SensorNode. Only accepts a Log of type 'configdata'.

func (*SensorNode) GetConfigString

func (sensornode *SensorNode) GetConfigString() string

A method of SensorNode that returns the sensor config of the node as a string.

type SensorPing

type SensorPing struct {
	// A mapping of string sensor types to float64 sensor values
	Sensordata map[string]float64

	// A SensorNode object that represents the origin of the ping data
	Sensornode SensorNode

	// A string that represents the pingID of a ping response
	PingID string

	// A string that represents the time of the ping response
	Pingtime string

	// A float32 value that reprsents the probability of fire in the neighbourhood of the node
	Fireprobability float64
}

A struct that defines the ping response of sensordata from a sensor node.

func NewSensorPing

func NewSensorPing(log Log, meshorchestrator *MeshOrchestrator) (*SensorPing, error)

A constructor function that generates and returns a SensorPing. Requires a Log of type 'sensordata' The value of Sensordata is collected by parsed the sensordata log. The value of the Sensornode is retrieved from MeshOrchestrator's Nodelist. The value of the PingID is taken from sensordata log. The value of the Pingtime is the current time when the struct is constructed. The value of Fireprobabiliy is set by the CalculateFireProbability method.

func (*SensorPing) CalculateFireProbability

func (sensorping *SensorPing) CalculateFireProbability() error

A function that calculates the probability of a fire in the neighbourhood of the node and sets it to the SensorPing object's Fireprobability field.

func (*SensorPing) GenerateSensorData

func (sensorping *SensorPing) GenerateSensorData(sensordata map[string]string, meshorchestrator *MeshOrchestrator)

A method of SensorPing that generates the sensor data from the map parsed from the sensordata log. Passes the sensor data through some regularity checks and through the simulator seed. This allows the simulator to override the values if necessary.

type ServiceConfig

type ServiceConfig struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

A struct that defines the configuration of an individual service that is a part of the FyrMesh service

type SimulatorSeed

type SimulatorSeed struct {
	// A float64 that  represents the initial value of the seed
	Initial float64
	// A float64 that represents the value by which the seed moves the cursor
	Adjust float64
	// A float64 that represents the width of the seed while generating values
	Width float64
	// A float64 that represents the max deviation from the initial value before the seed curve ends
	Peak float64
	// A float64 that represents the current value of the seed
	Cursor float64
	// A string that represents the kind of seed curve to follow
	Curve string
}

A struct that represents a simulator seed for a given type of sensor value

func NewSimulatorSeed

func NewSimulatorSeed(initial, peak, adjust, width float64, curve string) *SimulatorSeed

A constructor function that generates and returns a SimulatorSeed object. Requires the initial, peak, adjust, width and curve name. The cursor is set the value of the initial passed.

func (*SimulatorSeed) StartCurve

func (seed *SimulatorSeed) StartCurve(wg *sync.WaitGroup)

A method of SimulatorSeed that starts the curve of the seed.

Jump to

Keyboard shortcuts

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