Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ICT100_assignment4
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Vitale
ICT100_assignment4
Commits
3c33bfec
Commit
3c33bfec
authored
Sep 29, 2022
by
Jon
Browse files
Options
Downloads
Patches
Plain Diff
Add dummy method to make the occupying robot unavailable for subtask (c)
parent
4ad000e1
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/classes/assignment.js
+2
-2
2 additions, 2 deletions
src/classes/assignment.js
src/classes/task2/robot-waiter.js
+15
-0
15 additions, 0 deletions
src/classes/task2/robot-waiter.js
with
17 additions
and
2 deletions
src/classes/assignment.js
+
2
−
2
View file @
3c33bfec
...
...
@@ -321,10 +321,10 @@ class Task2 {
let
misplacedRobot
=
targetTable
.
getRobotAtTable
();
let
token
=
await
misplacedRobot
.
acquire
();
let
promiseSleep
=
new
Promise
((
resolve
)
=>
{
setTimeout
(
()
=>
{
misplacedRobot
.
dummyAction
().
then
(
()
=>
{
misplacedRobot
.
release
(
token
);
resolve
(
true
);
}
,
4000
+
Math
.
random
()
*
5000
);
});
});
await
safeTeleportTo
(
randRobot
.
getRobotID
(),
targetTable
.
getTableID
());
await
promiseSleep
;
...
...
This diff is collapsed.
Click to expand it.
src/classes/task2/robot-waiter.js
+
15
−
0
View file @
3c33bfec
...
...
@@ -159,4 +159,19 @@ class RobotWaiter {
this
.
_acquisitionTokens
=
[];
}
async
dummyAction
(){
this
.
#startProcess
(
`dummyAction()`
);
try
{
let
actionTime
=
parseInt
(
2000
+
Math
.
random
()
*
5000
);
await
this
.
sleep
(
actionTime
);
}
catch
(
error
)
{
throw
(
error
);
}
finally
{
this
.
#endProcess
();
}
return
true
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment