collector

package
v0.0.0-...-c4f4c22 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateEntry = errors.New("entry with given id already exists")

Functions

This section is empty.

Types

type BlockVar

type BlockVar struct {
	ID         int64   `json:"id"`
	S7DeviceID int64   `json:"s7_device_id"`
	DataBlock  int     `json:"data_block"`
	Addr       float32 `json:"addr"`
	Name       string  `json:"name"`
	Type       string  `json:"s7_type"`
	Unit       string  `json:"unit"`
}

type BlockVars

type BlockVars []BlockVar

type Client

type Client interface {
	AGReadDB(dbNumber int, start int, size int, buffer []byte) (err error)
	AGReadMB(start int, size int, buffer []byte) (err error)
	Close() error
}

type Collector

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

func NewCollector

func NewCollector(address string, rack, slot int, blockVars BlockVars, markers Markers, pub Publisher) (*Collector, error)

func NewCollectorFromClient

func NewCollectorFromClient(client Client, blockVars BlockVars, markers Markers, pub Publisher) (*Collector, error)

func (*Collector) Close

func (c *Collector) Close() error

func (*Collector) Collect

func (c *Collector) Collect() error

type DebugPublisher

type DebugPublisher struct {
	W io.Writer
}

func (*DebugPublisher) Publish

func (dp *DebugPublisher) Publish(buf []byte, vars []BlockVar, t time.Time) error

type Duration

type Duration time.Duration

type InfluxPublisher

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

func NewInfluxPublisher

func NewInfluxPublisher(addr, username, password, dbName, pointName string) (*InfluxPublisher, error)

func NewInfluxPublisherFromClient

func NewInfluxPublisherFromClient(client influx.Client, dbName, pointName string) *InfluxPublisher

func (*InfluxPublisher) Close

func (ip *InfluxPublisher) Close() error

func (*InfluxPublisher) PublishBlockVars

func (ip *InfluxPublisher) PublishBlockVars(buf []byte, db int, vars BlockVars, t time.Time) error

func (*InfluxPublisher) PublishMarkers

func (ip *InfluxPublisher) PublishMarkers(buf []byte, markers Markers, t time.Time) error

type Marker

type Marker struct {
	ID         int64   `json:"id"`
	S7DeviceID int64   `json:"s7_device_id"`
	Addr       float32 `json:"addr"`
	Name       string  `json:"name"`
}

type Markers

type Markers []Marker

type Poller

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

func NewPoller

func NewPoller(storage *PrestClient) *Poller

func (*Poller) Update

func (p *Poller) Update(client influx.Client, db string)

type PrestClient

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

func NewPrestClient

func NewPrestClient(host string) (s *PrestClient, err error)

func (*PrestClient) GetBlockVars

func (c *PrestClient) GetBlockVars(cid int) (BlockVars, error)

func (*PrestClient) GetChangedS7Devices

func (c *PrestClient) GetChangedS7Devices(t uint64) ([]S7Device, error)

func (*PrestClient) GetMarkers

func (c *PrestClient) GetMarkers(cid int) (Markers, error)

type Publisher

type Publisher interface {
	PublishBlockVars(buf []byte, dataBlock int, vars BlockVars, t time.Time) error
	PublishMarkers(buf []byte, markers Markers, t time.Time) error
}

type S7Device

type S7Device struct {
	ID           int64    `json:"id"`
	IP           string   `json:"ip"`
	Rack         int      `json:"rack"`
	Slot         int      `json:"slot"`
	Active       bool     `json:"active"`
	PollInterval Duration `json:"poll_interval"`
	UpdatedAt    uint64   `json:"updated_at"`
	SeriesName   string   `json:"series_name"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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