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

模拟器添加倍加德旋转PLC模拟

parent 990c4363
using System; using FLY.Simulation.Blowing;
using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
...@@ -18,12 +19,18 @@ namespace BlowingSimulator ...@@ -18,12 +19,18 @@ namespace BlowingSimulator
//AD盒对外接口 //AD盒对外接口
FLY.Simulation.Flyad7.OBJProxy.Flyad7_OBJProxy flyad7objproxy; FLY.Simulation.Flyad7.OBJProxy.Flyad7_OBJProxy flyad7objproxy;
//风环PLC //和美风环PLC
FLY.Simulation.Blowing.AirRingPlc plcLink; FLY.Simulation.Blowing.HeMeiAirRingPlc heMeiAirRingPlc;
/// <summary>
/// 倍加德旋转PLC
/// </summary>
FLY.Simulation.Blowing.BeiJiaDeRotaryPlc beiJiaDeRotaryPlc;
//吹膜逻辑 //吹膜逻辑
FLY.Simulation.Blowing.Blowing blowing; FLY.Simulation.Blowing.Blowing blowing;
public App() public App()
{ {
appjustone = new FLY.AppHelper.AppJustOne(this); appjustone = new FLY.AppHelper.AppJustOne(this);
...@@ -43,7 +50,7 @@ namespace BlowingSimulator ...@@ -43,7 +50,7 @@ namespace BlowingSimulator
{ {
Init(); Init();
var main = new MainWindow(); var main = new MainWindow();
main.Init(flyad7, plcLink, blowing); main.Init(flyad7, heMeiAirRingPlc, beiJiaDeRotaryPlc, blowing);
this.MainWindow = main; this.MainWindow = main;
...@@ -57,9 +64,11 @@ namespace BlowingSimulator ...@@ -57,9 +64,11 @@ namespace BlowingSimulator
blowing = new FLY.Simulation.Blowing.Blowing(); blowing = new FLY.Simulation.Blowing.Blowing();
plcLink = new FLY.Simulation.Blowing.AirRingPlc(); heMeiAirRingPlc = new FLY.Simulation.Blowing.HeMeiAirRingPlc();
plcLink.Init(blowing, blowing.mAirRing2); heMeiAirRingPlc.Init(blowing, blowing.mAirRing2);
beiJiaDeRotaryPlc = new FLY.Simulation.Blowing.BeiJiaDeRotaryPlc();
beiJiaDeRotaryPlc.Init(blowing);
flyad7 = new FLY.Simulation.Flyad7.FLYAD7(); flyad7 = new FLY.Simulation.Flyad7.FLYAD7();
...@@ -73,15 +82,6 @@ namespace BlowingSimulator ...@@ -73,15 +82,6 @@ namespace BlowingSimulator
flyad7objproxy.Listen(); flyad7objproxy.Listen();
FObjBase.PollModule.Current.Start(); FObjBase.PollModule.Current.Start();
//Task.Factory.StartNew(() =>
//{
// while (true)
// {
// FObjBase.PollModule.Current.OnPoll();
// Task.Delay(0).Wait();
// }
//});
} }
} }
} }
...@@ -158,19 +158,22 @@ ...@@ -158,19 +158,22 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Costura.Fody"> <PackageReference Include="Costura.Fody">
<Version>5.7.0</Version> <Version>4.1.0</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="NLog"> <PackageReference Include="NLog">
<Version>5.1.0</Version> <Version>4.6.8</Version>
</PackageReference> </PackageReference>
<PackageReference Include="PropertyChanged.Fody"> <PackageReference Include="PropertyChanged.Fody">
<Version>4.1.0</Version> <Version>3.3.1</Version>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="games_control.ico" /> <Resource Include="games_control.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="FodyWeavers.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
...@@ -66,16 +66,6 @@ ...@@ -66,16 +66,6 @@
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation> <xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string"> <xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation> <xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation> <xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
...@@ -102,16 +92,6 @@ ...@@ -102,16 +92,6 @@
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation> <xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:attribute> </xs:attribute>
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
<xs:annotation>
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="DisableCompression" type="xs:boolean"> <xs:attribute name="DisableCompression" type="xs:boolean">
<xs:annotation> <xs:annotation>
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation> <xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
...@@ -142,16 +122,6 @@ ...@@ -142,16 +122,6 @@
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation> <xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:attribute> </xs:attribute>
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
<xs:annotation>
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="Unmanaged32Assemblies" type="xs:string"> <xs:attribute name="Unmanaged32Assemblies" type="xs:string">
<xs:annotation> <xs:annotation>
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation> <xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
......
...@@ -40,17 +40,21 @@ ...@@ -40,17 +40,21 @@
<ColumnDefinition/> <ColumnDefinition/>
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<GroupBox Header="数据采集器" Margin="{StaticResource ControlMargin}" > <GroupBox Margin="{StaticResource ControlMargin}">
<GroupBox.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="AD盒"/>
<TextBlock>
(<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding Addr}" DataContext="{Binding FlyAd}"/>)
</TextBlock>
</StackPanel>
</GroupBox.Header>
<StackPanel Margin="{StaticResource ControlMargin}"> <StackPanel Margin="{StaticResource ControlMargin}">
<StackPanel.Resources> <StackPanel.Resources>
<Style x:Key="Styles.Text.FieldHeader" TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldHeader}"> <Style x:Key="Styles.Text.FieldHeader" TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldHeader}">
<Setter Property="Width" Value="80"/> <Setter Property="Width" Value="80"/>
</Style> </Style>
</StackPanel.Resources> </StackPanel.Resources>
<StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}" DataContext="{Binding FlyAd}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="地址:"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding Addr}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}"> <StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="采集值:"/> <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="采集值:"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding AD}"/> <TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding AD}"/>
...@@ -114,20 +118,25 @@ ...@@ -114,20 +118,25 @@
</WrapPanel> </WrapPanel>
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
<Grid Grid.Column="1" >
<GroupBox Grid.Column="1" Header="H3U" Margin="{StaticResource ControlMargin}" DataContext="{Binding Plc}" d:DataContext="{d:DesignInstance Type=blowing:AirRingPlc}"> <Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<GroupBox Margin="{StaticResource ControlMargin}" DataContext="{Binding HeMeiAirRingPlc}" d:DataContext="{d:DesignInstance Type=blowing:HeMeiAirRingPlc}">
<GroupBox.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="和美风环PLC"/>
<TextBlock>(<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding PlcAddr}"/>)
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding IsConnected,Converter={StaticResource connectionConv}}" /></TextBlock>
</StackPanel>
</GroupBox.Header>
<StackPanel Margin="{StaticResource ControlMargin}"> <StackPanel Margin="{StaticResource ControlMargin}">
<StackPanel.Resources> <StackPanel.Resources>
<Style x:Key="Styles.Text.FieldHeader" TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldHeader}"> <Style x:Key="Styles.Text.FieldHeader" TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldHeader}">
<Setter Property="Width" Value="80"/> <Setter Property="Width" Value="80"/>
</Style> </Style>
</StackPanel.Resources> </StackPanel.Resources>
<StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="地址:"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding PlcAddr}"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding IsConnected,Converter={StaticResource connectionConv}}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}"> <StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="心跳写入:"/> <TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="心跳写入:"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding LastUpdateDt,StringFormat={}{0:HH:mm:ss}}"/> <TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding LastUpdateDt,StringFormat={}{0:HH:mm:ss}}"/>
...@@ -142,6 +151,27 @@ ...@@ -142,6 +151,27 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>
<GroupBox Grid.Row="1" Margin="{StaticResource ControlMargin}" DataContext="{Binding BeiJiaDeRotaryPlc}" >
<GroupBox.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="倍加德旋转PLC"/>
<TextBlock>(<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding Port}"/>)</TextBlock>
</StackPanel>
</GroupBox.Header>
<StackPanel Margin="{StaticResource ControlMargin}">
<StackPanel.Resources>
<Style x:Key="Styles.Text.FieldHeader" TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldHeader}">
<Setter Property="Width" Value="80"/>
</Style>
</StackPanel.Resources>
<StackPanel Orientation="Horizontal" Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader}" Text="角度:"/>
<TextBlock Style="{StaticResource Styles.Text.FieldContent}" Text="{Binding Angle}"/>
</StackPanel>
</StackPanel>
</GroupBox>
</Grid>
</Grid> </Grid>
</Grid> </Grid>
......
...@@ -28,28 +28,28 @@ namespace BlowingSimulator ...@@ -28,28 +28,28 @@ namespace BlowingSimulator
MainVm viewModel; MainVm viewModel;
FLY.Simulation.Flyad7.FLYAD7 flyad7; FLY.Simulation.Flyad7.FLYAD7 flyad7;
FLY.Simulation.Blowing.Blowing blowing; FLY.Simulation.Blowing.Blowing blowing;
AirRingPlc plc; HeMeiAirRingPlc heMeiAirRingPlc;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
public void Init(FLY.Simulation.Flyad7.FLYAD7 flyad7, AirRingPlc plc, FLY.Simulation.Blowing.Blowing blowing) public void Init(FLY.Simulation.Flyad7.FLYAD7 flyad7, HeMeiAirRingPlc heMeiAirRingPlc, BeiJiaDeRotaryPlc beiJiaDeRotaryPlc, FLY.Simulation.Blowing.Blowing blowing)
{ {
this.flyad7 = flyad7; this.flyad7 = flyad7;
this.blowing = blowing; this.blowing = blowing;
this.plc = plc; this.heMeiAirRingPlc = heMeiAirRingPlc;
viewModel = new MainVm(); viewModel = new MainVm();
viewModel.Init(flyad7, plc); viewModel.Init(flyad7, heMeiAirRingPlc, beiJiaDeRotaryPlc);
this.DataContext = viewModel; this.DataContext = viewModel;
} }
private void button1_Click(object sender, RoutedEventArgs e) private void button1_Click(object sender, RoutedEventArgs e)
{ {
WindowBlowing wb = new WindowBlowing(); WindowBlowing wb = new WindowBlowing();
wb.Init(blowing, plc); wb.Init(blowing, heMeiAirRingPlc);
wb.ShowDialog(); wb.ShowDialog();
} }
...@@ -107,16 +107,23 @@ namespace BlowingSimulator ...@@ -107,16 +107,23 @@ namespace BlowingSimulator
private DispatcherTimer timer; private DispatcherTimer timer;
private FLYAD7 flyad; private FLYAD7 flyad;
private AirRingPlc plc; private HeMeiAirRingPlc heMeiAirRingPlc;
private BeiJiaDeRotaryPlc beiJiaDeRotaryPlc;
public FLY.Simulation.Flyad7.FLYAD7 FlyAd => flyad; public FLY.Simulation.Flyad7.FLYAD7 FlyAd => flyad;
public AirRingPlc Plc => plc; public HeMeiAirRingPlc HeMeiAirRingPlc => heMeiAirRingPlc;
public BeiJiaDeRotaryPlc BeiJiaDeRotaryPlc => beiJiaDeRotaryPlc;
public MainVm() public MainVm()
{ {
} }
public void Init(FLYAD7 flyad, AirRingPlc plc) public void Init(FLYAD7 flyad, HeMeiAirRingPlc heMeiAirRingPlc, BeiJiaDeRotaryPlc beiJiaDeRotaryPlc)
{ {
this.flyad = flyad; this.flyad = flyad;
this.plc = plc; this.heMeiAirRingPlc = heMeiAirRingPlc;
this.beiJiaDeRotaryPlc = beiJiaDeRotaryPlc;
//AD盒的信息降频显示
timer = new DispatcherTimer(); timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(0.1); timer.Interval = TimeSpan.FromSeconds(0.1);
timer.Tick += new EventHandler(timer_Tick); timer.Tick += new EventHandler(timer_Tick);
...@@ -125,6 +132,7 @@ namespace BlowingSimulator ...@@ -125,6 +132,7 @@ namespace BlowingSimulator
void timer_Tick(object sender, EventArgs e) void timer_Tick(object sender, EventArgs e)
{ {
//AD盒的信息降频显示
Position = flyad.Position; Position = flyad.Position;
Position2 = flyad.Position2; Position2 = flyad.Position2;
AD = flyad.AD; AD = flyad.AD;
......
...@@ -22,7 +22,7 @@ namespace BlowingSimulator ...@@ -22,7 +22,7 @@ namespace BlowingSimulator
public partial class WindowBlowing : Window public partial class WindowBlowing : Window
{ {
Blowing mBlowing; Blowing mBlowing;
AirRingPlc plcLink; HeMeiAirRingPlc plcLink;
public WindowBlowing() public WindowBlowing()
{ {
InitializeComponent(); InitializeComponent();
...@@ -146,7 +146,7 @@ namespace BlowingSimulator ...@@ -146,7 +146,7 @@ namespace BlowingSimulator
this.chart2.BackColor = System.Drawing.Color.Transparent; this.chart2.BackColor = System.Drawing.Color.Transparent;
} }
public void Init(Blowing blowing, AirRingPlc plcLink) public void Init(Blowing blowing, HeMeiAirRingPlc plcLink)
{ {
this.mBlowing = blowing; this.mBlowing = blowing;
this.plcLink = plcLink; this.plcLink = plcLink;
......
...@@ -13,17 +13,20 @@ using System.Windows.Threading; ...@@ -13,17 +13,20 @@ using System.Windows.Threading;
namespace FLY.Simulation.Blowing namespace FLY.Simulation.Blowing
{ {
/// <summary>
/// 中山和美风环PLC模拟器
/// </summary>
public class HeMeiAirRingPlc : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
//D200 通道数量 //D200 通道数量
//D201 设置值 更新 //D201 设置值 更新
//D400 设置值 160个 //D400 设置值 160个
//M3 风环开关 //M3 风环开关
//M4 检测电流 //M4 检测电流
//M0 看门狗 PC写1 //M0 看门狗 PC写1
public class AirRingPlc : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
const int ADDR_ChannelCnt = 200; const int ADDR_ChannelCnt = 200;
const int ADDR_Update = 201; const int ADDR_Update = 201;
const int ADDR_ChannelValues = 400; const int ADDR_ChannelValues = 400;
...@@ -53,7 +56,7 @@ namespace FLY.Simulation.Blowing ...@@ -53,7 +56,7 @@ namespace FLY.Simulation.Blowing
Modbus.WithThread.ServerTCP mserver; Modbus.WithThread.ServerTCP mserver;
public AirRingPlc() public HeMeiAirRingPlc()
{ {
} }
...@@ -303,20 +306,20 @@ namespace FLY.Simulation.Blowing ...@@ -303,20 +306,20 @@ namespace FLY.Simulation.Blowing
return hasElectricity; return hasElectricity;
} }
string filePath = "plc.json"; string filePath = "heMeiPlc.json";
public bool Save() public bool Save()
{ {
return AirRingJsonDb.Save(this, filePath); return HeMeiAirRingJsonDb.Save(this, filePath);
} }
bool Load() bool Load()
{ {
return AirRingJsonDb.Load(this, filePath); return HeMeiAirRingJsonDb.Load(this, filePath);
} }
} }
public class AirRingJsonDb public class HeMeiAirRingJsonDb
{ {
public static bool Load(AirRingPlc src, string filePath) public static bool Load(HeMeiAirRingPlc src, string filePath)
{ {
if (!File.Exists(filePath)) if (!File.Exists(filePath))
return false; return false;
...@@ -324,7 +327,7 @@ namespace FLY.Simulation.Blowing ...@@ -324,7 +327,7 @@ namespace FLY.Simulation.Blowing
try try
{ {
string json = File.ReadAllText(filePath); string json = File.ReadAllText(filePath);
var jsonDb = JsonConvert.DeserializeObject<AirRingJsonDb>(json); var jsonDb = JsonConvert.DeserializeObject<HeMeiAirRingJsonDb>(json);
src.PlcAddr = jsonDb.PlcAddr; src.PlcAddr = jsonDb.PlcAddr;
return true; return true;
} }
...@@ -336,11 +339,11 @@ namespace FLY.Simulation.Blowing ...@@ -336,11 +339,11 @@ namespace FLY.Simulation.Blowing
} }
public static bool Save(AirRingPlc src, string filePath) public static bool Save(HeMeiAirRingPlc src, string filePath)
{ {
try try
{ {
var jsonDb = new AirRingJsonDb() var jsonDb = new HeMeiAirRingJsonDb()
{ {
PlcAddr = src.PlcAddr PlcAddr = src.PlcAddr
}; };
......
using HslCommunication.Profinet.FATEK; using HslCommunication.Profinet.FATEK;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
...@@ -10,7 +12,10 @@ using System.Windows.Threading; ...@@ -10,7 +12,10 @@ using System.Windows.Threading;
namespace FLY.Simulation.Blowing namespace FLY.Simulation.Blowing
{ {
public class BeiJiaDePlc : INotifyPropertyChanged /// <summary>
/// 无锡倍加德旋转PLC模拟器
/// </summary>
public class BeiJiaDeRotaryPlc : INotifyPropertyChanged
{ {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
...@@ -38,9 +43,7 @@ namespace FLY.Simulation.Blowing ...@@ -38,9 +43,7 @@ namespace FLY.Simulation.Blowing
FatekProgramServer fatekProgramServer; FatekProgramServer fatekProgramServer;
Blowing blowing; Blowing blowing;
Blowing.AirRing airRing; public BeiJiaDeRotaryPlc()
DispatcherTimer timer;
public BeiJiaDePlc()
{ {
} }
...@@ -48,6 +51,11 @@ namespace FLY.Simulation.Blowing ...@@ -48,6 +51,11 @@ namespace FLY.Simulation.Blowing
public void Init(Blowing blowing) public void Init(Blowing blowing)
{ {
this.blowing = blowing; this.blowing = blowing;
Misc.BindingOperations.SetBinding(blowing, nameof(blowing.CurrAngle), updateAngle);
// 授权示例 Authorization example // 授权示例 Authorization example
//11.0.2 版本后,都是下面的激活码 //11.0.2 版本后,都是下面的激活码
if (!HslCommunication.Authorization.SetAuthorizationCode("e30dcfe8-f4e1-45d3-9aca-9ac8fa0787b1")) if (!HslCommunication.Authorization.SetAuthorizationCode("e30dcfe8-f4e1-45d3-9aca-9ac8fa0787b1"))
...@@ -58,7 +66,8 @@ namespace FLY.Simulation.Blowing ...@@ -58,7 +66,8 @@ namespace FLY.Simulation.Blowing
fatekProgramServer = new FatekProgramServer() fatekProgramServer = new FatekProgramServer()
{ {
Port = Port, Port = Port,
Station = Station Station = Station,
}; };
fatekProgramServer.ServerStart(); fatekProgramServer.ServerStart();
...@@ -67,12 +76,84 @@ namespace FLY.Simulation.Blowing ...@@ -67,12 +76,84 @@ namespace FLY.Simulation.Blowing
fatekProgramServer.Write(ADDR_Angle, Angle); fatekProgramServer.Write(ADDR_Angle, Angle);
}); });
Misc.BindingOperations.SetBinding(blowing, nameof(blowing.CurrAngle), updateAngle);
} }
private void updateAngle() private void updateAngle()
{ {
if(!IsReversed)
Angle = (Int16)(blowing.CurrAngle * 10); Angle = (Int16)(blowing.CurrAngle * 10);
else
Angle = (Int16)(-blowing.CurrAngle * 10);
}
string filePath = "beiJiaDeRotaryPlc.json";
public bool Save()
{
return BeiJiaDeRotaryPlcJsonDb.Save(this, filePath);
}
bool Load()
{
return BeiJiaDeRotaryPlcJsonDb.Load(this, filePath);
}
}
public class BeiJiaDeRotaryPlcJsonDb
{
public static bool Load(BeiJiaDeRotaryPlc src, string filePath)
{
if (!File.Exists(filePath))
return false;
try
{
string json = File.ReadAllText(filePath);
var jsonDb = JsonConvert.DeserializeObject<BeiJiaDeRotaryPlcJsonDb>(json);
src.Port = jsonDb.Port;
src.Station = jsonDb.Station;
src.IsReversed = jsonDb.IsReversed;
return true;
}
catch
{
//异常,没有json 解码失败
return false;
}
} }
public static bool Save(BeiJiaDeRotaryPlc src, string filePath)
{
try
{
var jsonDb = new BeiJiaDeRotaryPlc()
{
Port = src.Port,
Station = src.Station,
IsReversed = src.IsReversed
};
string json = JsonConvert.SerializeObject(jsonDb, Formatting.Indented);
File.WriteAllText(filePath, json);
return true;
}
catch
{
//异常,没有json 编码失败
return false;
}
}
/// <summary>
/// PLC 地址 及 端口
/// </summary>
public int Port { get; set; } = 500;
/// <summary>
/// 方向反转
/// </summary>
public bool IsReversed { get; set; } = true;
/// <summary>
/// 站号
/// </summary>
public byte Station { get; set; } = 2;
} }
} }
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BeiJiaDePlc.cs" /> <Compile Include="BeiJiaDeRotaryPlc.cs" />
<Compile Include="Blowing.cs" /> <Compile Include="Blowing.cs" />
<Compile Include="FilmLength3D.cs" /> <Compile Include="FilmLength3D.cs" />
<Compile Include="GageAD.cs" /> <Compile Include="GageAD.cs" />
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
<Version>11.0.6</Version> <Version>11.0.6</Version>
</PackageReference> </PackageReference>
<PackageReference Include="PropertyChanged.Fody"> <PackageReference Include="PropertyChanged.Fody">
<Version>4.1.0</Version> <Version>3.3.1</Version>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -8,7 +8,7 @@ namespace FLY.Simulation.Blowing ...@@ -8,7 +8,7 @@ namespace FLY.Simulation.Blowing
/// <summary> /// <summary>
/// 1脉冲 = ? mm /// 1脉冲 = ? mm
/// </summary> /// </summary>
public double Mmpp { get; set; } = 0.14; public double Mmpp { get; set; } = 0.0943;
/// <summary> /// <summary>
/// 机架总长 mm /// 机架总长 mm
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
<Version>10.1.1</Version> <Version>10.1.1</Version>
</PackageReference> </PackageReference>
<PackageReference Include="PropertyChanged.Fody"> <PackageReference Include="PropertyChanged.Fody">
<Version>4.1.0</Version> <Version>3.3.1</Version>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
...@@ -15,7 +15,7 @@ namespace FLY.Simulation.Flyad7 ...@@ -15,7 +15,7 @@ namespace FLY.Simulation.Flyad7
{ {
public class FLYAD7 : IFlyAD, INotifyPropertyChanged public class FLYAD7 : IFlyAD, INotifyPropertyChanged
{ {
public string Addr { get; set; } = "0.0.0.0:20006"; public string Addr { get; set; } = "127.168.251.10:20008";
public int Version { get; } = 2; public int Version { get; } = 2;
......
...@@ -62,10 +62,10 @@ ...@@ -62,10 +62,10 @@
<Version>10.1.1</Version> <Version>10.1.1</Version>
</PackageReference> </PackageReference>
<PackageReference Include="Newtonsoft.Json"> <PackageReference Include="Newtonsoft.Json">
<Version>13.0.2</Version> <Version>12.0.3</Version>
</PackageReference> </PackageReference>
<PackageReference Include="PropertyChanged.Fody"> <PackageReference Include="PropertyChanged.Fody">
<Version>4.1.0</Version> <Version>3.3.1</Version>
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......
...@@ -40,7 +40,7 @@ namespace FLY.Winder.BeiJiaDe.UI.Server ...@@ -40,7 +40,7 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
/// <summary> /// <summary>
/// 方向反转 /// 方向反转
/// </summary> /// </summary>
public bool IsReversed { get; set; } public bool IsReversed { get; set; } = true;
/// <summary> /// <summary>
/// 站号 /// 站号
...@@ -106,9 +106,9 @@ namespace FLY.Winder.BeiJiaDe.UI.Server ...@@ -106,9 +106,9 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
public void Init() public void Init()
{ {
Load(); //Load();
//if (!Load()) if (!Load())
// Save(); Save();
IPEndPoint ep = Misc.StringConverter.ToIPEndPoint(PlcAddr); IPEndPoint ep = Misc.StringConverter.ToIPEndPoint(PlcAddr);
...@@ -350,7 +350,7 @@ namespace FLY.Winder.BeiJiaDe.UI.Server ...@@ -350,7 +350,7 @@ namespace FLY.Winder.BeiJiaDe.UI.Server
/// <summary> /// <summary>
/// 方向反转 /// 方向反转
/// </summary> /// </summary>
public bool IsReversed { get; set; } public bool IsReversed { get; set; } = true;
public static bool Save(RotaryPlc src, string filePath) public static bool Save(RotaryPlc src, string filePath)
{ {
......
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