l5x

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: MIT Imports: 10 Imported by: 0

README

l5x

A parser for the RSLogix5000 L5X format

This parser was designed to generate go structures for L5X tags for use with go-plc.

Example Usage

Generate a file gen.go in a package types which contains all of the types in your program file. go run github.com/stellentus/l5x/cmd/l5x-to-go -package types -in PATH/TO/PROGRAM.L5X -out gen.go

To generate the same as above, but using a go generate command in your project, add the following comment at the beginning of a file in the types package. //go:generate go run github.com/stellentus/l5x/cmd/l5x-to-go -package types -in PATH/TO/PROGRAM.L5X -out gen.go

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrUnknownType = errors.New("unknown type")

Functions

func NamedTypeDeclaration

func NamedTypeDeclaration(nt NamedType) string

NamedTypeDeclaration is used to declare a named type inside a struct. It automatically embeds if the variable name matches the type name.

Example
fmt.Println(NamedTypeDeclaration(NamedType{
	GoName: "MY_VAR",
	Type:   typeBOOL,
}))
fmt.Println(NamedTypeDeclaration(NamedType{
	GoName: "MY_STRUCT",
	Type:   newTestStructType("StructType", nil), // The nil members don't matter
}))
Output:

MY_VAR bool
MY_STRUCT StructType

func TypeDefinition

func TypeDefinition(ty Type) string
Example
types := []Type{}
types = append(types, typeBOOL) // prints nothing as it's built-in
types = append(types, newTestStructType("DemoStruct", []NamedType{
	{GoName: "VAR", Type: typeBOOL},
}))
types = append(types, newTestStructType("FancyThing", []NamedType{
	{GoName: "COUNT", Type: typeINT},
	{GoName: "dsInstance", Type: types[1]},
}))

for _, ty := range types {
	fmt.Println(TypeDefinition(ty))
}
Output:


type DemoStruct struct {
	VAR bool
}
type FancyThing struct {
	COUNT int16
	dsInstance DemoStruct
}

Types

type AddOnInstrDef

type AddOnInstrDef struct {
	Name                 string      `xml:",attr"`
	Revision             string      `xml:",attr"`
	RevisionExtension    string      `xml:",attr"`
	Vendor               string      `xml:",attr"`
	ExecutePrescan       bool        `xml:",attr"`
	ExecutePostscan      bool        `xml:",attr"`
	ExecuteEnableInFalse bool        `xml:",attr"`
	CreatedDate          iso8601Time `xml:",attr"`
	CreatedBy            string      `xml:",attr"`
	EditedDate           iso8601Time `xml:",attr"`
	EditedBy             string      `xml:",attr"`
	SoftwareRevision     string      `xml:",attr"`
	Description          Description `xml:",omitempty"`
	Parameters           []Parameter `xml:"Parameters>Parameter"`
	LocalTags            []LocalTag  `xml:"LocalTags>LocalTag"`
	Routines             []Routine   `xml:"Routines>Routine"`
}

func (AddOnInstrDef) AsType

func (aoi AddOnInstrDef) AsType(knownTypes TypeList) (Type, error)

type Array

type Array struct {
	Name       string    `xml:",attr,omitempty"`
	DataType   string    `xml:",attr"` // TODO: enum
	Dimensions ArrayDims `xml:",attr"`
	Radix      Radix     `xml:",attr"`
	Elements   []Element `xml:"Element"`
}

type ArrayDims

type ArrayDims TagDims

func (ArrayDims) MarshalXMLAttr

func (dims ArrayDims) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (*ArrayDims) UnmarshalXMLAttr

func (dims *ArrayDims) UnmarshalXMLAttr(attr xml.Attr) error

type CST

type CST struct {
	MasterID int `xml:",attr"`
}

type Class

type Class int
const (
	ClassUser Class = iota
)

func (Class) MarshalXML

func (enum Class) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (Class) MarshalXMLAttr

func (enum Class) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (Class) String

func (enum Class) String() string

func (*Class) UnmarshalXML

func (enum *Class) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*Class) UnmarshalXMLAttr

func (enum *Class) UnmarshalXMLAttr(attr xml.Attr) error

type Comment

type Comment struct {
	Operand string `xml:",attr"`
	Cdata   string `xml:",cdata"`
}

type Communications

type Communications struct {
	ConfigTag   ConfigTag
	Connections []Connection `xml:"Connections>Connection"`
}

type ConfigTag

type ConfigTag struct {
	ConfigSize     int            `xml:",attr"`
	ExternalAccess ExternalAccess `xml:",attr"`
	Data           []Data
}

type Connection

type Connection struct {
	Name        string `xml:",attr"`
	RPI         int    `xml:",attr"`
	Type        IOType `xml:",attr"`
	EventID     int    `xml:",attr"`
	SendTrigger bool   `xml:"ProgrammaticallySendEventTrigger,attr"`
	InputTag    IOTag
	OutputTag   IOTag
}

type Controller

type Controller struct {
	Use                      string      `xml:",attr"`
	Name                     string      `xml:",attr"`
	ProcessorType            string      `xml:",attr"`
	MajorRev                 int         `xml:",attr"`
	MinorRev                 int         `xml:",attr"`
	TimeSlice                int         `xml:",attr"`
	ShareUnusedTimeSlice     int         `xml:",attr"`
	ProjectCreationDate      rsLogixTime `xml:",attr"`
	LastModifiedDate         rsLogixTime `xml:",attr"`
	SFCExecutionControl      string      `xml:",attr"`
	SFCRestartPosition       string      `xml:",attr"`
	SFCLastScan              string      `xml:",attr"`
	ProjectSN                string      `xml:",attr"`
	MatchProjectToController bool        `xml:",attr"`
	CanUseRPIFromProducer    bool        `xml:",attr"`
	BlockAutoUpdate          bool        `xml:"InhibitAutomaticFirmwareUpdate,attr"`
	PassThroughConfiguration string      `xml:",attr"`
	DownloadProjDocs         bool        `xml:"DownloadProjectDocumentationAndExtendedProperties,attr"`
	DownloadProjProps        bool        `xml:"DownloadProjectCustomProperties,attr"`
	ReportMinorOverflow      bool        `xml:",attr"`
	RedundancyInfo           RedundancyInfo
	Security                 Security
	SecurityInfo             struct{}
	DataTypes                []DataType      `xml:"DataTypes>DataType"`
	Modules                  []Module        `xml:"Modules>Module"`
	AddOnInstrDefs           []AddOnInstrDef `xml:"AddOnInstructionDefinitions>AddOnInstructionDefinition"`
	Tags                     TagList         `xml:"Tags>Tag"`
	Programs                 []Program       `xml:"Programs>Program"`
	Tasks                    []Task          `xml:"Tasks>Task"`
	CST                      CST
	WallClockTime            WallClockTime
	Trends                   []Trend `xml:"Trends>Trend"`
	DataLogs                 struct{}
	TimeSynchronize          TimeSynchronize
	EthernetPorts            []EthernetPort `xml:"EthernetPorts>EthernetPort"`
	EthernetNetwork          EthernetNetwork
}

func (Controller) TypeList

func (ctrl Controller) TypeList() (TypeList, error)

func (Controller) WriteTagsStruct

func (ctrl Controller) WriteTagsStruct(tl TypeList, wr io.Writer) error
Example
tl, _ := exampleController.TypeList()
exampleController.WriteTagsStruct(tl, os.Stdout)
Output:

type Dancer struct {
	DOW Dow
	EX_AOI EVENT_TOT
	MultiArray [2][4]int16 `plctag:"multiArray"`
}

type EXAMPLE_FACTORY struct {
	INFO_ABOUT [2]int16
	BIGGD Big_data_type `plctag:"bIGGD"`
	Dancer `plctag:"Program:dancer"`
}

type Data

type Data struct {
	Format    DataFormat      `xml:",attr"`
	L5K       string          `xml:",cdata"`
	Structure Structure       `xml:",omitempty"`
	DataValue DataValueMember `xml:",omitempty"`
	Array     Array           `xml:",omitempty"`
}

type DataFormat

type DataFormat int
const (
	DataFormatDecorated DataFormat = iota
	DataFormatL5K
	DataFormatMessage
)

func (DataFormat) MarshalXML

func (enum DataFormat) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (DataFormat) MarshalXMLAttr

func (enum DataFormat) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (DataFormat) String

func (enum DataFormat) String() string

func (*DataFormat) UnmarshalXML

func (enum *DataFormat) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*DataFormat) UnmarshalXMLAttr

func (enum *DataFormat) UnmarshalXMLAttr(attr xml.Attr) error

type DataType

type DataType struct {
	Name    string         `xml:",attr"`
	Family  DataTypeFamily `xml:",attr"`
	Class   Class          `xml:",attr"`
	Members []Member       `xml:"Members>Member"`
}

func (DataType) AsType

func (dt DataType) AsType(knownTypes TypeList) (Type, error)

type DataTypeFamily

type DataTypeFamily int
const (
	DataTypeFamilyNone DataTypeFamily = iota
	DataTypeFamilyString
)

func (DataTypeFamily) MarshalXML

func (enum DataTypeFamily) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (DataTypeFamily) MarshalXMLAttr

func (enum DataTypeFamily) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (DataTypeFamily) String

func (enum DataTypeFamily) String() string

func (*DataTypeFamily) UnmarshalXML

func (enum *DataTypeFamily) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*DataTypeFamily) UnmarshalXMLAttr

func (enum *DataTypeFamily) UnmarshalXMLAttr(attr xml.Attr) error

type DataValueMember

type DataValueMember struct {
	Name     string `xml:",attr,omitempty"`
	DataType string `xml:",attr"` // TODO: enum
	Radix    Radix  `xml:",attr"`
	Value    string `xml:",attr"`
}

type Description

type Description struct {
	Cdata string `xml:",cdata"`
}

type EKeyState

type EKeyState int
const (
	EKeyStateExactMatch EKeyState = iota
	EKeyStateCompatibleModule
	EKeyStateDisabled
)

func (EKeyState) MarshalXML

func (enum EKeyState) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (EKeyState) MarshalXMLAttr

func (enum EKeyState) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (EKeyState) String

func (enum EKeyState) String() string

func (*EKeyState) UnmarshalXML

func (enum *EKeyState) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*EKeyState) UnmarshalXMLAttr

func (enum *EKeyState) UnmarshalXMLAttr(attr xml.Attr) error

type EKeyState_s

type EKeyState_s struct {
	State EKeyState `xml:",attr"`
}

type Element

type Element struct {
	Index Index  `xml:",attr"`
	Value string `xml:",attr"`
}

type EthernetNetwork

type EthernetNetwork struct {
	SupervisorModeEnabled bool `xml:",attr"`
	SupervisorPrecedence  int  `xml:",attr"`
	BeaconInterval        int  `xml:",attr"`
	BeaconTimeout         int  `xml:",attr"`
	VLANID                int  `xml:",attr"`
}

type EthernetPort

type EthernetPort struct {
	Port        int  `xml:",attr"`
	Label       int  `xml:",attr"`
	PortEnabled bool `xml:",attr"`
}

type ExtendedProperties

type ExtendedProperties struct {
	Public struct {
		ConfigID int
		CatNum   string
	} `xml:"public"`
}

type ExternalAccess

type ExternalAccess int
const (
	ExternalAccessReadWrite ExternalAccess = iota
	ExternalAccessReadOnly
)

func (ExternalAccess) MarshalXML

func (enum ExternalAccess) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (ExternalAccess) MarshalXMLAttr

func (enum ExternalAccess) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (ExternalAccess) String

func (enum ExternalAccess) String() string

func (*ExternalAccess) UnmarshalXML

func (enum *ExternalAccess) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*ExternalAccess) UnmarshalXMLAttr

func (enum *ExternalAccess) UnmarshalXMLAttr(attr xml.Attr) error

type IOTag

type IOTag struct {
	ExternalAccess ExternalAccess `xml:",attr"`
	Comments       []Comment      `xml:"Comments>Comment,omitempty"`
	Data           []Data
}

type IOType

type IOType int
const (
	IOTypeInput IOType = iota
	IOTypeOutput
)

func (IOType) MarshalXML

func (enum IOType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (IOType) MarshalXMLAttr

func (enum IOType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (IOType) String

func (enum IOType) String() string

func (*IOType) UnmarshalXML

func (enum *IOType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*IOType) UnmarshalXMLAttr

func (enum *IOType) UnmarshalXMLAttr(attr xml.Attr) error

type Index

type Index TagDims

func (Index) MarshalXMLAttr

func (dims Index) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (*Index) UnmarshalXMLAttr

func (dims *Index) UnmarshalXMLAttr(attr xml.Attr) error

type LocalTag

type LocalTag struct {
	Name           string         `xml:",attr"`
	DataType       string         `xml:",attr"` // TODO: enum
	Dimensions     int            `xml:",attr"`
	Radix          Radix          `xml:",attr"`
	ExternalAccess ExternalAccess `xml:",attr"`
	Description    Description
	DefaultData    []Data `xml:",omitempty"`
}

type Member

type Member struct {
	Name           string         `xml:",attr"`
	DataType       string         `xml:",attr"` // TODO: enum
	Dimension      int            `xml:",attr"`
	Radix          Radix          `xml:",attr"`
	Hidden         bool           `xml:",attr"`
	BitNumber      int            `xml:",attr,omitempty"`
	Target         string         `xml:",attr,omitempty"` // TODO: must match another Member's name
	ExternalAccess ExternalAccess `xml:",attr"`
	Description    Description    `xml:",omitempty"`
}

func (Member) AsNamedType

func (mb Member) AsNamedType(knownTypes TypeList) (NamedType, error)

type Module

type Module struct {
	Name               string `xml:",attr"`
	CatalogNumber      string `xml:",attr"`
	Vendor             int    `xml:",attr"`
	ProductType        int    `xml:",attr"`
	ProductCode        int    `xml:",attr"`
	Major              int    `xml:",attr"`
	Minor              int    `xml:",attr"`
	ParentModule       string `xml:",attr"` // TODO: must match another module name
	ParentModPortId    int    `xml:",attr"`
	Inhibited          bool   `xml:",attr"`
	MajorFault         bool   `xml:",attr"`
	EKey               EKeyState_s
	Ports              []Port `xml:"Ports>Port"`
	Communications     Communications
	ExtendedProperties ExtendedProperties
}

type NamedType

type NamedType struct {
	PlcName string
	GoName  string
	Type    Type
}

func (*NamedType) SetAsProgram

func (nt *NamedType) SetAsProgram()

SetAsProgram changes the PlcName to indicate this is a program tag.

type Parameter

type Parameter struct {
	Name           string         `xml:",attr"`
	TagType        TagType        `xml:",attr"`
	DataType       string         `xml:",attr"` // TODO: enum
	Usage          IOType         `xml:",attr"`
	Radix          Radix          `xml:",attr"`
	Required       bool           `xml:",attr"`
	Visible        bool           `xml:",attr"`
	ExternalAccess ExternalAccess `xml:",attr"`
	Description    Description    `xml:",omitempty"`
	DefaultData    []Data         `xml:",omitempty"`
}

func (Parameter) AsNamedType

func (par Parameter) AsNamedType(knownTypes TypeList) (NamedType, error)

type Pen

type Pen struct {
	Name    string  `xml:",attr"`
	Color   string  `xml:",attr"`
	Visible bool    `xml:",attr"`
	Style   int     `xml:",attr"`
	Type    string  `xml:",attr"`
	Width   int     `xml:",attr"`
	Marker  int     `xml:",attr"`
	Min     float32 `xml:",attr"`
	Max     float32 `xml:",attr"`
}

type Port

type Port struct {
	Id       int      `xml:",attr"`
	Address  string   `xml:",attr"`
	Type     PortType `xml:",attr"`
	Upstream bool     `xml:",attr"`
	Bus      struct {
		Size int `xml:",attr,omitempty"`
	}
}

type PortType

type PortType int
const (
	PortTypeEthernet PortType = iota
	PortTypeCompact
)

func (PortType) MarshalXML

func (enum PortType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (PortType) MarshalXMLAttr

func (enum PortType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (PortType) String

func (enum PortType) String() string

func (*PortType) UnmarshalXML

func (enum *PortType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*PortType) UnmarshalXMLAttr

func (enum *PortType) UnmarshalXMLAttr(attr xml.Attr) error

type Program

type Program struct {
	Name            string    `xml:",attr"`
	TestEdits       bool      `xml:",attr"`
	MainRoutineName string    `xml:",attr"`
	Disabled        bool      `xml:",attr"`
	UseAsFolder     bool      `xml:",attr"`
	Tags            TagList   `xml:"Tags>Tag"`
	Routines        []Routine `xml:"Routines>Routine"`
}

type RSLogix5000Content

type RSLogix5000Content struct {
	XMLName          xml.Name    `xml:"RSLogix5000Content"`
	SchemaRevision   float32     `xml:",attr"`
	SoftwareRevision float32     `xml:",attr"`
	TargetName       string      `xml:",attr"`
	TargetType       string      `xml:",attr"`
	ContainsContext  bool        `xml:",attr"`
	ExportDate       rsLogixTime `xml:"ExportDate,attr"`
	ExportOptions    stringSlice `xml:"ExportOptions,attr"`
	Controller       Controller
}

func NewFromFile

func NewFromFile(path string) (*RSLogix5000Content, error)

NewFromFile parses the RSLogix5000 L5X file at the provided path.

func NewFromReader

func NewFromReader(rd io.Reader) (*RSLogix5000Content, error)

NewFromReader parses a reader which provides data in RSLogix5000 L5X format.

type Radix

type Radix int
const (
	RadixDecimal Radix = iota
	RadixNullType
	RadixFloat
	RadixBinary
	RadixASCII
	RadixHex
)

func (Radix) MarshalXML

func (enum Radix) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (Radix) MarshalXMLAttr

func (enum Radix) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (Radix) String

func (enum Radix) String() string

func (*Radix) UnmarshalXML

func (enum *Radix) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*Radix) UnmarshalXMLAttr

func (enum *Radix) UnmarshalXMLAttr(attr xml.Attr) error

type RedundancyInfo

type RedundancyInfo struct {
	Enabled                   bool `xml:",attr"`
	KeepTestEditsOnSwitchOver bool `xml:",attr"`
	IOMemoryPadPercentage     int  `xml:",attr"`
	DataTablePadPercentage    int  `xml:",attr"`
}

type Routine

type Routine struct {
	Name        string      `xml:",attr"`
	Type        RoutineType `xml:",attr"`
	Description Description
	RLLContent  struct {
		Rungs []Rung `xml:"Rung"`
	}
}

type RoutineType

type RoutineType int
const (
	RoutineTypeRLL RoutineType = iota
	RoutineTypeST
	RoutineTypeFBD
)

func (RoutineType) MarshalXML

func (enum RoutineType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (RoutineType) MarshalXMLAttr

func (enum RoutineType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (RoutineType) String

func (enum RoutineType) String() string

func (*RoutineType) UnmarshalXML

func (enum *RoutineType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*RoutineType) UnmarshalXMLAttr

func (enum *RoutineType) UnmarshalXMLAttr(attr xml.Attr) error

type Rung

type Rung struct {
	Number  int      `xml:",attr"`
	Type    RungType `xml:",attr"`
	Comment Description
	Text    Description
}

type RungType

type RungType int
const (
	RungTypeN RungType = iota
)

func (RungType) MarshalXML

func (enum RungType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (RungType) MarshalXMLAttr

func (enum RungType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (RungType) String

func (enum RungType) String() string

func (*RungType) UnmarshalXML

func (enum *RungType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*RungType) UnmarshalXMLAttr

func (enum *RungType) UnmarshalXMLAttr(attr xml.Attr) error

type Security

type Security struct {
	Code            int    `xml:",attr"`
	ChangesToDetect string `xml:",attr"`
}

type Structure

type Structure struct {
	DataType        string            `xml:",attr"` // TODO: enum
	StructureMember []DataValueMember `xml:"StructureMember>DataValueMember"`
	DataValueMember []DataValueMember
	ArrayMember     Array `xml:",omitempty"`
}

type Tag

type Tag struct {
	Name           string         `xml:",attr"`
	TagType        TagType        `xml:",attr"`
	DataType       string         `xml:",attr"` // TODO: enum
	Dimensions     TagDims        `xml:",attr,omitempty"`
	Radix          Radix          `xml:",attr,omitempty"`
	Constant       bool           `xml:",attr"`
	ExternalAccess ExternalAccess `xml:",attr"`
	Description    Description
	Data           []Data
}

type TagDims

type TagDims []int

func (TagDims) MarshalXMLAttr

func (dims TagDims) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (*TagDims) UnmarshalXMLAttr

func (dims *TagDims) UnmarshalXMLAttr(attr xml.Attr) error

type TagList

type TagList []Tag

func (TagList) NamedTypes

func (tags TagList) NamedTypes(tl TypeList) ([]NamedType, error)

type TagType

type TagType int
const (
	TagTypeBase TagType = iota
)

func (TagType) MarshalXML

func (enum TagType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (TagType) MarshalXMLAttr

func (enum TagType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (TagType) String

func (enum TagType) String() string

func (*TagType) UnmarshalXML

func (enum *TagType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*TagType) UnmarshalXMLAttr

func (enum *TagType) UnmarshalXMLAttr(attr xml.Attr) error

type Task

type Task struct {
	Name                 string   `xml:",attr"`
	Type                 TaskType `xml:",attr"`
	Priority             int      `xml:",attr"`
	Watchdog             int      `xml:",attr"`
	DisableUpdateOutputs bool     `xml:",attr"`
	InhibitTask          bool     `xml:",attr"`
	ScheduledPrograms    []struct {
		Name string `xml:",attr"`
	} `xml:"ScheduledPrograms>ScheduledProgram"`
}

type TaskType

type TaskType int
const (
	TaskTypeContinuous TaskType = iota
)

func (TaskType) MarshalXML

func (enum TaskType) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (TaskType) MarshalXMLAttr

func (enum TaskType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (TaskType) String

func (enum TaskType) String() string

func (*TaskType) UnmarshalXML

func (enum *TaskType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

func (*TaskType) UnmarshalXMLAttr

func (enum *TaskType) UnmarshalXMLAttr(attr xml.Attr) error

type TimeSynchronize

type TimeSynchronize struct {
	Priority1 int  `xml:",attr"`
	Priority2 int  `xml:",attr"`
	PTPEnable bool `xml:",attr"`
}

type Trend

type Trend struct {
	Name             string `xml:",attr"`
	SamplePeriod     int    `xml:",attr"`
	NumberOfCaptures int    `xml:",attr"`
	CaptureSizeType  string `xml:",attr"`
	CaptureSize      int    `xml:",attr"`
	StartTriggerType string `xml:",attr"`
	StopTriggerType  string `xml:",attr"`
	TrendxVersion    string `xml:",attr"`
	Template         string
	Pens             []Pen `xml:"Pens>Pen"`
}

type Type

type Type interface {
	// PlcName is the name of the type, as used by the PLC (e.g. "my_struct" or "INT")
	PlcName() string

	// GoName is the name of the type, as used by go (e.g. "MyStruct" or "int16")
	GoName() string

	// GoTypeString is the go definition of the type (e.g. "struct {Val uint8}" or "").
	// For basic types, it's an empty string.
	GoTypeString() string
}

type TypeList

type TypeList []Type

func NewTypeList

func NewTypeList() TypeList

func (*TypeList) AddControlLogixTypes

func (tl *TypeList) AddControlLogixTypes() error

AddControlLogixTypes adds a couple of types that are (I think) built into ControlLogix

func (TypeList) WithPlcName

func (tl TypeList) WithPlcName(name string) (Type, error)

func (TypeList) WriteDefinitions

func (tl TypeList) WriteDefinitions(wr io.Writer) error
Example
err := expectedTypeList.WriteDefinitions(os.Stdout)
if err != nil {
	fmt.Println("ERROR:", err)
}
Output:

type TIMER struct {
	PRE int32
	ACC int32
	EN bool
	TT bool
	DN bool
}

type COUNTER struct {
	PRE int32
	ACC int32
	CU bool
	CD bool
	DN bool
	OV bool
	UN bool
}

type PID_ENHANCED struct {
	EnableIn bool
	PV float32
	PVFault bool
	PVEUMax float32
	PVEUMin float32
	SPProg float32
	SPOper float32
	SPCascade float32
	SPHLimit float32
	SPLLimit float32
	UseRatio bool
	RatioProg float32
	RatioOper float32
	RatioHLimit float32
	RatioLLimit float32
	CVFault bool
	CVInitReq bool
	CVInitValue float32
	CVProg float32
	CVOper float32
	CVOverride float32
	CVPrevious float32
	CVSetPrevious bool
	CVManLimiting bool
	CVEUMax float32
	CVEUMin float32
	CVHLimit float32
	CVLLimit float32
	CVROCLimit float32
	FF float32
	FFPrevious float32
	FFSetPrevious bool
	HandFB float32
	HandFBFault bool
	WindupHIn bool
	WindupLIn bool
	ControlAction bool
	DependIndepend bool
	PGain float32
	IGain float32
	DGain float32
	PVEProportional bool
	PVEDerivative bool
	DSmoothing bool
	PVTracking bool
	ZCDeadband float32
	ZCOff bool
	PVHHLimit float32
	PVHLimit float32
	PVLLimit float32
	PVLLLimit float32
	PVDeadband float32
	PVROCPosLimit float32
	PVROCNegLimit float32
	PVROCPeriod float32
	DevHHLimit float32
	DevHLimit float32
	DevLLimit float32
	DevLLLimit float32
	DevDeadband float32
	AllowCasRat bool
	ManualAfterInit bool
	ProgProgReq bool
	ProgOperReq bool
	ProgCasRatReq bool
	ProgAutoReq bool
	ProgManualReq bool
	ProgOverrideReq bool
	ProgHandReq bool
	OperProgReq bool
	OperOperReq bool
	OperCasRatReq bool
	OperAutoReq bool
	OperManualReq bool
	ProgValueReset bool
	TimingMode int32
	OversampleDT float32
	RTSTime int32
	RTSTimeStamp int32
	AtuneAcquire bool
	AtuneStart bool
	AtuneUseGains bool
	AtuneAbort bool
	AtuneUnacquire bool
	EnableOut bool
	CVEU float32
	CV float32
	CVInitializing bool
	CVHAlarm bool
	CVLAlarm bool
	CVROCAlarm bool
	SP float32
	SPPercent float32
	SPHAlarm bool
	SPLAlarm bool
	PVPercent float32
	E float32
	EPercent float32
	InitPrimary bool
	WindupHOut bool
	WindupLOut bool
	Ratio float32
	RatioHAlarm bool
	RatioLAlarm bool
	ZCDeadbandOn bool
	PVHHAlarm bool
	PVHAlarm bool
	PVLAlarm bool
	PVLLAlarm bool
	PVROCPosAlarm bool
	PVROCNegAlarm bool
	DevHHAlarm bool
	DevHAlarm bool
	DevLAlarm bool
	DevLLAlarm bool
	ProgOper bool
	CasRat bool
	Auto bool
	Manual bool
	Override bool
	Hand bool
	DeltaT float32
	AtuneReady bool
	AtuneOn bool
	AtuneDone bool
	AtuneAborted bool
	AtuneBusy bool
	Status1 int32
	Status2 int32
	InstructFault bool
	PVFaulted bool
	CVFaulted bool
	HandFBFaulted bool
	PVSpanInv bool
	SPProgInv bool
	SPOperInv bool
	SPCascadeInv bool
	SPLimitsInv bool
	RatioProgInv bool
	RatioOperInv bool
	RatioLimitsInv bool
	CVProgInv bool
	CVOperInv bool
	CVOverrideInv bool
	CVPreviousInv bool
	CVEUSpanInv bool
	CVLimitsInv bool
	CVROCLimitInv bool
	FFInv bool
	FFPreviousInv bool
	HandFBInv bool
	PGainInv bool
	IGainInv bool
	DGainInv bool
	ZCDeadbandInv bool
	PVDeadbandInv bool
	PVROCLimitsInv bool
	DevHLLimitsInv bool
	DevDeadbandInv bool
	AtuneDataInv bool
	TimingModeInv bool
	RTSMissed bool
	RTSTimeInv bool
	RTSTimeStampInv bool
	DeltaTInv bool
}

type MESSAGE struct {
}

type Dow struct {
	DayOW int16
	Month int32
	MonthCode [13]int32
	DayOW1 float32
}

type PackedBits struct {
	STEP [2]uint32
}

type Big_data_type struct {
	XprivateX_cleaning_c0 int8
	CLEAN_MODE int16
	XprivateX_cleaning_c7 int8
}

type Datas_for_eating struct {
	TIMER
	XprivateX_cleaning_c0 int8
	FOOD_TIMER TIMER
	MEAL_PREP_TIMER TIMER
	BHAIG29GI TIMER
	COUNTDOWN_TO_DESSERT TIMER
	STEPS_REQUIRED int16
	SoMuchData Big_data_type `plctag:"soMuchData"`
}

type EVENT_TOT struct {
	EnableIn bool
	EnableOut bool
	AlarmSP int16
}

type WallClockTime

type WallClockTime struct {
	LocalTimeAdjustment int `xml:",attr"`
	TimeZone            int `xml:",attr"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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