using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.ComponentModel; namespace FLY.Simulation.Casting { public class GageAD : ISimulationGageAD, INotifyPropertyChanged { CurveCollection curve; //这是整个机架的数据 List datas_horizontal = new List();//横向AD数据, 1mm 一个AD值 /// /// 编码器2 1脉冲 = ? mm 辊直径120mm,编码器 转1圈800脉冲 /// const double Mmpp2 = 0.1;//120 * 3.14 / 800; const double RLen = 120 * 3.14; /// /// 1脉冲 = ? mm /// double mmpp = 0.1133; public double Mmpp { get { return mmpp; } set { mmpp = value; } } double filmvelocity = 23; /// /// 膜速度 m/min /// public double FilmVelocity { get { return filmvelocity; } set { if (filmvelocity != value) { filmvelocity = value; NotifyPropertyChanged("FilmVelocity"); } } } double filmlength = 0; /// /// 膜长 m /// public double FilmLength { get { return filmlength; } set { if (filmlength != value) { filmlength = value; NotifyPropertyChanged("FilmLength"); } } } bool isRunning = true; /// /// 运转中 /// public bool IsRunning { get { return isRunning; } set { if (isRunning != value) { isRunning = value; NotifyPropertyChanged("IsRunning"); } } } public GageAD() { curve = new CurveCollection("curve.xml"); Load(); } public int GetAD(int position) { int idx = (int)(position * Mmpp); if (idx < 0) idx = 0; else if (idx >= datas_horizontal.Count()) idx = datas_horizontal.Count() - 1; int ad = datas_horizontal[idx]; //Random r = new Random(); //int data = r.Next(50) - 25; //thick += data; return ad;// curve.Value2AD(thick, CurveCollection.AD2ValueFlag.NoRevised); } DateTime dtlast = DateTime.MinValue; public void OnPoll(DateTime now) { if (dtlast == DateTime.MinValue) { dtlast = now; return; } if (IsRunning) { double min = (now - dtlast).TotalMinutes; FilmLength += min * FilmVelocity; } dtlast = now; } public UInt16 GetInput() { UInt16 istatus = 0x0fff; double p = FilmLength * 1000 % RLen; if(p