Automation Connect IQ SDK

Sample for GPS related settings.
The first half is the same as the code at the beginning here.
Only the subsequent simulator operation part is described here.

# Launching and waiting to launch the simulator
$sim = New-Object Simulator($sdk)

# Load the program into the simulator and wait for the load to complete
$sdk.StartProgram($proj.DefaultProgramPath, $deviceName)

$outputDir = "O:Users....Downloadsoutput"

#Set GPS quality to Usable and position to Imperial Palace and save the state at that time in a bitmap
$sim.SetGPSPosition(35.685233, 139.752485)
sleep -Milliseconds 500 # Earn time to update the screen
$bitmap = $sim.Capture()
$bitmap.Save($(Join-Path $outputDir $deviceName".png"))
  • Line 12: GPS quality settings
    This is the screen of the simulator.

    The choice is enum, but in PowerShell, the definition name of enum, [Simulator + GPSQualityType] is followed by :: to set the field name.
    + Represents the internal definition of the Simulator class.
    Since the setting value set in the Simulator class is the internal definition of the Simulator class, the setting of other enums can be described as above.
  • Line 13: GPS coordinate value setting
    The value set here can be quoted from Google Maps.

    When you click the screen on Google Maps, a pop-up appears at the bottom of the screen.
    The red line on the above screen corresponds to the coordinates, and when you click it, it is pasted on the clipboard, so you can set the coordinates by pasting it on the editor.
  • Lines 14-16: Screen capture
    This is the code you will use often. It becomes the code to capture the screen.
    After setting GPS coordinates and time, it is for checking what the screen looks like.

    Functionally, it is equivalent to the above menu, but the implementation method is different, and the bitmap information is acquired directly from the simulator screen.
    Therefore, the Save instruction on the 16th line is required to save the bitmap.
    Also, “sleep -Milliseconds 500” is inserted before capture, because the time is adjusted until the program updates the screen.
    This time will change depending on the environment, device, program, etc. you are using, so it is best to have the adjustment time suit you.


Copied title and URL