copilot-visualizer-4.5.1: Visualizer for Copilot.
Copyright(c) NASA 2024-2025
LicenseBSD-style (see the LICENSE file in the distribution)
Safe HaskellNone
LanguageHaskell2010

Copilot.Visualize.Live

Description

Run a Copilot simulation live and allow interacting with it using a websocket.

This visualizer enables adding new streams to a visualization. To do so, the visualizer needs access to the original spec, and needs to be able to interpret new expressions in the same context as the prior expressions.

An example of a spec that can be passed as argument to the visualizer follows:

  spec :: String
  spec = unlines
    [ "let temperature :: Stream Word8"
    , "    temperature = extern "temperature" (Just [0, 15, 20, 25, 30])"
    , ""
    , "    ctemp :: Stream Float"
    , "    ctemp = (unsafeCast temperature) * (150.0 / 255.0) - 50.0"
    , ""
    , "    trueFalse :: Stream Bool"
    , "    trueFalse = [True] ++ not trueFalse"
    , ""
    , "in do trigger "heaton"  (temperature < 18) [arg ctemp, arg (constI16 1), arg trueFalse]"
    , "      trigger "heatoff" (temperature > 21) [arg (constI16 1), arg ctemp]"
    , "      observer "temperature" temperature"
    , "      observer "temperature2" (temperature + 1)"
    ]

The imports are predefined.

Synopsis

Documentation

visualize :: String -> IO () Source #

Start a simulation for an input spec, listening for commands and communicating the status via a websocket.

visualizeWith :: VisualSettings -> String -> IO () Source #

Start a simulation for an input spec, listening for commands and communicating the status via a websocket.

data VisualSettings Source #

Settings used to customize the simulation and interaction.

Constructors

VisualSettings 

Fields

mkDefaultVisualSettings :: VisualSettings Source #

Default settings that simulates 3 steps and listens on localhost at port 9160.

mkDefaultSimulationSettings :: SimulationSettings Source #

Default settings that simulates 3 steps and provides default imports of the main Copilot modules.