Class LaserModule
Represents a Keyence marking laser.
Inheritance
Implements
Inherited Members
Namespace: Loehnert.Lisrt.Laser.Keyence
Assembly: Loehnert.Lisrt.Laser.Keyence.dll
Syntax
public class LaserModule : InitializableCompositeModule, ICompositeModule, ILisrtModule, IInitializable, INotifyPropertyChangedEx, INotifyPropertyChanged, IHasServiceView, IHasDeviceLabel
Remarks
Performance Improvement
To speed up modifying a program, open a program using the CreateJob(Int32, Int32) method and close it after modification using the EndJob(Int32) 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.
Declaration
public LaserModule(string name, ICommunication communication)
Parameters
Type | Name | Description |
---|---|---|
String | name | Module Name. |
ICommunication | communication | Instance of communication module. |
Properties
DefaultTimeout
Gets or sets default timeout in milliseconds.
Declaration
[Configuration(1000)]
public int DefaultTimeout { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
DeviceLabel
Gets or sets the label for the device.
Declaration
[Configuration("Keyence")]
public string DeviceLabel { get; set; }
Property Value
Type | Description |
---|---|
String |
DeviceState
Gets the device state.
Declaration
public DeviceState DeviceState { get; }
Property Value
Type | Description |
---|---|
DeviceState |
Errors
Gets the current errors.
Declaration
public IEnumerable<string> Errors { get; }
Property Value
Type | Description |
---|---|
IEnumerable<String> |
InstanceID
Gets or sets the ID for this instance.
Declaration
[Configuration(0)]
public int InstanceID { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
LastReceivedResponse
Gets last received response from laser.
Declaration
public string LastReceivedResponse { get; }
Property Value
Type | Description |
---|---|
String |
LastSentCommand
Gets last sent command.
Declaration
public string LastSentCommand { get; }
Property Value
Type | Description |
---|---|
String |
MarkingBuilderVersion
Gets or sets current Marking Builder Version.
Declaration
[Configuration(MarkingBuilderVersion.MB3)]
public MarkingBuilderVersion MarkingBuilderVersion { get; set; }
Property Value
Type | Description |
---|---|
MarkingBuilderVersion |
Methods
ClearError()
Clears error memory on laser and updates error state collection afterwards.
Declaration
public void ClearError()
Exceptions
Type | Condition |
---|---|
NotInitializedException | Throw when the module is not initialized. |
LaserException | Thrown when the marking laser returns an error. |
CreateJob(Int32, Int32)
Opens a program for creation or modification.
Declaration
public void CreateJob(int programNumber, int timeoutInMs = 1000)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | programNumber | Number of program to create or modify. |
System.Int32 | timeoutInMs | Timespan in milliseconds after which an exception is thrown when device does not return an answer. |
Exceptions
Type | Condition |
---|---|
NotInitializedException | Throw when the module is not initialized. |
LaserException | Thrown when the marking laser returns an error. |
EndJob(Int32)
Ends creation or modification of a program.
Declaration
public void EndJob(int timeoutInMs = 1000)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutInMs | Timespan in milliseconds after which an exception is thrown when device does not return an answer. |
Exceptions
Type | Condition |
---|---|
NotInitializedException | Throw when the module is not initialized. |
LaserException | Thrown when the marking laser returns an error. |
Initialize()
Initializes laser module.
Declaration
public override void Initialize()
Overrides
Read2DCode(Read2DCodeParameters, Int32)
Reads a 2D code.
Declaration
public Read2DCodeResult Read2DCode(Read2DCodeParameters writeValues, int timeoutInMs = 1000)
Parameters
Type | Name | Description |
---|---|---|
Read2DCodeParameters | writeValues | Code read settings. |
System.Int32 | timeoutInMs | Timespan in milliseconds after which an exception is thrown when device does not return an answer. |
Returns
Type | Description |
---|---|
Read2DCodeResult | return values of scan operation depending on marking builder version. |
Exceptions
Type | Condition |
---|---|
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.
Declaration
public CameraImageSettings ReadCameraImageSetting(Targets targets)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Target parameters for communication. |
Returns
Type | Description |
---|---|
CameraImageSettings | Settings read from laser. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when any argument is null. |
System.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.
Declaration
public string ReadCharacterString(Targets targets)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Target parameters for communication. |
Returns
Type | Description |
---|---|
String | Last marked character string. |
Exceptions
Type | Condition |
---|---|
System.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.
Declaration
public CodeReaderLightSettings ReadCodeReaderLightSetting(Targets targets)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Targets. |
Returns
Type | Description |
---|---|
CodeReaderLightSettings | Parameters read from laser. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when any argument is null. |
System.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.
Declaration
public CodeReaderSettings ReadCodeReaderSetting(Targets targets)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Target parameters for communication. |
Returns
Type | Description |
---|---|
CodeReaderSettings | parameters read from laser. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when any argument is null. |
System.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.
Declaration
public CounterValues ReadCounter(Targets targets)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | target parameters for communication. |
Returns
Type | Description |
---|---|
CounterValues | parameters read from laser. |
Exceptions
Type | Condition |
---|---|
System.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.
Declaration
public GroupOffset ReadGroupOffset(Targets targets)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Target the group is belonging to. See GroupNumber. |
Returns
Type | Description |
---|---|
GroupOffset | The offset of a group. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when any argument is null. |
ReadLastCodeResult(Int32)
Reads 2D-Code from Laser with marking builder version MBPLUS.
Declaration
public Read2DCodeResult ReadLastCodeResult(int timeoutInMS = 1000)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutInMS | Timespan in milliseconds after which an exception is thrown when device does not return an answer. |
Returns
Type | Description |
---|---|
Read2DCodeResult | results of last scan operation. |
Exceptions
Type | Condition |
---|---|
NotInitializedException | Throw when the module is not initialized. |
LaserException | Thrown when the marking laser returns an error. |
ReadLastWindowCheckAfterMarkingResult(Int32)
Reads the last window check after marking result. Requires marking builder version MBPLUS.
Declaration
public WindowCheckResult ReadLastWindowCheckAfterMarkingResult(int timeoutInMS = 1000)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutInMS | Timespan in milliseconds after which an exception is thrown when device does not return an answer. |
Returns
Type | Description |
---|---|
WindowCheckResult | results of last window check. |
Exceptions
Type | Condition |
---|---|
System.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.
Declaration
public MarkingConfirmationResult ReadMarkingConfirmationResult()
Returns
Type | Description |
---|---|
MarkingConfirmationResult | The result of the last marking confirmation. |
ReadOnTheFlyParameters(Targets)
Reads OnTheFly settings from Laser.
Declaration
public OnTheFlySettings ReadOnTheFlyParameters(Targets targets)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Target parameters for communication. |
Returns
Type | Description |
---|---|
OnTheFlySettings | Parameters read from laser. |
Exceptions
Type | Condition |
---|---|
System.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.
Declaration
public int ReadProgramNumber()
Returns
Type | Description |
---|---|
System.Int32 | parameters read from laser. |
Exceptions
Type | Condition |
---|---|
System.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.
Declaration
public int ReadWindowCheckAfterMarkingAlarmThreshold(Targets targets)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | laser targets. |
Returns
Type | Description |
---|---|
System.Int32 | Alarm threshold in percent. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.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.
Declaration
public void ShowServiceView()
StartMarking(Int32)
Starts the loaded program.
Declaration
public void StartMarking(int timeoutInMs = 1000)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | timeoutInMs | Timespan in milliseconds after which an exception is thrown when device does not return an answer. |
Exceptions
Type | Condition |
---|---|
NotInitializedException | Throw when the module is not initialized. |
LaserException | Thrown when the marking laser returns an error. |
StopMarking()
Stops a running marking operation.
Declaration
public void StopMarking()
Exceptions
Type | Condition |
---|---|
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.
Declaration
public void UpdateDeviceState()
Exceptions
Type | Condition |
---|---|
NotInitializedException | Throw when the module is not initialized. |
LaserException | Thrown when the marking laser returns an error. |
UpdateErrorState()
Updates the Errors.
Declaration
public void UpdateErrorState()
Exceptions
Type | Condition |
---|---|
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.
Declaration
public void WriteCameraImageSetting(Targets targets, CameraImageSettings writeValues)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | target parameters for communication. |
CameraImageSettings | writeValues | settings to be written to laser. |
Exceptions
Type | Condition |
---|---|
System.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.
Declaration
public void WriteCharacterString(Targets targets, string markingCharacters)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Targets for marking. |
String | markingCharacters | 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
Type | Condition |
---|---|
System.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.
Declaration
public void WriteCodeReaderSetting(Targets targets, CodeReaderSettings writeValues)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Target parameters for communication. |
CodeReaderSettings | writeValues | parameters to be written to laser. |
Exceptions
Type | Condition |
---|---|
System.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.
Declaration
public void WriteCounter(Targets targets, CounterValues writeValues)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Target parameters for communication. |
CounterValues | writeValues | parameters to be written to laser. |
Exceptions
Type | Condition |
---|---|
System.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.
Declaration
public void WriteGroupOffset(Targets targets, GroupOffset groupOffset)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Target the group is belonging to. See GroupNumber. |
GroupOffset | groupOffset | Offset to set. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when any argument is null. |
WriteOnTheFlyParameters(Targets, OnTheFlySettings)
Writes OnTheFly settings to Laser.
Declaration
public void WriteOnTheFlyParameters(Targets targets, OnTheFlySettings writeValues)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Target parameters for communication. |
OnTheFlySettings | writeValues | OnTheFly parameters to be written to laser. |
Exceptions
Type | Condition |
---|---|
System.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(Int32)
Writes new program number to laser.
Declaration
public void WriteProgramNumber(int programNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | programNumber | New program number. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when any argument is null. |
WriteWindowCheckAfterMarkingAlarmThreshold(Targets, Int32)
Writes alarm threshold value for window check to laser.
Declaration
public void WriteWindowCheckAfterMarkingAlarmThreshold(Targets targets, int alarmThreshold)
Parameters
Type | Name | Description |
---|---|---|
Targets | targets | Laser targets. |
System.Int32 | alarmThreshold | Alarm threshold in percent. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
ArgumentOutOfRangeException | Throw when |
System.NotSupportedException | Thrown when the MarkingBuilderVersion is MB3. |
NotInitializedException | Throw when the module is not initialized. |
LaserException | Thrown when the marking laser returns an error. |