pcc

package module
v0.0.0-...-668706d Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

README

pcc

go.dev reference Go Report Card codecov Go sourcegraph

pcc solves several questions I've had over the years of working with industrial processes:

  • I want to define logic on the Process Controller side and have it be discoverable by an operator.
  • I want to be able to represent sequential and simultaneous processes and serialize them reliably and unambiguously.
    • I want a simple binary protocol for serializing process configuration.
    • Modbus registers for configuring process controllers is great, let's do something like that but reduced in scope and with extra register metadata in mind such as SI units.
  • I want to reuse modules between projects without duplicating too much code.
  • I want generic database interoperability with my process.
  • I want constrained memory consumption to be able to use protocol on microcontrollers. TinyGo compatibility.

How to install package:

go mod download github.com/soypat/pcc@latest

This is a work in progress. pcc provides robust process control primitives.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Procedure procedure
	Args      []byte
}

type CommandList

type CommandList struct {
	// APIVersion is the version of the API available for the module.
	APIVersion uint8

	// ModuleType is the type of module that this command list is for.
	ModuleType moduletype
	// Commands is a list of commands that may be executed by the module.
	Commands []Command
}

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func (*Controller) CallProcedure

func (c *Controller) CallProcedure(apiver uint8, module moduletype, proc procedure, id uint8, arg []byte) error

func (*Controller) Exec

func (c *Controller) Exec(proc *Process) error

func (*Controller) SetProcedures

func (c *Controller) SetProcedures(apiver uint8, module moduletype, fn func(proc procedure, id uint8, arg []byte) error)

func (*Controller) VisitProcedures

func (c *Controller) VisitProcedures(proc *Process, fn func(apiver uint8, module moduletype, proc procedure, id uint8, args []byte) error) error

type ControllerConfig

type ControllerConfig struct {

	// CRC is the CRC32 of the configuration packet, not including the CRC field (zeroed).
	CRC uint32
	// Registers contains the static configuration of the process controller.
	Registers []Register
	// CommandLists contains available actions that may be performed
	// by the modules available to the process controller.
	CommandLists []CommandList

	// Sequences contains
	Sequences []Sequence
	// contains filtered or unexported fields
}

ControllerConfig is the configuration of the process controller.

func (*ControllerConfig) AddCommand

func (cfg *ControllerConfig) AddCommand(apiver uint8, module moduletype, cmd Command)

func (ControllerConfig) GetCommandList

func (cfg ControllerConfig) GetCommandList(apiver uint8, module moduletype) *CommandList

GetCommandList returns the command list for the given API version and module type.

func (ControllerConfig) Reset

func (cfg ControllerConfig) Reset()

func (ControllerConfig) UUID

func (e ControllerConfig) UUID() uuid_t

func (ControllerConfig) Version

func (e ControllerConfig) Version() uint8

type Process

type Process struct {

	// CRC is the CRC32 of the process packet, not including the CRC field (zeroed).
	CRC   uint32
	Flags ProcessFlags
	Start maybetime

	// ConfigCRC is the CRC32 of the configuration stored in the process controller. Must match.
	ConfigCRC uint32
	// Units defines the process actions to be performed. The first unit is the start of the process.
	Units []Unit
	// contains filtered or unexported fields
}

Process is a complete definition of a process to be executed by the process controller.

func (Process) UUID

func (e Process) UUID() uuid_t

func (Process) Version

func (e Process) Version() uint8

func (*Process) VisitProcessUnits

func (p *Process) VisitProcessUnits(startIdx uint16, visitor func(idx uint16, u Unit) error) error

type ProcessFlags

type ProcessFlags uint64

type Register

type Register struct {
	Name [8]byte
	Base int8
	// rsv 	 [3]byte
	Dimension si.Dimension
	Value     int64
}

type Rx

type Rx struct {
	// contains filtered or unexported fields
}

func (*Rx) Reset

func (r *Rx) Reset(rd io.ReadCloser)

type Sequence

type Sequence struct {
	// Name is the human readable name of the sequence.
	Name [8]byte
	// Commands lists the commands to be executed in the sequence, in order.
	Commands []SequenceCommand
}

type SequenceCommand

type SequenceCommand struct {
	// CommandIndex is the 0-based index of the Command in the CommandList.
	CommandIndex uint16
	APIVersion   uint8
	// The identifier of the module to execute the command on.
	// For example, there may be several pumps in a process controller, each with a unique identifier.
	ModuleID uint8
	// ModuleType is the type of the module to execute the command on. Together with
	// APIVersion they select the CommandList to use.
	ModuleType moduletype
}

type Tx

type Tx struct {
}

type Unit

type Unit struct {
	Flags UnitFlags
	// Sequence is the index of this unit's sequence in the process controller's configuration.
	Sequence uint16
	// Next is the index of the next Unit in the process.
	Next uint16
	// Forks are the index of the forks to be started after running the unit.
	Forks []uint16
}

Unit represents a process control flow step in a Process. Actions of a Unit are represented as indices corresponding to the configuration of the process controller.

type UnitFlags

type UnitFlags uint8

UnitFlags decide the behavior of a Unit. | On End Bits(2) | RSV(6) |

func (UnitFlags) IsEnd

func (f UnitFlags) IsEnd() bool

func (UnitFlags) IsRestart

func (f UnitFlags) IsRestart() bool

Directories

Path Synopsis
examples
internal
si

Jump to

Keyboard shortcuts

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