knxproj

package module
v0.0.0-...-5849d71 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 13 Imported by: 0

README

knxproj - KNX project parser

I ported an existing project parser from Java to Go, which resulted in a bit of an ugly code.

Export used devices as JSON: go run cmd/main.go Project.knxproj

TODO

Resources

Documentation

Overview

Package knxproj parses the ETS file format and returns Groupaddresses with DPT.

Index

Constants

This section is empty.

Variables

View Source
var AddressStyle = 3
View Source
var AllGroupAddress map[string]GroupAddress
View Source
var ComObjectRefs map[string]ComObjectRef
View Source
var ComObjects map[string]ComObject
View Source
var Hardware map[string]Product
View Source
var Language = "en-US"
View Source
var Manufacturers map[string]Manufacturer

Functions

func ParseManufacturers

func ParseManufacturers(path string)

func ReadManufacturerData

func ReadManufacturerData(tmpFolder string)

func ReadProjects

func ReadProjects(tmpFolder string)

func Unzip

func Unzip(src, dest string) error

Types

type ApplicationProgram

type ApplicationProgram struct {
	ComObjects    []ComObject    `xml:"Static>ComObjectTable>ComObject"`
	ComObjectRefs []ComObjectRef `xml:"Static>ComObjectRefs>ComObjectRef"`

	Name string `xml:"Name,attr"`
	ID   string `xml:"Id,attr"`
}

type Area

type Area struct {
	ID      string `xml:"Id,attr"`
	Address string `xml:"Address,attr"`
	Name    string `xml:"Name,attr"`
	Puid    string `xml:"Puid,attr"`
	Lines   []Line `xml:"Line"`
}

type ChannelInstance

type ChannelInstance struct {
	IsActive string `xml:"IsActive,attr"`
	RefID    string `xml:"RefId,attr"`
	ID       string `xml:"Id,attr"`
	Name     string `xml:"Name,attr"`
}

type ComObject

type ComObject struct {
	ID                string `xml:"Id,attr"`
	Name              string `xml:"Name,attr"` // For what is name used? not visible in ETS
	Number            int    `xml:"Number,attr"`
	FunctionText      string `xml:"FunctionText,attr"`
	ObjectSize        string `xml:"ObjectSize,attr"`
	Text              string `xml:"Text,attr"`
	WriteFlag         string `xml:"WriteFlag,attr"`
	ReadFlag          string `xml:"ReadFlag,attr"`
	ReadOnInitFlag    string `xml:"ReadOnInitFlag,attr"`
	CommunicationFlag string `xml:"CommunicationFlag,attr"`
	TransmitFlag      string `xml:"TransmitFlag,attr"`
	UpdateFlag        string `xml:"UpdateFlag,attr"`
	DatapointType     string `xml:"DatapointType,attr"`
}

type ComObjectInstanceRef

type ComObjectInstanceRef struct {
	RefID             string     `xml:"RefId,attr"`
	IsActive          bool       `xml:"IsActive,attr"`
	DatapointType     string     `xml:"DatapointType,attr"`
	Text              string     `xml:"Text,attr"`
	ChannelID         string     `xml:"ChannelId,attr"`
	Connectors        Connectors `xml:"Connectors"`
	Description       string     `xml:"Description,attr"`
	TransmitFlag      string     `xml:"TransmitFlag,attr"`
	UpdateFlag        string     `xml:"UpdateFlag,attr"`
	WriteFlag         string     `xml:"WriteFlag,attr"`
	ReadFlag          string     `xml:"ReadFlag,attr"`
	CommunicationFlag string     `xml:"CommunicationFlag,attr"`
}

type ComObjectRef

type ComObjectRef struct {
	Name              string `xml:"Name,attr"`
	RefID             string `xml:"RefId,attr"`
	Tag               string `xml:"Tag,attr"`
	Text              string `xml:"Text,attr"`
	TransmitFlag      string `xml:"TransmitFlag,attr"`
	ReadFlag          string `xml:"ReadFlag,attr"` // Enabled or Disabled
	WriteFlag         string `xml:"WriteFlag,attr"`
	CommunicationFlag string `xml:"CommunicationFlag,attr"`
	UpdateFlag        string `xml:"UpdateFlag,attr"`
	ReadOnInitFlag    string `xml:"ReadOnInitFlag,attr"`
	ObjectSize        string `xml:"ObjectSize,attr"`
	FunctionText      string `xml:"FunctionText,attr"`
	ID                string `xml:"Id,attr"`
	DatapointType     string `xml:"DatapointType,attr"`
}

Why do the ComObjectRef have the same data as the ComObject?

type Connectors

type Connectors struct {
	Addresses []GroupAddressRef `xml:",any"`
}

type Device

type Device struct {
	ID               string  `json:"-"`
	ProductRefID     string  `json:"-"`
	Address          string  `json:"address"`
	Name             string  `json:"name"`
	Description      string  `json:"description"`
	Productname      string  `json:"productname"`
	Manufacturer     string  `json:"manufacturer"`
	Application      string  `json:"-"`
	Type             string  `json:"-"`
	Fingerprint      string  `json:"-"`
	SerialNumber     string  `json:"serialnumber"`
	Objects          Objects `json:"objects"`
	DownloadRequired bool    `json:"downloadrequired"`
}

func NewDevice

func NewDevice(area string, line string, xmlDevice DeviceInstance) *Device

func (Device) String

func (d Device) String() string

type DeviceInstance

type DeviceInstance struct {
	Description                               string                 `xml:"Description,attr"`
	MediumConfigLoaded                        string                 `xml:"MediumConfigLoaded,attr"`
	Comment                                   string                 `xml:"Comment,attr"`
	LastModified                              time.Time              `xml:"LastModified,attr"`
	Hardware2ProgramRefID                     string                 `xml:"Hardware2ProgramRefId,attr"`
	ID                                        string                 `xml:"Id,attr"`
	SerialNumber                              string                 `xml:"SerialNumber,attr"`
	IndividualAddressLoaded                   string                 `xml:"IndividualAddressLoaded,attr"`
	ProductRefID                              string                 `xml:"ProductRefId,attr"`
	ApplicationProgramLoaded                  string                 `xml:"ApplicationProgramLoaded,attr"`
	ParametersLoaded                          string                 `xml:"ParametersLoaded,attr"`
	IsCommunicationObjectVisibilityCalculated string                 `xml:"IsCommunicationObjectVisibilityCalculated,attr"`
	LastDownload                              time.Time              `xml:"LastDownload,attr"`
	CommunicationPartLoaded                   string                 `xml:"CommunicationPartLoaded,attr"`
	Name                                      string                 `xml:"Name,attr"`
	Address                                   string                 `xml:"Address,attr"`
	Puid                                      string                 `xml:"Puid,attr"`
	ComObjectInstanceRefs                     []ComObjectInstanceRef `xml:"ComObjectInstanceRefs>ComObjectInstanceRef"`
	ChannelInstances                          []ChannelInstance      `xml:"ChannelInstances>ChannelInstance"`
}

type Devices

type Devices []Device

func (Devices) Len

func (s Devices) Len() int

func (Devices) Less

func (s Devices) Less(i, j int) bool

func (Devices) Swap

func (s Devices) Swap(i, j int)

type GroupAddress

type GroupAddress struct {
	Address       string
	Name          string
	ID            string
	MainType      int
	SubType       int
	LinkedDevices int
	Flags         []string
}

func NewGroupAddress

func NewGroupAddress(ga GroupAddress2) *GroupAddress

func (GroupAddress) DataPointType

func (g GroupAddress) DataPointType() string

func (GroupAddress) String

func (g GroupAddress) String() string

type GroupAddress2

type GroupAddress2 struct {
	Puid          int    `xml:"Puid,attr"`
	ID            string `xml:"Id,attr"`
	Address       int    `xml:"Address,attr"`
	Name          string `xml:"Name,attr"`
	DatapointType string `xml:"DatapointType,attr"`
}

type GroupAddressGroup

type GroupAddressGroup struct {
	Name    string
	Address string
}

type GroupAddressRef

type GroupAddressRef struct {
	GroupAddressRefID string `xml:"GroupAddressRefId,attr"`
	Type              string // "send" or "receive"
}

type GroupAddresses

type GroupAddresses []GroupAddress

func (GroupAddresses) Len

func (s GroupAddresses) Len() int

func (GroupAddresses) Less

func (s GroupAddresses) Less(i, j int) bool

TODO: test with 2 style address

func (GroupAddresses) Swap

func (s GroupAddresses) Swap(i, j int)

type GroupRange

type GroupRange struct {
	Name         string          `xml:"Name,attr"`
	Puid         int             `xml:"Puid,attr"` // TODO: what does it mean?
	ID           string          `xml:"Id,attr"`
	RangeStart   int             `xml:"RangeStart,attr"` // TODO: what does it mean?
	RangeEnd     int             `xml:"RangeEnd,attr"`
	GroupRange   []GroupRange    `xml:"GroupRange"`
	GroupAddress []GroupAddress2 `xml:"GroupAddress"`
}

type Hardware2

type Hardware2 struct {
	//IsCoupler             string `xml:"IsCoupler,attr"`
	SerialNumber string `xml:"SerialNumber,attr"`
	//VersionNumber         string `xml:"VersionNumber,attr"`
	//HasApplicationProgram string `xml:"HasApplicationProgram,attr"`
	//BusCurrent            string `xml:"BusCurrent,attr"`
	//ID                    string `xml:"Id,attr"`
	//HasIndividualAddress  string `xml:"HasIndividualAddress,attr"`
	//OriginalManufacturer  string `xml:"OriginalManufacturer,attr"`
	//Name                  string `xml:"Name,attr"`
	Products []Product `xml:"Products>Product"`
}
type ApplicationProgramRef struct {
	RefID string `xml:"RefId,attr"`
}
type Manufacturer struct {
	RefID string `xml:"RefId,attr"`
}
type Language struct {
	Identifier string `xml:"Identifier,attr"`
}
type TranslationUnit struct {
	RefID string `xml:"RefId,attr"`
}
type TranslationElement struct {
	RefID string `xml:"RefId,attr"`
}
type Translation struct {
	AttributeName string `xml:"AttributeName,attr"`
	Text          string `xml:"Text,attr"`
}

type Installation

type Installation struct {
	Name           string       `xml:"Name,attr"`
	BCUKey         string       `xml:"BCUKey,attr"`
	DefaultLine    string       `xml:"DefaultLine,attr"`
	Topology       []Area       `xml:"Topology>Area"`
	GroupAddresses []GroupRange `xml:"GroupAddresses>GroupRanges>GroupRange"`
}

type Line

type Line struct {
	ID              string           `xml:"Id,attr"`
	Address         string           `xml:"Address,attr"`
	Name            string           `xml:"Name,attr"`
	MediumTypeRefID string           `xml:"MediumTypeRefId,attr"`
	Puid            string           `xml:"Puid,attr"`
	Devices         []DeviceInstance `xml:"DeviceInstance"`
}

type Manufacturer

type Manufacturer struct {
	ImportGroup        string `xml:"ImportGroup,attr"`
	CompatibilityGroup string `xml:"CompatibilityGroup,attr"`
	ID                 string `xml:"Id,attr"`
	KnxManufacturerID  string `xml:"KnxManufacturerId,attr"`
	Name               string `xml:"Name,attr"`
	DefaultLanguage    string `xml:"DefaultLanguage,attr"`
	ImportRestriction  string `xml:"ImportRestriction,attr"`
}

type ManufacturerData

type ManufacturerData map[string]string

type ManufacturerData2

type ManufacturerData2 struct {
	ApplicationProgram ApplicationProgram `xml:"ManufacturerData>Manufacturer>ApplicationPrograms>ApplicationProgram"`
}

type Object

type Object struct {
	Number       int      `json:"number"`
	Name         string   `json:"name"`
	Function     string   `json:"function"`
	Description  string   `json:"description"`
	Groupaddress []string `json:"groupaddress"`
	Bit          int      `json:"bit"`
	Flags        string   `json:"flags"`
	DPT          string   `json:"dpt"`
	RefID        string   `json:"-"`
	Channel      string   `json:"channel"`
	ReadOnInit   bool     `json:"-"`
}

type Objects

type Objects []Object

func (Objects) Len

func (slice Objects) Len() int

func (Objects) Less

func (slice Objects) Less(i, j int) bool

func (Objects) Swap

func (slice Objects) Swap(i, j int)

type ParameterInstanceRef

type ParameterInstanceRef struct {
	RefID string `xml:"RefId,attr"`
	Value string `xml:"Value,attr"`
}

type Product

type Product struct {
	DefaultLanguage    string `xml:"DefaultLanguage,attr"`
	Hash               string `xml:"Hash,attr"`
	ID                 string `xml:"Id,attr"`
	Text               string `xml:"Text,attr"`
	OrderNumber        string `xml:"OrderNumber,attr"`
	IsRailMounted      string `xml:"IsRailMounted,attr"`
	VisibleDescription string `xml:"VisibleDescription,attr"`
	SerialNumber       string
}

type Project

type Project struct {
	Name               string              `json:"name"`
	ID                 string              `json:"-"`
	Filename           string              `json:"filename"`
	GroupAddressStyle  int                 `json:"gaformat"`
	LastModified       time.Time           `json:"lastmodified"`
	DeviceList         Devices             `json:"devices"`
	GroupAddressList   GroupAddresses      `json:"-"`
	GroupAddressGroups []GroupAddressGroup `json:"-"`
}
var MainProject *Project

func NewProject

func NewProject(projFolder string) *Project

func (Project) String

func (p Project) String() string

type ProjectInformation

type ProjectInformation struct {
	Comment           string `xml:"Comment,attr"`
	CodePage          string `xml:"CodePage,attr"`
	DeviceCount       string `xml:"DeviceCount,attr"`
	LastUsedPuid      string `xml:"LastUsedPuid,attr"`
	GUID              string `xml:"Guid,attr"`
	Name              string `xml:"Name,attr"`
	GroupAddressStyle string `xml:"GroupAddressStyle,attr"`
	LastModified      string `xml:"LastModified,attr"`
}

type XMLHardware

type XMLHardware struct {
	//Manufacturer       Manufacturer         `xml:"ManufacturerData>Manufacturer"`
	Hardware []Hardware2 `xml:"ManufacturerData>Manufacturer>Hardware>Hardware"`
}

type XMLKNXMaster

type XMLKNXMaster struct {
	Manufacturers []Manufacturer `xml:"MasterData>Manufacturers>Manufacturer"`
}

type XMLProjectInformation

type XMLProjectInformation struct {
	CreatedBy   string `xml:"CreatedBy,attr"`
	ToolVersion string `xml:"ToolVersion,attr"`
	Project     struct {
		ID                 string             `xml:"Id,attr"`
		ProjectInformation ProjectInformation `xml:"ProjectInformation"`
	}
}

type XMLProjectInformationData

type XMLProjectInformationData struct {
	Installations []Installation `xml:"Project>Installations>Installation"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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