Documentation ¶
Index ¶
- type Device
- func (d *Device) Battery() models.DeviceBattery
- func (d *Device) Close() error
- func (c *Device) ExistsAssetInCache(id string) bool
- func (c *Device) FlushAssetsCache()
- func (c *Device) FlushRequirementsCache()
- func (c *Device) GetCachedAssets() []string
- func (c *Device) GetCachedRequirements() []*model.SensorsReadingRequest
- func (c *Device) GetCachedRequirementsFor(assetIDs ...string) []*model.SensorsReadingRequest
- func (c *Device) GetRequirementsFromCache(id string) (*model.SensorsReadingRequest, bool)
- func (d *Device) ID() string
- func (d *Device) IsLoggedToNetwork() bool
- func (d *Device) Location() models.Location
- func (d *Device) Name() string
- func (c *Device) PutAssetsToCache(assets ...*models.Asset)
- func (c *Device) PutRequirementsToCache(reqs ...*models.Requirements) (requests []*model.SensorsReadingRequest)
- func (d *Device) RegisterSensors(sensors ...sensor.Sensor)
- func (d *Device) RegisterStaticSensors(sensors ...sensor.Sensor) *Device
- func (d *Device) RegisteredSensors() sensor.SensorsRegister
- func (c *Device) RemoveAssetFromCache(id string)
- func (c *Device) RemoveRequirementsFromCache(id string)
- func (d *Device) SetBattery(battery models.DeviceBattery) error
- func (d *Device) SetLocation(location models.Location) error
- func (d *Device) SetSpecs(setter func(specs *model.DeviceSpecs)) error
- func (d *Device) SetState(state models.DeviceState) error
- func (d *Device) Specs() model.DeviceSpecs
- func (d *Device) Start()
- func (d *Device) State() models.DeviceState
- func (d *Device) StaticSensors() sensor.SensorsRegister
- func (d *Device) UnregisterSensor(id string)
- func (d *Device) UpdateDeviceModel(model *models.Device)
- func (d *Device) UpdateSensorsRegister(added []sensor.Sensor, removed []string)
- type Module
- type ModulesRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device defines driver for the IoT device itself.
func (*Device) Battery ¶
func (d *Device) Battery() models.DeviceBattery
Battery returns Device current battery stats.
func (*Device) ExistsAssetInCache ¶
ExistsAssetInCache determines whether the models.Asset record stored in cache by given `id`.
func (*Device) FlushAssetsCache ¶
func (c *Device) FlushAssetsCache()
FlushAssetsCache resets models.Asset records cache.
func (*Device) FlushRequirementsCache ¶
func (c *Device) FlushRequirementsCache()
FlushRequirementsCache resets models.Requirements records cache.
func (*Device) GetCachedAssets ¶
func (c *Device) GetCachedAssets() []string
GetCachedAssets returns IDs of cached models.Asset records.
func (*Device) GetCachedRequirements ¶
func (c *Device) GetCachedRequirements() []*model.SensorsReadingRequest
GetCachedRequirements returns data of cached models.Requirements records as model.SensorsReadingRequest.
func (*Device) GetCachedRequirementsFor ¶
func (c *Device) GetCachedRequirementsFor(assetIDs ...string) []*model.SensorsReadingRequest
GetCachedRequirementsFor returns models.Requirements cached data for given `assetIDs` as model.SensorsReadingRequest.
func (*Device) GetRequirementsFromCache ¶
func (c *Device) GetRequirementsFromCache(id string) (*model.SensorsReadingRequest, bool)
GetRequirementsFromCache tries to retrieve single models.Requirements from cache by given `id`, where it is stored as a model.SensorsReadingRequest record.
func (*Device) IsLoggedToNetwork ¶
IsLoggedToNetwork determines whether the Device is logged to network and thus is ready to operate.
func (*Device) PutAssetsToCache ¶
PutAssetsToCache puts models.Asset records to local cache.
func (*Device) PutRequirementsToCache ¶
func (c *Device) PutRequirementsToCache(reqs ...*models.Requirements) (requests []*model.SensorsReadingRequest)
PutRequirementsToCache puts models.Requirements records to local cache and return requests as they are stored.
func (*Device) RegisterSensors ¶
RegisterSensors adds given `sensors` on the Device sensors pool.
func (*Device) RegisterStaticSensors ¶
RegisterStaticSensors allows to registrant static (not auto-detectable) sensors.
func (*Device) RegisteredSensors ¶
func (d *Device) RegisteredSensors() sensor.SensorsRegister
RegisteredSensors returns map with sensors registered on the Device.
func (*Device) RemoveAssetFromCache ¶
func (c *Device) RemoveAssetFromCache(id string)
RemoveAssetFromCache removes models.Asset record to local cache by given `id`.
func (*Device) RemoveRequirementsFromCache ¶
func (c *Device) RemoveRequirementsFromCache(id string)
RemoveRequirementsFromCache removes models.Requirements record to local cache by given `id`.
func (*Device) SetBattery ¶
func (d *Device) SetBattery(battery models.DeviceBattery) error
SetBattery updates Device current battery stats in blockchain network.
func (*Device) SetLocation ¶
SetLocation updates Device current location in blockchain network.
func (*Device) SetSpecs ¶
func (d *Device) SetSpecs(setter func(specs *model.DeviceSpecs)) error
SetSpecs updates Device current specification in blockchain network.
func (*Device) SetState ¶
func (d *Device) SetState(state models.DeviceState) error
SetState updates Device current state in blockchain network.
func (*Device) Specs ¶
func (d *Device) Specs() model.DeviceSpecs
Specs returns Device current specification.
func (*Device) Start ¶
func (d *Device) Start()
Start performs startup of the Device and setting up all registered modules.
func (*Device) State ¶
func (d *Device) State() models.DeviceState
State returns Device current state.
func (*Device) StaticSensors ¶
func (d *Device) StaticSensors() sensor.SensorsRegister
StaticSensors returns map with sensors statically registered on the Device.
func (*Device) UnregisterSensor ¶
UnregisterSensor removes sensor by given `id` from the Device sensors pool.
func (*Device) UpdateDeviceModel ¶
UpdateDeviceModel updates Device data model (models.Device).
This method won't change state of the Device in blockchain ledger, it just updates device locally saved properties.
type Module ¶
type Module interface { // MID returns Module ID. MID() string // Setup registers logical Module onto the Device instance. Setup(device *Device) error // IsReady determines whether the logical Module's Setup is complete and it is ready to Start. IsReady() bool // Start starts Module operational routine. Start(ctx context.Context) // Close stops Module gracefully and clears allocated resources. Close() error }
Module defines interface for Device extendable logical modules.
type ModulesRegistry ¶
type ModulesRegistry []Module
ModulesRegistry defines pool of registered logical Module's extending the Device functionality.
func (ModulesRegistry) Close ¶
func (r ModulesRegistry) Close()
func (ModulesRegistry) Setup ¶
func (r ModulesRegistry) Setup(device *Device)
Setup registers all logical device.Module's presented in ModulesRegistry onto the device.Device instance.
func (ModulesRegistry) Start ¶
func (r ModulesRegistry) Start(ctx context.Context)
Start starts all presented in ModulesRegistry logical device.Module's operational routine.