当前位置: 首页>>代码示例>>Python>>正文


Python NetworkUtil.serialize_network_definition方法代码示例

本文整理汇总了Python中ion.agents.platform.util.network_util.NetworkUtil.serialize_network_definition方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkUtil.serialize_network_definition方法的具体用法?Python NetworkUtil.serialize_network_definition怎么用?Python NetworkUtil.serialize_network_definition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ion.agents.platform.util.network_util.NetworkUtil的用法示例。


在下文中一共展示了NetworkUtil.serialize_network_definition方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_build_network_definition

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def test_build_network_definition(self):
        ndef = RsnOmsUtil.build_network_definition(self._rsn_oms)

        if log.isEnabledFor(logging.TRACE):
            # serialize object to string
            serialization = NetworkUtil.serialize_network_definition(ndef)
            log.trace("NetworkDefinition serialization:\n%s", serialization)

        if not isinstance(self._rsn_oms, CIOMSSimulator):
            # OK, no more tests if we are not using the embedded simulator
            return

        # Else: do some verifications against network.yml (the spec used by
        # the simulator):

        self.assertTrue("UPS" in ndef.platform_types)

        pnode = ndef.root

        self.assertEqual(pnode.platform_id, "ShoreStation")
        self.assertTrue("ShoreStation_attr_1" in pnode.attrs)
        self.assertTrue("ShoreStation_port_1" in pnode.ports)

        sub_pnodes = pnode.subplatforms
        self.assertTrue("L3-UPS1" in sub_pnodes)
        self.assertTrue("Node1A" in sub_pnodes)
        self.assertTrue("input_voltage" in sub_pnodes["Node1A"].attrs)
        self.assertTrue("Node1A_port_1" in sub_pnodes["Node1A"].ports)
开发者ID:blazetopher,项目名称:coi-services,代码行数:30,代码来源:test_oms_util.py

示例2: setUp

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def setUp(self):
        self._start_container()

        self.container.start_rel_from_url('res/deploy/r2deploy.yml')

        self.RR   = ResourceRegistryServiceClient(node=self.container.node)
        self.IMS  = InstrumentManagementServiceClient(node=self.container.node)
        self.DAMS = DataAcquisitionManagementServiceClient(node=self.container.node)
        self.DP   = DataProductManagementServiceClient(node=self.container.node)
        self.PSC  = PubsubManagementServiceClient(node=self.container.node)
        self.PDC  = ProcessDispatcherServiceClient(node=self.container.node)
        self.DSC  = DatasetManagementServiceClient()
        self.IDS  = IdentityManagementServiceClient(node=self.container.node)
        self.RR2  = EnhancedResourceRegistryClient(self.RR)


        # Use the network definition provided by RSN OMS directly.
        rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri'])
        self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms)
        # get serialized version for the configuration:
        self._network_definition_ser = NetworkUtil.serialize_network_definition(self._network_definition)
        if log.isEnabledFor(logging.TRACE):
            log.trace("NetworkDefinition serialization:\n%s", self._network_definition_ser)


        self._async_data_result = AsyncResult()
        self._data_subscribers = []
        self._samples_received = []
        self.addCleanup(self._stop_data_subscribers)

        self._async_event_result = AsyncResult()
        self._event_subscribers = []
        self._events_received = []
        self.addCleanup(self._stop_event_subscribers)
        self._start_event_subscriber()
开发者ID:newbrough,项目名称:coi-services,代码行数:37,代码来源:test_platform_launch.py

示例3: setUp

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def setUp(self):
        self.DVR_CONFIG = {
            'oms_uri':    self._dispatch_simulator('launchsimulator'),
            'attributes': {},
            'ports':      {}
        }
        log.debug("DVR_CONFIG['oms_uri'] = %s", self.DVR_CONFIG['oms_uri'])

        yaml_filename = 'ion/agents/platform/rsn/simulator/network.yml'
        log.debug("retrieving network definition from %s", yaml_filename)
        network_definition = NetworkUtil.deserialize_network_definition(file(yaml_filename))

        if log.isEnabledFor(logging.DEBUG):
            network_definition_ser = NetworkUtil.serialize_network_definition(network_definition)
            log.debug("NetworkDefinition serialization:\n%s", network_definition_ser)

        platform_id = self.PLATFORM_ID
        pnode = network_definition.pnodes[platform_id]

        def evt_recv(driver_event):
            log.debug('GOT driver_event=%s', str(driver_event))

        self._plat_driver = RSNPlatformDriver(pnode, evt_recv, Mock(), Mock())
        res_state = self._plat_driver.get_resource_state()
        self.assertEqual(res_state, RSNPlatformDriverState.UNCONFIGURED)
开发者ID:ednad,项目名称:coi-services,代码行数:27,代码来源:test_rsn_platform_driver.py

示例4: setUp

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def setUp(self):
        self._start_container()

        self.container.start_rel_from_url('res/deploy/r2deploy.yml')

        self.RR   = ResourceRegistryServiceClient(node=self.container.node)
        self.IMS  = InstrumentManagementServiceClient(node=self.container.node)
        self.DAMS = DataAcquisitionManagementServiceClient(node=self.container.node)
        self.DP   = DataProductManagementServiceClient(node=self.container.node)
        self.PSC  = PubsubManagementServiceClient(node=self.container.node)
        self.PDC  = ProcessDispatcherServiceClient(node=self.container.node)
        self.DSC  = DatasetManagementServiceClient()
        self.IDS  = IdentityManagementServiceClient(node=self.container.node)
        self.RR2  = EnhancedResourceRegistryClient(self.RR)

        self.org_id = self.RR2.create(any_old(RT.Org))
        log.debug("Org created: %s", self.org_id)

        # Use the network definition provided by RSN OMS directly.
        rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri'])
        self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms)
        CIOMSClientFactory.destroy_instance(rsn_oms)

        # get serialized version for the configuration:
        self._network_definition_ser = NetworkUtil.serialize_network_definition(self._network_definition)
        log.trace("NetworkDefinition serialization:\n%s", self._network_definition_ser)

        # set attributes for the platforms:
        self._platform_attributes = {}
        for platform_id in self._network_definition.pnodes:
            pnode = self._network_definition.pnodes[platform_id]
            dic = dict((attr.attr_id, attr.defn) for attr in pnode.attrs.itervalues())
            self._platform_attributes[platform_id] = dic
        log.trace("_platform_attributes: %s", self._platform_attributes)

        # set ports for the platforms:
        self._platform_ports = {}
        for platform_id in self._network_definition.pnodes:
            pnode = self._network_definition.pnodes[platform_id]
            dic = {}
            for port_id, port in pnode.ports.iteritems():
                dic[port_id] = dict(port_id=port_id,
                                    network=port.network)
            self._platform_ports[platform_id] = dic
        log.trace("_platform_ports: %s", self._platform_attributes)

        self._async_data_result = AsyncResult()
        self._data_subscribers = []
        self._samples_received = []
        self.addCleanup(self._stop_data_subscribers)

        self._async_event_result = AsyncResult()
        self._event_subscribers = []
        self._events_received = []
        self.addCleanup(self._stop_event_subscribers)
        self._start_event_subscriber()
开发者ID:mbarry02,项目名称:coi-services,代码行数:58,代码来源:base_test_platform_agent_with_rsn.py

示例5: test_serialization_deserialization

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def test_serialization_deserialization(self):
        # create NetworkDefinition object by de-serializing the simulated network:
        ndef = NetworkUtil.deserialize_network_definition(
                file('ion/agents/platform/rsn/simulator/network.yml'))

        # serialize object to string
        serialization = NetworkUtil.serialize_network_definition(ndef)

        # recreate object by de-serializing the string:
        ndef2 = NetworkUtil.deserialize_network_definition(serialization)

        # verify the objects are equal:
        self.assertEquals(ndef.diff(ndef2), None)
开发者ID:blazetopher,项目名称:coi-services,代码行数:15,代码来源:test_network_util.py

示例6: setUp

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def setUp(self):

        # Use the network definition provided by RSN OMS directly.
        rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri'])
        network_definition = RsnOmsUtil.build_network_definition(rsn_oms)

        if log.isEnabledFor(logging.DEBUG):
            network_definition_ser = NetworkUtil.serialize_network_definition(network_definition)
            log.debug("NetworkDefinition serialization:\n%s", network_definition_ser)

        platform_id = self.PLATFORM_ID
        pnode = network_definition.pnodes[platform_id]
        self._plat_driver = RSNPlatformDriver(pnode, self.evt_recv)
开发者ID:blazetopher,项目名称:coi-services,代码行数:15,代码来源:test_oms_platform_driver.py

示例7: setUp

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def setUp(self):

        DVR_CONFIG['oms_uri'] = self._dispatch_simulator(oms_uri)
        log.debug("DVR_CONFIG['oms_uri'] = %s", DVR_CONFIG['oms_uri'])

        yaml_filename = 'ion/agents/platform/rsn/simulator/network.yml'
        log.debug("retrieving network definition from %s", yaml_filename)
        network_definition = NetworkUtil.deserialize_network_definition(file(yaml_filename))

        if log.isEnabledFor(logging.DEBUG):
            network_definition_ser = NetworkUtil.serialize_network_definition(network_definition)
            log.debug("NetworkDefinition serialization:\n%s", network_definition_ser)

        platform_id = self.PLATFORM_ID
        pnode = network_definition.pnodes[platform_id]
        self._plat_driver = RSNPlatformDriver(pnode, self.evt_recv)
开发者ID:StevenMyerson,项目名称:marine-integrations,代码行数:18,代码来源:test_rsn_platform_driver.py

示例8: setUpClass

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def setUpClass(cls):
        HelperTestMixin.setUpClass()

        # Use the network definition provided by RSN OMS directly.
        rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG["oms_uri"])
        network_definition = RsnOmsUtil.build_network_definition(rsn_oms)
        network_definition_ser = NetworkUtil.serialize_network_definition(network_definition)
        if log.isEnabledFor(logging.DEBUG):
            log.debug("NetworkDefinition serialization:\n%s", network_definition_ser)

        cls.PLATFORM_CONFIG = {
            "platform_id": cls.PLATFORM_ID,
            "driver_config": DVR_CONFIG,
            "network_definition": network_definition_ser,
        }

        NetworkUtil._gen_open_diagram(network_definition.pnodes[cls.PLATFORM_ID])
开发者ID:newbrough,项目名称:coi-services,代码行数:19,代码来源:test_platform_agent_with_oms.py

示例9: __init__

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def __init__(self, def_file, events_file, host, port, inactivity_period):
        """
        Creates a SimpleXMLRPCServer and starts a Thread where serve_forever
        is called on the server.

        @param def_file      Platform network definition file
        @param events_file   File with events to be published
        @param host   Hostname for the service
        @param port   Port for the service
        """
        log.info("Definition file: %s", def_file)
        log.info("Events file:     %s", events_file)

        self._running = True
        self._sim = CIOMSSimulatorWithExit(self, def_file, events_file)

        if log.isEnabledFor(logging.DEBUG):
            ser = NetworkUtil.serialize_network_definition(self._sim._ndef)
            log.debug("network serialization:\n   %s" % ser.replace('\n', '\n   '))

        self._server = SimpleXMLRPCServer((host, port), allow_none=True)

        actual_port = self._server.socket.getsockname()[1]
        uri = "http://%s:%s/" % (host, actual_port)

        # write the URI to a file for launching process to see it:
        with open("logs/rsn_oms_simulator.yml", 'w') as f:
            f.write("rsn_oms_simulator_uri=%s\n" % uri)

        self._server.register_introspection_functions()
        self._server.register_instance(self._sim, allow_dotted_names=True)

        log.info("Methods: %s", self._server.system_listMethods())

        self._check_pyon()

        runnable = Thread(target=self._server.serve_forever)
        runnable.setDaemon(True)
        runnable.start()

        log.info("OMS simulator xmlrpc server listening on %s" % uri)

        if inactivity_period:
            self._sim.x_exit_inactivity(inactivity_period)
开发者ID:ednad,项目名称:coi-services,代码行数:46,代码来源:oms_simulator_server.py

示例10: setUp

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def setUp(self):
        self._start_container()

        self.container.start_rel_from_url('res/deploy/r2deploy.yml')

        self.rrclient = ResourceRegistryServiceClient(node=self.container.node)
        self.omsclient = ObservatoryManagementServiceClient(node=self.container.node)
        self.imsclient = InstrumentManagementServiceClient(node=self.container.node)
        self.damsclient = DataAcquisitionManagementServiceClient(node=self.container.node)
        self.dpclient = DataProductManagementServiceClient(node=self.container.node)
        self.pubsubcli = PubsubManagementServiceClient(node=self.container.node)
        self.processdispatchclient = ProcessDispatcherServiceClient(node=self.container.node)
        self.dataprocessclient = DataProcessManagementServiceClient(node=self.container.node)
        self.dataset_management = DatasetManagementServiceClient()


        # Use the network definition provided by RSN OMS directly.
        rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri'])
        self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms)
        # get serialized version for the configuration:
        self._network_definition_ser = NetworkUtil.serialize_network_definition(self._network_definition)
        if log.isEnabledFor(logging.DEBUG):
            log.debug("NetworkDefinition serialization:\n%s", self._network_definition_ser)



        self.platformModel_id = None

        self.all_platforms = {}
        self.agent_streamconfig_map = {}

        self._async_data_result = AsyncResult()
        self._data_subscribers = []
        self._samples_received = []
        self.addCleanup(self._stop_data_subscribers)

        self._async_event_result = AsyncResult()
        self._event_subscribers = []
        self._events_received = []
        self.addCleanup(self._stop_event_subscribers)
        self._start_event_subscriber()

        self._set_up_DataProduct_obj()
        self._set_up_PlatformModel_obj()
开发者ID:newbrough,项目名称:coi-services,代码行数:46,代码来源:test_oms_launch2.py

示例11: int

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    parser.add_argument("-H", "--host",
                        help="host (default: %s)" % DEFAULT_HOST,
                        default=DEFAULT_HOST)
    parser.add_argument("-P", "--port",
                        help="port (default: %s)" % DEFAULT_PORT,
                        default=DEFAULT_PORT)

    opts = parser.parse_args()

    host = opts.host
    port = int(opts.port)

    oss = CIOMSSimulatorServer(host, port, thread=True)
    sim = oss.oms_simulator

    ser = NetworkUtil.serialize_network_definition(sim._ndef)
    log.info("network serialization:\n   %s" % ser.replace('\n', '\n   '))
    log.info("network.get_map() = %s\n" % sim.config.get_platform_map())

    log.info("Methods:\n\t%s", "\n\t".join(oss.methods))

    log.info("Listening on %s:%s", host, port)
    log.info("Enter ^D to exit")
    try:
        sys.stdin.read()
    except KeyboardInterrupt:
        pass
    except Exception, e:
        # likely not associated with a terminal
        pass
    log.info("\nExiting")
开发者ID:blazetopher,项目名称:coi-services,代码行数:33,代码来源:oms_simulator_server.py

示例12: setUp

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]
    def setUp(self):
        self._start_container()

        self.container.start_rel_from_url('res/deploy/r2deploy.yml')

        self.RR   = ResourceRegistryServiceClient(node=self.container.node)
        self.IMS  = InstrumentManagementServiceClient(node=self.container.node)
        self.DAMS = DataAcquisitionManagementServiceClient(node=self.container.node)
        self.DP   = DataProductManagementServiceClient(node=self.container.node)
        self.PSC  = PubsubManagementServiceClient(node=self.container.node)
        self.PDC  = ProcessDispatcherServiceClient(node=self.container.node)
        self.DSC  = DatasetManagementServiceClient()
        self.IDS  = IdentityManagementServiceClient(node=self.container.node)
        self.RR2  = EnhancedResourceRegistryClient(self.RR)

        self.org_id = self.RR2.create(any_old(RT.Org))
        log.debug("Org created: %s", self.org_id)

        # Create InstrumentModel
        # TODO create multiple models as needed; for the moment assuming all
        # used instruments are the same model here.
        instModel_obj = IonObject(RT.InstrumentModel,
                                  name='SBE37IMModel',
                                  description="SBE37IMModel")
        self.instModel_id = self.IMS.create_instrument_model(instModel_obj)
        log.debug('new InstrumentModel id = %s ', self.instModel_id)

        # Use the network definition provided by RSN OMS directly.
        rsn_oms = CIOMSClientFactory.create_instance(DVR_CONFIG['oms_uri'])
        self._network_definition = RsnOmsUtil.build_network_definition(rsn_oms)
        CIOMSClientFactory.destroy_instance(rsn_oms)

        if log.isEnabledFor(logging.TRACE):
            # show serialized version for the network definition:
            network_definition_ser = NetworkUtil.serialize_network_definition(self._network_definition)
            log.trace("NetworkDefinition serialization:\n%s", network_definition_ser)

        # set attributes for the platforms:
        self._platform_attributes = {}
        for platform_id in self._network_definition.pnodes:
            pnode = self._network_definition.pnodes[platform_id]
            dic = dict((attr.attr_id, attr.defn) for attr in pnode.attrs.itervalues())
            self._platform_attributes[platform_id] = dic
        log.trace("_platform_attributes: %s", self._platform_attributes)

        # set ports for the platforms:
        self._platform_ports = {}
        for platform_id in self._network_definition.pnodes:
            pnode = self._network_definition.pnodes[platform_id]
            dic = {}
            for port_id, port in pnode.ports.iteritems():
                dic[port_id] = dict(port_id=port_id,
                                    network=port.network)
            self._platform_ports[platform_id] = dic
        log.trace("_platform_ports: %s", self._platform_attributes)

        self._async_data_result = AsyncResult()
        self._data_subscribers = []
        self._samples_received = []
        self.addCleanup(self._stop_data_subscribers)

        self._async_event_result = AsyncResult()
        self._event_subscribers = []
        self._events_received = []
        self.addCleanup(self._stop_event_subscribers)
        self._start_event_subscriber(sub_type="platform_event")

        # instruments that have been set up: instr_key: i_obj
        self._setup_instruments = {}
开发者ID:jamie-cyber1,项目名称:coi-services,代码行数:71,代码来源:base_test_platform_agent_with_rsn.py

示例13: test_create_network_definition_from_ci_config

# 需要导入模块: from ion.agents.platform.util.network_util import NetworkUtil [as 别名]
# 或者: from ion.agents.platform.util.network_util.NetworkUtil import serialize_network_definition [as 别名]

#.........这里部分代码省略.........
                                                                                                                'monitor_cycle_seconds': 5,
                                                                                                                'read_write': 'read',
                                                                                                                'type': 'int',
                                                                                                                'units': 'xyz'},
                                                                                               'MJ01C_attr_2': {'attr_id': 'MJ01C_attr_2',
                                                                                                                'group': 'power',
                                                                                                                'max_val': 10,
                                                                                                                'min_val': -2,
                                                                                                                'monitor_cycle_seconds': 5,
                                                                                                                'read_write': 'write',
                                                                                                                'type': 'int',
                                                                                                                'units': 'xyz'}},
                                                                                'dvr_cls': 'RSNPlatformDriver',
                                                                                'dvr_mod': 'ion.agents.platform.rsn.rsn_platform_driver',
                                                                                'oms_uri': 'embsimulator',
                                                                                'ports': {'MJ01C_port_1': {'port_id': 'MJ01C_port_1'},
                                                                                          'MJ01C_port_2': {'port_id': 'MJ01C_port_2'}}},

                                                              'children': {'d0203cb9eb844727b7a8eea77db78e89': {'agent': {'resource_id': 'd0203cb9eb844727b7a8eea77db78e89'},
                                                                                                                'platform_config': {'platform_id': 'LJ01D'},
                                                                                                                'device_type': 'PlatformDevice',
                                                                                                                'driver_config': {'attributes': {'MVPC_pressure_1': {'attr_id': 'MVPC_pressure_1',
                                                                                                                                                                     'group': 'pressure',
                                                                                                                                                                     'max_val': 33.8,
                                                                                                                                                                     'min_val': -3.8,
                                                                                                                                                                     'monitor_cycle_seconds': 10,
                                                                                                                                                                     'precision': 0.04,
                                                                                                                                                                     'read_write': 'read',
                                                                                                                                                                     'type': 'float',
                                                                                                                                                                     'units': 'PSI'},
                                                                                                                                                 'MVPC_temperature': {'attr_id': 'MVPC_temperature',
                                                                                                                                                                      'group': 'temperature',
                                                                                                                                                                      'max_val': 58.5,
                                                                                                                                                                      'min_val': -1.5,
                                                                                                                                                                      'monitor_cycle_seconds': 10,
                                                                                                                                                                      'precision': 0.06,
                                                                                                                                                                      'read_write': 'read',
                                                                                                                                                                      'type': 'float',
                                                                                                                                                                      'units': 'Degrees C'},
                                                                                                                                                 'input_bus_current': {'attr_id': 'input_bus_current',
                                                                                                                                                                       'group': 'power',
                                                                                                                                                                       'max_val': 50,
                                                                                                                                                                       'min_val': -50,
                                                                                                                                                                       'monitor_cycle_seconds': 5,
                                                                                                                                                                       'precision': 0.1,
                                                                                                                                                                       'read_write': 'write',
                                                                                                                                                                       'type': 'float',
                                                                                                                                                                       'units': 'Amps'},
                                                                                                                                                 'input_voltage': {'attr_id': 'input_voltage',
                                                                                                                                                                   'group': 'power',
                                                                                                                                                                   'max_val': 500,
                                                                                                                                                                   'min_val': -500,
                                                                                                                                                                   'monitor_cycle_seconds': 5,
                                                                                                                                                                   'precision': 1,
                                                                                                                                                                   'read_write': 'read',
                                                                                                                                                                   'type': 'float',
                                                                                                                                                                   'units': 'Volts'}},
                                                                                                                                  'dvr_cls': 'RSNPlatformDriver',
                                                                                                                                  'dvr_mod': 'ion.agents.platform.rsn.rsn_platform_driver',
                                                                                                                                  'oms_uri': 'embsimulator',
                                                                                                                                  'ports': {'LJ01D_port_1': {'port_id': '1'},
                                                                                                                                            'LJ01D_port_2': {'port_id': '2'}}},
                                                                                                                'children': {},
                                                                                                                }
                                                              }
                                                             }
            }
        })

        ndef = NetworkUtil.create_network_definition_from_ci_config(CFG)

        if log.isEnabledFor(logging.TRACE):
            serialization = NetworkUtil.serialize_network_definition(ndef)
            log.trace("serialization = \n%s", serialization)

        self.assertIn('Node1D', ndef.pnodes)
        Node1D = ndef.pnodes['Node1D']

        common_attr_names = ['MVPC_pressure_1', 'MVPC_temperature',
                             'input_bus_current', 'input_voltage' ]

        for attr_name in common_attr_names:
            self.assertIn(attr_name, Node1D.attrs)

        #todo complete the network definition: align ports defintion with internal representation.
        #for port_name in ['Node1D_port_1', 'Node1D_port_2']:
        #    self.assertIn(port_name, Node1D.ports)

        for subplat_name in ['MJ01C', ]:
            self.assertIn(subplat_name, Node1D.subplatforms)

        MJ01C = Node1D.subplatforms['MJ01C']

        for subplat_name in ['LJ01D', ]:
            self.assertIn(subplat_name, MJ01C.subplatforms)

        LJ01D = MJ01C.subplatforms['LJ01D']

        for attr_name in common_attr_names:
            self.assertIn(attr_name, LJ01D.attrs)
开发者ID:ednad,项目名称:coi-services,代码行数:104,代码来源:test_network_util.py


注:本文中的ion.agents.platform.util.network_util.NetworkUtil.serialize_network_definition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。