diff --git a/Machines/ILSOS_PrismaticScanner/EquipDef.cs b/Machines/ILSOS_PrismaticScanner/EquipDef.cs index 773b02a..1d16b4e 100644 --- a/Machines/ILSOS_PrismaticScanner/EquipDef.cs +++ b/Machines/ILSOS_PrismaticScanner/EquipDef.cs @@ -9,7 +9,28 @@ namespace ILSOS_PrismaticScanner internal class DeviceIds : CommonDeviceIds { public const string MassFlowMeter = "MassFlowMeter"; + + // 26.04.06 + public const string ACS = "ACS"; } + // 추가 26.04.06 + internal class MotorIds + { + public const string AxisX2 = "AxisX2"; + public const string AxisY1 = "AxisY1"; + public const string AxisY2 = "AxisY2"; + public const string AxisZ = "AxisZ"; + + // TODO: 이정인 선임 ACS 변수 맵 수신 후 실제 번호 검증 + public enum eMotorIdx + { + AxisX2 = 1, + AxisY1 = 3, + AxisY2 = 4, + AxisZ = 5, + } + } + internal class SequenceIds : CommonSequenceIds { public const string SeqStreamTest = "SeqStreamTest"; diff --git a/Machines/ILSOS_PrismaticScanner/EquipmentSetup.cs b/Machines/ILSOS_PrismaticScanner/EquipmentSetup.cs index 3ccec21..606ebfe 100644 --- a/Machines/ILSOS_PrismaticScanner/EquipmentSetup.cs +++ b/Machines/ILSOS_PrismaticScanner/EquipmentSetup.cs @@ -39,6 +39,7 @@ using System.Windows.Controls; using System.Windows.Threading; using WeldingCommon; using WeldingCommon.Alarm; +using WeldingCommon.Devices.ACS; using WeldingCommon.Recipes; using WeldingCommon.Sequences; using WeldingCommon.Settings; @@ -49,6 +50,12 @@ using WeldingCommon.Views.Recipes.History; using WeldingCommon.Vision.Factory; using static WeldingCommon.Vision.Factory.VisionFactory; +// 26.04.06 +using AuroraACS; +using AuroraACS.Views; +using AuroraMotor; + + namespace ILSOS_PrismaticScanner { internal class EquipmentSetup : CommonEquipmentSetup, IEquipmentSetup @@ -153,6 +160,33 @@ namespace ILSOS_PrismaticScanner AlarmManager.Init(AuroraEnv); + #region Common에 있는 Device를 등록한다. 26.04.06 + // ↓ ACS 등록 추가 + var ACS = new ScannerACS(isSimul); + registry.Register(DeviceIds.ACS, () => ACS, new ACSDeviceConfig()); + + // TODO: 축 번호는 이정인 선임 변수 맵 수신 후 검증 + var motorX2 = new ACSMotor(MotorIds.AxisX2, ACS, 1, (int)MotorIds.eMotorIdx.AxisX2); + registry.Register(MotorIds.AxisX2, () => motorX2, + new ACSMotorConfig(MotorIds.AxisX2), + motor => new UCACSMotor(AuroraEnv.DeviceManager, motor.DeviceId)); + + var motorY1 = new ACSMotor(MotorIds.AxisY1, ACS, 3, (int)MotorIds.eMotorIdx.AxisY1); + registry.Register(MotorIds.AxisY1, () => motorY1, + new ACSMotorConfig(MotorIds.AxisY1), + motor => new UCACSMotor(AuroraEnv.DeviceManager, motor.DeviceId)); + + var motorY2 = new ACSMotor(MotorIds.AxisY2, ACS, 4, (int)MotorIds.eMotorIdx.AxisY2); + registry.Register(MotorIds.AxisY2, () => motorY2, + new ACSMotorConfig(MotorIds.AxisY2), + motor => new UCACSMotor(AuroraEnv.DeviceManager, motor.DeviceId)); + + var motorZ = new ACSMotor(MotorIds.AxisZ, ACS, 5, (int)MotorIds.eMotorIdx.AxisZ); + registry.Register(MotorIds.AxisZ, () => motorZ, + new ACSMotorConfig(MotorIds.AxisZ), + motor => new UCACSMotor(AuroraEnv.DeviceManager, motor.DeviceId)); + #endregion + } public override void RegisterRecipes(RecipeRegister register) diff --git a/Machines/ILSOS_PrismaticScanner/ILSOS_PrismaticScanner.csproj b/Machines/ILSOS_PrismaticScanner/ILSOS_PrismaticScanner.csproj index 517045a..d332e46 100644 --- a/Machines/ILSOS_PrismaticScanner/ILSOS_PrismaticScanner.csproj +++ b/Machines/ILSOS_PrismaticScanner/ILSOS_PrismaticScanner.csproj @@ -161,6 +161,10 @@ + + {6eea4c41-a833-41b8-a9d2-512f45e6beca} + AuroraACS + {c376d692-d3a2-44ea-bd2d-dedde648d587} AuroraCellTracker @@ -189,6 +193,10 @@ {858130f6-44a8-4b73-bd6e-0ed1aef4c0f4} AuroraLight + + {49a61fb7-ec36-4035-b7bc-63ab983590b4} + AuroraMotor + {21b083eb-97d6-49b3-acc4-c94c0fbfc999} AuroraOCT diff --git a/WeldingComponents/WeldingCommon/CommonEquipmentSetup.cs b/WeldingComponents/WeldingCommon/CommonEquipmentSetup.cs index 9402755..8731c1b 100644 --- a/WeldingComponents/WeldingCommon/CommonEquipmentSetup.cs +++ b/WeldingComponents/WeldingCommon/CommonEquipmentSetup.cs @@ -1,6 +1,8 @@  using Aurora; using Aurora.Api; +// 추가 - Aurora.Api.Device 명시 +using AuroraDevice = Aurora.Api.Device; using Aurora.Api.Manager; using Aurora.View; @@ -28,6 +30,8 @@ using WeldingCommon.Views; using WeldingCommon.Views.DoorInterlock; using WeldingCommon.Vision.Factory; + + namespace WeldingCommon { public abstract class CommonEquipmentSetup @@ -137,7 +141,7 @@ namespace WeldingCommon await System.Threading.Tasks.Task.Run(() => { try { var devices = AuroraEnv.DeviceManager.GetDevices(); - foreach (var device in devices) { + foreach (Aurora.Api.Device device in devices) { if (device.IsAutoActivation()) { if (device.Activate() != E1.OK) { Log.E($"{device.DeviceId} connect fail."); diff --git a/WeldingComponents/WeldingCommon/Devices/ACS/MotionVariable.cs b/WeldingComponents/WeldingCommon/Devices/ACS/MotionVariable.cs new file mode 100644 index 0000000..4811bf9 --- /dev/null +++ b/WeldingComponents/WeldingCommon/Devices/ACS/MotionVariable.cs @@ -0,0 +1,64 @@ +using Aurora.View; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WeldingCommon.Device.ACS +{ + public class MotionVariable : NotifyPropertyChangedBase + { + public MotionVariable() { } + //private eStage Stage { get; set; } + //public double X1AxisPosition { get; set; } = 0.0; + //public bool X1InPosition { get; set; } = false; + //public double X1AxisVelocity { get; set; } = 0.0; + //public double X1AxisAcceleration { get; set; } = 0.0; + + public double X2AxisPosition { get; set; } = 0.0; + public bool X2InPosition { get; set; } = false; + public double X2AxisVelocity { get; set; } = 0.0; + public double X2AxisAcceleration { get; set; } = 0.0; + + public double Y1AxisPosition { get; set; } = 0.0; + public bool Y1InPosition { get; set; } = false; + public double Y1AxisVelocity { get; set; } = 0.0; + public double Y1AxisAcceleration { get; set; } = 0.0; + + public double Y2AxisPosition { get; set; } = 0.0; + public bool Y2InPosition { get; set; } = false; + public double Y2AxisVelocity { get; set; } = 0.0; + public double Y2AxisAcceleration { get; set; } = 0.0; + + public double ZAxisPosition { get; set; } = 0.0; + public bool ZInPosition { get; set; } = false; + public double ZAxisVelocity { get; set; } = 0.0; + public double ZAxisAcceleration { get; set; } = 0.0; + + public bool IsHome { get; set; } = false; + + public bool IsLoadPosition { get; set; } = false; + public bool IsUnloadPosition { get; set; } = false; + public bool IsSafetyPosition { get; set; } = false; + public bool IsWeldingStartPosition { get; set; } = false; + + public bool IsLoadEnable { get; set; } = false; + public bool IsUnloadEnable { get; set; } = false; + + } + + //public class MotionVariableCollection : ObservableCollection + //{ + // public MotionVariableCollection() + // { + // } + // public MotionVariableCollection(IEnumerable collection) : base(collection) + // { + // } + // public MotionVariableCollection(List list) : base(list) + // { + // } + //} +} diff --git a/WeldingComponents/WeldingCommon/Devices/ACS/PrismaticGunACS.Parameter.cs b/WeldingComponents/WeldingCommon/Devices/ACS/PrismaticGunACS.Parameter.cs new file mode 100644 index 0000000..8d0cd77 --- /dev/null +++ b/WeldingComponents/WeldingCommon/Devices/ACS/PrismaticGunACS.Parameter.cs @@ -0,0 +1,38 @@ +// WeldingCommon/Devices/ACS/ScannerACS.Parameter.cs +namespace WeldingCommon.Devices.ACS +{ + public partial class ScannerACS + { + // ── 알람 ────────────────────────────────────────── + const string AlarmReset = "iAlarmreset"; + const string HeavyAlarm = "iAlarm"; + const string LightAlarm = "iLightAlarm"; + const string AlarmCodes = "iPCAlarmNo"; + + // ── 홈 ─────────────────────────────────────────── + const string iAllAxisHomeComplete = "iPCget_ALLAXIS_HOMECOMP"; + + // ── MOTF (Mark On The Fly) ──────────────────────── + // TODO: 이정인 선임 ACS 변수 맵 수신 후 실제 변수명으로 교체 + const string iMOTFStart = "iPCset_SCANNER_MOTF_START"; // placeholder + const string iMOTFComplete = "iPCget_SCANNER_MOTF_COMP"; // placeholder + const string rMOTFVelocity = "rPCset_SCANNER_MOTF_VEL"; // placeholder + const string rMOTFAcc = "rPCset_SCANNER_MOTF_ACC"; // placeholder + + // ── 레이저 ─────────────────────────────────────── + const string IsLaserOn = "LCI_DEVICE.LaserEnabled"; + const string iLaserUse = "iPCset_LASER_USE"; + + // ── 축 번호 ────────────────────────────────────── + const string iXAxisNumber = "iPCget_LCI_ASMASK_X"; + + // ── 버퍼 ───────────────────────────────────────── + private enum eBuffer + { + All_Axis_Home = 0, + + // TODO: Scanner MOTF 버퍼 번호 확인 후 수정 + MOTF_Start = 11, + } + } +} \ No newline at end of file diff --git a/WeldingComponents/WeldingCommon/Devices/ACS/PrismaticGunACS.cs b/WeldingComponents/WeldingCommon/Devices/ACS/PrismaticGunACS.cs new file mode 100644 index 0000000..e863057 --- /dev/null +++ b/WeldingComponents/WeldingCommon/Devices/ACS/PrismaticGunACS.cs @@ -0,0 +1,185 @@ +// WeldingCommon/Devices/ACS/ScannerACS.cs +using Aurora; +using Aurora.Api; +using Aurora.Api.Devices; +using Aurora.Util.HislogPlus; +using AuroraACS; +using ACS.SPiiPlusNET; +using Hermes; +using System.Windows; +using WeldingCommon.Device.ACS; +using WeldingCommon.Settings; + +namespace WeldingCommon.Devices.ACS +{ + public interface IScannerACS + { + bool IsActivated(); + + // 홈 + bool AllAxisHomeStart(); + bool AllAxisHomeStop(); + bool CheckAllAxisHome(); + + // MOTF + bool MOTFStart(); + bool MOTFStop(); + bool CheckMOTFComp(); + + // 레이저 + bool SetLaserIOUse(bool on); + bool IsLaserOn(); + + // 알람 + bool ResetAlarm(); + void AllAxisServoOff(); + } + + public partial class ScannerACS : ACSDevice, IScannerACS + { + // TODO: Scanner용 Setting ID 확정 후 교체 + private ACSDeviceSetting _setting; + private ACSMotor MotorStageX; // AxisX2 = Scanner Stage X + + public MotionVariable _motorVariable; + + public bool HasHeavyAlarm { get; private set; } + public bool HasLightAlarm { get; private set; } + public int[] HaveAlarmCodes { get => _HaveAlarmCodes; } + private int[] _HaveAlarmCodes = new int[11]; + + public ScannerACS(bool isSimulation, bool useTerminateUMD = false) + : base(isSimulation, useTerminateUMD) + { + _motorVariable = new MotionVariable(); + } + + protected override int DoActivate(IDeviceConfig config) + { + if (base.DoActivate(config) != E1.OK) + return E2.ABORTED; + + var env = Application.Current.AuroraEnv(); + + // TODO: Scanner용 SettingIds 확정 후 교체 + // _setting = env.SettingEntry[ScannerSettingIds.ACS] as ACSDeviceSetting; + + // Stage X 모터 취득 (null-safe) + // TODO: 이정인 선임 변수 맵 수신 후 축 번호 검증 + try { MotorStageX = env.DeviceManager[CommonDeviceIds.AxisX2] as ACSMotor; } + catch { MotorStageX = null; } + + SetMonitoringService(UpdateACSParam, 50); + StartMonitoringService(); + + return E1.OK; + } + + private void UpdateACSParam() + { + // Stage X 상태 갱신 + if (MotorStageX != null) + { + _motorVariable.X2AxisPosition = MotorStageX.GetActualPos(); + _motorVariable.X2InPosition = MotorStageX.IsInpos(); + _motorVariable.X2AxisVelocity = MotorStageX.GetFeedbackVelocity(); + _motorVariable.X2AxisAcceleration = MotorStageX.GetAcceleration(); + _motorVariable.IsHome = MotorStageX.GetServoStatus() == 1; + } + + // 알람 상태 갱신 + HasHeavyAlarm = ReadVariableInt(HeavyAlarm) == 1; + HasLightAlarm = ReadVariableInt(LightAlarm) == 1; + ReadVariableIntArrRef(AlarmCodes, ref _HaveAlarmCodes, + ProgramBuffer.ACSC_NONE, 0, 10); + } + + protected override int DoDeactivate() + { + StopMonitoringService(); + return base.DoDeactivate(); + } + + // ── 홈 ─────────────────────────────────────────── + bool IScannerACS.AllAxisHomeStart() + { + if (RunBuffer((ProgramBuffer)eBuffer.All_Axis_Home)) + { + Log.D("AllAxisHomeStart >> Complete"); + return true; + } + Log.D("AllAxisHomeStart >> Fail"); + return false; + } + + bool IScannerACS.AllAxisHomeStop() + { + StopBuffer((ProgramBuffer)eBuffer.All_Axis_Home); + Log.D("AllAxisHomeStop >> Complete"); + return true; + } + + bool IScannerACS.CheckAllAxisHome() + => ReadVariableInt(iAllAxisHomeComplete) > 0; + + // ── MOTF ───────────────────────────────────────── + // TODO: 이정인 선임 변수 맵 수신 후 버퍼 번호 및 변수명 교체 + bool IScannerACS.MOTFStart() + { + if (IsSimul) return true; + if (RunBuffer((ProgramBuffer)eBuffer.MOTF_Start)) + { + Log.I("MOTFStart >> Complete"); + return true; + } + Log.D("MOTFStart >> Fail"); + return false; + } + + bool IScannerACS.MOTFStop() + { + StopBuffer((ProgramBuffer)eBuffer.MOTF_Start); + Log.D("MOTFStop >> Complete"); + return true; + } + + bool IScannerACS.CheckMOTFComp() + { + if (IsSimul) return true; + return ReadVariableInt(iMOTFComplete) > 0; + } + + // ── 레이저 ─────────────────────────────────────── + bool IScannerACS.SetLaserIOUse(bool on) + { + if (WriteRealVariable(iLaserUse, on ? 1 : 0)) + { + Log.D($"SetLaserIOUse {on} >> Complete"); + return true; + } + Log.D("SetLaserIOUse >> Fail"); + return false; + } + + bool IScannerACS.IsLaserOn() + { + if (!IsActivated || !IsConnected) return false; + return ReadVariableInt(IsLaserOn) > 0; + } + + // ── 알람 ───────────────────────────────────────── + bool IScannerACS.ResetAlarm() + { + TerminalCommand("FCLEAR ALL"); + return WriteVariableInt(AlarmReset, 1); + } + + void IScannerACS.AllAxisServoOff() + { + if (!IsActivated || !IsConnected) return; + SetMotorDisableAll(); + } + + bool IScannerACS.IsActivated() => IsActivated; + } +} \ No newline at end of file diff --git a/WeldingComponents/WeldingCommon/EquipDefCommon.cs b/WeldingComponents/WeldingCommon/EquipDefCommon.cs index f693dfe..6cf1485 100644 --- a/WeldingComponents/WeldingCommon/EquipDefCommon.cs +++ b/WeldingComponents/WeldingCommon/EquipDefCommon.cs @@ -122,6 +122,10 @@ public const string CAS = "CAS"; public const string AJIN = "AJIN"; public const string AJINStageMotorZ = "AJINStageMotorZ"; + + #region + public const string AxisX2 = "AxisX2"; // 26.04.06 추가 + #endregion } public class CommonEventIds diff --git a/WeldingComponents/WeldingCommon/Utils/AuroraEx.cs b/WeldingComponents/WeldingCommon/Utils/AuroraEx.cs index 2c99812..06d4b01 100644 --- a/WeldingComponents/WeldingCommon/Utils/AuroraEx.cs +++ b/WeldingComponents/WeldingCommon/Utils/AuroraEx.cs @@ -1,5 +1,7 @@ using Aurora; using Aurora.Api; +// AuroraEx.cs 상단에 +using AuroraDevice = Aurora.Api.Device; using Aurora.Api.Manager; using AuroraMassFlowMeter; using AuroraOCT.Trumpf; @@ -17,7 +19,7 @@ namespace WeldingCommon.Utils { public static class AuroraEx { - public static bool IsAutoActivation(this Device dev) + public static bool IsAutoActivation(this AuroraDevice dev) { var Config = Application.Current.AuroraEnv().DeviceManager.GetDeviceConfig(dev.DeviceId); diff --git a/WeldingComponents/WeldingCommon/WeldingCommon.csproj b/WeldingComponents/WeldingCommon/WeldingCommon.csproj index 8fb19f2..52e81a9 100644 --- a/WeldingComponents/WeldingCommon/WeldingCommon.csproj +++ b/WeldingComponents/WeldingCommon/WeldingCommon.csproj @@ -54,6 +54,10 @@ prompt + + False + ..\..\AuroraDevices\AuroraACS\External\ACS.SPiiPlusNET.dll + ..\..\External\Aurora\bin\Aurora.exe @@ -205,6 +209,9 @@ + + + @@ -457,6 +464,10 @@ {97f61029-c403-4d16-b34a-53b5b78f2b74} AuroraUIComponent + + {6eea4c41-a833-41b8-a9d2-512f45e6beca} + AuroraACS + {546e6043-3162-468c-aacd-1c4eaa1bb494} AuroraCAS @@ -505,6 +516,10 @@ {007ba11c-c28e-4cfb-88c5-001988f0be8f} AuroraMotionBoard + + {49a61fb7-ec36-4035-b7bc-63ab983590b4} + AuroraMotor + {ffd404db-7fe2-447f-b469-56c61d863201} AuroraMXComponent