1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using FLY.Thick.Base.Common;
using FLY.Thick.Base.Server;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLY.Simulation.Blowing
{
public class GageAD:ISimulationGageAD
{
/// <summary>
/// 1脉冲 = ? mm
/// </summary>
public double Mmpp { get; set; } = 0.0943;
/// <summary>
/// 机架总长 mm
/// </summary>
public int TotalLength { get; set; } = 2440;
public Blowing mBlowing;
/// <summary>
/// 膜宽,mm
/// </summary>
public int FilmWidth;
/// <summary>
/// 膜开始位置, mm
/// </summary>
public int FilmBegin;
/// <summary>
/// 传感器直径,单位mm
/// </summary>
public int SenserWidth;
CurveCollection curve;
public GageAD()
{
curve = new CurveCollection();
mBlowing = new Blowing();
FilmWidth = (int)mBlowing.FilmWidth;
FilmBegin = 300;
SenserWidth = 30;
}
public void OnPoll(DateTime now)
{
//NewAirDatas();
mBlowing.OnPoll(now);
}
public int GetAD(int mm)
{
return GetAD_1(mm);
//return GetAD_2(mm);
}
int GetAD_1(int mm)
{
Random r = new Random();
int data = r.Next(30*2) - 30;// 单位 0.01um, ±0.3um波动
if ((mm >= FilmBegin) && (mm<(FilmBegin+FilmWidth)))
{
int position_mm = mm-FilmBegin;
FilmData fd = mBlowing.GetData(position_mm);
if (fd != null)
{
data += fd.data1 + fd.data2;
}
}
//求平均值
double thick = data / 100.0;
return curve.Value2Ad(thick, AD2ValueFlag.NoRevised);
}
int GetAD_2(int mm)
{
int[] datas = new int[SenserWidth];
for (int i = 0; i < SenserWidth; i+=5)
{
datas[i] = GetAD_1(mm - SenserWidth / 2 + i);
}
//求平均值
return (int)datas.Average();
}
/// <summary>
/// 获取输入口
/// </summary>
/// <returns></returns>
public UInt16 GetInput()
{
UInt16 istatus = 0x0fff;
if (!mBlowing.IsShieldI9)
{
if (mBlowing.CheckLimit0())
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RENZIJIA_0);
}
if (mBlowing.CheckLimit1())
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RENZIJIA_1);
if (mBlowing.CheckOrg())
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RENZIJIA_ORG);
if (mBlowing.CheckRoll())
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RSENSOR);
return istatus;
}
public int GetPosition2()
{
double p = mBlowing.GlobalAngle / 360;
return (int)(mBlowing.PosOfR * p);
}
public int GetSpeed2()
{
return (int)(mBlowing.PosOfR * mBlowing.CurrAngleVelocity / 360);
}
public void SetOutput(ushort output)
{
}
}
}