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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLY.Simulation.Blowing
{
public class GageAD:ISimulationGageAD
{
/// <summary>
/// 1脉冲 = ? mm
/// </summary>
double mmpp = 0.1133;
public double Mmpp
{
get { return mmpp; }
set
{
mmpp = value;
}
}
public Blowing mBlowing;
/// <summary>
/// 机架总长
/// </summary>
public int PosLen;
/// <summary>
/// 膜宽
/// </summary>
public int FilmWidth;
/// <summary>
/// 膜开始位置
/// </summary>
public int FilmBegin;
/// <summary>
/// 传感器直径
/// </summary>
public int SenserWidth;
public int[] AirDatas;
CurveCollection curve;
public GageAD()
{
curve = new CurveCollection();
double mm_gagelen = 3000;//设备总长3m
double mm_filmwidth = 2300;//膜宽2.3m
double mm_senserwidth = 15;//传感器15mm
double mm_filmbegin = 300;//mm
PosLen = 8030;
double ppmm = PosLen / mm_gagelen;
FilmWidth = (int)(mm_filmwidth * ppmm);
FilmBegin = (int)(mm_filmbegin * ppmm);
SenserWidth = (int)(mm_senserwidth * ppmm);
mBlowing = new Blowing();
mBlowing.FilmWidth = FilmWidth;
AirDatas = new int[PosLen];
NewAirDatas();
}
void NewAirDatas()
{
int a = 20;
Random r = new Random();
for (int i = 0; i < AirDatas.Count(); i++)
{
AirDatas[i] = r.Next(a) - a/2;
}
}
public void OnPoll(DateTime now)
{
//NewAirDatas();
mBlowing.OnPoll(now);
}
public int GetAD(int pos)
{
return GetAD_1(pos);
//return GetAD_2(pos);
}
int GetAD_1(int pos)
{
int idx = pos;
if(idx<0)
idx = 0;
else if(idx>=PosLen)
idx = PosLen-1;
Random r = new Random();
int data = r.Next(50) - 25;
if ((idx >= FilmBegin) && (idx<(FilmBegin+FilmWidth)))
{
FilmData fd = mBlowing.GetData(idx-FilmBegin);
if (fd != null)
{
data += fd.data1 + fd.data2;
}
}
//求平均值
int thick = (int)data;
return curve.Value2AD(thick, CurveCollection.AD2ValueFlag.NoRevised);
}
int GetAD_2(int pos)
{
int[] datas = new int[SenserWidth];
for (int i = 0; i < SenserWidth; i++)
{
datas[i] = GetAD_1(pos - 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 - 1);
}
if (mBlowing.CheckLimit1())
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RENZIJIA_1-1);
if (mBlowing.CheckRoll())
Misc.MyBase.CLEARBIT(ref istatus, IODefinition.IN_RSENSOR-1);
return istatus;
}
public int GetPosition2()
{
return 0;
}
public int GetSpeed2()
{
return 0;
}
}
}