kxcommon

package
v0.0.0-...-fefe0ed Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2019 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GUIDNew

func GUIDNew() string

GUIDNew Generates a new Guid

func Mapkey

func Mapkey(m map[string]string, value string) (key string, ok bool)

func SerializeObject

func SerializeObject(obj interface{}) (string, error)

func ToBool

func ToBool(val interface{}) (bool, error)

Types

type AMQPExchange

type AMQPExchange struct {
	Uri          string
	HostName     string
	ExchangeName string
	ExchangeType string
	QueueName    string
	RoutingKey   string
	UserName     string
	Password     string
	Durable      bool
	AutoDelete   bool
	Reliable     bool
	Connection   *amqp.Connection
	Channel      *amqp.Channel
	Queue        *amqp.Queue
	Messages     []string
	Confirms     chan amqp.Confirmation
	IsOpen       bool
}

AMQPExchange contains all parameters required to create or open an exchenge

func AMQPExchangeNew

func AMQPExchangeNew(hostName string, port int, exchangeName string, exchangeType string, queueName string, routingKey string,
	userName string, password string, durable bool, autoDelete bool, reliable bool) *AMQPExchange

AMQPExchangeNew creates a new exchange in the Broker

func (*AMQPExchange) Close

func (exch *AMQPExchange) Close() error

Close closes the exchange

func (*AMQPExchange) Open

func (exch *AMQPExchange) Open(isQueued bool) error

Open opens a previosly created Exchange

func (*AMQPExchange) PrepareReceiveFunc

func (exch *AMQPExchange) PrepareReceiveFunc(f func(msgs <-chan amqp.Delivery)) error

PrepareReceiveFunc Prepares exchange/queue to receive messages

func (*AMQPExchange) Publish

func (exch *AMQPExchange) Publish(body string) error

Publish publishes a new message into an existing exchange

func (*AMQPExchange) PublishObject

func (exch *AMQPExchange) PublishObject(obj interface{}) error

PublishObject serializes objects (JSON) and publish to existing exchange

func (*AMQPExchange) ReadMessages

func (exch *AMQPExchange) ReadMessages() ([]string, error)

ReadMessages reads the messajes accumulated in the queue

type AnalyticsArg

type AnalyticsArg struct {
	Name    string
	Value   string
	Quality string
}

AnalyticsArg argument into the request

func AnalyticsArgNew

func AnalyticsArgNew(name string, value string, quality string) AnalyticsArg

type AnalyticsRequest

type AnalyticsRequest struct {
	Function string
	Args     []AnalyticsArg
}

AnalyticsRequest main request to analytic calculation

func AnalyticsRequestNew

func AnalyticsRequestNew(function string, args []AnalyticsArg) AnalyticsRequest

type AnalyticsResponse

type AnalyticsResponse struct {
	Results []AnalyticsArg
	Success bool
}

type KXHistTSRecord

type KXHistTSRecord struct {
	Tag       string
	PType     string
	Value     float64
	ValueStr  string
	Quality   string
	TimeStamp time.Time
}

KXHistTSRecord defines the structure of the time series record in TSDB

type KXRTPObject

type KXRTPObject struct {
	ID    int
	Tag   string
	Ptype string
	Cv    *RtVal
	Pv    *RtVal
	Avg   *RtAvg
}

KXRTPObject configuration structure for Physical Objects

func DecodeUpdateMessage

func DecodeUpdateMessage(message string) (KXRTPObject, error)

DecodeUpdateMessage get messages coming from a KXDataProc

func (*KXRTPObject) Deserialize

func (rtpObject *KXRTPObject) Deserialize(jsonInput string) error

Deserialize - attempt to convert a Json to RTKXPObject

func (*KXRTPObject) Serialize

func (rtpObject *KXRTPObject) Serialize() (string, error)

Serialize - convert a RTKXPObject to Json

type KXScanMessageUnitType

type KXScanMessageUnitType int
const (
	MessageUnitTypeValue KXScanMessageUnitType = iota
	MessageUnitTypeQuality
	MessageUnitTypeUnknown
)

func (KXScanMessageUnitType) String

func (scanMessageUnitQuality KXScanMessageUnitType) String() string

type Quality

type Quality int

Quality enum

const (
	QualityOk Quality = iota
	QualityOld
	QualityBad
	QualityUnknown
)

func GetQualityFromString

func GetQualityFromString(qualityStr string) (Quality, error)

func (Quality) String

func (quality Quality) String() string

type RTDB

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

RTDB Real Time DB Class

func (*RTDB) CloseRTDB

func (rtdb *RTDB) CloseRTDB() error

CloseRTDB closes the RealTime DB

func (*RTDB) GetRTPObject

func (rtdb *RTDB) GetRTPObject(key string) (KXRTPObject, error)

GetRTPObject get RTpObject form RTDB (if exists)

func (*RTDB) GetValueFromKey

func (rtdb *RTDB) GetValueFromKey(key string) (string, error)

GetValueFromKey queries a value from key

func (*RTDB) IsRTDBConnected

func (rtdb *RTDB) IsRTDBConnected() bool

IsRTDBConnected checks if RTDB is connected

func (*RTDB) OpenRTDB

func (rtdb *RTDB) OpenRTDB() error

OpenRTDB opens the Real Time DB

func (*RTDB) RTDBNew

func (rtdb *RTDB) RTDBNew(hostName string, port int, userName string, password string, defaultDB int, jsonField string)

RTDBNew creates a new RT DB connection object

func (*RTDB) SetValueForKey

func (rtdb *RTDB) SetValueForKey(key string, value string) error

SetValueForKey updates db value for a key

func (*RTDB) UpdateRTPObject

func (rtdb *RTDB) UpdateRTPObject(key string, rtpObject KXRTPObject) error

UpdateRTPObject updates RTPObject into RTDB

type RtAvg

type RtAvg struct {
	Average  float64
	Variance float64
}

RtAvg represent Realtime calculated averages

type RtVal

type RtVal struct {
	Value     float64
	ValueStr  string
	Quality   Quality
	Timestamp time.Time
}

RtVal represent a realtime sample

type ScanMessage

type ScanMessage struct {
	MID     string
	Payload []ScanMessageUnit
}

ScanMessage holds a group of new data sent from any scanner to the data processor

func ScanMessageNew

func ScanMessageNew() ScanMessage

ScanMessageNew creates a new scan message

func (*ScanMessage) ScanMessageAdd

func (sm *ScanMessage) ScanMessageAdd(smu ScanMessageUnit)

ScanMessageAdd Add a new ScanMessageUnit to existing ScanMessage

type ScanMessageUnit

type ScanMessageUnit struct {
	ID        int
	Tag       string
	Value     string
	Quality   string
	MType     KXScanMessageUnitType
	TimeStamp time.Time
}

ScanMessageUnit contains a single new value to be sent to the data processor

func ScanMessageUnitNew

func ScanMessageUnitNew(pOID int, tag string, value string, quality string, mType KXScanMessageUnitType, timeStamp time.Time) ScanMessageUnit

ScanMessageUnitNew creates a new scan message Unit

type TSDB

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

TSDB Time Series DB Class

func TSDBNew

func TSDBNew(hostName string, port int, userName string, password string) *TSDB

TSDBNew creates a new Time Series DB connection object

func (*TSDB) CloseTSDB

func (tsdb *TSDB) CloseTSDB() error

CloseTSDB closes the Time-Stamped DB

func (*TSDB) OpenTSDB

func (tsdb *TSDB) OpenTSDB() error

OpenTSDB opens the Time-Stamped DB

func (*TSDB) QueryTSOneTagLastValue

func (tsdb *TSDB) QueryTSOneTagLastValue(database string, table string, tag string, endTimeStamp time.Time) (map[string]interface{}, error)

QueryTSOneTagLastValue get lasr record from TimeStamped database for one tag where time < specified

func (*TSDB) QueryTSOneTagTimeRange

func (tsdb *TSDB) QueryTSOneTagTimeRange(database string, table string, tag string, startTimeStamp time.Time, endTimeStamp time.Time) ([]map[string]interface{}, error)

QueryTSOneTagTimeRange get records from TimeStamped database for one tag in a time range

type TSRecord

type TSRecord struct {
	TimeStamp time.Time
	Tags      map[string]string
	Fields    map[string]interface{}
}

TSRecord Time Series record structure

Jump to

Keyboard shortcuts

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