...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<Macro Name="CreateGreenhouse"> <Argument> <Greenhouses></Greenhouses> </Argument> <Result> <SetLocalData key="Greenhouses"> <Value> <Include>$Macro.Argument.Greenhouses</Include> </Value> </SetLocalData> <for each="record" in="Greenhouse" from="$LocalData.Greenhouses" using="$ProcessData"> <JavaScript> var NumberOfLanes = [:$ProcessData.record.NumberOfLanes:]; var ZonesPerLane = [:$ProcessData.record.ZonesPerLane:]; var NumberOfZones = NumberOfLanes * ZonesPerLane; sffContext.execute("SetLocalData","key","NumberOfZones","value",NumberOfZones); </JavaScript> <executeQuery> <QueryString> <Query> <Create> <Greenhouse> <GreenhouseName>[:$ProcessData.record.GreenHouseName:]</GreenhouseName> <BoundingBox> <Vertex1>0</Vertex1> <Vertex2>0</Vertex2> <Vertex3>110</Vertex3> <Vertex4>40</Vertex4> </BoundingBox> <LaneCount> [:$ProcessData.record.NumberOfLanes:] </LaneCount> <LaneWidth>110</LaneWidth> <ZoneLength>10</ZoneLength> <ZoneInLane> [:$ProcessData.record.ZonesPerLane:] </ZoneInLane> <ZoneCount>[:$LocalData.NumberOfZones:]</ZoneCount> <GHLength>110</GHLength> <GHWidth>40</GHWidth> <ExternalEnv> <Temperature>1</Temperature> <Humidity>1</Humidity> <Light>1</Light> <SoilMoisture>1</SoilMoisture> <Wind>19.5</Wind> </ExternalEnv> <InternalEnv> <Temperature>1</Temperature> <Humidity>1</Humidity> <Light>1</Light> <SoilMoisture>1</SoilMoisture> </InternalEnv> <GHLanes></GHLanes> <SunnyDay>True</SunnyDay> <Location> <latitude> [:$ProcessData.record.Location.latitude:] </latitude> <longitude> [:$ProcessData.record.Location.longitude:] </longitude> </Location> </Greenhouse> </Create> </Query> </QueryString> </executeQuery> <if condition="$Response.Message.Value/Create/Status eq 'Success'"> <then> <SetContextData key="GreenhouseID"> <Value>[:$Response.Message.Value.Create.Greenhouse.GreenhouseID:]</Value> </SetContextData> <executeQuery> <QueryString> <Query> <Save format="version,current"> <ExtTempSensor> <peripheral> serial </peripheral> <baudrate> 115200 </baudrate> <interfacePort> /dev/cu.usbserial-AH02V4BU </interfacePort> <interface> serial </interface> <format> ascii </format> <operation> receive </operation> <uniqueId> 76522 </uniqueId> <avgMonthHighTemp> </avgMonthHighTemp> <avgMonthLowTemp> </avgMonthLowTemp> <TempValue> </TempValue> <SensingInterval> 3600 </SensingInterval> </ExtTempSensor> </Save> <Save format="version,current"> <ExtHumiditySensor> <peripheral> serial </peripheral> <baudrate> 115200 </baudrate> <interfacePort> /dev/cu.usbserial-AH02V4BU </interfacePort> <interface> serial </interface> <format> ascii </format> <operation> receive </operation> <uniqueId> 76522 </uniqueId> <avgMonthHighTemp> </avgMonthHighTemp> <avgMonthLowTemp> </avgMonthLowTemp> <HumidityValue> </HumidityValue> </ExtHumiditySensor> </Save> <Save format="version,current"> <ExtLightSensor> <peripheral> serial </peripheral> <baudrate> 115200 </baudrate> <interfacePort> /dev/cu.usbserial-AH02V4BU </interfacePort> <interface> serial </interface> <format> ascii </format> <operation> receive </operation> <uniqueId> 76522 </uniqueId> <Intensity> $Null() </Intensity> <HourMeanLight> </HourMeanLight> <LightValue> </LightValue> </ExtLightSensor> </Save> <Save format="version,current"> <GHTempSensor> <GreenhouseID> [:$ContextData.GreenhouseID:] </GreenhouseID> <peripheral> serial </peripheral> <baudrate> 115200 </baudrate> <interfacePort> /dev/cu.usbserial-AH02V4BU </interfacePort> <interface> serial </interface> <format> ascii </format> <operation> receive </operation> <uniqueId> 76522 </uniqueId> <avgMonthHighTemp> </avgMonthHighTemp> <avgMonthLowTemp> </avgMonthLowTemp> <TempValue> </TempValue> <SensingInterval> 3600 </SensingInterval> </GHTempSensor> </Save> <Save format="version,current"> <GHHumiditySensor> <GreenhouseID> [:$ContextData.GreenhouseID:] </GreenhouseID> <peripheral> serial </peripheral> <baudrate> 115200 </baudrate> <interfacePort> /dev/cu.usbserial-AH02V4BU </interfacePort> <interface> serial </interface> <format> ascii </format> <operation> receive </operation> <uniqueId> 76522 </uniqueId> <HumidityValue> 0 </HumidityValue> </GHHumiditySensor> </Save> </Query> </QueryString> </executeQuery> <SetContextData key="FirstLane"> <Value>Yes</Value> </SetContextData> <For each="laneRecord" in="Lane" from="$ProcessData.record.Lanes" using="$LocalData"> <addLanes> <GreenhouseID>[:$ContextData.GreenhouseID:]</GreenhouseID> <LaneName>[:$LocalData.laneRecord.LaneName:]</LaneName> <LaneLength>110</LaneLength> <LaneWidth>40</LaneWidth> <ZoneInLane>[:$ProcessData.record.ZonesPerLane:]</ZoneInLane> <BorderLane>No</BorderLane> </addLanes> <if condition="$Response.Message.Value/Create/Status eq 'Success'"> <then> <SetLocalData key="LaneID"> <Value>[:$Response.Message.Value.Create.Lane.LaneID:]</Value> </SetLocalData> <loadZoneModels> <LaneID>[:$LocalData.LaneID:]</LaneID> <ZonesPerLane>[:$ProcessData.record.ZonesPerLane:]</ZonesPerLane> <CropType>[:$LocalData.laneRecord.CropType:]</CropType> <FirstLane>[:$ContextData.FirstLane:]</FirstLane> </loadZoneModels> </then> </if> <SetContextData key="FirstLane"> <Value>No</Value> </SetContextData> </For> </then> </if> </for> </Result> </Macro> |
Add Action to Start Simulate
...