2026-06-05 13:44:39 +09:00

130 lines
5.3 KiB
C#

using Aurora.Api;
using Aurora.Api.Devices;
using Aurora.View;
using ILSOS_PrismaticGun.Process;
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace ILSOS_PrismaticGun.Settings
{
public enum eTeachingPosition
{
Load,
UnLoad,
SafetyPosition,
StageWeldingStartPos,
}
public enum ePLCEnableLimitPosition
{
LoadPositiveLimit, // + Limit
LoadNegativeLimit, // - Limit
UnloadPositiveLimit, // + Limit
UnloadNegativeLimit, // - Limit
}
public class TeachingPositionSetting : ISettingItem
{
public SettingPosition[] SettingPositions { get; set; } = new SettingPosition[Enum.GetValues(typeof(eStage)).Length * Enum.GetValues(typeof(eTeachingPosition)).Length];
public SettingPosition[] PLCEnablePosition { get; set; } = new SettingPosition[Enum.GetValues(typeof(eStage)).Length * Enum.GetValues(typeof(ePLCEnableLimitPosition)).Length];
public double RealCellExistRangeMinStageA { get; set; }
public double RealCellExistRangeMaxStageA { get; set; }
public double RealCellExistRangeMinStageB { get; set; }
public double RealCellExistRangeMaxStageB { get; set; }
public TeachingPositionSetting()
{
SettingPositions[0] = new SettingPosition(eStage.A, eTeachingPosition.Load);
SettingPositions[1] = new SettingPosition(eStage.A, eTeachingPosition.UnLoad);
SettingPositions[2] = new SettingPosition(eStage.A, eTeachingPosition.SafetyPosition);
SettingPositions[3] = new SettingPosition(eStage.A, eTeachingPosition.StageWeldingStartPos);
SettingPositions[4] = new SettingPosition(eStage.B, eTeachingPosition.Load);
SettingPositions[5] = new SettingPosition(eStage.B, eTeachingPosition.UnLoad);
SettingPositions[6] = new SettingPosition(eStage.B, eTeachingPosition.SafetyPosition);
SettingPositions[7] = new SettingPosition(eStage.B, eTeachingPosition.StageWeldingStartPos);
PLCEnablePosition[0] = new SettingPosition(eStage.A, ePLCEnableLimitPosition.LoadPositiveLimit);
PLCEnablePosition[1] = new SettingPosition(eStage.A, ePLCEnableLimitPosition.LoadNegativeLimit);
PLCEnablePosition[2] = new SettingPosition(eStage.A, ePLCEnableLimitPosition.UnloadPositiveLimit);
PLCEnablePosition[3] = new SettingPosition(eStage.A, ePLCEnableLimitPosition.UnloadNegativeLimit);
PLCEnablePosition[4] = new SettingPosition(eStage.B, ePLCEnableLimitPosition.LoadPositiveLimit);
PLCEnablePosition[5] = new SettingPosition(eStage.B, ePLCEnableLimitPosition.LoadNegativeLimit);
PLCEnablePosition[6] = new SettingPosition(eStage.B, ePLCEnableLimitPosition.UnloadPositiveLimit);
PLCEnablePosition[7] = new SettingPosition(eStage.B, ePLCEnableLimitPosition.UnloadNegativeLimit);
}
public SettingPosition Get(eStage stage, eTeachingPosition position)
{
int stageIndex = (int)stage;
int positionIndex = (int)position;
int totalPositionCount = Enum.GetValues(typeof(eTeachingPosition)).Length;
int index = stageIndex * totalPositionCount + positionIndex;
if (index < 0 || index >= SettingPositions.Length)
return null;
return SettingPositions[index];
}
public SettingPosition Get(eStage stage, ePLCEnableLimitPosition position)
{
int stageIndex = (int)stage;
int positionIndex = (int)position;
int totalPositionCount = Enum.GetValues(typeof(ePLCEnableLimitPosition)).Length;
int index = stageIndex * totalPositionCount + positionIndex;
if (index < 0 || index >= PLCEnablePosition.Length)
return null;
return PLCEnablePosition[index];
}
}
public class SettingPosition : NotifyPropertyChangedBase
{
public string Name { get => _Name; set => SetProperty(ref _Name, value); }
private string _Name;
public double AxisX { get => _AxisX; set => SetProperty(ref _AxisX, value); }
private double _AxisX = 0.0;
public double AxisY { get => _AxisY; set => SetProperty(ref _AxisY, value); }
private double _AxisY = 0.0;
public double AxisZ { get => _AxisZ; set => SetProperty(ref _AxisZ, value); }
private double _AxisZ = 0.0;
public SettingPosition(eStage stage, eTeachingPosition position)
{
Name = $"Stage{Enum.GetName(typeof(eStage), stage)}{Enum.GetName(typeof(eTeachingPosition), position)}";
AxisX = -999.0;
AxisY = -999.0;
AxisZ = -999.0;
}
public SettingPosition(eStage stage, ePLCEnableLimitPosition position)
{
Name = $"Stage{Enum.GetName(typeof(eStage), stage)}{Enum.GetName(typeof(eTeachingPosition), position)}";
AxisX = -999.0;
AxisY = -999.0;
AxisZ = -999.0;
}
public SettingPosition()
{
AxisX = -999.0;
AxisY = -999.0;
AxisZ = -999.0;
}
}
}