2026-01-26 18:56:53 +09:00

177 lines
10 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AuroraLaser.Trumpf.TruPulseNano
{
public partial class LaserDeviceTruPulseNano
{
public enum TrupulseNanoCommand
{
// Interface Control Commands
SetBaudRate = 0x10,
GetBaudRate = 0x11,
SetControlMode = 0x14,
GetControlMode = 0x15,
SetControlSignals = 0x1A,
GetControlSignals = 0x1B,
SetAnalogCurrentSetPoint = 0x1C,
GetAnalogSignals = 0x1D,
// Pulse Generator Commands
SetPulseWaveform = 0x20,
GetPulseWaveform = 0x21,
SetPulseRate = 0x22,
GetPulseRate = 0x23,
SetPulseBurstLength = 0x24,
GetPulseBurstLength = 0x25,
SetPumpDutyFactor = 0x26,
GetPumpDutyFactor = 0x27,
SetAllPulseGeneratorParameters = 0x2C,
GetAllPulseGeneratorParameters = 0x2D,
RestartPulseGenerator = 0x2F,
// Monitoring Commands
QueryStatusLinesAndAlarms = 0x50,
QueryLaserTemperatures = 0x51,
QueryLaserCurrents = 0x52,
QueryPowerSupplyVoltages = 0x53,
QueryHardwareInterface = 0x54,
QueryOperatingHours = 0x55,
QueryExternalPulseTriggerRepetitionRate = 0x56,
QueryExtendedLaserCurrents = 0x57,
// Diagnostics Commands
SetLaserIntoDiagnosisState = 0x60,
GetLaserSerialNumber = 0x62,
GetLaserPartNumber = 0x63,
GetLaserFirmwareDetails = 0x64,
GetLaserDescription = 0x65
}
public static readonly Dictionary<TrupulseNanoCommand, (int ArgumentCount, Type[] ArgumentTypes)> CommandArguments = new Dictionary<TrupulseNanoCommand, (int, Type[])>
{
// Interface Control Commands
{ TrupulseNanoCommand.SetBaudRate, (1, new Type[] { typeof(UInt32) }) },
{ TrupulseNanoCommand.GetBaudRate, (0, null) },
{ TrupulseNanoCommand.SetControlMode, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.GetControlMode, (0, null) },
{ TrupulseNanoCommand.SetControlSignals, (1, new Type[] { typeof(UInt16) }) },
{ TrupulseNanoCommand.GetControlSignals, (0, null) },
{ TrupulseNanoCommand.SetAnalogCurrentSetPoint, (2, new Type[] { typeof(UInt16), typeof(UInt16) }) },
{ TrupulseNanoCommand.GetAnalogSignals, (1, new Type[] { typeof(UInt16) }) },
// Pulse Generator Commands
{ TrupulseNanoCommand.SetPulseWaveform, (1, new Type[] { typeof(UInt16) }) },
{ TrupulseNanoCommand.GetPulseWaveform, (0, null) },
{ TrupulseNanoCommand.SetPulseRate, (1, new Type[] { typeof(UInt32) }) },
{ TrupulseNanoCommand.GetPulseRate, (0, null) },
{ TrupulseNanoCommand.SetPulseBurstLength, (1, new Type[] { typeof(UInt32) }) },
{ TrupulseNanoCommand.GetPulseBurstLength, (0, null) },
{ TrupulseNanoCommand.SetPumpDutyFactor, (1, new Type[] { typeof(UInt16) }) },
{ TrupulseNanoCommand.GetPumpDutyFactor, (0, null) },
{ TrupulseNanoCommand.SetAllPulseGeneratorParameters, (4, new Type[] { typeof(UInt16), typeof(UInt32), typeof(UInt32), typeof(UInt16) }) },
{ TrupulseNanoCommand.GetAllPulseGeneratorParameters, (1, new Type[] { typeof(UInt16) }) },
{ TrupulseNanoCommand.RestartPulseGenerator, (1, new Type[] { typeof(UInt16) }) },
// Monitoring Commands
{ TrupulseNanoCommand.QueryStatusLinesAndAlarms, (0, null) },
{ TrupulseNanoCommand.QueryLaserTemperatures, (0, null) },
{ TrupulseNanoCommand.QueryLaserCurrents, (0, null) },
{ TrupulseNanoCommand.QueryPowerSupplyVoltages, (0, null) },
{ TrupulseNanoCommand.QueryHardwareInterface, (0, null) },
{ TrupulseNanoCommand.QueryOperatingHours, (0, null) },
{ TrupulseNanoCommand.QueryExternalPulseTriggerRepetitionRate, (0, null) },
{ TrupulseNanoCommand.QueryExtendedLaserCurrents, (0, null) },
// Diagnostics Commands
{ TrupulseNanoCommand.SetLaserIntoDiagnosisState, (0, null) },
{ TrupulseNanoCommand.GetLaserSerialNumber, (0, null) },
{ TrupulseNanoCommand.GetLaserPartNumber, (0, null) },
{ TrupulseNanoCommand.GetLaserFirmwareDetails, (0, null) },
{ TrupulseNanoCommand.GetLaserDescription, (0, null) }
};
public static readonly Dictionary<TrupulseNanoCommand, (int ArgumentCount, Type[] ArgumentTypes)> ResponseArguments = new Dictionary<TrupulseNanoCommand, (int, Type[])>
{
// Interface Control Commands
{ TrupulseNanoCommand.SetBaudRate, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.GetBaudRate, (1, new Type[] { typeof(UInt32) }) },
{ TrupulseNanoCommand.SetControlMode, (2, new Type[] { typeof(byte),typeof(byte) }) },
{ TrupulseNanoCommand.GetControlMode, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.SetControlSignals, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.GetControlSignals, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.SetAnalogCurrentSetPoint, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.GetAnalogSignals, (3, new Type[] { typeof(byte), typeof(byte), typeof(UInt16) }) },
// Pulse Generator Commands
{ TrupulseNanoCommand.SetPulseWaveform, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.GetPulseWaveform, (2, new Type[] { typeof(UInt16) ,typeof(UInt32) }) },
{ TrupulseNanoCommand.SetPulseRate, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.GetPulseRate, (1, new Type[] { typeof(UInt32) }) },
{ TrupulseNanoCommand.SetPulseBurstLength, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.GetPulseBurstLength, (1, new Type[] { typeof(UInt32) }) },
{ TrupulseNanoCommand.SetPumpDutyFactor, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.GetPumpDutyFactor, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.SetAllPulseGeneratorParameters, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.GetAllPulseGeneratorParameters, (8, new Type[] { typeof(UInt16), typeof(UInt16) ,typeof(UInt32) ,typeof(UInt32) ,typeof(UInt32) ,typeof(UInt16) }) },
{ TrupulseNanoCommand.RestartPulseGenerator, (1, new Type[] { typeof(byte) }) },
// Monitoring Commands
{ TrupulseNanoCommand.QueryStatusLinesAndAlarms, (-1,new Type[] {typeof(UInt16) }) },
{ TrupulseNanoCommand.QueryLaserTemperatures, (2, new Type[] { typeof(UInt16) ,typeof(UInt16) }) },
{ TrupulseNanoCommand.QueryLaserCurrents, (2, new Type[] { typeof(UInt16) ,typeof(UInt16) }) },
{ TrupulseNanoCommand.QueryPowerSupplyVoltages, (2, new Type[] { typeof(UInt16) ,typeof(UInt16) }) },
{ TrupulseNanoCommand.QueryHardwareInterface, (4, new Type[] { typeof(UInt16) ,typeof(UInt16), typeof(UInt16), typeof(UInt16) }) },
{ TrupulseNanoCommand.QueryOperatingHours, (1, new Type[] { typeof(UInt32) }) },
{ TrupulseNanoCommand.QueryExternalPulseTriggerRepetitionRate, (1, new Type[] { typeof(UInt32) }) },
{ TrupulseNanoCommand.QueryExtendedLaserCurrents, (4, new Type[] { typeof(UInt16), typeof(UInt16), typeof(UInt16), typeof(UInt16) }) },
// Diagnostics Commands
{ TrupulseNanoCommand.SetLaserIntoDiagnosisState, (1, new Type[] { typeof(byte) }) },
{ TrupulseNanoCommand.GetLaserSerialNumber, (1, new Type[] { typeof(UInt32) }) },
{ TrupulseNanoCommand.GetLaserPartNumber, (-1, new Type[] {typeof(byte) }) },
{ TrupulseNanoCommand.GetLaserFirmwareDetails, (6, new Type[] { typeof(UInt16), typeof(UInt16), typeof(UInt16), typeof(UInt16), typeof(UInt32), typeof(UInt16) }) },
{ TrupulseNanoCommand.GetLaserDescription, (4, new Type[] { typeof(UInt16), typeof(UInt16), typeof(UInt16), typeof(UInt32) }) },
};
public static readonly Dictionary<TrupulseNanoCommand, string[]> CommandArgumentDescriptions = new Dictionary<TrupulseNanoCommand, string[]>
{
{ TrupulseNanoCommand.SetBaudRate, new[] { "RS-232 baud rate (9600,19200,38400,57600,115200)" } },
{ TrupulseNanoCommand.SetControlMode, new[] { "Control Interface Mode (0 - 7)" } },
{ TrupulseNanoCommand.SetControlSignals, new[] { "Control Signals (0: Laser Enable, 1: Pilot Laser Enable , 2: CW Pulse)" } },
{ TrupulseNanoCommand.SetAnalogCurrentSetPoint, new[] { "Set Point (0: Active current, 1: Simmer current)", "Set Point 2 (0-1000)" } },
{ TrupulseNanoCommand.GetAnalogSignals, new[] { "Get Point (0: Active current, 1: Simmer current)"} },
{ TrupulseNanoCommand.SetPulseWaveform, new[] { "Pulse waveform (0-63)" } },
{ TrupulseNanoCommand.SetPulseRate, new[] { "Pulse rate (1000-1000000 : Pulsed Mode , 0-99 : CW Mode , 100-100000 : CW-M Mode )" } },
{ TrupulseNanoCommand.SetPulseBurstLength, new[] { "Pulse burst length (0-1000000, 0 = continuous)" } },
{ TrupulseNanoCommand.SetPumpDutyFactor, new[] { "Pump Modulation duty factor (0-1000)" } },
{ TrupulseNanoCommand.SetAllPulseGeneratorParameters, new[] { "Pulse waveform (0-63)", "Pulse rate (0-1000000)", "Pulse burst length (0-1000000)", "Pump duty factor (0-1000)" } },
{ TrupulseNanoCommand.GetAllPulseGeneratorParameters, new[] { "Pulse waveform (0-63)" } },
{ TrupulseNanoCommand.RestartPulseGenerator, new[] { "Waveform (0-63)" } },
};
public enum ResponseCheck
{
CommandNotSupported = 0,
Unused = 1,
UnknownCommand = 2,
StopByteError = 3,
ChecksumError = 4,
PayloadTooLong = 5,
Timeout = 6,
}
public enum CommandCheck
{
CommandNotRecognized = 0,
DataBytesTooSmall = 2,
DataBytesTooLarge = 3,
}
}
}