transport

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2021 License: MIT Imports: 20 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// SignalKindDescription defines the string representations of the SignalKind enumeration values.
	SignalKindDescription = [...]string{
		"Angle",
		"Magnitude",
		"Frequency",
		"DfDt",
		"Status",
		"Digital",
		"Analog",
		"Calculation",
		"Statistic",
		"Alarm",
		"Quality",
		"Unknown"}

	// SignalKindAcronym defines the abbreviated string representations of the SignalKind enumeration values.
	SignalKindAcronym = [...]string{
		"PA",
		"PM",
		"FQ",
		"DF",
		"SF",
		"DV",
		"AV",
		"CV",
		"ST",
		"AL",
		"QF",
		"??"}
)
View Source
var CompressionModes = struct {
	// GZip defines a bit flag used determine if GZip compression will be used to metadata exchange.
	GZip CompressionModesEnum
	// TSSC defines a bit flag used determine if the time-series special compression algorithm will be used for data exchange.
	TSSC CompressionModesEnum
	// None defines state where no compression will be used.
	None CompressionModesEnum
}{
	GZip: 0x00000020,
	TSSC: 0x00000040,
	None: 0x00000000,
}

CompressionModes is an enumeration of the possible compression modes supported by STTP.

View Source
var ConnectStatus = struct {
	// Success defines that a connection succeeded.
	Success ConnectStatusEnum
	// Failed defines that a connection failed.
	Failed ConnectStatusEnum
	// Canceled defines that a connection was cancelled.
	Canceled ConnectStatusEnum
}{
	Success:  1,
	Failed:   0,
	Canceled: -1,
}

ConnectStatus is an enumeration of the possible connection status results used by the SubscriberConnector.

View Source
var DataPacketFlags = struct {
	// Compact determines if serialized measurement is compact. Bit set = compact, bit clear = full fidelity.
	Compact DataPacketFlagsEnum
	// CipherIndex determines which cipher index to use when encrypting data packet. Bit set = use odd cipher index (i.e., 1), bit clear = use even cipher index (i.e., 0).
	CipherIndex DataPacketFlagsEnum
	// Compressed determines if data packet payload is compressed. Bit set = payload compressed, bit clear = payload normal.
	Compressed DataPacketFlagsEnum
	// CacheIndex determines with signal index cache to use when decoding a data packet. Used by STTP version 2 or greater.
	CacheIndex DataPacketFlagsEnum
	// NoFlags defines state where there are no flags set. This would represent unsynchronized, full fidelity measurement data packets.
	NoFlags DataPacketFlagsEnum
}{
	Compact:     0x02,
	CipherIndex: 0x04,
	Compressed:  0x08,
	CacheIndex:  0x10,
	NoFlags:     0x0,
}

DataPacketFlags is an enumeration of the possible flags for a data packet.

View Source
var OperationalEncoding = struct {
	// UTF16LE targets little-endian 16-bit Unicode character encoding for strings (deprecated).
	UTF16LE OperationalEncodingEnum
	// UTF16BE targets big-endian 16-bit Unicode character encoding for strings (deprecated).
	UTF16BE OperationalEncodingEnum
	// UTF8 targets 8-bit variable-width Unicode character encoding for strings.
	UTF8 OperationalEncodingEnum
}{
	UTF16LE: 0x00000000,
	UTF16BE: 0x00000100,
	UTF8:    0x00000200,
}

OperationalEncoding is an enumeration of the possible string encoding options of an STTP session.

View Source
var OperationalModes = struct {
	// VersionMask defines a bit mask used to get version number of protocol. Version number is currently set to 2.
	VersionMask OperationalModesEnum
	// CompressionModeMask defines a bit mask used to get mode of compression. GZip and TSSC compression are the only modes currently supported. Remaining bits are reserved for future compression modes.
	CompressionModeMask OperationalModesEnum
	// EncodingMask defines a bit mask used to get character encoding used when exchanging messages between publisher and subscriber.
	EncodingMask OperationalModesEnum
	// ReceiveExternalMetadata defines a bit flag used to determine whether external measurements are exchanged during metadata synchronization. Bit set = external measurements are exchanged, bit clear = no external measurements are exchanged.
	ReceiveExternalMetadata OperationalModesEnum
	// ReceiveInternalMetadata defines a bit flag used to determine whether internal measurements are exchanged during metadata synchronization. Bit set = internal measurements are exchanged, bit clear = no internal measurements are exchanged.
	ReceiveInternalMetadata OperationalModesEnum
	// CompressPayloadData defines a bit flag used to determine whether payload data is compressed when exchanging between publisher and subscriber. Bit set = compress, bit clear = no compression.
	CompressPayloadData OperationalModesEnum
	// CompressSignalIndexCache defines a bit flag used to determine whether the signal index cache is compressed when exchanging between publisher and subscriber. Bit set = compress, bit clear = no compression.
	CompressSignalIndexCache OperationalModesEnum
	// CommpressMetadata defines a bit flag used to determine whether metadata is compressed when exchanging between publisher and subscriber. Bit set = compress, bit clear = no compression.
	CommpressMetadata OperationalModesEnum
	// NoFlags defines state where there are no flags set.
	NoFlags OperationalModesEnum
}{
	VersionMask:              0x0000001F,
	CompressionModeMask:      0x000000E0,
	EncodingMask:             0x00000300,
	ReceiveExternalMetadata:  0x02000000,
	ReceiveInternalMetadata:  0x04000000,
	CompressPayloadData:      0x20000000,
	CompressSignalIndexCache: 0x40000000,
	CommpressMetadata:        0x80000000,
	NoFlags:                  0x00000000,
}

OperationalModes is an enumeration of the possible modes that affect how DataPublisher and DataSubscriber communicate during an STTP session.

View Source
var SecurityMode = struct {
	// None defines that data will be sent over the wire unencrypted.
	None SecurityModeEnum
	// TLS defines that data will be sent over wire using Transport Layer Security.
	TLS SecurityModeEnum
}{
	None: 0,
	TLS:  1,
}

SecurityMode is an enumeration of the possible security modes used by the DataPublisher to secure data sent over the command channel in STTP.

View Source
var ServerCommand = struct {
	// Connect defines a service command code for handling connect operations. Only used as part of connection refused response.
	Connect ServerCommandEnum
	// MetaDataRefresh defines a service command code for requesting an updated set of metadata.
	MetadataRefresh ServerCommandEnum
	// Subscribe defines a service command code for requesting a subscription of streaming data from server based on connection string that follows.
	Subscribe ServerCommandEnum
	// Unsubscribe  defines a service command code for requesting that server stop sending streaming data to the client and cancel the current subscription.
	Unsubscribe ServerCommandEnum
	// RotateCipherKeys defines a service command code for manually requesting that server send a new set of cipher keys for data packet encryption (UDP only).
	RotateCipherKeys ServerCommandEnum
	// UpdateProcessingInterval defines a service command code for manually requesting that server to update the processing interval with the following specified value.
	UpdateProcessingInterval ServerCommandEnum
	// DefineOperationalModes defines a service command code for establishing operational modes. As soon as connection is established, requests that server set operational modes that affect how the subscriber and publisher will communicate.
	DefineOperationalModes ServerCommandEnum
	// ConfirmNotification defines a service command code for receipt of a notification. This message is sent in response to ServerResponse.Notify.
	ConfirmNotification ServerCommandEnum
	// ConfirmBufferBlock defines a service command code for receipt of a buffer block measurement. This message is sent in response to ServerResponse.BufferBlock.
	ConfirmBufferBlock ServerCommandEnum
	// ConfirmSignalIndexCache defines a service command for confirming the receipt of a signal index cache. This allows publisher to safely transition to next signal index cache.
	ConfirmSignalIndexCache ServerCommandEnum
	// UserCommand00 defines a service command code for handling user-defined commands.
	UserCommand00 ServerCommandEnum
	// UserCommand01 defines a service command code for handling user-defined commands.
	UserCommand01 ServerCommandEnum
	// UserCommand02 defines a service command code for handling user-defined commands.
	UserCommand02 ServerCommandEnum
	// UserCommand03 defines a service command code for handling user-defined commands.
	UserCommand03 ServerCommandEnum
	// UserCommand04 defines a service command code for handling user-defined commands.
	UserCommand04 ServerCommandEnum
	// UserCommand05 defines a service command code for handling user-defined commands.
	UserCommand05 ServerCommandEnum
	// UserCommand06 defines a service command code for handling user-defined commands.
	UserCommand06 ServerCommandEnum
	// UserCommand07 defines a service command code for handling user-defined commands.
	UserCommand07 ServerCommandEnum
	// UserCommand08 defines a service command code for handling user-defined commands.
	UserCommand08 ServerCommandEnum
	// UserCommand09 defines a service command code for handling user-defined commands.
	UserCommand09 ServerCommandEnum
	// UserCommand10 defines a service command code for handling user-defined commands.
	UserCommand10 ServerCommandEnum
	// UserCommand11 defines a service command code for handling user-defined commands.
	UserCommand11 ServerCommandEnum
	// UserCommand12 defines a service command code for handling user-defined commands.
	UserCommand12 ServerCommandEnum
	// UserCommand13 defines a service command code for handling user-defined commands.
	UserCommand13 ServerCommandEnum
	// UserCommand14 defines a service command code for handling user-defined commands.
	UserCommand14 ServerCommandEnum
	// UserCommand15 defines a service command code for handling user-defined commands.
	UserCommand15 ServerCommandEnum
}{

	Connect:                  0x00,
	MetadataRefresh:          0x01,
	Subscribe:                0x02,
	Unsubscribe:              0x03,
	RotateCipherKeys:         0x04,
	UpdateProcessingInterval: 0x05,
	DefineOperationalModes:   0x06,
	ConfirmNotification:      0x07,
	ConfirmBufferBlock:       0x08,
	ConfirmSignalIndexCache:  0x0A,
	UserCommand00:            0xD0,
	UserCommand01:            0xD1,
	UserCommand02:            0xD2,
	UserCommand03:            0xD3,
	UserCommand04:            0xD4,
	UserCommand05:            0xD5,
	UserCommand06:            0xD6,
	UserCommand07:            0xD7,
	UserCommand08:            0xD8,
	UserCommand09:            0xD9,
	UserCommand10:            0xDA,
	UserCommand11:            0xDB,
	UserCommand12:            0xDC,
	UserCommand13:            0xDD,
	UserCommand14:            0xDE,
	UserCommand15:            0xDF,
}

ServerCommand is an enumeration of the possible server commands received by a DataPublisher and sent by a DataSubscriber during an STTP session.

View Source
var ServerResponse = struct {
	// Succeeded defines a service response code for indicating a succeeded response. Informs client that its solicited server command succeeded, original command and success message follow.
	Succeeded ServerResponseEnum
	// Failed defines a service response code for indicating a failed response. Informs client that its solicited server command failed, original command and failure message follow.
	Failed ServerResponseEnum
	// DataPacket defines a service response code for indicating a data packet. Unsolicited response informs client that a data packet follows.
	DataPacket ServerResponseEnum
	// UpdateSignalIndexCache defines a service response code for indicating a signal index cache update. Unsolicited response requests that client update its runtime signal index cache with the one that follows.
	UpdateSignalIndexCache ServerResponseEnum
	// UpdateBaseTimes defines a service response code for indicating a runtime base-timestamp offsets have been updated. Unsolicited response requests that client update its runtime base-timestamp offsets with those that follow.
	UpdateBaseTimes ServerResponseEnum
	// UpdateCipherKeys defines a service response code for indicating a runtime cipher keys have been updated. Response, solicited or unsolicited, requests that client update its runtime data cipher keys with those that follow.
	UpdateCipherKeys ServerResponseEnum
	// DataStartTime defines a service response code for indicating the start time of data being published. Unsolicited response provides the start time of data being processed from the first measurement.
	DataStartTime ServerResponseEnum
	// ProcessingComplete defines a service response code for indicating that processing has completed. Unsolicited response provides notification that input processing has completed, typically via temporal constraint.
	ProcessingComplete ServerResponseEnum
	// BufferBlock defines a service response code for indicating a buffer block. Unsolicited response informs client that a raw buffer block follows.
	BufferBlock ServerResponseEnum
	// Notification defines a service response code for indicating a notification. Unsolicited response provides a notification message to the client.
	Notification ServerResponseEnum
	// ConfigurationChanged defines a service response code for indicating a that the publisher configuration metadata has changed. Unsolicited response provides a notification that the publisher's source configuration has changed and that client may want to request a meta-data refresh.
	ConfigurationChanged ServerResponseEnum
	// UserResponse00 defines a service response code for handling user-defined responses.
	UserResponse00 ServerResponseEnum
	// UserResponse01 defines a service response code for handling user-defined responses.
	UserResponse01 ServerResponseEnum
	// UserResponse02 defines a service response code for handling user-defined responses.
	UserResponse02 ServerResponseEnum
	// UserResponse03 defines a service response code for handling user-defined responses.
	UserResponse03 ServerResponseEnum
	// UserResponse04 defines a service response code for handling user-defined responses.
	UserResponse04 ServerResponseEnum
	// UserResponse05 defines a service response code for handling user-defined responses.
	UserResponse05 ServerResponseEnum
	// UserResponse06 defines a service response code for handling user-defined responses.
	UserResponse06 ServerResponseEnum
	// UserResponse07 defines a service response code for handling user-defined responses.
	UserResponse07 ServerResponseEnum
	// UserResponse08 defines a service response code for handling user-defined responses.
	UserResponse08 ServerResponseEnum
	// UserResponse09 defines a service response code for handling user-defined responses.
	UserResponse09 ServerResponseEnum
	// UserResponse10 defines a service response code for handling user-defined responses.
	UserResponse10 ServerResponseEnum
	// UserResponse11 defines a service response code for handling user-defined responses.
	UserResponse11 ServerResponseEnum
	// UserResponse12 defines a service response code for handling user-defined responses.
	UserResponse12 ServerResponseEnum
	// UserResponse13 defines a service response code for handling user-defined responses.
	UserResponse13 ServerResponseEnum
	// UserResponse14 defines a service response code for handling user-defined responses.
	UserResponse14 ServerResponseEnum
	// UserResponse15 defines a service response code for handling user-defined responses.
	UserResponse15 ServerResponseEnum
	// NoOP defines a service response code for indicating a nil-operation keep-alive ping. The command channel can remain quiet for some time, this command allows a period test of client connectivity.
	NoOP ServerResponseEnum
}{

	Succeeded:              0x80,
	Failed:                 0x81,
	DataPacket:             0x82,
	UpdateSignalIndexCache: 0x83,
	UpdateBaseTimes:        0x84,
	UpdateCipherKeys:       0x85,
	DataStartTime:          0x86,
	ProcessingComplete:     0x87,
	BufferBlock:            0x88,
	Notification:           0x89,
	ConfigurationChanged:   0x8A,
	UserResponse00:         0xE0,
	UserResponse01:         0xE1,
	UserResponse02:         0xE2,
	UserResponse03:         0xE3,
	UserResponse04:         0xE4,
	UserResponse05:         0xE5,
	UserResponse06:         0xE6,
	UserResponse07:         0xE7,
	UserResponse08:         0xE8,
	UserResponse09:         0xE9,
	UserResponse10:         0xEA,
	UserResponse11:         0xEB,
	UserResponse12:         0xEC,
	UserResponse13:         0xED,
	UserResponse14:         0xEE,
	UserResponse15:         0xEF,
	NoOP:                   0xFF,
}

ServerResponse is an enumeration of the possible server responses received sent by a DataPublisher and received by a DataSubscriber during an STTP session.

View Source
var SignalKind = struct {
	// Angle defines a phase angle signal kind (could be a voltage or a current).
	Angle SignalKindEnum
	// Magnitude defines a phase magnitude signal kind (could be a voltage or a current).
	Magnitude SignalKindEnum
	// Frequency defines a line frequency signal kind.
	Frequency SignalKindEnum
	// DfDt defines a frequency delta over time (dF/dt) signal kind.
	DfDt SignalKindEnum
	// Status defines a status flags signal kind.
	Status SignalKindEnum
	// Digital defines a digital value signal kind.
	Digital SignalKindEnum
	// Analog defines an analog value signal kind.
	Analog SignalKindEnum
	// Calculation defines a calculated value signal kind.
	Calculation SignalKindEnum
	// Statistic defines a statistical value signal kind.
	Statistic SignalKindEnum
	// Alarm defines an alarm value signal kind.
	Alarm SignalKindEnum
	// Quality defines a quality flags signal kind.
	Quality SignalKindEnum
	// Unknown defines an undetermined signal kind.
	Unknown SignalKindEnum
}{
	Angle:       0,
	Magnitude:   1,
	Frequency:   2,
	DfDt:        3,
	Status:      4,
	Digital:     5,
	Analog:      6,
	Calculation: 7,
	Statistic:   8,
	Alarm:       9,
	Quality:     10,
	Unknown:     11,
}

SignalKind is an enumeration of the possible kinds of signals a Measurement can represent.

View Source
var StateFlags = struct {
	// Normal defines a Measurement flag for a normal state.
	Normal StateFlagsEnum
	// BadData defines a Measurement flag for a bad data state.
	BadData StateFlagsEnum
	// SuspectData defines a Measurement flag for a suspect data state.
	SuspectData StateFlagsEnum
	// OverRangeError defines a Measurement flag for a over range error, i.e., unreasonable high value.
	OverRangeError StateFlagsEnum
	// UnderRangeError defines a Measurement flag for a under range error, i.e., unreasonable low value.
	UnderRangeError StateFlagsEnum
	// AlarmHigh defines a Measurement flag for a alarm for high value.
	AlarmHigh StateFlagsEnum
	// AlarmLow defines a Measurement flag for a alarm for low value.
	AlarmLow StateFlagsEnum
	// WarningHigh defines a Measurement flag for a warning for high value.
	WarningHigh StateFlagsEnum
	// WarningLow defines a Measurement flag for a warning for low value.
	WarningLow StateFlagsEnum
	// FlatlineAlarm defines a Measurement flag for a alarm for flat-lined value, i.e., latched value test alarm.
	FlatlineAlarm StateFlagsEnum
	// ComparisonAlarm defines a Measurement flag for a comparison alarm, i.e., outside threshold of comparison with a real-time value.
	ComparisonAlarm StateFlagsEnum
	// ROCAlarm defines a Measurement flag for a rate-of-change alarm.
	ROCAlarm StateFlagsEnum
	// ReceivedAsBad defines a Measurement flag for a bad value received.
	ReceivedAsBad StateFlagsEnum
	// CalculatedValue defines a Measurement flag for a calculated value state.
	CalculatedValue StateFlagsEnum
	// CalculationError defines a Measurement flag for a calculation error with the value.
	CalculationError StateFlagsEnum
	// CalculationWarning defines a Measurement flag for a calculation warning with the value.
	CalculationWarning StateFlagsEnum
	// ReservedQualityFlag defines a Measurement flag for a reserved quality.
	ReservedQualityFlag StateFlagsEnum
	// BadTime defines a Measurement flag for a bad time state.
	BadTime StateFlagsEnum
	// SuspectTime defines a Measurement flag for a suspect time state.
	SuspectTime StateFlagsEnum
	// LateTimeAlarm defines a Measurement flag for a late time alarm.
	LateTimeAlarm StateFlagsEnum
	// FutureTimeAlarm defines a Measurement flag for a future time alarm.
	FutureTimeAlarm StateFlagsEnum
	// UpSampled defines a Measurement flag for a up-sampled state.
	UpSampled StateFlagsEnum
	// DownSampled defines a Measurement flag for a down-sampled state.
	DownSampled StateFlagsEnum
	// DiscardedValue defines a Measurement flag for a discarded value state.
	DiscardedValue StateFlagsEnum
	// ReservedTimeFlag defines a Measurement flag for a reserved time
	ReservedTimeFlag StateFlagsEnum
	// UserDefinedFlag1 defines a Measurement flag for user defined state 1.
	UserDefinedFlag1 StateFlagsEnum
	// UserDefinedFlag2 defines a Measurement flag for user defined state 2.
	UserDefinedFlag2 StateFlagsEnum
	// UserDefinedFlag3 defines a Measurement flag for user defined state 3.
	UserDefinedFlag3 StateFlagsEnum
	// UserDefinedFlag4 defines a Measurement flag for user defined state 4.
	UserDefinedFlag4 StateFlagsEnum
	// UserDefinedFlag5 defines a Measurement flag for user defined state 5.
	UserDefinedFlag5 StateFlagsEnum
	// SystemError defines a Measurement flag for a system error state.
	SystemError StateFlagsEnum
	// SystemWarning defines a Measurement flag for a system warning state.
	SystemWarning StateFlagsEnum
	// MeasurementError defines a Measurement flag for an error state.
	MeasurementError StateFlagsEnum
}{
	Normal:              0x0,
	BadData:             0x1,
	SuspectData:         0x2,
	OverRangeError:      0x4,
	UnderRangeError:     0x8,
	AlarmHigh:           0x10,
	AlarmLow:            0x20,
	WarningHigh:         0x40,
	WarningLow:          0x80,
	FlatlineAlarm:       0x100,
	ComparisonAlarm:     0x200,
	ROCAlarm:            0x400,
	ReceivedAsBad:       0x800,
	CalculatedValue:     0x1000,
	CalculationError:    0x2000,
	CalculationWarning:  0x4000,
	ReservedQualityFlag: 0x8000,
	BadTime:             0x10000,
	SuspectTime:         0x20000,
	LateTimeAlarm:       0x40000,
	FutureTimeAlarm:     0x80000,
	UpSampled:           0x100000,
	DownSampled:         0x200000,
	DiscardedValue:      0x400000,
	ReservedTimeFlag:    0x800000,
	UserDefinedFlag1:    0x1000000,
	UserDefinedFlag2:    0x2000000,
	UserDefinedFlag3:    0x4000000,
	UserDefinedFlag4:    0x8000000,
	UserDefinedFlag5:    0x10000000,
	SystemError:         0x20000000,
	SystemWarning:       0x40000000,
	MeasurementError:    0x80000000,
}

StateFlags is an enumeration of the possible quality states of a Measurement value.

Functions

func SignalTypeAcronym

func SignalTypeAcronym(kind SignalKindEnum, phasorType rune) string

SignalTypeAcronym gets the specific four-character signal type acronym for a SignalKind enumeration value and phasor type, i.e., "V" voltage or "I" current.

Types

type BufferBlock

type BufferBlock struct {
	// Measurement's globally unique identifier.
	SignalID guid.Guid

	// Buffer is an atomic unit of data, i.e., a binary buffer. This buffer typically
	// represents a partial image of a larger whole.
	Buffer []byte
}

BufferBlock defines an atomic unit of data, i.e., a binary buffer, for transport in STTP.

type CompactMeasurement

type CompactMeasurement struct {
	Measurement
	// contains filtered or unexported fields
}

CompactMeasurement defines a measured value, in simple compact format, for transmission or reception in STTP.

func NewCompactMeasurement

func NewCompactMeasurement(signalIndexCache *SignalIndexCache, includeTime bool, useMillisecondResolution bool, baseTimeOffsets *[2]int64) CompactMeasurement

NewCompactMeasurement creates a new CompactMeasurement

func (*CompactMeasurement) Decode

func (cm *CompactMeasurement) Decode(buffer []byte) int

Decode parses a CompactMeasurement from the specified byte buffer.

func (*CompactMeasurement) GetBinaryLength

func (cm *CompactMeasurement) GetBinaryLength() uint32

GetBinaryLength gets the binary byte length of a CompactMeasurement

func (*CompactMeasurement) GetCompactStateFlags

func (cm *CompactMeasurement) GetCompactStateFlags() byte

GetCompactStateFlags gets byte level compact state flags with encoded time index and base time offset bits.

func (*CompactMeasurement) GetRuntimeID

func (cm *CompactMeasurement) GetRuntimeID() int32

GetRuntimeID gets the 4-byte run-time signal index for this measurement.

func (*CompactMeasurement) GetTimestampC2

func (cm *CompactMeasurement) GetTimestampC2() uint16

GetTimestampC2 gets offset compressed millisecond-resolution 2-byte timestamp.

func (*CompactMeasurement) GetTimestampC4

func (cm *CompactMeasurement) GetTimestampC4() uint32

GetTimestampC4 gets offset compressed tick-resolution 4-byte timestamp.

func (*CompactMeasurement) SetCompactStateFlags

func (cm *CompactMeasurement) SetCompactStateFlags(value byte)

SetCompactStateFlags sets byte level compact state flags with encoded time index and base time offset bits.

func (*CompactMeasurement) SetRuntimeID

func (cm *CompactMeasurement) SetRuntimeID(signalIndex int32)

SetRuntimeID assigns CompactMeasurement SignalID (UUID) from the specified signalIndex.

type CompressionModesEnum

type CompressionModesEnum uint32

CompressionModesEnum defines the type for the CompressionModes enumeration.

type ConnectStatusEnum

type ConnectStatusEnum int

ConnectStatusEnum defines the type for the ConnectStatus enumeration.

type DataPacketFlagsEnum

type DataPacketFlagsEnum byte

DataPacketFlagsEnum defines the type for the DataPacketFlags enumeration.

type DataSubscriber

type DataSubscriber struct {

	// StatusMessageCallback is called when a informational message should be logged.
	StatusMessageCallback func(string)

	// ErrorMessageCallback is called when an error message should be logged.
	ErrorMessageCallback func(string)

	// ConnectionTerminatedCallback is called when DataSubscriber terminates its connection.
	ConnectionTerminatedCallback func()

	// AutoReconnectCallback is called when DataSubscriber automatically reconnects.
	AutoReconnectCallback func()

	// MetadataReceivedCallback is called when DataSubscriber receives a metadata response.
	MetadataReceivedCallback func([]byte)

	// SubscriptionUpdatedCallback is called when DataSubscriber receives a new signal index cache.
	SubscriptionUpdatedCallback func(signalIndexCache *SignalIndexCache)

	// DataStartTimeCallback is called with timestamp of first received measurement in a subscription.
	DataStartTimeCallback func(ticks.Ticks)

	// ConfigurationChangedCallback is called when the DataPublisher sends a notification that configuration has changed.
	ConfigurationChangedCallback func()

	// NewMeasurementsCallback is called when DataSubscriber receives a set of new measurements from the DataPublisher.
	NewMeasurementsCallback func([]Measurement)

	// NewBufferBlocksCallback is called when DataSubscriber receives a set of new buffer block measurements from the DataPublisher.
	NewBufferBlocksCallback func([]BufferBlock)

	// ProcessingCompleteCallback is called when the DataPublished sends a notification that temporal processing has completed,
	// i.e., the end of a historical playback data stream has been reached.
	ProcessingCompleteCallback func(string)

	// NotificationReceivedCallback is called when the DataPublisher sends a notification that requires receipt.
	NotificationReceivedCallback func(string)

	// CompressPayloadData determines whether payload data is compressed, defaults to TSSC.
	CompressPayloadData bool

	// CompressMetadata determines whether the metadata transfer is compressed, defaults to GZip.
	CompressMetadata bool

	// CompressSignalIndexCache determines whether the signal index cache is compressed, defaults to  GZip.
	CompressSignalIndexCache bool

	// Version defines the STTP protocol version used by this library
	Version byte

	// STTPSourceInfo defines the STTP library API title as identification information of DataSubscriber to a DataPublisher.
	STTPSourceInfo string

	// STTPVersionInfo defines the STTP library API version as identification information of DataSubscriber to a DataPublisher.
	STTPVersionInfo string

	// STTPUpdatedOnInfo defines when the STTP library API was last updated as identification information of DataSubscriber to a DataPublisher.
	STTPUpdatedOnInfo string
	// contains filtered or unexported fields
}

DataSubscriber represents a client subscription for an STTP connection.

func NewDataSubscriber

func NewDataSubscriber() *DataSubscriber

NewDataSubscriber creates a new DataSubscriber.

func (*DataSubscriber) ActiveSignalIndexCache

func (ds *DataSubscriber) ActiveSignalIndexCache() *SignalIndexCache

GetSignalIndexCache gets the active signal index cache.

func (*DataSubscriber) Connect

func (ds *DataSubscriber) Connect(hostName string, port uint16) error

Connect requests the the DataSubscriber initiate a connection to the DataPublisher.

func (*DataSubscriber) Connector

func (ds *DataSubscriber) Connector() *SubscriberConnector

Connector gets the SubscriberConnector associated with this DataSubscriber.

func (*DataSubscriber) DecodeString

func (ds *DataSubscriber) DecodeString(data []byte) string

DecodeString decodes an STTP string according to the defined operational modes.

func (*DataSubscriber) Disconnect

func (ds *DataSubscriber) Disconnect()

Disconnect initiates a DataSubscriber disconnect sequence.

func (*DataSubscriber) Dispose

func (ds *DataSubscriber) Dispose()

Dispose cleanly shuts down a DataSubscriber that is no longer being used, e.g., during a normal application exit.

func (*DataSubscriber) EncodeString

func (ds *DataSubscriber) EncodeString(data string) []byte

EncodeString encodes an STTP string according to the defined operational modes.

func (*DataSubscriber) IsConnected

func (ds *DataSubscriber) IsConnected() bool

IsConnected determines if a DataSubscriber is currently connected to a DataPublisher.

func (*DataSubscriber) IsSubscribed

func (ds *DataSubscriber) IsSubscribed() bool

IsSubscribed determines if a DataSubscriber is currently subscribed to a data stream.

func (*DataSubscriber) SendServerCommand

func (ds *DataSubscriber) SendServerCommand(commandCode ServerCommandEnum)

SendServerCommand sends a server command code to the DataPublisher with no payload.

func (*DataSubscriber) SendServerCommandWithMessage

func (ds *DataSubscriber) SendServerCommandWithMessage(commandCode ServerCommandEnum, message string)

SendServerCommandWithMessage sends a server command code to the DataPublisher along with the specified string message as payload.

func (*DataSubscriber) SendServerCommandWithPayload

func (ds *DataSubscriber) SendServerCommandWithPayload(commandCode ServerCommandEnum, data []byte)

SendServerCommandWithPayload sends a server command code to the DataPublisher along with the specified data payload.

func (*DataSubscriber) Subscribe

func (ds *DataSubscriber) Subscribe() error

Subscribe notifies the DataPublisher that a DataSubscriber would like to start receiving streaming data.

func (*DataSubscriber) SubscriberID

func (ds *DataSubscriber) SubscriberID() guid.Guid

SubscriberID gets the subscriber ID as assigned by the DataPublisher upon receipt of the SignalIndexCache.

func (*DataSubscriber) Subscription

func (ds *DataSubscriber) Subscription() *SubscriptionInfo

Subscription gets the SubscriptionInfo associated with this DataSubscriber.

func (*DataSubscriber) TotalCommandChannelBytesReceived

func (ds *DataSubscriber) TotalCommandChannelBytesReceived() uint64

TotalCommandChannelBytesReceived gets the total number of bytes received via the command channel since last connection.

func (*DataSubscriber) TotalDataChannelBytesReceived

func (ds *DataSubscriber) TotalDataChannelBytesReceived() uint64

TotalDataChannelBytesReceived gets the total number of bytes received via the data channel since last connection.

func (*DataSubscriber) TotalMeasurementsReceived

func (ds *DataSubscriber) TotalMeasurementsReceived() uint64

TotalMeasurementsReceived gets the total number of measurements received since last subscription.

func (*DataSubscriber) Unsubscribe

func (ds *DataSubscriber) Unsubscribe()

Unsubscribe notifies the DataPublisher that a DataSubscriber would like to stop receiving streaming data.

type Measurement

type Measurement struct {
	// Measurement's globally unique identifier.
	SignalID guid.Guid

	// Instantaneous value of the measurement.
	Value float64

	// The time, in ticks, that this measurement was taken.
	Timestamp ticks.Ticks

	// Flags indicating the state of the measurement as reported by the device that took it.
	Flags StateFlagsEnum
}

Measurement defines a basic unit of data for use by the STTP API.

func (*Measurement) AdjustedValue

func (m *Measurement) AdjustedValue() float64

AdjustedValue gets the Value of a Measurement with any linear adjustments applied from the measurement's Adder and Multiplier metadata.

func (*Measurement) DateTime

func (m *Measurement) DateTime() time.Time

DateTime gets a Measurement Ticks based timestamp as a standard Go Time value.

func (*Measurement) Metadata

func (m *Measurement) Metadata() *MeasurementMetadata

Metadata gets the MeasurementMetadata associated with a measurement from the local registry. If the metadata does not exist, a new record is created and returned.

func (*Measurement) TicksValue

func (m *Measurement) TicksValue() int64

TicksValue gets the integer-based time from a Measurement Ticks based timestamp, i.e., the 62-bit time value excluding any reserved flags.

type MeasurementMetadata

type MeasurementMetadata struct {
	// Measurement's globally unique identifier.
	SignalID guid.Guid

	// Additive value modifier.
	Adder float64

	// Multiplicative value modifier.
	Multiplier float64

	// Identification number used in human-readable measurement key.
	ID uint64

	// Source used in human-readable measurement key.
	Source string

	// Human-readable tag name or reference value used to help describe or help identify
	// the measurement. This value is initially empty and intended for end-user application.
	Tag string
}

MeasurementMetadata defines the ancillary information associated with a Measurement.

func LookupMetadata

func LookupMetadata(signalID guid.Guid) *MeasurementMetadata

LookupMetadata gets the MeasurementMetadata for the specified signalID from the local registry. If the metadata does not exist, a new record is created and returned.

type OperationalEncodingEnum

type OperationalEncodingEnum uint32

OperationalEncodingEnum defines the type for the OperationalEncoding enumeration.

type OperationalModesEnum

type OperationalModesEnum uint32

OperationalModesEnum defines the type for the OperationalModes enumeration.

type SecurityModeEnum

type SecurityModeEnum int

SecurityModeEnum defines the type for the SecurityMode enumeration.

type ServerCommandEnum

type ServerCommandEnum byte

ServerCommandEnum defines the type for the ServerCommand enumeration.

type ServerResponseEnum

type ServerResponseEnum byte

ServerResponseEnum defines the type for the ServerResponse enumeration.

type SignalIndexCache

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

SignalIndexCache maps 32-bit runtime IDs to 128-bit globally unique Measurement IDs. The structure additionally provides reverse lookup and an extra mapping to human-readable measurement keys.

func NewSignalIndexCache

func NewSignalIndexCache() *SignalIndexCache

NewSignalIndexCache makes a new SignalIndexCache

func (*SignalIndexCache) BinaryLength

func (sic *SignalIndexCache) BinaryLength() uint32

BinaryLength gets the binary length, in bytes, for the SignalIndexCache.

func (*SignalIndexCache) Contains

func (sic *SignalIndexCache) Contains(signalIndex int32) bool

Contains determines if the specified signalIndex exists with the SignalIndexCache.

func (*SignalIndexCache) Count

func (sic *SignalIndexCache) Count() uint32

Count returns the number of Measurement records that can be found in the SignalIndexCache.

func (*SignalIndexCache) ID

func (sic *SignalIndexCache) ID(signalIndex int32) uint64

ID returns the Measurement integer ID for the specified signalIndex in the SignalIndexCache.

func (*SignalIndexCache) Record

func (sic *SignalIndexCache) Record(signalIndex int32) (guid.Guid, string, uint64, bool)

Record returns the key Measurement values, signalID Guid, source string, and integer ID and a final boolean value representing find success for the specified signalIndex in the SignalIndexCache.

func (*SignalIndexCache) SignalID

func (sic *SignalIndexCache) SignalID(signalIndex int32) guid.Guid

SignalID returns the signal ID Guid for the specified signalIndex in the SignalIndexCache.

func (*SignalIndexCache) SignalIDs

func (sic *SignalIndexCache) SignalIDs() guid.HashSet

SignalIDs returns a HashSet for all the Guid values found in the SignalIndexCache.

func (*SignalIndexCache) SignalIndex

func (sic *SignalIndexCache) SignalIndex(signalID guid.Guid) int32

SignalIndex returns the signal index for the specified signalID Guid in the SignalIndexCache.

func (*SignalIndexCache) Source

func (sic *SignalIndexCache) Source(signalIndex int32) string

Source returns the Measurement source string for the specified signalIndex in the SignalIndexCache.

type SignalKindEnum

type SignalKindEnum uint16

SignalKindEnum defines the type for the SignalKind enumeration.

func ParseSignalKindAcronym

func ParseSignalKindAcronym(acronym string) SignalKindEnum

ParseSignalKindAcronym gets the SignalKind enumeration value for the specified acronym.

type StateFlagsEnum

type StateFlagsEnum uint32

StateFlagsEnum defines the type for the StateFlags enumeration.

type SubscriberConnection

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

SubscriberConnection represents a connection from a DataPublisher to DataSubscriber.

func (*SubscriberConnection) EncodeString

func (sc *SubscriberConnection) EncodeString(value string) []byte

EncodeString encodes an STTP string according to the defined operational modes.

type SubscriberConnector

type SubscriberConnector struct {
	// ErrorMessageCallback is called when an error message should be logged.
	ErrorMessageCallback func(string)

	// ReconnectCallback is called when SubscriberConnector attempts to reconnect.
	ReconnectCallback func(*DataSubscriber)

	// Hostname is the DataPublisher DNS name or IP.
	Hostname string

	// Port it the TCP/IP listening port of the DataPublisher.
	Port uint16

	// MaxRetries defines the maximum number of times to retry a connection.
	// Set value to -1 to retry infinitely.
	MaxRetries int32

	// RetryInterval defines the base retry interval, in milliseconds. Retries will
	// exponentially back-off starting from this interval.
	RetryInterval int32

	// MaxRetryInterval defines the maximum retry interval, in milliseconds.
	MaxRetryInterval int32

	// AutoReconnect defines flag that determines if connections should be
	// automatically reattempted.
	AutoReconnect bool
	// contains filtered or unexported fields
}

SubscriberConnector represents a connector that will establish or automatically reestablish a connection from a DataSubscriber to a DataPublisher.

func (*SubscriberConnector) Cancel

func (sc *SubscriberConnector) Cancel()

Cancel stops all current and future connection sequences.

func (*SubscriberConnector) Connect

Connect initiates a connection sequence for a DataSubscriber

func (*SubscriberConnector) ResetConnection

func (sc *SubscriberConnector) ResetConnection()

ResetConnection resets SubscriberConnector for a new connection.

type SubscriptionInfo

type SubscriptionInfo struct {
	// FilterExpression defines the desired measurements for a subscription. Examples include:
	//
	// * Directly specified signal IDs (UUID values in string format):
	//     38A47B0-F10B-4143-9A0A-0DBC4FFEF1E8; E4BBFE6A-35BD-4E5B-92C9-11FF913E7877
	//
	// * Directly specified tag names:
	//     DOM_GPLAINS-BUS1:VH; TVA_SHELBY-BUS1:VH
	//
	// * Directly specified identifiers in "measurement key" format:
	//     PPA:15; STAT:20
	//
	// * A filter expression against a selection view:
	//     FILTER ActiveMeasurements WHERE Company='GPA' AND SignalType='FREQ'
	FilterExpression string

	// Throttled determines if data will be published using down-sampling.
	Throttled bool
	// PublishInterval defines the down-sampling publish interval to use when Throttled is true.
	PublishInterval float64

	// UdpDataChannel requests that a UDP channel be used for data publication.
	UdpDataChannel bool
	// DataChannelLocalPort defines the desired UDP port to use for publication.
	DataChannelLocalPort uint16

	// IncludeTime determines if time should be included in non-compressed, compact measurements.
	IncludeTime bool
	// UseMillisecondResolution determines if time should be restricted to milliseconds in non-compressed, compact measurements.
	UseMillisecondResolution bool
	// RequestNaNValueFilter requests that the publisher filter, i.e., does not send, any NaN values.
	RequestNaNValueFilter bool

	// StartTime defines the start time for a requested temporal data playback, i.e., a historical subscription.
	// Simply by specifying a StartTime and StopTime, a subscription is considered a historical subscription.
	// Note that the publisher may not support historical subscriptions, in which case the subscribe will fail.
	StartTime string
	// StopTime defines the stop time for a requested temporal data playback, i.e., a historical subscription.
	// Simply by specifying a StartTime and StopTime, a subscription is considered a historical subscription.
	// Note that the publisher may not support historical subscriptions, in which case the subscribe will fail.
	StopTime string
	// ConstraintParameters defines any custom constraint parameters for a requested temporal data playback. This can
	// include parameters that may be needed to initiate, filter, or control historical data access.
	ConstraintParameters string
	// ProcessingInterval defines the initial playback speed, in milliseconds, for a requested temporal data playback.
	// With the exception of the values of -1 and 0, this value specifies the desired processing interval for data, i.e.,
	// basically a delay, or timer interval, over which to process data. A value of -1 means to use the default processing
	// interval while a value of 0 means to process data as fast as possible.
	ProcessingInterval int32

	// ExtraConnectionStringParameters defines any extra custom connection string parameters that may be needed for a subscription.
	ExtraConnectionStringParameters string
}

SubscriptionInfo defines subscription related settings for a DataSubscriber instance.

Jump to

Keyboard shortcuts

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