formatter_lib

package module
v0.0.0-...-b45c931 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2018 License: Apache-2.0 Imports: 13 Imported by: 3 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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(iotRepo string, httpclient HttpClient, deviceid string, serviceid string) (transformer EventTransformer, err error)

func NewTransformerFromRouting

func NewTransformerFromRouting(iotRepo string, httpclient HttpClient, routing string) (result EventTransformer, err error)

func (*EventTransformer) GetDevice

func (this *EventTransformer) GetDevice(client HttpClient, deviceId string) (result model.DeviceInstance, err error)

func (*EventTransformer) GetDeviceType

func (this *EventTransformer) GetDeviceType(client HttpClient, id string) (result model.DeviceType, err error)

func (*EventTransformer) Transform

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

type FormatedOutput

type FormatedOutput map[string]interface{}

type HttpClient

type HttpClient interface {
	Get(url string) (resp *http.Response, err error)
}

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 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
⌂ 换网址