Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iotamak-core
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMAC
AMAK
Python
IoTAMAK
iotamak-core
Commits
b4db11d1
Commit
b4db11d1
authored
3 years ago
by
shinedday
Browse files
Options
Downloads
Patches
Plain Diff
Fix : Agent now 1 only 1 execution policy (full cycle)
parent
36fd1a0c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
agent.py
+0
-3
0 additions, 3 deletions
agent.py
ihm.py
+7
-0
7 additions, 0 deletions
ihm.py
scheduler.py
+19
-7
19 additions, 7 deletions
scheduler.py
with
26 additions
and
10 deletions
agent.py
+
0
−
3
View file @
b4db11d1
...
@@ -70,9 +70,6 @@ class Agent(Schedulable):
...
@@ -70,9 +70,6 @@ class Agent(Schedulable):
self
.
on_perceive
()
self
.
on_perceive
()
self
.
publish
(
"
cycle_done
"
,
""
)
self
.
wait
()
self
.
on_decide
()
self
.
on_decide
()
self
.
on_act
()
self
.
on_act
()
...
...
This diff is collapsed.
Click to expand it.
ihm.py
+
7
−
0
View file @
b4db11d1
...
@@ -118,6 +118,9 @@ class Ihm(MqttClient, SSHClient):
...
@@ -118,6 +118,9 @@ class Ihm(MqttClient, SSHClient):
if
cmd
.
lower
()
==
"
pause
"
:
if
cmd
.
lower
()
==
"
pause
"
:
self
.
client
.
publish
(
"
ihm/pause
"
)
self
.
client
.
publish
(
"
ihm/pause
"
)
if
cmd
.
lower
()
==
"
unpause
"
:
self
.
client
.
publish
(
"
ihm/unpause
"
)
if
cmd
.
lower
()
in
[
"
s
"
,
"
step
"
]:
if
cmd
.
lower
()
in
[
"
s
"
,
"
step
"
]:
self
.
client
.
publish
(
"
ihm/step
"
)
self
.
client
.
publish
(
"
ihm/step
"
)
...
@@ -132,6 +135,10 @@ class Ihm(MqttClient, SSHClient):
...
@@ -132,6 +135,10 @@ class Ihm(MqttClient, SSHClient):
print
(
"
Hostname :
"
,
client
.
hostname
,
"
Responded :
"
,
result
)
print
(
"
Hostname :
"
,
client
.
hostname
,
"
Responded :
"
,
result
)
if
cmd
.
lower
()
==
"
mode
"
:
self
.
client
.
publish
(
"
ihm/mode
"
)
self
.
client
.
publish
(
"
ihm/step
"
)
self
.
client
.
publish
(
"
ihm/step
"
)
sleep
(
2
)
sleep
(
2
)
...
...
This diff is collapsed.
Click to expand it.
scheduler.py
+
19
−
7
View file @
b4db11d1
...
@@ -28,18 +28,33 @@ class Scheduler(Schedulable):
...
@@ -28,18 +28,33 @@ class Scheduler(Schedulable):
self
.
subscribe
(
"
env/action_done
"
,
self
.
update_schedulable
)
self
.
subscribe
(
"
env/action_done
"
,
self
.
update_schedulable
)
self
.
subscribe
(
"
ihm/step
"
,
self
.
step
)
self
.
subscribe
(
"
ihm/step
"
,
self
.
step
)
self
.
subscribe
(
"
ihm/pause
"
,
self
.
pause
)
self
.
subscribe
(
"
ihm/pause
"
,
self
.
pause
)
self
.
subscribe
(
"
ihm/unpause
"
,
self
.
unpause
)
self
.
subscribe
(
"
ihm/mode
"
,
self
.
mode
)
self
.
agent_waiting
=
0
self
.
agent_waiting
=
0
self
.
schedulable_waiting
=
0
self
.
schedulable_waiting
=
0
print
(
"
Init done
"
)
print
(
"
Init done
"
)
def
mode
(
self
,
client
,
userdata
,
message
)
->
None
:
"""
Function called when the IHM change scheduler mode
"""
self
.
execution_policy
=
(
1
-
self
.
execution_policy
)
%
2
def
pause
(
self
,
client
,
userdata
,
message
)
->
None
:
def
pause
(
self
,
client
,
userdata
,
message
)
->
None
:
"""
"""
Function called when the IHM pause
/unpause
the scheduler
Function called when the IHM pause the scheduler
"""
"""
self
.
paused
=
not
self
.
paused
self
.
paused
=
True
self
.
ihm_token
+=
1
self
.
ihm_token
=
0
def
unpause
(
self
,
client
,
userdata
,
message
)
->
None
:
"""
Function called when the IHM unpause the scheduler
"""
self
.
paused
=
False
self
.
ihm_token
=
1
def
step
(
self
,
client
,
userdata
,
message
)
->
None
:
def
step
(
self
,
client
,
userdata
,
message
)
->
None
:
"""
"""
...
@@ -108,10 +123,7 @@ class Scheduler(Schedulable):
...
@@ -108,10 +123,7 @@ class Scheduler(Schedulable):
main part of a cycle : Agent cycle
main part of a cycle : Agent cycle
"""
"""
self
.
client
.
publish
(
"
scheduler/agent/wakeup
"
,
""
)
self
.
client
.
publish
(
"
scheduler/agent/wakeup
"
,
""
)
# Agent doing phase 1
# Agent doing cycle
self
.
wait_agent
()
self
.
client
.
publish
(
"
scheduler/agent/wakeup
"
,
""
)
# agent doing phase 2
self
.
wait_agent
()
self
.
wait_agent
()
def
last_part
(
self
)
->
None
:
def
last_part
(
self
)
->
None
:
...
...
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