Projects ======== A **project** is everything a user made, saved as one file: the Flow, the Station, the variables, the Board arrangement and the run settings. It belongs to the user, not to the station: a station ships a *starter* (its descriptor's ``[graph]``, ``[[variables]]`` and ``[board]``), and a project is what the user did with it. A station needs no code for projects. The app builds and reads the file itself, from shapes the protocol already has. The file -------- ``name.psf``: readable JSON, indented, so a diff shows what changed. Parts that are empty are left out. Files saved before the extension changed (``name.paperboat.json``) still open. .. code-block:: json { "paperboat": 0, "station": "cart-pole", "flow": { "nodes": [{ "id": "pid-1", "type": "pid", "params": { "kp": 40 }, "pos": [260, 0] }], "edges": [{ "from": ["angle-1", "angle"], "to": ["pid-1", "error"] }] }, "station": { "objects": [{ "id": "cart-1", "type": "cartpole", "props": { "pole_length": 1.2 } }] }, "variables": [{ "name": "pole_length", "type": "number", "value": 1.2, "unit": "m" }], "board": { "instruments": [{ "block": "graph-1", "size": "large", "at": [1, 0] }] }, "run": { "duration": 5 } } .. list-table:: :header-rows: 1 :widths: 14 86 * - Field - Meaning * - ``paperboat`` - The project format version, ``0`` today. A newer file is refused, and the message says which version it is. * - ``station`` - The ``engine`` the project was made on (``hello``). Opening it on another station warns first. * - ``flow`` - The Flow canvas as a protocol ``Graph``, groups included. Every node has its place (``pos``), and a wire the user moved has its bends (``points``); stations ignore both. * - ``station`` - The Station, a protocol ``Station``. * - ``variables`` - The list the Variables sheet shows (the station's defaults and the user's own). * - ``board`` - The user's Board arrangement, if they made one (a protocol ``BoardLayout``). * - ``run`` - Only the run settings the user changed from the station's defaults. The shape is ``Project`` in ``protocol/schema/paperboat-0.schema.json`` (and ``protocol.ts``, generated from it). It is not a message: the app writes and reads it. In the app ---------- The **File** menu: **Open…** (Ctrl+O), **Save** (Ctrl+S), **Save as…** (Ctrl+Shift+S), **Restore last session** and **Recent projects**. Dropping a project file on the window opens it. The bar shows the project's name, with a dot while there are changes not saved. * Where the browser has the File System Access API (Chromium), Save writes back to the file the user chose. Elsewhere Save downloads a copy and Open uses a file input. * Opening checks the file first and changes nothing if it can't be read: not JSON, not a project, a newer format, or damaged (the message names where). It asks first when the project comes from another station or replaces unsaved changes. Edit > **Undo open project** brings back everything that was open. * A block whose type the opening station lacks stays on the canvas as a lost block, with its params and wires, so opening a project on a station with fewer blocks loses nothing. * The browser keeps unsaved work as it happens, per station, and offers it back after a reload (**Restore your last session?**). It also keeps the last few saved or opened projects, so Recent projects can reopen them. From the CLI ------------ You can launch a saved project with the CLI: .. code-block:: bash paperboat open project.psf This validates the project format, resolves and starts the matching station, ensures the Web UI is running, and loads the project. To execute the saved project headlessly: .. code-block:: bash paperboat open project.psf --run A project holds what the user made, not what a run did. A run's results are kept separately, as a **run record**. Run records ----------- ``paperboat run --record