# Requirements

## Beck-end

- Portable single executable capable of running on old Linux machine
- It should serve a web UI frontend that could be easily forwarded via SSH tunnel
- It should also have a rest API for desktop client if needed
- It should support multiple clients

### Data source

- primary data-source are EPICS and Synthetic, but the service should be easily extendible (via plugins)
- data-source should get data at maximum rate possible and mutualize the data with all clients that
  require the same data
- timestamp from the data-source should be used when available
- subscribe mechanism should be preferred when possible
- user can mix live data and archived data when available

#### EPICS Data-Source

- should get all information available from signal name (type, ranges, enum values [if any], acquisition mode, write/read mode etc.)
- subscription/monitor preferable
- optimize multiple signal access when possible
- if possible retrieve list of available signals
- if possible use EPICS archive for access to historical data

#### Synthetic Data-Source

- use any existing signal (from this datasource of other) or synthetic sources (random signals, timers etc) and process it using any combination of user defined processing functions (band pass filters, moving average, gain, offset, derivative, custom formula etc)
- user should have access to a library of optimized math and signal processing functions
- user can use LUA or similar for defining custom code and combine functions or using more advanced logic

### Front-end

- Front-end should adapt to screen DPI
- It should use modern web tools/libs but no webgpu
- It should be as fast as possible and as reactive as possible: it should feel as much as possible like a native program
- Front-end has to primary modes: edit and view

#### Edit mode

- in this mode user can create monitor and control user interfaces
- in a resizable and collapsable left pane a tree of available signals should be visualised:
  - the list is a combination of the server signal list per datasource
  - user defined one (e.g. user can add a custom PV name to the epics datasource or new synthetic signal for the synthetic datasource)
  - user can load a list (csv) of custom signals (NAME, DataSource, DS PARAMETERS)
- user can drag and drop signals from the left panel to the main pane:
  - when signal is dropped a list of possible widgets (iconized) compatible with the signal type is proposed:
    - text view (just `name: value + unit`)
      - fft
      - waterfall plot (for multidimensional signal)
      - histogram
      - bar
      - logic analyser

- on the main pane user can select widgets:
  - selected widget should have a rect bounding box with handles and delete button
  - can move them (drag and drop)
  - edit content (double click)
    - gauge
    - vertical/horizontal bar
    - set value (`name: new_value | current_value+unit |`set button`)
    - led (with condition and color and optional name)
    - button to send command / set value
    - multi led for bitset (e.g. uint8 each bit is a signal)
    - plot (can accomodate multiple signals):
      - timeseries
      - fft
      - waterfall plot (for multidimensional signal)
      - histogram
      - bar
      - logic analyser
- on the main pane user can select widgets:
  - selected widget should have a rect bounding box with handles and delete button
  - can move them (drag and drop)
  - edit content (double click)
  - delete (del button, or clicking on a x button on the top right corner)
  - resize them (using handles)
- user can select multiple widgets by ctrl+click (add/remove widget to selection) or area select, when multiple widgets are selected:
  - user can move them all togheter by dragging any of the selected widget
  - user can delete all of them (del key)
  - an align/distribute toolbar should appear letting:
    - align vertically/horizontally: different option (left/center/right)
    - distribute evenly vertically/horizontally: different options: distance center or gap size
- on the right a widget setting pane should appear when a widget is selected with widget options:
  - scale or ranges
  - conditions for led and multiled
  - plot type and plot settings
  - labels
  - font size
  - text color
  - and all other usefull options
- a top toolbar should have at least the following tools:
  - show/hide signal pane
  - show/hide widget pane
  - undo/redo button (also ctrl+z/ctrl+shift+z)
  - save/load interface (to server)
  - export/import (to local file)
  - add text to the interface
  - add image to the interface
  - add links to other interfaces (button that open another interface)
- interface are saved and exported as XML

#### View mode

- view mode is the default mode
- in this mode user has on the left a collapsable interface selection pane:
  - contains all server saved interface
    - right click on a existing interface user can edit or clone and edit the interface
  - it has an import option to load a local interface
  - it has a new interface button that open the edit mode
- when an interface is selected user can interact with the hmi:
  - edit values
  - click buttons
  - zoom/interact with plots
  - etc
- right clicking to a widget open a menu with:
  - signal info : open a small window/dialog with signal or signals information (DS, type, unit, etc)
  - copy signal name: copy signal name to system clipboard
  - export data to csv: export available data of the current signal
  - any other information/action that could be useful
- user will not have any edit capabilities in this mode (no drag/drop, no resize, nothing else)
- the top toolbar should contain:
  - button to show/hide interface list pane
  - a time selection to move back to a specific time if possible (if server has this capabilities)
  - live button to come back to live data (if server has hist capabilities)
