seisplotjs

3.1.4
src/datalink.ts

const for datalink protocol for web sockets, DataLink1.0

DATALINK_PROTOCOL

Type: string

enum for modes, either QUERY or STREAM

MODE

const for query mode, QUERY

QUERY_MODE

STREAM_MODE

src/datalink.ts

const for streaming mode, STREAM

STREAM_MODE

MAX_PROC_NUM

src/datalink.ts

const for maximum process number to create fake number for datalink id, 2^16-2

MAX_PROC_NUM

USER_BROWSER

src/datalink.ts

const for fake user name for datalink id, browser

USER_BROWSER

Type: string

DEFAULT_PROGRAM

src/datalink.ts

const for fake program name for datalink id, seisplotjs

DEFAULT_PROGRAM

Type: string

DEFAULT_ARCH

src/datalink.ts

const for fake architecture for datalink id, javascript

DEFAULT_ARCH

Type: string

const for error response, ERROR

ERROR

Type: string

const for ok response, OK

OK

Type: string

const for info response, INFO

INFO

Type: string

const for id response, ID

ID

Type: string

PACKET

Type: string

STREAM

Type: string

ENDSTREAM

Type: string

MSEED_TYPE

Type: string

MSEED3_TYPE

src/datalink.ts
MSEED3_TYPE

Type: string

IRIS_RINGSERVER_URL

src/datalink.ts
IRIS_RINGSERVER_URL

Type: string

DataLinkConnection

src/datalink.ts

A websocket based Datalink connection.

Note this cannot connect directly to a native TCP socket, instead it sends the datalink protocol over a websocket.

Currently only the IRIS ringserver, https://github.com/iris-edu/ringserver, supports websockets, but it may be possible to use thrid party tools to proxy the websocket to a TCP datalink socket.

The datalink protocol is documented here https://earthscope.github.io/libdali/datalink-protocol.html

new DataLinkConnection(url: string, packetHandler: function (packet: DataLinkPacket): void, errorHandler: function (error: Error): void)
Parameters
url (string) websocket url to the ringserver
packetHandler (function (packet: DataLinkPacket): void) callback for packets as they arrive
errorHandler (function (error: Error): void) callback for errors
Static Members
ensureDataLinkResponse(dl)
ensureDataLinkPacket(dl)
Instance Members
packetHandler
errorHandler
closeHandler
serverId
clientIdNum
programname
username
architecture
webSocket
setOnClose(closeHandler)
connect()
isConnected()
mode
stream()
endStream()
close()
sendId()
encodeDL(header, data?)
sendDLBinary(header, data?)
sendDLCommand(command, dataString?)
awaitDLBinary(header, data?)
awaitDLCommand(command, dataString?)
writeAck(streamid, hpdatastart, hpdataend, data?)
id(programname, username, processid, architecture)
info(infoType)
infoStatus()
infoStreams()
infoConnections()
positionAfter(time)
positionAfterHPTime(hpTime)
match(pattern)
reject(pattern)
read(packetId)
handleArrayBuffer(rawData)

DataLinkResponse

src/datalink.ts

Datalink response, used for ID, INFO, OK and ERROR responses.

new DataLinkResponse(type: string, value: string, message: string)
Parameters
type (string)
value (string)
message (string)
Static Members
parse(header, data?)
Instance Members
type
value
message
isError()
toString()

DataLinkPacket

src/datalink.ts

Represents a Datalink packet from the ringserver.

new DataLinkPacket(header: string, dataview: DataView)
Parameters
header (string)
dataview (DataView)
Instance Members
header
streamId
pktid
hppackettime
hppacketstart
hppacketend
dataSize
_miniseed
_mseed3
packetStart
packetEnd
packetTime
isMiniseed()
asMiniseed()
isMiniseed3()
asMiniseed3()

DataLinkIdStats

src/datalink.ts
new DataLinkIdStats(version: string, serverId: string, capabilities: Array<string>)
Parameters
version (string)
serverId (string)
capabilities (Array<string>)
Static Members
parseXMLAttributes(statusEl)
Instance Members
version
serverId
capabilities
toString()

DataLinkStats

src/datalink.ts
new DataLinkStats(startTime: DateTime, ringVersion: string, ringSize: number, packetSize: number, maximumPacketID: number, maximumPackets: number, memoryMappedRing: boolean, volatileRing: boolean, totalConnections: number, totalStreams: number, txPacketRate: number, txByteRate: number, rxPacketRate: number, rxByteRate: number, earliestPacketID: number, earliestPacketCreationTime: DateTime, earliestPacketDataStartTime: DateTime, earliestPacketDataEndTime: DateTime, latestPacketID: number, latestPacketCreationTime: DateTime, latestPacketDataStartTime: DateTime, latestPacketDataEndTime: DateTime)
Parameters
startTime (DateTime)
ringVersion (string)
ringSize (number)
packetSize (number)
maximumPacketID (number)
maximumPackets (number)
memoryMappedRing (boolean)
volatileRing (boolean)
totalConnections (number)
totalStreams (number)
txPacketRate (number)
txByteRate (number)
rxPacketRate (number)
rxByteRate (number)
earliestPacketID (number)
earliestPacketCreationTime (DateTime)
earliestPacketDataStartTime (DateTime)
earliestPacketDataEndTime (DateTime)
latestPacketID (number)
latestPacketCreationTime (DateTime)
latestPacketDataStartTime (DateTime)
latestPacketDataEndTime (DateTime)
Static Members
parseXMLAttributes(statusEl)
Instance Members
startTime
ringVersion
ringSize
packetSize
maximumPacketID
maximumPackets
memoryMappedRing
volatileRing
totalConnections
totalStreams
txPacketRate
txByteRate
rxPacketRate
rxByteRate
earliestPacketID
earliestPacketCreationTime
earliestPacketDataStartTime
earliestPacketDataEndTime
latestPacketID
latestPacketCreationTime
latestPacketDataStartTime
latestPacketDataEndTime
toString()
new ThreadStat(flags: Array<string>, type: Array<string>, port: number)
Parameters
flags (Array<string>)
type (Array<string>)
port (number)
Static Members
parseXMLAttributes(statusEl)
Instance Members
flags
port
toString()

StatusResponse

src/datalink.ts
new StatusResponse(idStats: DataLinkIdStats, datalinkStats: DataLinkStats, threadStats: Array<ThreadStat>)
Parameters
idStats (DataLinkIdStats)
datalinkStats (DataLinkStats)
threadStats (Array<ThreadStat>)
Static Members
fromDatalinkResponse(daliResp)
fromXML(daliXML)
Instance Members
idStats
datalinkStats
threadStats
rawXml
toString()
new StreamStat(name: string, earliestPacketID: number, earliestPacketDataStartTime: DateTime, earliestPacketDataEndTime: DateTime, latestPacketID: number, latestPacketDataStartTime: DateTime, latestPacketDataEndTime: DateTime, dataLatency: number)
Parameters
name (string)
earliestPacketID (number)
earliestPacketDataStartTime (DateTime)
earliestPacketDataEndTime (DateTime)
latestPacketID (number)
latestPacketDataStartTime (DateTime)
latestPacketDataEndTime (DateTime)
dataLatency (number)
Static Members
parseXMLAttributes(statusEl)
Instance Members
name
earliestPacketID
earliestPacketDataStartTime
earliestPacketDataEndTime
latestPacketID
latestPacketDataStartTime
latestPacketDataEndTime
dataLatency
toString()

StreamsResponse

src/datalink.ts
new StreamsResponse(datalinkStats: DataLinkStats, streams: Array<StreamStat>)
Parameters
datalinkStats (DataLinkStats)
streams (Array<StreamStat>)
Static Members
fromDatalinkResponse(daliResp)
fromXML(daliXML)
Instance Members
datalinkStats
streams
toString()

ConnectionsResponse

src/datalink.ts

Non implementation, just stores xml as a string. Unlikely to be useful remotely as ringserver doesn't allow.

new ConnectionsResponse(daliXML: string)
Parameters
daliXML (string) raw xml form server
Static Members
fromDatalinkResponse(daliResp)
fromXML(daliXML)
Instance Members
daliXML
toString()

daliDateTime

src/datalink.ts

Convert DataLink style dates, like "2022-10-04 15:11:24.786990" to ISO form for DateTime

daliDateTime(dalitime: string): DateTime
Parameters
dalitime (string) datalink time
Returns
DateTime: DateTime

dateTimeToHPTime

src/datalink.ts

Convert DateTime to a HPTime number.

dateTimeToHPTime(m: DateTime): number
Parameters
m (DateTime) DateTime to convert
Returns
number: microseconds since epoch

hpTimeToDateTime

src/datalink.ts

Convert hptime number to a DateTime.

hpTimeToDateTime(hptime: number): DateTime
Parameters
hptime (number) hptime to convert
Returns
DateTime: DateTime in utc for the hptime

stringToUint8Array

src/datalink.ts

Encode string into a Uint8Array.

stringToUint8Array(dataString: string?): Uint8Array
Parameters
dataString (string?) String to encode.
Returns
Uint8Array: String as bytes in Uint8Array.