Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dk/96 visible expression #173

Merged
merged 27 commits into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e6233db
WIP: integrate expression evaluation with enable/visible sets
Aug 16, 2022
d10e09b
Add TODO around replaceable mods and expressions
Aug 16, 2022
0b33f55
Implement visibility test for 'enable' annotation
Aug 16, 2022
d46058e
Set 'enable' even if no annotation is provided
Aug 16, 2022
13d386c
Fix typo in test package, fix typo in test
Aug 16, 2022
cd6f1cd
Add and implement tests for remaining 'visible' conditions
Aug 16, 2022
58942aa
Don't lazy load types, load on discovery
Aug 16, 2022
076770e
Use 'type' to build up modification paths
Aug 18, 2022
f6472e0
Include modifiers with 'TemplateInputs'
Aug 18, 2022
093b6eb
Map modifiers to serializable format
Aug 18, 2022
bb275cc
WIP: Add redeclared parameters to test package
Aug 19, 2022
4846c62
Fix type on 'getOptions'
Aug 19, 2022
caf55eb
Simplify redeclare statements
Aug 19, 2022
31272da
WIP: Add todo around mod path buildup
Aug 19, 2022
df8890b
WIP: remove 'getModifiers' accessor
Aug 23, 2022
8629605
WIP: handle extend_clause modifiers
Aug 23, 2022
89d705f
Update shape of serializable modifier structure
Aug 23, 2022
da3cf28
Use correct basepath when creating modifiers
Aug 23, 2022
da1d418
Change TemplateInput mods back to a list
Aug 24, 2022
0ad311e
WIP: update modifier tests
Aug 24, 2022
58af86b
WIP: update constrainby modifier test
Aug 24, 2022
679467c
Include modifiers when generating replaceable template input
Aug 24, 2022
036cef0
Move modelica-json types
Aug 24, 2022
422269b
Add tree debugger script
Aug 26, 2022
c918f95
Fix incorrect key assignment, update formatting
Aug 26, 2022
40372d0
Fix bad reference in test
Aug 29, 2022
757bd73
Show options that are not visible in tree visualizer
Aug 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"debug-tree": "^0.1.3"
}
}
38 changes: 38 additions & 0 deletions server/scripts/visualize-option-tree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Option Visualizer helper
*/

const DebugTree = require("debug-tree");
const templateData = require("./templates.json");

DebugTree.start("output.html");

const path = "Buildings.Templates.AirHandlersFans.VAVMultiZone";
const options = templateData["options"];
const optionMap = {};
options.map((o) => (optionMap[o.modelicaPath] = o));

const isPrimitive = (o) => {
const type = o.type;
return (
type && (type.startsWith("Medium") || ["Boolean", "String"].includes(type))
);
};

const writeNode = (nodePath, depth = 0) => {
const node = optionMap[nodePath];
let printStr = node?.visible ? `******* - ${node?.name}` : `${node?.name}`;
// if (node?.visible && !isPrimitive(node)) {
console.log(DebugTree.depth(depth), printStr);
// }

node?.options?.map((oPath) => {
const o = optionMap[oPath];
const newDepth = o?.visible ? depth + 1 : depth;
writeNode(oPath, depth + 1);
});
};

writeNode(path);

DebugTree.end();
5 changes: 1 addition & 4 deletions server/src/parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ export function getSystemTypes(): templates.SystemTypeN[] {
return templates.getSystemTypes();
}

export function getOptions(): {
options: parser.TemplateInput[];
scheduleOptions: parser.ScheduleOption[];
} {
export function getOptions() {
return templates.getOptions();
}
77 changes: 75 additions & 2 deletions server/src/parser/mj-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Manually created interfaces to match the output of the modelica-json tool

*/

import { DeclarationBlock } from "./modification";

export interface ClassModification {
element_modification_or_replaceable: {
each: boolean;
Expand Down Expand Up @@ -121,3 +119,78 @@ export interface ProtectedElement {
component_clause: ComponentClause;
description: Description;
}


export type ExtendsClause = {
extends_clause: ClassMod;
name: string;
}

export type ConstraintDef = {
name: string;
class_modification: ClassMod;
}

export type DeclarationBlock = {
identifier: string;
modification?: ClassMod | WrappedMod | Assignment | RedeclareMod;
};

export type DescriptionBlock = {
description_string: string;
annotation?: any;
};

export type ComponentDeclaration1 = {
declaration: DeclarationBlock;
description?: DescriptionBlock;
};

export type ComponentClause1 = {
type_specifier: string; // Modelica Path
component_declaration1: ComponentDeclaration1;
};

export type ShortClassDefinition = {
class_prefixes: string; // //(PARTIAL)? (CLASS | MODEL | (OPERATOR)? RECORD | BLOCK | (EXPANDABLE)? CONNECTOR | TYPE | PACKAGE | ((PURE | IMPURE))? (OPERATOR)? FUNCTION | OPERATOR),
short_class_specifier: ShortClassSpecifier; // from 'parser.ts'
};

export type ElementReplaceable = {
component_clause1: ComponentClause1;
short_class_definition: ShortClassDefinition;
};

export type RedeclareMod = {
element_redeclaration: {
each: boolean;
final: boolean;
short_class_definition?: ShortClassDefinition;
element_replaceable?: ElementReplaceable;
component_clause1?: ComponentClause1;
};
};

export type ClassMod = {
class_modification: (WrappedMod | RedeclareMod)[];
name: string;
};

export type Assignment = {
equal: boolean;
expression: {
simple_expression: string; // JSON deserializable value
};
};

// Replacable
export type WrappedMod = {
element_modification_or_replaceable: {
element_modification: Mod;
};
};

export type Mod = {
name: string;
modification: ClassMod | WrappedMod | Assignment | RedeclareMod;
};
Loading