diff --git a/trick_source/web/HttpServer/src/VariableServerVariable.cpp b/trick_source/web/HttpServer/src/VariableServerVariable.cpp index 6b4799f8..1597a46b 100644 --- a/trick_source/web/HttpServer/src/VariableServerVariable.cpp +++ b/trick_source/web/HttpServer/src/VariableServerVariable.cpp @@ -3,6 +3,7 @@ #include // for fpclassify #include // for setprecision + VariableServerVariable::VariableServerVariable(REF2 * ref ) { varInfo = ref; address = varInfo->address; diff --git a/trick_source/web/mockup/.gitignore b/trick_source/web/mockup/.gitignore index 4d29575d..163ceba8 100644 --- a/trick_source/web/mockup/.gitignore +++ b/trick_source/web/mockup/.gitignore @@ -17,6 +17,8 @@ .env.development.local .env.test.local .env.production.local +.jsprettier +.prettierrc npm-debug.log* yarn-debug.log* diff --git a/trick_source/web/mockup/.prettierrc b/trick_source/web/mockup/.prettierrc deleted file mode 100644 index dcb72794..00000000 --- a/trick_source/web/mockup/.prettierrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "all" -} \ No newline at end of file diff --git a/trick_source/web/mockup/src/AppStyles.js b/trick_source/web/mockup/src/AppStyles.js index c9b696f1..7cdfb01a 100644 --- a/trick_source/web/mockup/src/AppStyles.js +++ b/trick_source/web/mockup/src/AppStyles.js @@ -8,9 +8,9 @@ export default theme => ({ display: 'flex', }, - toolbar: {}, + //toolbar: {}, - appbar: { width: `calc(100% - ${drawerWidth}px)`, marginLeft: drawerWidth }, + // appbar: { width: `calc(100% - ${drawerWidth}px)`, marginLeft: drawerWidth }, paper: { margin: '0 auto', diff --git a/trick_source/web/mockup/src/Client.js b/trick_source/web/mockup/src/Client.js index 850325f5..87d3f31d 100644 --- a/trick_source/web/mockup/src/Client.js +++ b/trick_source/web/mockup/src/Client.js @@ -1,43 +1,51 @@ -import React from 'react'; -import AppBar from '@material-ui/core/AppBar'; -import MuiBox from '@material-ui/core/Box'; -import Toolbar from '@material-ui/core/Toolbar'; -import Table from '@material-ui/core/Table'; -import TableBody from '@material-ui/core/TableBody'; -import TableCell from '@material-ui/core/TableCell'; -import TableHead from '@material-ui/core/TableHead'; -import TableRow from '@material-ui/core/TableRow'; -import Paper from '@material-ui/core/Paper'; -import TextField from '@material-ui/core/TextField'; -import Typography from '@material-ui/core/Typography'; -import Button from '@material-ui/core/Button'; -import ExpansionPanel from '@material-ui/core/ExpansionPanel'; -import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'; -import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'; -import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; -import { Flex, Box } from 'reflexbox'; -import TreeView from '@material-ui/lab/TreeView'; -import ChevronRightIcon from '@material-ui/icons/ChevronRight'; -import TreeItem from '@material-ui/lab/TreeItem'; -import SearchIcon from '@material-ui/icons/Search'; -import InputBase from '@material-ui/core/InputBase'; +import React, { useState } from "react"; +import AppBar from "@material-ui/core/AppBar"; +import MuiBox from "@material-ui/core/Box"; +import Toolbar from "@material-ui/core/Toolbar"; +import Table from "@material-ui/core/Table"; +import TableBody from "@material-ui/core/TableBody"; +import TableCell from "@material-ui/core/TableCell"; +import TableHead from "@material-ui/core/TableHead"; +import TableRow from "@material-ui/core/TableRow"; +import Paper from "@material-ui/core/Paper"; +import TextField from "@material-ui/core/TextField"; +import Typography from "@material-ui/core/Typography"; +import Button from "@material-ui/core/Button"; +import ExpansionPanel from "@material-ui/core/ExpansionPanel"; +import ExpansionPanelSummary from "@material-ui/core/ExpansionPanelSummary"; +import ExpansionPanelDetails from "@material-ui/core/ExpansionPanelDetails"; +import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; +import { Flex, Box } from "reflexbox"; +import TreeView from "@material-ui/lab/TreeView"; +import ChevronRightIcon from "@material-ui/icons/ChevronRight"; +import TreeItem from "@material-ui/lab/TreeItem"; +import SearchIcon from "@material-ui/icons/Search"; +import InputBase from "@material-ui/core/InputBase"; -import Drawer from '@material-ui/core/Drawer'; +import Drawer from "@material-ui/core/Drawer"; -import List from '@material-ui/core/List'; +import List from "@material-ui/core/List"; -import Divider from '@material-ui/core/Divider'; -import ListItem from '@material-ui/core/ListItem'; -import ListItemIcon from '@material-ui/core/ListItemIcon'; -import ListItemText from '@material-ui/core/ListItemText'; -import InboxIcon from '@material-ui/icons/MoveToInbox'; -import MailIcon from '@material-ui/icons/Mail'; +import Divider from "@material-ui/core/Divider"; +import ListItem from "@material-ui/core/ListItem"; +import ListItemIcon from "@material-ui/core/ListItemIcon"; +import ListItemText from "@material-ui/core/ListItemText"; +import InboxIcon from "@material-ui/icons/MoveToInbox"; +import MailIcon from "@material-ui/icons/Mail"; -import OutlinedInput from '@material-ui/core/OutlinedInput'; +import Dialog from "@material-ui/core/Dialog"; +import DialogTitle from "@material-ui/core/DialogTitle"; +import Radio from "@material-ui/core/Radio"; +import RadioGroup from "@material-ui/core/RadioGroup"; +import FormHelperText from "@material-ui/core/FormHelperText"; +import FormControlLabel from "@material-ui/core/FormControlLabel"; +import FormControl from "@material-ui/core/FormControl"; +import FormLabel from "@material-ui/core/FormLabel"; +//import OutlinedInput from '@material-ui/core/OutlinedInput'; -import MenuItem from '@material-ui/core/MenuItem'; +//import MenuItem from '@material-ui/core/MenuItem'; -import Select from '@material-ui/core/Select'; +//import Select from '@material-ui/core/Select'; export default class Client extends React.Component { constructor(props) { @@ -45,25 +53,58 @@ export default class Client extends React.Component { this.state = { variables: [], data: [], - unit: [], + units: [], time: 0.0, + sie: { top_level_objects: [] }, + children: {}, + addVariable: "", + dialogOpen: false, + dialogText: "", + dialogDims: [], + dialogElems: [], + dialogStart: [], + selectedVar: "", + data_record: false, + data_record_text: "Enable Data Record" /* TODO get dr info from sim */, + realtime: true, + realtime_text: "Realtime Enabled" /* TODO get dr info from sim */, }; - console.log('Client created'); + console.log("Client created"); this.ws = new WebSocket( - 'ws://localhost:8888/api/ws/VariableServer', - 'myProtocol', + "ws://localhost:8888/api/ws/VariableServer", + "myProtocol", ); this.ws.onopen = e => { this.var_cycle(100); this.var_unpause(); //this.var_add("trick_sys.sched.time_tics"); - console.log('opened'); + console.log("opened"); + this.request_sie(); }; this.ws.onmessage = e => { - console.log('Message received'); + //console.log('Message received'); let message = JSON.parse(e.data); - console.log(message); - this.setState({ time: message.time, data: message.values }); + if (message.msg_type === "error") { + console.log(message.error); + } + if (message.msg_type === "values") { + this.setState({ time: message.time, data: message.values }); + } + if (message.msg_type === "sie") { + console.log(message); + this.setState({ sie: message.data }); + } + if (message.msg_type === "units") { + console.log(message); + let i = this.state.variables.indexOf(message.var_name); + this.setState({ + units: [ + ...this.state.units.slice(0, i), + message.data, + ...this.state.units.slice(i + 1), + ], + }); + } }; } @@ -74,7 +115,7 @@ export default class Client extends React.Component { var_add = v => { let msg = { - cmd: 'var_add', + cmd: "var_add", var_name: v, }; this.send_msg(msg); @@ -82,14 +123,14 @@ export default class Client extends React.Component { var_unpause = () => { let msg = { - cmd: 'var_unpause', + cmd: "var_unpause", }; this.send_msg(msg); }; var_cycle = p => { let msg = { - cmd: 'var_cycle', + cmd: "var_cycle", period: p, }; this.send_msg(msg); @@ -97,17 +138,21 @@ export default class Client extends React.Component { var_clear = () => { let msg = { - cmd: 'var_clear', + cmd: "var_clear", }; this.send_msg(msg); }; - addVariable = v => { - this.setState({ - variables: [...this.state.variables, v], - data: [...this.state.data, 0.0], + addVariable = (path, units = "--") => { + console.log("in add var"); + this.setState(prev => { + return { + variables: [...prev.variables, path], + data: [...prev.data, 0.0], + units: [...prev.units, units], + }; }); - this.var_add(v); + this.var_add(path); }; clearVariables = () => { @@ -117,22 +162,64 @@ export default class Client extends React.Component { input_processor = cmd => { let msg = { - cmd: 'python', + cmd: "python", pycode: cmd, }; this.send_msg(msg); }; sim_start = () => { - this.input_processor('trick.exec_run()'); + this.input_processor("trick.exec_run()"); }; sim_freeze = () => { - this.input_processor('trick.exec_freeze()'); + this.input_processor("trick.exec_freeze()"); }; sim_shutdown = () => { - this.input_processor('trick.stop()'); + this.input_processor("trick.stop()"); }; + + sim_data_record_toggle = () => { + /* TODO get dr info from sim */ + this.setState(prev => { + if (!prev.data_record) { + this.input_processor("trick.dr_enable()"); + return { data_record: true, data_record_text: "Data Record On" }; + } else { + this.input_processor("trick.dr_disable()"); + return { data_record: false, data_record_text: "Data Record Off" }; + } + }); + }; + + sim_realtime_toggle = () => { + /* TODO get dr info from sim */ + this.setState(prev => { + if (!prev.realtime) { + this.input_processor("trick.real_time_enable()"); + return { realtime: true, realtime_text: "Realtime On" }; + } else { + this.input_processor("trick.real_time_disable()"); + return { realtime: false, realtime_text: "Realtime Off" }; + } + }); + }; + + request_sie = () => { + let msg = { + cmd: "sie", + }; + this.send_msg(msg); + }; + + request_units = var_name => { + let msg = { + cmd: "units", + var_name: var_name, + }; + this.send_msg(msg); + }; + sim_step = () => { /* TODO handle debug stepping mode this.input_processor('trick.debug_pause_on()'); @@ -140,7 +227,7 @@ export default class Client extends React.Component { */ }; - BoxButton = ({ text, color = 'primary', fullWidth = true, onClick }) => ( + BoxButton = ({ text, color = "primary", fullWidth = true, onClick }) => ( + + + + ); } diff --git a/trick_source/web/mockup/src/withRoot.js b/trick_source/web/mockup/src/withRoot.js index 512b2aad..99705a14 100644 --- a/trick_source/web/mockup/src/withRoot.js +++ b/trick_source/web/mockup/src/withRoot.js @@ -1,9 +1,9 @@ import React from 'react'; import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles'; -import cyan from '@material-ui/core/colors/cyan'; -import deepPurple from '@material-ui/core/colors/deepPurple'; -import green from '@material-ui/core/colors/green'; -import blueGrey from '@material-ui/core/colors/blueGrey'; +//import cyan from '@material-ui/core/colors/cyan'; +//import deepPurple from '@material-ui/core/colors/deepPurple'; +//import green from '@material-ui/core/colors/green'; +//import blueGrey from '@material-ui/core/colors/blueGrey'; import CssBaseline from '@material-ui/core/CssBaseline'; // A theme with custom primary and secondary color.