123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Event;
- using Aitex.Core.Utilities;
- using FurnaceRT.Devices;
- using MECF.Framework.Common.Event;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using static Aitex.Core.RT.Device.Unit.IoBoat;
- namespace FurnaceRT.Equipments.Boats
- {
- public partial class BoatModule
- {
- [Tag("AlarmSignalStepperMotorAlarm")]
- public IoAlarmSignal SensorStepperMotorAlarm { get; set; }
- private List<AlarmEventItem> _triggeredAlarmList = new List<AlarmEventItem>();
- private int _alarmNumber;
- public IoShutter ShutterDevice { get; set; }
- public IoAPC APCDevice { get; set; }
- public IoFurnaceMotor ZAxisDevice { get; set; }
- public IoFurnaceMotor RAxisDevice { get; set; }
- [Tag("SensorVAC1")]
- public IoSensor SensorVAC1 { get; set; }
- [Tag("SensorVAC2")]
- public IoSensor SensorVAC2 { get; set; }
- [Tag("SensorVAC3")]
- public IoSensor SensorVAC3 { get; set; }
- [Tag("SensorVAC4")]
- public IoSensor SensorVAC4 { get; set; }
- [Tag("SensorVAC5")]
- public IoSensor SensorVAC5 { get; set; }
- [Tag("SensorVAC6")]
- public IoSensor SensorVAC6 { get; set; }
- [Tag("SensorWaferRobotEX1AxisHomePosition")]
- public IoSensor SensorWaferRobotEX1AxisHomePosition { get; set; }
- [Tag("SensorWaferRobotEX2AxisHomePosition")]
- public IoSensor SensorWaferRobotEX2AxisHomePosition { get; set; }
- [Tag("SensorPS13LStatus")]
- public IoSensor SensorPS13LStatus { get; set; }
- [Tag("SensorBoatUnloadInterlock")]
- public IoSensor SensorBoatUnloadInterlock { get; set; }
- public void InitDevice()
- {
- Func<object, bool> _isTagAttribute = attribute => attribute is TagAttribute;
- Func<MemberInfo, bool> _hasTagAttribute = mi => mi.GetCustomAttributes(false).Any(_isTagAttribute);
- var properties = this.GetType().GetProperties().Where(_hasTagAttribute);
- foreach (var field in properties)
- {
- TagAttribute tag = field.GetCustomAttributes(false).First(_isTagAttribute) as TagAttribute;
- IDevice device = DEVICE.GetDevice<IDevice>($"{Module}.{tag.Tag}");
- if (device == null)
- device = DEVICE.GetDevice<IDevice>($"PM1.{tag.Tag}");
- if (device != null)
- {
- device.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;
- PropertyInfo pi = (PropertyInfo)field;
- var convertedValue = Convert.ChangeType(device, pi.PropertyType);
- System.Diagnostics.Debug.Assert(convertedValue != null);
- pi.SetValue(this, convertedValue);
- }
- }
- ShutterDevice = DEVICE.GetDevice<IoShutter>($"PM1.Shutter");
- this.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;
- if (ShutterDevice != null)
- ShutterDevice.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;
- APCDevice = DEVICE.GetDevice<IoAPC>($"PM1.APC");
- ZAxisDevice = DEVICE.GetDevice<IoFurnaceMotor>($"PM1.BoatElevatorServo");
- RAxisDevice = DEVICE.GetDevice<IoFurnaceMotor>($"PM1.BoatRotationServo");
- System.Diagnostics.Debug.Assert(ZAxisDevice != null);
- System.Diagnostics.Debug.Assert(RAxisDevice != null);
- System.Diagnostics.Debug.Assert(ShutterDevice != null);
- System.Diagnostics.Debug.Assert(SensorVAC1 != null);
- System.Diagnostics.Debug.Assert(SensorVAC2 != null);
- System.Diagnostics.Debug.Assert(SensorVAC3 != null);
- System.Diagnostics.Debug.Assert(SensorPS13LStatus != null);
- System.Diagnostics.Debug.Assert(SensorBoatUnloadInterlock != null);
- }
- public void OnModuleDeviceAlarmStateChanged(string deviceId, AlarmEventItem alarmItem)
- {
- if (alarmItem.IsTriggered)
- {
- EventLevel level = alarmItem.Level;
- _triggeredAlarmList.Add(alarmItem);
- if (level == EventLevel.Alarm)
- {
- try
- {
- EV.PostAlarmLog(Module, alarmItem);
- }
- catch (Exception ex)
- {
- EV.WriteEvent(ex.Message.ToString());
- }
- }
- else
- {
- EV.PostWarningLog(Module, alarmItem);
- }
- }
- else
- {
- }
- }
- public void SetZAxisSpeed(float speed)
- {
- //BoatDevice.SetZAxisSpeed(speed);
- }
- public void SetRAxisSpeed(float speed)
- {
- //BoatDevice.SetRAxisSpeed(speed);
- }
- public void SetRAxisIntervalPosition(float position)
- {
- //BoatDevice.SetRAxisIntervalPosition(position);
- }
- public void BoatZAxisStop()
- {
- ZAxisDevice.ServoStop();
- }
- public void BoatRAxisStop()
- {
- RAxisDevice.ServoStop();
- }
- private bool SetBoatZAxisSpeed(out string reason, int time, object[] param)
- {
- reason = string.Empty;
- SetZAxisSpeed(Convert.ToSingle(param[0].ToString()));
- return true;
- }
- private bool SetBoatRAxisSpeed(out string reason, int time, object[] param)
- {
- reason = string.Empty;
- SetRAxisSpeed(Convert.ToSingle(param[0].ToString()));
- return true;
- }
- private bool SetBoatRAxisAngle(out string reason, int time, object[] param)
- {
- reason = string.Empty;
- SetRAxisIntervalPosition(Convert.ToSingle(param[0].ToString()));
- return true;
- }
- private bool SetBoatZAxisStop(out string reason, int time, object[] param)
- {
- reason = string.Empty;
- BoatZAxisStop();
- return true;
- }
- private bool SetBoatRAxisStop(out string reason, int time, object[] param)
- {
- reason = string.Empty;
- BoatRAxisStop();
- return true;
- }
- }
- }
|