Skip to content

Commit

Permalink
feat: Support customize helicorder size, scale and samples per span
Browse files Browse the repository at this point in the history
  • Loading branch information
bclswl0827 committed Dec 24, 2024
1 parent 29bdbfe commit 3055ac7
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Starting from v2.2.5, all notable changes to this project will be documented in this file.

## v3.6.0

### Bug Fixes

- Fixed incorrect coordinates when legacy mode enabled.

### New Features

- Support customizing helicorder image size, waveform scale and samples per span.

## v3.5.0

### New Features
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.5.0
v3.6.0
3 changes: 3 additions & 0 deletions build/assets/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
"helicorder": {
"enable": true,
"lifecycle": 10,
"scale": 2.0,
"size": 1000,
"samples": 10000,
"path": "/home/user/helicorder"
}
}
Expand Down
7 changes: 7 additions & 0 deletions services/helicorder/default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package helicorder

func (s *HelicorderService) loadDefault() {
s.imageSize = HELICORDER_IMAGE_SIZE
s.spanSamples = HELICORDER_DOWNSAMPLE_FACTOR
s.scaleFactor = HELICORDER_SCALE_FACTOR
}
16 changes: 14 additions & 2 deletions services/helicorder/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ func (m *HelicorderService) Start(options *services.Options, waitGroup *sync.Wai
m.stationCode = options.Config.Stream.Station
m.networkCode = options.Config.Stream.Network
m.locationCode = options.Config.Stream.Location
m.loadDefault()

if imageSize, err := options.Config.Services.GetValue(m.GetServiceName(), "size", "int"); err == nil {
m.imageSize = imageSize.(int)
}
if spanSamples, err := options.Config.Services.GetValue(m.GetServiceName(), "samples", "int"); err == nil {
m.spanSamples = spanSamples.(int)
}
if scaleFactor, err := options.Config.Services.GetValue(m.GetServiceName(), "scale", "float"); err == nil {
m.scaleFactor = scaleFactor.(float64)
}

dataProvider := &provider{
database: options.Database,
queryCache: cache.NewKv(HELICORDER_TIME_SPAN),
Expand Down Expand Up @@ -117,14 +129,14 @@ func (m *HelicorderService) Start(options *services.Options, waitGroup *sync.Wai
channelName := dataProvider.GetChannel()
logger.GetLogger(m.GetServiceName()).Infof("start plotting helicorder for %s", channelName)

err = helicorderCtx.Plot(currentTime, HELICORDER_DOWNSAMPLE_FACTOR, HELICORDER_SCALE_FACTOR, HELICORDER_LINE_WIDTH)
err = helicorderCtx.Plot(currentTime, m.spanSamples, m.scaleFactor, HELICORDER_LINE_WIDTH)
if err != nil {
logger.GetLogger(m.GetServiceName()).Errorln(err)
continue
}

filePath := m.getFilePath(channelName, currentTime)
err = helicorderCtx.Save(HELICORDER_IMAGE_SIZE, filePath)
err = helicorderCtx.Save(m.imageSize, filePath)
if err != nil {
logger.GetLogger(m.GetServiceName()).Errorln(err)
continue
Expand Down
6 changes: 5 additions & 1 deletion services/helicorder/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const (
HELICORDER_IMAGE_SIZE = 1000
HELICORDER_DOWNSAMPLE_FACTOR = 5000
HELICORDER_SCALE_FACTOR = 2.2
HELICORDER_LINE_WIDTH = 0.8
HELICORDER_LINE_WIDTH = 1
)

type HelicorderService struct {
Expand All @@ -16,4 +16,8 @@ type HelicorderService struct {
stationCode string
networkCode string
locationCode string

imageSize int
spanSamples int
scaleFactor float64
}

0 comments on commit 3055ac7

Please sign in to comment.