...
Greenhouse : Overall DataModel holder for Greenhouse. GHLanes is defined of type reference. There are two types of references - simple reference and smart reference. Smartness can be defined by providing a "Find" Query at the time of model definition or at the time of instantiating the model. GHLanes is defined as Reference to include all the Lanes from Lane model.
Code Block language xml title Greenhouse DataModel linenumbers true <DataModel Name="Greenhouse"> <Sid Name="GreenhouseID"/> <BoundingBox Name="GreenhouseLocation"/> <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"/> <Reference Name="GHLanes"> <Find> <Lane> <LaneID ne=""/> </Lane> </Find> </Reference> </DataModel>
Grid - DataModel for storing Grid information.
Code Block language xml title Grid DataModel linenumbers true <DataModel Name="Grid"> <Sid Name="GridID"/> <String Name="ZoneID"/> <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="ZoneGrid" Type="Zone" Cardinality="1"/> </DataModel>
Zone - DataModel for storing Zone information. Does a Smart Reference to Grid at instantiation time by simply defining ZoneGrids as Reference type. The Find query can be add at the instantiation time.
Code Block language xml title Zone DataModel linenumbers true <DataModel Name="Zone"> <Sid Name="ZoneID"/> <String Name="LaneID"/> <String Name="ZoneName"/> <BoundingBox Name="ZoneLocation"/> <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"/> <Reference Name="LaneZone" Type="Lane" Cardinality="1"/> <Reference Name="ZoneGrids"/> </DataModel>
Lane - DataModel to hold Lane information. Defines Smart Reference to Zones.
Code Block language xml title Lane DataModel linenumbers true <DataModel Name="Lane"> <Find> <Sid Name="LaneID"/> <Grid> <String Name="LaneName"/> <GridID <String Namene="GreenhouseID"/> <Double Name="LaneLength"/></Grid> </Find> <Double</Reference> </DataModel>
Lane - DataModel to hold Lane information. Defines Smart Reference to Zones.
Code Block language xml title Lane DataModel linenumbers true <DataModel Name="LaneWidthLane"/> <Integer<Sid Name="LaneID"/> <String Name="ZoneInLaneLaneName"/> <String Name="BorderLaneGreenhouseID"/> <BoundingBox<Double Name="LaneLocationLaneLength"/> <Reference<Double Name="LaneZonesLaneWidth"/> </DataModel>
Data + Things
We have to assign 1 temperature sensor per zone. We do this by:
- Use the content of MultipleSensors tutorial project and bring in all the model content into this tutorial.
- Use Simple Reference in TempSensorModel to a particular Zone using ZoneID
Other sensors and actuators can be referenced in a similar fashion.
...
language | xml |
---|---|
title | TempSensorModel with reference to Zone |
linenumbers | true |
...
<Integer Name="ZoneInLane"/> <String Name="BorderLane"/> <BoundingBox Name="LaneLocation"/> <Reference Name="GreenhouseLane" Type="Greenhouse" Cardinality="1"/> <Reference Name="
...
Queries
Let's start writing some queries to create and read the data.
Create Grids
...
language | xml |
---|---|
title | Create Grid |
linenumbers | true |
...
LaneZones"> <Find> <Zone>
...
...
<ZoneID ne=""/>
...
...
</Zone>
...
</Find>
...
...
</Reference>
...
</DataModel>
Data + Things
We have to assign 1 temperature sensor per zone. We do this by:
- Use the content of MultipleSensors tutorial project and bring in all the model content into this tutorial.
- Use Simple Reference in TempSensorModel to a particular Zone using ZoneID
Other sensors and actuators can be referenced in a similar fashion.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<ThingModel Name="TempSensorModel" Combines="TempSensorFacet">
<Sid Name="TempSensorId"/>
<Reference Name="TempSensorInZone" Type="Zone" Cardinality="1"/>
</ThingModel> |
Queries
Let's start writing some queries to create and read the data.
Create Grids
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<Query> <Find> <Zone> <ZoneName eq="Zone1"/> </Zone> </Find> <Create> <Grid> <GridName> 1 </GridWEPosition> <GridLength> 3.33 Grid1 </GridLength>GridName> <GridWidth><GridNSPosition> 3.331 </GridWidth>GridNSPosition> <SoilMoisture><GridWEPosition> 01 </SoilMoisture>GridWEPosition> <AmbientLight><GridLength> 03.33 </AmbientLight> </Grid> </Create> </Query> |
Create Zone
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<Query>GridLength> <DeleteAll> <GridWidth> <Zone> 3.33 <ZoneID ne=""/> </Zone>GridWidth> <SoilMoisture> </DeleteAll> <Create> <Zone>0 <ZoneWidth></SoilMoisture> <AmbientLight> 10 </ZoneWidth>0 <ZoneLength></AmbientLight> <ZoneGrid>[:$Response.Message.Value.Find.Result.Zone.ZoneID:]</ZoneGrid> 10 </Grid> </ZoneLength>Create> </Query> |
Create Zone
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<Query> <DeleteAll> <GridOnLength> <Zone> 3 </GridOnLength> <GridOnWidth><ZoneID ne=""/> </Zone> </DeleteAll> 3<Create> </GridOnWidth><Zone> <GridCount><ZoneWidth> 910 </GridCount>ZoneWidth> <GridLength><ZoneLength> 3.3310 </GridLength>ZoneLength> <GridWidth><GridOnLength> 3.33 </GridWidth>GridOnLength> <EndZone><GridOnWidth> No3 </EndZone>GridOnWidth> <ZoneTemperature><GridCount> 09 </ZoneTemperature>GridCount> <ZoneHumidity> <GridLength> 0 </ZoneHumidity>3.33 <CropType>Tomato<</CropType>GridLength> <ZoneGrids><GridWidth> <Value>3.33 </GridWidth> <Find> <EndZone> No <Grid> </EndZone> <ZoneTemperature> <GridName eq="Zone1.Grid1"/> 0 </Grid>ZoneTemperature> <ZoneHumidity> </Find> 0 </Value>ZoneHumidity> <<CropType>Tomato</ZoneGrids>CropType> </Zone> </Create> </Query> |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<Query> <DeleteAll> <TempSensorModel> <TempSensorId ne=""/> </TempSensorModel> </DeleteAll> <Find> <Zone> <ZoneName eq="Zone-1Zone1"/> </Zone> </Find> <Create> <TempSensorModel> <TempValueInC> 0 </TempValueInC> <TempValueInF> 0 </TempValueInF> <TempSensorInZone> [:$Response.Message.Value.Find.Result.Zone.ZoneID:] </TempSensorInZone> </TempSensorModel> </Create> </Query> |
...