iec61499

package
v0.0.0-...-aee3c85 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrUndefinedEvent is used to indicate an event can't be found
	ErrUndefinedEvent = errors.New("Unknown event '{{arg}}'")

	//ErrNoEvents is used to indicate no events are present
	ErrNoEvents = errors.New("No Events Present")

	//ErrWrongBlockType is used to indicate the wrong type of block has been used in an operation (ie adding an internal var to a compositefb)
	ErrWrongBlockType = errors.New("Wrong Block Type for this operation")

	//ErrFbInstNameUndefined is used to indicate that an fb block instance with that name can't be found
	ErrFbInstNameUndefined = errors.New("FB instance name undefined")
)
View Source
var (
	//ErrFbTypeNameNotUnique is used to indicate when a FBType name isn't unique in the set
	ErrFbTypeNameNotUnique = errors.New("FBType Name '{{arg}}' is not unique in the set")

	//ErrInterfaceNameNotUnique is used to indicate when an interface name isn't unique in a block
	ErrInterfaceNameNotUnique = errors.New("Interface name '{{arg}}' is not unique in the FB")

	//ErrUndefinedAssociatedDataPort is used when an associated data port (to an event) can't be located
	ErrUndefinedAssociatedDataPort = errors.New("The associated data port '{{arg}}' can't be found")

	//ErrInterfaceDataTypeNotValid is used to indicate when an interface data type isn't valid
	ErrInterfaceDataTypeNotValid = errors.New("Interface data type '{{arg}}' is not valid")

	//ErrCompositeBFBsDontGetEventDataAssociations is used to indicate when a CFB block thas been given event/data associations
	ErrCompositeBFBsDontGetEventDataAssociations = errors.New("Composite FBs can't have event/data associations")

	//ErrUndefinedAlgorithm is used to indicate that an algorithm was referenced that can't be found (so probably a typo has occured)
	ErrUndefinedAlgorithm = errors.New("Can't find Algorithm with name '{{arg}}'")

	//ErrUndefinedState is used to indicate that a state was referenced that can't be found (so probably a typo has occured)
	ErrUndefinedState = errors.New("Can't find State with name '{{arg}}'")

	//ErrOnlyBasicFBsGetTriggers is returned when triggers (event/data associations) are put on anything other than a BasicFB
	ErrOnlyBasicFBsGetTriggers = errors.New("Only Basic FBs can have event/data associations/triggers")

	//ErrStateNameNotUnique is returned when a state name in a bfb is not unique
	ErrStateNameNotUnique = errors.New("The state name '{{arg}}' is not unique in the FB")

	//ErrFbReferenceInvalidType is returned when an embedded child type in a CFB can't be found
	ErrFbReferenceInvalidType = errors.New("The FBType of the FBReference (the instance type of an embedded FB) '{{arg}}' can't be found")

	//ErrFbReferenceNameNotUnique is returned when an instance in the CFB has a non-unique name
	ErrFbReferenceNameNotUnique = errors.New("The FBReference Name '{{arg}}' of the instance is not unique in the CFB")
)

Functions

func ComputeFBChildrenCounts

func ComputeFBChildrenCounts(fbs []FB) error

ComputeFBChildrenCounts counts and stores all FB children in all FBtypes across the network

func ConvertSTExpressionForPolicy

func ConvertSTExpressionForPolicy(il InterfaceList, inputPolicy bool, expr stconverter.STExpression) stconverter.STExpression

ConvertSTExpressionForPolicy will convert a single STExpression from an Output Policy transition guard to its Input Policy transition guard's Deriviation a == input b == output "a" becomes "a" "b" becomes "true" (technically becomes "true or not true") "a and b" becomes "a" "func(a, b)" becomes "func(a, true)" "!b" becomes "true" (technically becomes "not(true or not true)") TODO: a transition based only on time becomes nil?

func FBECCGuardToSTExpression

func FBECCGuardToSTExpression(pName, guard string) ([]stconverter.STInstruction, *stconverter.STParseError)

FBECCGuardToSTExpression converts a given FB's guard into a STExpression parsetree

func FBsEqual

func FBsEqual(a FB, b FB) bool

FBsEqual checks two function blocks for equality. It only checks the important fields.

func GetFBChildrenCounts

func GetFBChildrenCounts(fb *FB, fbs []FB) (int, error)

GetFBChildrenCounts recursively counts the number of fbChildren a fbtype has

func SolveSTExpression

func SolveSTExpression(il InterfaceList, inputPolicy bool, inp stconverter.STExpression) stconverter.STExpression

SolveSTExpression will solve simple STExpressions The top level should be one of the following if VARIABLE ONLY, return VARIABLE = 1 if NOT(VARIABLE) ONLY, return VARIABLE = 0 if VARIABLE == EXPRESSION, return VARIABLE = EXPRESSION if VARIABLE > EXPRESSION, return VARIABLE = EXPRESSION + 1 if VARIABLE >= EXPRESSION, return VARIABLE = EXPRESSION if VARIABLE < EXPRESSION, return VARIABLE = EXPRESSION - 1 if VARIABLE <= EXPRESSION, return VARIABLE = EXPRESSION if VARIABLE != EXPRESSION, return VARIABLE = EXPRESSION + 1 otherwise, return nil (can't solve)

func SplitExpressionsOnOr

func SplitExpressionsOnOr(expr stconverter.STExpression) []stconverter.STExpression

SplitExpressionsOnOr will take a given STExpression and return a slice of STExpressions which are split over the "or" operators, e.g. [a] should become [a] [or a b] should become [a] [b] [or a [b and c]] should become [a] [b and c] [[a or b] and [c or d]] should become [a and c] [a and d] [b and c] [b and d]

func VariablesContain

func VariablesContain(vars []Variable, name string) bool

VariablesContain returns true if a list of variables contains a given name

Types

type Action

type Action struct {
	Algorithm string `xml:"Algorithm,attr,omitempty"`
	Output    string `xml:"Output,attr,omitempty"`

	DebugInfo `xml:"-"`
}

Action is a link between an ECState and an Algorithm

type Algorithm

type Algorithm struct {
	Name    string        `xml:"Name,attr"`
	Comment string        `xml:"Comment,attr"`
	Other   OtherLanguage `xml:",omitEmpty"`

	DebugInfo `xml:"-"`
}

Algorithm is some code associated with a BasicFB

type BasicFB

type BasicFB struct {
	InternalVars []Variable     `xml:"InternalVars>VarDeclaration,omitempty"`
	States       []ECState      `xml:"ECC>ECState"`
	Transitions  []ECTransition `xml:"ECC>ECTransition,omitempty"`
	Algorithms   []Algorithm    `xml:"Algorithm,omitempty"`
}

BasicFB is used for basic function blocks (ie FB definitions)

func (*BasicFB) AddAlgorithm

func (bfb *BasicFB) AddAlgorithm(name string, lang string, prog string, debug DebugInfo) *BasicFB

AddAlgorithm adds an algorithm to a bfb it will return an error message if the block is not a basicFB

func (*BasicFB) AddDataInternals

func (bfb *BasicFB) AddDataInternals(intNames []string, typ string, size string, initialValue string, debug DebugInfo) *BasicFB

AddDataInternals adds data internals to a bfb, and adds the InternalVars section if it is nil

func (*BasicFB) AddState

func (bfb *BasicFB) AddState(name string, actions []Action, debug DebugInfo) *BasicFB

AddState adds a state to a bfb

func (*BasicFB) AddTransition

func (bfb *BasicFB) AddTransition(source string, dest string, cond string, debug DebugInfo) *BasicFB

AddTransition adds a state transition to a bfb

func (*BasicFB) GetTransitionsForState

func (b *BasicFB) GetTransitionsForState(source string) []ECTransition

GetTransitionsForState returns only the transitions for a given source state

type CompilerInfo

type CompilerInfo struct {
	Header   string `xml:"header,attr"`
	Classdef string `xml:"classdef,attr"`
}

CompilerInfo is used when compiling by some 61499 compilers (but not goFB)

type CompositeFB

type CompositeFB struct {
	XMLName          xml.Name      `xml:"FBNetwork"`
	FBs              []FBReference `xml:"FB"`
	EventConnections []Connection  `xml:"EventConnections>Connection,omitempty"`
	DataConnections  []Connection  `xml:"DataConnections>Connection,omitempty"`
}

CompositeFB is the type for composition function blocks (should be embedded into FB)

func (*CompositeFB) AddInstances

func (cfb *CompositeFB) AddInstances(fbTypeName string, fbInstNames []string, debug DebugInfo) *CompositeFB

AddInstances adds an instance to a cfb

func (*CompositeFB) AddNetworkDataConn

func (cfb *CompositeFB) AddNetworkDataConn(source string, destination string, debug DebugInfo) *CompositeFB

AddNetworkDataConn adds data network connections from one source to one destination

func (*CompositeFB) AddNetworkEventConns

func (cfb *CompositeFB) AddNetworkEventConns(sources []string, destination string, debug DebugInfo) *CompositeFB

AddNetworkEventConns adds event network connections from many sources to a single destination in a cfb

func (*CompositeFB) AddNetworkParameter

func (cfb *CompositeFB) AddNetworkParameter(param string, fbInstName string, portName string, debug DebugInfo) (*CompositeFB, *FBError)

AddNetworkParameter adds a parameter to a cfb network. It returns an error if the fbInstName is undefined (as it needs it to store the parameter)

func (*CompositeFB) GetUniqueDataConnSources

func (c *CompositeFB) GetUniqueDataConnSources() []string

GetUniqueDataConnSources is used to list all unique sources for data connections

func (*CompositeFB) GetUniqueEventConnSources

func (c *CompositeFB) GetUniqueEventConnSources() []string

GetUniqueEventConnSources is used to list all unique sources for event connections

type Connection

type Connection struct {
	Source      string `xml:"Source,attr"`
	Destination string `xml:"Destination,attr"`
	Dx1         string `xml:"dx1,attr"`

	DebugInfo `xml:"-"`
}

Connection is used to link either events or data lines together inside CompositeFBs

type ConnectionWithType

type ConnectionWithType struct {
	Connection
	Type string
}

ConnectionWithType struct used in cases when we want to know what a Connection's Data Type is (this can store it)

type DebugInfo

type DebugInfo struct {
	SourceLine int
	SourceFile string
}

DebugInfo is used when valid so that if something is invalid we can let the user know

type ECState

type ECState struct {
	Name      string   `xml:"Name,attr"`
	ECActions []Action `xml:"ECAction,omitempty"`
	Comment   string   `xml:"Comment,attr"`
	X         string   `xml:"x,attr"`
	Y         string   `xml:"y,attr"`

	DebugInfo `xml:"-"`
}

ECState is a state in the ECC (Execution control chart) of a BasicFB

type ECTransition

type ECTransition struct {
	Source      string `xml:"Source,attr"`
	Destination string `xml:"Destination,attr"`
	Condition   string `xml:"Condition,attr"`
	X           string `xml:"x,attr"`
	Y           string `xml:"y,attr"`

	DebugInfo `xml:"-"`
}

ECTransition is a transition in the ECC of a BasicFB

type Event

type Event struct {
	Name    string `xml:"Name,attr"`
	Comment string `xml:"Comment,attr"`
	With    []With `xml:",omitEmpty"`

	DebugInfo `xml:"-"`
}

Event is used to store events in BasicFBs

func (*Event) IsLoadFor

func (e *Event) IsLoadFor(v *Variable) bool

IsLoadFor used in templates for triggering updates of input data

type FB

type FB struct {
	XMLName xml.Name
	Name    string `xml:"Name,attr"`
	Comment string `xml:"Comment,attr"`

	Identification Identification

	VersionInfo VersionInfo

	CompilerInfo CompilerInfo
	//interface
	InterfaceList

	ResourceVars []Variable    `xml:"VarDeclaration"` //used in resource I/O
	Resources    []FBReference `xml:"Resource"`       //used in devices

	BasicFB     *BasicFB     `xml:",omitempty"`
	CompositeFB *CompositeFB `xml:",omitempty"`
	ServiceFB   *ServiceFB   `xml:",omitempty"`
	HybridFB    *HybridFB    `xml:"-"`          //don't ever export HybridFBs, convert them to BFBs first
	Policies    []PolicyFB   `xml:",omitempty"` //PolicyFB can wrap the execution of a given block

	NumChildren int `xml:"-"` //this is useful when using the event queue as we use it to assign unique blockInstanceIDs, it stores the recursive number of children a block has
	DebugInfo   `xml:"-"`
}

FB is the overall type for function blocks

func FindBlockDefinitionForType

func FindBlockDefinitionForType(bs []FB, t string) *FB

FindBlockDefinitionForType will search a list of FBs for a given name and return that block

func Must

func Must(f *FB, err *FBError) *FB

Must is used to panic if an error occurs when chaining functions

func NewBasicFB

func NewBasicFB(name string) *FB

NewBasicFB returns a BasicFB with default fields filled

func NewCompositeFB

func NewCompositeFB(name string) *FB

NewCompositeFB returns a CompositeFB with default fields filled

func NewHybridFB

func NewHybridFB(name string) *FB

NewHybridFB returns a HybridFB with default fields filled

func NewServiceFB

func NewServiceFB(name string) *FB

NewServiceFB returns a ServiceFB with default fields filled

func (*FB) AddBFBAlgorithm

func (fb *FB) AddBFBAlgorithm(name string, lang string, prog string, debug DebugInfo) *FB

AddBFBAlgorithm adds algorithm to an fb's bfb without performing error checking

func (*FB) AddBFBDataInternals

func (fb *FB) AddBFBDataInternals(intNames []string, typ string, size string, initialValue string, debug DebugInfo) *FB

AddBFBDataInternals adds data internals to an fb's bfb without performing error checking

func (*FB) AddBFBState

func (fb *FB) AddBFBState(name string, actions []Action, debug DebugInfo) *FB

AddBFBState adds state to an fb's bfb without performing error checking

func (*FB) AddBFBTransition

func (fb *FB) AddBFBTransition(source string, dest string, cond string, debug DebugInfo) *FB

AddBFBTransition adds a transition to an fb's bfb without performing error checking

func (*FB) AddCFBInstances

func (fb *FB) AddCFBInstances(fbTypeName string, fbInstNames []string, debug DebugInfo) *FB

AddCFBInstances adds an instance to a fb cfb without performing error checking

func (*FB) AddCFBNetworkDataConn

func (fb *FB) AddCFBNetworkDataConn(source string, destination string, debug DebugInfo) *FB

AddCFBNetworkDataConn adds data network conenctions in a fb cfb without performing error checking

func (*FB) AddCFBNetworkEventConns

func (fb *FB) AddCFBNetworkEventConns(sources []string, destination string, debug DebugInfo) *FB

AddCFBNetworkEventConns adds event network connections from many sources to a single destination in a fb cfb without performing error checking

func (*FB) AddCFBNetworkParameter

func (fb *FB) AddCFBNetworkParameter(param string, fbInstName string, portName string, debug DebugInfo) *FB

AddCFBNetworkParameter adds adds a parameter to a cfb network without performing error checking

func (*FB) AddDataInputs

func (fb *FB) AddDataInputs(intNames []string, intTriggers []string, typ string, size string, initialValue string, debug DebugInfo) (*FB, *FBError)

AddDataInputs adds data inputs to an FB it will return an error message if a trigger can't be found

func (*FB) AddDataOutputs

func (fb *FB) AddDataOutputs(intNames []string, intTriggers []string, typ string, size string, initialValue string, debug DebugInfo) (*FB, *FBError)

AddDataOutputs adds data inputs to an FB it will return an error message if a trigger can't be found

func (*FB) AddEventInputNames

func (fb *FB) AddEventInputNames(names []string, debug DebugInfo) *FB

AddEventInputNames adds event input names to a FB

func (*FB) AddEventOutputNames

func (fb *FB) AddEventOutputNames(names []string, debug DebugInfo) *FB

AddEventOutputNames adds event output names to a FB

func (*FB) AddHFBAlgorithm

func (fb *FB) AddHFBAlgorithm(name string, prog string, debug DebugInfo) *FB

AddHFBAlgorithm adds algorithm to an fb's hfb without performing error checking

func (*FB) AddHFBDataInternals

func (fb *FB) AddHFBDataInternals(intNames []string, typ string, size string, initialValue string, debug DebugInfo) *FB

AddHFBDataInternals adds data internals to an fb's bfb without performing error checking

func (*FB) AddHFBLocation

func (fb *FB) AddHFBLocation(name string, invariants []HFBInvariant, actions []Action, debug DebugInfo) *FB

AddHFBLocation adds location to an fb's hfb without performing error checking

func (*FB) AddHFBTransition

func (fb *FB) AddHFBTransition(source string, dest string, cond string, debug DebugInfo) *FB

AddHFBTransition adds a transition to an fb's bfb without performing error checking

func (*FB) AddPFBDataInternals

func (fb *FB) AddPFBDataInternals(intNames []string, typ string, size string, initialValue string, debug DebugInfo) *FB

AddPFBDataInternals adds data internals to an fb's efb without performing error checking

func (*FB) AddPFBState

func (fb *FB) AddPFBState(name string, debug DebugInfo) *FB

AddPFBState adds state to an fb's bfb without performing error checking

func (*FB) AddPFBTransition

func (fb *FB) AddPFBTransition(source string, dest string, cond string, expressions []PFBExpression, debug DebugInfo) *FB

AddPFBTransition adds a transition to an fb's bfb without performing error checking

func (*FB) AddPolicy

func (fb *FB) AddPolicy(name string) *FB

AddPolicy adds a PolicyFB to an FB

func (*FB) AddSIFBParams

func (fb *FB) AddSIFBParams(lang string, arbitrary string, inStruct string, preInit string, init string, run string, shutdown string, debug DebugInfo) *FB

AddSIFBParams adds all parameters to an SIFB. It returns no error

func (*FB) AddxFBDataInternals

func (fb *FB) AddxFBDataInternals(intNames []string, typ string, size string, initialValue string, debug DebugInfo) (*FB, error)

AddxFBDataInternals adds data internals to an fb's bfb OR hfb if a block is neither an hfb or a bfb then it returns an error

func (*FB) GetAllVarNames

func (fb *FB) GetAllVarNames() []string

GetAllVarNames gets all input, output, and internal (if available) var names on an FB

func (FB) GetDataConnectionTypes

func (f FB) GetDataConnectionTypes(otherBlocks []FB) ([]ConnectionWithType, error)

GetDataConnectionTypes is used to list all data connections in a given FB with their types as well

func (FB) GetUniqueDataConnSourcesWithTypes

func (f FB) GetUniqueDataConnSourcesWithTypes(otherBlocks []FB) ([]SourceAndType, error)

GetUniqueDataConnSourcesWithTypes is used to list all unique sources for data connections and their types

func (FB) IsSIFB

func (f FB) IsSIFB() bool

IsSIFB returns true if the FB is an interface only (i.e. is a SIFB)

func (*FB) NameUseCounter

func (fb *FB) NameUseCounter(name string) int

NameUseCounter will search all name fields {events,data,states,etc} of a FB to check to see if a given name is used anywhere and increment each time it is

func (*FB) SetXMLName

func (fb *FB) SetXMLName()

SetXMLName sets an appropriate name for the xml block type

func (*FB) TranslateHFBtoBFB

func (f *FB) TranslateHFBtoBFB() error

TranslateHFBtoBFB will take a Hybrid Function Block and translate it to its equivalent Basic Function Block It operates according to the algorithm specified in [TODO: Paper link]

func (*FB) TranslatePFBtoBFB

func (f *FB) TranslatePFBtoBFB() error

TranslatePFBtoBFB will take a Policy Function Block and compile it to its equivalent Basic Function Block It operates according to the algorithm specified in [TODO: Paper link]

func (*FB) TranslatePFBtoSIFB

func (f *FB) TranslatePFBtoSIFB() error

TranslatePFBtoSIFB will take a Policy Function Block and compile it to its enforcer as a Service Interface Function Block It operates according to the algorithm specified in [TODO: Paper link]

type FBError

type FBError struct {
	Arg string
	Err error
}

FBError is used to pass helpful error messages out to clients

type FBReference

type FBReference struct {
	Name      string      `xml:"Name,attr"`
	Type      string      `xml:"Type,attr"`
	X         string      `xml:"x,attr"`
	Y         string      `xml:"y,attr"`
	Parameter []Parameter `xml:",omitempty"`

	DebugInfo `xml:"-"`
}

FBReference are used inside CompositeFBs as instances of other function blocks

type HFBInvariant

type HFBInvariant struct {
	Invariant string

	DebugInfo
}

HFBInvariant is used to store invariant conditions in HFB locations The invariant will be in the form "variable [operand] value and/or ..."

type HFBLocation

type HFBLocation struct {
	Name       string
	ECActions  []Action
	Comment    string
	Invariants []HFBInvariant

	DebugInfo
}

HFBLocation is a location in the HFB HA (hybrid automata state machine) of a HybridFB

type HybridFB

type HybridFB struct {
	InternalVars []Variable     `xml:"-"`
	Locations    []HFBLocation  `xml:"-"`
	Transitions  []ECTransition `xml:"-"`
	Algorithms   []Algorithm    `xml:"-"`
}

HybridFB is used for Hybrid Function Blocks, which are translated to Basic Function Blocks before export

func (*HybridFB) AddAlgorithm

func (hfb *HybridFB) AddAlgorithm(name string, prog string, debug DebugInfo) *HybridFB

AddAlgorithm adds an algorithm to a hfb

func (*HybridFB) AddDataInternals

func (hfb *HybridFB) AddDataInternals(intNames []string, typ string, size string, initialValue string, debug DebugInfo) *HybridFB

AddDataInternals adds data internals to a bfb, and adds the InternalVars section if it is nil

func (*HybridFB) AddLocation

func (hfb *HybridFB) AddLocation(name string, invariants []HFBInvariant, actions []Action, debug DebugInfo) *HybridFB

AddLocation adds a location to a hfb

func (*HybridFB) AddTransition

func (hfb *HybridFB) AddTransition(source string, dest string, cond string, debug DebugInfo) *HybridFB

AddTransition adds a state transition to a bfb

type Identification

type Identification struct {
	Standard string `xml:"Standard,attr"`
}

Identification identifies what version of the standard is being used

type InterfaceList

type InterfaceList struct {
	EventInputs  []Event    `xml:"InterfaceList>EventInputs>Event,omitempty"`
	EventOutputs []Event    `xml:"InterfaceList>EventOutputs>Event,omitempty"`
	InputVars    []Variable `xml:"InterfaceList>InputVars>VarDeclaration,omitempty"`
	OutputVars   []Variable `xml:"InterfaceList>OutputVars>VarDeclaration,omitempty"`
}

InterfaceList is a container for all the IO ports of a Function Block

func (InterfaceList) HasEventNamed

func (il InterfaceList) HasEventNamed(input bool, s string) bool

HasEventNamed will check a given InterfaceList to see if it has an event of that name

func (InterfaceList) HasIODataNamed

func (il InterfaceList) HasIODataNamed(input bool, s string) bool

HasIODataNamed will check a given InterfaceList to see if it has an IO data var of that name

func (InterfaceList) HasIONamed

func (il InterfaceList) HasIONamed(input bool, s string) bool

HasIONamed will check a given InterfaceList to see if it has an output of that name

type OtherLanguage

type OtherLanguage struct {
	XMLName  xml.Name `xml:"Other"`
	Language string   `xml:"Language,attr"`
	Text     string   `xml:"Text,attr"`
}

OtherLanguage states what language an algorithm is written in

type PFBEnforcer

type PFBEnforcer struct {
	Name         string
	OutputPolicy PFBEnforcerPolicy
	InputPolicy  PFBEnforcerPolicy
	// contains filtered or unexported fields
}

A PFBEnforcer will store a given input and output policy and can derive the enforcers required to uphold them

func MakePFBEnforcer

func MakePFBEnforcer(il InterfaceList, p PolicyFB) (*PFBEnforcer, error)

MakePFBEnforcer will convert a given policy to an enforcer for that policy

func (*PFBEnforcer) SolveViolationTransition

func (enf *PFBEnforcer) SolveViolationTransition(tr PFBSTTransition, inputPolicy bool) STExpressionSolution

SolveViolationTransition will attempt to solve a given transition TODO: consider where people have been too explicit with their time variables, and have got non-violating time-based transitions 1. Check to see if there is a non-violating transition with an equivalent guard to the violating transition 2. Select first solution

type PFBEnforcerPolicy

type PFBEnforcerPolicy struct {
	InternalVars []Variable
	States       []PFBState
	Transitions  []PFBSTTransition
}

A PFBEnforcerPolicy is what goes inside a PFBEnforcer, it is derived from a Policy

func DeriveInputEnforcerPolicy

func DeriveInputEnforcerPolicy(il InterfaceList, outPol PFBEnforcerPolicy) PFBEnforcerPolicy

DeriveInputEnforcerPolicy will derive an Input Policy from a given Output Policy

func (PFBEnforcerPolicy) DoesExpressionInvolveTime

func (pol PFBEnforcerPolicy) DoesExpressionInvolveTime(expr stconverter.STExpression) bool

DoesExpressionInvolveTime returns true if a given expression uses time

func (PFBEnforcerPolicy) GetDTimers

func (pol PFBEnforcerPolicy) GetDTimers() []Variable

GetDTimers returns all DTIMERS in a PFBEnforcerPolicy

func (PFBEnforcerPolicy) GetNonViolationTransitions

func (pol PFBEnforcerPolicy) GetNonViolationTransitions() []PFBSTTransition

GetNonViolationTransitions returns a slice of all transitions in this PFBEnforcerPolicy that have their destinations not set to "violation", ie. are not violation transitions

func (PFBEnforcerPolicy) GetViolationTransitions

func (pol PFBEnforcerPolicy) GetViolationTransitions() []PFBSTTransition

GetViolationTransitions returns a slice of all transitions in this PFBEnforcerPolicy that have their destinations set to "violation", ie. are violation transitions

func (*PFBEnforcerPolicy) RemoveDuplicateTransitions

func (pol *PFBEnforcerPolicy) RemoveDuplicateTransitions()

RemoveDuplicateTransitions will do a search through a policies transitions and remove any that are simple duplicates (i.e. every field the same and in the same order).

type PFBExpression

type PFBExpression struct {
	VarName string
	Value   string
}

PFBExpression is used to assign a var a value based on a PFBTransitions

type PFBSTTransition

type PFBSTTransition struct {
	PFBTransition
	STGuard stconverter.STExpression
}

PFBSTTransition is a container struct for a PFBTransition and its ST translated guard

func ConvertPFBSTTransitionForInputPolicy

func ConvertPFBSTTransitionForInputPolicy(il InterfaceList, inputPolicy bool, outpTrans PFBSTTransition) PFBSTTransition

ConvertPFBSTTransitionForInputPolicy will convert a single PFBSTTransition from an Output Policy to its Input Policy Deriviation

func SplitPFBSTTransitions

func SplitPFBSTTransitions(cTrans []PFBSTTransition) []PFBSTTransition

SplitPFBSTTransitions will take a slice of PFBSTTRansitions and then split transitions which have OR clauses into multiple transitions it relies on the SplitExpressionsOnOr function below

type PFBState

type PFBState struct {
	Name      string
	DebugInfo `xml:"-"`
}

PFBState is a state in the policy specification of an enforcerFB

type PFBTransition

type PFBTransition struct {
	ECTransition
	Expressions []PFBExpression //expressions associated with this transition
}

PFBTransition is a transition between PFBStates in an PolicyFB (mealy machine transitions)

type Parameter

type Parameter struct {
	Name  string `xml:"Name,attr"`
	Value string `xml:"Value,attr"`

	DebugInfo `xml:"-"`
}

Parameter is a custom values associated with a FBReferences

type PolicyFB

type PolicyFB struct {
	Name         string
	InternalVars []Variable      `xml:"InternalVars>VarDeclaration,omitempty"`
	States       []PFBState      `xml:"ECC>ECState"`
	Transitions  []PFBTransition `xml:"ECC>ECTransition,omitempty"`
}

PolicyFB is used for specifying policies that must be kept

func (*PolicyFB) AddDataInternals

func (efb *PolicyFB) AddDataInternals(intNames []string, typ string, size string, initialValue string, debug DebugInfo) *PolicyFB

AddDataInternals adds data internals to a efb, and adds the InternalVars section if it is nil

func (*PolicyFB) AddState

func (efb *PolicyFB) AddState(name string, debug DebugInfo) *PolicyFB

AddState adds a state to a bfb

func (*PolicyFB) AddTransition

func (efb *PolicyFB) AddTransition(source string, dest string, cond string, expressions []PFBExpression, debug DebugInfo) *PolicyFB

AddTransition adds a state transition to a bfb

func (*PolicyFB) GetPFBSTTransitions

func (p *PolicyFB) GetPFBSTTransitions() ([]PFBSTTransition, error)

GetPFBSTTransitions will convert all internal PFBTransitions into PFBSTTransitions (i.e. PFBTransitions with a ST symbolic tree condition)

type STExpressionSolution

type STExpressionSolution struct {
	Expression string
	Comment    string
}

STExpressionSolution stores a solution to a violation transition

type ServiceAutogenerateCode

type ServiceAutogenerateCode struct {
	Language string `xml:",attr"` //Language of all *Texts below

	ArbitraryText string `xml:",attr"` //When autogenerating, put this outside of functions/structs at the beginning of the .c file
	InStructText  string `xml:",attr"` //When autogenerating, put this in the struct
	PreInitText   string `xml:",attr"` //When autogenerating, put this in pre_init function
	InitText      string `xml:",attr"` //When autogenerating, put this in init function
	RunText       string `xml:",attr"` //When autogenerating, put this in run function
	ShutdownText  string `xml:",attr"` //When autogenerating, put this in shutdown function

	DebugInfo `xml:"-"`
}

ServiceAutogenerateCode is used to store autogenerating code information for ServiceFBs it is not technically part of the standard, but should be safely ignored by tools that don't use this package

type ServiceFB

type ServiceFB struct {
	XMLName      xml.Name                 `xml:"Service"`
	Autogenerate *ServiceAutogenerateCode `xml:",omitempty"` //set fields in this we want to autogenerate files that is goFB compatible using the below *Texts
}

ServiceFB is used for compatible SIFBs

func (*ServiceFB) AddParams

func (sifb *ServiceFB) AddParams(lang string, arbitrary string, inStruct string, preInit string, init string, run string, shutdown string, debug DebugInfo) *ServiceFB

AddParams adds all parameters to an autogenerating SIFB

type SourceAndType

type SourceAndType struct {
	Source string
	Type   string
}

SourceAndType is used in similiar cases to ConnectionWithType, when we want to know both the source's name and the data type (this can store it)

type ValidateError

type ValidateError struct {
	Err error
	Arg string
	DebugInfo
}

A ValidateError is returned when validation of a network of function block fails

func ValidateFBs

func ValidateFBs(fbs []FB) *ValidateError

ValidateFBs will take a slice of FBs and check that they are valid It will check for the following, in this order: ALL FBs: - Type name unique in set - Interface names are unique in fb - Interface data types are valid - Interface associations (if present) are valid in fb (ie only bfbs get associations) BASIC FBs: - Internal data names don't conflict with interface names - Internal data types are valid COMPOSITE FBs: - CFB instance types exist - CFB instance names unique - CFB event/data connections valid based on instances

func (ValidateError) Error

func (v ValidateError) Error() string

type Variable

type Variable struct {
	Name         string `xml:"Name,attr"`
	Type         string `xml:"Type,attr"`
	ArraySize    string `xml:"ArraySize,attr,omitempty"`
	InitialValue string `xml:"InitialValue,attr,omitempty"`
	Comment      string `xml:"Comment,attr"`

	DebugInfo `xml:"-"`
}

Variable is used as a variable in an algorithm of a BasicFB

func FindVarDefinitionForName

func FindVarDefinitionForName(b FB, n string) *Variable

FindVarDefinitionForName will search a given block IO vars for a given variable

func (Variable) GetArraySize

func (v Variable) GetArraySize() int

GetArraySize returns the array size as an integer if there is one that can be parsed, otherwise 0

func (Variable) GetInitialArray

func (v Variable) GetInitialArray() []string

GetInitialArray returns a formatted initial array if there is one to do so

type VersionInfo

type VersionInfo struct {
	Organization string `xml:"Organization,attr"`
	Version      string `xml:"Version,attr"`
	Author       string `xml:"Author,attr"`
	Date         string `xml:"Date,attr"`
}

VersionInfo is used to provide metadata about the fb's version

type With

type With struct {
	Var string `xml:"Var,attr"`
}

With associates a variable and an event (as data only changes on events)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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