Пример #1
0
    def ini_channel(self):
        '''
        Func: After the nodes have been created for the network, generate a channel module for 
        each node. The channel module will be used to manage the channel information from the node 
        to each of the other nodes in the network
        '''

        # Check if the channel module has been created, do nothing if yes
        if self.channel is not None:
            print(
                'Warning: The channel module has already been created for {}'.
                format(self.type))
            return 0

        # Otherwise, create the channel module for the node
        ###################################################################
        elmt_name = self.type + '_' + net_name.chnl
        elmt_type = net_name.chnl
        elmt_num = 1  # Dummy parameter

        # network topology info, 1 network created
        addi_info = {'ntwk': self.ntwk, 'parent': self}
        info = net_func.mkinfo(elmt_name, elmt_type, elmt_num, addi_info)

        # create node object
        chnl_obj = net_channel.channel(info)
        ###################################################################

        # update the channel module for this node
        self.channel = chnl_obj
        print('Channel modulate created for node {}'.format(self.type))
Пример #2
0
    def new_blockage(block_name, block_type):
        ###################################################################
        elmt_name = block_name
        elmt_type = block_type
        elmt_num = 1  # Dummy parameter

        # network topology info, 1 network created
        addi_info = {'ntwk': self.ntwk, 'parent': self.ntwk}
        info = net_func.mkinfo(elmt_name, elmt_type, elmt_num, addi_info)

        # create node object
        blk_obj = net_blk.blockage(info)  # create the node object
Пример #3
0
def new_ntwk(ntwk_type=None):
    '''
    create a network of the specified network type
    '''
    elmt_name = net_name.ntwk
    elmt_type = ntwk_type
    elmt_num = 1

    # network topology info, 1 network created
    addi_info = {'ntwk': None, 'parent': None}
    info = net_func.mkinfo(elmt_name, elmt_type, elmt_num, addi_info)

    # create network
    return net_ntwk(info)
Пример #4
0
def new_group(ntwk_obj, group_name):
    '''
    Func: create a group for base station
    ntwk_obj: the object of the network to which the group is added
    group_name: the name of the group to be created
    '''
    elmt_name = group_name
    elmt_type = None  # Dummy parameter
    elmt_num = 1  # Dummy parameter

    # network topology info, 1 network created
    addi_info = {'ntwk': ntwk_obj, 'parent': ntwk_obj}
    info = net_func.mkinfo(elmt_name, elmt_type, elmt_num, addi_info)

    # create the group
    return node_group(info)
Пример #5
0
def new_gui(ntwk = None):
    '''
    create a GUI for the network
    ntwk: The network object for which the GUI is created
    '''
    #####################################################
    elmt_name = net_name.gui
    elmt_type = net_name.gui
    elmt_num  = 1    
    
    # network topology info, 1 network created
    addi_info = {'ntwk':ntwk, 'parent':ntwk}
    info = net_func.mkinfo(elmt_name, elmt_type, elmt_num, addi_info)    
    
    obj_gui = gui(info)
    #####################################################
    # create network
    return obj_gui  
Пример #6
0
    def ini_channel_2node(self):
        print('Initializing channels from {} to all the other nodes...'.format(
            self.parent.type))

        # Loop over all nodes in the network
        for node_name in self.ntwk.name_list_all_nodes:

            # No need to consider the channel from a node to itself
            if node_name == self.parent.type:
                continue

            # Otherwise, create the channel module for the node
            ###################################################################
            # Construct a unique channel name with the names of two nodes
            elmt_name = self.get_name_chanl_2node(self.parent.type, node_name)

            # If the channel module has been created, skip
            # This may happen since only one channel needed for each pair of nodes
            if elmt_name in self.ntwk.name_list_all_n2n_chnl:
                continue

            elmt_type = net_name.chnl_n2n
            elmt_num = 1  # Dummy parameter

            # network topology info, 1 network created
            addi_info = {
                'ntwk': self.ntwk,
                'parent': self,
                'node1': self.parent.type,
                'node2': node_name
            }
            info = net_func.mkinfo(elmt_name, elmt_type, elmt_num, addi_info)

            # create node object
            chnl_obj = net_channel.channel_node2node(info)
            ###################################################################

            # Add the channel name to the overall list maintained by the network
            self.ntwk.name_list_all_n2n_chnl.append(elmt_name)
            print('{} created.'.format(elmt_name))
Пример #7
0
    def add_node(self, node_type, num_node):
        '''
        func: add new nodes to the group. For each new node, an new object will be created based on the 
        definition class
        node_type: the type of node to be added: BS, EU,...
        num_node: the number of nodes to be added
        '''

        # Construct the name of the node type
        #print('Adding '+node_type+'...')

        # Add node one by one, num_node will be added in total
        # node_id starts from 1 rather than 0
        for node_id_minus_1 in range(num_node):
            node_id = node_id_minus_1 + 1

            # construct the name of current node
            node_name = self.get_node_name(node_type, node_id)

            ###################################################################
            elmt_name = node_name
            elmt_type = node_type
            elmt_num = 1  # Dummy parameter

            # network topology info, 1 network created
            addi_info = {'ntwk': self.ntwk, 'parent': self, 'node_id': node_id}
            info = net_func.mkinfo(elmt_name, elmt_type, elmt_num, addi_info)

            # create node object
            def_class = getattr(
                net_node,
                node_type)  # first, get the defining class for the node type
            node_obj = def_class(info)  # second, create the node object
            #node_obj  = net_node.node(info)

            # add the node to the corresponding group
            self.addmember(elmt_name)