AutomationConnectIQ-Sample13

Automation Connect IQ SDK

Explanation about what was added in Ver0.3.

Ability to edit Activity Monitor tables

using namespace AutomationConnectIQ.Lib;
$sdk = New-Object GarminSDK -Property @{
	Key = "H:DevelopGarminkeydeveloper_key"
}
$sim = New-Object Simulator($sdk)
$sim.WaitForInput()

$monitor = $sim.CreateActivityMonitor()
$monitor.Open()
$monitor.SetActiveMinutesGoal(123)

$monitor.SetValue($true, 0, 0, 300)
$monitor.SetValue($true, 0, 1, 5050)
$monitor.SetValue($true, 0, 5, 5)
$monitor.SetValue($true, 0, 6, 6)
$monitor.SetValue($true, 0, 7, 7)
$monitor.SetValue($true, 0, 8, 8)
$monitor.SetValue($true, 0, 9, 9)
for ($row = 0; $row -lt 7; $row++) {
	for ($column = 0; $column -lt 9; $column++) {
		$monitor.SetValue($false, $row, $column, $row * 10 + $column)
	}
}
$monitor.Ok()

$sim.FastForward(5)

When the above is executed, the following screen will be displayed.

  • Lines 8 and 9: Processing to display the Activity Monitor screen
    The idea is similar to the Time Simulation class. The screen is displayed with Open, but since it becomes a modal screen, set and cancel with the Ok / Cancel method.
    In the above example, Ok on the 24th line reflects the settings.
  • Line 10: Weekly Active Minutes Goal Settings
  • Lines 12-23: Code for setting data from Today to 7Days Ago
    Specify whether the first argument is the upper (Today) grid or the lower (Yesterday or later) grid. $ True becomes the upper grid.
    The 2nd and 3rd indicate the position in the grid, and the 4th argument is the value to be set.
  • Line 26: Method to operate Fast Forward of simulator

Notes and changing the arguments of Checker.Check

public bool Check(string device, Simulation func, PrePostAction pre = null)

Added the third argument. I made it possible to give a function to run the simulator before loading the program into the simulator.

Activity Monitor’s Today Steps are determined by Steps Per Minutes, Fast Forward, and the elapsed time after setting.
There is also the problem that 0 cannot be reset after the simulator is started.

Therefore, in order to set Steps to a fixed value when capturing the screen, I felt that it was necessary to make a decision immediately after starting the simulator and before loading the program.

The Check method performed for all devices was set to pre, but there was no such parameter on the single device side. Therefore, pre can be registered even for a single device.
The default is null and the same call as V0.2 is possible.

How to set the value of Steps

At the beginning, it says “Steps are Steps Per Minutes and Fast Forward, and the value is determined by the elapsed time after setting”, but the troublesome part is that “the value is determined by the elapsed time after setting”.
If you set a large value in Steps, for example, a 5-digit number to check if there is room in the number of digits to be displayed, if you enter a maximum settable value such as 300 in Steps Per Minutes, it will take seconds immediately after setting. Steps increase in units, and it becomes difficult to achieve the desired value.

Therefore, if you want to set Steps to the desired value, set Steps Per Minutes to 1 and call Fast Forward repeatedly so that the specified value is obtained.
However, since the Fast Forward setting can only be set up to 600, it will be the specified value, so Fast Forward will be called multiple times.

Specifically, the following code

using namespace AutomationConnectIQ.Lib;
$sdk = New-Object GarminSDK -Property @{
	Key = "H:DevelopGarminkeydeveloper_key"
}
$sim = New-Object Simulator($sdk)
$sim.WaitForInput()

$monitor = $sim.CreateActivityMonitor()
$monitor.Open()
$monitor.SetValue($true, 0, 0, 1)
$monitor.Ok()
$count = 12345
for (; $count -gt 600; $count -= 600) {
	$sim.FastForward(600)
}
$sim.FastForward($count)

$monitor.Open()
$monitor.SetValue($true, 0, 0, 0)
$monitor.Ok()
  • Lines 9-11: Set Steps Per Minutes to 1.
  • Lines 12-16: Call Fast Forward until the specified Steps are reached
    It is desirable that the processing of this part be completed within 1 minute.
    If it takes more than 1 minute, it may not be the expected Steps because it is counted by the elapsed time.
  • Lines 18-20: Set Steps Per Minutes to 0 to prevent Steps from increasing over time

コメント

Copied title and URL