Skip to content

Commit

Permalink
Add option for NetworkSender target host
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJKoopman committed Sep 8, 2019
1 parent 54a3dc6 commit fd79666
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions agents/smurf-stream-simulator/smurf_stream_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class SmurfStreamSimulator:
OCSAgent object which forms this Agent
log : txaio.tx.Logger
txaio logger ojbect, created by the OCSAgent
target_host : str
Target remote host address
port : int
Port to send data over
writer : spt3g.core.G3NetworkSender
Expand All @@ -67,13 +69,14 @@ class SmurfStreamSimulator:
List of simulated channels to stream
"""
def __init__(self, agent, port=4536, num_chans=528):
def __init__(self, agent, target_host="*", port=4536, num_chans=528):
self.agent = agent
self.log = agent.log

self.port = port

self.writer = core.G3NetworkSender(hostname="*", port=self.port)
self.writer = core.G3NetworkSender(hostname=target_host,
port=self.port)

self.is_streaming = False

Expand Down Expand Up @@ -155,6 +158,8 @@ def make_parser(parser=None):
pgroup.add_argument("--auto-start", default=False, type=bool,
help="Automatically start streaming at " +
"Agent startup.")
pgroup.add_argument("--target-host", default="*",
help="Target remote host.")
pgroup.add_argument("--port", default=50000,
help="Port to listen on.")
pgroup.add_argument("--num-chans", default=528,
Expand All @@ -171,7 +176,8 @@ def make_parser(parser=None):
site_config.reparse_args(args, 'SmurfStreamSimulator')

agent, runner = ocs_agent.init_site_agent(args)
sim = SmurfStreamSimulator(agent, port=int(args.port),
sim = SmurfStreamSimulator(agent, target_host=args.target_host,
port=int(args.port),
num_chans=int(args.num_chans))

agent.register_process('stream', sim.start_stream, sim.stop_stream,
Expand Down

0 comments on commit fd79666

Please sign in to comment.