ecal

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

README

golang-ecal

A high-level interface from GO to eCAL based on a low-level interface generated via SWIG.

Status

This is the initial version providing an abstraction of the SWIG-generated low-level interface for initialization, publishers and subscribers.

ecal: This is the high-level interface. It allows initialization, data publishing and reception.

ecalc: This is the pure SWIG-generated low-level interface.

As the full low-level interface is accessible, you can do whatever the eCAL C interface allows you to do. More GO-like approaches like channels are only available via the high-level interface and thus are currently limited to publishers and subscribers. The publisher and subscriber interface are complete excluding event callbacks. Services and other functionality are currently only available via the low-level ecalc interface.

Usage

GO is about simplicity, so the high-level interface initializes a lot of settings with defaults if you do not call the initialization functions yourself.

Sending:

package main

import (
    "log"
    "time"

    "github.com/Blutkoete/golang-ecal/ecal"
)

func main() {
    pub, pubChannel, err := ecal.PublisherCreate("Hello", "base:std::string", "", true)
    if err != nil {
	    log.Fatal(err)
    }
    defer pub.Destroy()

    count := 0
    for ecal.Ok() {
	    message := ecal.Message{Content: []byte(fmt.Sprintf("Hello World from Go (%d)", count)),
		                    	Timestamp: -1}
	    count += 1
	    select {
	    case pubChannel <- message:
		    log.Printf("Sent \"%s\"\n", message.Content)
	    case <-time.After(time.Second):
	    }
	    <-time.After(250 * time.Millisecond)
    }
}

Receiving:

package main

import (
    "log"
    "time"

    "github.com/Blutkoete/golang-ecal/ecal"
)

func main() {
    sub, subChannel, err := ecal.SubscriberCreate("Hello", "base:std::string", "", true, 1024)
    if err != nil {
	    log.Fatal(err)
    }
    defer sub.Destroy()

    for ecal.Ok() {
	    select {
	    case message := <-subChannel:
		    log.Printf("Received \"%s\"\n", message.Content)
	    case <-time.After(time.Second):
	    }
    }
}

Documentation

Index

Constants

View Source
const (
	KeepLastHistoryQOS = iota
	KeepAllHistoryQOS  = iota
)
View Source
const (
	BestEffortReliability = iota
	ReliableReliability   = iota
)
View Source
const (
	TLayerNone   = 0
	TlayerUDPMc  = 1
	TLayerSHM    = 4
	TLayerInProc = 42
	TLayerAll    = 255
)
View Source
const (
	SModeNone = -1
	SModeOff  = 0
	SModeOn   = 1
	SModeAuto = 2
)
View Source
const InitMonitoring uint = uint(ecalc.ECAL_Init_Monitoring)
View Source
const InitProcessReg uint = uint(ecalc.ECAL_Init_ProcessReg)
View Source
const InitPublisher uint = uint(ecalc.ECAL_Init_Publisher)
View Source
const InitSubscriber uint = uint(ecalc.ECAL_Init_Subscriber)
View Source
const InitTimeSync uint = uint(ecalc.ECAL_Init_TimeSync)

Variables

This section is empty.

Functions

func Finalize

func Finalize(components uint) error

func Initialize

func Initialize(args []string, unitName string, components uint) error

func Ok

func Ok() bool

func ProcessSleepMS

func ProcessSleepMS(sleepTimeMs int64)

Types

type Message

type Message struct {
	Content   []byte
	Timestamp int64
}

type PublisherIf

type PublisherIf interface {
	Start() error
	Stop() error
	Destroy() error

	IsStopped() bool
	IsDestroyed() bool
	IsSubscribed() bool

	GetHandle() uintptr
	GetInputChannel() chan<- Message
	GetEventChannel() <-chan bool
	GetTopic() string
	GetType() string
	GetDescription() string
	GetQoS() (WriterQOS, error)
	GetLayerMode() (int, int)
	GetMaxBandwidthUDP() int64
	GetID() int64

	SetDescription(topicDesc string) error
	SetQoS(qos WriterQOS) error
	SetLayerMode(layerMode int, sendMode int) error
	SetMaxBandwidthUDP(bandwidth int64) error
	SetID(id int64) error

	ShareType(state int) error
	ShareDescription(state int) error

	Dump() ([]byte, error)
	// contains filtered or unexported methods
}

func PublisherCreate

func PublisherCreate(topicName string, topicType string, topicDesc string, start bool) (PublisherIf, chan<- Message, error)

type ReaderQOS

type ReaderQOS struct {
	HistoryKind int
	Reliability int
}

type SubscriberIf

type SubscriberIf interface {
	Start() error
	Stop() error
	Destroy() error

	IsStopped() bool
	IsDestroyed() bool

	GetHandle() uintptr
	GetBufferSize() int
	GetOutputChannel() <-chan Message
	GetEventChannel() <-chan bool
	GetTopic() string
	GetType() string
	GetDescription() string
	GetQoS() (ReaderQOS, error)
	GetIDs() []int64
	GetTimeout() int

	SetQoS(qos ReaderQOS) error
	SetIDs(id []int64) error
	SetTimeout(timeout int) error

	Dump() ([]byte, error)
}

func SubscriberCreate

func SubscriberCreate(topicName string, topicType string, topicDesc string, start bool, bufferSize int) (SubscriberIf, <-chan Message, error)

type WriterQOS

type WriterQOS struct {
	HistoryKind int
	Reliability int
}

Jump to

Keyboard shortcuts

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