golabview

package module
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MPL-2.0 Imports: 3 Imported by: 0

README

golabview

Connect your go code with your LabVIEW code ! This module is a bridge between LabVIEW and Golang.

Functions

Flatten / Unflatten

This module provide a solution to flatten and unflatten data from and to LabVIEW from a Golang project. For the moment it is a manual method. An improvement could be to use the reflection.

Example :


/**************************************************************************************************/
/* Calibration Struct
/**************************************************************************************************/

//Calibration struct
type Calibration struct {
	CalA [][]float32
	CalB [][]float32
	Date float64
}

/**************************************************************************************************/
/* Calibration Struct Flatten & UnFlatten
/**************************************************************************************************/

// UnflattenFromByteSlice Calibration return rest of readed slice
func (cal *Calibration) UnflattenFromByteSlice(SliceToRead []byte) []byte {
	var data interface{}

	SliceToRead, data = golabview.Unflatten(SliceToRead, cal.CalA)
	cal.CalA = data.([][]float32)

	SliceToRead, data = golabview.Unflatten(SliceToRead, cal.CalB)
	cal.CalB = data.([][]float32)

	SliceToRead, data = golabview.Unflatten(SliceToRead, cal.Date)
	cal.Date = data.(float64)

	return SliceToRead
}

// FlattenToByteSlice Calibration and return writed size
func (cal Calibration) FlattenToByteSlice(sliceToWrite []byte) int {
	var index int
	index += golabview.Flatten(sliceToWrite[index:], cal.CalA)
	index += golabview.Flatten(sliceToWrite[index:], cal.CalB)
	index += golabview.Flatten(sliceToWrite[index:], cal.Date)
	return index
}

Time conversion

This module provide a solution to convert Golang Time and LabView Time.

Example :

	timestampDoubleTest := golabview.TimeToDouble(time.Now())
	timestampTime := golabview.DoubleToTime(timestampDoubleTest)
	timestampTimeRec := golabview.TimeToTimeRec(timestampTime)
	timestampDouble := golabview.TimeRecToDouble(timestampTimeRec)
	timestampTimeRec2 := golabview.DoubleToTimeRec(timestampDouble)
	timestampTime2 := golabview.TimeRecToTime(timestampTimeRec2)
	timestampDouble2 := golabview.TimeToDouble(timestampTime2)

Documentation

Index

Constants

View Source
const (
	StringOfTimestamp = 0 // string of full Timestamp yyyy mm dd HH MM SS

	StringOfDate = 1 // String of Date yyyy mm dd

	StringOfDateHour = 2 // String of Date yyyy mm dd HH

	StringOfHourMinuteSecond = 3 // String of Hour and minute HH MM SS

	StringOfHourMinute = 4 // String of Hour and minute HH MM

	StringOfHour = 5 // String of Hour HH

)

Variables

This section is empty.

Functions

func DoubleToTime

func DoubleToTime(timeToConvert float64) (timeGo time.Time)

func Flatten

func Flatten(SliceToWrite []byte, element interface{}) int

func FlattenSize

func FlattenSize(SliceToWrite []byte, element int) int

func TestTimeConversion

func TestTimeConversion()

func TimeRecToDouble

func TimeRecToDouble(TimeRec TimeRecLabview) float64

func TimeRecToTime

func TimeRecToTime(TimeRec TimeRecLabview) (timeGo time.Time)

func TimeToDouble

func TimeToDouble(timeToConvert time.Time) float64

func Unflatten

func Unflatten(SliceToRead []byte, element interface{}) (SliceReaded []byte, elementReaded interface{})

func UnflattenSize

func UnflattenSize(SliceToRead []byte) (SliceReaded []byte, element int)

Types

type TimeRecLabview

type TimeRecLabview struct {
	FractionalSecond float64 `json:"fractional second"`

	Second int32 `json:"second"`

	Minute int32 `json:"minute"`

	Hour int32 `json:"hour"`

	DayOfMonth int32 `json:"day of month"`

	Month int32 `json:"month"`

	Year int32 `json:"year"`

	DayOfWeek int32 `json:"day of week"`

	DayOfYear int32 `json:"day of year"`

	Dst int32 `json:"DST"`
}

func DoubleToTimeRec

func DoubleToTimeRec(timeToConvert float64) (TimeRec TimeRecLabview)

func TimeToTimeRec

func TimeToTimeRec(timeToConvert time.Time) (TimeRec TimeRecLabview)

func UnflattenTimeRecLabview

func UnflattenTimeRecLabview(SliceToRead []byte) (SliceReaded []byte, ltr TimeRecLabview)

func (*TimeRecLabview) FlattenToByteSlice

func (ltr *TimeRecLabview) FlattenToByteSlice(dataSlice []byte) int

func (*TimeRecLabview) GetString

func (ltr *TimeRecLabview) GetString(formatTime int) string

func (*TimeRecLabview) SetFromString

func (ltr *TimeRecLabview) SetFromString(timeString string, formatTime int) bool

func (*TimeRecLabview) SetTime

func (ltr *TimeRecLabview) SetTime(timeToWrite time.Time)

func (*TimeRecLabview) UnflattenFromByteSlice

func (ltr *TimeRecLabview) UnflattenFromByteSlice(SliceToRead []byte)

type TimeStampLabview

type TimeStampLabview struct {
	Second int64

	Fraction uint64
}

func TimeToTimeStampLabview

func TimeToTimeStampLabview(timeToConvert time.Time) (TimeToTimeStampLabview TimeStampLabview)

Jump to

Keyboard shortcuts

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