Skip to content

OTPModulePosition

dsmurfin edited this page Aug 28, 2021 · 6 revisions

OTPModulePosition

OTP Module Position

public struct OTPModulePosition: OTPModule, Equatable 

Implements an OTP Standard Module of the Position type and handles creation and parsing.

This data structure contains the current position of a Point in all three linear directions (x, y, z), and scaling indicating whether units are in μm or mm.

Example usage:

   // initialize a module at x = 0.002m, y = 1m, z = 2m
   let module = OTPModulePosition(x: 2000, y: 1000000, z: 2000000, scaling: .μm)
 

Inheritance

Equatable, OTPModule

Initializers

init()

Initializes this OTPModule with default values.

public init() 

init(x:y:z:scaling:)

Initializes an OTP Module Position.

public init(x: Int32, y: Int32, z: Int32, scaling: Scaling) 

Parameters

  • x: The X position in units dependent on scaling.
  • y: The Y position in units dependent on scaling.
  • z: The Z position in units dependent on scaling.
  • scaling: The scaling of the position.

Properties

identifier

Uniquely identifies the module using an OTPModuleIdentifier.

public static let identifier: OTPModuleIdentifier 

dataLength

The size of the module's data in bytes.

public static let dataLength: OTPPDULength = 13

moduleLength

The total size of the module in bytes, including identifiers and length.

public static let moduleLength: OTPPDULength = dataLength + OTPPDULength(ModuleLayer.Offset.data.rawValue)

scaling

The scaling of the position values in this module.

public var scaling: Scaling = .μm

x

The X position in units dependent on scaling.

public var x: Int32 = 0 

y

The Y position in units dependent on scaling.

public var y: Int32 = 0 

z

The Z position in units dependent on scaling.

public var z: Int32 = 0 

logDescription

A human-readable log description of this module.

public var logDescription: String 

Methods

createAsData()

Creates a Module as Data.

public func createAsData() -> Data 

Returns

The OTPModule as a Data object.

parse(fromData:)

Attempts to create an OTPModulePosition from the data.

public static func parse(fromData data: Data) throws -> (module: Self, length: OTPPDULength) 

Parameters

  • data: The data to be parsed.

Throws

An error of type ModuleLayerValidationError.

Returns

A valid OTPModulePosition and the length of the PDU.

merge(modules:)

Merges an arrray of modules.

public static func merge(modules: [OTPModule]) -> (module: Self?, excludePoint: Bool) 

Parameters

  • modules: The OTPModules to be merged.

Returns

An optional OTPModule of this type, and whether to exclude the OTPPoint due to a mismatch.

isEqualToModule(_:)

Calculates whether this module is considered equal to another one.

public func isEqualToModule(_ module: OTPModule) -> Bool 

Parameters

  • module: The OTPModule to be compared against.

Returns

Whether these OTPModules are considered equal.

Clone this wiki locally