Documentation
¶
Overview ¶
Package initmessages contains all init messages that can be used to initiate a certain type of connection with DuetControlServer.
These are - CommandInitMessage - InterceptInitMessage - SubscribeInitMessage
Even though all types are public it is strongly advised to use the corresponding NewXYZInitMessage() functions to get a valid instance of an init message.
Index ¶
Constants ¶
const ( // ConnectionModeUnknown is an unknown connection type. If this is used the connection // is immediately terminated ConnectionModeUnknown ConnectionMode = "Unknown" // ConnectionModeCommand enters command mode. This allows clients to send general // purpose messages to the control server like G-codes or requests of the full // object model ConnectionModeCommand = "Command" // ConnectionModeIntercept enters interception mode. This allows clients to intercept // G/M/T-codes before or after they are initially processed or after they have been executed ConnectionModeIntercept = "Intercept" // ConnectionModeSubscribe enters subscription mode. In this mode object model updates are // transmitted to the client after each update ConnectionModeSubscribe = "Subscribe" )
const ( // InterceptionModePre intercepts codes before they are internally processed by the control server InterceptionModePre InterceptionMode = "Pre" // InterceptionModePost intercepts codes after the initial processing of the control server // but before they are forwarded to the RepRapFirmware controller InterceptionModePost = "Post" // InterceptionModeExecuted receives notifications for executed codes. In this state the final // result can still be changed InterceptionModeExecuted = "Executed" )
const ( // ProcotolVersion is the version the server needs to have to be compatible with // this client ProtocolVersion = 11 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseInitMessage ¶
type BaseInitMessage struct { // Mode is the desired connection mode Mode ConnectionMode // Version number of the client-side API Version int64 }
BaseInitMessage holds the common members of all init messages
func NewBaseInitMessage ¶
func NewBaseInitMessage(mode ConnectionMode) BaseInitMessage
NewBaseInitMessage creates a new BaseInitMessage for the given ConnectionMode
func (*BaseInitMessage) GetMode ¶
func (bim *BaseInitMessage) GetMode() ConnectionMode
GetMode returns the connection mode
type ClientInitMessage ¶
type ClientInitMessage interface { // GetMode returns the connection mode GetMode() ConnectionMode }
ClientInitMessage is sent from the client to the server as response to a ServerInitMessage. It allows to select the connection mode.
func NewCommandInitMessage ¶
func NewCommandInitMessage() ClientInitMessage
NewCommandInitMessage returns a command init message
func NewInterceptInitMessage ¶
func NewInterceptInitMessage(iMode InterceptionMode, channels []types.CodeChannel, filters []string, priorityCodes bool) ClientInitMessage
NewInterceptInitMessage creates a new InterceptInitMessage for the given InterceptionMode
func NewSubscribeInitMessage ¶
func NewSubscribeInitMessage(subMode SubscriptionMode, filters []string) ClientInitMessage
NewSubscribeInitMessage returns a new SubscribeInitMessage for the given mode and filters
type ConnectionMode ¶
type ConnectionMode string
ConnectionMode represents supported connection types for client connections
type InterceptInitMessage ¶
type InterceptInitMessage struct { BaseInitMessage // InterceptionMode selects when to intercept codes. InterceptionMode InterceptionMode // Channels is a list of channels where codes may be intercepted // If the list is empty, all available channels are used Channels []types.CodeChannel // Filters is a list of G/M/T-codes to filter or Q for comments // This may only specify the code type and major/minor number (e.g. G1 or M105). // Alternatively keyword types may be specified (e.g. if or elif). // Asterisks are supported, tool (e.g. T*) Filters []string // PriorityCodes defines if priority codes may be intercepted (e.g. M112, M122, M999) // See also CodeType.IsPrioritized PriorityCodes bool }
InterceptInitMessage enters interception mode. Whenever a code is received the connection must respons with one of - commands.Ignore to pass through the code without modifications (i.e. it is ignored by the client) - commands.Resolve to resolve the current code and return a message (i.e. the client has handled this code) In addition the interceptor may issue custom commands once a code has been received. Do not attemt to perform commands before an intercepted code is received else the order of commands exectution cannot be guaranteed.
type InterceptionMode ¶
type InterceptionMode string
InterceptionMode represents supported interception modes
type ServerInitMessage ¶
type ServerInitMessage struct { // Version of the server-side API. A client is supposed to check if received API level is // greater than or equal to ExpectedServerVersion (i.e. its own API level) once a connection // has been established in order to ensure that all of the required commands are actually // supported by the control server. Version int64 // Id is the unique connection ID assigned by the control server to allow clients to track their commands Id int64 }
ServerInitMessage is sent by the server to the client in JSON format once a connection has been established
func (*ServerInitMessage) IsCompatible ¶
func (s *ServerInitMessage) IsCompatible() bool
IsCompatible checks if the returned server API version is compatible with this client
type SubscribeInitMessage ¶
type SubscribeInitMessage struct { BaseInitMessage // SubscriptionMode is the type of subscription SubscriptionMode SubscriptionMode // Filter is an optional filter path for mode Patch // Multiple filters can be used on one connection and they have to be delimited by one of these charaters: ['|', ',', ' ', '\r', '\n'] // This setting is deprecated in favor of the new Filters list Filter string // Filters is an optional list of filter paths for mode Patch // The style of a filter is similar to XPath. For example, if you want to monitor only the current heater temperatures, // you can use the filter expression "heat/heaters[*]/current". Wildcards are supported either for full names or indices. // To get updates for an entire namespace, the ** wildcard can be used (for example heat/** for everything heat-related), // however it can be only used at the end of a filter expression. Filters []string }
SubscribeInitMessage enters subscription mode to receive either full object model or change patches after every update
type SubscriptionMode ¶
type SubscriptionMode string
SubscriptionMode represents supported subscription modes
const ( // SubscriptionModeFull receives full object model after each update // Generic messages may or may not be included in full object model. To keep // track of messages reliably it is strongly advised to creat a subscription // in Patch mode SubscriptionModeFull SubscriptionMode = "Full" // SubscriptionModePatch receives only updated JSON fragments of the object model SubscriptionModePatch = "Patch" )