Commit 990c4363 authored by 潘栩锋's avatar 潘栩锋 🚴

添加倍加德旋转模拟

parent 4775ef6f
using HslCommunication.Profinet.FATEK;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
namespace FLY.Simulation.Blowing
{
public class BeiJiaDePlc : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// int16 角度 x10
/// </summary>
const string ADDR_Angle = "D98";
/// <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;
public Int16 Angle { get; set; }
FatekProgramServer fatekProgramServer;
Blowing blowing;
Blowing.AirRing airRing;
DispatcherTimer timer;
public BeiJiaDePlc()
{
}
//11.0.2 版本后,都是下面的激活码
public void Init(Blowing blowing)
{
this.blowing = blowing;
// 授权示例 Authorization example
//11.0.2 版本后,都是下面的激活码
if (!HslCommunication.Authorization.SetAuthorizationCode("e30dcfe8-f4e1-45d3-9aca-9ac8fa0787b1"))
{
throw new Exception("激活失败! 当前程序只能连续运行8个小时!");
}
fatekProgramServer = new FatekProgramServer()
{
Port = Port,
Station = Station
};
fatekProgramServer.ServerStart();
Misc.BindingOperations.SetBinding(this, nameof(Angle), () =>
{
fatekProgramServer.Write(ADDR_Angle, Angle);
});
Misc.BindingOperations.SetBinding(blowing, nameof(blowing.CurrAngle), updateAngle);
}
private void updateAngle()
{
Angle = (Int16)(blowing.CurrAngle * 10);
}
}
}
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
<Reference Include="WindowsBase" /> <Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="BeiJiaDePlc.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" />
......
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