Commit 2a61cb6c authored by 潘栩锋's avatar 潘栩锋 🚴

1.添加 添加 FilmPositionDetect 模块。

2.修改 DynArea 的通讯都改为 json
parent 3fd8c736
...@@ -6,6 +6,7 @@ using FObjBase; ...@@ -6,6 +6,7 @@ using FObjBase;
using FLY.Thick.Base.Common; using FLY.Thick.Base.Common;
using FLY.Thick.Base.OBJ_INTERFACE; using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.IService; using FLY.Thick.Base.IService;
using Newtonsoft.Json;
namespace FLY.Thick.Base.Client namespace FLY.Thick.Base.Client
{ {
...@@ -15,6 +16,7 @@ namespace FLY.Thick.Base.Client ...@@ -15,6 +16,7 @@ namespace FLY.Thick.Base.Client
private UInt32 mServerID; private UInt32 mServerID;
private IFConn mConn; private IFConn mConn;
public DynAreaService(UInt32 id) public DynAreaService(UInt32 id)
{ {
mServerID = id; mServerID = id;
...@@ -57,9 +59,9 @@ namespace FLY.Thick.Base.Client ...@@ -57,9 +59,9 @@ namespace FLY.Thick.Base.Client
{ {
case DYNAREA_OBJ_INTERFACE.PUSH_ADPOS: case DYNAREA_OBJ_INTERFACE.PUSH_ADPOS:
{ {
DYNAREA_OBJ_INTERFACE.Pack_GetADPos pack = new DYNAREA_OBJ_INTERFACE.Pack_GetADPos(); string json = Misc.Converter.BytesToString(infodata);
if (!pack.TryParse(infodata)) DYNAREA_OBJ_INTERFACE.Pack_GetADPos pack = JsonConvert.DeserializeObject<DYNAREA_OBJ_INTERFACE.Pack_GetADPos>(json);
return;
mDynArea.AD = pack.ad; mDynArea.AD = pack.ad;
mDynArea.Thick = pack.thick; mDynArea.Thick = pack.thick;
mDynArea.Position = pack.position; mDynArea.Position = pack.position;
...@@ -67,34 +69,29 @@ namespace FLY.Thick.Base.Client ...@@ -67,34 +69,29 @@ namespace FLY.Thick.Base.Client
} break; } break;
case DYNAREA_OBJ_INTERFACE.PUSH_SCANINFO: case DYNAREA_OBJ_INTERFACE.PUSH_SCANINFO:
{ {
DYNAREA_OBJ_INTERFACE.Pack_GetScanInfo pack = new DYNAREA_OBJ_INTERFACE.Pack_GetScanInfo(); string json = Misc.Converter.BytesToString(infodata);
if (!pack.TryParse(infodata)) DYNAREA_OBJ_INTERFACE.Pack_GetScanInfo pack = JsonConvert.DeserializeObject<DYNAREA_OBJ_INTERFACE.Pack_GetScanInfo>(json);
return; if (pack.sampleAD != null)
//TODO
for (int i = 0; i < 3; i++)
{ {
mDynArea.SampleAD[i] = pack.sampleAD[i]; for (int i = 0; i < mDynArea.SampleAD.Count() && i < pack.sampleAD.Count(); i++)
{
mDynArea.SampleAD[i] = pack.sampleAD[i];
}
} }
mDynArea.TempState = pack.tempState; mDynArea.TempState = pack.tempState;
mDynArea.DataValid = pack.datavalid; mDynArea.DataValid = pack.datavalid;
mDynArea.RollDown = pack.rolldown;
mDynArea.Direction = pack.direction; mDynArea.Direction = pack.direction;
mDynArea.Width = pack.width; mDynArea.Width = pack.width;
mDynArea.FilmVelocity = pack.filmVelocity; mDynArea.FilmVelocity = pack.filmVelocity;
mDynArea.FilmPosition = pack.filmPosition;
mDynArea.Velocity = pack.velocity; mDynArea.Velocity = pack.velocity;
} break; } break;
case DYNAREA_OBJ_INTERFACE.PUSH_PROFILE: case DYNAREA_OBJ_INTERFACE.PUSH_PROFILE:
{ {
DYNAREA_OBJ_INTERFACE.Pack_GetProfile pack = new DYNAREA_OBJ_INTERFACE.Pack_GetProfile(); string json = Misc.Converter.BytesToString(infodata);
if (!pack.TryParse(infodata)) DYNAREA_OBJ_INTERFACE.Pack_GetProfile pack = JsonConvert.DeserializeObject<DYNAREA_OBJ_INTERFACE.Pack_GetProfile>(json);
return;
mDynArea.ProductName = pack.ProductName; mDynArea.ProductName = pack.ProductName;
mDynArea.Target = pack.Target; mDynArea.Target = pack.Target;
mDynArea.Alarm = pack.Alarm; mDynArea.Alarm = pack.Alarm;
...@@ -107,9 +104,9 @@ namespace FLY.Thick.Base.Client ...@@ -107,9 +104,9 @@ namespace FLY.Thick.Base.Client
} break; } break;
case DYNAREA_OBJ_INTERFACE.PUSH_SYSTEM: case DYNAREA_OBJ_INTERFACE.PUSH_SYSTEM:
{ {
DYNAREA_OBJ_INTERFACE.Pack_GetSystem pack = new DYNAREA_OBJ_INTERFACE.Pack_GetSystem(); string json = Misc.Converter.BytesToString(infodata);
if (!pack.TryParse(infodata)) DYNAREA_OBJ_INTERFACE.Pack_GetSystem pack = JsonConvert.DeserializeObject<DYNAREA_OBJ_INTERFACE.Pack_GetSystem>(json);
return;
mDynArea.FLYADIsConnect = pack.isConnect; mDynArea.FLYADIsConnect = pack.isConnect;
mDynArea.SecuteLock = pack.secuteLock; mDynArea.SecuteLock = pack.secuteLock;
mDynArea.Hrs = pack.hrs; mDynArea.Hrs = pack.hrs;
...@@ -118,33 +115,33 @@ namespace FLY.Thick.Base.Client ...@@ -118,33 +115,33 @@ namespace FLY.Thick.Base.Client
} break; } break;
case DYNAREA_OBJ_INTERFACE.PUSH_BOLTMAP: case DYNAREA_OBJ_INTERFACE.PUSH_BOLTMAP:
{ {
DYNAREA_OBJ_INTERFACE.Pack_GetBoltmap pack = new DYNAREA_OBJ_INTERFACE.Pack_GetBoltmap(); string json = Misc.Converter.BytesToString(infodata);
if (!pack.TryParse(infodata)) DYNAREA_OBJ_INTERFACE.Pack_GetBoltmap pack = JsonConvert.DeserializeObject<DYNAREA_OBJ_INTERFACE.Pack_GetBoltmap>(json);
return;
mDynArea.NBolts = pack.NBolts; mDynArea.NBolts = pack.NBolts;
mDynArea.FirstBoltNo = pack.FirstBoltNo; mDynArea.FirstBoltNo = pack.FirstBoltNo;
} break; } break;
case DYNAREA_OBJ_INTERFACE.PUSH_IO: case DYNAREA_OBJ_INTERFACE.PUSH_IO:
{ {
DYNAREA_OBJ_INTERFACE.Pack_GetIO pack = new DYNAREA_OBJ_INTERFACE.Pack_GetIO(); string json = Misc.Converter.BytesToString(infodata);
if (!pack.TryParse(infodata)) DYNAREA_OBJ_INTERFACE.Pack_GetIO pack = JsonConvert.DeserializeObject<DYNAREA_OBJ_INTERFACE.Pack_GetIO>(json);
return;
mDynArea.IStatus = pack.iStatus; mDynArea.IStatus = pack.iStatus;
mDynArea.OStatus = pack.oStatus; mDynArea.OStatus = pack.oStatus;
} break; } break;
case DYNAREA_OBJ_INTERFACE.PUSH_CONTROLLER_STATE: case DYNAREA_OBJ_INTERFACE.PUSH_CONTROLLER_STATE:
{ {
DYNAREA_OBJ_INTERFACE.Pack_GetControllerState pack = new DYNAREA_OBJ_INTERFACE.Pack_GetControllerState(); string json = Misc.Converter.BytesToString(infodata);
if (!pack.TryParse(infodata)) DYNAREA_OBJ_INTERFACE.Pack_GetControllerState pack = JsonConvert.DeserializeObject<DYNAREA_OBJ_INTERFACE.Pack_GetControllerState>(json);
return;
mDynArea.ControllerState = pack.controller_state; mDynArea.ControllerState = pack.controller_state;
mDynArea.AutoScanCounter = pack.autoscan_counter; mDynArea.AutoScanCounter = pack.autoscan_counter;
} break; } break;
case DYNAREA_OBJ_INTERFACE.PUSH_POSITION2: case DYNAREA_OBJ_INTERFACE.PUSH_POSITION2:
{ {
DYNAREA_OBJ_INTERFACE.Pack_Position2 pack = new DYNAREA_OBJ_INTERFACE.Pack_Position2(); string json = Misc.Converter.BytesToString(infodata);
if (!pack.TryParse(infodata)) DYNAREA_OBJ_INTERFACE.Pack_Position2 pack = JsonConvert.DeserializeObject<DYNAREA_OBJ_INTERFACE.Pack_Position2>(json);
return;
mDynArea.Position2 = pack.position; mDynArea.Position2 = pack.position;
}break; }break;
} }
......
...@@ -110,71 +110,34 @@ namespace FLY.Thick.Base.Common ...@@ -110,71 +110,34 @@ namespace FLY.Thick.Base.Common
/// </summary> /// </summary>
public double FilmVelocity { get; set; } public double FilmVelocity { get; set; }
/// <summary> /// <summary>
/// 膜生产位置 m
/// </summary>
public double FilmPosition { get; set; }
/// <summary>
/// 测厚仪速度 m/min /// 测厚仪速度 m/min
/// </summary> /// </summary>
public double Velocity { get; set; } public double Velocity { get; set; }
#endregion #endregion
#region 运行状态 #region 运行状态
private CTRL_STATE _controllerState; /// <summary>
public CTRL_STATE ControllerState//运行状态 /// 运行状态
{ /// </summary>
get { public CTRL_STATE ControllerState { get; set; }
return _controllerState;
} /// <summary>
set { ///
if (_controllerState != value) /// </summary>
{ public int AutoScanCounter { get; set; } = 5;
_controllerState = value;
NotifyPropertyChanged("ControllerState");
}
}
}
private int autoscancounter=5;
public int AutoScanCounter
{
get
{
return autoscancounter;
}
set
{
if (autoscancounter != value)
{
autoscancounter = value;
NotifyPropertyChanged("AutoScanCounter");
}
}
}
#endregion #endregion
#region IO #region IO
private UInt16 iStatus = 0xffff;
public UInt16 IStatus public UInt16 IStatus { get; set; } = 0xffff;
{
get { return iStatus; } public UInt16 OStatus { get; set; } = 0xffff;
set
{
if (iStatus != value)
{
iStatus = value;
NotifyPropertyChanged("IStatus");
}
}
}
public UInt16 oStatus = 0xffff;
public UInt16 OStatus
{
get { return oStatus; }
set
{
if (oStatus != value)
{
oStatus = value;
NotifyPropertyChanged("OStatus");
}
}
}
#endregion #endregion
#region 系统 #region 系统
...@@ -280,8 +243,6 @@ namespace FLY.Thick.Base.Common ...@@ -280,8 +243,6 @@ namespace FLY.Thick.Base.Common
/// </summary> /// </summary>
public int NBolts { get; set; } = 50; public int NBolts { get; set; } = 50;
private int _firstBoltNo = 0;
/// <summary> /// <summary>
/// 开始分区号 /// 开始分区号
/// </summary> /// </summary>
...@@ -291,13 +252,7 @@ namespace FLY.Thick.Base.Common ...@@ -291,13 +252,7 @@ namespace FLY.Thick.Base.Common
#region INotifyPropertyChanged 成员 #region INotifyPropertyChanged 成员
protected void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
#endregion #endregion
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.6.0\build\PropertyChanged2.Fody.props" Condition="Exists('..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.6.0\build\PropertyChanged2.Fody.props')" /> <Import Project="..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.6.0\build\PropertyChanged2.Fody.props" Condition="Exists('..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.6.0\build\PropertyChanged2.Fody.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FLY.Thick.Base</RootNamespace> <RootNamespace>FLY.Thick.Base</RootNamespace>
<AssemblyName>FLY.Thick.Base</AssemblyName> <AssemblyName>FLY.Thick.Base</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp> </NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\FLY.Thick.Base.XML</DocumentationFile> <DocumentationFile>bin\Debug\FLY.Thick.Base.XML</DocumentationFile>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
...@@ -33,12 +35,16 @@ ...@@ -33,12 +35,16 @@
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationIcon> <ApplicationIcon>
</ApplicationIcon> </ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PropertyChanged2, Version=2.6.0.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL"> <Reference Include="PropertyChanged2, Version=2.6.0.0, Culture=neutral, PublicKeyToken=ee3ee20bcf148ddd, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.6.0\lib\net40\PropertyChanged2.dll</HintPath> <HintPath>..\..\..\Project.FLY.Thick.Normal\packages\PropertyChanged2.Fody.2.6.0\lib\net40\PropertyChanged2.dll</HintPath>
</Reference> </Reference>
...@@ -49,6 +55,7 @@ ...@@ -49,6 +55,7 @@
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Client\BoltCreateInfo.cs" /> <Compile Include="Client\BoltCreateInfo.cs" />
...@@ -96,6 +103,7 @@ ...@@ -96,6 +103,7 @@
<Compile Include="IService\IGetSampleService.cs" /> <Compile Include="IService\IGetSampleService.cs" />
<Compile Include="IService\IInitParamService.cs" /> <Compile Include="IService\IInitParamService.cs" />
<Compile Include="IService\INotifyErrorArisen.cs" /> <Compile Include="IService\INotifyErrorArisen.cs" />
<Compile Include="IService\IFilmPositionDetectService.cs" />
<Compile Include="IService\IPasswordService.cs" /> <Compile Include="IService\IPasswordService.cs" />
<Compile Include="IService\IProfileService.cs" /> <Compile Include="IService\IProfileService.cs" />
<Compile Include="IService\IRejectService.cs" /> <Compile Include="IService\IRejectService.cs" />
...@@ -149,6 +157,7 @@ ...@@ -149,6 +157,7 @@
<Compile Include="Server\BorderSearch.cs" /> <Compile Include="Server\BorderSearch.cs" />
<Compile Include="Server\CoatingSegmentSearch.cs" /> <Compile Include="Server\CoatingSegmentSearch.cs" />
<Compile Include="Server\CurveCollection.cs" /> <Compile Include="Server\CurveCollection.cs" />
<Compile Include="Server\FilmPositionDetect.cs" />
<Compile Include="Server\GetSample.cs" /> <Compile Include="Server\GetSample.cs" />
<Compile Include="Server\GM_Base.cs" /> <Compile Include="Server\GM_Base.cs" />
<Compile Include="Server\GM_Fix.cs" /> <Compile Include="Server\GM_Fix.cs" />
......
using FLY.Thick.Base.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FLY.Thick.Base.IService
{
public interface IFilmPositionDetect : INotifyPropertyChanged
{
/// <summary>
/// 线速度 m/min
/// </summary>
double FilmVelocity { get; }
/// <summary>
/// 膜位置, m
/// </summary>
double FilmPosition { get; }
/// <summary>
/// 线速度阀值,低于阀值,速度直接变为0
/// </summary>
double FilmVThreshold { get; set; }
/// <summary>
/// 编码器2 放大
/// </summary>
float Encoder2_comp { get; set; }
/// <summary>
/// 线速度来源
/// </summary>
FilmVSRC FilmVSrc { get; set; }
/// <summary>
/// 线速度:编码器2 mm/pulse
/// </summary>
double Encoder2_mmpp { get; set; }
/// <summary>
/// 线速度:1圈多少mm
/// </summary>
double MmOfR { get; set; }
/// <summary>
/// 设置膜位置为某值
/// </summary>
/// <param name="filmPosition"></param>
void Reset(double filmPosition);
}
}
...@@ -70,60 +70,51 @@ namespace FLY.Thick.Base.OBJ_INTERFACE ...@@ -70,60 +70,51 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
#endregion #endregion
} }
public class Pack_GetScanInfo : IPack public class Pack_GetScanInfo
{ {
public int[] sampleAD = new int[3];//最新样品AD /// <summary>
public bool tempState;//动态温修 /// 最新样品AD
public bool datavalid;//数据有效 /// </summary>
public int rolldown;//下辊信号 public int[] sampleAD;
public Misc.DIRECTION direction;//扫描方向 /// <summary>
public double width;//膜宽 mm /// 动态温修
public double filmVelocity;//线速度m/min /// </summary>
public double velocity;//速度 m/min public bool tempState;
#region IPack 成员 /// <summary>
/// 数据有效
public byte[] ToBytes() /// </summary>
{ public bool datavalid;
List<byte> buf = new List<byte>(); /// <summary>
for (int i = 0; i < 3; i++) /// 扫描方向
{ /// </summary>
buf.AddRange(BitConverter.GetBytes(sampleAD[i])); public Misc.DIRECTION direction;
} /// <summary>
buf.AddRange(BitConverter.GetBytes(tempState)); /// 膜宽 mm
buf.AddRange(BitConverter.GetBytes(datavalid)); /// </summary>
buf.AddRange(BitConverter.GetBytes(rolldown)); public double width;
buf.Add((byte)direction); /// <summary>
buf.AddRange(BitConverter.GetBytes(width)); /// 线速度m/min
buf.AddRange(BitConverter.GetBytes(filmVelocity)); /// </summary>
buf.AddRange(BitConverter.GetBytes(velocity)); public double filmVelocity;
return (buf.ToArray()); /// <summary>
} /// 膜生产位置m
/// </summary>
public bool TryParse(byte[] value) public double filmPosition;
{ /// <summary>
if (value.Length < (12 + 1 + 1 + 4 + 1+8*3)) /// 速度 m/min
return false; /// </summary>
int index = 0; public double velocity;
for (int i = 0; i < 3; i++)
{
sampleAD[i] = BitConverter.ToInt32(value, index); index += 4;
}
tempState = BitConverter.ToBoolean(value, index); index++;
datavalid = BitConverter.ToBoolean(value, index); index++;
rolldown = BitConverter.ToInt32(value, index); index += 4;
direction = (Misc.DIRECTION)value[index];index++;
width = BitConverter.ToDouble(value, index); index += 8;
filmVelocity = BitConverter.ToDouble(value, index); index += 8;
velocity = BitConverter.ToDouble(value, index); index += 8;
return true;
}
#endregion
} }
public class Pack_GetControllerState : IPack public class Pack_GetControllerState : IPack
{ {
public CTRL_STATE controller_state;//运行状态 /// <summary>
public int autoscan_counter;//自动扫描时间累积 /// 运行状态
/// </summary>
public CTRL_STATE controller_state;
/// <summary>
/// 自动扫描时间累积
/// </summary>
public int autoscan_counter;
#region IPack 成员 #region IPack 成员
......
...@@ -6,7 +6,7 @@ using FLY.Thick.Base.Common; ...@@ -6,7 +6,7 @@ using FLY.Thick.Base.Common;
using FObjBase; using FObjBase;
using FLY.Thick.Base.OBJ_INTERFACE; using FLY.Thick.Base.OBJ_INTERFACE;
using FLY.Thick.Base.Server; using FLY.Thick.Base.Server;
using Newtonsoft.Json;
namespace FLY.Thick.Base.Server.OBJProxy namespace FLY.Thick.Base.Server.OBJProxy
{ {
...@@ -69,10 +69,10 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -69,10 +69,10 @@ namespace FLY.Thick.Base.Server.OBJProxy
(e.PropertyName == "TempState") || (e.PropertyName == "TempState") ||
(e.PropertyName == "Mix") || (e.PropertyName == "Mix") ||
(e.PropertyName == "DataValid") || (e.PropertyName == "DataValid") ||
(e.PropertyName == "RollDown") ||
(e.PropertyName == "Direction") || (e.PropertyName == "Direction") ||
(e.PropertyName == "Width") || (e.PropertyName == "Width") ||
(e.PropertyName == "FilmVelocity")|| (e.PropertyName == "FilmVelocity")||
(e.PropertyName == "FilmPosition") ||
(e.PropertyName == "Velocity") (e.PropertyName == "Velocity")
) )
{ {
...@@ -195,7 +195,8 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -195,7 +195,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
position = mDynArea.Position, position = mDynArea.Position,
boltIndex = mDynArea.BoltIndex boltIndex = mDynArea.BoltIndex
}; };
infodata = p.ToBytes(); string json = JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break; } break;
case DYNAREA_OBJ_INTERFACE.GET_SCANINFO: case DYNAREA_OBJ_INTERFACE.GET_SCANINFO:
{ {
...@@ -204,18 +205,14 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -204,18 +205,14 @@ namespace FLY.Thick.Base.Server.OBJProxy
tempState = mDynArea.TempState, tempState = mDynArea.TempState,
direction = mDynArea.Direction, direction = mDynArea.Direction,
datavalid = mDynArea.DataValid, datavalid = mDynArea.DataValid,
rolldown = mDynArea.RollDown,
width = mDynArea.Width, width = mDynArea.Width,
filmVelocity = mDynArea.FilmVelocity, filmVelocity = mDynArea.FilmVelocity,
velocity = mDynArea.Velocity filmPosition = mDynArea.FilmPosition,
velocity = mDynArea.Velocity,
sampleAD = mDynArea.SampleAD.ToArray()
}; };
for(int i=0;i<3;i++) string json = JsonConvert.SerializeObject(p);
{ infodata = Misc.Converter.StringToBytes(json);
p.sampleAD[i] = mDynArea.SampleAD[i];
}
infodata = p.ToBytes();
} break; } break;
case DYNAREA_OBJ_INTERFACE.GET_PROFILE: case DYNAREA_OBJ_INTERFACE.GET_PROFILE:
{ {
...@@ -231,7 +228,8 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -231,7 +228,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
Comp = mDynArea.Comp, Comp = mDynArea.Comp,
Shift = mDynArea.Shift Shift = mDynArea.Shift
}; };
infodata = p.ToBytes(); string json = JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break; } break;
case DYNAREA_OBJ_INTERFACE.GET_BOLTMAP: case DYNAREA_OBJ_INTERFACE.GET_BOLTMAP:
{ {
...@@ -240,7 +238,8 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -240,7 +238,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
NBolts = mDynArea.NBolts, NBolts = mDynArea.NBolts,
FirstBoltNo = mDynArea.FirstBoltNo FirstBoltNo = mDynArea.FirstBoltNo
}; };
infodata = p.ToBytes(); string json = JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break; } break;
case DYNAREA_OBJ_INTERFACE.GET_IO: case DYNAREA_OBJ_INTERFACE.GET_IO:
{ {
...@@ -249,7 +248,8 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -249,7 +248,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
iStatus = mDynArea.IStatus, iStatus = mDynArea.IStatus,
oStatus = mDynArea.OStatus oStatus = mDynArea.OStatus
}; };
infodata = p.ToBytes(); string json = JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break; } break;
case DYNAREA_OBJ_INTERFACE.GET_CONTROLLER_STATE: case DYNAREA_OBJ_INTERFACE.GET_CONTROLLER_STATE:
...@@ -259,7 +259,8 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -259,7 +259,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
controller_state = mDynArea.ControllerState, controller_state = mDynArea.ControllerState,
autoscan_counter = mDynArea.AutoScanCounter autoscan_counter = mDynArea.AutoScanCounter
}; };
infodata = p.ToBytes(); string json = JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break; } break;
case DYNAREA_OBJ_INTERFACE.GET_SYSTEM: case DYNAREA_OBJ_INTERFACE.GET_SYSTEM:
{ {
...@@ -271,7 +272,8 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -271,7 +272,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
hrs = mDynArea.Hrs, hrs = mDynArea.Hrs,
gagetype = mDynArea.GageType gagetype = mDynArea.GageType
}; };
infodata = p.ToBytes(); string json = JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break; } break;
case DYNAREA_OBJ_INTERFACE.GET_POSITION2: case DYNAREA_OBJ_INTERFACE.GET_POSITION2:
{ {
...@@ -279,7 +281,8 @@ namespace FLY.Thick.Base.Server.OBJProxy ...@@ -279,7 +281,8 @@ namespace FLY.Thick.Base.Server.OBJProxy
{ {
position = mDynArea.Position2 position = mDynArea.Position2
}; };
infodata = p.ToBytes(); string json = JsonConvert.SerializeObject(p);
infodata = Misc.Converter.StringToBytes(json);
} break; } break;
default: default:
infodata = null; infodata = null;
......
using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService;
using FlyADBase;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
namespace FLY.Thick.Base.Server
{
/// <summary>
/// 膜位置检测
/// 通过辊接近开关,或者编码器2
/// </summary>
public class FilmPositionDetect : IFilmPositionDetect
{
/// <summary>
/// 线速度 m/min
/// </summary>
public double FilmVelocity { get; private set; }
/// <summary>
/// 膜位置, m
/// </summary>
public double FilmPosition { get; private set; }
/// <summary>
/// 线速度阀值,低于阀值,速度直接变为0
/// </summary>
public double FilmVThreshold { get; set; }
/// <summary>
/// 线速度来源
/// </summary>
public FilmVSRC FilmVSrc { get; set; }
/// <summary>
/// 线速度:编码器2 mm/pulse
/// </summary>
public double Encoder2_mmpp { get; set; }
/// <summary>
/// 编码器2 放大
/// </summary>
public float Encoder2_comp { get; set; }
/// <summary>
/// 线速度:1圈多少mm
/// </summary>
public double MmOfR { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
private FlyAD7 mFlyAD;
public void Init(FlyAD7 flyAD)
{
mFlyAD = flyAD;
//------------------------------------------------------------------------------------------------------------------------------------
//线速度------------------------------------------------------------------------------------------------------------------------------
mFlyAD.PropertyChanged += (s, e) =>
{
if (FilmVSrc != FilmVSRC.EN2)
return;
if (e.PropertyName == "Speed2")
{
double speed = mFlyAD.Speed2 * Encoder2_mmpp;//mm/s
speed = speed * 60 / 1000;//m/min
FilmVelocity = speed;
}
else if (e.PropertyName == "Position2")
{
if (FilmVSrc != FilmVSRC.EN2)
return;
double position2 = mFlyAD.Position2* Encoder2_mmpp;//mm
position2 /= 1000.0;
FilmPosition = position2 + BaseFilmPosition;
}
};
//------------------------------------------------------------------------------------------------------------------------------------
//辊信号生成线速度-----------------------------------------------------------------------------------------------------------------------------
InitRoundFilmVelocity();
}
#region 辊信号生成 线速度
DispatcherTimer round_t;
DateTime dtRound;
int RCnt = 0;
double BaseFilmPosition = 0;
void InitRoundFilmVelocity()
{
round_t = new DispatcherTimer();
round_t.Interval = TimeSpan.FromSeconds(1);
round_t.Tick += new EventHandler(round_t_Tick);
mFlyAD.IStatusChangedEvent += new IStatusChangedEventHandler(mFlyAD_IStatusChangedEvent_round);
}
void mFlyAD_IStatusChangedEvent_round(object sender, IStatusChangedEventArgs e)
{
if (FilmVSrc != FilmVSRC.ROUND)
return;
if (!Misc.MyBase.CHECKBIT(e.IChanged, 11 - 1))
return;
if (Misc.MyBase.CHECKBIT(e.IStatus, 11 - 1))
return;
//1->0
DateTime dt = e.Time;
if (dt <= dtRound)
return;
if (dtRound != DateTime.MinValue)
{
double v = MmOfR / 1000.0 / (dt - dtRound).TotalMinutes;
if (v < 2)//太慢了
{
dt = DateTime.MinValue;
v = 0;
}
FilmVelocity = v;
if (v > 0)
{
RCnt++;
double p = RCnt * MmOfR / 1000.0 + BaseFilmPosition;
if (FilmPosition < p)
FilmPosition = p;
}
}
dtRound = dt;
if (dtRound != DateTime.MinValue)
{
if (!round_t.IsEnabled)
round_t.Start();
}
}
void round_t_Tick(object sender, EventArgs e)
{
if (FilmVSrc != FilmVSRC.ROUND)
{
round_t.Stop();
return;
}
if (dtRound == DateTime.MinValue)
{
round_t.Stop();
return;
}
//1->0
DateTime dt = DateTime.Now;
if (dt <= dtRound)
return;
double v = MmOfR / 1000.0 / (dt - dtRound).TotalMinutes;
if (v < (FilmVelocity - 1))
{
if (v < 2)
{
dtRound = DateTime.MinValue;
v = 0;
}
FilmVelocity = v;
}
double p1 = RCnt * MmOfR / 1000.0;
double p2 = (dt - dtRound).TotalMinutes * FilmVelocity;
if (p2 <= MmOfR / 1000.0)
p2 = MmOfR / 1000.0;
p1 += p2;
if (FilmPosition < p1)
FilmPosition = p1;
if (dtRound == DateTime.MinValue)
{
round_t.Stop();
return;
}
}
#endregion
/// <summary>
/// 设置膜位置为某值
/// </summary>
/// <param name="filmPosition"></param>
public void Reset(double filmPosition)
{
if (FilmVSrc == FilmVSRC.EN2)
{
mFlyAD.Position2 = 0;
}
else
{
FilmPosition = 0;
RCnt = 0;
}
BaseFilmPosition = filmPosition;
}
}
}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Fody" version="3.3.5" targetFramework="net40" developmentDependency="true" /> <package id="Fody" version="3.3.5" targetFramework="net40" developmentDependency="true" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net462" />
<package id="PropertyChanged2.Fody" version="2.6.0" targetFramework="net40" /> <package id="PropertyChanged2.Fody" version="2.6.0" targetFramework="net40" />
</packages> </packages>
\ No newline at end of file
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