Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nrm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
16
Issues
16
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
argo
nrm
Commits
7a953c62
Commit
7a953c62
authored
Sep 05, 2017
by
Srinivasan Ramesh
Committed by
Swann Perarnau
Dec 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pub-sub connection between GRM and NRM
parent
96b9d832
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
4 deletions
+14
-4
Makefile
Makefile
+1
-1
nrm/daemon.py
nrm/daemon.py
+13
-3
No files found.
Makefile
View file @
7a953c62
...
...
@@ -4,7 +4,7 @@ source:
$(PYTHON)
setup.py sdist
install
:
$(PYTHON)
setup.py
install
--force
$(PYTHON)
setup.py
install
--force
--prefix
/g/g91/ramesh2/ARGO/NRM
check
:
tox
nrm/daemon.py
View file @
7a953c62
...
...
@@ -71,7 +71,7 @@ class Daemon(object):
self.applications = {}
self.buf = ''
self.logger = logging.getLogger(__name__)
self.target = 1
self.target = 1
.0
def do_application_receive(self, parts):
self.logger.info("
receiving
application
stream
:
" + repr(parts))
...
...
@@ -104,10 +104,14 @@ class Daemon(object):
total_power = self.machine_info['energy']['power']['total']
# Publish the power values so that GRM can pick it up
self.nrm_publish_sock.send("
%
f" % (total_power))
nrm_topic = "
23.45
"
self.nrm_publish_sock.send("
%
s
%
s
" % (nrm_topic, str(total_power)))
self.logger.info("
Sending
power
values
:
" + str(total_power))
self.target = random.randrange(0, 34)
# Subcribe to the topic for new power allocations published by the GRM
# self.target = random.randrange(0, 34)
string = self.grm_publish_sock.recv()
topic, self.target = string.split()
self.logger.info("
target
measure
:
" + str(self.target))
for identity, application in self.applications.iteritems():
...
...
@@ -144,15 +148,21 @@ class Daemon(object):
context = zmq.Context()
socket = context.socket(zmq.STREAM)
self.nrm_publish_sock = context.socket(zmq.PUB)
self.grm_publish_sock = context.socket(zmq.SUB)
bind_param = "
tcp
:
//%
s
:
%
d
" % (bind_address, bind_port)
nrm_bind_param = "
tcp
:
//%
s
:
%
d
" % (bind_address, nrm_publish_port)
grm_bind_param = "
tcp
:
//
localhost
:
%
d
" % (grm_publish_port)
socket.bind(bind_param)
self.nrm_publish_sock.bind(nrm_bind_param)
self.grm_publish_sock.connect(grm_bind_param)
grm_filter = "
34.56
"
self.grm_publish_sock.setsockopt(zmq.SUBSCRIBE, grm_filter)
self.logger.info("
socket
bound
to
:
" + bind_param)
self.logger.info("
NRM
publish
socket
bound
to
:
" + nrm_bind_param)
self.logger.info("
GRM
publish
socket
connected
to
:
" + grm_bind_param)
self.stream = zmqstream.ZMQStream(socket)
self.stream.on_recv(self.do_application_receive)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment