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

flyad7 吹膜模拟添加360旋转, 旋转架复位,旋转架停止, 牵引停止

parent 9512dcc5
......@@ -15,14 +15,49 @@ namespace FLY.Simulation.Blowing
{
#region 参数
#region 旋转架
/// <summary>
/// 360° 连续旋转
/// </summary>
[JsonProperty]
public bool Is360 { get; set; }
/// <summary>
/// 正向旋转
/// </summary>
public bool IsForw { get; set; }
/// <summary>
/// 旋转架复位中
/// </summary>
public bool IsOrg { get; set; }
/// <summary>
/// 旋转架启动中
/// </summary>
public bool IsRotationOn { get; set; }
/// <summary>
/// 牵引启动中
/// </summary>
public bool IsTractionOn { get; set; }
/// <summary>
/// 1圈总脉冲
/// </summary>
[JsonProperty]
public double PosOfR { get; set; }
/// <summary>
/// 两个限位间的角度范围 != 旋转的总角度,限位值 °
/// </summary>
[JsonProperty]
public double AngleRange { get; set; }
/// <summary>
/// 复位信号角度范围°
/// </summary>
[JsonProperty]
public double OrgAngleRange { get; set; }
/// <summary>
/// 旋转的速度, min/R 1R = 360°
/// </summary>
......@@ -108,11 +143,18 @@ namespace FLY.Simulation.Blowing
#endregion
#region 动态数据
/// <summary>
/// 当前人字架角度 °
/// </summary>
public double CurrAngle { get; private set; }
/// <summary>
/// 全局角度 °
/// </summary>
public double GlobalAngle { get; private set; }
/// <summary>
/// 当前速度,单位 °/s
/// </summary>
public double CurrAngleVelocity { get; private set; }
......@@ -129,7 +171,6 @@ namespace FLY.Simulation.Blowing
#endregion
public HMI mHMI;
private int avg;
public int Avg { get; set; }
/// <summary>
/// 原始数据
......@@ -167,7 +208,8 @@ namespace FLY.Simulation.Blowing
{
//撞了限位后,限位信号一直在。。。。
PosOfR = 50000;
OrgAngleRange = 5;//复位信号角度°
AngleRange = 350;//两个限位间的角度范围350°
AngleVelocity = 6;//出限位 到 撞另一个限位的时间 8min/ 360°
AngleAccTime = 1;//加速时间1s
......@@ -217,6 +259,15 @@ namespace FLY.Simulation.Blowing
mHMI = new HMI();
mHMI.mAirRing = mAirRing2;
Is360 = false;
IsForw = true;
IsOrg = false;
IsRotationOn = true;
IsTractionOn = true;
}
void mAirRing2_AfterDatasUpdateEvent(ObservableCollection<int> obj)
......@@ -427,7 +478,7 @@ namespace FLY.Simulation.Blowing
if (percent < 0)
{
angle = 0;
return false;
return true;
}
//找到了
angle = (mPositionAngleList[idx1].angle - mPositionAngleList[idx2].angle) * percent + mPositionAngleList[idx2].angle;
......@@ -435,7 +486,7 @@ namespace FLY.Simulation.Blowing
}
}
angle = 0;
return false;
return true;
}
public FilmData GetData(double position)
......@@ -497,6 +548,7 @@ namespace FLY.Simulation.Blowing
/// </summary>
public void OnPoll(DateTime now)
{
UpdatePositionAndAngle(now);
}
......@@ -527,10 +579,43 @@ namespace FLY.Simulation.Blowing
/// </summary>
DateTime mDTWrap = DateTime.MinValue;
void UpdateAngleV(DateTime now, TimeSpan ts)
/// <summary>
/// 更新旋转
/// </summary>
/// <param name="now"></param>
/// <param name="ts"></param>
void UpdateAngleV(DateTime now, TimeSpan ts)
{
if (IsOrg) {
IsRotationOn = false;
UpdateAngleV_Org(now, ts);
return;
}
if (IsRotationOn) {
if (Is360)
{
UpdateAngleV_360(now, ts);
}
else {
UpdateAngleV_ForwBackw(now, ts);
}
}
}
/// <summary>
/// 正反向旋转
/// </summary>
/// <param name="now"></param>
/// <param name="ts"></param>
void UpdateAngleV_ForwBackw(DateTime now, TimeSpan ts)
{
double angle = CurrAngle + CurrAngleVelocity * ts.TotalSeconds;
//旋转
switch (mState)
{
case STATE.Constant:
......@@ -566,9 +651,12 @@ namespace FLY.Simulation.Blowing
{
//反转
anglev = -anglev;
IsForw = false;
}
double dv = anglev - CurrAngleVelocity;
CurrAngleAccV = dv / AngleAccTime;
else {
IsForw = true;
}
CurrAngleAccV = anglev / AngleAccTime;
}
} break;
case STATE.Acc:
......@@ -594,28 +682,104 @@ namespace FLY.Simulation.Blowing
}
} break;
}
double delta = angle - CurrAngle;
GlobalAngle += delta;
CurrAngle = angle;
}
/// <summary>
/// 连续旋转
/// </summary>
/// <param name="now"></param>
/// <param name="ts"></param>
void UpdateAngleV_360(DateTime now, TimeSpan ts)
{
double anglev = 360.0 / (AngleVelocity * 60);
if (IsForw)
CurrAngleVelocity = anglev;
else
CurrAngleVelocity = -anglev;
double angle = CurrAngle + CurrAngleVelocity * ts.TotalSeconds;
double delta = angle - CurrAngle;
GlobalAngle += delta;
CurrAngle = angle;
}
/// <summary>
/// 复位
/// </summary>
/// <param name="now"></param>
/// <param name="ts"></param>
void UpdateAngleV_Org(DateTime now, TimeSpan ts)
{
double anglev = 360.0 / (AngleVelocity * 60);
if (CurrAngle > 0){
CurrAngleVelocity = -anglev;
}
else if (CurrAngle < 0)
{
CurrAngleVelocity = anglev;
}
else {
CurrAngleVelocity = 0;
IsOrg = false;
return;
}
double angle = CurrAngle + CurrAngleVelocity * ts.TotalSeconds;
double delta = angle - CurrAngle;
if (((CurrAngle > 0) && (angle <= 0))||
((CurrAngle < 0) && (angle >= 0)))
{
delta = 0 - CurrAngle;
CurrAngle = 0;
CurrAngleVelocity = 0;
IsOrg = false;
return;
}
GlobalAngle += delta;
CurrAngle = angle;
}
/// <summary>
/// 驱动器,根据时间,更新angle,
/// </summary>
/// <param name="now"></param>
void UpdatePositionAndAngle(DateTime now)
{
if (mDTLast == DateTime.MinValue)
{
double position = FilmDistance;
DateTime time = now;
while (position > 0)
{
mPositionAngleList.Insert(0,
new PositionAngleInfo()
{
dt = time,
position = position,
angle = 0
});
TimeSpan ts1 = TimeSpan.FromMilliseconds(10);
time -= ts1;
position -= FilmVelocity * ts1.TotalMinutes;
}
mDTLast = now;
CurrFilmLength = 0;
CurrFilmLength = FilmDistance;
CurrAngle = 0;//在中间
mState = STATE.Constant;
double anglev = 360.0 / (AngleVelocity * 60);
CurrAngleVelocity = anglev;
mPositionAngleList.Add(
new PositionAngleInfo()
{
dt = mDTLast,
position = CurrFilmLength,
angle = CurrAngle
});
return;
}
......@@ -627,7 +791,12 @@ namespace FLY.Simulation.Blowing
mDTLast = dt;
//线速度。。。。
CurrFilmLength += FilmVelocity * ts.TotalMinutes;
if(IsTractionOn)//启动牵引
CurrFilmLength += FilmVelocity * ts.TotalMinutes;
UpdateAngleV(dt, ts);
......@@ -642,20 +811,46 @@ namespace FLY.Simulation.Blowing
if (mPositionAngleList.Count > ListCap)
mPositionAngleList.RemoveAt(0);
}
public bool CheckLimit1()
public bool CheckOrg()
{
if (CurrAngle >= AngleRange / 2)
if (CurrAngle <= OrgAngleRange / 2 && CurrAngle >= -OrgAngleRange / 2)
return true;
else
return false;
}
public bool CheckLimit1()
{
if (Is360)
{
if (CurrAngleVelocity < 0)
return true;
else
return false;
}
else
{
if (CurrAngle >= AngleRange / 2)
return true;
else
return false;
}
}
public bool CheckLimit0()
{
if (CurrAngle <= (-AngleRange / 2))
return true;
if (Is360)
{
if (CurrAngleVelocity > 0)
return true;
else
return false;
}
else
return false;
{
if (CurrAngle <= (-AngleRange / 2))
return true;
else
return false;
}
}
public bool CheckRoll()
{
......
......@@ -69,7 +69,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.5</Version>
<Version>3.3.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
......@@ -11,6 +11,16 @@
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property 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>
......@@ -31,6 +41,16 @@
<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:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
......
......@@ -137,11 +137,17 @@ namespace FLY.Simulation.Blowing
if (mBlowing.CheckLimit0())
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RENZIJIA_0 - 1);
}
if (mBlowing.CheckLimit1())
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RENZIJIA_1-1);
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RENZIJIA_1 - 1);
if (mBlowing.CheckOrg())
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RENZIJIA_ORG - 1);
if (mBlowing.CheckRoll())
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RSENSOR-1);
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RSENSOR - 1);
return istatus;
}
......@@ -149,11 +155,12 @@ namespace FLY.Simulation.Blowing
public int GetPosition2()
{
return 0;
double p = mBlowing.GlobalAngle / 360;
return (int)(mBlowing.PosOfR * p);
}
public int GetSpeed2()
{
return 0;
return (int)(mBlowing.PosOfR * mBlowing.CurrAngleVelocity / 360);
}
}
}
......
......@@ -61,7 +61,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.5</Version>
<Version>3.3.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
......@@ -11,6 +11,16 @@
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property 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>
......@@ -31,6 +41,16 @@
<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:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
......
......@@ -68,7 +68,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.5</Version>
<Version>3.3.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
......@@ -11,6 +11,16 @@
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property 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>
......@@ -31,6 +41,16 @@
<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:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
......
......@@ -96,7 +96,7 @@
<Version>10.1.1</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.5</Version>
<Version>3.3.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
......@@ -410,8 +410,9 @@ namespace FLY.Simulation.Flyad7
Position2Org = mSimGageAD.GetPosition2();
int pos2;
if(mSyncPos2List.Position2Changed(Position2, out pos2))
//同步模式
if (mSyncPos2List.Position2Changed(Position2, out int pos2))
{
Position2 = pos2;
}
......@@ -439,12 +440,12 @@ namespace FLY.Simulation.Flyad7
else
Misc.MyBase.SIGNBIT(ref istatus, IODefinition.IN_ORG - 1);
//同步模式下才有这个
UInt16 inchange = (UInt16)(istatus ^ IStatus);
if (Misc.MyBase.CHECKBIT(inchange, IODefinition.IN_VSENSOR - 1))
if (Misc.MyBase.CHECKBIT(inchange, IODefinition.IN_VSENSOR - 1))
{
//处理position2
int pos2;
if(mSyncPos2List.VSensorChanged(Misc.MyBase.CHECKBIT(istatus, IODefinition.IN_VSENSOR - 1), Position2, out pos2))
if (mSyncPos2List.VSensorChanged(Misc.MyBase.CHECKBIT(istatus, IODefinition.IN_VSENSOR - 1), Position2, out int pos2))
{
Position2 = pos2;
}
......
......@@ -11,6 +11,16 @@
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property 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>
......@@ -31,6 +41,16 @@
<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:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
......
......@@ -61,7 +61,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.5</Version>
<Version>3.3.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
......@@ -11,6 +11,16 @@
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property 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>
......@@ -31,6 +41,16 @@
<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:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
......
......@@ -57,7 +57,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.5</Version>
<Version>3.3.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
......@@ -11,6 +11,16 @@
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property 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>
......@@ -31,6 +41,16 @@
<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:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:all>
......
......@@ -7,14 +7,45 @@ namespace FLY.Simulation
{
public class IODefinition
{
/// <summary>
/// 归0
/// </summary>
public const int IN_ORG = 2;
/// <summary>
/// 反向限位
/// </summary>
public const int IN_MINLIMIT = 3;
/// <summary>
/// 正向限位
/// </summary>
public const int IN_MAXLIMIT = 4;
/// <summary>
/// 手动正转
/// </summary>
public const int IN_FORW = 7;
/// <summary>
/// 手动反转
/// </summary>
public const int IN_BACKW = 8;
/// <summary>
/// 旋转架 信号0
/// </summary>
public const int IN_RENZIJIA_0 = 9;
/// <summary>
/// 旋转架 信号1
/// </summary>
public const int IN_RENZIJIA_1 = 10;
/// <summary>
/// 线速度
/// </summary>
public const int IN_RSENSOR = 11;
/// <summary>
/// 纵向边界信息
/// </summary>
public const int IN_VSENSOR = 12;
/// <summary>
/// 旋转架 复位信号
/// </summary>
public const int IN_RENZIJIA_ORG = 12;
}
}
......@@ -192,7 +192,7 @@
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.5</Version>
<Version>3.3.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
......@@ -11,6 +11,16 @@
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property 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>
......@@ -31,6 +41,16 @@
<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:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
......
......@@ -164,7 +164,21 @@
<TextBlock Style="{StaticResource FieldNameStyle}" Text="第1根加热棒对应角度"/>
<TextBox Style="{StaticResource InputStyle}" Text="{Binding Channel1stAngle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="2">
<TextBlock Style="{StaticResource FieldNameStyle}" Text="1圈脉冲数"/>
<TextBox Style="{StaticResource InputStyle}" Text="{Binding PosOfR}"/>
</StackPanel>
<Button Style="{StaticResource ButtonStyle}" Content="保存" Click="btnSaveClick"/>
<GroupBox Header="运动控制">
<StackPanel>
<CheckBox Content="连续旋转" Height="16" Margin="5" IsChecked="{Binding Is360}" />
<CheckBox Content="正向旋转" Height="16" Margin="5" IsChecked="{Binding IsForw}" />
<CheckBox Content="复位" Height="16" Margin="5" IsChecked="{Binding IsOrg}" />
<CheckBox Content="旋转启动" Height="16" Margin="5" IsChecked="{Binding IsRotationOn}" />
<CheckBox Content="牵引启动" Height="16" Margin="5" IsChecked="{Binding IsTractionOn}" />
</StackPanel>
</GroupBox>
</StackPanel>
</GroupBox>
......
......@@ -27,18 +27,14 @@ namespace FlyADBase
const int MARKNO_SET_SYSPARAM = 3;
const int MARKNO_SET_SAVE = 4;
#endregion
#region 成员变量
TCPCConn conn = null;
/// <summary>
/// 不设置服务器
/// </summary>
private bool bShieldSetValueEx = false;
/// <summary>
/// AD盒使用时间刷新
/// </summary>
private DateTime dt_surplus = DateTime.MinValue;
class DtAndBool
{
bool bNeedGet;
......@@ -72,8 +68,11 @@ namespace FlyADBase
int last_position = int.MinValue;
bool isReadyGetState = false;
bool isReadyGetPos1AD1 = false;
bool isReadyGetPos2 = false;
bool isReadyGetIO = false;
#endregion
/// <summary>
///
......@@ -81,12 +80,27 @@ namespace FlyADBase
public FlyAD7()
{
Now = DateTime.Now;
mSysTick.Reset();
mSysTick.BeReseted += MSysTick_BeReseted;
this.PropertyChanged += new PropertyChangedEventHandler(FlyAD7_PropertyChanged);
PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, new PollModule.PollHandler(OnPoll));
//每隔一个小时
PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, () =>
{
if (!IsConnected)
return;
if (Surplus < 60000)
{
if (Surplus > 0)
{
Surplus--;
CurrObjSys.CallFunctionEx(conn, FLYAD7_OBJ_INTERFACE.SYS_DATA_INTERFACE.ID, ID,
FLYAD7_OBJ_INTERFACE.SYS_DATA_INTERFACE.CALL_SURPLUS_SUB,
null);
}
}
}, TimeSpan.FromMinutes(60));
//60秒内收不到1个timegrid ,就会重连
PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD,
......@@ -108,12 +122,16 @@ namespace FlyADBase
}
}
}
}, TimeSpan.FromSeconds(1));
constructor2();
}
private void MSysTick_BeReseted()
{
BeResetTime = DateTime.Now;
}
#region IFlyADClient
/// <summary>
/// 连接成功
......@@ -172,7 +190,16 @@ namespace FlyADBase
conn = CurrObjSys.Connect_to_Another_OBJSys(LocalEP, ID);
conn.HasCRC = HasCRC;
}
/// <summary>
/// 已经从AD盒获取全部当前数据
/// </summary>
public bool IsReady { get; protected set; }
/// <summary>
/// 通过判断systick,判断AD盒是否发生重启;
/// BeReseted为上一次被复位时间
/// </summary>
public DateTime BeResetTime { get; private set; }
/// <summary>
/// 用于同步, 最后一次 纵向信号 0->1 时,主轴脉冲
/// </summary>
......@@ -188,9 +215,33 @@ namespace FlyADBase
#endregion
void updateIsReady() {
if (isReadyGetState == false)
{
IsReady = false;
return;
}
if (isReadyGetPos1AD1 == false)
{
IsReady = false;
return;
}
if (isReadyGetPos2 == false)
{
IsReady = false;
return;
}
if (isReadyGetIO == false)
{
IsReady = false;
return;
}
IsReady = true;
return;
}
void FlyAD7_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "HasCRC")
if (e.PropertyName == nameof(HasCRC))
{
if (conn != null)
conn.HasCRC = HasCRC;
......@@ -199,12 +250,12 @@ namespace FlyADBase
if (bShieldSetValueEx)
return;
if ((e.PropertyName == "Velocity") ||
(e.PropertyName == "SVelocity") ||
(e.PropertyName == "ATime") ||
(e.PropertyName == "DTime") ||
(e.PropertyName == "HVelocity1") ||
(e.PropertyName == "HVelocity2"))
if ((e.PropertyName == nameof(Velocity)) ||
(e.PropertyName == nameof(SVelocity)) ||
(e.PropertyName == nameof(ATime)) ||
(e.PropertyName == nameof(DTime)) ||
(e.PropertyName == nameof(HVelocity1)) ||
(e.PropertyName == nameof(HVelocity2)))
{
FObjBase.PollModule.Current.Poll_JustOnce(
delegate ()
......@@ -214,8 +265,8 @@ namespace FlyADBase
SetPosParam(Velocity, SVelocity, ATime, DTime, HVelocity1, HVelocity2);
}, this, MARKNO_SET_VELOCITY);
}
else if ((e.PropertyName == "PosOffset") ||
(e.PropertyName == "JogVelocity"))
else if ((e.PropertyName == nameof(PosOffset)) ||
(e.PropertyName == nameof(JogVelocity)))
{
FObjBase.PollModule.Current.Poll_JustOnce(
delegate ()
......@@ -229,10 +280,10 @@ namespace FlyADBase
}.ToBytes());
}, this, MARKNO_SET_ZEROPOS);
}
else if ((e.PropertyName == "MotorType") ||
(e.PropertyName == "PosOfGrid") ||
(e.PropertyName == "Ratio01") ||
(e.PropertyName == "Ratio02"))
else if ((e.PropertyName == nameof(MotorType)) ||
(e.PropertyName == nameof(PosOfGrid)) ||
(e.PropertyName == nameof(Ratio01)) ||
(e.PropertyName == nameof(Ratio02)))
{
FObjBase.PollModule.Current.Poll_JustOnce(
delegate ()
......@@ -240,7 +291,7 @@ namespace FlyADBase
SetSysParam(PosOfGrid, MotorType, Ratio01, Ratio02);
}, this, MARKNO_SET_SYSPARAM);
}
else if (e.PropertyName == "Pos1LCShift")
else if (e.PropertyName == nameof(Pos1LCShift))
{
CurrObjSys.CallFunctionEx(
......@@ -253,7 +304,7 @@ namespace FlyADBase
pos1_LCShift = Pos1LCShift
}.ToBytes());
}
else if (e.PropertyName == "Position2")
else if (e.PropertyName == nameof(Position2))
{
CurrObjSys.CallFunctionEx(
conn,
......@@ -265,7 +316,7 @@ namespace FlyADBase
pos2 = Position2
}.ToBytes());
}
else if (e.PropertyName == "Pos2Comp")
else if (e.PropertyName == nameof(Pos2Comp))
{
CurrObjSys.CallFunctionEx(
conn,
......@@ -306,6 +357,11 @@ namespace FlyADBase
SENSE_CONFIG.ADD);
UpdateParam();
isReadyGetState = false;
isReadyGetPos1AD1 = false;
isReadyGetPos2 = false;
isReadyGetIO = false;
updateIsReady();
//DRIVE_MAN
CurrObjSys.GetValueEx(
......@@ -353,11 +409,7 @@ namespace FlyADBase
SyncClear();
SyncEnd();
mSysTick.Reset();
Init2();
}
......@@ -400,6 +452,10 @@ namespace FlyADBase
Position = pack.pos;
//AD = pack.ad;
advGetPos1AD1(pack.ad);
isReadyGetPos1AD1 = true;
updateIsReady();
} break;
case FLYAD7_OBJ_INTERFACE.FLYADC_OBJ_INTERFACE.GET_POS2:
{
......@@ -411,6 +467,9 @@ namespace FlyADBase
if (!IsCalSpeed)
Speed2 = pack.speed2;
isReadyGetPos2 = true;
updateIsReady();
}
break;
}
......@@ -428,6 +487,9 @@ namespace FlyADBase
IStatus = pack.istatus;
OStatus = pack.ostatus;
advGetIo();
isReadyGetIO = true;
updateIsReady();
} break;
}
} break;
......@@ -451,13 +513,15 @@ namespace FlyADBase
} break;
case FLYAD7_OBJ_INTERFACE.DRIVE_MAN_INTERFACE.GET_STATE:
{
//TODO ?????
FLYAD7_OBJ_INTERFACE.DRIVE_MAN_INTERFACE.Pack_DriveState p = new FLYAD7_OBJ_INTERFACE.DRIVE_MAN_INTERFACE.Pack_DriveState();
if (!p.TryParse(infodata))
break;
DriveOrder = p.order;//TODO
DriveOrder = p.order;
DriveStatus = p.status;
Marker = p.marker;
isReadyGetState = true;
updateIsReady();
} break;
case FLYAD7_OBJ_INTERFACE.DRIVE_MAN_INTERFACE.GET_SYNC_STATUS:
{
......@@ -473,7 +537,6 @@ namespace FlyADBase
if (!p.TryParse(infodata))
break;
//TODO
}
break;
}
......@@ -549,8 +612,7 @@ namespace FlyADBase
{
Int32 systick_1st = 0;
DateTime dt_1st = DateTime.MinValue;
Int32 systick_last = 0;
public event Action BeReseted;
public void Reset()
{
dt_1st = DateTime.MinValue;
......@@ -566,36 +628,31 @@ namespace FlyADBase
{
dt_1st = DateTime.Now;
systick_1st = systick;
systick_last = systick;
return dt_1st;
}
//记录与新的timemark 相差10秒,太大了,重新生成 timemark 与 dt 的关系
else if (Math.Abs(systick - systick_last) > 10000)
int ms = systick - systick_1st;
if ((ms < 1000)||
(ms> 1000 * 60 * 3))//记录与新的timemark 相差3分钟,太大了,重新生成 timemark 与 dt 的关系
{
//被复位了
BeReseted?.Invoke();
dt_1st = DateTime.Now;
systick_1st = systick;
systick_last = systick;
return dt_1st;
}
else
{
int ms = systick - systick_1st;
systick_last = systick;
DateTime dt = dt_1st.AddMilliseconds(ms);
systick_1st = systick;
dt_1st = dt;
if (Math.Abs((DateTime.Now-dt).TotalSeconds) > 5000)//滞后5s,异常
{
//修正
dt = DateTime.Now;
dt_1st = dt;
}
return dt;
}
DateTime dt = dt_1st.AddMilliseconds(ms);
systick_1st = systick;
dt_1st = dt;
//if (Math.Abs((DateTime.Now-dt).TotalSeconds) > 5000)//滞后5s,异常
//{
// //修正
// dt = DateTime.Now;
// dt_1st = dt;
//}
return dt;
}
}
TSysTick mSysTick = new TSysTick();
......@@ -836,25 +893,7 @@ namespace FlyADBase
DateTime now = DateTime.Now;
if (Surplus != 65535)
{
if (dt_surplus == DateTime.MinValue)
{
dt_surplus = now - TimeSpan.FromMinutes(40);//再过20分钟,就会 执行 使用时间+1
}
else if ((now - dt_surplus).TotalHours >= 1) //每隔一个小时 执行 使用时间+1
{
dt_surplus = now;
if (Surplus > 0)
{
Surplus--;
CurrObjSys.CallFunctionEx(conn, FLYAD7_OBJ_INTERFACE.SYS_DATA_INTERFACE.ID, ID,
FLYAD7_OBJ_INTERFACE.SYS_DATA_INTERFACE.CALL_SURPLUS_SUB,
null);
}
}
}
if (sysinfo_wait.NeedGet(now, TimeSpan.FromSeconds(1)))
{
......
......@@ -45,12 +45,23 @@ namespace FlyADBase
/// </summary>
void ReConnect();
/// <summary>
/// 已经从AD盒获取全部当前数据
/// </summary>
bool IsReady { get; }
/// <summary>
/// 通过判断systick,判断AD盒是否发生重启;
/// BeResetTime为上一次被复位时间
/// </summary>
DateTime BeResetTime { get; }
/// <summary>
/// 用于同步, 最后一次 纵向信号 0->1 时,主轴脉冲
/// </summary>
int LastPos2At01 { get; }
/// <summary>
/// 当前在同步状态
/// </summary>
......@@ -60,6 +71,8 @@ namespace FlyADBase
/// 同步列表,完成后,会删除
/// </summary>
ObservableCollection<SyncOrder> SyncOrders { get; }
}
/// <summary>
......@@ -67,6 +80,7 @@ namespace FlyADBase
/// </summary>
public interface IFlyADClientAdv : IFlyADClient
{
/// <summary>
/// 通过脉冲计算速度,不使用AD盒的输出
/// </summary>
......
......@@ -213,7 +213,7 @@
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="PropertyChanged.Fody">
<Version>3.2.5</Version>
<Version>3.3.1</Version>
</PackageReference>
<PackageReference Include="Unity">
<Version>5.11.7</Version>
......
......@@ -11,6 +11,16 @@
<xs:documentation>Used to control if the On_PropertyName_Changed feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="TriggerDependentProperties" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the Dependent properties feature is enabled.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="EnableIsChangedProperty" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to control if the IsChanged property 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>
......@@ -31,6 +41,16 @@
<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:attribute name="SuppressWarnings" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings from this weaver.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="SuppressOnPropertyNameChangedWarning" type="xs:boolean">
<xs:annotation>
<xs:documentation>Used to turn off build warnings about mismatched On_PropertyName_Changed methods.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
......
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