Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. 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
    languagexml
    titleGreenhouse DataModel
    linenumberstrue
    <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>
  2. Grid - DataModel for storing Grid information.

    Code Block
    languagexml
    titleGrid DataModel
    linenumberstrue
    <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>
  3. 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
    languagexml
    titleZone DataModel
    linenumberstrue
    <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
    languagexml
    titleLane DataModel
    linenumberstrue
    <DataModel Name="Lane">    <Find>
      <Sid Name="LaneID"/>   <Grid>
       <String Name="LaneName"/>    <GridID   <String Namene="GreenhouseID"/>
          <Double Name="LaneLength"/></Grid>
        </Find>
       <Double</Reference>
    </DataModel>
  4. Lane - DataModel to hold Lane information. Defines Smart Reference to Zones.

    Code Block
    languagexml
    titleLane DataModel
    linenumberstrue
    <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:

  1. Use the content of MultipleSensors tutorial project and bring in all the model content into this tutorial.
  2. Use Simple Reference in TempSensorModel to a particular Zone using ZoneID
    Other sensors and actuators can be referenced in a similar fashion.

...

languagexml
titleTempSensorModel with reference to Zone
linenumberstrue

...

  1.       <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

...

languagexml
titleCreate Grid
linenumberstrue

...

  1. LaneZones">
             <Find>
                <Zone>
       

...

  1.        

...

  1.      <ZoneID ne=""/>
      

...

  1.        

...

  1.    </Zone>
       

...

  1.       </Find>
      

...

  1.     

...

  1. </Reference>
    

...

  1. </DataModel>

Data + Things

We have to assign 1 temperature sensor per zone. We do this by:

  1. Use the content of MultipleSensors tutorial project and bring in all the model content into this tutorial.
  2. Use Simple Reference in TempSensorModel to a particular Zone using ZoneID
    Other sensors and actuators can be referenced in a similar fashion.
Code Block
languagexml
titleTempSensorModel with reference to Zone
linenumberstrue
<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
languagexml
titleCreate Grid
linenumberstrue
<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
languagexml
titleCreate Zone
linenumberstrue
<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
languagexml
titleCreate Zone
linenumberstrue
<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
languagexml
titleCreate Temperature Sensor
linenumberstrue
<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>

...