ets

package
v0.0.0-...-52f53cc Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ets provides functions to extract information from ETS .knxproj and .knxprod exports.

Opening the archive

You can open exported projects and product databases.

archive, err := ets.OpenExportArchive("my-project.knxproj")
if err != nil {
	fmt.Println(err)
	return
}

// Make sure to close the archive eventually.
defer archive.Close()

OpenExportArchive will scan for project and manufacturer files inside the given export archive. Project and manufacturer files will be stored in ProjectFiles and ManufacturerFiles respectively.

for _, manuFile := range archive.ManufacturerFiles {
	fmt.Println(manuFile.ContentID)
}

for _, projFile := range archive.ProjectFiles {
	fmt.Println(projFile.ProjectID)
}

Decoding files

Not all files within the export might be relevant to you. Therefore, no files are decoded automatically.

for _, projFile := range archive.ProjectFiles {
	projInfo, err := projFile.Decode()
	if err != nil {
		log.Println(err)
		continue
	}

	// Variable projInfo contains the project info described in the projFile.
	fmt.Println("Project", projInfo.Name)
}

This decodes only the basic project information. The actual project is contained in the installation files. Each installation file can contain multiple project installations. Yes, this is weird.

for _, instFile := range projFile.InstallationFiles {
	proj, err := instFile.Decode()
	if err != nil {
		log.Println(err)
		continue
	}

	for _, inst := range proj.Installations {
		fmt.Println("Installation", inst.Name)
	}
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplicationProgram

type ApplicationProgram struct {
	ID         ApplicationProgramID
	Name       string
	Version    uint
	Objects    []ComObject
	ObjectRefs []ComObjectRef
}

ApplicationProgram is an application program.

type ApplicationProgramID

type ApplicationProgramID string

ApplicationProgramID is the ID of an application program.

type Area

type Area struct {
	ID      AreaID
	Name    string
	Address uint
	Lines   []Line
}

Area is an area.

type AreaID

type AreaID string

AreaID is the ID of an area.

type ComObject

type ComObject struct {
	ID                ComObjectID
	Name              string
	Text              string
	Description       string
	FunctionText      string
	ObjectSize        string
	DatapointType     string
	Priority          string
	ReadFlag          bool
	WriteFlag         bool
	CommunicationFlag bool
	TransmitFlag      bool
	UpdateFlag        bool
	ReadOnInitFlag    bool
}

ComObject is a communication object.

type ComObjectID

type ComObjectID string

ComObjectID is the ID of a communication object.

type ComObjectInstanceRef

type ComObjectInstanceRef struct {
	RefID         ComObjectRefID
	DatapointType string
	Connectors    []Connector
}

ComObjectInstanceRef connects a communication object reference with zero or more group addresses.

type ComObjectRef

type ComObjectRef struct {
	ID                ComObjectRefID
	RefID             ComObjectID
	Name              *string
	Text              *string
	Description       *string
	FunctionText      *string
	ObjectSize        *string
	DatapointType     *string
	Priority          *string
	ReadFlag          *bool
	WriteFlag         *bool
	CommunicationFlag *bool
	TransmitFlag      *bool
	UpdateFlag        *bool
	ReadOnInitFlag    *bool
}

ComObjectRef is an instance/reference to a communication object.

type ComObjectRefID

type ComObjectRefID string

ComObjectRefID is the ID of a communication object reference.

type Connector

type Connector struct {
	Receive bool
	RefID   GroupAddressID
}

Connector is a connection to a group address.

type DeviceInstance

type DeviceInstance struct {
	ID         DeviceInstanceID
	Name       string
	Address    uint
	ComObjects []ComObjectInstanceRef
}

DeviceInstance is a device instance.

type DeviceInstanceID

type DeviceInstanceID string

DeviceInstanceID is the ID of a device instance.

type ExportArchive

type ExportArchive struct {
	ProjectFiles      []ProjectFile
	ManufacturerFiles []ManufacturerFile
	// contains filtered or unexported fields
}

ExportArchive is a handle to an exported archive (.knxproj or .knxprod).

func OpenExportArchive

func OpenExportArchive(path string) (*ExportArchive, error)

OpenExportArchive opens the exported archive located at given path.

func (*ExportArchive) Close

func (ex *ExportArchive) Close() error

Close the archive handle.

type GroupAddress

type GroupAddress struct {
	ID      GroupAddressID
	Name    string
	Address uint
}

GroupAddress is a group address.

type GroupAddressID

type GroupAddressID string

GroupAddressID is the ID of a group address.

type GroupRange

type GroupRange struct {
	ID         GroupRangeID
	Name       string
	RangeStart uint
	RangeEnd   uint
	Addresses  []GroupAddress
	SubRanges  []GroupRange
}

GroupRange is a range of group addresses.

type GroupRangeID

type GroupRangeID string

GroupRangeID is the ID of a group range.

type Installation

type Installation struct {
	Name           string
	Topology       []Area
	GroupAddresses []GroupRange
}

Installation is an installation within a project.

type InstallationFile

type InstallationFile struct {
	*zip.File

	InstallationID string
}

InstallationFile is a file that contains zero or more project installations.

func (*InstallationFile) Decode

func (i *InstallationFile) Decode() (p *Project, err error)

Decode the file in order to retrieve the project inside it.

type Line

type Line struct {
	ID      LineID
	Name    string
	Address uint
	Devices []DeviceInstance
}

Line is a line.

type LineID

type LineID string

LineID is the ID of a line.

type ManufacturerData

type ManufacturerData struct {
	Manufacturer ManufacturerID
	Programs     []ApplicationProgram
}

ManufacturerData contains manufacturer-specific data.

func DecodeManufacturerData

func DecodeManufacturerData(r io.Reader) (*ManufacturerData, error)

DecodeManufacturerData parses the contents of a manufacturer file.

func (*ManufacturerData) UnmarshalXML

func (md *ManufacturerData) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements xml.Unmarshaler.

type ManufacturerFile

type ManufacturerFile struct {
	*zip.File

	ManufacturerID string
	ContentID      string
}

ManufacturerFile is a manufacturer file.

func (*ManufacturerFile) Decode

func (mf *ManufacturerFile) Decode() (md *ManufacturerData, err error)

Decode the file in order to retrieve the manufacturer data inside it.

type ManufacturerID

type ManufacturerID string

ManufacturerID is the ID of a manufacturer.

type Project

type Project struct {
	ID            ProjectID
	Installations []Installation
}

Project contains an entire project. These information are usually stored within a file located at P-XXXX/N.xml (0 <= N <= 16).

func DecodeProject

func DecodeProject(r io.Reader) (*Project, error)

DecodeProject parses the contents of a project file.

func (*Project) UnmarshalXML

func (p *Project) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements xml.Unmarshaler.

type ProjectFile

type ProjectFile struct {
	*zip.File

	ProjectID         string
	InstallationFiles []InstallationFile
}

ProjectFile is a file that contains project information.

func (*ProjectFile) Decode

func (pf *ProjectFile) Decode() (pi *ProjectInfo, err error)

Decode the file in order to retrieve the project info inside it.

type ProjectID

type ProjectID string

ProjectID is a project identifier.

type ProjectInfo

type ProjectInfo struct {
	ID   ProjectID
	Name string
}

ProjectInfo contains project information. These information are usually stored in the P-XXXX/Project.xml file.

func DecodeProjectInfo

func DecodeProjectInfo(r io.Reader) (*ProjectInfo, error)

DecodeProjectInfo parses the contents of project info file.

func (*ProjectInfo) UnmarshalXML

func (pi *ProjectInfo) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements xml.Unmarshaler.

Jump to

Keyboard shortcuts

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