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

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://raw.githubusercontent.com/iris-edu/libdali/master/doc/DataLink.protocol

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)
positionAfter(time)
positionAfterHPTime(hpTime)
match(pattern)
reject(pattern)
read(packetId)

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
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()
miniseed
isMiniseed3()
miniseed3

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

hpTimeToMoment

src/datalink.ts

Convert hptime number to a DateTime.

hpTimeToMoment(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.