151 lines
5.1 KiB
C#
151 lines
5.1 KiB
C#
namespace Sick.SafetyScanners.DataStructures;
|
|
|
|
/// <summary>
|
|
/// Communication settings used to configure the SICK Safety Scanner
|
|
/// This structure is used with ChangeCommSettingsCommand to configure scanner parameters
|
|
/// </summary>
|
|
public sealed class CommSettings
|
|
{
|
|
/// <summary>
|
|
/// Gets or sets the channel number (0-3)
|
|
/// </summary>
|
|
public byte Channel { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the publishing frequency (publish every n-th scan)
|
|
/// Example: 1 = publish every scan, 2 = publish every 2nd scan (half frequency)
|
|
/// </summary>
|
|
public ushort PublishingFrequency { get; init; } = 1;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the interface type
|
|
/// 0: EFI-pro, 1: EtherNet/IP, 3: Profinet, 4: Non-safe Ethernet
|
|
/// </summary>
|
|
public InterfaceType EInterfaceType { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the start angle in radians
|
|
/// If start and end angles are equal, all angles are regarded
|
|
/// </summary>
|
|
public double StartAngle { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the end angle in radians
|
|
/// If start and end angles are equal, all angles are regarded
|
|
/// </summary>
|
|
public double EndAngle { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the enabled features as a bitset (ushort)
|
|
/// Use SensorDataFeatures constants or SensorDataFeatures.ToFeatureFlags() to set
|
|
/// </summary>
|
|
public ushort Features { get; init; } = SensorDataFeatures.All;
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether general system state feature is enabled
|
|
/// </summary>
|
|
public bool GeneralSystemStateEnabled { get; init; } = true;
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether derived settings feature is enabled
|
|
/// </summary>
|
|
public bool DerivedSettingsEnabled { get; init; } = true;
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether measurement data feature is enabled
|
|
/// </summary>
|
|
public bool MeasurementDataEnabled { get; init; } = true;
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether intrusion data feature is enabled
|
|
/// </summary>
|
|
public bool IntrusionDataEnabled { get; init; } = true;
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether application data feature is enabled
|
|
/// </summary>
|
|
public bool ApplicationDataEnabled { get; init; } = true;
|
|
|
|
/// <summary>
|
|
/// Gets or sets whether the channel is enabled
|
|
/// </summary>
|
|
public bool Enabled { get; init; } = true;
|
|
|
|
/// <summary>
|
|
/// Gets or sets the host UDP port (0 = auto-assign)
|
|
/// </summary>
|
|
public ushort HostUdpPort { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the host IP address as a string (e.g., "192.168.1.100")
|
|
/// </summary>
|
|
public string HostIp { get; init; } = "192.168.1.100";
|
|
|
|
/// <summary>
|
|
/// Creates a CommSettings with all features enabled
|
|
/// </summary>
|
|
public static CommSettings CreateDefault()
|
|
{
|
|
return new CommSettings
|
|
{
|
|
Channel = 0,
|
|
PublishingFrequency = 1,
|
|
EInterfaceType = InterfaceType.NonSafeEthernet,
|
|
StartAngle = 0.0,
|
|
EndAngle = 0.0, // Equal to start angle means all angles
|
|
Features = SensorDataFeatures.All,
|
|
GeneralSystemStateEnabled = true,
|
|
DerivedSettingsEnabled = true,
|
|
MeasurementDataEnabled = true,
|
|
IntrusionDataEnabled = true,
|
|
ApplicationDataEnabled = true,
|
|
Enabled = true,
|
|
HostUdpPort = 0,
|
|
HostIp = "192.168.1.100"
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates a CommSettings with custom feature flags
|
|
/// </summary>
|
|
public static CommSettings Create(
|
|
byte channel,
|
|
string hostIp,
|
|
ushort hostUdpPort,
|
|
bool generalSystemState = true,
|
|
bool derivedSettings = true,
|
|
bool measurementData = true,
|
|
bool intrusionData = true,
|
|
bool applicationData = true,
|
|
ushort publishingFrequency = 1,
|
|
double startAngle = 0.0,
|
|
double endAngle = 0.0,
|
|
InterfaceType interfaceType = InterfaceType.NonSafeEthernet,
|
|
bool enabled = true)
|
|
{
|
|
return new CommSettings
|
|
{
|
|
Channel = channel,
|
|
PublishingFrequency = publishingFrequency,
|
|
EInterfaceType = interfaceType,
|
|
StartAngle = startAngle,
|
|
EndAngle = endAngle,
|
|
Features = SensorDataFeatures.ToFeatureFlags(
|
|
generalSystemState,
|
|
derivedSettings,
|
|
measurementData,
|
|
intrusionData,
|
|
applicationData),
|
|
GeneralSystemStateEnabled = generalSystemState,
|
|
DerivedSettingsEnabled = derivedSettings,
|
|
MeasurementDataEnabled = measurementData,
|
|
IntrusionDataEnabled = intrusionData,
|
|
ApplicationDataEnabled = applicationData,
|
|
Enabled = enabled,
|
|
HostUdpPort = hostUdpPort,
|
|
HostIp = hostIp
|
|
};
|
|
}
|
|
}
|
|
|