Commit bd130581 authored by 潘栩锋's avatar 潘栩锋 :bicyclist:

修改 PLC旋转顺序逻辑

parent 52a2953f
...@@ -27,42 +27,61 @@ ...@@ -27,42 +27,61 @@
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<Button Style="{StaticResource Styles.Button.Empty}" Tag="{Binding .}" Click="btnTAreaClick"> <Button Style="{StaticResource Styles.Button.Empty}" Tag="{Binding .}" Click="btnTAreaClick">
<UniformGrid Columns="1" > <Grid>
<UniformGrid.Resources> <Grid.RowDefinitions>
<Style TargetType="ContentControl"> <RowDefinition Height="auto"/>
<Setter Property="Margin" Value="{StaticResource ControlMargin}"/> <RowDefinition/>
<Setter Property="MinWidth" Value="150"/> <RowDefinition/>
<Setter Property="MinHeight" Value="116"/> <RowDefinition/>
</Style> <RowDefinition/>
</UniformGrid.Resources> <RowDefinition/>
<Border Style="{StaticResource Styles.Module.Border}" Background="{StaticResource Color_background}" CornerRadius="5,5,0,0" > <RowDefinition/>
<Viewbox > <RowDefinition/>
<TextBlock Text="{Binding Number}" Foreground="{StaticResource Color_title}" </Grid.RowDefinitions>
FontSize="100" FontWeight="Bold" FontFamily="Arial Black" TextAlignment="Right" /> <Border Style="{StaticResource Styles.Module.Border}" Background="{StaticResource Color_background}" CornerRadius="5,5,0,0" Margin="{StaticResource ControlMargin}">
</Viewbox> <TextBlock Text="{Binding Number}" Foreground="{StaticResource Color_title}"
FontSize="50" FontWeight="Bold" FontFamily="Arial Black" TextAlignment="Center" />
</Border> </Border>
<Viewbox Stretch="Uniform" StretchDirection="DownOnly"> <ContentControl Grid.Row="1" ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[0]}" Margin="{StaticResource ControlMargin}"/>
<ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[0]}"/> <ContentControl Grid.Row="2" ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[1]}" Margin="{StaticResource ControlMargin}"/>
</Viewbox> <ContentControl Grid.Row="3" ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[2]}" Margin="{StaticResource ControlMargin}"/>
<Viewbox Stretch="Uniform" StretchDirection="DownOnly"> <ContentControl Grid.Row="4" ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[3]}" Margin="{StaticResource ControlMargin}"/>
<ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[1]}"/> <ContentControl Grid.Row="5" ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[4]}" Margin="{StaticResource ControlMargin}"/>
</Viewbox> <ContentControl Grid.Row="6" ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[5]}" Margin="{StaticResource ControlMargin}"/>
<Viewbox Stretch="Uniform" StretchDirection="DownOnly"> <ContentControl Grid.Row="7" ContentTemplate="{StaticResource TmTemplate}" Content="{Binding .}" Margin="{StaticResource ControlMargin}"/>
<ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[2]}"/>
</Viewbox> <!--<UniformGrid Columns="1" Grid.Row="1">
<Viewbox Stretch="Uniform" StretchDirection="DownOnly"> <UniformGrid.Resources>
<ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[3]}"/> <Style TargetType="ContentControl">
</Viewbox> <Setter Property="Margin" Value="{StaticResource ControlMargin}"/>
<Viewbox Stretch="Uniform" StretchDirection="DownOnly"> <Setter Property="MinWidth" Value="150"/>
<ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[4]}"/> <Setter Property="MinHeight" Value="116"/>
</Viewbox> </Style>
<Viewbox Stretch="Uniform" StretchDirection="DownOnly"> </UniformGrid.Resources>
<ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[5]}"/> <Viewbox Stretch="Uniform" StretchDirection="DownOnly" >
</Viewbox> <ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[0]}" Width="250" />
<Viewbox Stretch="Uniform" StretchDirection="DownOnly"> </Viewbox>
<ContentControl ContentTemplate="{StaticResource TmTemplate}" Content="{Binding .}"/> <Viewbox Stretch="Uniform" StretchDirection="DownOnly">
</Viewbox> <ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[1]}"/>
</UniformGrid> </Viewbox>
<Viewbox Stretch="Uniform" StretchDirection="DownOnly">
<ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[2]}"/>
</Viewbox>
<Viewbox Stretch="Uniform" StretchDirection="DownOnly">
<ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[3]}"/>
</Viewbox>
<Viewbox Stretch="Uniform" StretchDirection="DownOnly">
<ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[4]}"/>
</Viewbox>
<Viewbox Stretch="Uniform" StretchDirection="DownOnly">
<ContentControl ContentTemplate="{StaticResource TcTemplate}" Content="{Binding Temperatures[5]}"/>
</Viewbox>
<Viewbox Stretch="Uniform" StretchDirection="DownOnly">
<ContentControl ContentTemplate="{StaticResource TmTemplate}" Content="{Binding .}"/>
</Viewbox>
</UniformGrid>-->
</Grid>
</Button> </Button>
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
Content="{ Binding Source={StaticResource downBlowingSystemUt}, Path=TAreas[0].Temperatures[0]}"/> Content="{ Binding Source={StaticResource downBlowingSystemUt}, Path=TAreas[0].Temperatures[0]}"/>
<ContentControl Width="240" Margin="{StaticResource ControlMargin}" ContentTemplate="{StaticResource TcAllSetTemplate}" <ContentControl Width="240" Margin="{StaticResource ControlMargin}" ContentTemplate="{StaticResource TcAllSetTemplate}"
Content="{ Binding Source={StaticResource downBlowingSystemUt}, Path=TAreas[0]}"/> Content="{ Binding Source={StaticResource downBlowingSystemUt}, Path=TAreas[0]}"/>
<ContentControl Width="116" Margin="{StaticResource ControlMargin}" ContentTemplate="{StaticResource TcTemplate}" <ContentControl Margin="{StaticResource ControlMargin}" ContentTemplate="{StaticResource TcTemplate}"
Content="{ Binding Source={StaticResource downBlowingSystemUt}, Path=TAreas[0].Temperatures[0]}"/> Content="{ Binding Source={StaticResource downBlowingSystemUt}, Path=TAreas[0].Temperatures[0]}"/>
<ContentControl MinWidth="150" MinHeight="116" Margin="{StaticResource ControlMargin}" ContentTemplate="{StaticResource TmTemplate}" <ContentControl MinWidth="150" MinHeight="116" Margin="{StaticResource ControlMargin}" ContentTemplate="{StaticResource TmTemplate}"
Content="{ Binding Source={StaticResource downBlowingSystemUt}, Path=TAreas[1]}"/> Content="{ Binding Source={StaticResource downBlowingSystemUt}, Path=TAreas[1]}"/>
......
<NavigationWindow x:Class="FLY.DownBlowing.UI.Server.MainWindow" <NavigationWindow x:Class="FLY.DownBlowing.UI.Server.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" ResizeMode="NoResize" SizeToContent="WidthAndHeight" MinWidth="400" MinHeight="200" Title="MainWindow" SizeToContent="WidthAndHeight" MinWidth="400" MinHeight="200"
ShowsNavigationUI="False" ShowsNavigationUI="False"
Loaded="NavigationWindow_Loaded"> Loaded="NavigationWindow_Loaded">
</NavigationWindow> </NavigationWindow>
\ No newline at end of file
...@@ -11,9 +11,22 @@ ...@@ -11,9 +11,22 @@
<Page.Resources> <Page.Resources>
<local:TimeSpan2msConverter x:Key="timespan2msConv"/> <local:TimeSpan2msConverter x:Key="timespan2msConv"/>
<local:PgMainVmUt x:Key="viewModel"/> <local:PgMainVmUt x:Key="viewModel"/>
<Style TargetType="TextBlock" x:Key="TextBlockStyle_Led">
<Setter Property="Margin" Value="2"/>
<Setter Property="Text" Value="[x]"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Gray"/>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self} ,Path=Tag}" Value="true">
<Setter Property="Text" Value="[√]"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Background" Value="Yellow"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Page.Resources> </Page.Resources>
<Grid d:DataContext="{StaticResource viewModel}"> <Grid d:DataContext="{StaticResource viewModel}">
<StackPanel Margin="5"> <StackPanel Orientation="Horizontal" Margin="5">
<GroupBox Header="PLC" Margin="5"> <GroupBox Header="PLC" Margin="5">
<StackPanel> <StackPanel>
<ItemsControl x:Name="itemcontrol" ItemsSource="{Binding PLCs}"> <ItemsControl x:Name="itemcontrol" ItemsSource="{Binding PLCs}">
...@@ -61,16 +74,19 @@ ...@@ -61,16 +74,19 @@
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="旋转启动" /> <TextBlock Text="旋转启动" />
<TextBlock FontSize="20" Text="{Binding IsRotaryOn}"/> <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsRotaryOn}" />
</StackPanel> </StackPanel>
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="顺时针旋转(反)" /> <TextBlock Text="顺时针旋转(反)" />
<TextBlock FontSize="20" Text="{Binding IsBackw}"/> <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsBackw}" />
</StackPanel> </StackPanel>
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="逆时针旋转(正)" /> <TextBlock Text="逆时针旋转(正)" />
<TextBlock FontSize="20" Text="{Binding IsForw}"/> <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsForw}" />
</StackPanel> </StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="电机频率" /> <TextBlock Text="电机频率" />
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
...@@ -92,33 +108,55 @@ ...@@ -92,33 +108,55 @@
<TextBlock Text="p" VerticalAlignment="Bottom"/> <TextBlock Text="p" VerticalAlignment="Bottom"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="全局角度" />
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="20" Text="{Binding Angle,StringFormat={}{0:F0}}"/>
<TextBlock Text="°" VerticalAlignment="Top"/>
</StackPanel>
</StackPanel>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" > <StackPanel Orientation="Horizontal" >
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="换向信号0" /> <TextBlock Text="换向信号0" />
<TextBlock> <StackPanel Orientation="Horizontal">
<Run Text="{Binding IsTurnSign0}"/>[<Run FontSize="20" Text="{Binding RPosAtTurnSign0,StringFormat={}{0:F0}}"/>p] <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsTurnSign0}" />
<TextBlock><Run FontSize="20" Text="{Binding RPosAtTurnSign0,StringFormat={}{0:F0}}"/>p
(<Run FontSize="20" Text="{Binding TurnSign0Cnt}"/>) (<Run FontSize="20" Text="{Binding TurnSign0Cnt}"/>)
</TextBlock> </TextBlock>
</StackPanel>
</StackPanel> </StackPanel>
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="复位原点信号" /> <TextBlock Text="复位原点信号" />
<TextBlock> <StackPanel Orientation="Horizontal">
<Run Text="{Binding IsOrgSign}"/>[<Run FontSize="20" Text="{Binding RPosAtOrgSign,StringFormat={}{0:F0}}"/>p] <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsOrgSign}" />
</TextBlock> <TextBlock><Run FontSize="20" Text="{Binding RPosAtOrgSign,StringFormat={}{0:F0}}"/>p
</TextBlock>
</StackPanel>
</StackPanel> </StackPanel>
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="换向信号1" /> <TextBlock Text="换向信号1" />
<TextBlock> <StackPanel Orientation="Horizontal">
<Run Text="{Binding IsTurnSign1}"/>[<Run FontSize="20" Text="{Binding RPosAtTurnSign1,StringFormat={}{0:F0}}"/>p] <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsTurnSign1}" />
</TextBlock> <TextBlock><Run FontSize="20" Text="{Binding RPosAtTurnSign1,StringFormat={}{0:F0}}"/>p
</TextBlock>
</StackPanel>
</StackPanel> </StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="牵引速度" /> <TextBlock Text="牵引速度" />
<TextBlock> <TextBlock>
<Run FontSize="20" Text="{Binding TractionVelocity,StringFormat={}{0:F1}}"/>m/min <Run FontSize="20" Text="{Binding TractionVelocity,StringFormat={}{0:F1}}"/>m/min
</TextBlock> </TextBlock>
</StackPanel> </StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="1圈脉冲" />
<TextBlock>
<Run FontSize="20" Text="{Binding RPosOfR,StringFormat={}{0:F0}}"/>p
</TextBlock>
</StackPanel>
<Button Content="配置" Padding="20,5" Margin="5" HorizontalAlignment="Left" Click="btnRotaryClick"></Button> <Button Content="配置" Padding="20,5" Margin="5" HorizontalAlignment="Left" Click="btnRotaryClick"></Button>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
......
...@@ -5,15 +5,26 @@ ...@@ -5,15 +5,26 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FLY.DownBlowing.UI.Server" xmlns:local="clr-namespace:FLY.DownBlowing.UI.Server"
mc:Ignorable="d" mc:Ignorable="d"
Title="WdRotary" Height="101.4" Width="518.1"> Title="WdRotary" Height="300" Width="400">
<Grid> <Grid>
<StackPanel> <Grid.RowDefinitions>
<StackPanel Orientation="Horizontal"> <RowDefinition Height="auto"/>
<StackPanel Margin="5" x:Name="spRotary"> <RowDefinition/>
<CheckBox Content="反向" IsChecked="{Binding IsReversed}"/> </Grid.RowDefinitions>
</StackPanel> <StackPanel Orientation="Horizontal">
<Button Content="确定" Padding="20,5" Margin="5" Click="btnOkClick"/> <StackPanel Margin="5" x:Name="spRotary">
<CheckBox Content="反向" IsChecked="{Binding IsReversed}"/>
</StackPanel> </StackPanel>
<Button Content="确定" Padding="20,5" Margin="5" Click="btnOkClick"/>
</StackPanel> </StackPanel>
<DataGrid x:Name="dgSigns" Grid.Row="1" Margin="5" AutoGenerateColumns="False" IsReadOnly="True" >
<DataGrid.Columns>
<DataGridTextColumn Header="时间" Binding="{Binding Time,StringFormat={}{0:HH:mm:ss.f}}" />
<DataGridTextColumn Header="信号" Binding="{Binding No}" />
<DataGridTextColumn Header="全局脉冲" Binding="{Binding RPosGlobal,StringFormat={}{0:F0}}"/>
<DataGridTextColumn Header="相对脉冲" Binding="{Binding RPos,StringFormat={}{0:F0}}"/>
<DataGridTextColumn Header="频率(Hz)" Binding="{Binding RotaryFreqSet,StringFormat={}{0:F0}}"/>
</DataGrid.Columns>
</DataGrid>
</Grid> </Grid>
</Window> </Window>
...@@ -31,6 +31,7 @@ namespace FLY.DownBlowing.UI.Server ...@@ -31,6 +31,7 @@ namespace FLY.DownBlowing.UI.Server
{ {
this.rotarySystem = rotarySystem; this.rotarySystem = rotarySystem;
spRotary.DataContext = rotarySystem; spRotary.DataContext = rotarySystem;
dgSigns.ItemsSource = rotarySystem.Signs;
} }
private void btnOkClick(object sender, RoutedEventArgs e) private void btnOkClick(object sender, RoutedEventArgs e)
{ {
......
...@@ -57,7 +57,7 @@ namespace FLY.DownBlowing.Server ...@@ -57,7 +57,7 @@ namespace FLY.DownBlowing.Server
private PLCProxySystem plcos = new PLCProxySystem(); public PLCProxySystem plcos = new PLCProxySystem();
/// <summary> /// <summary>
/// PLC代理系统 /// PLC代理系统
/// </summary> /// </summary>
...@@ -117,6 +117,17 @@ namespace FLY.DownBlowing.Server ...@@ -117,6 +117,17 @@ namespace FLY.DownBlowing.Server
//step 3 历史数据记录 //step 3 历史数据记录
//添加任务 //添加任务
PLCos.SetPlan(nameof(WinderData), new string[] {
nameof(WinderData.IsRotaryOn),
nameof(WinderData.T1Velocity),
nameof(WinderData.RotaryFreqSet),
nameof(WinderData.RotaryFreq),
nameof(WinderData.IsRotaryForw),
nameof(WinderData.IsRotaryBackw),
nameof(WinderData.IsRotaryBackwTurn),
nameof(WinderData.IsRotaryForwTurn),
nameof(WinderData.IsRotaryOrgSign)
}, 0);
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
//last step PLC 更新计划服务初始化 //last step PLC 更新计划服务初始化
......
using FLY.DownBlowing.Common; 
using FLY.Thick.Blowing.RotaryMachine.IService; using FLY.Thick.Blowing.RotaryMachine.IService;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
...@@ -11,6 +11,8 @@ using System.Text; ...@@ -11,6 +11,8 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Threading; using System.Windows.Threading;
using WinderAccessory = FLY.DownBlowing.Common.WinderData;
namespace FLY.DownBlowing.Server namespace FLY.DownBlowing.Server
{ {
public class RotarySystem : IRotarySerivce public class RotarySystem : IRotarySerivce
...@@ -65,6 +67,11 @@ namespace FLY.DownBlowing.Server ...@@ -65,6 +67,11 @@ namespace FLY.DownBlowing.Server
/// </summary> /// </summary>
public double RPosAtOrgSign { get; set; } = double.NaN; public double RPosAtOrgSign { get; set; } = double.NaN;
/// <summary>
/// 从换向信号1 到 原点信号, 灭到亮 发生时, 旋转架脉冲 (中值)
/// </summary>
public double RPosAtOrgSign1 { get; set; } = double.NaN;
/// <summary> /// <summary>
/// 旋转塔逆时针换向信号发生时, 旋转架脉冲(大值) /// 旋转塔逆时针换向信号发生时, 旋转架脉冲(大值)
/// </summary> /// </summary>
...@@ -74,6 +81,9 @@ namespace FLY.DownBlowing.Server ...@@ -74,6 +81,9 @@ namespace FLY.DownBlowing.Server
///旋转架全局脉冲, 当前旋转架脉冲 = GlobalRPos - OrgRPos; ///旋转架全局脉冲, 当前旋转架脉冲 = GlobalRPos - OrgRPos;
/// </summary> /// </summary>
public double RPosGlobal { get; set; } = 0; public double RPosGlobal { get; set; } = 0;
public double RPosOfR { get; set; } = 10000;
public double Angle { get; set; }
/// <summary> /// <summary>
/// 旋转塔开启指示 /// 旋转塔开启指示
...@@ -87,7 +97,10 @@ namespace FLY.DownBlowing.Server ...@@ -87,7 +97,10 @@ namespace FLY.DownBlowing.Server
#endregion #endregion
public int TurnSign0Cnt { get; set; } public int TurnSign0Cnt { get; set; }
WinderData winderAccessory;
public List<SignCell> Signs = new List<SignCell>();
WinderAccessory winderAccessory;
DispatcherTimer dispatcherTimer; DispatcherTimer dispatcherTimer;
Stopwatch stopwatch_rpos; Stopwatch stopwatch_rpos;
...@@ -95,7 +108,7 @@ namespace FLY.DownBlowing.Server ...@@ -95,7 +108,7 @@ namespace FLY.DownBlowing.Server
{ {
} }
public void Init(WinderData _winderAccessory) public void Init(WinderAccessory _winderAccessory)
{ {
winderAccessory = _winderAccessory; winderAccessory = _winderAccessory;
...@@ -109,27 +122,14 @@ namespace FLY.DownBlowing.Server ...@@ -109,27 +122,14 @@ namespace FLY.DownBlowing.Server
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryOn), this, nameof(IsRotaryOn)); Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryOn), this, nameof(IsRotaryOn));
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryForw), () => Misc.BindingOperations.SetBinding(winderAccessory,
{ new string[]{
IsForw = (!IsReversed) ? winderAccessory.IsRotaryForw : winderAccessory.IsRotaryBackw; nameof(winderAccessory.IsRotaryForw),
IsBackw = (!IsReversed) ? winderAccessory.IsRotaryBackw : winderAccessory.IsRotaryForw; nameof(winderAccessory.IsRotaryBackw),
}); nameof(winderAccessory.IsRotaryForwTurn),
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryBackw), () => nameof(winderAccessory.IsRotaryBackwTurn)},
{ updateSign);
IsForw = (!IsReversed) ? winderAccessory.IsRotaryForw : winderAccessory.IsRotaryBackw;
IsBackw = (!IsReversed) ? winderAccessory.IsRotaryBackw : winderAccessory.IsRotaryForw;
});
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryForwTurn), () =>
{
IsTurnSign1 = (!IsReversed) ? winderAccessory.IsRotaryForwTurn : winderAccessory.IsRotaryBackwTurn;
IsTurnSign0 = (!IsReversed) ? winderAccessory.IsRotaryBackwTurn : winderAccessory.IsRotaryForwTurn;
});
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryBackwTurn), () =>
{
IsTurnSign1 = (!IsReversed) ? winderAccessory.IsRotaryForwTurn : winderAccessory.IsRotaryBackwTurn;
IsTurnSign0 = (!IsReversed) ? winderAccessory.IsRotaryBackwTurn : winderAccessory.IsRotaryForwTurn;
});
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryOrgSign), this, nameof(IsOrgSign)); Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryOrgSign), this, nameof(IsOrgSign));
...@@ -150,6 +150,23 @@ namespace FLY.DownBlowing.Server ...@@ -150,6 +150,23 @@ namespace FLY.DownBlowing.Server
dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.Tick += DispatcherTimer_Tick;
stopwatch_rpos = new Stopwatch(); stopwatch_rpos = new Stopwatch();
} }
void updateSign()
{
if (!IsReversed)
{
IsForw = winderAccessory.IsRotaryForw;
IsBackw = winderAccessory.IsRotaryBackw;
IsTurnSign0 = winderAccessory.IsRotaryForwTurn;
IsTurnSign1 = winderAccessory.IsRotaryBackwTurn;
}
else
{
IsForw = winderAccessory.IsRotaryBackw;
IsBackw = winderAccessory.IsRotaryForw;
IsTurnSign0 = winderAccessory.IsRotaryBackwTurn;
IsTurnSign1 = winderAccessory.IsRotaryForwTurn;
}
}
void updateRSpeed() void updateRSpeed()
{ {
if (IsForw) if (IsForw)
...@@ -182,6 +199,10 @@ namespace FLY.DownBlowing.Server ...@@ -182,6 +199,10 @@ namespace FLY.DownBlowing.Server
return; return;
} }
RPosGlobal += RSpeed * totalSeconds; RPosGlobal += RSpeed * totalSeconds;
double p = RPosGlobal - RPosAtTurnSign0;
Angle = 360 * (p - RPosOfR / 2) / RPosOfR;
} }
public void StartMeasureRPos() public void StartMeasureRPos()
...@@ -195,42 +216,66 @@ namespace FLY.DownBlowing.Server ...@@ -195,42 +216,66 @@ namespace FLY.DownBlowing.Server
dispatcherTimer.Stop(); dispatcherTimer.Stop();
} }
void AddSign(SignCell sign)
{
Signs.Insert(0, sign);
while (Signs.Count > 100)
Signs.RemoveAt(Signs.Count() - 1);
}
void AddSign(int no)
{
AddSign(new SignCell() { No = no, RPosGlobal = RPosGlobal, Time = DateTime.Now, RPos = RPosGlobal - RPosAtTurnSign0, RotaryFreqSet = RotaryFreqSet });
}
private void RotarySystem_PropertyChanged(object sender, PropertyChangedEventArgs e) private void RotarySystem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == nameof(IsReversed)) if (e.PropertyName == nameof(IsReversed))
{ {
IsForw = (!IsReversed) ? winderAccessory.IsRotaryForw : winderAccessory.IsRotaryBackw; updateSign();
IsBackw = (!IsReversed) ? winderAccessory.IsRotaryBackw : winderAccessory.IsRotaryForw;
IsTurnSign0 = (!IsReversed) ? winderAccessory.IsRotaryBackwTurn : winderAccessory.IsRotaryForwTurn;
IsTurnSign1 = (!IsReversed) ? winderAccessory.IsRotaryForwTurn : winderAccessory.IsRotaryBackwTurn;
} }
else if (e.PropertyName == nameof(IsTurnSign0)) else if (e.PropertyName == nameof(IsTurnSign0))
{ {
if (IsTurnSign0) if (IsTurnSign0)
{ {
RPosAtTurnSign0 = RPosGlobal; RPosAtTurnSign0 = RPosGlobal;
AddSign(0);
TurnSign0Cnt++; TurnSign0Cnt++;
} }
} }
else if (e.PropertyName == nameof(IsTurnSign1)) else if (e.PropertyName == nameof(IsTurnSign1))
{ {
if (IsTurnSign1) if (IsTurnSign1)
{
RPosAtTurnSign1 = RPosGlobal; RPosAtTurnSign1 = RPosGlobal;
RPosOfR = RPosAtTurnSign1 - RPosAtTurnSign0;
AddSign(1);
}
} }
else if (e.PropertyName == nameof(IsOrgSign)) else if (e.PropertyName == nameof(IsOrgSign))
{ {
if (IsOrgSign) if (IsForw)
{ {
if (IsForw) if (IsOrgSign)
{ {
RPosAtOrgSign = RPosGlobal; RPosAtOrgSign = RPosGlobal;
AddSign(20);
}
else
{
RPosAtOrgSign1 = RPosGlobal;
AddSign(21);
} }
} }
else else if (IsBackw)
{ {
if (IsBackw) if (IsOrgSign)
{
RPosAtOrgSign1 = RPosGlobal;
AddSign(21);
}
else if (!IsOrgSign)
{ {
RPosAtOrgSign = RPosGlobal; RPosAtOrgSign = RPosGlobal;
AddSign(20);
} }
} }
} }
...@@ -309,5 +354,34 @@ namespace FLY.DownBlowing.Server ...@@ -309,5 +354,34 @@ namespace FLY.DownBlowing.Server
public bool IsReversed = true; public bool IsReversed = true;
} }
public class SignCell : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 信号
/// </summary>
public int No { get; set; }
/// <summary>
/// 全局脉冲
/// </summary>
public double RPosGlobal { get; set; }
/// <summary>
/// 时间
/// </summary>
public DateTime Time { get; set; }
/// <summary>
/// 相对脉冲
/// </summary>
public double RPos { get; set; }
/// <summary>
/// 旋转频率设置Hz
/// </summary>
public double RotaryFreqSet { get; set; }
}
} }
...@@ -73,8 +73,10 @@ namespace FLY.DownBlowing.Server ...@@ -73,8 +73,10 @@ namespace FLY.DownBlowing.Server
rotarySystem.Init(mData.WinderData); rotarySystem.Init(mData.WinderData);
Misc.BindingOperations.SetBinding(mData.PLCos, nameof(IPLCProxySystemService.IsConnectedWithPLC), () => {
if (mData.PLCos.IsConnectedWithPLC) Misc.BindingOperations.SetBinding(
mData.plcos.PLCs[0].Client, nameof(Modbus.WithThread.ClientTCP.IsConnected), () => {
if (mData.plcos.PLCs[0].Client.IsConnected)
rotarySystem.StartMeasureRPos(); rotarySystem.StartMeasureRPos();
else else
rotarySystem.StopMeasureRPos(); rotarySystem.StopMeasureRPos();
......
...@@ -50,17 +50,21 @@ namespace FLY.Thick.Blowing.RotaryMachine.Client ...@@ -50,17 +50,21 @@ namespace FLY.Thick.Blowing.RotaryMachine.Client
public double RSpeed { get; set; } public double RSpeed { get; set; }
/// <summary> /// <summary>
/// 旋转塔顺时针换向信号发生时, 旋转架脉冲 (小值) /// 换向信号0发生时, 旋转架脉冲 (小值)
/// </summary> /// </summary>
public double RPosAtTurnSign0 { get; set; } public double RPosAtTurnSign0 { get; set; }
/// <summary> /// <summary>
/// 旋转塔顺复位原点信号发生时, 旋转架脉冲 (中值) /// 从换向信号0 到 原点信号, 灭到亮 发生时, 旋转架脉冲 (中值)
/// </summary> /// </summary>
public double RPosAtOrgSign { get; set; } public double RPosAtOrgSign { get; set; }
/// <summary>
/// 从换向信号1 到 原点信号, 灭到亮 发生时, 旋转架脉冲 (中值)
/// </summary>
public double RPosAtOrgSign1 { get; set; }
/// <summary> /// <summary>
/// 旋转塔逆时针换向信号发生时, 旋转架脉冲(大值) /// 换向信号1 发生时, 旋转架脉冲(大值)
/// </summary> /// </summary>
public double RPosAtTurnSign1 { get; set; } public double RPosAtTurnSign1 { get; set; }
......
...@@ -46,17 +46,21 @@ namespace FLY.Thick.Blowing.RotaryMachine.IService ...@@ -46,17 +46,21 @@ namespace FLY.Thick.Blowing.RotaryMachine.IService
double RSpeed { get; } double RSpeed { get; }
/// <summary> /// <summary>
/// 旋转塔顺时针换向信号发生时, 旋转架脉冲 (小值) /// 换向信号0发生时, 旋转架脉冲 (小值)
/// </summary> /// </summary>
double RPosAtTurnSign0 { get; } double RPosAtTurnSign0 { get; }
/// <summary> /// <summary>
/// 旋转塔顺复位原点信号发生时, 旋转架脉冲 (中值) /// 从换向信号0 到 原点信号, 灭到亮 发生时, 旋转架脉冲 (中值)
/// </summary> /// </summary>
double RPosAtOrgSign { get; } double RPosAtOrgSign { get; }
/// <summary>
/// 从换向信号1 到 原点信号, 灭到亮 发生时, 旋转架脉冲 (中值)
/// </summary>
double RPosAtOrgSign1 { get; }
/// <summary> /// <summary>
/// 旋转塔逆时针换向信号发生时, 旋转架脉冲(大值) /// 换向信号1发生时, 旋转架脉冲(大值)
/// </summary> /// </summary>
double RPosAtTurnSign1 { get; } double RPosAtTurnSign1 { get; }
......
...@@ -51,6 +51,6 @@ using System.Windows; ...@@ -51,6 +51,6 @@ using System.Windows;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示: //通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.2")] [assembly: AssemblyVersion("7.0.3")]
[assembly: AssemblyFileVersion("7.0.2")] [assembly: AssemblyFileVersion("7.0.3")]
[assembly: Guid("38E0D8EC-4D1C-49FF-AB08-6289294C5BD4")] [assembly: Guid("38E0D8EC-4D1C-49FF-AB08-6289294C5BD4")]
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<NavigationWindow x:Class="FLY.Winder.UI.Server.MainWindow" <NavigationWindow x:Class="FLY.Winder.UI.Server.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" ResizeMode="NoResize" SizeToContent="WidthAndHeight" MinWidth="400" MinHeight="200" Title="MainWindow" SizeToContent="WidthAndHeight" MinWidth="400" MinHeight="200"
ShowsNavigationUI="False" ShowsNavigationUI="False"
Loaded="NavigationWindow_Loaded"> Loaded="NavigationWindow_Loaded">
</NavigationWindow> </NavigationWindow>
...@@ -8,9 +8,22 @@ ...@@ -8,9 +8,22 @@
Title="PgMain" > Title="PgMain" >
<Page.Resources> <Page.Resources>
<local:PgMainVmUt x:Key="viewModel"/> <local:PgMainVmUt x:Key="viewModel"/>
<Style TargetType="TextBlock" x:Key="TextBlockStyle_Led">
<Setter Property="Margin" Value="2"/>
<Setter Property="Text" Value="[x]"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Gray"/>
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self} ,Path=Tag}" Value="true">
<Setter Property="Text" Value="[√]"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="Background" Value="Yellow"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Page.Resources> </Page.Resources>
<Grid d:DataContext="{StaticResource viewModel}"> <Grid d:DataContext="{StaticResource viewModel}">
<StackPanel Margin="5"> <StackPanel Orientation="Horizontal" Margin="5">
<GroupBox Header="PLC" Margin="5"> <GroupBox Header="PLC" Margin="5">
<StackPanel> <StackPanel>
<ItemsControl x:Name="itemcontrol" ItemsSource="{Binding PLCs}"> <ItemsControl x:Name="itemcontrol" ItemsSource="{Binding PLCs}">
...@@ -55,19 +68,22 @@ ...@@ -55,19 +68,22 @@
<GroupBox x:Name="gbRotary" Header="旋转架" Margin="5"> <GroupBox x:Name="gbRotary" Header="旋转架" Margin="5">
<StackPanel> <StackPanel>
<StackPanel Orientation="Horizontal" > <StackPanel Orientation="Horizontal" >
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="旋转启动" /> <TextBlock Text="旋转启动" />
<TextBlock FontSize="20" Text="{Binding IsRotaryOn}"/> <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsRotaryOn}" />
</StackPanel> </StackPanel>
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="顺时针旋转(反)" /> <TextBlock Text="顺时针旋转(反)" />
<TextBlock FontSize="20" Text="{Binding IsBackw}"/> <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsBackw}" />
</StackPanel> </StackPanel>
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="逆时针旋转(正)" /> <TextBlock Text="逆时针旋转(正)" />
<TextBlock FontSize="20" Text="{Binding IsForw}"/> <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsForw}" />
</StackPanel> </StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="电机频率" /> <TextBlock Text="电机频率" />
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
...@@ -89,33 +105,55 @@ ...@@ -89,33 +105,55 @@
<TextBlock Text="p" VerticalAlignment="Bottom"/> <TextBlock Text="p" VerticalAlignment="Bottom"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="全局角度" />
<StackPanel Orientation="Horizontal">
<TextBlock FontSize="20" Text="{Binding Angle,StringFormat={}{0:F0}}"/>
<TextBlock Text="°" VerticalAlignment="Top"/>
</StackPanel>
</StackPanel>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" > <StackPanel Orientation="Horizontal" >
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="换向信号0" /> <TextBlock Text="换向信号0" />
<TextBlock> <StackPanel Orientation="Horizontal">
<Run Text="{Binding IsTurnSign0}"/>[<Run FontSize="20" Text="{Binding RPosAtTurnSign0,StringFormat={}{0:F0}}"/>p] <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsTurnSign0}" />
<TextBlock><Run FontSize="20" Text="{Binding RPosAtTurnSign0,StringFormat={}{0:F0}}"/>p
(<Run FontSize="20" Text="{Binding TurnSign0Cnt}"/>) (<Run FontSize="20" Text="{Binding TurnSign0Cnt}"/>)
</TextBlock> </TextBlock>
</StackPanel>
</StackPanel> </StackPanel>
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="复位原点信号" /> <TextBlock Text="复位原点信号" />
<TextBlock> <StackPanel Orientation="Horizontal">
<Run Text="{Binding IsOrgSign}"/>[<Run FontSize="20" Text="{Binding RPosAtOrgSign,StringFormat={}{0:F0}}"/>p] <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsOrgSign}" />
</TextBlock> <TextBlock><Run FontSize="20" Text="{Binding RPosAtOrgSign,StringFormat={}{0:F0}}"/>p
</TextBlock>
</StackPanel>
</StackPanel> </StackPanel>
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="换向信号1" /> <TextBlock Text="换向信号1" />
<TextBlock> <StackPanel Orientation="Horizontal">
<Run Text="{Binding IsTurnSign1}"/>[<Run FontSize="20" Text="{Binding RPosAtTurnSign1,StringFormat={}{0:F0}}"/>p] <TextBlock Style="{StaticResource TextBlockStyle_Led}" Tag="{Binding IsTurnSign1}" />
</TextBlock> <TextBlock><Run FontSize="20" Text="{Binding RPosAtTurnSign1,StringFormat={}{0:F0}}"/>p
</TextBlock>
</StackPanel>
</StackPanel> </StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<StackPanel Margin="4" > <StackPanel Margin="4" >
<TextBlock Text="牵引速度" /> <TextBlock Text="牵引速度" />
<TextBlock> <TextBlock>
<Run FontSize="20" Text="{Binding TractionVelocity,StringFormat={}{0:F1}}"/>m/min <Run FontSize="20" Text="{Binding TractionVelocity,StringFormat={}{0:F1}}"/>m/min
</TextBlock> </TextBlock>
</StackPanel> </StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="1圈脉冲" />
<TextBlock>
<Run FontSize="20" Text="{Binding RPosOfR,StringFormat={}{0:F0}}"/>p
</TextBlock>
</StackPanel>
<Button Content="配置" Padding="20,5" Margin="5" HorizontalAlignment="Left" Click="btnRotaryClick"></Button> <Button Content="配置" Padding="20,5" Margin="5" HorizontalAlignment="Left" Click="btnRotaryClick"></Button>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
......
...@@ -12,7 +12,7 @@ using System.Windows; ...@@ -12,7 +12,7 @@ using System.Windows;
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("佛山市枫莱尔自动化技术有限公司")] [assembly: AssemblyCompany("佛山市枫莱尔自动化技术有限公司")]
[assembly: AssemblyProduct("收卷服务器")] [assembly: AssemblyProduct("收卷服务器")]
[assembly: AssemblyCopyright("Copyright © 2021 FlyAutomation")] [assembly: AssemblyCopyright("Copyright © 2022 FlyAutomation")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
...@@ -51,6 +51,6 @@ using System.Windows; ...@@ -51,6 +51,6 @@ using System.Windows;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: : // 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.2.0")] [assembly: AssemblyVersion("7.0.4.0")]
[assembly: AssemblyFileVersion("7.0.2.0")] [assembly: AssemblyFileVersion("7.0.4.0")]
[assembly: Guid("0CE35EA7-927A-41C0-9DC6-80511329760B")] [assembly: Guid("0CE35EA7-927A-41C0-9DC6-80511329760B")]
...@@ -5,9 +5,13 @@ ...@@ -5,9 +5,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FLY.Winder.UI.Server" xmlns:local="clr-namespace:FLY.Winder.UI.Server"
mc:Ignorable="d" mc:Ignorable="d"
Title="WdRotary" Height="101.4" Width="518.1"> Title="WdRotary" Height="300" Width="400">
<Grid> <Grid>
<StackPanel> <Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<StackPanel Margin="5" x:Name="spRotary"> <StackPanel Margin="5" x:Name="spRotary">
<CheckBox Content="反向" IsChecked="{Binding IsReversed}"/> <CheckBox Content="反向" IsChecked="{Binding IsReversed}"/>
...@@ -15,5 +19,16 @@ ...@@ -15,5 +19,16 @@
<Button Content="确定" Padding="20,5" Margin="5" Click="btnOkClick"/> <Button Content="确定" Padding="20,5" Margin="5" Click="btnOkClick"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<DataGrid x:Name="dgSigns" Grid.Row="1" Margin="5" AutoGenerateColumns="False" IsReadOnly="True" >
<DataGrid.Columns>
<DataGridTextColumn Header="时间" Binding="{Binding Time,StringFormat={}{0:HH:mm:ss.f}}" />
<DataGridTextColumn Header="信号" Binding="{Binding No}" />
<DataGridTextColumn Header="全局脉冲" Binding="{Binding RPosGlobal,StringFormat={}{0:F0}}"/>
<DataGridTextColumn Header="相对脉冲" Binding="{Binding RPos,StringFormat={}{0:F0}}"/>
<DataGridTextColumn Header="频率(Hz)" Binding="{Binding RotaryFreqSet,StringFormat={}{0:F0}}"/>
</DataGrid.Columns>
</DataGrid>
</Grid> </Grid>
</Window> </Window>
...@@ -30,10 +30,16 @@ namespace FLY.Winder.UI.Server ...@@ -30,10 +30,16 @@ namespace FLY.Winder.UI.Server
{ {
this.rotarySystem = rotarySystem; this.rotarySystem = rotarySystem;
spRotary.DataContext = rotarySystem; spRotary.DataContext = rotarySystem;
dgSigns.ItemsSource = rotarySystem.Signs;
} }
private void btnOkClick(object sender, RoutedEventArgs e) private void btnOkClick(object sender, RoutedEventArgs e)
{ {
rotarySystem.Save(); rotarySystem.Save();
} }
private void btnApplyClick(object sender, RoutedEventArgs e)
{
}
} }
} }
...@@ -65,6 +65,11 @@ namespace FLY.Winder.Server ...@@ -65,6 +65,11 @@ namespace FLY.Winder.Server
/// </summary> /// </summary>
public double RPosAtOrgSign { get; set; } = double.NaN; public double RPosAtOrgSign { get; set; } = double.NaN;
/// <summary>
/// 从换向信号1 到 原点信号, 灭到亮 发生时, 旋转架脉冲 (中值)
/// </summary>
public double RPosAtOrgSign1 { get; set; } = double.NaN;
/// <summary> /// <summary>
/// 旋转塔逆时针换向信号发生时, 旋转架脉冲(大值) /// 旋转塔逆时针换向信号发生时, 旋转架脉冲(大值)
/// </summary> /// </summary>
...@@ -74,6 +79,9 @@ namespace FLY.Winder.Server ...@@ -74,6 +79,9 @@ namespace FLY.Winder.Server
///旋转架全局脉冲, 当前旋转架脉冲 = GlobalRPos - OrgRPos; ///旋转架全局脉冲, 当前旋转架脉冲 = GlobalRPos - OrgRPos;
/// </summary> /// </summary>
public double RPosGlobal { get; set; } = 0; public double RPosGlobal { get; set; } = 0;
public double RPosOfR { get; set; } = 10000;
public double Angle { get; set; }
/// <summary> /// <summary>
/// 旋转塔开启指示 /// 旋转塔开启指示
...@@ -87,12 +95,16 @@ namespace FLY.Winder.Server ...@@ -87,12 +95,16 @@ namespace FLY.Winder.Server
#endregion #endregion
public int TurnSign0Cnt { get; set; } public int TurnSign0Cnt { get; set; }
public List<SignCell> Signs = new List<SignCell>();
WinderAccessory winderAccessory; WinderAccessory winderAccessory;
DispatcherTimer dispatcherTimer; DispatcherTimer dispatcherTimer;
Stopwatch stopwatch_rpos; Stopwatch stopwatch_rpos;
public RotarySystem() { public RotarySystem()
{
} }
public void Init(WinderAccessory _winderAccessory) public void Init(WinderAccessory _winderAccessory)
{ {
...@@ -108,27 +120,14 @@ namespace FLY.Winder.Server ...@@ -108,27 +120,14 @@ namespace FLY.Winder.Server
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryOn), this, nameof(IsRotaryOn)); Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryOn), this, nameof(IsRotaryOn));
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryForw), () => Misc.BindingOperations.SetBinding(winderAccessory,
{ new string[]{
IsForw = (!IsReversed) ? winderAccessory.IsRotaryForw : winderAccessory.IsRotaryBackw; nameof(winderAccessory.IsRotaryForw),
IsBackw = (!IsReversed) ? winderAccessory.IsRotaryBackw : winderAccessory.IsRotaryForw; nameof(winderAccessory.IsRotaryBackw),
}); nameof(winderAccessory.IsRotaryForwTurn),
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryBackw), () => nameof(winderAccessory.IsRotaryBackwTurn)},
{ updateSign);
IsForw = (!IsReversed) ? winderAccessory.IsRotaryForw : winderAccessory.IsRotaryBackw;
IsBackw = (!IsReversed) ? winderAccessory.IsRotaryBackw : winderAccessory.IsRotaryForw;
});
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryForwTurn), () =>
{
IsTurnSign1 = (!IsReversed) ? winderAccessory.IsRotaryForwTurn : winderAccessory.IsRotaryBackwTurn;
IsTurnSign0 = (!IsReversed) ? winderAccessory.IsRotaryBackwTurn : winderAccessory.IsRotaryForwTurn;
});
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryBackwTurn), () =>
{
IsTurnSign1 = (!IsReversed) ? winderAccessory.IsRotaryForwTurn : winderAccessory.IsRotaryBackwTurn;
IsTurnSign0 = (!IsReversed) ? winderAccessory.IsRotaryBackwTurn : winderAccessory.IsRotaryForwTurn;
});
Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryOrgSign), this, nameof(IsOrgSign)); Misc.BindingOperations.SetBinding(winderAccessory, nameof(winderAccessory.IsRotaryOrgSign), this, nameof(IsOrgSign));
...@@ -149,7 +148,24 @@ namespace FLY.Winder.Server ...@@ -149,7 +148,24 @@ namespace FLY.Winder.Server
dispatcherTimer.Tick += DispatcherTimer_Tick; dispatcherTimer.Tick += DispatcherTimer_Tick;
stopwatch_rpos = new Stopwatch(); stopwatch_rpos = new Stopwatch();
} }
void updateRSpeed() void updateSign()
{
if (!IsReversed)
{
IsForw = winderAccessory.IsRotaryForw;
IsBackw = winderAccessory.IsRotaryBackw;
IsTurnSign0 = winderAccessory.IsRotaryForwTurn;
IsTurnSign1 = winderAccessory.IsRotaryBackwTurn;
}
else
{
IsForw = winderAccessory.IsRotaryBackw;
IsBackw = winderAccessory.IsRotaryForw;
IsTurnSign0 = winderAccessory.IsRotaryBackwTurn;
IsTurnSign1 = winderAccessory.IsRotaryForwTurn;
}
}
void updateRSpeed()
{ {
if (IsForw) if (IsForw)
{ {
...@@ -169,66 +185,95 @@ namespace FLY.Winder.Server ...@@ -169,66 +185,95 @@ namespace FLY.Winder.Server
double totalSeconds = stopwatch_rpos.Elapsed.TotalSeconds; double totalSeconds = stopwatch_rpos.Elapsed.TotalSeconds;
stopwatch_rpos.Restart(); stopwatch_rpos.Restart();
if (!IsBackw && !IsForw) if (!IsBackw && !IsForw)
{ {
//没有运行 //没有运行
return; return;
} }
if (IsTurnSign0 || IsTurnSign1) { if (IsTurnSign0 || IsTurnSign1)
{
//转向信号触发时, 脉冲没有变化 //转向信号触发时, 脉冲没有变化
return; return;
} }
RPosGlobal += RSpeed * totalSeconds; RPosGlobal += RSpeed * totalSeconds;
double p = RPosGlobal - RPosAtTurnSign0;
Angle = 360 * (p - RPosOfR / 2) / RPosOfR;
} }
public void StartMeasureRPos() public void StartMeasureRPos()
{ {
stopwatch_rpos.Restart(); stopwatch_rpos.Restart();
dispatcherTimer.Start(); dispatcherTimer.Start();
} }
public void StopMeasureRPos() public void StopMeasureRPos()
{ {
stopwatch_rpos.Stop(); stopwatch_rpos.Stop();
dispatcherTimer.Stop(); dispatcherTimer.Stop();
} }
void AddSign(SignCell sign)
{
Signs.Insert(0, sign);
while (Signs.Count > 100)
Signs.RemoveAt(Signs.Count() - 1);
}
void AddSign(int no)
{
AddSign(new SignCell() { No = no, RPosGlobal = RPosGlobal, Time = DateTime.Now, RPos = RPosGlobal - RPosAtTurnSign0, RotaryFreqSet = RotaryFreqSet });
}
private void RotarySystem_PropertyChanged(object sender, PropertyChangedEventArgs e) private void RotarySystem_PropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
if (e.PropertyName == nameof(IsReversed)) if (e.PropertyName == nameof(IsReversed))
{ {
IsForw = (!IsReversed) ? winderAccessory.IsRotaryForw : winderAccessory.IsRotaryBackw; updateSign();
IsBackw = (!IsReversed) ? winderAccessory.IsRotaryBackw : winderAccessory.IsRotaryForw;
IsTurnSign0 = (!IsReversed) ? winderAccessory.IsRotaryBackwTurn : winderAccessory.IsRotaryForwTurn;
IsTurnSign1 = (!IsReversed) ? winderAccessory.IsRotaryForwTurn : winderAccessory.IsRotaryBackwTurn;
} }
else if (e.PropertyName == nameof(IsTurnSign0)) else if (e.PropertyName == nameof(IsTurnSign0))
{ {
if (IsTurnSign0) if (IsTurnSign0)
{ {
RPosAtTurnSign0 = RPosGlobal; RPosAtTurnSign0 = RPosGlobal;
AddSign(0);
TurnSign0Cnt++; TurnSign0Cnt++;
} }
} }
else if (e.PropertyName == nameof(IsTurnSign1)) else if (e.PropertyName == nameof(IsTurnSign1))
{ {
if (IsTurnSign1) if (IsTurnSign1)
{
RPosAtTurnSign1 = RPosGlobal; RPosAtTurnSign1 = RPosGlobal;
RPosOfR = RPosAtTurnSign1 - RPosAtTurnSign0;
AddSign(1);
}
} }
else if (e.PropertyName == nameof(IsOrgSign)) else if (e.PropertyName == nameof(IsOrgSign))
{ {
if (IsOrgSign) if (IsForw)
{ {
if (IsForw) if (IsOrgSign)
{ {
RPosAtOrgSign = RPosGlobal; RPosAtOrgSign = RPosGlobal;
AddSign(20);
}
else
{
RPosAtOrgSign1 = RPosGlobal;
AddSign(21);
} }
} }
else else if (IsBackw)
{ {
if (IsBackw) if (IsOrgSign)
{
RPosAtOrgSign1 = RPosGlobal;
AddSign(21);
}
else if (!IsOrgSign)
{ {
RPosAtOrgSign = RPosGlobal; RPosAtOrgSign = RPosGlobal;
AddSign(20);
} }
} }
} }
...@@ -236,7 +281,8 @@ namespace FLY.Winder.Server ...@@ -236,7 +281,8 @@ namespace FLY.Winder.Server
{ {
updateRSpeed(); updateRSpeed();
} }
else if (e.PropertyName == nameof(IsBackw)) { else if (e.PropertyName == nameof(IsBackw))
{
updateRSpeed(); updateRSpeed();
} }
} }
...@@ -245,7 +291,8 @@ namespace FLY.Winder.Server ...@@ -245,7 +291,8 @@ namespace FLY.Winder.Server
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
public bool Save() { public bool Save()
{
return RotarySystemJsonDb.Save(this, filePath); return RotarySystemJsonDb.Save(this, filePath);
} }
bool Load() bool Load()
...@@ -305,5 +352,35 @@ namespace FLY.Winder.Server ...@@ -305,5 +352,35 @@ namespace FLY.Winder.Server
public bool IsReversed = true; public bool IsReversed = true;
} }
public class SignCell : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 信号
/// </summary>
public int No { get; set; }
/// <summary>
/// 全局脉冲
/// </summary>
public double RPosGlobal { get; set; }
/// <summary>
/// 时间
/// </summary>
public DateTime Time { get; set; }
/// <summary>
/// 相对脉冲
/// </summary>
public double RPos { get; set; }
/// <summary>
/// 旋转频率设置Hz
/// </summary>
public double RotaryFreqSet { get; set; }
}
} }
...@@ -114,6 +114,7 @@ namespace FLY.Winder.Server ...@@ -114,6 +114,7 @@ namespace FLY.Winder.Server
nameof(Accessory.Traction2TensionKg), nameof(Accessory.Traction2TensionKg),
nameof(Accessory.RotaryCurrent), nameof(Accessory.RotaryCurrent),
nameof(Accessory.RotaryFreq), nameof(Accessory.RotaryFreq),
nameof(Accessory.RotaryFreqSet),
nameof(Accessory.IsRotaryForw), nameof(Accessory.IsRotaryForw),
nameof(Accessory.IsRotaryBackw), nameof(Accessory.IsRotaryBackw),
......
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