Files
KeyBoard_QT/docs/host_logic_rebuild.md
2026-04-11 09:34:25 +08:00

1.4 KiB

Host LGC Rebuild

Goal

Keep the logic layer small, readable, and teachable.

The logic layer should:

  • own connection state
  • own handshake state
  • call DRI for bytes
  • call COM for frame and packet parsing
  • expose a small interface to APP

The logic layer should not:

  • parse serial bytes by itself
  • enumerate devices directly
  • own widget code

Completed Nodes

Node 1: function executor shell

Files:

  • KeyBorad/KeyBorad/LOGIC/Lgc_FunctionExecutor.h
  • KeyBorad/KeyBorad/LOGIC/Lgc_FunctionExecutor.cpp

Design notes:

  • keep function execution out of session code
  • reserve one place for OS-specific actions
  • keep the initial implementation small

Node 2: state model

Files updated in this step:

  • KeyBorad/KeyBorad/LOGIC/Lgc_State.h

Design notes:

  • state is plain data
  • connection text and last action text live here
  • handshake result fields live here

Node 3: session handshake path

Files planned next:

  • KeyBorad/KeyBorad/LOGIC/Lgc_Session.h
  • KeyBorad/KeyBorad/LOGIC/Lgc_Session.cpp

Target behavior:

  • try CDC handshake
  • store the active transport
  • read next parsed packet

Node 4: core facade

Files planned after session:

  • KeyBorad/KeyBorad/LOGIC/Lgc_Core.h
  • KeyBorad/KeyBorad/LOGIC/Lgc_Core.cpp

Target behavior:

  • give APP one small entry point
  • forward start/poll/close to session
  • refresh state from handshake results