circuitscript 0.0.38 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BaseVisitor.js +69 -46
- package/dist/cjs/SymbolValidatorVisitor.js +1 -1
- package/dist/cjs/antlr/CircuitScriptLexer.js +80 -80
- package/dist/cjs/antlr/CircuitScriptParser.js +580 -613
- package/dist/cjs/builtinMethods.js +32 -10
- package/dist/cjs/draw_symbols.js +375 -233
- package/dist/cjs/execute.js +142 -131
- package/dist/cjs/export.js +2 -4
- package/dist/cjs/geometry.js +52 -19
- package/dist/cjs/globals.js +14 -9
- package/dist/cjs/helpers.js +16 -3
- package/dist/cjs/layout.js +143 -151
- package/dist/cjs/logger.js +8 -1
- package/dist/cjs/objects/ClassComponent.js +22 -22
- package/dist/cjs/objects/ExecutionScope.js +10 -4
- package/dist/cjs/objects/Frame.js +4 -1
- package/dist/cjs/objects/ParamDefinition.js +120 -4
- package/dist/cjs/objects/PinDefinition.js +1 -4
- package/dist/cjs/objects/types.js +41 -0
- package/dist/cjs/render.js +41 -110
- package/dist/cjs/sizing.js +33 -7
- package/dist/cjs/utils.js +92 -2
- package/dist/cjs/visitor.js +279 -284
- package/dist/esm/BaseVisitor.mjs +70 -47
- package/dist/esm/SymbolValidatorVisitor.mjs +1 -1
- package/dist/esm/antlr/CircuitScriptLexer.mjs +80 -80
- package/dist/esm/antlr/CircuitScriptParser.mjs +580 -613
- package/dist/esm/builtinMethods.mjs +29 -10
- package/dist/esm/draw_symbols.mjs +381 -238
- package/dist/esm/execute.mjs +144 -133
- package/dist/esm/export.mjs +2 -4
- package/dist/esm/geometry.mjs +52 -19
- package/dist/esm/globals.mjs +13 -8
- package/dist/esm/helpers.mjs +17 -4
- package/dist/esm/layout.mjs +144 -153
- package/dist/esm/logger.mjs +8 -1
- package/dist/esm/objects/ClassComponent.mjs +21 -26
- package/dist/esm/objects/ExecutionScope.mjs +10 -4
- package/dist/esm/objects/Frame.mjs +4 -1
- package/dist/esm/objects/ParamDefinition.mjs +119 -3
- package/dist/esm/objects/PinDefinition.mjs +0 -2
- package/dist/esm/objects/types.mjs +42 -0
- package/dist/esm/render.mjs +44 -113
- package/dist/esm/sizing.mjs +34 -8
- package/dist/esm/utils.mjs +86 -1
- package/dist/esm/visitor.mjs +281 -286
- package/dist/types/BaseVisitor.d.ts +3 -2
- package/dist/types/antlr/CircuitScriptParser.d.ts +5 -3
- package/dist/types/draw_symbols.d.ts +81 -49
- package/dist/types/execute.d.ts +16 -11
- package/dist/types/geometry.d.ts +31 -19
- package/dist/types/globals.d.ts +15 -10
- package/dist/types/helpers.d.ts +2 -1
- package/dist/types/layout.d.ts +22 -21
- package/dist/types/logger.d.ts +1 -1
- package/dist/types/objects/ClassComponent.d.ts +19 -16
- package/dist/types/objects/ExecutionScope.d.ts +2 -1
- package/dist/types/objects/Frame.d.ts +5 -3
- package/dist/types/objects/ParamDefinition.d.ts +31 -2
- package/dist/types/objects/PinDefinition.d.ts +0 -2
- package/dist/types/objects/types.d.ts +7 -2
- package/dist/types/render.d.ts +2 -1
- package/dist/types/utils.d.ts +9 -1
- package/dist/types/visitor.d.ts +5 -5
- package/libs/lib.cst +102 -32
- package/package.json +7 -3
|
@@ -3,22 +3,26 @@ import { SymbolDrawingCommands } from '../draw_symbols.js';
|
|
|
3
3
|
import { Net } from './Net.js';
|
|
4
4
|
import { PinDefinition, PinId } from './PinDefinition.js';
|
|
5
5
|
import { WireSegment } from './Wire.js';
|
|
6
|
-
import { ExecutionContext } from '
|
|
6
|
+
import { ExecutionContext } from '../execute.js';
|
|
7
|
+
import { NumericValue } from './ParamDefinition.js';
|
|
7
8
|
export declare class ClassComponent {
|
|
8
9
|
instanceName: string;
|
|
9
10
|
numPins: number;
|
|
10
|
-
parameters: Map<string, number | string>;
|
|
11
|
+
parameters: Map<string, number | string | NumericValue>;
|
|
11
12
|
pins: Map<number, PinDefinition>;
|
|
12
13
|
pinNets: Map<number, Net>;
|
|
13
14
|
pinWires: Map<number, WireSegment[]>;
|
|
15
|
+
pinsMaxPositions: {
|
|
16
|
+
[key: string]: number;
|
|
17
|
+
};
|
|
14
18
|
_cachedPins: string;
|
|
15
19
|
_cachedParams: string;
|
|
16
|
-
className: string;
|
|
17
20
|
_copyID?: number;
|
|
18
21
|
_copyFrom?: ClassComponent;
|
|
19
|
-
arrangeProps: Map<string,
|
|
20
|
-
displayProp:
|
|
22
|
+
arrangeProps: Map<string, NumericValue[]> | null;
|
|
23
|
+
displayProp: SymbolDrawingCommands | null;
|
|
21
24
|
widthProp: number | null;
|
|
25
|
+
heightProp: number | null;
|
|
22
26
|
typeProp: string | null;
|
|
23
27
|
copyProp: boolean;
|
|
24
28
|
angleProp: number;
|
|
@@ -26,29 +30,28 @@ export declare class ClassComponent {
|
|
|
26
30
|
wireOrientationAngle: number;
|
|
27
31
|
useWireOrientationAngle: boolean;
|
|
28
32
|
didSetWireOrientationAngle: boolean;
|
|
29
|
-
styles: {
|
|
30
|
-
[key: string]: number | string;
|
|
31
|
-
};
|
|
32
33
|
assignedRefDes: string | null;
|
|
33
|
-
|
|
34
|
-
moduleCounter: number;
|
|
35
|
-
moduleExecutionContext: ExecutionContext;
|
|
36
|
-
moduleExecutionContextName: string;
|
|
37
|
-
modulePinIdToPortMap: Map<number, ClassComponent>;
|
|
38
|
-
constructor(instanceName: string, numPins: number, className: string);
|
|
34
|
+
constructor(instanceName: string, numPins: number);
|
|
39
35
|
setupPins(): void;
|
|
40
36
|
getDefaultPin(): number;
|
|
41
37
|
hasPin(pinId: number | string): boolean;
|
|
42
38
|
getPin(pinId: number | string): PinId;
|
|
43
39
|
getNextPinAfter(pinIndex: number): number;
|
|
44
|
-
setParam(key: string, value: number | string): void;
|
|
40
|
+
setParam(key: string, value: number | string | NumericValue): void;
|
|
45
41
|
hasParam(key: string): boolean;
|
|
46
42
|
private refreshParamCache;
|
|
47
43
|
private refreshPinsCache;
|
|
48
44
|
refreshCache(): void;
|
|
49
45
|
getParam<T>(key: string): T;
|
|
50
46
|
toString(): string;
|
|
51
|
-
static simple(instanceName: string, numPins: number
|
|
47
|
+
static simple(instanceName: string, numPins: number): ClassComponent;
|
|
52
48
|
isEqual(other: ClassComponent): boolean;
|
|
53
49
|
clone(): ClassComponent;
|
|
54
50
|
}
|
|
51
|
+
export declare class ModuleComponent extends ClassComponent {
|
|
52
|
+
moduleContainsExpressions?: Expressions_blockContext;
|
|
53
|
+
moduleCounter: number;
|
|
54
|
+
moduleExecutionContext?: ExecutionContext;
|
|
55
|
+
moduleExecutionContextName?: string;
|
|
56
|
+
modulePinIdToPortMap?: Map<number, ClassComponent>;
|
|
57
|
+
}
|
|
@@ -36,7 +36,7 @@ export declare class ExecutionScope {
|
|
|
36
36
|
private findNet;
|
|
37
37
|
getNetWithName(name: string): Net;
|
|
38
38
|
hasNet(component: ClassComponent, pin: number): boolean;
|
|
39
|
-
getNet(component: ClassComponent, pin: number): Net;
|
|
39
|
+
getNet(component: ClassComponent, pin: number): Net | null;
|
|
40
40
|
setNet(component: ClassComponent, pin: number, net: Net): void;
|
|
41
41
|
removeNet(component: ClassComponent, pin: number): void;
|
|
42
42
|
getNets(): ComponentPinNetPair[];
|
|
@@ -44,6 +44,7 @@ export declare class ExecutionScope {
|
|
|
44
44
|
printNets(): void;
|
|
45
45
|
setActive(type: ActiveObject, item: any): void;
|
|
46
46
|
clearActive(): void;
|
|
47
|
+
setCurrent(component: ClassComponent | null, pin?: number | null): void;
|
|
47
48
|
}
|
|
48
49
|
export declare enum SequenceAction {
|
|
49
50
|
To = "to",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FrameType } from "
|
|
1
|
+
import { FrameType } from "../globals.js";
|
|
2
2
|
export declare class Frame {
|
|
3
3
|
parameters: Map<string, any>;
|
|
4
4
|
frameId: number;
|
|
5
5
|
frameType: FrameType;
|
|
6
|
-
constructor(frameId: number, frameType
|
|
6
|
+
constructor(frameId: number, frameType?: FrameType);
|
|
7
7
|
}
|
|
8
8
|
export declare enum FrameParamKeys {
|
|
9
9
|
Title = "title",
|
|
@@ -13,7 +13,9 @@ export declare enum FrameParamKeys {
|
|
|
13
13
|
Width = "width",
|
|
14
14
|
Height = "height",
|
|
15
15
|
PaperSize = "paper_size",
|
|
16
|
-
SheetType = "sheet_type"
|
|
16
|
+
SheetType = "sheet_type",
|
|
17
|
+
SheetNumber = "sheet_number",
|
|
18
|
+
SheetTotal = "sheet_total"
|
|
17
19
|
}
|
|
18
20
|
export declare enum FramePlotDirection {
|
|
19
21
|
Row = "row",
|
|
@@ -1,16 +1,45 @@
|
|
|
1
|
+
import { Big } from 'big.js';
|
|
1
2
|
export declare class ParamDefinition {
|
|
2
3
|
paramName: string;
|
|
3
4
|
paramValue: string | number | any;
|
|
4
5
|
constructor(paramName: string, paramValue: any);
|
|
5
6
|
}
|
|
6
7
|
export declare class NumericValue {
|
|
7
|
-
value: string | number;
|
|
8
|
-
|
|
8
|
+
value: string | number | Big;
|
|
9
|
+
valuePart: Big;
|
|
10
|
+
prefixPart: number;
|
|
11
|
+
constructor(value: string | number | Big, prefix?: number);
|
|
9
12
|
toString(): string;
|
|
10
13
|
toDisplayString(): string;
|
|
14
|
+
toNumber(): number;
|
|
15
|
+
toBigNumber(): Big;
|
|
16
|
+
div(value: NumericValue | number): NumericValue;
|
|
17
|
+
mul(value: NumericValue | number): NumericValue;
|
|
18
|
+
add(value: NumericValue | number): NumericValue;
|
|
19
|
+
sub(value: NumericValue | number): NumericValue;
|
|
20
|
+
mod(value: NumericValue | number): NumericValue;
|
|
21
|
+
neg(): NumericValue;
|
|
22
|
+
eq(value: NumericValue): boolean;
|
|
11
23
|
}
|
|
24
|
+
export declare function numeric(value: number): NumericValue;
|
|
12
25
|
export declare class PercentageValue {
|
|
13
26
|
value: string | number;
|
|
14
27
|
constructor(value: string | number);
|
|
15
28
|
toString(): string;
|
|
29
|
+
toNumber(): number;
|
|
30
|
+
}
|
|
31
|
+
export declare class WrappedNumber {
|
|
32
|
+
value: number;
|
|
33
|
+
constructor(value: number);
|
|
34
|
+
toString(): string;
|
|
35
|
+
toNumber(): number;
|
|
36
|
+
}
|
|
37
|
+
export type NumberOperatorType = NumericValue | PercentageValue | WrappedNumber;
|
|
38
|
+
export declare class NumberOperator {
|
|
39
|
+
prepare(value: number | NumberOperatorType): NumberOperatorType;
|
|
40
|
+
multiply(value1: NumberOperatorType, value2: NumberOperatorType): NumberOperatorType;
|
|
41
|
+
divide(value1: NumberOperatorType, value2: NumberOperatorType): NumberOperatorType;
|
|
42
|
+
addition(value1: NumberOperatorType, value2: NumberOperatorType): NumberOperatorType;
|
|
43
|
+
subtraction(value1: NumberOperatorType, value2: NumberOperatorType): NumberOperatorType;
|
|
44
|
+
modulus(value1: NumberOperatorType, value2: NumberOperatorType): NumberOperatorType;
|
|
16
45
|
}
|
|
@@ -40,22 +40,27 @@ export declare class UndeclaredReference {
|
|
|
40
40
|
reference: ReferenceType;
|
|
41
41
|
constructor(reference: ReferenceType);
|
|
42
42
|
throwMessage(): string;
|
|
43
|
+
toString(): string;
|
|
44
|
+
nameString(): string;
|
|
43
45
|
}
|
|
44
46
|
export declare class DeclaredReference {
|
|
45
47
|
found: boolean;
|
|
46
48
|
name?: string;
|
|
47
49
|
trailers?: string[];
|
|
48
|
-
type?:
|
|
50
|
+
type?: 'value' | 'instance' | 'variable';
|
|
49
51
|
value?: any;
|
|
52
|
+
parentValue?: any;
|
|
50
53
|
constructor(refType: ReferenceType);
|
|
51
54
|
toString(): string;
|
|
55
|
+
toDisplayString(): string;
|
|
52
56
|
}
|
|
53
57
|
export type ReferenceType = {
|
|
54
58
|
found: boolean;
|
|
55
59
|
name?: string;
|
|
56
60
|
trailers?: string[];
|
|
57
|
-
type?:
|
|
61
|
+
type?: 'value' | 'instance' | 'variable';
|
|
58
62
|
value?: any;
|
|
63
|
+
parentValue?: any;
|
|
59
64
|
};
|
|
60
65
|
export declare enum ParseSymbolType {
|
|
61
66
|
Variable = "variable",
|
package/dist/types/render.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="pdfkit" />
|
|
2
2
|
import { Svg } from '@svgdotjs/svg.js';
|
|
3
3
|
import { SheetFrame } from "./layout.js";
|
|
4
|
-
|
|
4
|
+
import { Logger } from './logger.js';
|
|
5
|
+
export declare function renderSheetsToSVG(sheetFrames: SheetFrame[], logger: Logger): Svg;
|
|
5
6
|
export declare function generateSvgOutput(canvas: Svg, zoomScale?: number): string;
|
|
6
7
|
export declare function generatePdfOutput(doc: PDFKit.PDFDocument, canvas: Svg, sheetSize: string, sheetSizeDefined: boolean, zoomScale?: number): void;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { Big } from 'big.js';
|
|
2
|
+
import { ParserRuleContext } from "antlr4ng";
|
|
1
3
|
import { ClassComponent } from "./objects/ClassComponent";
|
|
4
|
+
import { NumericValue } from "./objects/ParamDefinition";
|
|
2
5
|
export declare class SimpleStopwatch {
|
|
3
6
|
startTime: Date;
|
|
4
7
|
constructor();
|
|
@@ -19,4 +22,9 @@ export declare function getBoundsSize(bounds: BoundBox): {
|
|
|
19
22
|
height: number;
|
|
20
23
|
};
|
|
21
24
|
export declare function getPortType(component: ClassComponent): string | null;
|
|
22
|
-
export declare function roundValue(value:
|
|
25
|
+
export declare function roundValue(value: NumericValue): NumericValue;
|
|
26
|
+
export declare function throwWithContext(context: ParserRuleContext, message: string): void;
|
|
27
|
+
export declare function combineMaps(map1: Map<string, any>, map2: Map<string, any>): Map<string, any>;
|
|
28
|
+
export declare function getNumberExponential(value: string): number;
|
|
29
|
+
export declare function getNumberExponentialText(value: number): string;
|
|
30
|
+
export declare function resolveToNumericValue(value: Big): NumericValue;
|
package/dist/types/visitor.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Add_component_exprContext, AdditionExprContext, At_blockContext, At_block_pin_exprContext, At_block_pin_expression_complexContext, At_block_pin_expression_simpleContext, At_component_exprContext, BinaryOperatorExprContext, Path_blocksContext, Component_select_exprContext, Create_component_exprContext, Create_graphic_exprContext, DataExprContext, Data_expr_with_assignmentContext, Double_dot_property_set_exprContext, Frame_exprContext, Function_def_exprContext, Keyword_assignment_exprContext, MultiplyExprContext, Nested_propertiesContext, Net_namespace_exprContext, Pin_select_expr2Context, Pin_select_exprContext, Point_exprContext, Property_exprContext, Property_key_exprContext, Property_set_exprContext, Single_line_propertyContext, To_component_exprContext, Wire_exprContext, UnaryOperatorExprContext, Wire_expr_direction_onlyContext, Wire_expr_direction_valueContext, If_exprContext, If_inner_exprContext, LogicalOperatorExprContext, Nested_properties_innerContext, Expressions_blockContext, Create_module_exprContext, Property_block_exprContext, While_exprContext, For_exprContext, GraphicCommandExprContext, Graphic_expressions_blockContext, GraphicForExprContext } from './antlr/CircuitScriptParser.js';
|
|
2
2
|
import { ClassComponent } from './objects/ClassComponent.js';
|
|
3
3
|
import { PinTypes } from './objects/PinTypes.js';
|
|
4
|
-
import { ComponentPin, ComponentPinNet } from './objects/types.js';
|
|
4
|
+
import { ComponentPin, ComponentPinNet, ComponentPinNetPair } from './objects/types.js';
|
|
5
5
|
import { Net } from './objects/Net.js';
|
|
6
6
|
import { BaseVisitor } from './BaseVisitor.js';
|
|
7
7
|
import { ParserRuleContext } from 'antlr4ng';
|
|
@@ -55,9 +55,12 @@ export declare class ParserVisitor extends BaseVisitor {
|
|
|
55
55
|
visitWhile_expr: (ctx: While_exprContext) => void;
|
|
56
56
|
visitFor_expr: (ctx: For_exprContext) => void;
|
|
57
57
|
private resolveDataExpr;
|
|
58
|
+
private resolveDataValue;
|
|
58
59
|
pinTypes: PinTypes[];
|
|
59
60
|
private parseCreateComponentPins;
|
|
60
61
|
private parseCreateModulePorts;
|
|
62
|
+
private getArrangePropFromModulePorts;
|
|
63
|
+
private getPortItems;
|
|
61
64
|
private parseCreateComponentParams;
|
|
62
65
|
printNets(): void;
|
|
63
66
|
dumpNets(): ComponentPinNet[];
|
|
@@ -72,16 +75,13 @@ export declare class ParserVisitor extends BaseVisitor {
|
|
|
72
75
|
getNetList(): NetListItem[];
|
|
73
76
|
getGraph(): {
|
|
74
77
|
sequence: any[];
|
|
75
|
-
nets:
|
|
76
|
-
components: ClassComponent[];
|
|
78
|
+
nets: ComponentPinNetPair[];
|
|
77
79
|
};
|
|
78
80
|
annotateComponents(): void;
|
|
79
81
|
applySheetFrameComponent(): {
|
|
80
82
|
frameComponent: ClassComponent | null;
|
|
81
83
|
};
|
|
82
84
|
private resolveNets;
|
|
83
|
-
private setComponentOrientation;
|
|
84
|
-
private setComponentFlip;
|
|
85
85
|
private getPropertyExprList;
|
|
86
86
|
}
|
|
87
87
|
export type NetListItem = {
|
package/libs/lib.cst
CHANGED
|
@@ -5,10 +5,10 @@ def net(net_name):
|
|
|
5
5
|
pins: 1
|
|
6
6
|
copy: true
|
|
7
7
|
angle: -90
|
|
8
|
-
display: create graphic:
|
|
8
|
+
display: create graphic (params):
|
|
9
9
|
hline: -50, 0, 100
|
|
10
10
|
vpin: 1, 0, 50, -50, display_pin_id=false
|
|
11
|
-
label:
|
|
11
|
+
label: params.net_name, 0, -15, fontSize=50, anchor="middle"
|
|
12
12
|
type: "net"
|
|
13
13
|
params:
|
|
14
14
|
net_name: net_name
|
|
@@ -19,10 +19,10 @@ def supply(net_name):
|
|
|
19
19
|
pins: 1
|
|
20
20
|
copy: true
|
|
21
21
|
angle: -90
|
|
22
|
-
display: create graphic:
|
|
22
|
+
display: create graphic (params):
|
|
23
23
|
hline: -50, 0, 100
|
|
24
24
|
vpin: 1, 0, 50, -50, display_pin_id=false
|
|
25
|
-
label:
|
|
25
|
+
label: params.net_name, 0, -15, fontSize=50, anchor="middle"
|
|
26
26
|
type: "net"
|
|
27
27
|
params:
|
|
28
28
|
net_name: net_name
|
|
@@ -33,11 +33,11 @@ def label(value, anchor="left"):
|
|
|
33
33
|
pins: 1
|
|
34
34
|
copy: true
|
|
35
35
|
followWireOrientation: false
|
|
36
|
-
display: create graphic:
|
|
36
|
+
display: create graphic (params):
|
|
37
37
|
textColor: "#222"
|
|
38
|
-
label:
|
|
38
|
+
label: params.value, 0, -10, fontSize=50, anchor=anchor
|
|
39
39
|
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
40
|
-
type: "
|
|
40
|
+
type: "net"
|
|
41
41
|
params:
|
|
42
42
|
net_name: value
|
|
43
43
|
value: value
|
|
@@ -47,9 +47,9 @@ def port(value, portType="input"):
|
|
|
47
47
|
return create component:
|
|
48
48
|
pins: 1
|
|
49
49
|
copy: true
|
|
50
|
-
display: create graphic:
|
|
50
|
+
display: create graphic (params):
|
|
51
51
|
textColor: "#222"
|
|
52
|
-
label:
|
|
52
|
+
label: params.value, 0, 0, fontSize=40, anchor="left", vanchor="middle", portType=portType
|
|
53
53
|
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
54
54
|
type: "port"
|
|
55
55
|
params:
|
|
@@ -63,12 +63,12 @@ def res(value):
|
|
|
63
63
|
|
|
64
64
|
return create component:
|
|
65
65
|
pins: 2
|
|
66
|
-
display: create graphic:
|
|
66
|
+
display: create graphic (params):
|
|
67
67
|
rect: 0, 0, width, height
|
|
68
68
|
hpin: 1, -width/2 - 30, 0, 30
|
|
69
69
|
hpin: 2, width/2 + 30, 0, -30
|
|
70
|
-
label:
|
|
71
|
-
label:
|
|
70
|
+
label: params.refdes, -width/2, -height/2 - 20, fontSize=50, anchor="left"
|
|
71
|
+
label: params.value, 0, 0, fontSize=30, anchor="middle", vanchor="middle"
|
|
72
72
|
type: "res"
|
|
73
73
|
params:
|
|
74
74
|
value: value
|
|
@@ -82,14 +82,14 @@ def cap(value):
|
|
|
82
82
|
return create component:
|
|
83
83
|
pins: 2
|
|
84
84
|
angle: 90
|
|
85
|
-
display: create graphic:
|
|
85
|
+
display: create graphic (params):
|
|
86
86
|
lineWidth: 13
|
|
87
87
|
hline: -width/2, 20, width
|
|
88
88
|
hline: -width/2, -20, width
|
|
89
89
|
vpin: 1, 0, -100, 80
|
|
90
90
|
vpin: 2, 0, 100, -80
|
|
91
|
-
label:
|
|
92
|
-
label:
|
|
91
|
+
label: params.refdes, 80, -30, fontSize=50, anchor="left", vanchor="middle"
|
|
92
|
+
label: params.value, 80, 30, fontSize=50, anchor = "left", vanchor="middle"
|
|
93
93
|
type: "cap"
|
|
94
94
|
params:
|
|
95
95
|
value: value
|
|
@@ -103,15 +103,15 @@ def ind(value):
|
|
|
103
103
|
return create component:
|
|
104
104
|
pins: 2
|
|
105
105
|
type: "ind"
|
|
106
|
-
display: create graphic:
|
|
106
|
+
display: create graphic (params):
|
|
107
107
|
arc: -15, 0, 5, 180, 360
|
|
108
108
|
arc: -5, 0, 5, 180, 360
|
|
109
109
|
arc: 5, 0, 5, 180, 360
|
|
110
110
|
arc: 15, 0, 5, 180, 360
|
|
111
111
|
hpin: 1, -width/2 - 20, 0, 20
|
|
112
112
|
hpin: 2, width/2 + 20, 0, -20
|
|
113
|
-
label: (
|
|
114
|
-
label: (
|
|
113
|
+
label: (params.refdes, -width/2, -height/2 -5 , fontSize=50, anchor="left")
|
|
114
|
+
label: (params.value, 0, 10, fontSize=50, anchor="middle", vanchor="middle")
|
|
115
115
|
params:
|
|
116
116
|
value: value
|
|
117
117
|
|
|
@@ -124,12 +124,12 @@ def diode():
|
|
|
124
124
|
return create component:
|
|
125
125
|
pins: 2
|
|
126
126
|
type: "diode"
|
|
127
|
-
display: create graphic:
|
|
127
|
+
display: create graphic (params):
|
|
128
128
|
triangle: -width/2, 0, width/2, 0, height
|
|
129
129
|
vline: width/2, -height/2, height
|
|
130
130
|
hpin: 1, -width/2-100, 0, 100 # anode
|
|
131
131
|
hpin: 2, width/2 + 100, 0, -100 # cathode
|
|
132
|
-
label:
|
|
132
|
+
label: params.refdes, 0, -100, fontSize=50, anchor="middle", vanchor="top"
|
|
133
133
|
|
|
134
134
|
def led(color):
|
|
135
135
|
width = 100
|
|
@@ -140,7 +140,7 @@ def led(color):
|
|
|
140
140
|
1: "cathode"
|
|
141
141
|
2: "anode"
|
|
142
142
|
type: "diode"
|
|
143
|
-
display: create graphic:
|
|
143
|
+
display: create graphic (params):
|
|
144
144
|
triangle: -width/2, 0, width/2, 0, height
|
|
145
145
|
vline: width/2, -height/2, height
|
|
146
146
|
path: ("M", 70, 30, "L", 130, 90,
|
|
@@ -149,10 +149,11 @@ def led(color):
|
|
|
149
149
|
"M", 180, 60, "L", 180, 90, "L", 150, 90)
|
|
150
150
|
hpin: 1, -width/2-100, 0, 100 # anode
|
|
151
151
|
hpin: 2, width/2 + 100, 0, -100 # cathode
|
|
152
|
-
label:
|
|
153
|
-
label:
|
|
152
|
+
label: params.refdes, 0, -100, fontSize=50, anchor="middle", vanchor="top"
|
|
153
|
+
label: params.color, 0, 100, fontSize=40, anchor="middle", vanchor="bottom"
|
|
154
154
|
params:
|
|
155
155
|
size: "0603"
|
|
156
|
+
color: color
|
|
156
157
|
footprint: "LED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolder"
|
|
157
158
|
|
|
158
159
|
|
|
@@ -162,12 +163,12 @@ def cgnd():
|
|
|
162
163
|
pins: 1
|
|
163
164
|
copy: true
|
|
164
165
|
angle: 90
|
|
165
|
-
display: create graphic:
|
|
166
|
+
display: create graphic (params):
|
|
166
167
|
hline: -15, 0, 30
|
|
167
168
|
hline: -10, 5, 20
|
|
168
169
|
hline: -5, 10, 10
|
|
169
170
|
vpin: 1, 0, -10, 10, display_pin_id=false
|
|
170
|
-
label:
|
|
171
|
+
label: params.net_name, 0, 22, fontSize=50, anchor="middle"
|
|
171
172
|
type: "net"
|
|
172
173
|
params:
|
|
173
174
|
net_name: net_name
|
|
@@ -181,10 +182,10 @@ def dgnd(net_name="GND"):
|
|
|
181
182
|
pins: 1
|
|
182
183
|
copy: true
|
|
183
184
|
angle: 90
|
|
184
|
-
display: create graphic:
|
|
185
|
+
display: create graphic (params):
|
|
185
186
|
triangle: 0, 0, 0, height, width
|
|
186
187
|
vpin: 1, 0, -50, 50, display_pin_id=false
|
|
187
|
-
label:
|
|
188
|
+
label: params.net_name, 0, height + 50, fontSize=50, anchor="middle", vanchor="middle"
|
|
188
189
|
type: "net"
|
|
189
190
|
params:
|
|
190
191
|
net_name: net_name
|
|
@@ -194,6 +195,7 @@ def text(value, offsetX = 0, offsetY = 0, fontSize = 50):
|
|
|
194
195
|
return create component:
|
|
195
196
|
pins: 1
|
|
196
197
|
followWireOrientation: false
|
|
198
|
+
type: "graphic"
|
|
197
199
|
display: create graphic:
|
|
198
200
|
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
199
201
|
text:
|
|
@@ -221,6 +223,17 @@ def arrow_point():
|
|
|
221
223
|
path: ("M", -5, 0, "L", -20, 0)
|
|
222
224
|
hpin: 1, 0, 0, 0, display_pin_id=false
|
|
223
225
|
|
|
226
|
+
def no_connect(size=20):
|
|
227
|
+
return create component:
|
|
228
|
+
pins: 1
|
|
229
|
+
display: create graphic:
|
|
230
|
+
path: "M", -size, -size, "L", size, size
|
|
231
|
+
path: "M", -size, size, "L", size, -size
|
|
232
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
233
|
+
|
|
234
|
+
def dnc(size=20):
|
|
235
|
+
return no_connect(size)
|
|
236
|
+
|
|
224
237
|
def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin_y,
|
|
225
238
|
col_display_value, row_display_value, inner_frame_margin = 50):
|
|
226
239
|
|
|
@@ -230,6 +243,9 @@ def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin
|
|
|
230
243
|
vertical_1 = margin_y - inner_frame_margin
|
|
231
244
|
vertical_2 = paper_height - margin_y + inner_frame_margin
|
|
232
245
|
|
|
246
|
+
inner_width = paper_width - 2 * margin_x
|
|
247
|
+
inner_height = paper_height - 2 * margin_y
|
|
248
|
+
|
|
233
249
|
tmp_height = paper_height - margin_y * 2 + inner_frame_margin * 2
|
|
234
250
|
tmp_y = margin_y - inner_frame_margin
|
|
235
251
|
|
|
@@ -244,9 +260,19 @@ def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin
|
|
|
244
260
|
ratio_x = 1 / num_columns
|
|
245
261
|
ratio_y = 1 / num_rows
|
|
246
262
|
|
|
263
|
+
title_block_width = 2000
|
|
264
|
+
title_block_height = 350
|
|
265
|
+
|
|
266
|
+
# center of title_block
|
|
267
|
+
title_block_x = margin_x + inner_width - title_block_width
|
|
268
|
+
title_block_y = margin_y + inner_height - title_block_height
|
|
269
|
+
|
|
270
|
+
title_block_x2 = title_block_x + title_block_width
|
|
271
|
+
title_block_y2 = title_block_y + title_block_height
|
|
272
|
+
|
|
247
273
|
return create component:
|
|
248
|
-
type: "
|
|
249
|
-
display: create graphic:
|
|
274
|
+
type: "graphic"
|
|
275
|
+
display: create graphic (params):
|
|
250
276
|
fill: "none"
|
|
251
277
|
|
|
252
278
|
# outer rect
|
|
@@ -255,7 +281,7 @@ def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin
|
|
|
255
281
|
|
|
256
282
|
# inner rect
|
|
257
283
|
lineColor: "#111111"
|
|
258
|
-
rect: paper_width/2, paper_height/2,
|
|
284
|
+
rect: paper_width/2, paper_height/2, inner_width, inner_height
|
|
259
285
|
|
|
260
286
|
rect: (paper_width/2, paper_height/2,
|
|
261
287
|
paper_width - 2 * margin_x + inner_frame_margin * 2,
|
|
@@ -300,7 +326,46 @@ def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin
|
|
|
300
326
|
anchor: "middle"
|
|
301
327
|
vanchor: "middle"
|
|
302
328
|
|
|
329
|
+
# Draw title frame
|
|
330
|
+
text:
|
|
331
|
+
content: "Size: " + paper_size_name
|
|
332
|
+
offset: title_block_x + 20, title_block_y2 - 30
|
|
333
|
+
anchor: "left"
|
|
334
|
+
vanchor: "bottom"
|
|
335
|
+
|
|
336
|
+
text:
|
|
337
|
+
content: "Sheet: " + params.sheet_number + "/" + params.sheet_total
|
|
338
|
+
anchor: "left"
|
|
339
|
+
vanchor: "bottom"
|
|
340
|
+
offset: title_block_x + title_block_width / 2 + 20, title_block_y2 - 30
|
|
341
|
+
|
|
342
|
+
hline: title_block_x, title_block_y2 - 100, title_block_width
|
|
343
|
+
vline: title_block_x + title_block_width / 2, title_block_y2, -100
|
|
344
|
+
|
|
345
|
+
text:
|
|
346
|
+
content: "Rev: " + params.revision
|
|
347
|
+
anchor: "left"
|
|
348
|
+
vanchor: "bottom"
|
|
349
|
+
offset: title_block_x + 20 , title_block_y2 - 130
|
|
350
|
+
|
|
351
|
+
hline: title_block_x, title_block_y2 - 200, title_block_width
|
|
352
|
+
|
|
353
|
+
text:
|
|
354
|
+
content: params.title
|
|
355
|
+
offset: title_block_x + 20, title_block_y2 - 240
|
|
356
|
+
bold: true
|
|
357
|
+
fontSize: 60
|
|
358
|
+
anchor: "left"
|
|
359
|
+
vanchor: "bottom"
|
|
360
|
+
|
|
361
|
+
rect: title_block_x + title_block_width / 2, title_block_y + title_block_height / 2, title_block_width, title_block_height
|
|
362
|
+
|
|
303
363
|
params:
|
|
364
|
+
title: "Sheet title"
|
|
365
|
+
revision: "V1"
|
|
366
|
+
sheet_number: 1
|
|
367
|
+
sheet_total: 1
|
|
368
|
+
|
|
304
369
|
paper_size: paper_size_name
|
|
305
370
|
paper_width: paper_width
|
|
306
371
|
paper_height: paper_height
|
|
@@ -350,9 +415,14 @@ def sheet_A5():
|
|
|
350
415
|
|
|
351
416
|
return sheet_generator("A5", paper_width, paper_height, margin, margin, range(1, 5), ["A", "B", "C"])
|
|
352
417
|
|
|
353
|
-
def sheet_A6():
|
|
418
|
+
def sheet_A6(revision="V1"):
|
|
354
419
|
paper_width = toMils(148)
|
|
355
420
|
paper_height = toMils(105)
|
|
356
421
|
margin = 400
|
|
357
422
|
|
|
358
|
-
|
|
423
|
+
tmp_sheet = sheet_generator("A6", paper_width, paper_height, margin, margin, range(1, 4), ["A", "B"])
|
|
424
|
+
tmp_sheet.revision = revision
|
|
425
|
+
|
|
426
|
+
return tmp_sheet
|
|
427
|
+
|
|
428
|
+
document.sheet_type = sheet_A4()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "circuitscript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Interpreter for the circuitscript language",
|
|
5
5
|
"homepage": "https://circuitscript.net",
|
|
6
6
|
"engines": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"libs"
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
|
+
"@types/big.js": "^6.2.2",
|
|
27
28
|
"@types/figlet": "^1.5.8",
|
|
28
29
|
"@types/jest": "~29.5",
|
|
29
30
|
"@types/node": "~18",
|
|
@@ -69,7 +70,9 @@
|
|
|
69
70
|
"profile-flame": "node --prof-process --preprocess -j isolate*.log | flamebearer",
|
|
70
71
|
"server": "node server.js",
|
|
71
72
|
"pack-local": "npm pack; rm circuitscript-install.tgz; mv `ls | grep circuitscript` circuitscript-install.tgz; cp circuitscript-install.tgz ../circuitscript-vscode/client; cp circuitscript-install.tgz ../circuitscript-vscode/server",
|
|
72
|
-
"changelog": "auto-changelog --handlebars-setup ../changelog/helper.js"
|
|
73
|
+
"changelog": "auto-changelog --handlebars-setup ../changelog/helper.js -p",
|
|
74
|
+
"preversion": "npm run test",
|
|
75
|
+
"version": "npm run changelog && git add CHANGELOG.md"
|
|
73
76
|
},
|
|
74
77
|
"boilerplate_author": "Jakub Synowiec <jsynowiec@users.noreply.github.com>",
|
|
75
78
|
"license": "MIT",
|
|
@@ -78,13 +81,14 @@
|
|
|
78
81
|
"@flatten-js/core": "1.5.5",
|
|
79
82
|
"@svgdotjs/svg.js": "3.2.0",
|
|
80
83
|
"antlr4ng": "^3.0.4",
|
|
84
|
+
"big.js": "^6.2.2",
|
|
81
85
|
"commander": "^11.1.0",
|
|
82
86
|
"express": "^4.18.2",
|
|
83
87
|
"figlet": "^1.7.0",
|
|
84
88
|
"lodash": "^4.17.21",
|
|
85
89
|
"pdfkit": "^0.15.1",
|
|
86
90
|
"svg-to-pdfkit": "^0.1.8",
|
|
87
|
-
"svgdom": "0.1.14",
|
|
91
|
+
"svgdom": "^0.1.14",
|
|
88
92
|
"this-file": "^2.0.3",
|
|
89
93
|
"tslib": "~2.5",
|
|
90
94
|
"ws": "^8.14.2"
|