-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple implementation of SeedLink buffer
- Loading branch information
1 parent
99da461
commit e23683a
Showing
93 changed files
with
327 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v2.5.5 | ||
v2.6.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package seedlink | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"github.com/bclswl0827/mseedio" | ||
) | ||
|
||
func CreateSLPacket(count []int32, ts, seq int64, network, station, channel, location string) ([]byte, error) { | ||
// Generate MiniSEED, send to client | ||
var miniseed mseedio.MiniSeedData | ||
// Init header fields | ||
miniseed.Init(mseedio.STEIM2, mseedio.MSBFIRST) | ||
|
||
// Append MiniSEED data | ||
err := miniseed.Append(count, &mseedio.AppendOptions{ | ||
StationCode: station, | ||
LocationCode: location, | ||
ChannelCode: channel, | ||
NetworkCode: network, | ||
SampleRate: float64(len(count)), | ||
StartTime: time.UnixMilli(ts).UTC(), | ||
SequenceNumber: fmt.Sprintf("%06d", seq), | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Get MiniSEED bytes | ||
miniseed.Series[0].BlocketteSection.RecordLength = 9 | ||
dataBytes, err := miniseed.Encode(mseedio.OVERWRITE, mseedio.MSBFIRST) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Return SeedLink packet | ||
slSeq := []byte(fmt.Sprintf("SL%06X", seq)) | ||
return append(slSeq, dataBytes...), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package geophone | ||
|
||
func (g *Geophone) getSize(packetLen, checksumLen int) int { | ||
func (g *Geophone) getPacketSize(packetLen, checksumLen int) int { | ||
// channelLen*packetLen*int32 + checksumLen + 1 | ||
return checksumLen*packetLen*4 + checksumLen + 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,15 @@ | ||
package miniseed | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/bclswl0827/mseedio" | ||
) | ||
|
||
const MODULE string = "miniseed" | ||
|
||
const ( | ||
MAX_DURATION float64 = 4.0 | ||
MAX_DURATION float64 = 3.0 | ||
BIT_ORDER int = mseedio.MSBFIRST | ||
ENCODING_TYPE int = mseedio.STEIM2 | ||
) | ||
|
||
type MiniSEED struct{} | ||
|
||
type channelBuffer struct { | ||
DataBuffer []int32 | ||
Samples int32 | ||
SeqNum int64 | ||
} | ||
|
||
type miniSEEDBuffer struct { | ||
TimeStamp time.Time | ||
ChannelBuffer map[string]*channelBuffer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package seedlink | ||
|
||
import ( | ||
"github.com/anyshake/observer/driver/seedlink" | ||
"github.com/anyshake/observer/publisher" | ||
) | ||
|
||
func (s *SeedLink) handleBuffer(gp *publisher.Geophone, buffer *seedlink.SeedLinkBuffer) error { | ||
if len(buffer.Data) < buffer.Size { | ||
buffer.Data = append(buffer.Data, *gp) | ||
} else { | ||
buffer.Data = append(buffer.Data[1:], *gp) | ||
} | ||
|
||
s.OnReady(nil, "1 record added to buffer") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.