Showing posts with label SWMM5 swmm5.def Summary. Show all posts
Showing posts with label SWMM5 swmm5.def Summary. Show all posts

Saturday, December 28, 2024

SWMM5 swmm5.def Summary

 Below is an overview of what this exports definition file indicates for SWMM5.DLL, typically found in a Windows DLL export definition (.def) file. It shows which functions are exported from the SWMM5 dynamic library and what their exported names (including calling conventions) are. In other words, this file tells consumers of SWMM5.DLL which routines they can call.


1. What Is a .def File?

In Windows development, a Module Definition File (.def file):

  • Lists all exported functions (the routines that can be called externally by programs or other libraries).
  • Potentially renames exports (e.g., = _swmm_close@0).
  • Allows controlling the ordinal and name of each export.

For SWMM5, this .def file ensures the C API functions of the SWMM engine are visible to external applications.


2. The Export List

LIBRARY     SWMM5.DLL

EXPORTS
    swmm_close                    = _swmm_close@0
    swmm_decodeDate               = _swmm_decodeDate@36
    swmm_end                      = _swmm_end@0
    swmm_getCount                 = _swmm_getCount@4
    swmm_getError                 = _swmm_getError@8
    swmm_getIndex                 = _swmm_getIndex@8
    swmm_getMassBalErr            = _swmm_getMassBalErr@12
    swmm_getName                  = _swmm_getName@16
    swmm_getSavedValue            = _swmm_getSavedValue@12
    swmm_getValue                 = _swmm_getValue@8
    swmm_getVersion               = _swmm_getVersion@0
    swmm_getWarnings              = _swmm_getWarnings@0
    swmm_open                     = _swmm_open@12
    swmm_report                   = _swmm_report@0
    swmm_run                      = _swmm_run@12
    swmm_setValue                 = _swmm_setValue@16
    swmm_start                    = _swmm_start@4
    swmm_step                     = _swmm_step@4
    swmm_stride                   = _swmm_stride@8
    swmm_writeLine                = _swmm_writeLine@4

2.1 Library Declaration

LIBRARY     SWMM5.DLL
  • Declares that the name of the library is SWMM5.DLL.

2.2 EXPORTS Section

  • Each line declares a function name, optionally followed by = _functionName@N, where:
    • functionName is how the function is known in user code (the “decorated” name in stdcall).
    • @N indicates the bytes of parameters on the stack (for example, _swmm_getError@8 typically means an stdcall function with 8 bytes of parameters).
    • For a C/C++ function using the __stdcall convention, the decorated name often looks like _functionName@stackbytes.

Below are descriptions of each function (these are typical from SWMM5’s C API, although details can vary slightly):

  1. swmm_close = _swmm_close@0
    Closes the opened SWMM project and frees memory.

  2. swmm_decodeDate = _swmm_decodeDate@36
    Decodes an internal SWMM datetime into year, month, day, hour, minute, second.

    • _@36 implies six parameters (6*4=24 bytes) plus possibly a return address, etc.
  3. swmm_end = _swmm_end@0
    Terminates a simulation after a swmm_start(). Typically calls internal housekeeping.

  4. swmm_getCount = _swmm_getCount@4
    Returns the number of objects (nodes, links, etc.) in a given category.

  5. swmm_getError = _swmm_getError@8
    Retrieves the last error code/message encountered.

  6. swmm_getIndex = _swmm_getIndex@8
    Retrieves the internal index of a named object (like a node name → index).

  7. swmm_getMassBalErr = _swmm_getMassBalErr@12
    Obtains system mass balance error after a run.

  8. swmm_getName = _swmm_getName@16
    Gets the name of an object from its index/type.

  9. swmm_getSavedValue = _swmm_getSavedValue@12
    Retrieves a saved result (e.g., flow, depth) for an object after or during a run.

  10. swmm_getValue = _swmm_getValue@8
    Gets a current simulation value for some property of a node/link.

  11. swmm_getVersion = _swmm_getVersion@0
    Returns the SWMM engine version code (e.g., 52004).

  12. swmm_getWarnings = _swmm_getWarnings@0
    Returns the number of warning messages encountered.

  13. swmm_open = _swmm_open@12
    Opens an input file and prepares data structures (typical signature: swmm_open(inFile, rptFile, outFile)).

  14. swmm_report = _swmm_report@0
    Writes the output reports (summary, statistics).

  15. swmm_run = _swmm_run@12
    A convenience function that calls swmm_open(), swmm_exec(), and swmm_close() in one shot.

  16. swmm_setValue = _swmm_setValue@16
    Sets a property for an object in the simulation (e.g., modifies parameters on-the-fly).

  17. swmm_start = _swmm_start@4
    Initializes simulation objects before stepping repeatedly.

  18. swmm_step = _swmm_step@4
    Executes one routing time step in SWMM (returns how much time actually advanced, or 0 if done).

  19. swmm_stride = _swmm_stride@8
    Possibly a variant of step that runs multiple steps at once or steps with a stride approach (depending on SWMM’s version).

  20. swmm_writeLine = _swmm_writeLine@4
    Writes a line of text to the SWMM report or output interface.


3. Why This .def File Matters

  • Windows exports: On Windows, __stdcall functions get decorated names, e.g. _function@N. A .def file can map a simpler C name (swmm_open) to that decorated name, ensuring external code can import the function by the simpler name.
  • This file ensures the DLL can be linked properly by external code that calls swmm_... functions.

4. Summary

This snippet:

  1. Declares the library name: SWMM5.DLL.
  2. Defines which C API functions SWMM exposes to external software:
    • Opening/Closing/Running SWMM simulations,
    • Getting/Setting object data (like node flows, index lookups),
    • Retrieving error info, version, mass balance, etc.
  3. Uses the calling convention and decoration typical for __stdcall functions on Windows.

Hence, end-users wanting to dynamically link against SWMM5.DLL can call these functions (like swmm_run) to control a SWMM simulation, query results, or modify parameters at runtime.

InfoSWMM: A 2030 AI-Assisted Study Guide

  InfoSWMM: A 2030 AI-Assisted Study Guide delete   InfoSWMM: A 2030 AI-Assisted Study Guide A comprehensive study guide for someone in 2030...