Documentation ¶
Index ¶
- Variables
- func NamedTypeDeclaration(nt NamedType) string
- func TypeDefinition(ty Type) string
- type AddOnInstrDef
- type Array
- type ArrayDims
- type CST
- type Class
- func (enum Class) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum Class) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum Class) String() string
- func (enum *Class) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *Class) UnmarshalXMLAttr(attr xml.Attr) error
- type Comment
- type Communications
- type ConfigTag
- type Connection
- type Controller
- type Data
- type DataFormat
- func (enum DataFormat) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum DataFormat) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum DataFormat) String() string
- func (enum *DataFormat) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *DataFormat) UnmarshalXMLAttr(attr xml.Attr) error
- type DataType
- type DataTypeFamily
- func (enum DataTypeFamily) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum DataTypeFamily) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum DataTypeFamily) String() string
- func (enum *DataTypeFamily) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *DataTypeFamily) UnmarshalXMLAttr(attr xml.Attr) error
- type DataValueMember
- type Description
- type EKeyState
- func (enum EKeyState) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum EKeyState) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum EKeyState) String() string
- func (enum *EKeyState) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *EKeyState) UnmarshalXMLAttr(attr xml.Attr) error
- type EKeyState_s
- type Element
- type EthernetNetwork
- type EthernetPort
- type ExtendedProperties
- type ExternalAccess
- func (enum ExternalAccess) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum ExternalAccess) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum ExternalAccess) String() string
- func (enum *ExternalAccess) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *ExternalAccess) UnmarshalXMLAttr(attr xml.Attr) error
- type IOTag
- type IOType
- func (enum IOType) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum IOType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum IOType) String() string
- func (enum *IOType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *IOType) UnmarshalXMLAttr(attr xml.Attr) error
- type Index
- type LocalTag
- type Member
- type Module
- type NamedType
- type Parameter
- type Pen
- type Port
- type PortType
- func (enum PortType) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum PortType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum PortType) String() string
- func (enum *PortType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *PortType) UnmarshalXMLAttr(attr xml.Attr) error
- type Program
- type RSLogix5000Content
- type Radix
- func (enum Radix) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum Radix) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum Radix) String() string
- func (enum *Radix) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *Radix) UnmarshalXMLAttr(attr xml.Attr) error
- type RedundancyInfo
- type Routine
- type RoutineType
- func (enum RoutineType) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum RoutineType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum RoutineType) String() string
- func (enum *RoutineType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *RoutineType) UnmarshalXMLAttr(attr xml.Attr) error
- type Rung
- type RungType
- func (enum RungType) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum RungType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum RungType) String() string
- func (enum *RungType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *RungType) UnmarshalXMLAttr(attr xml.Attr) error
- type Security
- type Structure
- type Tag
- type TagDims
- type TagList
- type TagType
- func (enum TagType) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum TagType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum TagType) String() string
- func (enum *TagType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *TagType) UnmarshalXMLAttr(attr xml.Attr) error
- type Task
- type TaskType
- func (enum TaskType) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (enum TaskType) MarshalXMLAttr(name xml.Name) (xml.Attr, error)
- func (enum TaskType) String() string
- func (enum *TaskType) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (enum *TaskType) UnmarshalXMLAttr(attr xml.Attr) error
- type TimeSynchronize
- type Trend
- type Type
- type TypeList
- type WallClockTime
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnknownType = errors.New("unknown type")
Functions ¶
func NamedTypeDeclaration ¶
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 ¶
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"` }
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 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"` 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 (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"` }
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 (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 Description ¶
type Description struct {
Cdata string `xml:",cdata"`
}
type EKeyState ¶
type EKeyState int
func (EKeyState) MarshalXML ¶
func (EKeyState) MarshalXMLAttr ¶
func (*EKeyState) UnmarshalXML ¶
type EKeyState_s ¶
type EKeyState_s struct {
State EKeyState `xml:",attr"`
}
type EthernetNetwork ¶
type EthernetPort ¶
type ExtendedProperties ¶
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 (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 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"` }
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 ¶
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"` }
type PortType ¶
type PortType int
func (PortType) MarshalXML ¶
func (PortType) MarshalXMLAttr ¶
func (*PortType) UnmarshalXML ¶
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 RedundancyInfo ¶
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 (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
func (RungType) MarshalXML ¶
func (RungType) MarshalXMLAttr ¶
func (*RungType) UnmarshalXML ¶
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 TaskType ¶
type TaskType int
func (TaskType) MarshalXML ¶
func (TaskType) MarshalXMLAttr ¶
func (*TaskType) UnmarshalXML ¶
type TimeSynchronize ¶
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 ¶
AddControlLogixTypes adds a couple of types that are (I think) built into ControlLogix
func (TypeList) WriteDefinitions ¶
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 ¶
Click to show internal directories.
Click to hide internal directories.