增加轴的复制属性、轴的恢复功能

master
lhiven 2 years ago
parent d4078b106a
commit 96976d122a

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Rs.Motion.Base
{
public class BaseAxisControl
{
List<IAxis> axes= new List<IAxis>();
private bool bLoadAxis = false;
private void LoadAxis()
{
if(!bLoadAxis)
{
PropertyInfo[] pis = this.GetType().GetProperties(System.Reflection.BindingFlags.Instance | BindingFlags.Public);
foreach (var item in pis)
{
IAxis axis = (IAxis)item.GetValue(this, null);
axes.Add(axis);
}
bLoadAxis = true;
}
}
public void AllEnable()
{
LoadAxis();
foreach (IAxis axis in axes)
{
axis.Enable();
}
}
public void AllDisEnable()
{
LoadAxis();
foreach (IAxis axis in axes)
{
axis.Enable();
}
}
public void AllStop()
{
LoadAxis();
foreach (IAxis axis in axes)
{
axis.Stop();
}
}
public void Restore()
{
LoadAxis();
foreach (IAxis axis in axes)
{
axis.Restore();
}
}
}
}

@ -34,164 +34,203 @@ namespace Rs.Motion.Base.Config
[XmlElement]
[CommonPropertyDescription("卡类型 \r\n 脉冲卡 0 \r\n 总线卡 1 ")]
[CopyAttribute]
public ushort CardType { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("回零方向 \r\n0:负方向回零 \r\n1:正方向回零")]
[CopyAttribute]
public ushort HomeDir { get; set; } = 0;
[XmlElement]
[LeisaiPropertyDescription("回零模式 \r\n0一次回零\r\n1一次回零加回找\r\n2二次回零\r\n3原点加同向 EZ\r\n4单独记一个 EZ\r\n5原点加反向 EZ\r\n6原点锁存\r\n7原点锁存加同向 EZ\r\n8单独记一个 EZ 锁存\r\n9原点锁存加反向 EZ")]
[ZTMPropertyDescription("回零模式 \r\n 0-无效 \r\n1-HOME零点开关一次回零 \r\n 2-LMT限位开关一次回零\r\n 3-Z编码器Z相信号一次回零\r\n 4-HOME+Z原点与编码器Z相信号联合回零\r\n5-LMT+Z限位开关与编码器Z相信号联合回零\r\n 6-LMT+HOME限位开关与零点开关联合回零\r\n7-LMT+HOME+Z限位开关、零点开关与编码器Z相信号联合回零\r\n 8-原地,仅仅将轴的位置清零")]
[CopyAttribute]
public ushort HomeMode { get; set; } = 3;
[XmlElement]
[CommonPropertyDescription("原点信号有效电平 \r\n0:低有效,\r\n1:高有效")]
[CopyAttribute]
public ushort HomeOrgLogic { get; set; } = 0;
[XmlElement]
[LeisaiPropertyDescription("回零速度模式: \r\n0:低速回零 \r\n1:高速回零")]
[ZTMPropertyDescription("不用此属性")]
[CopyAttribute]
public ushort HomeVelMode { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("回零速度: 单位 mm/s")]
[CopyAttribute]
public int HomeSpeed { get; set; } = 2;
[XmlElement]
[CommonPropertyDescription("回原点偏后偏移 mm")]
[CopyAttribute]
public double HomeOffset { get; set; } = 0.0;
[XmlElement]
[CommonPropertyDescription("是否启用编码器 \r\n 0禁用 \r\n 1启用")]
[CopyAttribute]
public ushort EnableEncoder { get; set; } = 0;
[XmlElement]
[DisplayName("脉冲模式")]
[Description("脉冲模式")]
[CopyAttribute]
public ushort PulseMode { get; set; } = 1;
[XmlElement]
[CommonPropertyDescription("脉冲输出模式")]
[CopyAttribute]
public ushort PulseOutMode { get; set; } = 5;
[XmlElement]
[CommonPropertyDescription("脉冲输出方向")]
[CopyAttribute]
public short PulseOutDir { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("脉冲输出索引方向")]
[CopyAttribute]
public short PulseOutIndexDir { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("编码器输入口的计数方式 \r\n0非 A/B 相(脉冲/方向) \r\n11×A/B \r\n22×A/B \r\n34×A/B")]
[CopyAttribute]
public ushort CounterInMode { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("启用EMG急停信号 \r\n0:禁用 \r\n1:启用")]
[CopyAttribute]
public ushort EnableEmg { get; set; }
[XmlElement]
[CommonPropertyDescription("EMG信号有效电平\r\n0低有效\r\n1高有效")]
[CopyAttribute]
public ushort EmgLogic { get; set; }
[XmlElement]
[CommonPropertyDescription("最大速度 单位:mm/s")]
[CopyAttribute]
public double MaxSpeed { get; set; }
[XmlElement]
[CommonPropertyDescription("最小速度 单位:mm/s")]
[CopyAttribute]
public double MinSpeed { get; set; }
[XmlElement]
[CommonPropertyDescription("停止速度 单位:mm/s")]
[CopyAttribute]
public double StopSpeed { get; set; }
[XmlElement]
[CommonPropertyDescription("S型曲线时间 单位:秒")]
[CopyAttribute]
public double STime { get; set; } = 0.02;
[XmlElement]
[CommonPropertyDescription("电机转一圈的脉冲数 pulse/r")]
[CopyAttribute]
public int PulseOneRound { get; set; } = 10000;
[XmlElement]
[CommonPropertyDescription("电机转一圈运动距离 mm/r")]
[CopyAttribute]
public double DistOneRound { get; set; } = 5;
[XmlElement]
[CommonPropertyDescription("正向软极限位置 mm")]
[CopyAttribute]
public double PelSoftwarePosition { get; set; } = 50.0;
[XmlElement]
[CopyAttribute]
[CommonPropertyDescription("负向软极限位置 mm")]
public double NelSoftwarePosition { get; set; } = -50.0;
[XmlElement]
[CommonPropertyDescription("是否启用软限位 0:禁止 1-允许")]
[CopyAttribute]
public ushort EnableSoftwareEL { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("软极限源 0:指令位置 1:编码器位置")]
[CopyAttribute]
public ushort SoftSource { get; set; } = 1;
[XmlElement]
[CommonPropertyDescription("限位信号的有效电平 0:正负限位低电平有效 1:正负限位高电平有效")]
[CopyAttribute]
public ushort ElLogic { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("限位开关是否启用 根据卡的相关说明配置")]
[CopyAttribute]
public ushort EnableEL { get; set; }
[XmlElement]
[CommonPropertyDescription("软极限制动模式 0:减速停止 1:立即停止")]
[CopyAttribute]
public ushort EL_stop_mode { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("Z信号电平 0:低电平有效 1:高电平有效")]
[CopyAttribute]
public ushort EzLogic { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("加速度时间S")]
[CopyAttribute]
public double AccTime { get; set; } = 0.0;
[XmlElement]
[CommonPropertyDescription("减速度时间S")]
[CopyAttribute]
public double DecTime { get; set; } = 0.0;
[XmlElement]
[CommonPropertyDescription("到位信号电平 0:低电平有效 1:高电平有效")]
[CopyAttribute]
public ushort InpLogic { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("到位信号启用")]
[CopyAttribute]
public ushort EnableInp { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("报警信号电平 0:低电平有效 1:高电平有效")]
[CopyAttribute]
public ushort AlarmLogic { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("报警信号启用 0:禁用 1:启用")]
[CopyAttribute]
public ushort EnableAlarm { get; set; } = 0;
[XmlElement]
[CommonPropertyDescription("允许的误差 单位:mm")]
[CopyAttribute]
public double Tolerance { get; set; } = 0.1;
[XmlElement]
[CommonPropertyDescription("高速位置对比的电平脉冲宽度 单位:us")]
[CopyAttribute]
public int HcmpPulseWidth { get; set; } = 50;
[XmlElement]
[CommonPropertyDescription("高速位置比较有效电平:\r\n0低电平\r\n1高电平")]
[CopyAttribute]
public ushort HcmpOutLogic { get; set; } = 0;
[XmlElement]
[ZTMPropertyDescription("电流值 ma")]
[CopyAttribute]
public short Current { get; set; } = 500;
[XmlElement]
@ -201,4 +240,9 @@ namespace Rs.Motion.Base.Config
[XmlElement]
public ushort AssistEncoder { get; set; } = 0;
}
public class CopyAttribute:Attribute
{
}
}

@ -1,4 +1,6 @@
using Rs.Motion.Base.Config;
using Newtonsoft.Json;
using Rs.Framework;
using Rs.Motion.Base.Config;
using System;
using System.Collections.Generic;
using System.Linq;
@ -9,6 +11,7 @@ using static GTN.mc_ecat;
namespace Rs.Motion.Base
{
[Serializable]
public class IAxis
{
/// <summary>
@ -32,6 +35,15 @@ namespace Rs.Motion.Base
return ErrorCode.Ok;
}
public string GetConfigString()
{
if(Config != null)
{
return JsonConvert.SerializeObject(Config);
}
return string.Empty;
}
public virtual ErrorCode Deinit()
{
return ErrorCode.Ok;
@ -243,5 +255,14 @@ namespace Rs.Motion.Base
{
return ErrorCode.Ok;
}
/// <summary>
/// 暂停后恢复
/// </summary>
/// <returns></returns>
public virtual ErrorCode Restore()
{
return ErrorCode.Ok;
}
}
}

@ -32,6 +32,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\Administrator\Desktop\新建文件夹 (3)\Rs.MotionPlat\Rs.Framework\bin\Debug\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data.SQLite">
@ -45,6 +49,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Base\BaseAxisControl.cs" />
<Compile Include="Base\IAxis.cs" />
<Compile Include="Base\ICard.cs" />
<Compile Include="Base\Config\AxisConfig.cs" />

@ -995,6 +995,7 @@ namespace Rs.Motion.GugaoEcat
(float)((homeSpeedPulse / 1000.0) / (Config.AccTime * 1000.0)),//回零加速度
(int)dfHome_offset, //回原后偏移
0);
LogHelper.Debug($"axis {Config.AxisName} start home ,homedir={Config.HomeDir},homemode={Config.HomeMode}");
if (m_apiResult != 0)
{
HomeStatus = EHomeStatus.Fail;
@ -1134,7 +1135,7 @@ namespace Rs.Motion.GugaoEcat
public override ErrorCode SetPosCompare(ushort channel, double[] postions)
{
m_apiResult = ZTM.ZT_SetCompareParam(Config.CardMc, 0, 1, (short)Config.AxisId, 7,0, 1, (uint)Config.HcmpPulseWidth);
m_apiResult = ZTM.ZT_SetCompareParam(Config.CardMc, 0, 1, (short)Config.AxisId, (short)channel, 0, 1, (uint)Config.HcmpPulseWidth);
double[] poses = new double[postions.Length];
for (int i = 0; i < poses.Length; i++)
{

Loading…
Cancel
Save