首次上传

This commit is contained in:
hanqiangqiang
2026-06-15 10:56:30 +08:00
commit b0213b94d6
4160 changed files with 736101 additions and 0 deletions
@@ -0,0 +1,154 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using MECF.Framework.RT.EquipmentLibrary.Core.Extensions;
using MECF.Framework.RT.EquipmentLibrary.Core.Interfaces;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobort.Errors
{
public class HiwinRobotAggregatedErrors : IBitTypeClass
{
#region Variables
private const int BIT_WIDTH = 16;
#endregion
#region Constructors
public HiwinRobotAggregatedErrors()
{
Input = new HiwinRobotInputErrors();
Sensor = new HiwinRobotSensorErrors();
AxisT = new HiwinRobotServoErrors();
AxisR = new HiwinRobotServoErrors();
AxisZ = new HiwinRobotServoErrors();
Controller = new HiwinRobotControllerErrors();
}
public HiwinRobotAggregatedErrors(string response)
{
if(!IsErrResponse(response, out var rawErr))
throw new InvalidOperationException("the format of response string is incorrect.");
Input = int.TryParse(rawErr[0], NumberStyles.HexNumber, null, out var input)
? input.ToBitTypeClass<HiwinRobotInputErrors>(BIT_WIDTH)
: 0xffff.ToBitTypeClass<HiwinRobotInputErrors>(BIT_WIDTH); // 如果转换错误,全部置为错误,以防呆
Sensor = int.TryParse(rawErr[1], NumberStyles.HexNumber, null, out var sensor)
? sensor.ToBitTypeClass<HiwinRobotSensorErrors>(BIT_WIDTH)
: 0xffff.ToBitTypeClass<HiwinRobotSensorErrors>(BIT_WIDTH); // 如果转换错误,全部置为错误,以防呆
AxisT = int.TryParse(rawErr[2], NumberStyles.HexNumber, null, out var axisT)
? axisT.ToBitTypeClass<HiwinRobotServoErrors>(BIT_WIDTH)
: 0xffff.ToBitTypeClass<HiwinRobotServoErrors>(BIT_WIDTH); // 如果转换错误,全部置为错误,以防呆
AxisR = int.TryParse(rawErr[3], NumberStyles.HexNumber, null, out var axisR)
? axisR.ToBitTypeClass<HiwinRobotServoErrors>(BIT_WIDTH)
: 0xffff.ToBitTypeClass<HiwinRobotServoErrors>(BIT_WIDTH); // 如果转换错误,全部置为错误,以防呆
AxisZ = int.TryParse(rawErr[4], NumberStyles.HexNumber, null, out var axisZ)
? axisZ.ToBitTypeClass<HiwinRobotServoErrors>(BIT_WIDTH)
: 0xffff.ToBitTypeClass<HiwinRobotServoErrors>(BIT_WIDTH); // 如果转换错误,全部置为错误,以防呆
AxisW = int.TryParse(rawErr[5], NumberStyles.HexNumber, null, out var axisW)
? axisW.ToBitTypeClass<HiwinRobotServoErrors>(BIT_WIDTH)
: 0xffff.ToBitTypeClass<HiwinRobotServoErrors>(BIT_WIDTH); // 如果转换错误,全部置为错误,以防呆
AxisH = int.TryParse(rawErr[6], NumberStyles.HexNumber, null, out var axisH)
? axisH.ToBitTypeClass<HiwinRobotServoErrors>(BIT_WIDTH)
: 0xffff.ToBitTypeClass<HiwinRobotServoErrors>(BIT_WIDTH); // 如果转换错误,全部置为错误,以防呆
Controller = int.TryParse(rawErr[7], NumberStyles.HexNumber, null, out var cont)
? cont.ToBitTypeClass<HiwinRobotControllerErrors>(BIT_WIDTH)
: 0xffff.ToBitTypeClass<HiwinRobotControllerErrors>(BIT_WIDTH); // 如果转换错误,全部置为错误,以防呆
}
#endregion
#region Properties
/// <summary>
/// 输入错误
/// </summary>
public HiwinRobotInputErrors Input { get; }
/// <summary>
/// 传感器错误
/// </summary>
public HiwinRobotSensorErrors Sensor { get; }
/// <summary>
/// T轴错误
/// </summary>
public HiwinRobotServoErrors AxisT { get; }
/// <summary>
/// R轴错误
/// </summary>
public HiwinRobotServoErrors AxisR { get; }
/// <summary>
/// Z轴错误
/// </summary>
public HiwinRobotServoErrors AxisZ { get; }
/// <summary>
/// Z轴错误
/// </summary>
public HiwinRobotServoErrors AxisW { get; }
/// <summary>
/// Z轴错误
/// </summary>
public HiwinRobotServoErrors AxisH { get; }
/// <summary>
/// 控制器错误
/// </summary>
public HiwinRobotControllerErrors Controller { get; }
/// <summary>
/// 返回整合的错误信息列表。
/// </summary>
public List<string> AggregateErrorMessages
{
get
{
var errs = new List<string>();
errs.AddRange(Input.AggregateErrorMessages());
errs.AddRange(Sensor.AggregateErrorMessages());
// 伺服轴的错误输出文本中加入轴名称
errs.AddRange(AxisT.AggregateErrorMessages()
.Select(x=>string.Concat($"[{nameof(AxisT)}]", x)));
errs.AddRange(AxisR.AggregateErrorMessages()
.Select(x => string.Concat($"[{nameof(AxisR)}]", x)));
errs.AddRange(AxisZ.AggregateErrorMessages()
.Select(x => string.Concat($"[{nameof(AxisZ)}]", x)));
errs.AddRange(AxisW.AggregateErrorMessages()
.Select(x => string.Concat($"[{nameof(AxisW)}]", x)));
errs.AddRange(AxisH.AggregateErrorMessages()
.Select(x => string.Concat($"[{nameof(AxisH)}]", x)));
errs.AddRange(Controller.AggregateErrorMessages());
return errs;
}
}
#endregion
#region Methods
public static bool IsErrResponse(string response, out string[] errArray)
{
errArray = response.Split(',');
return errArray.Length == 8;
}
#endregion
}
}
@@ -0,0 +1,56 @@
using MECF.Framework.RT.EquipmentLibrary.Core.Attributes;
using MECF.Framework.RT.EquipmentLibrary.Core.Interfaces;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobort.Errors
{
public class HiwinRobotControllerErrors : IBitTypeClass
{
/// <summary>
/// ERROR(401) 紧急停止开关被触发。
/// </summary>
[BitTypeClassProperty(0, "ERROR(401) 紧急停止开关被触发", true)]
public bool Error401 { get; private set; }
/// <summary>
/// ERROR(402) 控制器电源故障。
/// </summary>
[BitTypeClassProperty(1, "ERROR(402) 控制器电源故障", true)]
public bool Error402 { get; private set; }
/// <summary>
/// ERROR(403) 控制器电压过低。
/// </summary>
[BitTypeClassProperty(2, "ERROR(403) 控制器电压过低", true)]
public bool Error403 { get; private set; }
/// <summary>
/// ERROR(404) 控制器电压过高。
/// </summary>
[BitTypeClassProperty(3, "ERROR(404) 控制器电压过高", true)]
public bool Error404 { get; private set; }
/// <summary>
/// ERROR(405) 控制器判定驱动器故障。
/// </summary>
[BitTypeClassProperty(4, "ERROR(405) 控制器判定驱动器故障", true)]
public bool Error405 { get; private set; }
/// <summary>
/// ERROR(406) 控制器电压异常。
/// </summary>
[BitTypeClassProperty(5, "ERROR(406) 控制器电压异常", true)]
public bool Error406 { get; private set; }
/// <summary>
/// ERROR(407) 控制器无法辨识驱动器部。
/// </summary>
[BitTypeClassProperty(6, "ERROR(407) 控制器无法辨识驱动器部", true)]
public bool Error407 { get; private set; }
/// <summary>
/// ERROR(408) 驱动器UPS故障。
/// </summary>
[BitTypeClassProperty(7, "ERROR(408) 驱动器UPS故障", true)]
public bool Error408 { get; private set; }
}
}
@@ -0,0 +1,44 @@
using MECF.Framework.RT.EquipmentLibrary.Core.Attributes;
using MECF.Framework.RT.EquipmentLibrary.Core.Interfaces;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobort.Errors
{
public class HiwinRobotInputErrors : IBitTypeClass
{
/// <summary>
/// ERROR(101):巨集指令输入错误。
/// </summary>
[BitTypeClassProperty(0, "ERROR(101) 巨集指令输入错误", true)]
public bool Error101 { get; private set; }
/// <summary>
/// ERROR(102):站名输入错误。
/// </summary>
[BitTypeClassProperty(1, "ERROR(102) 站名输入错误", true)]
public bool Error102 { get; private set; }
/// <summary>
/// ERROR(103):轴名输入错误。
/// </summary>
[BitTypeClassProperty(2, "ERROR(103) 轴名输入错误", true)]
public bool Error103 { get; private set; }
/// <summary>
/// ERROR(104):群组名称输入错误。
/// </summary>
[BitTypeClassProperty(3, "ERROR(104) 群组名称输入错误", true)]
public bool Error104 { get; private set; }
/// <summary>
/// ERROR(105):引数输入错误。
/// </summary>
[BitTypeClassProperty(4, "ERROR(105) 引数输入错误", true)]
public bool Error105 { get; private set; }
/// <summary>
/// ERROR(106):输入距离超过软体极限。
/// </summary>
[BitTypeClassProperty(5, "ERROR(106) 输入距离超过软体极限", true)]
public bool Error106 { get; private set; }
}
}
@@ -0,0 +1,80 @@
using MECF.Framework.RT.EquipmentLibrary.Core.Attributes;
using MECF.Framework.RT.EquipmentLibrary.Core.Interfaces;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobort.Errors
{
public class HiwinRobotSensorErrors : IBitTypeClass
{
/// <summary>
/// ERROR(201) 机械臂取放晶圆前,真空状态已被启动。
/// </summary>
[BitTypeClassProperty(0, "ERROR(201) 机械臂取放晶圆前,真空状态已被启动", true)]
public bool Error201 { get; private set; }
/// <summary>
/// ERROR(202) 机械臂取放晶圆后,真空状态无法被产生或接触。
/// </summary>
[BitTypeClassProperty(1, "ERROR(202) 机械臂取放晶圆后,真空状态无法被产生或接触", true)]
public bool Error202 { get; private set; }
/// <summary>
/// ERROR(203) 机械臂Z轴硬件上极限开关被触发。
/// </summary>
[BitTypeClassProperty(2, "ERROR(203) 机械臂Z轴硬件上极限开关被触发", true)]
public bool Error203 { get; private set; }
/// <summary>
/// ERROR(204) 机械臂Z轴硬件下极限开关被触发。
/// </summary>
[BitTypeClassProperty(3, "ERROR(204) 机械臂Z轴硬件下极限开关被触发", true)]
public bool Error204 { get; private set; }
/// <summary>
/// ERROR(205) 机械臂取晶圆前或放晶圆后,光传感器状态已被启动。
/// </summary>
[BitTypeClassProperty(4, "ERROR(205) 机械臂取晶圆前或放晶圆后,光传感器状态已被启动", true)]
public bool Error205 { get; private set; }
/// <summary>
/// ERROR(206) 机械臂取晶圆后或放晶圆前,光传感器状态已被解除。
/// </summary>
[BitTypeClassProperty(5, "ERROR(206) 机械臂取晶圆后或放晶圆前,光传感器状态已被解除", true)]
public bool Error206 { get; private set; }
/// <summary>
/// ERROR(207) 机械臂磁簧开关为伸出状态,无法被缩回。
/// </summary>
[BitTypeClassProperty(6, "ERROR(207) 机械臂磁簧开关为伸出状态,无法被缩回", true)]
public bool Error207 { get; private set; }
/// <summary>
/// ERROR(208) 机械臂磁簧开关为缩回状态,无法被伸出。
/// </summary>
[BitTypeClassProperty(7, "ERROR(208) 机械臂磁簧开关为缩回状态,无法被伸出", true)]
public bool Error208 { get; private set; }
/// <summary>
/// ERROR(209) 机械臂H轴正硬限位被触发。
/// </summary>
[BitTypeClassProperty(8, "ERROR(209) 机械臂H轴正硬限位被触发", true)]
public bool Error209 { get; private set; }
/// <summary>
/// ERROR(210) 机械臂H轴负硬限位被触发。
/// </summary>
[BitTypeClassProperty(9, "ERROR(210) 机械臂H轴负硬限位被触发", true)]
public bool Error210 { get; private set; }
/// <summary>
/// ERROR(211) 机械臂翻转缸未翻至正面。
/// </summary>
[BitTypeClassProperty(10, "ERROR(211) 机械臂翻转缸未翻至正面", true)]
public bool Error211 { get; private set; }
/// <summary>
/// ERROR(212) 机械臂翻转缸未翻至反面。
/// </summary>
[BitTypeClassProperty(11, "ERROR(212) 机械臂翻转缸未翻至反面", true)]
public bool Error212 { get; private set; }
}
}
@@ -0,0 +1,87 @@
using MECF.Framework.RT.EquipmentLibrary.Core.Attributes;
using MECF.Framework.RT.EquipmentLibrary.Core.Interfaces;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobort.Errors
{
public class HiwinRobotServoErrors : IBitTypeClass
{
/// <summary>
/// ERROR(301):马达尚未励磁或励磁失败。
/// </summary>
[BitTypeClassProperty(0, "ERROR(301) 马达尚未励磁或励磁失败", true)]
public bool Error301 { get; private set; }
/// <summary>
/// ERROR(302):马达未归原位或归原位失败。
/// </summary>
[BitTypeClassProperty(1, "ERROR(302) 马达未归原位或归原位失败", true)]
public bool Error302 { get; private set; }
/// <summary>
/// ERROR(303):马达正在移动。
/// </summary>
[BitTypeClassProperty(2, "ERROR(303) 马达正在移动", true)]
public bool Error303 { get; private set; }
/// <summary>
/// ERROR(304):跟随误差超过设定的最大位置误差。
/// </summary>
[BitTypeClassProperty(3, "ERROR(304) 跟随误差超过设定的最大位置误差", true)]
public bool Error304 { get; private set; }
/// <summary>
/// ERROR(305):伺服马达编码器错误。
/// </summary>
[BitTypeClassProperty(4, "ERROR(305) 伺服马达编码器错误", true)]
public bool Error305 { get; private set; }
/// <summary>
/// ERROR(306):伺服马达编码器故障。
/// </summary>
[BitTypeClassProperty(5, "ERROR(306) 伺服马达编码器故障", true)]
public bool Error306 { get; private set; }
/// <summary>
/// ERROR(307):私服马达温度过高。
/// </summary>
[BitTypeClassProperty(6, "ERROR(307) 私服马达温度过高", true)]
public bool Error307 { get; private set; }
/// <summary>
/// ERROR(308):马达移动至正软限位位置。
/// </summary>
[BitTypeClassProperty(7, "ERROR(308) 马达移动至正软限位位置", true)]
public bool Error308 { get; private set; }
/// <summary>
/// ERROR(309):马达移动至负软限位位置。
/// </summary>
[BitTypeClassProperty(8, "ERROR(309) 马达移动至负软限位位置", true)]
public bool Error309 { get; private set; }
/// <summary>
/// ERROR(310):马达某轴速度或加速度参数异常。
/// </summary>
[BitTypeClassProperty(9, "ERROR(310) 马达某轴速度或加速度参数异常", true)]
public bool Error310 { get; private set; }
/// <summary>
/// ERROR(311):T/Z/H轴归原点时,R/W轴尚未归原点。
/// </summary>
[BitTypeClassProperty(10, "ERROR(311) T/Z/H轴归原点时,R/W轴尚未归原点", true)]
public bool Error311 { get; private set; }
/// <summary>
/// ERROR(312):T/Z/H轴归原点时,R/W轴尚未缩回到安全位置。
/// </summary>
[BitTypeClassProperty(11, "ERROR(312) T/Z/H轴归原点时,R/W轴尚未缩回到安全位置", true)]
public bool Error312 { get; private set; }
/// <summary>
/// ERROR(313):控制器温度过高。
/// </summary>
[BitTypeClassProperty(12, "ERROR(313) 控制器温度过高", true)]
public bool Error313 { get; private set; }
}
}
@@ -0,0 +1,114 @@
using MECF.Framework.RT.EquipmentLibrary.Core.Attributes;
using MECF.Framework.RT.EquipmentLibrary.Core.Interfaces;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobort
{
public class HiwinRobotStatus : IBitTypeClass
{
#region Constructor
#endregion
#region Properties
/// <summary>
/// 返回是否已接收巨集指令尚未被执行。
/// </summary>
[BitTypeClassProperty(0, "已接收巨集指令尚未被执行")]
public bool IsCommandNotExecuted { get; private set; }
/// <summary>
/// 返回是否正压力传感器被触发。
/// </summary>
[BitTypeClassProperty(1, "正压力传感器被触发")]
public bool IsPosPressureSensorTriggered { get; private set; }
/// <summary>
/// 返回是否负压力传感器被触发。
/// </summary>
[BitTypeClassProperty(2, "负压力传感器被触发")]
public bool IsNegPressureSensorTriggered { get; private set; }
/// <summary>
/// 返回是否电磁阀已被启动。
/// </summary>
[BitTypeClassProperty(3, "电磁阀已被启动")]
public bool IsSolenoidValveTurnedOn { get; private set; }
/// <summary>
/// 返回是否单轴或多轴马达发生错误。
/// </summary>
[BitTypeClassProperty(4, "单轴或多轴马达发生错误", true)]
public bool IsMotorError { get; private set; }
/// <summary>
/// 返回是否单个或多个极限开关被触发。
/// </summary>
[BitTypeClassProperty(5, "单个或多个极限开关被触发", true)]
public bool IsEndLimitTriggered { get; private set; }
/// <summary>
/// 返回是否单个或多个轴伺服马达归零未成功。
/// </summary>
[BitTypeClassProperty(6, "单个或多个轴伺服马达归零未成功", true)]
public bool IsHomingFailed { get; private set; }
/// <summary>
/// 保留位1。
/// </summary>
[BitTypeClassProperty(7, "保留位1")]
public bool Reserved1 { get; private set; }
/// <summary>
/// 返回是否指令正在执行中。
/// </summary>
[BitTypeClassProperty(8, "指令正在执行中")]
public bool IsCommandExecuting { get; private set; }
/// <summary>
/// 返回是否单个或多个轴正在移动中。
/// </summary>
[BitTypeClassProperty(9, "单个或多个轴正在移动中")]
public bool IsMoving { get; private set; }
/// <summary>
/// 返回是否单个或多个马达已被解除励磁。
/// </summary>
[BitTypeClassProperty(10, "单个或多个马达已被解除励磁中", true)]
public bool IsServoOff { get; private set; }
/// <summary>
/// 返回是否已回原点但RW轴未在原点位置。
/// </summary>
[BitTypeClassProperty(11, "已回原点但RW轴未在原点位置", true)]
public bool IsHomedButRWAxis { get; private set; }
/// <summary>
/// 返回是否已回原点并且处于缩回状态。
/// </summary>
[BitTypeClassProperty(12, "已回原点并且处于缩回状态")]
public bool IsHomedAndRetracted { get; private set; }
/// <summary>
/// 保留位2。
/// </summary>
[BitTypeClassProperty(13, "保留位2")]
public bool Reserved2 { get; private set; }
/// <summary>
/// 返回是否控制器返回错误。
/// </summary>
[BitTypeClassProperty(14, "控制器返回错误", true)]
public bool IsControllerError { get; private set; }
/// <summary>
/// 保留位3。
/// </summary>
[BitTypeClassProperty(15, "保留位3")]
public bool Reserved3 { get; private set; }
#endregion
}
}
@@ -0,0 +1,91 @@
using Aitex.Core.RT.Log;
using MECF.Framework.Common.Communications;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.HwinRobot
{
public class HwinRobotMessage : AsciiMessage
{
public string Data { get; set; }
public string ErrorText { get; set; }
}
public class HwinRobotTCPConnection : TCPPortConnectionBase
{
private bool _isAckMode = false;//should read from config file
public HwinRobotTCPConnection(string address, string endof)
: base(address, endof, true)
{
}
public override bool SendMessage(string message)
{
return base.SendMessage(message);
}
protected override void ActiveHandlerProceedMessage(MessageBase msg)
{
lock (_lockerActiveHandler)
{
if (_activeHandler != null)
{
if (msg.IsFormatError || !((HwinRobotHandler)_activeHandler).HasResponse || (_activeHandler.HandleMessage(msg, out bool transactionComplete) && transactionComplete))
{
_activeHandler = null;
}
}
}
}
protected override MessageBase ParseResponse(string rawText)
{
HwinRobotMessage msg = new HwinRobotMessage();
msg.RawMessage = rawText;
if (rawText.Length <= 0)
{
LOG.Error($"empty response,");
msg.IsFormatError = true;
return msg;
}
rawText = rawText.Replace("\r", "").Replace("\n", "");
if (rawText.Contains("_ERR"))
{
msg.IsError = true;
var rewTextArray = rawText.Split(' ');
msg.Data = rewTextArray[1];
msg.IsComplete = true;
}
else if (rawText.Contains("_BG_RDY"))
{
if (!_isAckMode)
{
LOG.Error($"response format check failed, BG_RDY is not valid in Mode 1");
msg.IsFormatError = true;
return msg;
}
msg.Data = rawText;
msg.IsResponse = true;
msg.IsAck = true;
msg.IsComplete = true;
}
else if (rawText.Contains("_RDY"))
{
msg.Data = rawText.Replace("_RDY", "");
msg.IsResponse = true;
msg.IsAck = true;
msg.IsComplete = true;
}
else
{
msg.Data = rawText;
msg.IsResponse = true;
}
return msg;
}
}
}