Permalink
Browse files

Modified port_agent_process.py to handle new port agent config params…

… for botpt.
  • Loading branch information...
deverett committed May 2, 2013
1 parent cf57451 commit 24c9b43ecceae1a3acba1eb82e0571288fef8017
Showing with 35 additions and 10 deletions.
  1. +1 −1 buildout.cfg
  2. +34 −9 ion/agents/port/port_agent_process.py
View
@@ -62,7 +62,7 @@ cmds =
[port_agent]
path = ${port_agent_hack:path}
recipe = zc.recipe.cmmi
-url = https://github.com/deverett/port_agent/tarball/master
+url = https://github.com/ooici/port_agent/tarball/master
configure-options =
--prefix=${port_agent:path}
@@ -69,7 +69,14 @@ class PortAgentType(BaseEnum):
What type of port agent are we running? ethernet, serial, digi etc...
"""
ETHERNET = 'ethernet'
+ BOTPT = "botpt"
+class ObservatoryType(BaseEnum):
+ """
+ What type of port agent are we running? ethernet, serial, digi etc...
+ """
+ STANDARD = 'standard'
+ MULTI = 'multi'
class PortAgentProcess(object):
"""
@@ -339,14 +346,20 @@ def __init__(self, config, timeout = DEFAULT_TIMEOUT, test_mode = False):
self._config = config
self._timeout = timeout
self._test_mode = test_mode
-
+
# Verify our configuration is correct
+ self._observatory_type = config.get("observatory_type", ObservatoryType.STANDARD)
self._device_addr = config.get("device_addr")
self._device_port = config.get("device_port")
+ self._device_tx_port = config.get("device_tx_port")
+ self._device_rx_port = config.get("device_rx_port")
self._binary_path = config.get("binary_path", "port_agent")
self._command_port = config.get("command_port");
self._pa_addr = config.get("port_agent_addr");
+ """
+ DHE: need to be able to retrieve multiple data ports here
+ """
self._data_port = config.get("data_port");
self._log_level = config.get("log_level");
self._type = config.get("type", PortAgentType.ETHERNET)
@@ -357,21 +370,30 @@ def __init__(self, config, timeout = DEFAULT_TIMEOUT, test_mode = False):
if not self._device_addr:
raise PortAgentMissingConfig("missing config: device_addr")
- if not self._device_port:
- raise PortAgentMissingConfig("missing config: device_port")
+ if PortAgentType.BOTPT == self._type:
+ if not self._device_tx_port:
+ raise PortAgentMissingConfig("missing config: device_tx_port (BOTPT)")
+ if not self._device_rx_port:
+ raise PortAgentMissingConfig("missing config: device_rx_port (BOTPT)")
+ elif PortAgentType.ETHERNET == self._type:
+ if not self._device_port:
+ raise PortAgentMissingConfig("missing config: device_port (ETHERNET)")
+ else:
+ raise PortAgentLaunchException("unknown port agent type: %s" % self._type)
if not self._command_port:
raise PortAgentMissingConfig("missing config: command_port")
- if not self._data_port:
- raise PortAgentMissingConfig("missing config: data_port")
+ if ObservatoryType.MULTI == self._observatory_type:
+ if not self._data_port:
+ raise PortAgentMissingConfig("missing config: data_port")
+ else:
+ if not self._data_port:
+ raise PortAgentMissingConfig("missing config: data_port")
if not self._binary_path:
raise PortAgentMissingConfig("missing config: binary_path")
- if not self._type == PortAgentType.ETHERNET:
- raise PortAgentLaunchException("unknown port agent type: %s" % self._type)
-
self._tmp_config = self.get_config();
def get_config(self):
@@ -385,7 +407,10 @@ def get_config(self):
temp.write("log_dir %s\n" % (PROCESS_BASE_DIR))
temp.write("pid_dir %s\n" % (PROCESS_BASE_DIR))
temp.write("data_dir %s\n" % (PROCESS_BASE_DIR))
- temp.write("instrument_type tcp\n")
+ if PortAgentType.BOTPT == self._type:
+ temp.write("instrument_type botpt\n")
+ else:
+ temp.write("instrument_type tcp\n")
temp.write("instrument_data_port %d\n" % (self._device_port) )
temp.write("instrument_addr %s\n" % (self._device_addr) )
temp.write("data_port %d\n" % (self._data_port) )

0 comments on commit 24c9b43

Please sign in to comment.