...
Tip |
---|
|
| Related docs |
---|
IoT application topology | | Selective initialization | | Cluster | |
|
Tip |
---|
|
| Related docs |
---|
Engine-to-engine queries | | Edge-cloud parallel controls | | Edge over-ride and cloud over-ride controls | |
|
Background
In order to model a real-world IoT application or a solution it is imperative to distribute load. In Greenhouse example we have a total of
...
270+ Sensors and Actuators.
It is impractical to run entire sensors and actuators on one single node (either OnPrem or Cloud)
Cluster Design
Greenhouse Model Review
Complete Greenhouse Model (Queries, Macros, Facets, Models, Types) can be found here
Types
- Primitive Types
- Cardinality
- Defaults
- Composites
Code Block |
---|
language | xml |
---|
theme | Emacs |
---|
title | Greenhouse Types |
---|
linenumbers | true |
---|
collapse | true |
---|
|
<Def Name="EnvInfo">
<Number Name="Temperature"/>
<Number Name="Humidity"/>
<Number Name="Light"/>
<Number Name="Pressure"/>
<Number Name="SoilMoisture"/>
<Number Name="Wind"/>
<String Name="LastUpdatedByProvider"/>
</Def>
<Def Name="BoundingBox">
<GeoLocation Name="Vertex1"/>
<GeoLocation Name="Vertex2"/>
<GeoLocation Name="Vertex3"/>
<GeoLocation Name="Vertex4"/>
</Def>
<Def Name="GeoLocation">
<Number Name="latitude"/>
<Number Name="longitude"/>
</Def>
<Def Name="PeripheralParams">
<String Name="Peripheral" />
<String Name="InterfacePort" />
<String Name="Interface" />
<String Name="UniqueId" default="56789" />
<String Name="Baudrate" />
<String Name="Format" default="ascii" />
<String Name="Operation" />
<String Name="Payload" />
</Def>
<Def Name="PhilipLightState">
<Boolean Name="On"/>
<Integer Name="bri"/>
<Integer Name="hue"/>
<Integer Name="sat"/>
<String Name="effect"/>
<Double Name="xy" cardinality="2"/>
<Integer Name="ct"/>
<String Name="alert"/>
<String Name="colormode"/>
<Boolean Name="reachable"/>
</Def>
<Def Name="ImageSize">
<Number Name="Height" />
<Number Name="Width" />
</Def>
<Def Name="CameraConfig">
<Number Name="Channel" />
<Number Name="Standard" />
<Number Name="Brightness" />
<Number Name="Contrast" />
<Number Name="Gamma" />
<Number Name="Saturation" />
<Number Name="Sharpness" />
<Number Name="Hue" />
<Number Name="Gain" />
<Number Name="Quality" />
</Def>
<Def Name="USBCameraParams">
<ImageSize Name="Size" />
<CameraConfig Name="Configuration" />
<String Name="SaveToDisk" />
<String Name="ImageFormat" />
<String Name="ImageName" />
</Def> |
DataModel
- Primitive Types
- Default Format
- Hidden Modifiers
- Simple References
Code Block |
---|
language | xml |
---|
theme | Emacs |
---|
title | Greenhouse DataModel |
---|
linenumbers | true |
---|
collapse | true |
---|
|
<DataModel Name="Greenhouse">
<Sid Name="GreenhouseID"/>
<String Name="GreenhouseName"/>
<GeoLocation Name="Location"/>
<String Name="LocationName"/>
<BoundingBox Name="Boundary"/>
<Integer Name="LaneCount"/>
<Double Name="LaneWidth"/>
<Double Name="ZoneLength"/>
<Integer Name="ZoneInLane"/>
<Integer Name="ZoneCount"/>
<Double Name="GHLength"/>
<Double Name="GHWidth"/>
<EnvInfo Name="ExternalEnv"/>
<EnvInfo Name="InternalEnv"/>
<String Name="VentOnOffState"/>
<String Name="FansOnOffState"/>
<Boolean Name="SunnyDay"/>
<Boolean Name="Running" default="false"/> <!-- true / false -->
<Reference Name="GHLanes"/>
<Reference Name="GHExternalEnv"/>
<Reference Name="GHInternalEnv"/>
</DataModel>
<DataModel Name="Lane">
<Sid Name="LaneID"/>
<String Name="LaneName"/>
<Double Name="LaneLength"/>
<Double Name="LaneWidth"/>
<Integer Name="ZoneInLane"/>
<String Name="BorderLane"/>
<BoundingBox Name="LaneLocation"/>
<Reference Name="GreenhouseID" Type="Greenhouse" Cardinality="1"/>
<Reference Name="LaneZones"/>
</DataModel>
<DataModel Name="Zone">
<Sid Name="ZoneID"/>
<String Name="ZoneName"/>
<BoundingBox Name="ZoneLocation"/>
<GeoLocation Name="Location"/>
<Double Name="ZoneWidth"/>
<Double Name="ZoneLength"/>
<Integer Name="GridOnLength"/>
<Integer Name="GridOnWidth"/>
<Integer Name="GridCount"/>
<Double Name="GridLength"/>
<Double Name="GridWidth"/>
<String Name="EndZone"/>
<Double Name="ZoneTemperature"/>
<Double Name="ZoneHumidity"/>
<Double Name="ZoneAvgSM"/>
<Double Name="ZoneAvgLight"/>
<String Name="CropType"/>
<Date Name="SeedingDate" format="$SimpleDateFormat(dd-MM-yyyy)"/>
<Date Name="LastFertilisationDate" format="$SimpleDateFormat(dd-MM-yyyy)"/>
<String Name="HarvestingSeason"/>
<Integer Name="NoOfPlants"/>
<Double Name="VPD"/>
<String Name="Live"/> <!-- Yes/No -->
<Reference Name="LaneID" Type="Lane" Cardinality="1"/>
<Reference Name="ZoneGrids"/>
</DataModel>
<DataModel Name="Grid">
<Sid Name="GridID"/>
<String Name="GridName"/>
<BoundingBox Name="GridLocation"/>
<Integer Name="GridNSPosition"/>
<Integer Name="GridWEPosition"/>
<Double Name="GridLength"/>
<Double Name="GridWidth"/>
<Double Name="SoilMoisture"/>
<Double Name="AmbientLight"/>
<Reference Name="ZoneID" Type="Zone" Cardinality="1"/>
</DataModel>
<AppModel Name="ExternalEnv">
<Sid Name="ExternalEnvID"/>
<Number Name="ExtTemperature"/>
<Number Name="ExtHumidity"/>
<Number Name="ExtLight"/>
<Reference Name="GreenhouseID" Type="Greenhouse" Cardinality="1"/>
</AppModel>
<AppModel Name="InternalEnv">
<Sid Name="InternalEnvID"/>
<Number Name="IntTemperature"/>
<Number Name="IntHumidity"/>
<Number Name="IntLight"/>
<Reference Name="GreenhouseID" Type="Greenhouse" Cardinality="1"/>
</AppModel>
<DataModel Name="AvgCityTemp">
<Sid Name="Sid"/>
<Number Name="Month"/>
<Number Name="AvgMonthHighTemp"/>
<Number Name="AvgMonthLowTemp"/>
</DataModel>
<DataModel Name="AvgCityHumidity">
<Sid Name="Sid"/>
<Number Name="Month" Modifiers="hidden"/>
<Number Name="MorningHumidity"/>
<Number Name="AfternoonHumidity"/>
</DataModel>
<DataModel Name="GHTempSensorCurrentTemp">
<Sid Name="Sid"/>
<String Name="TempSensorID"/>
<Double Name="CurrentTemp"/>
<Reference Name="GreenhouseID" Type="Greenhouse" Cardinality="1"/>
</DataModel>
<DataModel Name="GHHumiditySensorCurrentHumidity">
<Sid Name="Sid"/>
<String Name="HumiditySensorID"/>
<Double Name="CurrentHumidity"/>
<Reference Name="GreenhouseID" Type="Greenhouse" Cardinality="1"/>
</DataModel> |
ThingModel and ThingFacets
- Protocol Handlers Used: PERIF, UCAM, HTTP, PHID
- Attach Things to Data using Simple References
- Proxy Sensor Design Pattern (Single MCUThingFacet → All Sensors)
- ThingFacets with Multiple Actions
- ThingFacet to load Vendor-Specified MetaData
Code Block |
---|
language | xml |
---|
theme | Emacs |
---|
title | Greenhouse ThingModel and Facets |
---|
linenumbers | true |
---|
collapse | true |
---|
|
<ThingModel Name="GHHumiditySensor" Combines="GHHumiditySensorFacet">
<Sid Name="SensorId"/>
<Reference Name="GreenhouseID" Type="Greenhouse" Cardinality="1"/>
</ThingModel>
<ThingModel Name="GHTempSensor" Combines="GHTempSensorFacet">
<Sid Name="sensorId"/>
<Reference Name="GreenhouseID" Type="Greenhouse" Cardinality="1"/>
</ThingModel>
<ThingModel Name="ServoMotorDevice" combines="ServoMotor">
<Sid Name="ServoID"/>
</ThingModel>
<ThingModel Name="HumiditySensor" Combines="HumiditySensorFacetNS">
<Sid Name="sensorId"/>
<Reference Name="ZoneID" Type="Zone" Cardinality="1"/>
</ThingModel>
<ThingModel Name="Heater">
<Sid Name="HeaterID"/>
<String Name="OnOffState"/>
<Integer Name="HeatingLevel"/>
<Reference Name="ZoneID" Type="Zone" Cardinality="1"/>
</ThingModel>
<ThingModel Name="LightModel" Combines="LightFacetNS">
<Sid Name="LightID"/>
<Reference Name="GridID" Type="Grid" Cardinality="1"/>
</ThingModel>
<ThingModel Name="AmbientLightSensorModel" Combines="AmbientLightSensorFacetNS">
<Sid Name="AmbientLightID"/>
<Reference Name="GridID" Type="Grid" Cardinality="1"/>
</ThingModel>
<ThingModel Name="IrrigationNozzleModel" Combines="IrrigationNozzleFacetNS">
<Sid Name="IrrigationNozzleID"/>
<Reference Name="GridID" Type="Grid" Cardinality="1"/>
</ThingModel>
<ThingModel Name="MCUSensorModel" combines="MCUSensorFacet">
<Sid Name="SensorId"/>
</ThingModel> |
Macros
Gateway Setup
...
How things are connected to Gateways
Gateway Type | Things | Protocol | Grid | Zone |
---|
Intel ADVANTECH | Ambient Light Sensor | Xbee/Serial | Image Removed | |
Intel ADVANTECH | Soil Sensor | Xbee/Serial | Image Removed | |
Intel ADVANTECH | Light | Xbee/IP | Image Removed | |
Intel ADVANTECH | Irrigation Nozzle (Selonoid) | Xbee/Serial | | |
Intel ADVANTECH | Temperature Sensor | Xbee/Serial | | Image Removed |
Intel ADVANTECH | Humidity Sensor | Xbee/Serial | | Image Removed |
Raspberry Pi - 3 | Camera | UCAM/Serial | | Image Removed |
TQLEngine | Heater | - | | Simulated |
Intel ADVANTECH | Irrigation Motor | PHID/Serial | | Image Removed |
Cluster Definition
...
- Pipeline Macros - ExecuteQuery, ScheduleJob, UnScheduleJob, SubscribeToTQL
- Greenhouse Creation (Bulk Initialization)
- Simulate Sensors & Actuators
- Internal Activation of ThingFacets
Code Block |
---|
language | xml |
---|
theme | Emacs |
---|
title | Greenhouse Macros |
---|
linenumbers | true |
---|
collapse | true |
---|
|
<Macro Name="ExecuteQuery">
<Argument>
<QueryString>
<Query/>
</QueryString>
</Argument>
<Result>
<OnRequest Target="[:RuntimeParams.FacetIDName:]" Disable="CMD_SERVER">
<Process Return="CMD_NOP">
<Message>
<Value>
[:$Macro.Argument.QueryString:]
</Value>
</Message>
</Process>
</OnRequest>
</Result>
</Macro> |
Gateway Setup
Cloud Setup (AWS)
Initialization Variation
Cloud Initialization
Live Gateway Init
MicroController (Pi) Init
- We only need to initialize USB Camera and Data Model
Code Block |
---|
language | xml |
---|
theme | Emacs |
---|
title | Pi - Init Queries |
---|
linenumbers | true |
---|
collapse | true |
---|
|
<Query>
<DeleteAll format="version,current">
<Greenhouse>
<GreenhouseID ne = ""/>
</Greenhouse>
</DeleteAll>
<Create>
<Greenhouse>
<GreenhouseID>
livegreenhouse
</GreenhouseID>
<GreenhouseName>
Intel-GreenHouse
</GreenhouseName>
<BoundingBox>
<Vertex1>
0
</Vertex1>
<Vertex2>
0
</Vertex2>
<Vertex3>
110
</Vertex3>
<Vertex4>
40
</Vertex4>
</BoundingBox>
<LaneCount>
3
</LaneCount>
<LaneWidth>
110
</LaneWidth>
<ZoneLength>
10
</ZoneLength>
<ZoneInLane>
5
</ZoneInLane>
<ZoneCount>
15
</ZoneCount>
<GHLength>
110
</GHLength>
<GHWidth>
40
</GHWidth>
<ExternalEnv>
<Temperature>
26
</Temperature>
<Humidity>
53
</Humidity>
<Light>
1
</Light>
<SoilMoisture>
20
</SoilMoisture>
<Wind>
19.5
</Wind>
</ExternalEnv>
<InternalEnv>
<Temperature>
20
</Temperature>
<Humidity>
53
</Humidity>
<Light>
1
</Light>
<SoilMoisture>
1
</SoilMoisture>
</InternalEnv>
<GHLanes>
</GHLanes>
<SunnyDay>
True
</SunnyDay>
<Location>
<latitude>
37.3718999
</latitude>
<longitude>
-122.0022377
</longitude>
</Location>
</Greenhouse>
</Create>
<DeleteAll format="version,current">
<Lane>
<LaneID ne = ""/>
</Lane>
</DeleteAll>
<create>
<Lane>
<LaneID>
livelane
</LaneID>
<GreenhouseID>
livegreenhouse
</GreenhouseID>
<LaneName>
lane-1
</LaneName>
<LaneLength>
5
</LaneLength>
<LaneWidth>
1
</LaneWidth>
<ZoneInLane>
4
</ZoneInLane>
<BorderLane>
1
</BorderLane>
<BoundingBox>
<Vertex1>
5
</Vertex1>
<Vertex2>
28
</Vertex2>
<Vertex3>
105
</Vertex3>
<Vertex4>
38
</Vertex4>
</BoundingBox>
</Lane>
</create>
<DeleteAll format="version,current">
<Zone>
<ZoneID ne = ""/>
</Zone>
</DeleteAll>
<create>
<Zone>
<ZoneID>
livezone
</ZoneID>
<ZoneName>
Intel-Zone
</ZoneName>
<LaneID>
livelane
</LaneID>
<ZoneLength>
1
</ZoneLength>
<ZoneWidth>
1
</ZoneWidth>
<ZoneLocation>
<Vertex1>
1
</Vertex1>
<Vertex2>
1
</Vertex2>
<Vertex3>
1
</Vertex3>
<Vertex4>
1
</Vertex4>
</ZoneLocation>
<EndZone>
endzone
</EndZone>
<GridOnLength>
1
</GridOnLength>
<GridOnWidth>
1
</GridOnWidth>
<GridCount>
1
</GridCount>
<GridLength>
1
</GridLength>
<GridWidth>
1
</GridWidth>
<ZoneTemperature>
26
</ZoneTemperature>
<ZoneHumidity>
53
</ZoneHumidity>
<ZoneAvgSM>
20
</ZoneAvgSM>
<ZoneAvgLight>
2
</ZoneAvgLight>
<CropType>
Apple
</CropType>
<SeedingDate>
11-04-2016
</SeedingDate>
<LastFertilisationDate>
14-04-2016
</LastFertilisationDate>
<HarvestingSeason>
April
</HarvestingSeason>
<NoOfPlants>
5
</NoOfPlants>
<VPD>
0
</VPD>
<Location>
<latitude>
1.11
</latitude>
<longitude>
1.12
</longitude>
</Location>
<Live>
yes
</Live>
</Zone>
</create>
<DeleteAll format="version,current">
<Grid>
<GridID ne=""/>
</Grid>
</DeleteAll>
<create>
<Grid>
<GridName>
Intel-Grid
</GridName>
<GridID>
livegrid
</GridID>
<ZoneID>
livezone
</ZoneID>
<GridLength>
1
</GridLength>
<GridWidth>
1
</GridWidth>
<GridNSPosition>
N
</GridNSPosition>
<GridWEPosition>
E
</GridWEPosition>
<GridLocation>
<Vertex1>
1
</Vertex1>
<Vertex2>
1
</Vertex2>
<Vertex3>
1
</Vertex3>
<Vertex4>
1
</Vertex4>
</GridLocation>
<SoilMoisture>
53
</SoilMoisture>
<AmbientLight>
0
</AmbientLight>
</Grid>
</create>
<DeleteAll>
<Camera>
<CameraID ne=""/>
</Camera>
</DeleteAll>
<Save>
<Camera>
<ZoneID>
livezone
</ZoneID>
<Image>
$Null()
</Image>
<USBCameraParameters>
<Size>
<Height>
0
</Height>
<Width>
0
</Width>
</Size>
<Configuration>
<Channel>
0
</Channel>
<Standard>
0
</Standard>
<Brightness>
0
</Brightness>
<Contrast>
0
</Contrast>
<Gamma>
286
</Gamma>
<Saturation>
65
</Saturation>
<Sharpness>
6
</Sharpness>
<Hue>
0
</Hue>
<Gain>
0
</Gain>
<Quality>
</Quality>
</Configuration>
<SaveToDisk>
true
</SaveToDisk>
<ImageFormat>
jpeg
</ImageFormat>
<ImageName>
ucam_testpic.jpeg
</ImageName>
</USBCameraParameters>
</Camera>
</Save>
</Query> |
Cluster Definition