Skip to content

Commit 54bac8b

Browse files
added new maths blocks
1 parent 45c29c4 commit 54bac8b

2 files changed

Lines changed: 66 additions & 3 deletions

File tree

src/nodeConfig.js

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import IntegratorNode from './components/nodes/IntegratorNode';
77
import AdderNode from './components/nodes/AdderNode';
88
import ScopeNode from './components/nodes/ScopeNode';
99
import StepSourceNode from './components/nodes/StepSourceNode';
10-
import {createFunctionNode} from './components/nodes/FunctionNode';
10+
import { createFunctionNode } from './components/nodes/FunctionNode';
1111
import DefaultNode from './components/nodes/DefaultNode';
1212
import MultiplierNode from './components/nodes/MultiplierNode';
1313
import { Splitter2Node, Splitter3Node } from './components/nodes/Splitters';
@@ -60,6 +60,32 @@ export const nodeTypes = {
6060
fir: DefaultNode
6161
};
6262

63+
export const nodeMathTypes = {
64+
sin: DefaultNode,
65+
cos: DefaultNode,
66+
sqrt: DefaultNode,
67+
abs: DefaultNode,
68+
pow: DefaultNode,
69+
exp: DefaultNode,
70+
log: DefaultNode,
71+
log10: DefaultNode,
72+
tan: DefaultNode,
73+
sinh: DefaultNode,
74+
cosh: DefaultNode,
75+
tanh: DefaultNode,
76+
atan: DefaultNode,
77+
norm: DefaultNode,
78+
mod: DefaultNode,
79+
clip: DefaultNode,
80+
}
81+
82+
// add nodeMathTypes to nodeTypes
83+
Object.keys(nodeMathTypes).forEach(type => {
84+
if (!nodeTypes[type]) {
85+
nodeTypes[type] = nodeMathTypes[type];
86+
}
87+
});
88+
6389
// Node categories for better organization
6490
export const nodeCategories = {
6591
'Sources': {
@@ -71,7 +97,7 @@ export const nodeCategories = {
7197
description: 'Signal processing and transformation nodes'
7298
},
7399
'Math': {
74-
nodes: ['adder', 'multiplier', 'splitter2', 'splitter3'],
100+
nodes: ['adder', 'multiplier', 'splitter2', 'splitter3'].concat(Object.keys(nodeMathTypes)),
75101
description: 'Mathematical operation nodes'
76102
},
77103
'Control': {
@@ -124,8 +150,24 @@ export const getNodeDisplayName = (nodeType) => {
124150
'scope': 'Scope',
125151
'spectrum': 'Spectrum',
126152
'differentiator': 'Differentiator',
153+
'sin': 'Sine',
154+
'cos': 'Cosine',
155+
'sqrt': 'Square Root',
156+
'abs': 'Absolute',
157+
'pow': 'Power',
158+
'exp': 'Exponential',
159+
'log': 'Logarithm',
160+
'log10': 'Logarithm (Base 10)',
161+
'tan': 'Tangent',
162+
'sinh': 'Hyperbolic Sine',
163+
'cosh': 'Hyperbolic Cosine',
164+
'tanh': 'Hyperbolic Tangent',
165+
'atan': 'Inverse Tangent',
166+
'norm': 'Normalization',
167+
'mod': 'Modulo',
168+
'clip': 'Clipping',
127169
};
128-
170+
129171
return displayNames[nodeType] || nodeType.charAt(0).toUpperCase() + nodeType.slice(1);
130172
};
131173

src/python/pathsim_utils.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,27 @@
8888
"fir": pathsim.blocks.FIR,
8989
}
9090

91+
math_blocks = {
92+
"sin": pathsim.blocks.Sin,
93+
"cos": pathsim.blocks.Cos,
94+
"sqrt": pathsim.blocks.Sqrt,
95+
"abs": pathsim.blocks.Abs,
96+
"pow": pathsim.blocks.Pow,
97+
"exp": pathsim.blocks.Exp,
98+
"log": pathsim.blocks.Log,
99+
"log10": pathsim.blocks.Log10,
100+
"tan": pathsim.blocks.Tan,
101+
"sinh": pathsim.blocks.Sinh,
102+
"cosh": pathsim.blocks.Cosh,
103+
"tanh": pathsim.blocks.Tanh,
104+
"atan": pathsim.blocks.Atan,
105+
"norm": pathsim.blocks.Norm,
106+
"mod": pathsim.blocks.Mod,
107+
"clip": pathsim.blocks.Clip,
108+
}
109+
110+
map_str_to_object.update(math_blocks)
111+
91112
map_str_to_event = {
92113
"ZeroCrossingDown": pathsim.events.ZeroCrossingDown,
93114
"ZeroCrossingUp": pathsim.events.ZeroCrossingUp,

0 commit comments

Comments
 (0)