Skip to content
Snippets Groups Projects
Commit 8fd0070c authored by Fabian Vu's avatar Fabian Vu
Browse files

Add B2Program JS Code

parent 7fbc77d6
No related branches found
No related tags found
No related merge requests found
Showing
with 7925 additions and 0 deletions
{
"svg":"architecture.svg",
"items":[
{
"repeat": ["1", "2", "3"],
"id":"eo_general_%0",
"attr":"stroke",
"value":"IF general_EV = TRUE THEN \"green\" ELSE \"red\" END"
},
{
"repeat": ["1", "2"],
"id":"eo_open_doors_%0",
"attr":"stroke",
"value":"IF open_EV = TRUE THEN \"green\" ELSE \"red\" END"
},
{
"repeat": ["1", "2"],
"id":"eo_close_doors_%0",
"attr":"stroke",
"value":"IF close_EV = TRUE THEN \"green\" ELSE \"red\" END"
},
{
"repeat": ["1", "2"],
"id":"eo_retract_gears_%0",
"attr":"stroke",
"value":"IF retract_EV = TRUE THEN \"green\" ELSE \"red\" END"
},
{
"repeat": ["1", "2"],
"id":"eo_extend_gears_%0",
"attr":"stroke",
"value":"IF extend_EV = TRUE THEN \"green\" ELSE \"red\" END"
},
{
"for": {"from": "1", "to": "6"},
"id":"hydraulic_circuit_%0",
"attr":"stroke-width",
"value":"IF general_valve = valve_open THEN 2 ELSE 1 END"
},
{
"repeat": ["1", "2", "3", "4", "5", "6"],
"id":"hydraulic_circuit_%0",
"attr":"stroke",
"value":"IF general_valve = valve_open THEN \"#88d2f7\" ELSE \"#cccccc\" END"
},
{
"repeat": ["1", "2", "3", "4"],
"id":"extension_circuit_doors_%0",
"attr":"stroke-width",
"value":"IF valve_open_door = valve_open THEN 2 ELSE 1 END"
},
{
"repeat": ["1", "2", "3", "4"],
"id":"extension_circuit_doors_%0",
"attr":"stroke",
"value":"IF valve_open_door = valve_open THEN \"#88d2f7\" ELSE \"#cccccc\" END"
},
{
"repeat": ["1", "2", "3", "4"],
"id":"retraction_circuit_doors_%0",
"attr":"stroke-width",
"value":"IF valve_close_door = valve_open THEN 2 ELSE 1 END"
},
{
"repeat": ["1", "2", "3", "4"],
"id":"retraction_circuit_doors_%0",
"attr":"stroke",
"value":"IF valve_close_door = valve_open THEN \"#88d2f7\" ELSE \"#cccccc\" END"
},
{
"repeat": ["1", "2", "3", "4"],
"id":"extension_circuit_gears_%0",
"attr":"stroke-width",
"value":"IF valve_extend_gear = valve_open THEN 2 ELSE 1 END"
},
{
"repeat": ["1", "2", "3", "4"],
"id":"extension_circuit_gears_%0",
"attr":"stroke",
"value":"IF valve_extend_gear = valve_open THEN \"#88d2f7\" ELSE \"#cccccc\" END"
},
{
"repeat": ["1", "2", "3", "4"],
"id":"retraction_circuit_gears_%0",
"attr":"stroke-width",
"value":"IF valve_retract_gear = valve_open THEN 2 ELSE 1 END"
},
{
"repeat": ["1", "2", "3", "4"],
"id":"retraction_circuit_gears_%0",
"attr":"stroke",
"value":"IF valve_retract_gear = valve_open THEN \"#88d2f7\" ELSE \"#cccccc\" END"
},
{
"id":"door_cylinder_forcer",
"attr":"transform",
"value":"{closed |-> \"translate(0,0)\", open |-> \"translate(90,0)\", door_moving |-> \"translate(45,0)\"}(door)"
},
{
"id":"gear_cylinder_forcer",
"attr":"transform",
"value":"{extended |-> \"translate(0,0)\", retracted |-> \"translate(90,0)\", gear_moving |-> \"translate(45,0)\"}(gear)"
},
{
"repeat": ["fr","lt", "rt"],
"id":"%0_door_cylinder_forcer",
"attr":"transform",
"value":"{closed |-> \"translate(0,0)\", open |-> \"translate(90,0)\", door_moving |-> \"translate(45,0)\"}(doors(%0))"
},
{
"repeat": ["fr","lt", "rt"],
"id":"%0_gear_cylinder_forcer",
"attr":"transform",
"value":"{extended |-> \"translate(0,0)\", retracted |-> \"translate(90,0)\", gear_moving |-> \"translate(45,0)\"}(gears(%0))"
},
{
"repeat": ["fr", "lt", "rt"],
"id":"%0_door_cylinder_l",
"attr":"fill",
"value":"{closed |-> \"#cccccc\", open |-> \"#88d2f7\", door_moving |-> \"#88d2f7\"}(doors(%0))"
},
{
"repeat": ["fr", "lt", "rt"],
"id":"%0_door_cylinder_r",
"attr":"fill",
"value":"{closed |-> \"#cccccc\", open |-> \"#88d2f7\", door_moving |-> \"#cccccc\"}(doors(%0))"
},
{
"repeat": ["fr","lt", "rt"],
"id":"%0_gear_cylinder_l",
"attr":"fill",
"value":"{extended |-> \"#cccccc\", retracted |-> \"#88d2f7\", gear_moving |-> \"#88d2f7\"}(gears(%0))"
},
{
"repeat": ["fr","lt", "rt"],
"id":"%0_gear_cylinder_r",
"attr":"fill",
"value":"{extended |-> \"#cccccc\", retracted |-> \"#88d2f7\", gear_moving |-> \"#cccccc\"}(gears(%0))"
},
{
"id":"ev_handle",
"attr":"xlink:href",
"value":"IF handle = up THEN \"img/handle_up.png\" ELSE \"img/handle_down.png\" END"
},
{
"repeat": ["1", "2"],
"id":"ev_general_%0",
"attr":"fill",
"value":"IF general_valve = valve_open THEN \"blue\" ELSE \"gray\" END"
},
{
"repeat": ["1", "2"],
"id":"ev_open_doors_%0",
"attr":"fill",
"value":"IF valve_open_door = valve_open THEN \"blue\" ELSE \"gray\" END"
},
{
"repeat": ["1", "2"],
"id":"ev_close_doors_%0",
"attr":"fill",
"value":"IF valve_close_door = valve_open THEN \"blue\" ELSE \"gray\" END"
},
{
"repeat": ["1", "2"],
"id":"ev_extended_gears_%0",
"attr":"fill",
"value":"IF valve_extend_gear = valve_open THEN \"blue\" ELSE \"gray\" END"
},
{
"repeat": ["1", "2"],
"id":"ev_retraction_gears_%0",
"attr":"fill",
"value":"IF valve_retract_gear = valve_open THEN \"blue\" ELSE \"gray\" END"
},
{
"repeat": ["1", "2", "3"],
"id":"analogical_switch_%0",
"attr":"fill",
"value":"IF general_EV = TRUE THEN \"green\" ELSE \"red\" END"
},
{
"repeat": ["1", "2", "3"],
"id":"analogical_switch_%0",
"attr":"stroke",
"value":"IF general_EV = TRUE THEN \"green\" ELSE \"red\" END"
},
{
"repeat": ["1", "2", "3"],
"id":"close_switch_%0",
"attr":"fill",
"value":"IF general_EV = TRUE THEN \"green\" ELSE \"red\" END"
},
{
"repeat": ["1", "2", "3"],
"id":"close_switch_%0",
"attr":"stroke",
"value":"IF general_EV = TRUE THEN \"green\" ELSE \"red\" END"
},
{
"id":"analogical_switch_open",
"attr":"visibility",
"value":"IF analogical_switch = switch_open THEN \"visible\" ELSE \"hidden\" END"
},
{
"id":"analogical_switch_closed",
"attr":"visibility",
"value":"IF analogical_switch = switch_closed THEN \"visible\" ELSE \"hidden\" END"
}
],
"events": [
{
"id":"con_stimulate_general_valve",
"event":"con_stimulate_general_valve",
"predicates":[]
},
{
"id":"close_switch_1",
"event":"env_open_analogical_switch",
"predicates":[]
},
{
"id":"open_switch",
"event":"env_close_analogical_switch",
"predicates":[]
}
]
}
{
"svg":"physical.svg",
"items":[
{
"repeat": ["fr", "lt", "rt"],
"id":"door_%0",
"attr":"xlink:href",
"value":"IF doors(%0) = open THEN \"img/door_open.png\" ELSIF doors(%0) = closed \"img/door_closed.png\" ELSE \"img/door_door_moving.png\" END"
},
{
"repeat": ["fr", "lt", "rt"],
"id":"gear_%0",
"attr":"xlink:href",
"value":"IF gears(%0) = extended THEN \"img/gear_extended.png\" ELSIF gears(%0) = retracted \"img/gear_retracted.png\" ELSE \"img/gear_gear_moving.png\" END"
}
],
"events": []
}
This diff is collapsed.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>LandingGear_R6</title>
<head>
<body>
<div>
<h1>Visualization <br></h1>
<object id="physical" data="physical.svg" type="image/svg+xml"></object>
</div>
<div>
<h1>Operations View <br></h1>
<div id="_operations_view">
<div class="param" style="grid-column: span 2;">Parameter</div>
<div style="text-align: center; grid-column: -1;">Event</div>
</div>
</div>
<div>
<h1>History View <br></h1>
<div id="_history_view_buttons">
<input id="_upload_trace_input" type="file" style="display:none;"></input>
<input id="_export_trace" type="file" style="display:none;"></input>
</div>
<div id="_history_view">
</div>
<br>
<br>
<h1>Scenario View <br></h1>
<div id="_scenario_view">
</div>
</div>
<div id="_state_view">
<h1>State View <br></h1>
<div id="_state_view_variables" class="state_view_section">
<div class="state_view_header collapsed" onclick="collapse(this)">Variables</div>
</div>
<div id="_state_view_constants" class="state_view_section">
<div class="state_view_header collapsed" onclick="collapse(this)">Constants</div>
</div>
<div id="_state_view_sets" class="state_view_section">
<div class="state_view_header collapsed" onclick="collapse(this)">Sets</div>
</div>
<div id="_state_view_invariant" class="state_view_section">
<div class="state_view_header collapsed" onclick="collapse(this)">Invariant</div>
</div>
</div>
<script type="module" src="./immutable/dist/immutable.es.js"></script>
<script type="module" src="./btypes/BTuple.js"></script>
<script type="module" src="./btypes/BRelation.js"></script>
<script type="module" src="./btypes/BBoolean.js"></script>
<script type="module" src="./btypes/BSet.js"></script>
<script type="module" src="./btypes/BObject.js"></script>
<script type="module" src="./LandingGear_R6.js"></script>
<script type="module" src="./LandingGear_R6-visualisation.js" defer></script>
</body>
<script>
function collapse(element) {
element.classList.toggle("collapsed");
}
</script>
<style>
#_operations_view{
display: grid;
grid-template-columns: auto auto auto;
gap: 0.5%;
margin-bottom: auto;
margin-right: 1rem;
}
:root {
--noneOrGrid: grid;
}
.param{
display: var(--noneOrGrid);
grid-column: span 2;
grid-template-columns: subgrid;
gap: 5px;
}
#_history_view{
margin-bottom: auto;
margin-right: 1rem;
overflow-y : auto;
padding-right: 18px;
max-height: 90vh;
}
#_history_view > span.active {
background: lightblue;
}
#_history_view_buttons {
display: grid;
grid-template-columns: 1fr 1fr;
}
#_scenario_view{
margin-right: 1rem;
overflow-y : auto;
padding-right: 18px;
gap: 5%;
display: grid;
}
#_scenario_view > span.active {
background: lightblue;
}
#_scenario_view_buttons {
display: grid;
grid-template-columns: 1fr 1fr;
}
.state_view_section {
display: grid;
grid-template-columns: auto auto;
gap: 0px 20px;
}
.state_view_header {
grid-column: 1 / -1;
border-bottom: 1px solid black;
}
.state_view_header:only-child {
display: none;
}
.state_view_header::after {
content: "\25B2";
margin-left: 5px;
float: right;
}
.collapsed ~ * {
display: none;
}
.collapsed::after {
content: "\25BC";
}
body {
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 20px;
align-items: start;
}
</style>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"description": "Created from B2Program JS Export",
"transitionList": [
{
"name": "$initialise_machine",
"params": {}
},
{
"name": "toggle_handle_up",
"params": {}
},
{
"name": "begin_flying",
"params": {}
},
{
"name": "con_stimulate_general_valve",
"params": {}
},
{
"name": "con_stimulate_open_door_valve",
"params": {}
},
{
"name": "env_close_analogical_switch",
"params": {}
},
{
"name": "open_valve_door_open",
"params": {}
},
{
"name": "evn_open_general_valve",
"params": {}
},
{
"name": "env_start_open_door",
"params": {}
},
{
"name": "env_start_open_door",
"params": {}
},
{
"name": "env_start_open_door",
"params": {
"gr": "rt"
}
},
{
"name": "env_open_door_skip",
"params": {
"gr": "fr"
}
},
{
"name": "env_open_door_skip",
"params": {
"gr": "lt"
}
},
{
"name": "env_open_door_last",
"params": {
"gr": "rt"
}
},
{
"name": "con_stimulate_retract_gear_valve",
"params": {}
},
{
"name": "open_valve_retract_gear",
"params": {}
},
{
"name": "env_start_retracting_first",
"params": {
"gr": "fr"
}
},
{
"name": "env_start_retracting_first",
"params": {
"gr": "lt"
}
},
{
"name": "env_start_retracting_first",
"params": {
"gr": "rt"
}
},
{
"name": "env_retract_gear_skip",
"params": {
"gr": "fr"
}
},
{
"name": "env_retract_gear_skip",
"params": {
"gr": "lt"
}
},
{
"name": "env_retract_gear_last",
"params": {
"gr": "rt"
}
},
{
"name": "con_stop_stimulate_retract_gear_valve",
"params": {}
},
{
"name": "con_stop_stimulate_open_door_valve",
"params": {}
},
{
"name": "close_valve_door_open",
"params": {}
},
{
"name": "con_stimulate_close_door_valve",
"params": {}
},
{
"name": "open_valve_door_close",
"params": {}
},
{
"name": "env_start_close_door",
"params": {
"gr": "fr"
}
},
{
"name": "env_start_close_door",
"params": {
"gr": "lt"
}
},
{
"name": "env_start_close_door",
"params": {
"gr": "rt"
}
},
{
"name": "env_close_door_skip",
"params": {
"gr": "fr"
}
},
{
"name": "env_close_door_skip",
"params": {
"gr": "lt"
}
},
{
"name": "env_close_door",
"params": {
"gr": "rt"
}
},
{
"name": "con_stop_stimulate_close_door_valve",
"params": {}
},
{
"name": "close_valve_door_close",
"params": {}
},
{
"name": "con_stop_stimulate_general_valve",
"params": {}
},
{
"name": "close_valve_retract_gear",
"params": {}
},
{
"name": "evn_close_general_valve",
"params": {}
}
],
"metadata": {
"fileType": "Trace",
"formatVersion": 1,
"creator": "B2Program JS",
"modelName": "LandingGear_R6"
}
}
\ No newline at end of file
export class BBoolean {
constructor(value) {
if (typeof (value) === 'boolean') {
this.value = value;
}
else if (typeof value === 'string') {
this.value = value.toLowerCase() === 'true';
}
else {
this.value = value.value;
}
}
and(other) {
return new BBoolean(this.value && other.value);
}
or(other) {
return new BBoolean(this.value || other.value);
}
not() {
return new BBoolean(!this.value);
}
implies(other) {
return this.not().or(other);
}
equivalent(other) {
return this.implies(other).and(other.implies(this));
}
equal(other) {
return new BBoolean(this.value === other.value);
}
equals(other) {
if (!(other instanceof BBoolean)) {
return false;
}
return this.equal(other).booleanValue();
}
unequal(other) {
return new BBoolean(this.value != other.value);
}
booleanValue() {
return this.value;
}
toString() {
return this.value.toString();
}
hashCode() {
return this.value ? 1 : 0;
}
}
This diff is collapsed.
export class BObject {
equals(other) {
return false;
}
hashCode() {
return 0;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
import { BBoolean } from "./BBoolean.js";
export class BStruct {
isRecord() {
return new BBoolean(true);
}
isNotRecord() {
return new BBoolean(false);
}
}
This diff is collapsed.
import { BSet } from "./BSet.js";
import { BBoolean } from "./BBoolean.js";
export class BUtils {
}
BUtils.BOOL = new BSet(new BBoolean(true), new BBoolean(false));
export class SelectError extends Error {
constructor(msg) {
super(msg);
Object.setPrototypeOf(this, SelectError.prototype);
}
}
\ No newline at end of file
B2Program/LandingGear/GearsDoors/img/door_closed.png

4.7 KiB

B2Program/LandingGear/GearsDoors/img/door_door_moving.png

5.05 KiB

B2Program/LandingGear/GearsDoors/img/door_open.png

5.88 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment