Table of Contents

Class LaserModule

Namespace
Loehnert.Lisrt.Laser.Keyence
Assembly
Loehnert.Lisrt.Laser.Keyence.dll

Represents a Keyence marking laser.

public class LaserModule : InitializableCompositeModule, ICompositeModule, ILisrtModule, IInitializable, INotifyPropertyChangedEx, INotifyPropertyChanged, IHasServiceView, IHasDeviceLabel
Inheritance
PropertyChangedBase
LaserModule
Implements
INotifyPropertyChangedEx
Inherited Members
PropertyChangedBase.Refresh()
PropertyChangedBase.IsNotifying
PropertyChangedBase.PropertyChanged

Remarks

Performance Improvement

To speed up modifying a program, open a program using the CreateJob(int, int) method and close it after modification using the EndJob(int) method. This means that the program only has to be verified once, and not with every change.

Constructors

LaserModule(string, ICommunication)

Initializes a new instance of the LaserModule class.

public LaserModule(string name, ICommunication communication)

Parameters

name string

Module Name.

communication ICommunication

Instance of communication module.

Properties

DefaultTimeout

Gets or sets default timeout in milliseconds.

[Configuration(1000)]
public int DefaultTimeout { get; set; }

Property Value

int

DeviceLabel

Gets or sets the label for the device.

[Configuration("Keyence")]
public string DeviceLabel { get; set; }

Property Value

string

DeviceState

Gets the device state.

public DeviceState DeviceState { get; }

Property Value

DeviceState

Errors

Gets the current errors.

public IEnumerable<string> Errors { get; }

Property Value

IEnumerable<string>

InstanceID

Gets or sets the ID for this instance.

[Configuration(0)]
public int InstanceID { get; set; }

Property Value

int

LastReceivedResponse

Gets last received response from laser.

public string LastReceivedResponse { get; }

Property Value

string

LastSentCommand

Gets last sent command.

public string LastSentCommand { get; }

Property Value

string

MarkingBuilderVersion

Gets or sets current Marking Builder Version.

[Configuration(MarkingBuilderVersion.MB3)]
public MarkingBuilderVersion MarkingBuilderVersion { get; set; }

Property Value

MarkingBuilderVersion

Methods

ClearError()

Clears error memory on laser and updates error state collection afterwards.

public void ClearError()

Exceptions

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

CreateJob(int, int)

Opens a program for creation or modification.

public void CreateJob(int programNumber, int timeoutInMs = 1000)

Parameters

programNumber int

Number of program to create or modify.

timeoutInMs int

Timespan in milliseconds after which an exception is thrown when device does not return an answer.

Exceptions

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

EndJob(int)

Ends creation or modification of a program.

public void EndJob(int timeoutInMs = 1000)

Parameters

timeoutInMs int

Timespan in milliseconds after which an exception is thrown when device does not return an answer.

Exceptions

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

Initialize()

Initializes laser module.

public override void Initialize()

Read2DCode(Read2DCodeParameters, int)

Reads a 2D code.

public Read2DCodeResult Read2DCode(Read2DCodeParameters writeValues, int timeoutInMs = 1000)

Parameters

writeValues Read2DCodeParameters

Code read settings.

timeoutInMs int

Timespan in milliseconds after which an exception is thrown when device does not return an answer.

Returns

Read2DCodeResult

return values of scan operation depending on marking builder version.

Exceptions

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ReadCameraImageSetting(Targets)

Reads the camera image settings from laser.

public CameraImageSettings ReadCameraImageSetting(Targets targets)

Parameters

targets Targets

Target parameters for communication.

Returns

CameraImageSettings

Settings read from laser.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotSupportedException

Thrown when the MarkingBuilderVersion property is MB3.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ReadCharacterString(Targets)

Reads last marked character string on laser.

public string ReadCharacterString(Targets targets)

Parameters

targets Targets

Target parameters for communication.

Returns

string

Last marked character string.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ReadCodeReaderLightSetting(Targets)

Reads the code reader lighting settings.

public CodeReaderLightSettings ReadCodeReaderLightSetting(Targets targets)

Parameters

targets Targets

Targets.

Returns

CodeReaderLightSettings

Parameters read from laser.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotSupportedException

Thrown when the MarkingBuilderVersion property is MB3.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ReadCodeReaderSetting(Targets)

Reads code reader settings from Laser.

public CodeReaderSettings ReadCodeReaderSetting(Targets targets)

Parameters

targets Targets

Target parameters for communication.

Returns

CodeReaderSettings

parameters read from laser.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotSupportedException

Thrown when the MarkingBuilderVersion property is MB3.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ReadCounter(Targets)

Read laser counter parameters from Laser.

public CounterValues ReadCounter(Targets targets)

Parameters

targets Targets

target parameters for communication.

Returns

CounterValues

parameters read from laser.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ReadGroupOffset(Targets)

Reads the offset of a group.

public GroupOffset ReadGroupOffset(Targets targets)

Parameters

targets Targets

Target the group is belonging to. See GroupNumber.

Returns

GroupOffset

The offset of a group.

Exceptions

ArgumentNullException

Thrown when any argument is null.

ReadLastCodeResult(int)

Reads 2D-Code from Laser with marking builder version MBPLUS.

public Read2DCodeResult ReadLastCodeResult(int timeoutInMS = 1000)

Parameters

timeoutInMS int

Timespan in milliseconds after which an exception is thrown when device does not return an answer.

Returns

Read2DCodeResult

results of last scan operation.

Exceptions

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ReadLastWindowCheckAfterMarkingResult(int)

Reads the last window check after marking result. Requires marking builder version MBPLUS.

public WindowCheckResult ReadLastWindowCheckAfterMarkingResult(int timeoutInMS = 1000)

Parameters

timeoutInMS int

Timespan in milliseconds after which an exception is thrown when device does not return an answer.

Returns

WindowCheckResult

results of last window check.

Exceptions

NotSupportedException

Thrown when the MarkingBuilderVersion is MB3.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ReadMarkingConfirmationResult()

Reads the last marking confirmation result.

public MarkingConfirmationResult ReadMarkingConfirmationResult()

Returns

MarkingConfirmationResult

The result of the last marking confirmation.

ReadOnTheFlyParameters(Targets)

Reads OnTheFly settings from Laser.

public OnTheFlySettings ReadOnTheFlyParameters(Targets targets)

Parameters

targets Targets

Target parameters for communication.

Returns

OnTheFlySettings

Parameters read from laser.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ReadProgramNumber()

Reads loaded program number from laser.

public int ReadProgramNumber()

Returns

int

parameters read from laser.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ReadWindowCheckAfterMarkingAlarmThreshold(Targets)

Reads the alarm threshold value for window check with marking builder version MBPLUS.

public int ReadWindowCheckAfterMarkingAlarmThreshold(Targets targets)

Parameters

targets Targets

laser targets.

Returns

int

Alarm threshold in percent.

Exceptions

ArgumentNullException

Thrown when targets is null.

NotSupportedException

Thrown when the MarkingBuilderVersion is MB3.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

ShowServiceView()

Shows the service window.

public void ShowServiceView()

StartMarking(int)

Starts the loaded program.

public void StartMarking(int timeoutInMs = 1000)

Parameters

timeoutInMs int

Timespan in milliseconds after which an exception is thrown when device does not return an answer.

Exceptions

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

StopMarking()

Stops a running marking operation.

public void StopMarking()

Exceptions

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

UpdateDeviceState()

Updates device state Properties and error state collection afterwards.

public void UpdateDeviceState()

Exceptions

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

UpdateErrorState()

Updates the Errors.

public void UpdateErrorState()

Exceptions

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

WriteCameraImageSetting(Targets, CameraImageSettings)

Writes camera image settings to Laser.

public void WriteCameraImageSetting(Targets targets, CameraImageSettings writeValues)

Parameters

targets Targets

target parameters for communication.

writeValues CameraImageSettings

settings to be written to laser.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

WriteCharacterString(Targets, string)

Writes the marking string to the laser.

public void WriteCharacterString(Targets targets, string markingCharacters)

Parameters

targets Targets

Targets for marking.

markingCharacters string

Marking characters.

Remarks

  • This command can be sent to a block No. having the block type (BlockType) of “-4: Hatch logo/-3: Photo/-2: Workpiece image/-1: Logo/00: Horizontal characters/01: Vertical characters/02: Arc clockwise/03: Arc counterclockwise/09: Barcode/2D Code”.
  • To send a “, (comma)” as a string, send it in the form of “%044A” (ASCII).
  • To send a “%” as a string, send it in the form of “%%” (ASCII).

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

WriteCodeReaderSetting(Targets, CodeReaderSettings)

Writes code reader settings to Laser.

public void WriteCodeReaderSetting(Targets targets, CodeReaderSettings writeValues)

Parameters

targets Targets

Target parameters for communication.

writeValues CodeReaderSettings

parameters to be written to laser.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

WriteCounter(Targets, CounterValues)

Write counter settings to laser.

public void WriteCounter(Targets targets, CounterValues writeValues)

Parameters

targets Targets

Target parameters for communication.

writeValues CounterValues

parameters to be written to laser.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

WriteGroupOffset(Targets, GroupOffset)

Sets the offset of a group.

public void WriteGroupOffset(Targets targets, GroupOffset groupOffset)

Parameters

targets Targets

Target the group is belonging to. See GroupNumber.

groupOffset GroupOffset

Offset to set.

Exceptions

ArgumentNullException

Thrown when any argument is null.

WriteOnTheFlyParameters(Targets, OnTheFlySettings)

Writes OnTheFly settings to Laser.

public void WriteOnTheFlyParameters(Targets targets, OnTheFlySettings writeValues)

Parameters

targets Targets

Target parameters for communication.

writeValues OnTheFlySettings

OnTheFly parameters to be written to laser.

Exceptions

ArgumentNullException

Thrown when any argument is null.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.

WriteProgramNumber(int)

Writes new program number to laser.

public void WriteProgramNumber(int programNumber)

Parameters

programNumber int

New program number.

Exceptions

ArgumentNullException

Thrown when any argument is null.

WriteWindowCheckAfterMarkingAlarmThreshold(Targets, int)

Writes alarm threshold value for window check to laser.

public void WriteWindowCheckAfterMarkingAlarmThreshold(Targets targets, int alarmThreshold)

Parameters

targets Targets

Laser targets.

alarmThreshold int

Alarm threshold in percent.

Exceptions

ArgumentNullException

Thrown when targets is null.

ArgumentOutOfRangeException

Throw when alarmThreshold is less than 0 or greater than 100.

NotSupportedException

Thrown when the MarkingBuilderVersion is MB3.

NotInitializedException

Throw when the module is not initialized.

LaserException

Thrown when the marking laser returns an error.