Commit ba757040 authored by 潘栩锋's avatar 潘栩锋 🚴

整理 flyad代码。 整理TimeGridAdv逻辑

parent a127e0b2
......@@ -91,6 +91,11 @@
<Name>FlyADBase</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="PropertyChanged.Fody">
<Version>2.6.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<PropertyChanged />
</Weavers>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="PropertyChanged" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="InjectOnPropertyNameChanged" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EventInvokerNames" type="xs:string">
<xs:annotation>
<xs:documentation>Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEquality" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should be inserted. If false, equality checking will be disabled for the project.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="CheckForEqualityUsingBaseEquals" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseStaticEqualsFromBase" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if equality checks should use the static Equals method resolved from the base class.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
\ No newline at end of file
......@@ -190,7 +190,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.2</Version>
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>2.6.1</Version>
......
using Misc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FlyADBase
{
public class GridIStatusEventArgs : EventArgs
{
public Misc.DIRECTION direction;
/// <summary>
/// 输入口 1~12
/// </summary>
public int istatus_no;
public Int32 marker;//扫描标记
/// <summary>
/// 扫描开始点
/// </summary>
public int pos_start;
/// <summary>
/// 扫长度
/// </summary>
public int pos_len;
/// <summary>
/// 输入口 信号为0, 的范围段
/// </summary>
public List<Range> data_0;
/// <summary>
/// 输入口 信号为1, 的范围段
/// </summary>
public List<Range> data_1;
}
public delegate void GridIStatusEventHander(object sender, GridIStatusEventArgs e);
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FlyADBase
{
public class IStatusChangedEventArgs : EventArgs
{
public IStatusChangedEventArgs(DateTime time, UInt16 istatus, UInt16 ichanged, int pos, int pos2)
{
Time = time;
IStatus = istatus;
IChanged = ichanged;
Position = pos;
Position2 = pos2;
}
/// <summary>
/// 开始时间点
/// </summary>
public DateTime Time;
/// <summary>
/// 输入口状态
/// </summary>
public UInt16 IStatus;
/// <summary>
/// 变化量
/// </summary>
public UInt16 IChanged;
/// <summary>
/// 变化时的脉冲1
/// </summary>
public int Position;
/// <summary>
/// 变化时的脉冲2
/// </summary>
public int Position2;
}
public delegate void IStatusChangedEventHandler(object sender, IStatusChangedEventArgs e);
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FlyADBase
{
public class MiniGridEventArgs : EventArgs
{
public Misc.DIRECTION direction;
public int posOfGrid;
public int grid_start;
public int[] buf;
public Int32 marker;//扫描标记
}
public delegate void MiniGridEventHandler(object sender, MiniGridEventArgs e);
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FlyADBase
{
/// <summary>
/// 高级timegrid
/// </summary>
public class TimeGridAdvEventArgs : EventArgs
{
/// <summary>
///
/// </summary>
public TimeGridAdvEventArgs()
{
}
/// <summary>
///
/// </summary>
/// <param name="data"></param>
public TimeGridAdvEventArgs(GridAdvUnit[] data)
{
Data = data;
}
public int Marker { get; set; }
/// <summary>
/// 数据
/// </summary>
public IEnumerable<GridAdvUnit> Data { get; set; }
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public delegate void TimeGridAdvEventHandler(object sender, TimeGridAdvEventArgs e);
/// <summary>
/// 高级timegrid 每个单元
/// </summary>
public class GridAdvUnit
{
/// <summary>
/// 时间
/// </summary>
public DateTime dt;
/// <summary>
/// ad值
/// </summary>
public int ad;
/// <summary>
/// 脉冲
/// </summary>
public int pos;
/// <summary>
/// 状态
/// </summary>
public UInt16 istatus;
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return $"{dt.Ticks} | {ad} | {pos} | {istatus:X2}";
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FlyADBase
{
public class TimeGridEventArgs : EventArgs
{
public TimeGridEventArgs()
{
}
public TimeGridEventArgs(DateTime time, TimeSpan tspan, int[] data)
{
Time = time;
Ts = tspan;
Data = data;
}
/// <summary>
/// 数据
/// </summary>
public int[] Data { get; set; }
/// <summary>
/// 单数据时间间隔
/// </summary>
public TimeSpan Ts { get; set; }
/// <summary>
/// 开始时间点
/// </summary>
public DateTime Time { get; set; }
}
public delegate void TimeGridEventHandler(object sender, TimeGridEventArgs e);
}
......@@ -6,6 +6,9 @@ using FObjBase;
using System.Net;
using FlyADBase;
/// <summary>
/// AD盒 通信的 OBJ 包定义
/// </summary>
namespace FLYAD7_OBJ_INTERFACE
{
public class FLYADC_OBJ_INTERFACE
......
This diff is collapsed.
......@@ -25,6 +25,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>bin\Debug\FlyADBase.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
......@@ -47,11 +48,17 @@
<ItemGroup>
<Compile Include="FlyAD7.cs" />
<Compile Include="FLYAD7_OBJ_INTERFACE.cs" />
<Compile Include="EventArgs\GridIStatusEventArgs.cs" />
<Compile Include="FlyADClientAdv.cs" />
<Compile Include="IFlyAD.cs" />
<Compile Include="IFlyADClient.cs" />
<Compile Include="IFlyADClientAdv.cs" />
<Compile Include="EventArgs\IStatusChangedEventArgs.cs" />
<Compile Include="EventArgs\MiniGridEventArgs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SyncOrder.cs" />
<Compile Include="EventArgs\TimeGridAdvEventArgs.cs" />
<Compile Include="TimeGridAdvHelper.cs" />
<Compile Include="EventArgs\TimeGridEventArgs.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Project.FLY.FObjSys\FObjSys\FObjBase.csproj">
......@@ -64,6 +71,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="NLog">
<Version>4.6.8</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>2.6.1</Version>
</PackageReference>
......
This diff is collapsed.
This diff is collapsed.
using System;
using Misc;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
......@@ -9,7 +10,7 @@ using System.Threading.Tasks;
namespace FlyADBase
{
/// <summary>
/// 客户端的 flyad
/// 客户端AD盒
/// </summary>
public interface IFlyADClient : IFlyAD
{
......@@ -17,49 +18,73 @@ namespace FlyADBase
/// 连接成功
/// </summary>
bool IsConnected { get; }
/// <summary>
/// 重连次数
/// </summary>
int ConnectCnt { get; }
/// <summary>
/// 机架修
/// CRC 校
/// </summary>
CorrectADsHandler CorrectADs { get; set; }
bool HasCRC { get; set; }
/// <summary>
/// CRC 校正
/// 连接
/// </summary>
bool HasCRC { get; set; }
void Connect();
/// <summary>
/// grid 滤波
/// 连接 ep
/// </summary>
int GridSmooth { get; set; }
/// <param name="ep"></param>
void Connect(IPEndPoint ep);
/// <summary>
/// 重连
/// </summary>
void ReConnect();
/// <summary>
/// Ratio02 / Ratio01
/// 用于同步, 最后一次 纵向信号 0->1 时,主轴脉冲
/// </summary>
double Speed1Scale { get; }
int LastPos2At01 { get; }
/// <summary>
/// 当前在同步状态
/// </summary>
bool IsSync { get; }
/// <summary>
/// 同步列表,完成后,会删除
/// </summary>
ObservableCollection<SyncOrder> SyncOrders { get; }
}
/// <summary>
/// 连接
/// 客户端AD盒附加的功能
/// </summary>
void Connect();
public interface IFlyADClientAdv : IFlyADClient
{
/// <summary>
/// 通过脉冲计算速度,不使用AD盒的输出
/// </summary>
bool IsCalSpeed { get; set; }
/// <summary>
/// 机架修正
/// </summary>
CorrectADsHandler CorrectADs { get; set; }
/// <summary>
/// 连接 ep
/// grid 滤波
/// </summary>
/// <param name="ep"></param>
void Connect(IPEndPoint ep);
int GridSmooth { get; set; }
/// <summary>
/// 重连
/// 脉冲比例 Ratio02(编码器脉冲) / Ratio01(电机脉冲)
/// </summary>
void ReConnect();
double Speed1Scale { get; }
/// <summary>
/// 机架总长
......@@ -75,15 +100,7 @@ namespace FlyADBase
/// </summary>
void RuntoMax();
/// <summary>
/// 用于同步, 最后一次 纵向信号 0->1 时,主轴脉冲
/// </summary>
int LastPos2At01 { get; }
/// <summary>
/// 当前在同步状态
/// </summary>
bool IsSync { get; }
/// <summary>
/// 设置输出
......@@ -92,6 +109,32 @@ namespace FlyADBase
/// <param name="is1"></param>
void SetOutputBit(int index, bool is1);
/// <summary>
/// 从正反缓存区, 获取grid数据
/// </summary>
/// <param name="direction">方向, 只有 正,反</param>
/// <param name="grid_start">grid 开始位置</param>
/// <param name="grid_len">grid 长度</param>
/// <param name="dat">grid 数据</param>
void GetGrid(DIRECTION direction, int grid_start, int grid_len, out int[] dat);
/// <summary>
/// 从正反缓存区, 获取全部grid数据
/// </summary>
/// <param name="direction">方向, 只有 正,反</param>
/// <param name="dat">grid 数据</param>
void GetGrid(DIRECTION direction, out int[] dat);
/// <summary>
/// 转为 grid 数据
/// </summary>
/// <param name="gridAdvUnits"></param>
/// <param name="dat"></param>
void ToGrid(List<GridAdvUnit> gridAdvUnits, out int[] dat);
/// <summary>
/// 动作完成
/// </summary>
bool IsFinish { get; }
#region 滞后处理
/// <summary>
/// ad滞后修正 单位ms
......@@ -105,20 +148,27 @@ namespace FlyADBase
#region runto 推送 istatus 变化
/// <summary>
/// 添加 GridIStatusEvent 事件;
/// 获取一整幅 grid 对应的 输入口状态 数据
/// </summary>
/// <param name="istatus_no"></param>
/// <param name="func"></param>
void GridIStatusEventAdd(int istatus_no, GridIStatusEventHander func);
/// <summary>
/// 删除 GridIStatusEvent 事件
/// </summary>
/// <param name="istatus_no"></param>
/// <param name="func"></param>
void GridIStatusEventDel(int istatus_no, GridIStatusEventHander func);
#endregion
#region 同步
}
/// <summary>
/// 同步列表,完成后,会删除
/// 机架修正
/// </summary>
ObservableCollection<SyncOrder> SyncOrders { get; }
#endregion
}
/// <param name="direction"></param>
/// <param name="start_grid"></param>
/// <param name="dat"></param>
public delegate void CorrectADsHandler(Misc.DIRECTION direction, int start_grid, int[] dat);
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FlyADBase
{
/// <summary>
/// 同步指令状态
/// </summary>
public enum SyncOrderState
{
/// <summary>
/// 等待开始
/// </summary>
Waiting,
/// <summary>
/// 运行中
/// </summary>
Doing,
/// <summary>
/// 动作结束
/// </summary>
Finish
}
/// <summary>
/// 同步指令基类
/// </summary>
public abstract class SyncOrder : INotifyPropertyChanged
{
/// <summary>
/// 状态
/// </summary>
public SyncOrderState State { get; set; } = SyncOrderState.Waiting;
/// <summary>
/// 标识
/// </summary>
public Int32 Marker { get; set; }
/// <summary>
///
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
}
/// <summary>
/// 同步指令-同步运行至逻辑位置
/// </summary>
public class SyncOrder_SyncRunAtLC : SyncOrder
{
/// <summary>
///
/// </summary>
public int Pos2Begin { get; set; }
/// <summary>
///
/// </summary>
public int Pos2End { get; set; }
/// <summary>
///
/// </summary>
public int Pos1LC { get; set; }
/// <summary>
///
/// </summary>
public bool HasDataGrid { get; set; }
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
string s;
......@@ -46,8 +82,15 @@ namespace FlyADBase
"Marker=" + Marker.ToString() + ")";
}
}
/// <summary>
/// 同步指令-归0
/// </summary>
public class SyncOrder_SyncOrigin : SyncOrder
{
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
string s;
......@@ -63,6 +106,9 @@ namespace FlyADBase
}
}
/// <summary>
/// 同步指令-运行至
/// </summary>
public class SyncOrder_SyncRunTo : SyncOrder
{
public int Pos1 { get; set; }
......@@ -86,11 +132,29 @@ namespace FlyADBase
}
}
/// <summary>
/// 同步指令-运行至逻辑位置
/// </summary>
public class SyncOrder_SyncRunToLC : SyncOrder
{
/// <summary>
///
/// </summary>
public int Pos1 { get; set; }
/// <summary>
///
/// </summary>
public UInt32 Velocity { get; set; }
/// <summary>
///
/// </summary>
public bool HasDataGrid { get; set; }
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
string s;
......@@ -108,9 +172,20 @@ namespace FlyADBase
"Marker=" + Marker.ToString() + ")";
}
}
/// <summary>
/// 同步指令-等待
/// </summary>
public class SyncOrder_SyncWait : SyncOrder
{
/// <summary>
///
/// </summary>
public int MS { get; set; }
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
string s;
......@@ -127,9 +202,16 @@ namespace FlyADBase
}
}
/// <summary>
/// 同步指令扩展功能
/// </summary>
public static class SyncOrderExtention
{
/// <summary>
///
/// </summary>
/// <param name="order"></param>
/// <param name="flyad"></param>
public static void Add(this SyncOrder order, IFlyAD flyad)
{
if (order is SyncOrder_SyncRunAtLC)
......@@ -153,14 +235,32 @@ namespace FlyADBase
((SyncOrder_SyncWait)order).Add(flyad);
}
}
/// <summary>
///
/// </summary>
/// <param name="order"></param>
/// <param name="flyad"></param>
public static void Add(this SyncOrder_SyncRunAtLC order, IFlyAD flyad)
{
flyad.SyncRunAtLC(order.Pos2Begin, order.Pos2End, order.Pos1LC, order.HasDataGrid, order.Marker);
}
/// <summary>
///
/// </summary>
/// <param name="order"></param>
/// <param name="flyad"></param>
public static void Add(this SyncOrder_SyncOrigin order, IFlyAD flyad)
{
flyad.SyncOrigin(order.Marker);
}
/// <summary>
///
/// </summary>
/// <param name="order"></param>
/// <param name="flyad"></param>
public static void Add(this SyncOrder_SyncRunTo order, IFlyAD flyad)
{
......@@ -168,6 +268,12 @@ namespace FlyADBase
order.Pos1, order.Velocity, order.HasDataGrid, order.Marker);
}
/// <summary>
///
/// </summary>
/// <param name="order"></param>
/// <param name="flyad"></param>
public static void Add(this SyncOrder_SyncRunToLC order, IFlyAD flyad)
{
......@@ -175,6 +281,12 @@ namespace FlyADBase
order.Pos1, order.Velocity, order.HasDataGrid, order.Marker);
}
/// <summary>
///
/// </summary>
/// <param name="order"></param>
/// <param name="flyad"></param>
public static void Add(this SyncOrder_SyncWait order, IFlyAD flyad)
{
flyad.SyncWait(order.MS, order.Marker);
......
......@@ -168,7 +168,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.2</Version>
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>2.6.1</Version>
......
......@@ -117,9 +117,6 @@ namespace Flyad7_WPF
MessageBox.Show("flyad.Pos2Comp = " + Pos2Comp.ToString() );
}
private void button_clear_Click(object sender, RoutedEventArgs e)
{
flyad.SyncClear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment