AutomationConnectIQ-Sample8

Automation Connect IQ SDK

Introducing the convenience class Checker that builds and starts the simulator.
First, about the method to build one device and start the simulator.

using namespace AutomationConnectIQ.Lib;

$outputDir = "output"

function Capture {
	$time.Action([TimeSimulator+ExecuteType]::Start)
	Start-sleep -Milliseconds 500
	$time.Action([TimeSimulator+ExecuteType]::Pause)

	$bitmap = $simulator.Capture()
	$bitmap.Save($(Join-Path $outputDir $device".png"))
	$time.Action([TimeSimulator+ExecuteType]::Stop)
}

# Create a check object
# Parameters are developer key and monkey project file
$check = New-Object Checker -Property @{
	Key = "developer_key"
	Project = "monkey.jungle"
}

# Execute build check process with fr45
# The simulation process is "delegate bool Simulation (string device, Simulator sim)"
# Describe the simulation process with a PowerShell script block accordingly
$check.Check("fr45", {
	#Receive device name and simulator object as parameters
	Param($device, $simulator)

	$simulator.SetGPSPosition(35.685233, 139.752485)
	
	# Open the time window, change the language to English and then change to the specified time
	$time = $simulator.CreateTime()
	$time.Open()
	$time.Time = Get-Date "2020-1-1 13:00:00"
	$simulator.SetLanguage([Simulator+Language]::English)
	Capture
	$time.Close()
	return $true
})
  • Lines 5-13
    A PowerShell function version of the standard code for opening and capturing the time window shown in AutomationConnectIQ-Sample7.
  • Lines 17-20: Object creation of Checker class
    The key file name and project file name are passed as parameters.
  • 25th line ~
    In the Check method, describe the operations to be performed in build, simulator startup, and simulation in script blocks.
    The first argument is the device name of the program to be generated.
    The second argument describes the process to be executed by the simulator in a script block.
    The parameters passed are the device name and the object for simulator operation.
    The 27th line is the passing of the parameter.
    The return $true on line 38 matches the delegate bool Simulation(string device, Simulator sim) that is the source of this script block. It is unknown whether it is just working.

コメント

Copied title and URL