Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion scripts/config/pathsim/blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"Divider",
"Amplifier",
"Function",
"Polynomial",
"Sin",
"Cos",
"Tan",
Expand Down Expand Up @@ -78,9 +79,15 @@
"LogicNot"
],

"Mixed": [
"Discrete": [
"SampleHold",
"FirstOrderHold",
"FIR",
"DiscreteIntegrator",
"DiscreteDerivative",
"DiscreteStateSpace",
"DiscreteTransferFunction",
"TappedDelay",
"ADC",
"DAC",
"Counter",
Expand Down
11 changes: 11 additions & 0 deletions src/lib/components/icons/blocks/curves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,17 @@ export function sampleHoldSamples(n = 6): Sample[] {
return out;
}

/** First-order hold — piecewise-linear interpolation through sample points.
* Same sample values as SampleHold so the two icons read as a pair. */
export function firstOrderHoldSamples(n = 6): Sample[] {
const samplesY = [0.1, 0.3, 0.55, 0.75, 0.55, 0.85];
const out: Sample[] = [];
for (let i = 0; i < n; i++) {
out.push([i / (n - 1), samplesY[i]]);
}
return out;
}

export function backlashSamples(): Sample[] {
return [
[-1, -0.7],
Expand Down
9 changes: 9 additions & 0 deletions src/lib/components/icons/blocks/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ export const iconRegistry: Record<string, IconDef> = {
DynamicalSystem: { kind: 'math', latex: '\\begin{aligned}\\dot{x} &= f(x, u, t)\\\\ y &= g(x, u, t)\\end{aligned}' },
DynamicalFunction: { kind: 'math', latex: 'f(u, t)' },
Function: { kind: 'math', latex: 'f(u)' },
Polynomial: { kind: 'math', latex: 'y = \\sum_{k=0}^{n} c_k\\,u^{n-k}' },

/* --- Discrete-time blocks --- */
FirstOrderHold: { kind: 'plot', samples: () => C.firstOrderHoldSamples() },
DiscreteIntegrator: { kind: 'math', latex: '\\dfrac{T}{z-1}' },
DiscreteDerivative: { kind: 'math', latex: '\\dfrac{z-1}{T\\,z}' },
DiscreteStateSpace: { kind: 'math', latex: '\\begin{aligned}x[k{+}1] &= Ax[k]{+}Bu[k]\\\\ y[k] &= Cx[k]{+}Du[k]\\end{aligned}' },
DiscreteTransferFunction: { kind: 'math', latex: 'H(z) = \\dfrac{B(z)}{A(z)}' },
TappedDelay: { kind: 'svg', name: 'TappedDelay' },

/* --- Geometric SVGs (kept as files) --- */
Adder: { kind: 'svg', name: 'Adder' },
Expand Down
8 changes: 8 additions & 0 deletions src/lib/components/icons/blocks/svg/TappedDelay.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/lib/constants/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const BLOCK_CATEGORY_ORDER: string[] = [
'Dynamic',
'Algebraic',
'Logic',
'Mixed',
'Discrete',
'Recording',
'Subsystem'
];
Expand Down
218 changes: 200 additions & 18 deletions src/lib/nodes/generated/blocks.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/lib/nodes/shapes/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const categoryShapeMap: Record<string, string> = {
Dynamic: 'rect',
Algebraic: 'rect',
Logic: 'rect',
Mixed: 'mixed',
Discrete: 'mixed',
Recording: 'pill',
Subsystem: 'rect',
Chemical: 'rect'
Expand Down
8 changes: 6 additions & 2 deletions src/lib/nodes/uiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,16 @@ export const syncPortBlocks = new Set([
'Mod',
'Clip',
'Pow',
'Polynomial',
'Rescale',
'Alias',

// Logic blocks (element-wise)
'LogicNot',

// Mixed blocks (parallel sampling)
'SampleHold'
// Discrete blocks (parallel sampling / discrete dynamics)
'SampleHold',
'FirstOrderHold',
'DiscreteIntegrator',
'DiscreteDerivative'
]);
Loading