Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@chzam1
Copy link
Owner

@chzam1 chzam1 commented Aug 4, 2025

No description provided.

…t_ instead; remove unused member: mePlatform
…the same and different parts in initialize() with comments
…ecServiceBase

Motivation:
The MecServiceBase descendants UALCMPApp and ServiceRegistry are not used MecServiceBase::initialize().
The initialize in these modules contains some copyed code from MecServiceBase::initialize().
…ameter to componentCarrierModule parameter.

old: The componentCarrierIndex specified the module carrierAggregation.componentCarrier[<componentCarrierIndex>]
new: componentCarrierModule specifies the path to ComponentCarrier module
…ponentCarrierIndex NED parameter to componentCarrierModule parameter.'
…ifecycle support is unimplemented in module)
…ed by MecAppBase.cc, moved these to MecAppBase.ned
…ed by these descendants: MecRnisTestApp and MECWarningAlertApp
michele-segata and others added 30 commits January 22, 2025 15:30
…apps by using pre-defined device application ids
…ket::connect()

/simulations/NR/mec/multiMecHost -f omnetpp.ini -c MultiMec -r 0
  (runtime error with exitcode=1: <!> Error: TcpSocket::connect():
  connect() or listen() already called (need renewSocket()?)
  -- in module (simu5g::MECWarningAlertApp) MultiMecHost.mecHost1.MECWarningAlertApp)
changed by last few commits
And adjusted includes/imports.

Used the following python script:

import os
import re
import shutil
import argparse
from pathlib import Path

def find_simple_modules(base_path):
    """Find all simple module definitions in .ned files"""
    simple_modules = []

    for ned_file in Path(base_path).rglob('*.ned'):
        with open(ned_file, 'r', encoding='utf-8') as f:
            content = f.read()
            # Find simple module definitions
            # Pattern matches: simple ModuleName [extends Something] {
            matches = re.finditer(r'simple\s+(\w+)(?:\s+extends\s+\w+)?\s*{', content)
            for match in matches:
                module_name = match.group(1)
                simple_modules.append({
                    'module_name': module_name,
                    'file_path': str(ned_file),
                    'directory': str(ned_file.parent)
                })
    return simple_modules

def find_cpp_implementations(base_path):
    """Find all C++ class implementations using Define_Module macro"""
    cpp_modules = []

    for cc_file in Path(base_path).rglob('*.cc'):
        with open(cc_file, 'r', encoding='utf-8') as f:
            content = f.read()
            # Find Define_Module macro usages
            matches = re.finditer(r'Define_Module\((\w+)\)', content)
            for match in matches:
                class_name = match.group(1)
                # Also find the corresponding .h file
                h_file = cc_file.parent / (cc_file.stem + '.h')
                cpp_modules.append({
                    'class_name': class_name,
                    'cc_file': str(cc_file),
                    'h_file': str(h_file) if h_file.exists() else None,
                    'directory': str(cc_file.parent)
                })
    return cpp_modules

def find_mismatched_modules(base_path):
    """Find modules where .ned and .cc files are in different directories"""
    simple_modules = find_simple_modules(base_path)
    cpp_modules = find_cpp_implementations(base_path)

    # Create lookup dictionary for C++ implementations
    cpp_lookup = {m['class_name']: m for m in cpp_modules}

    mismatches = []
    for ned_module in simple_modules:
        module_name = ned_module['module_name']
        if module_name in cpp_lookup:
            cpp_module = cpp_lookup[module_name]
            if ned_module['directory'] != cpp_module['directory']:
                mismatches.append({
                    'module_name': module_name,
                    'ned_file': ned_module['file_path'],
                    'ned_dir': ned_module['directory'],
                    'cc_file': cpp_module['cc_file'],
                    'h_file': cpp_module['h_file']
                })

    return mismatches

def move_files(mismatches):
    """Move mismatched files to their corresponding .ned locations"""
    moved_files = []
    for mm in mismatches:
        ned_dir = mm['ned_dir']

        # Move .cc file
        cc_file = Path(mm['cc_file'])
        new_cc_path = Path(ned_dir) / cc_file.name
        try:
            shutil.move(str(cc_file), str(new_cc_path))
            moved_files.append(f"Moved {cc_file.name} to {ned_dir}")
        except Exception as e:
            print(f"Error moving {cc_file}: {e}")

        # Move .h file if it exists
        if mm['h_file']:
            h_file = Path(mm['h_file'])
            new_h_path = Path(ned_dir) / h_file.name
            try:
                shutil.move(str(h_file), str(new_h_path))
                moved_files.append(f"Moved {h_file.name} to {ned_dir}")
            except Exception as e:
                print(f"Error moving {h_file}: {e}")

    return moved_files

def main():
    parser = argparse.ArgumentParser(description='Find and optionally move mismatched OMNeT++ module files')
    parser.add_argument('--move', action='store_true', help='Move files to their corresponding .ned locations')
    args = parser.parse_args()

    base_path = os.path.dirname(os.path.abspath(__file__))
    mismatches = find_mismatched_modules(base_path)

    if not mismatches:
        print("No mismatched module implementations found!")
        return

    print("Found mismatched module implementations:")
    print("-" * 80)
    for mm in mismatches:
        print(f"Module: {mm['module_name']}")
        print(f"  NED file: {mm['ned_file']}")
        print(f"  C++ file: {mm['cc_file']}")
        if mm['h_file']:
            print(f"  H file: {mm['h_file']}")
        print("-" * 80)

    if args.move:
        print("\nMoving files to their corresponding .ned locations...")
        moved = move_files(mismatches)
        print("\nMoved files:")
        for move in moved:
            print(move)

if __name__ == '__main__':
    main()
They are sensitive to modules being moved to a different package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants