Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug?] Async findColors blocks AT processes #1

Open
ThibaultRT opened this issue Aug 1, 2020 · 0 comments
Open

[bug?] Async findColors blocks AT processes #1

ThibaultRT opened this issue Aug 1, 2020 · 0 comments

Comments

@ThibaultRT
Copy link

ThibaultRT commented Aug 1, 2020

@kentkrantz first issue report - let me know if it’s matching your expectations

When launching async findColors, the code after the call is executed until any AT function is called -> at this point, AT blocks until async findColors is finished, then it continues execution

Sample’s code output in the logs:

2EC29814-7FD7-48A9-871D-ECBE19477542

Logs explanation:
Line 1: start of code
Line 2: console.log called right after calling the async findColors
Line 3-14: findColors Finding callback logs, during 5 seconds
Line 15-22 : sample of swiping commands that should have been executed WHILE findColors run

Sample code :

var colors =  [{ color: 16417035, x: 0, y: 0 },{ color: 16777215, x: 8, y: 17 }]
var area = {x:89,y:1640,width:425,height:119}
console.log("starting async findColors")
at.findColors({
            options : {colors:colors,count:1,region:area,debug:true}, // OPTIONAL, options for finding colors.
            duration: '5s', // OPTIONAL, how long time you want it to keep finding? Three formats are supported: 1. `duration: 10` means repeat finding 10 times, the value must be a number, can't be a string; 2. `duration: '60s'` means keep finding for 60 seconds, the value must be seconds + a character 's'; 3. `duration: '2020-05-30 12:00:00'` means keep finding till 2020-05-30 12:00:00. Default is `duration: 10` means repeat 10 times, the value must be a string.
            interval: 250, // OPTIONAL, interval between loops in milliseconds, default is 1000 milliseconds.
            exitIfFound: false, // OPTIONAL, if exit findColors if got a result successfully, default is true.
            eachFindingCallback: () => { // OPTIONAL, will call this function after each finding loop.
                console.log("looking..")
            },
            foundCallback: result => { // OPTIONAL, will call this function while getting matched result, returns the rectangle coordinate matching the action you specified through `matchMethod`.
                console.log("result found : " +JSON.stringify(result))
                at.tap(result[0].x,result[0].y)
            },
            errorCallback: error => { // OPTIONAL, handle any error, will exit findColors if got error, if no errorCallback provide, it will alert while getting error.
                alert(error)
            },
            completedCallback: () => { // OPTIONAL, callback when all finding completed
                console.log("finished")
            },
            block: false, // OPTIONAL, you want to run findColors asynchronously or synchronously, block=true means it will run synchronously and block here till completed, default is false, doesn't block here.
        })
console.log("let's swipe screen")
at.touchDown(1,500,500)
console.log("touched down!")
at.usleep(100000)
console.log("slept a bit")
for(var i=0;i<= 50;i++){
    at.touchMove(1,500+(i*10),500)
    at.usleep(50000)
    console.log("swiping...")
}
at.usleep(250000)
at.touchUp(1,1000,500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant