Skip to content

Commit

Permalink
Fix issue that MiniSEED recording interrupt in legacy mode
Browse files Browse the repository at this point in the history
  • Loading branch information
bclswl0827 committed Aug 7, 2024
1 parent f0315ab commit 732d9df
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

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

## v3.0.1

### Bug Fixes

- Fixed the issue where MiniSEED recording in legacy mode would be interrupted due to sampling rate jitter

## v3.0.0

### Breaking Changes

- **Data Protocol**: The AnyShake Explorer data protocol has been entirely refactored. **Please rebuild and flash the firmware of AnyShake Explorer to the latest version.**
- **Data Protocol**: The AnyShake Explorer data protocol has been entirely refactored. **Please rebuild and burn the firmware of AnyShake Explorer to the latest version.**
- **Configuration File**: The configuration file layout has been completely overhauled. The old configuration file format is no longer supported.
- **SeedLink Server**: The SeedLink service has been temporarily removed and will be re-implemented in a future release.
- **API Endpoints**: Some request and response fields have been modified in API v1. Please refer to the built-in Swagger API documentation for details.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.0.0
v3.0.1
12 changes: 6 additions & 6 deletions build/assets/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"port": 123
},
"database_settings": {
"engine": "sqlite",
"host": "",
"port": 0,
"username": "",
"password": "",
"database": "/home/yuki/observer.db"
"engine": "postgresql",
"host": "127.0.0.1",
"port": 5432,
"username": "postgres",
"password": "passw0rd",
"database": "observer"
},
"server_settings": {
"host": "0.0.0.0",
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
REACT_APP_VERSION=v3.0.0
REACT_APP_RELEASE=b2150f37-20240808023110
REACT_APP_VERSION=v3.0.1
REACT_APP_RELEASE=f0315abf-20240808033910
1 change: 1 addition & 0 deletions services/miniseed/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (m *MiniSeedService) Start(options *services.Options, waitGroup *sync.WaitG
explorer.EXPLORER_CHANNEL_CODE_E: 0,
explorer.EXPLORER_CHANNEL_CODE_N: 0,
}
m.legacyMode = options.Config.Explorer.Legacy
m.cleanUpCountDown = MINISEED_CLEANUP_INTERVAL
m.writeBufferCountDown = MINISEED_WRITE_INTERVAL

Expand Down
10 changes: 6 additions & 4 deletions services/miniseed/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
)

const (
MINISEED_BIT_ORDER = mseedio.MSBFIRST
MINISEED_ENCODE_TYPE = mseedio.STEIM2
MINISEED_WRITE_INTERVAL = 5
MINISEED_CLEANUP_INTERVAL = 60
MINISEED_BIT_ORDER = mseedio.MSBFIRST
MINISEED_ENCODE_TYPE = mseedio.STEIM2
MINISEED_WRITE_INTERVAL = 5
MINISEED_CLEANUP_INTERVAL = 60
MINISEED_ALLOWED_JITTER_MS = 10
)

type MiniSeedService struct {
Expand All @@ -18,6 +19,7 @@ type MiniSeedService struct {
writeBufferCountDown int
cleanUpCountDown int
lifeCycle int
legacyMode bool
basePath string
stationCode string
networkCode string
Expand Down
14 changes: 8 additions & 6 deletions services/miniseed/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package miniseed

import (
"fmt"
"math"
"time"

"github.com/anyshake/observer/drivers/explorer"
Expand All @@ -14,17 +15,18 @@ func (m *MiniSeedService) handleWrite() error {
startSampleRate = m.miniseedBuffer[0].SampleRate
)

// Check if the timestamp is continuous
// Check if the timestamp is within the allowed jitter
for i := 1; i < len(m.miniseedBuffer); i++ {
if m.miniseedBuffer[i].Timestamp != startTimestamp+int64(i*1000) {
if math.Abs(float64(m.miniseedBuffer[i].Timestamp-startTimestamp-int64(i*1000))) > 1000+MINISEED_ALLOWED_JITTER_MS {
return fmt.Errorf("timestamp is not continuous, expected %d, got %d", startTimestamp+int64(i*1000), m.miniseedBuffer[i].Timestamp)
}
}

// Check if sample rate is the same
for i := 1; i < len(m.miniseedBuffer); i++ {
if m.miniseedBuffer[i].SampleRate != startSampleRate {
return fmt.Errorf("sample rate is not the same, expected %d, got %d", startSampleRate, m.miniseedBuffer[i].SampleRate)
if !m.legacyMode {
for i := 1; i < len(m.miniseedBuffer); i++ {
if m.miniseedBuffer[i].SampleRate != startSampleRate {
return fmt.Errorf("sample rate is not the same, expected %d, got %d", startSampleRate, m.miniseedBuffer[i].SampleRate)
}
}
}

Expand Down

0 comments on commit 732d9df

Please sign in to comment.