How mayankchetan/discon-wrapper works
Project type and purpose
• This is a full-stack, multi-service Go application (“DISCON-Wrapper”) for bridging 32-bit wind turbine Controller DLLs into 64-bit simulation applications (OpenFAST).
• It comprises three primary services:
• discon-client: a 64-bit shared‐library plugin (DLL) loaded by OpenFAST
• discon-server: a 32-bit server process that loads the legacy Controller DLL and proxies calls over WebSockets
• discon-manager: a browser-based admin web application to configure, monitor, and orchestrate server instances
File structure
• Top-level directories and files:
• discon-client/ (client.go)
• discon-server/ (server.go, websocket.go, load_shared_library.c)
• discon-manager/ (main.go, admin.go, config.go, docker.go, templates/, config/, db/)
• shared/ (shared/utils)
• Dockerfiles (for manager, server, rosco), docker-compose.yml
• docs/ (Sphinx-based documentation, including dedicated pages for each component)
• Patterns & configurations:
• discon-manager uses MVC (Go templates + controllers + JSON “database”)
• discon-server uses a WebSocket RPC pattern to marshal/unmarshal payloads (payload.go)
• Docker-compose orchestrates three containers: manager, server, rosco
README for additional insights
• discon-server listens on a configurable TCP/WebSocket port, loads the legacy Controller via a C shared-library loader, and waits for client connections.
• discon-client.dll is loaded by OpenFAST, reads environment variables (server address, controller path, entry proc), opens a WebSocket, and proxies function calls & file transfers.
• The wrapper is transparent to OpenFAST: it simply replaces the Controller DLL.
• discon-manager is mentioned in docs as a way to centrally configure server settings and controller deployments.
Main components & interactions
a. Components
• OpenFAST Simulator
• discon-client.dll (64-bit, loaded by OpenFAST)
• WebSocket Channel (TCP/ws:// or wss://)
• discon-server process (32-bit)
• Legacy Controller DLL (e.g., controller.dll)
• File Transfer sub-system (part of shared/utils)
• discon-manager Web UI
• Configuration storage (config.yaml, controllers.json)
• Manager’s embedded database
• Docker Engine / Orchestration (docker-compose)
b. Relationships & data flow
1. OpenFAST calls into discon-client.dll
2. Client marshals arguments → sends over WebSocket → Server
3. Server → unmarshals → invokes legacy Controller DLL via load_shared_library.c
4. Controller returns results → Server marshals → sends back over WebSocket → Client
5. Client returns result to OpenFAST
6. If Controller requests input files: Client checks local filesystem, transfers file to Server over WebSocket, updates path before invocation
7. discon-manager communicates with Docker Engine (via docker.go) to launch/stop discon-server instances, updates config and controllers.json
8. Browser ← HTTP ← discon-manager ← reads/writes Configuration database
c. Architectural patterns & principles
• Microservices: each component (client, server, manager) lives in its own process/container
• RPC over WebSockets for cross–address-space calls
• MVC for the manager (Go templates + handlers + JSON “DB”)
• Shared utility library for payload encoding, logging, and file-transfer logic
d. Key technologies & libraries
• Go for all three services
• C for load_shared_library.c in discon-server
• WebSockets (gorilla/websocket or stdlib)
• Sphinx/RST for documentation
• Docker & docker-compose for containerization
• Go templates for manager UI