formatter_lib

package module
v0.0.0-...-82f4aab Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

README

library to format device-messages corresponding to information from the iot-device-repository for unified consumption by the sepl-platform or transmission to the device

Documentation

Index

Constants

View Source
const (
	PLAIN_ID = "http://www.sepl.wifa.uni-leipzig.de/ontlogies/device-repo#PlainText"
	JSON_ID  = "http://www.sepl.wifa.uni-leipzig.de/ontlogies/device-repo#json"
	XML_ID   = "http://www.sepl.wifa.uni-leipzig.de/ontlogies/device-repo#xml"
)
View Source
const (
	XmlAttrFlag = "attr"
	XmlAnonym   = "anonym"
)

Variables

This section is empty.

Functions

func FormatToJson

func FormatToJson(config []model.ConfigField, value InputOutput) (result string, err error)

func FormatToJsonStruct

func FormatToJsonStruct(config []model.ConfigField, value InputOutput) (result interface{}, err error)

func FormatToPlainText

func FormatToPlainText(config []model.ConfigField, value InputOutput) (string, error)

func FormatToXml

func FormatToXml(config []model.ConfigField, value InputOutput, addidionalInfo []model.AdditionalFormatInfo) (result string, err error)

func GetFormatedValue

func GetFormatedValue(config []model.ConfigField, format string, value InputOutput, info []model.AdditionalFormatInfo) (result string, err error)

func UseDeviceConfig

func UseDeviceConfig(config []model.ConfigField, str string) string

func UseLiterals

func UseLiterals(value *InputOutput, valueType model.ValueType) (err error)

Types

type EventMsg

type EventMsg []ProtocolPart

type EventTransformer

type EventTransformer struct {
	Service model.Service

	IotRepoUrl string
	// contains filtered or unexported fields
}

func NewTransformer

func NewTransformer(iot Iot, deviceid string, serviceid string) (transformer EventTransformer, err error)

func NewTransformerFromRouting

func NewTransformerFromRouting(iot Iot, routing string) (result EventTransformer, err error)

func (*EventTransformer) Transform

func (this *EventTransformer) Transform(event EventMsg) (result string, err error)

type FormatedOutput

type FormatedOutput map[string]interface{}

type InputOutput

type InputOutput struct {
	Name    string        `json:"name,omitempty"`
	FieldId string        `json:"field_id"`
	Type    Type          `json:"type"`
	Value   string        `json:"value,omitempty"`
	Values  []InputOutput `json:"values,omitempty"`
}

func ParseFormat

func ParseFormat(valueType model.ValueType, format string, value string, info []model.AdditionalFormatInfo) (result InputOutput, err error)

content of valueType.Fields may be changed

func ParseFromJson

func ParseFromJson(valueType model.ValueType, value string) (result InputOutput, err error)

func ParseFromJsonInterface

func ParseFromJsonInterface(valueType model.ValueType, valueInterface interface{}) (result InputOutput, err error)

func ParseFromPlainText

func ParseFromPlainText(valueType model.ValueType, value string) (result InputOutput, err error)

func ParseFromXml

func ParseFromXml(valueType model.ValueType, value string, infos []model.AdditionalFormatInfo) (result InputOutput, err error)

type Iot

type Iot interface {
	GetDevice(id string) (result model.DeviceInstance, err error)
	GetDeviceType(id string) (result model.DeviceType, err error)
}

type ProtocolPart

type ProtocolPart struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Type

type Type struct {
	Id   string `json:"id"`
	Name string `json:"name"`
	Desc string `json:"desc"`
	Base string `json:"base"`
}

type XmlInfo

type XmlInfo struct {
	Value          InputOutput
	AdditionalInfo []model.AdditionalFormatInfo

	Config []model.ConfigField
	// contains filtered or unexported fields
}

func (XmlInfo) Init

func (this XmlInfo) Init() XmlInfo

func (XmlInfo) MarshalXML

func (this XmlInfo) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error)

TODO chardata

Jump to

Keyboard shortcuts

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