Documentation
¶
Index ¶
- func CleanStates(in map[string]interface{}) (out map[string]interface{})
- func GetTemplateParameterList(str string) (result []string, err error)
- func RenderTempl(templ string, parameter interface{}) (result string, err error)
- type ChangeRoutine
- type ChangeRoutineIndexElement
- type ChangeRoutineResponse
- type CreateChangeRoutineByTemplateRequest
- type CreateChangeRoutineRequest
- type CreateDeviceByTypeRequest
- type CreateDeviceRequest
- type CreateRoomRequest
- type CreateServiceRequest
- type CreateTemplateRequest
- type CreateWorldRequest
- type Device
- type DeviceMsg
- type DeviceResponse
- type Graph
- type MongoPersistence
- func (this *MongoPersistence) Close()
- func (this MongoPersistence) DeleteGraph(id string) (err error)
- func (this MongoPersistence) DeleteTemplate(id string) (err error)
- func (this MongoPersistence) DeleteWorld(id string) (err error)
- func (this MongoPersistence) GetTemplate(id string) (templ RoutineTemplate, err error)
- func (this MongoPersistence) GetTemplates() (templ []RoutineTemplate, err error)
- func (this MongoPersistence) LoadGraphs() (result map[string]*Graph, err error)
- func (this MongoPersistence) LoadWorlds() (result map[string]*World, err error)
- func (this MongoPersistence) PersistGraph(graph Graph) (err error)
- func (this MongoPersistence) PersistTemplate(templ RoutineTemplate) (err error)
- func (this MongoPersistence) PersistWorld(world World) (err error)
- type PersistenceInterface
- type Point
- type Room
- type RoomMsg
- type RoomResponse
- type RoutineTemplate
- type Service
- type ServiceResponse
- type StateRepo
- func (this *StateRepo) CreateChangeRoutine(jwt jwt.Jwt, msg CreateChangeRoutineRequest) (result ChangeRoutineResponse, access bool, exists bool, err error)
- func (this *StateRepo) CreateChangeRoutineByTemplate(jwt jwt.Jwt, msg CreateChangeRoutineByTemplateRequest) (routine ChangeRoutineResponse, access bool, exists bool, err error)
- func (this *StateRepo) CreateDevice(jwt jwt.Jwt, msg CreateDeviceRequest) (device DeviceResponse, access bool, worldAndExists bool, err error)
- func (this *StateRepo) CreateDeviceByType(jwt jwt.Jwt, msg CreateDeviceByTypeRequest) (result DeviceResponse, access bool, worldAndExists bool, err error)
- func (this *StateRepo) CreateProtocol(handler string, segments []model.ProtocolSegment) (protocol model.Protocol, err error)
- func (this *StateRepo) CreateRoom(jwt jwt.Jwt, msg CreateRoomRequest) (room RoomResponse, access bool, worldExists bool, err error)
- func (this *StateRepo) CreateService(jwt jwt.Jwt, msg CreateServiceRequest) (service ServiceResponse, access bool, worldAndExists bool, err error)
- func (this *StateRepo) CreateTemplate(jwt jwt.Jwt, request CreateTemplateRequest) (result RoutineTemplate, err error)
- func (this *StateRepo) CreateWorld(jwt jwt.Jwt, msg CreateWorldRequest) (world WorldMsg, err error)
- func (this *StateRepo) DeleteChangeRoutine(jwt jwt.Jwt, id string) (routine ChangeRoutineResponse, access bool, exists bool, err error)
- func (this *StateRepo) DeleteDevice(jwt jwt.Jwt, id string) (device DeviceResponse, access bool, exists bool, err error)
- func (this *StateRepo) DeleteExternalDevice(jwt jwt.Jwt, id string) (err error)
- func (this *StateRepo) DeleteRoom(jwt jwt.Jwt, id string) (room RoomResponse, access bool, exists bool, err error)
- func (this *StateRepo) DeleteService(jwt jwt.Jwt, id string) (service ServiceResponse, access bool, exists bool, err error)
- func (this *StateRepo) DeleteTemplate(jwt jwt.Jwt, id string) (err error)
- func (this *StateRepo) DeleteWorld(jwt jwt.Jwt, id string) (access bool, exists bool, err error)
- func (this *StateRepo) DevDeleteWorld(id string) (err error)
- func (this *StateRepo) DevGetWorld(id string) (world WorldMsg, exist bool, err error)
- func (this *StateRepo) DevUpdateDevice(worldId string, roomId string, device DeviceMsg) (err error)
- func (this *StateRepo) DevUpdateRoom(worldId string, room RoomMsg) (err error)
- func (this *StateRepo) DevUpdateWorld(worldMsg WorldMsg) (err error)
- func (this *StateRepo) EnsureProtocol(handler string, segments []model.ProtocolSegment) (protocolId string, err error)
- func (this *StateRepo) GenerateExternalDevice(jwt jwt.Jwt, request CreateDeviceByTypeRequest) (device model.Device, err error)
- func (this *StateRepo) GetIotDeviceType(jwt jwt.Jwt, id string) (dt model.DeviceType, err error)
- func (this *StateRepo) GetIotDeviceTypes(jwt jwt.Jwt) (result []model.DeviceType, err error)
- func (this *StateRepo) GetIotDeviceTypesIds(jwt jwt.Jwt) (result []string, err error)
- func (this *StateRepo) GetMosesDeviceTypesIds(jwt jwt.Jwt) (result []string, err error)
- func (this *StateRepo) GetProtocolList(handler string) (result []models.Protocol, err error)
- func (this *StateRepo) HandleCommand(externalDeviceRef string, externalServiceRef string, cmdMsg interface{}, ...)
- func (this *StateRepo) Load() (err error)
- func (this *StateRepo) PopulateServiceService(jwt jwt.Jwt, serviceMsg UpdateServiceRequest) (service Service, err error)
- func (this *StateRepo) ReadChangeRoutine(jwt jwt.Jwt, id string) (routine ChangeRoutineResponse, access bool, exists bool, err error)
- func (this *StateRepo) ReadDevice(jwt jwt.Jwt, id string) (device DeviceResponse, access bool, exists bool, err error)
- func (this *StateRepo) ReadRoom(jwt jwt.Jwt, id string) (room RoomResponse, access bool, exists bool, err error)
- func (this *StateRepo) ReadService(jwt jwt.Jwt, id string) (service ServiceResponse, access bool, exists bool, err error)
- func (this *StateRepo) ReadTemplate(jwt jwt.Jwt, id string) (result RoutineTemplate, exists bool, err error)
- func (this *StateRepo) ReadTemplates(jwt jwt.Jwt) (result []RoutineTemplate, err error)
- func (this *StateRepo) ReadWorld(jwt jwt.Jwt, id string) (world WorldMsg, access bool, exists bool, err error)
- func (this *StateRepo) ReadWorlds(jwt jwt.Jwt) (worlds []WorldMsg, err error)
- func (this *StateRepo) RunService(serviceId string, cmdMsg interface{}) (resp interface{}, err error)
- func (this *StateRepo) Start()
- func (this *StateRepo) StartDevice(world *World, room *Room, device *Device) (tickers []*time.Ticker, stops []chan bool, err error)
- func (this *StateRepo) StartRoom(world *World, room *Room) (tickers []*time.Ticker, stops []chan bool, err error)
- func (this *StateRepo) StartService(world *World, room *Room, device *Device, service Service) (tickers []*time.Ticker, stops []chan bool, err error)
- func (this *StateRepo) StartWorld(world *World) (tickers []*time.Ticker, stops []chan bool, err error)
- func (this *StateRepo) Stop() (err error)
- func (this *StateRepo) UpdateChangeRoutine(jwt jwt.Jwt, msg UpdateChangeRoutineRequest) (routine ChangeRoutineResponse, access bool, exists bool, err error)
- func (this *StateRepo) UpdateChangeRoutineByTemplate(jwt jwt.Jwt, msg UpdateChangeRoutineByTemplateRequest) (routine ChangeRoutineResponse, access bool, exists bool, err error)
- func (this *StateRepo) UpdateDevice(jwt jwt.Jwt, msg UpdateDeviceRequest) (device DeviceResponse, access bool, exists bool, err error)
- func (this *StateRepo) UpdateRoom(jwt jwt.Jwt, msg UpdateRoomRequest) (room RoomResponse, access bool, exists bool, err error)
- func (this *StateRepo) UpdateService(jwt jwt.Jwt, msg UpdateServiceRequest) (service ServiceResponse, access bool, exists bool, err error)
- func (this *StateRepo) UpdateTemplate(jwt jwt.Jwt, request UpdateTemplateRequest) (result RoutineTemplate, exists bool, err error)
- func (this *StateRepo) UpdateWorld(jwt jwt.Jwt, msg UpdateWorldRequest) (world WorldMsg, access bool, exists bool, err error)
- type UpdateChangeRoutineByTemplateRequest
- type UpdateChangeRoutineRequest
- type UpdateDeviceRequest
- type UpdateRoomRequest
- type UpdateServiceRequest
- type UpdateTemplateRequest
- type UpdateWorldRequest
- type World
- type WorldMsg
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanStates ¶
func GetTemplateParameterList ¶
Example ¶
templ := ` Hello {{name}} You have just won {{value}} dollars! {{#in_ca}} Well, {{taxed_value}} dollars, after taxes. {{/in_ca}} ` fmt.Println(GetTemplateParameterList(templ))
Output: [name value in_ca taxed_value] <nil>
func RenderTempl ¶
Types ¶
type ChangeRoutine ¶
type ChangeRoutineResponse ¶
type CreateChangeRoutineByTemplateRequest ¶
type CreateChangeRoutineByTemplateRequest struct { RefType string `json:"ref_type"` // "world" || "room" || "device" RefId string `json:"ref_id"` TemplId string `json:"templ_id"` Interval int64 `json:"interval"` Parameter map[string]string `json:"parameter"` }
{ref_type:"workd|room|device", ref_id: "", templ_id: "", name: "", desc: "", parameter: {<<param_name>>: <<param_value>>}}
type CreateChangeRoutineRequest ¶
type CreateChangeRoutineRequest struct { RefType string `json:"ref_type"` // "world" || "room" || "device" RefId string `json:"ref_id"` Interval int64 `json:"interval"` Code string `json:"code"` }
{ref_type:"workd|room|device", ref_id: "", interval: 0, code:""}
type CreateDeviceRequest ¶
type CreateRoomRequest ¶
type CreateServiceRequest ¶
type CreateServiceRequest struct { Device string `json:"device"` Name string `json:"name"` ExternalRef string `json:"external_ref"` //platform intern service id, will be used to populate Service.Marshaller and as endpoint for the Connector SensorInterval int64 `json:"sensor_interval"` Code string `json:"code"` }
type CreateTemplateRequest ¶
type CreateWorldRequest ¶
type Device ¶
type Device struct { Id string `json:"id" bson:"id"` Name string `json:"name" bson:"name"` ImageUrl string `json:"image_url" bson:"image_url"` ExternalTypeId string `json:"external_type_id" bson:"external_type_id"` ExternalRef string `json:"external_ref" bson:"external_ref"` //platform intern device id; 1:1 States map[string]interface{} `json:"states" bson:"states"` ChangeRoutines map[string]ChangeRoutine `json:"change_routines" bson:"change_routines"` Services map[string]Service `json:"services" bson:"services"` }
func (*Device) CleanStates ¶
func (this *Device) CleanStates()
type DeviceMsg ¶
type DeviceMsg struct { Id string `json:"id"` Name string `json:"name"` ExternalTypeId string `json:"external_type_id"` ExternalRef string `json:"external_ref"` //platform intern device id; 1:1 States map[string]interface{} `json:"states"` ChangeRoutines map[string]ChangeRoutine `json:"change_routines"` Services map[string]Service `json:"services"` }
func (*DeviceMsg) CleanStates ¶
func (this *DeviceMsg) CleanStates()
type DeviceResponse ¶
type MongoPersistence ¶
type MongoPersistence struct {
// contains filtered or unexported fields
}
func NewMongoPersistence ¶
func NewMongoPersistence(config config.Config) (result MongoPersistence, err error)
func (*MongoPersistence) Close ¶
func (this *MongoPersistence) Close()
func (MongoPersistence) DeleteGraph ¶
func (this MongoPersistence) DeleteGraph(id string) (err error)
func (MongoPersistence) DeleteTemplate ¶
func (this MongoPersistence) DeleteTemplate(id string) (err error)
func (MongoPersistence) DeleteWorld ¶
func (this MongoPersistence) DeleteWorld(id string) (err error)
func (MongoPersistence) GetTemplate ¶
func (this MongoPersistence) GetTemplate(id string) (templ RoutineTemplate, err error)
func (MongoPersistence) GetTemplates ¶
func (this MongoPersistence) GetTemplates() (templ []RoutineTemplate, err error)
func (MongoPersistence) LoadGraphs ¶
func (this MongoPersistence) LoadGraphs() (result map[string]*Graph, err error)
func (MongoPersistence) LoadWorlds ¶
func (this MongoPersistence) LoadWorlds() (result map[string]*World, err error)
func (MongoPersistence) PersistGraph ¶
func (this MongoPersistence) PersistGraph(graph Graph) (err error)
func (MongoPersistence) PersistTemplate ¶
func (this MongoPersistence) PersistTemplate(templ RoutineTemplate) (err error)
func (MongoPersistence) PersistWorld ¶
func (this MongoPersistence) PersistWorld(world World) (err error)
type PersistenceInterface ¶
type PersistenceInterface interface { PersistWorld(world World) (err error) PersistGraph(graph Graph) (err error) PersistTemplate(templ RoutineTemplate) error LoadWorlds() (map[string]*World, error) LoadGraphs() (map[string]*Graph, error) GetTemplate(id string) (templ RoutineTemplate, err error) GetTemplates() (templ []RoutineTemplate, err error) DeleteWorld(id string) error DeleteGraph(id string) error DeleteTemplate(id string) error }
type Room ¶
type Room struct { Id string `json:"id" bson:"id"` Name string `json:"name" bson:"name"` States map[string]interface{} `json:"states" bson:"states"` Devices map[string]*Device `json:"devices" bson:"devices"` ChangeRoutines map[string]ChangeRoutine `json:"change_routines" bson:"change_routines"` }
func (*Room) CleanStates ¶
func (this *Room) CleanStates()
type RoomMsg ¶
type RoomMsg struct { Id string `json:"id"` Name string `json:"name"` States map[string]interface{} `json:"states"` Devices map[string]DeviceMsg `json:"devices"` ChangeRoutines map[string]ChangeRoutine `json:"change_routines"` }
func (*RoomMsg) CleanStates ¶
func (this *RoomMsg) CleanStates()
type RoomResponse ¶
type RoutineTemplate ¶
type Service ¶
type Service struct { Id string `json:"id" bson:"id"` Name string `json:"name" bson:"name"` ExternalRef string `json:"external_ref" bson:"external_ref"` //platform intern service id, will be used to populate Service.Marshaller and as endpoint for the Connector SensorInterval int64 `json:"sensor_interval" bson:"sensor_interval"` Code string `json:"code"` }
type ServiceResponse ¶
type ServiceResponse struct { World string `json:"world"` Room string `json:"room"` Device string `json:"device"` Service UpdateServiceRequest `json:"service"` }
type StateRepo ¶
type StateRepo struct { Worlds map[string]*World Graphs map[string]*Graph Persistence PersistenceInterface Connector *platform_connector_lib.Connector Config config.Config MosesProtocolId string StateLogger connectionlog.Logger // contains filtered or unexported fields }
func (*StateRepo) CreateChangeRoutine ¶
func (this *StateRepo) CreateChangeRoutine(jwt jwt.Jwt, msg CreateChangeRoutineRequest) (result ChangeRoutineResponse, access bool, exists bool, err error)
func (*StateRepo) CreateChangeRoutineByTemplate ¶
func (this *StateRepo) CreateChangeRoutineByTemplate(jwt jwt.Jwt, msg CreateChangeRoutineByTemplateRequest) (routine ChangeRoutineResponse, access bool, exists bool, err error)
func (*StateRepo) CreateDevice ¶
func (this *StateRepo) CreateDevice(jwt jwt.Jwt, msg CreateDeviceRequest) (device DeviceResponse, access bool, worldAndExists bool, err error)
func (*StateRepo) CreateDeviceByType ¶
func (this *StateRepo) CreateDeviceByType(jwt jwt.Jwt, msg CreateDeviceByTypeRequest) (result DeviceResponse, access bool, worldAndExists bool, err error)
func (*StateRepo) CreateProtocol ¶
func (*StateRepo) CreateRoom ¶
func (this *StateRepo) CreateRoom(jwt jwt.Jwt, msg CreateRoomRequest) (room RoomResponse, access bool, worldExists bool, err error)
func (*StateRepo) CreateService ¶
func (this *StateRepo) CreateService(jwt jwt.Jwt, msg CreateServiceRequest) (service ServiceResponse, access bool, worldAndExists bool, err error)
func (*StateRepo) CreateTemplate ¶
func (this *StateRepo) CreateTemplate(jwt jwt.Jwt, request CreateTemplateRequest) (result RoutineTemplate, err error)
func (*StateRepo) CreateWorld ¶
func (*StateRepo) DeleteChangeRoutine ¶
func (*StateRepo) DeleteDevice ¶
func (*StateRepo) DeleteExternalDevice ¶
func (*StateRepo) DeleteRoom ¶
func (*StateRepo) DeleteService ¶
func (*StateRepo) DeleteTemplate ¶
func (*StateRepo) DeleteWorld ¶
func (*StateRepo) DevDeleteWorld ¶
func (*StateRepo) DevGetWorld ¶
func (*StateRepo) DevUpdateDevice ¶
Update for HTTP-DEV-API Stops all change routines and redeploys new world with new room and device requests a mutex lock on the state repo
func (*StateRepo) DevUpdateRoom ¶
Update for HTTP-DEV-API Stops all change routines and redeploys new world with new room requests a mutex lock on the state repo
func (*StateRepo) DevUpdateWorld ¶
Update for HTTP-DEV-API Stops all change routines and redeploys new world requests a mutex lock on the state repo
func (*StateRepo) EnsureProtocol ¶
func (*StateRepo) GenerateExternalDevice ¶
func (*StateRepo) GetIotDeviceType ¶
func (*StateRepo) GetIotDeviceTypes ¶
func (*StateRepo) GetIotDeviceTypesIds ¶
func (*StateRepo) GetMosesDeviceTypesIds ¶
func (*StateRepo) GetProtocolList ¶
func (*StateRepo) HandleCommand ¶
func (*StateRepo) Load ¶
Stops all change routines if any are running and loads state repo from the database (no restart of change routines)
func (*StateRepo) PopulateServiceService ¶
func (*StateRepo) ReadChangeRoutine ¶
func (*StateRepo) ReadDevice ¶
func (*StateRepo) ReadService ¶
func (*StateRepo) ReadTemplate ¶
func (*StateRepo) ReadTemplates ¶
func (this *StateRepo) ReadTemplates(jwt jwt.Jwt) (result []RoutineTemplate, err error)
func (*StateRepo) ReadWorlds ¶
func (*StateRepo) RunService ¶
func (*StateRepo) Start ¶
func (this *StateRepo) Start()
starts change routines; will first call stop() to prevent overpopulation of change routines if error occurs, the state repo may be in a partially running state which can not be stopped with Stop() in this case a panic occurs
func (*StateRepo) StartDevice ¶
func (*StateRepo) StartService ¶
func (*StateRepo) StartWorld ¶
func (*StateRepo) Stop ¶
stops all change routines; may be called repeatedly while already stopped ore not started
func (*StateRepo) UpdateChangeRoutine ¶
func (this *StateRepo) UpdateChangeRoutine(jwt jwt.Jwt, msg UpdateChangeRoutineRequest) (routine ChangeRoutineResponse, access bool, exists bool, err error)
func (*StateRepo) UpdateChangeRoutineByTemplate ¶
func (this *StateRepo) UpdateChangeRoutineByTemplate(jwt jwt.Jwt, msg UpdateChangeRoutineByTemplateRequest) (routine ChangeRoutineResponse, access bool, exists bool, err error)
func (*StateRepo) UpdateDevice ¶
func (this *StateRepo) UpdateDevice(jwt jwt.Jwt, msg UpdateDeviceRequest) (device DeviceResponse, access bool, exists bool, err error)
func (*StateRepo) UpdateRoom ¶
func (this *StateRepo) UpdateRoom(jwt jwt.Jwt, msg UpdateRoomRequest) (room RoomResponse, access bool, exists bool, err error)
func (*StateRepo) UpdateService ¶
func (this *StateRepo) UpdateService(jwt jwt.Jwt, msg UpdateServiceRequest) (service ServiceResponse, access bool, exists bool, err error)
func (*StateRepo) UpdateTemplate ¶
func (this *StateRepo) UpdateTemplate(jwt jwt.Jwt, request UpdateTemplateRequest) (result RoutineTemplate, exists bool, err error)
func (*StateRepo) UpdateWorld ¶
type UpdateDeviceRequest ¶
type UpdateDeviceRequest struct { Id string `json:"id"` Name string `json:"name"` States map[string]interface{} `json:"states"` ChangeRoutines map[string]ChangeRoutine `json:"change_routines"` Services map[string]Service `json:"services"` ExternalRef string `json:"external_ref"` //platform intern device id; 1:1 }
type UpdateRoomRequest ¶
type UpdateRoomRequest struct { Id string `json:"id"` Name string `json:"name"` States map[string]interface{} `json:"states"` ChangeRoutines map[string]ChangeRoutine `json:"change_routines"` }
type UpdateServiceRequest ¶
type UpdateTemplateRequest ¶
type UpdateWorldRequest ¶
type UpdateWorldRequest struct { Id string `json:"id"` Name string `json:"name"` States map[string]interface{} `json:"states"` ChangeRoutines map[string]ChangeRoutine `json:"change_routines"` }
type World ¶
type World struct { Id string `json:"id" bson:"id"` Owner string `json:"-" bson:"owner"` Name string `json:"name" bson:"name"` States map[string]interface{} `json:"states" bson:"states"` Rooms map[string]*Room `json:"rooms" bson:"rooms"` ChangeRoutines map[string]ChangeRoutine `json:"change_routines" bson:"change_routines"` // contains filtered or unexported fields }
func (*World) CleanStates ¶
func (this *World) CleanStates()
type WorldMsg ¶
type WorldMsg struct { Id string `json:"id"` Owner string `json:"-"` Name string `json:"name"` States map[string]interface{} `json:"states"` Rooms map[string]RoomMsg `json:"rooms"` ChangeRoutines map[string]ChangeRoutine `json:"change_routines"` }
func (*WorldMsg) CleanStates ¶
func (this *WorldMsg) CleanStates()