Skip to content

Commit 65b01f6

Browse files
Merge pull request #62 from kwehage/kwehage-function-add
Add more function and signal generator blocks
2 parents fcae4ce + 437195c commit 65b01f6

7 files changed

+536
-128
lines changed

doc/fastcat_device_config_parameters.md

+141-20
Original file line numberDiff line numberDiff line change
@@ -775,21 +775,35 @@ Note: Exactly 6 signals must be specified in the signals list.
775775

776776
## Function
777777

778-
| Parameter | Description |
779-
| --------------- | ------------------------------------------------------------ |
780-
| `function_type` | type of function {`POLYNOMINAL`} |
781-
| `order` | `POLYNOMINAL` only. Order of polynominal function |
782-
| `coefficients` | `POLYNOMINAL` only. The coefficients, length must be equal to `order + 1` . Starts with highest-power term. |
783-
784-
Currently, only an N-order Polynomial function is implemented. Other function types could include logistic, expoentials, sigmoid, etc. Open an issue (or pull request) if you would like to see more functions added.
785-
786-
The `coefficients`(here `coeff`) are specified in the following order (`N`)
778+
| Parameter | Description |
779+
| --------------------- | ------------------------------------------------------------ |
780+
| `function_type` | type of function {`POLYNOMINAL`, `SUMMATION`, `MULTIPLICATION`, `POWER`, `EXPONENTIAL`, `SIGMOID`} |
781+
| | |
782+
| for `POLYNOMIAL`: | |
783+
| `order` | order of polynomial |
784+
| `coefficients` | Polynomial coefficients; length must be equal to `order + 1` . Starts with highest-power term. |
785+
| | |
786+
| for `SUMMATION`: | no additional parameters, specify `signals` field only, signals will be added together |
787+
| | |
788+
| for `MULTIPLICATION`: | no additional parameters, specify `signals` field only, signals will be multiplied together |
789+
| | |
790+
| for `POWER`: | raises a single signal to a constant power: `(x^a)` |
791+
| `exponent` | exponent |
792+
| | |
793+
| for `EXPONENTIAL` | raises a constant to the value of a single signal: `(a^x)` |
794+
| `base` | base (`a`; optional; if not provided, defaults to euler's number `e`) |
795+
| | |
796+
| for `SIGMOID`: | logistic function defined by `1.0 / (1 + e^-x)` |
797+
798+
799+
### Polynomial
800+
The `coefficients` (here `coeff`) are specified in the following order (`N`)
787801

788802
```
789803
y = coeff[0] * x^(N) + coeff[1] * x^(N-1) + ... + coeff[N-1] * x^(1) + coeff[N] * x^(0);
790804
```
791805
792-
Note: The function device only accepts a single signal. Multi-variate functions are not supported currently - if they are implemented, a new device type should be created.
806+
Note: The function device only accepts a single signal. Multi-variate polynomial functions are not currently supported.
793807
794808
#### Example
795809
@@ -802,10 +816,90 @@ Implement the function `y = 1*x + 100`
802816
order: 1
803817
coefficients: [1, 100]
804818
signals:
805-
- observed_device_name: sig_gen_1signal
819+
- observed_device_name: sig_gen_1
820+
request_signal_name: output
821+
```
822+
823+
824+
### Summation
825+
Specify two or more signals to sum together
826+
827+
#### Example
828+
829+
Implement the function `y = x1 + x2`
830+
831+
```yaml
832+
- device_class: Function
833+
name: fun_2
834+
function_type: SUMMATION
835+
signals:
836+
- observed_device_name: sig_gen_1
837+
request_signal_name: output
838+
- observed_device_name: sig_gen_2
806839
request_signal_name: output
807840
```
808841
842+
### Multiplication
843+
Specify two or more signals to multiply together
844+
845+
#### Example
846+
847+
Implement the function `y = x1 * x2 * x3`
848+
849+
```yaml
850+
- device_class: Function
851+
name: fun_3
852+
function_type: MULTIPLICATION
853+
signals:
854+
- observed_device_name: sig_gen_1
855+
request_signal_name: output
856+
- observed_device_name: sig_gen_2
857+
request_signal_name: output
858+
- observed_device_name: sig_gen_3
859+
request_signal_name: output
860+
```
861+
862+
863+
### Exponential
864+
Raise a constant to the power of the signal
865+
866+
#### Example
867+
Implement the function `y = e^x`
868+
869+
```yaml
870+
- device_class: Function
871+
name: fun_4
872+
function_type: EXPONENTIAL
873+
- observed_device_name: sig_gen_1
874+
request_signal_name: output
875+
```
876+
877+
Implement the function `y = 2.0^x`
878+
```yaml
879+
- device_class: Function
880+
name: fun_5
881+
function_type: EXPONENTIAL
882+
base: 2.0
883+
- observed_device_name: sig_gen_1
884+
request_signal_name: output
885+
```
886+
887+
888+
### Sigmoid
889+
Return the sigmoid logistic function
890+
891+
#### Example
892+
Implement the sigmoid logistic function `y = 1.0 / (1.0 + e^-x)`
893+
894+
```yaml
895+
- device_class: Function
896+
name: fun_6
897+
function_type: SIGMOID
898+
- observed_device_name: sig_gen_1
899+
request_signal_name: output
900+
```
901+
902+
809903
## Pid
810904

811905
| Parameter | Description |
@@ -886,18 +980,28 @@ if signal is falling
886980

887981
| Parameter | Description |
888982
| ----------------------- | --------------------------------------------------------- |
889-
| `signal_generator_type` | The type of signal to generate {`SINE_WAVE`, `SAW_TOOTH`} |
983+
| `signal_generator_type` | The type of signal to generate {`SINE_WAVE`, `SAW_TOOTH`, `GAUSSIAN_RANDOM`, `UNIFORM_RANDOM`} |
890984
| | |
891-
| for `SINE_WAVE`, | |
892-
| `angular_frequency` | obvious |
893-
| `phase` | obvious |
894-
| `amplitude` | obvious |
895-
| `offset` | obvious |
985+
| for `SINE_WAVE`: | |
986+
| `angular_frequency` | sine wave angular frequency |
987+
| `phase` | sine wave phase |
988+
| `amplitude` | sine wave amplitude |
989+
| `offset` | sine wave offset |
896990
| | |
897-
| for `SAW_TOOTH`, | |
991+
| for `SAW_TOOTH`: | |
898992
| `max` | max value of the sawtooth wave |
899993
| `min` | min value of the sawtooth wave |
900994
| `slope` | The rate of change in EU/sec. May be positive or negative |
995+
| | |
996+
| for `GAUSSIAN_RANDOM`: | |
997+
| `mean` | mean signal value |
998+
| `sigma` | standard deviation |
999+
| `seed` | specify random seed as an optional unsigned integer; each signal generator uses its own random seed; if no random seed is provided, defaults to 1 |
1000+
| | |
1001+
| for `UNIFORM_RANDOM`: | |
1002+
| `max` | maximum signal value |
1003+
| `min` | minimum signal value |
1004+
| `seed` | specify random seed as an optional unsigned integer; each signal generator uses its own random seed; if no random seed is provided, defaults to 1 |
9011005

9021006
The `SINE_WAVE` signal generator output is computed as:
9031007

@@ -912,7 +1016,7 @@ The `SAW_TOOTH` signal generator output is computed as:
9121016
* apply slope each process update
9131017
* when the 'upper' limit is reached, reset the output 'lower' limit
9141018

915-
#### Example
1019+
#### Examples
9161020

9171021
``` yaml
9181022
- device_class: SignalGenerator
@@ -926,13 +1030,30 @@ The `SAW_TOOTH` signal generator output is computed as:
9261030

9271031
``` yaml
9281032
- device_class: SignalGenerator
929-
name: sig_gen_2signal
1033+
name: sig_gen_2
9301034
signal_generator_type: SAW_TOOTH
9311035
max: 1
9321036
min: 0
9331037
slope: 1
9341038
```
9351039

1040+
```yaml
1041+
- device_class: SignalGenerator
1042+
name: sig_gen_3
1043+
signal_generator_type: GAUSSIAN_RANDOM
1044+
mean: 0.0
1045+
sigma: 0.2
1046+
seed: 50
1047+
```
1048+
1049+
```yaml
1050+
- device_class: SignalGenerator
1051+
name: sig_gen_4
1052+
signal_generator_type: UNIFORM_RANDOM
1053+
min: -5.0
1054+
max: 10.0
1055+
# seed is optional
1056+
```
9361057

9371058

9381059
## VirtualFts

example_configs/one_of_every_device_offline.yaml

+67
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,27 @@ buses:
9595
amplitude: 10
9696
offset: 0
9797

98+
- device_class: SignalGenerator
99+
name: sig_gen_2
100+
signal_generator_type: SAW_TOOTH
101+
slope: 10.0
102+
max: 0.5
103+
min: -0.5
104+
105+
- device_class: SignalGenerator
106+
name: sig_gen_3
107+
signal_generator_type: GAUSSIAN_RANDOM
108+
seed: 2
109+
mean: 0.0
110+
sigma: 0.2
111+
112+
- device_class: SignalGenerator
113+
name: sig_gen_4
114+
signal_generator_type: UNIFORM_RANDOM
115+
min: -10.0
116+
max: 20.0
117+
# seed is an optional parameter, uses default of 1 if not provided
118+
98119
- device_class: Conditional
99120
name: cond_1
100121
conditional_type: ">"
@@ -179,6 +200,52 @@ buses:
179200
- observed_device_name: sig_gen_1
180201
request_signal_name: output
181202

203+
- device_class: Function
204+
name: fun_2
205+
function_type: SUMMATION
206+
signals:
207+
- observed_device_name: sig_gen_1
208+
request_signal_name: output
209+
- observed_device_name: sig_gen_2
210+
request_signal_name: output
211+
212+
- device_class: Function
213+
name: fun_3
214+
function_type: MULTIPLICATION
215+
signals:
216+
- observed_device_name: sig_gen_1
217+
request_signal_name: output
218+
- observed_device_name: sig_gen_2
219+
request_signal_name: output
220+
- observed_device_name: sig_gen_3
221+
request_signal_name: output
222+
223+
- device_class: Function
224+
name: fun_4
225+
function_type: POWER
226+
exponent: 4 # raise signal to the 4th power (x^4)
227+
signals:
228+
- observed_device_name: sig_gen_1
229+
request_signal_name: output
230+
231+
- device_class: Function
232+
name: fun_5
233+
function_type: EXPONENTIAL
234+
base: 4 # raise 4 to the power of the signal (4^x)
235+
signals:
236+
- observed_device_name: sig_gen_1
237+
request_signal_name: output
238+
239+
- device_class: Function
240+
name: fun_6
241+
function_type: EXPONENTIAL
242+
# When 'base' is not specified, uses the default exponential function
243+
# exp(x), which uses a base equal to euler's number `e`
244+
# This example raises e to the power of the signal (e^x)
245+
signals:
246+
- observed_device_name: sig_gen_1
247+
request_signal_name: output
248+
182249
- device_class: Filter
183250
name: filt_lowpass_1
184251
filter_type: DIGITAL_AB

0 commit comments

Comments
 (0)