dl

package
v0.0.0-...-f2c17e5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 7 Imported by: 0

README

dl

import "github.com/GeoNet/kit/seis/dl"

Overview

The dl module has been writen as a lightweight replacement for the C libdali library. It is aimed at clients that need to connect to a datalink server, either requesting inforamtion or for uploading most likely miniseed records.

Index

Package files

conn.go dlink.go doc.go types.go

Constants

const (
    PreheaderSize = 3
)

func MarshalPreheader

func MarshalPreheader(r Preheader) (b [PreheaderSize]byte)

type DLConn

type DLConn struct {
    net.Conn
    // contains filtered or unexported fields
}

DLConn provides connection information to a datalink service.

func NewDLConn
func NewDLConn(service string, timeout time.Duration) (*DLConn, error)

NewDLConn makes a connection to a datalink service, the function SetId should be run after the connection is made and Close should be called when the link is no longer required.

func (*DLConn) Id
func (d *DLConn) Id() string

Id returns the client identification sent to the server.

func (*DLConn) SetId
func (d *DLConn) SetId(program, username string) error

SetId sens an ID message to the remote connection and decodes the connection capabilities.

func (*DLConn) Size
func (d *DLConn) Size() int

Size returns the current expected packet size.

func (*DLConn) Writable
func (d *DLConn) Writable() bool

Writable returns whether packets can be written over the connection.

func (*DLConn) WriteMS
func (d *DLConn) WriteMS(srcname string, start, end time.Time, data []byte) error

WriteMS sends a raw miniseed packet to a datalink service, it will need to be decoded prior to sending to allow for the required message identification values to added.

type DLink struct {
    // contains filtered or unexported fields
}

DLink is a wrapper around a DLConn connection.

func NewDLink(server string, opts ...DLinkOpt) *DLink

NewDLink returns a DLink pointer for the given server, optional settings can be passed as DLinkOpt functions.

func (d *DLink) Connect() (*DLConn, error)

Connect returns a DLConn pointer on a successful connection to a datalink server.

func (d *DLink) SetProgram(s string)

SetProgram sets the program name used for connection requests.

func (d *DLink) SetTimeout(t time.Duration)

SetTimeout sets the timeout value used for connection requests.

func (d *DLink) SetUsername(s string)

SetUsername sets the username used for connection requests.

type DLinkOpt

type DLinkOpt func(*DLink)

DLinkOpt is a function for setting DLink internal parameters.

func SetDLProgram
func SetDLProgram(s string) DLinkOpt

SetDLProgram sets the program name for datalink connections.

func SetDLTimeout
func SetDLTimeout(t time.Duration) DLinkOpt

SetDLTimeout sets the timeout for seedlink server commands and packet requests.

func SetDLUsername
func SetDLUsername(s string) DLinkOpt

SetDLUsername sets the username for datalink connections.

type Packet

type Packet struct {
    Preheader Preheader
    Header    []byte
    Body      []byte
}

type Preheader

type Preheader struct {
    DL           [2]byte //ASCII String == "DL"
    HeaderLength uint8   //1 byte describing the length of rest of the header
}

func UnmarshalPreheader
func UnmarshalPreheader(b [PreheaderSize]byte) (r Preheader)

Generated by godoc2md

Documentation

Overview

The dl module has been writen as a lightweight replacement for the C libdali library. It is aimed at clients that need to connect to a datalink server, either requesting inforamtion or for uploading most likely miniseed records.

Index

Constants

View Source
const (
	PreheaderSize = 3
)

Variables

This section is empty.

Functions

func MarshalPreheader

func MarshalPreheader(r Preheader) (b [PreheaderSize]byte)

Types

type DLConn

type DLConn struct {
	net.Conn
	// contains filtered or unexported fields
}

DLConn provides connection information to a datalink service.

func NewDLConn

func NewDLConn(service string, timeout time.Duration) (*DLConn, error)

NewDLConn makes a connection to a datalink service, the function SetId should be run after the connection is made and Close should be called when the link is no longer required.

func (*DLConn) Id

func (d *DLConn) Id() string

Id returns the client identification sent to the server.

func (*DLConn) SetId

func (d *DLConn) SetId(program, username string) error

SetId sens an ID message to the remote connection and decodes the connection capabilities.

func (*DLConn) Size

func (d *DLConn) Size() int

Size returns the current expected packet size.

func (*DLConn) Writable

func (d *DLConn) Writable() bool

Writable returns whether packets can be written over the connection.

func (*DLConn) WriteMS

func (d *DLConn) WriteMS(srcname string, start, end time.Time, data []byte) error

WriteMS sends a raw miniseed packet to a datalink service, it will need to be decoded prior to sending to allow for the required message identification values to added.

type DLink struct {
	// contains filtered or unexported fields
}

DLink is a wrapper around a DLConn connection.

func NewDLink(server string, opts ...DLinkOpt) *DLink

NewDLink returns a DLink pointer for the given server, optional settings can be passed as DLinkOpt functions.

func (*DLink) Connect

func (d *DLink) Connect() (*DLConn, error)

Connect returns a DLConn pointer on a successful connection to a datalink server.

func (*DLink) SetProgram

func (d *DLink) SetProgram(s string)

SetProgram sets the program name used for connection requests.

func (*DLink) SetTimeout

func (d *DLink) SetTimeout(t time.Duration)

SetTimeout sets the timeout value used for connection requests.

func (*DLink) SetUsername

func (d *DLink) SetUsername(s string)

SetUsername sets the username used for connection requests.

type DLinkOpt

type DLinkOpt func(*DLink)

DLinkOpt is a function for setting DLink internal parameters.

func SetDLProgram

func SetDLProgram(s string) DLinkOpt

SetDLProgram sets the program name for datalink connections.

func SetDLTimeout

func SetDLTimeout(t time.Duration) DLinkOpt

SetDLTimeout sets the timeout for seedlink server commands and packet requests.

func SetDLUsername

func SetDLUsername(s string) DLinkOpt

SetDLUsername sets the username for datalink connections.

type Packet

type Packet struct {
	Preheader Preheader
	Header    []byte
	Body      []byte
}

type Preheader

type Preheader struct {
	DL           [2]byte //ASCII String == "DL"
	HeaderLength uint8   //1 byte describing the length of rest of the header
}

func UnmarshalPreheader

func UnmarshalPreheader(b [PreheaderSize]byte) (r Preheader)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL