feat(inputs.mock): Add sine phase (#15990)
This commit is contained in:
parent
31ddd699c5
commit
391b4b86a7
|
|
@ -40,6 +40,7 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
||||||
# name = "wave"
|
# name = "wave"
|
||||||
# amplitude = 1.0
|
# amplitude = 1.0
|
||||||
# period = 0.5
|
# period = 0.5
|
||||||
|
# phase = 20.0
|
||||||
# base_line = 0.0
|
# base_line = 0.0
|
||||||
# [[inputs.mock.step]]
|
# [[inputs.mock.step]]
|
||||||
# name = "plus_one"
|
# name = "plus_one"
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ type sineWave struct {
|
||||||
Name string `toml:"name"`
|
Name string `toml:"name"`
|
||||||
Amplitude float64 `toml:"amplitude"`
|
Amplitude float64 `toml:"amplitude"`
|
||||||
Period float64 `toml:"period"`
|
Period float64 `toml:"period"`
|
||||||
|
Phase float64 `toml:"phase"`
|
||||||
BaseLine float64 `toml:"base_line"`
|
BaseLine float64 `toml:"base_line"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,7 +119,7 @@ func (m *Mock) generateRandomFloat64(fields map[string]interface{}) {
|
||||||
// Create sine waves
|
// Create sine waves
|
||||||
func (m *Mock) generateSineWave(fields map[string]interface{}) {
|
func (m *Mock) generateSineWave(fields map[string]interface{}) {
|
||||||
for _, field := range m.SineWave {
|
for _, field := range m.SineWave {
|
||||||
fields[field.Name] = math.Sin(float64(m.counter)*field.Period*math.Pi)*field.Amplitude + field.BaseLine
|
fields[field.Name] = math.Sin((float64(m.counter)+field.Phase)*field.Period*math.Pi)*field.Amplitude + field.BaseLine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
# name = "wave"
|
# name = "wave"
|
||||||
# amplitude = 1.0
|
# amplitude = 1.0
|
||||||
# period = 0.5
|
# period = 0.5
|
||||||
|
# phase = 20.0
|
||||||
# base_line = 0.0
|
# base_line = 0.0
|
||||||
# [[inputs.mock.step]]
|
# [[inputs.mock.step]]
|
||||||
# name = "plus_one"
|
# name = "plus_one"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue