12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238 |
- using Aitex.Core.Common.DeviceData;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- using MECF.Framework.Common.CommonData;
- using MECF.Framework.Common.DataCenter;
- using MECF.Framework.Common.OperationCenter;
- using OpenSEMI.ClientBase;
- using SciChart.Charting.Model.DataSeries;
- using SciChart.Charting.Visuals.Axes;
- using SciChart.Charting.Visuals.RenderableSeries;
- using SciChart.Data.Model;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Media;
- using VirgoUI.Client.Models.Sys;
- namespace VirgoUI.Client.Models.PMs
- {
- public class MFCVerificationDataListItem : NotifiableItem
- {
- private float _Setpoint;
- public float Setpoint
- {
- get
- {
- return _Setpoint;
- }
- set
- {
- _Setpoint = value;
- InvokePropertyChanged("Setpoint");
- }
- }
- private float _CalculateValue;
- public float CalculateValue
- {
- get
- {
- return _CalculateValue;
- }
- set
- {
- _CalculateValue = value;
- InvokePropertyChanged("CalculateValue");
- }
- }
- private float _ElapseTime;
- public float ElapseTime
- {
- get
- {
- return _ElapseTime;
- }
- set
- {
- _ElapseTime = value;
- InvokePropertyChanged("ElapseTime");
- }
- }
- private float _deviation;
- public float Deviation
- {
- get
- {
- return _deviation;
- }
- set
- {
- _deviation = value;
- InvokePropertyChanged("Deviation");
- }
- }
- private string _result;
- public string Result
- {
- get
- {
- return Convert.ToBoolean(_result) ? "OK" : "Failed";
- }
- set
- {
- _result = value;
- InvokePropertyChanged("Result");
-
- }
- }
- private string _resultBackground;
- public string ResultBackground
- {
- get
- {
- return _resultBackground;
- }
-
- set
- {
- _resultBackground = value;
-
- InvokePropertyChanged("ResultBackground");
- }
- }
- private float _pressure;
- public float Pressure
- {
- get
- {
- return _pressure;
- }
- set
- {
- _pressure = value;
- InvokePropertyChanged("Pressure");
- }
- }
- }
- public class MFCVerificationErrorRateListItem : NotifiableItem
- {
- public float Setpoint { get; set; }
- public float CalculateValue { get; set; }
- public float ErrorRate { get; set; }
- public float ElapsedTime { get; set; }
- public float Deviation { get; set; }
- public string Result { get; set; }
- }
- public class MFCVerificationData : NotifiableItem
- {
- public string Module { get; set; }
- public string Name { get; set; }
- public string Time { get; set; }
- public float Percent10Setpoint { get; set; }
- public float Percent10Calculate { get; set; }
- public float Percent20Setpoint { get; set; }
- public float Percent20Calculate { get; set; }
- public float Percent30Setpoint { get; set; }
- public float Percent30Calculate { get; set; }
- public float Percent40Setpoint { get; set; }
- public float Percent40Calculate { get; set; }
- public float Percent50Setpoint { get; set; }
- public float Percent50Calculate { get; set; }
- public float Percent60Setpoint { get; set; }
- public float Percent60Calculate { get; set; }
- public float Percent70Setpoint { get; set; }
- public float Percent70Calculate { get; set; }
- public float Percent80Setpoint { get; set; }
- public float Percent80Calculate { get; set; }
- public float Percent90Setpoint { get; set; }
- public float Percent90Calculate { get; set; }
- public float Percent100Setpoint { get; set; }
- public float Percent100Calculate { get; set; }
- public float Setpoint { get; set; }
- public float Calculate { get; set; }
- }
- public class MFCVerificationViewModel : ModuleUiViewModelBase, ISupportMultipleSystem
- {
- public MFCVerificationViewModel()
- {
- var now = DateTime.Today;
- SearchBeginTime = now;
- SearchEndTime = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59, 999);
- }
- #region MFCs
- #region MFCData
- private AITMfcData _mfc1DeviceData;
- [Subscription("MfcGas1")]
- public AITMfcData MFC1DeviceData
- {
- get
- {
- return _mfc1DeviceData;
- }
- set
- {
- if (_mfc1DeviceData == null || _mfc1DeviceData.Scale != value.Scale)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- int delta = (int)value.Scale / 10;
- if (MFC1VerificationPoints != null)
- MFC1VerificationPoints.Clear();
- else
- MFC1VerificationPoints = new ObservableCollection<int>();
- //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
- for (int i = 0; i < 10; i++)
- {
- MFC1VerificationPoints.Add(delta + delta * i);
- }
- }));
- }
- _mfc1DeviceData = value;
- }
- }
- private AITMfcData _mfc2DeviceData;
- [Subscription("MfcGas2")]
- public AITMfcData MFC2DeviceData
- {
- get
- {
- return _mfc2DeviceData;
- }
- set
- {
- if (_mfc2DeviceData == null || _mfc2DeviceData.Scale != value.Scale)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- int delta = (int)value.Scale / 10;
- if (MFC2VerificationPoints != null)
- MFC2VerificationPoints.Clear();
- else
- MFC2VerificationPoints = new ObservableCollection<int>();
- //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
- for (int i = 0; i < 10; i++)
- {
- MFC2VerificationPoints.Add(delta + delta * i);
- }
- }));
- }
- _mfc2DeviceData = value;
- }
- }
- private AITMfcData _mfc3DeviceData;
- [Subscription("MfcGas3")]
- public AITMfcData MFC3DeviceData
- {
- get
- {
- return _mfc3DeviceData;
- }
- set
- {
- if (_mfc3DeviceData == null || _mfc3DeviceData.Scale != value.Scale)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- int delta = (int)value.Scale / 10;
- if (MFC3VerificationPoints != null)
- MFC3VerificationPoints.Clear();
- else
- MFC3VerificationPoints = new ObservableCollection<int>();
- //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
- for (int i = 0; i < 10; i++)
- {
- MFC3VerificationPoints.Add(delta + delta * i);
- }
- }));
- }
- _mfc3DeviceData = value;
- }
- }
- private AITMfcData _mfc4DeviceData;
- [Subscription("MfcGas4")]
- public AITMfcData MFC4DeviceData
- {
- get
- {
- return _mfc4DeviceData;
- }
- set
- {
- if (_mfc4DeviceData == null || _mfc4DeviceData.Scale != value.Scale)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- int delta = (int)value.Scale / 10;
- if (MFC4VerificationPoints != null)
- MFC4VerificationPoints.Clear();
- else
- MFC4VerificationPoints = new ObservableCollection<int>();
- //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
- for (int i = 0; i < 10; i++)
- {
- MFC4VerificationPoints.Add(delta + delta * i);
- }
- }));
- }
- _mfc4DeviceData = value;
- }
- }
- private AITMfcData _mfc5DeviceData;
- [Subscription("MfcGas5")]
- public AITMfcData MFC5DeviceData
- {
- get
- {
- return _mfc5DeviceData;
- }
- set
- {
- if (_mfc5DeviceData == null || _mfc5DeviceData.Scale != value.Scale)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- int delta = (int)value.Scale / 10;
- if (MFC5VerificationPoints != null)
- MFC5VerificationPoints.Clear();
- else
- MFC5VerificationPoints = new ObservableCollection<int>();
- //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
- for (int i = 0; i < 10; i++)
- {
- MFC5VerificationPoints.Add(delta + delta * i);
- }
- }));
- }
- _mfc5DeviceData = value;
- }
- }
- #endregion
- #region MFCVerificationResult
- private string _MFC1VerificationResult;
- [Subscription("MfcGas1.VerificationResult")]
- public string MFC1VerificationResult
- {
- get
- {
- return _MFC1VerificationResult;
- }
- set
- {
- if(_MFC1VerificationResult != value)
- {
- var results = value.Split(';');
- if(results != null && results.Length > 0)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- MFC1VerificationData.Clear();
- foreach (var item in results)
- {
- var onePoint = item.Split(',');
- if (onePoint != null && onePoint.Length >= 5)
- {
- MFC1VerificationData.Add(new MFCVerificationDataListItem()
- {
- Setpoint = Convert.ToSingle(onePoint[0]),
- CalculateValue = Convert.ToSingle(onePoint[1]),
- ElapseTime = Convert.ToSingle(onePoint[2]),
- Deviation = Convert.ToSingle(onePoint[3]),
- Result = onePoint[4],
- ResultBackground = Convert.ToBoolean(onePoint[4]) ? "Green":"Red",
- });
- }
- else
- {
- if (onePoint != null && onePoint.Length >= 2)
- {
- MFC1VerificationData.Add(new MFCVerificationDataListItem()
- {
- Setpoint = Convert.ToSingle(onePoint[0]),
- CalculateValue = Convert.ToSingle(onePoint[1]),
- });
- }
- }
- }
- }));
- }
- }
- _MFC1VerificationResult = value;
- }
- }
- private string _MFC2VerificationResult;
- [Subscription("MfcGas2.VerificationResult")]
- public string MFC2VerificationResult
- {
- get
- {
- return _MFC2VerificationResult;
- }
- set
- {
- if (_MFC2VerificationResult != value)
- {
- var results = value.Split(';');
- if (results != null && results.Length > 0)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- MFC2VerificationData.Clear();
- foreach (var item in results)
- {
- var onePoint = item.Split(',');
- if (onePoint != null && onePoint.Length >= 5)
- {
- MFC2VerificationData.Add(new MFCVerificationDataListItem()
- {
- Setpoint = Convert.ToSingle(onePoint[0]),
- CalculateValue = Convert.ToSingle(onePoint[1]),
- ElapseTime = Convert.ToSingle(onePoint[2]),
- Deviation = Convert.ToSingle(onePoint[3]),
- Result = onePoint[4],
- ResultBackground = Convert.ToBoolean(onePoint[4]) ? "Green" : "Red",
- });
- }
- else
- {
- if (onePoint != null && onePoint.Length >= 2)
- {
- MFC2VerificationData.Add(new MFCVerificationDataListItem()
- {
- Setpoint = Convert.ToSingle(onePoint[0]),
- CalculateValue = Convert.ToSingle(onePoint[1]),
- });
- }
- }
- }
- }));
- }
- }
- _MFC2VerificationResult = value;
- }
- }
- private string _MFC3VerificationResult;
- [Subscription("MfcGas3.VerificationResult")]
- public string MFC3VerificationResult
- {
- get
- {
- return _MFC3VerificationResult;
- }
- set
- {
- if (_MFC3VerificationResult != value)
- {
- var results = value.Split(';');
- if (results != null && results.Length > 0)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- MFC3VerificationData.Clear();
- foreach (var item in results)
- {
- var onePoint = item.Split(',');
- if (onePoint != null && onePoint.Length >= 5)
- {
- MFC3VerificationData.Add(new MFCVerificationDataListItem()
- {
- Setpoint = Convert.ToSingle(onePoint[0]),
- CalculateValue = Convert.ToSingle(onePoint[1]),
- ElapseTime = Convert.ToSingle(onePoint[2]),
- Deviation = Convert.ToSingle(onePoint[3]),
- Result = onePoint[4],
- ResultBackground = Convert.ToBoolean(onePoint[4]) ? "Green" : "Red",
- });
- }
- else
- {
- if (onePoint != null && onePoint.Length >= 2)
- {
- MFC3VerificationData.Add(new MFCVerificationDataListItem()
- {
- Setpoint = Convert.ToSingle(onePoint[0]),
- CalculateValue = Convert.ToSingle(onePoint[1]),
- });
- }
- }
- }
- }));
- }
- }
- _MFC3VerificationResult = value;
- }
- }
- private string _MFC4VerificationResult;
- [Subscription("MfcGas4.VerificationResult")]
- public string MFC4VerificationResult
- {
- get
- {
- return _MFC4VerificationResult;
- }
- set
- {
- if (_MFC4VerificationResult != value)
- {
- var results = value.Split(';');
- if (results != null && results.Length > 0)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- MFC4VerificationData.Clear();
- foreach (var item in results)
- {
- var onePoint = item.Split(',');
- if (onePoint != null && onePoint.Length >= 5)
- {
- MFC4VerificationData.Add(new MFCVerificationDataListItem()
- {
- Setpoint = Convert.ToSingle(onePoint[0]),
- CalculateValue = Convert.ToSingle(onePoint[1]),
- ElapseTime = Convert.ToSingle(onePoint[2]),
- Deviation = Convert.ToSingle(onePoint[3]),
- Result = onePoint[4],
- ResultBackground = Convert.ToBoolean(onePoint[4]) ? "Green" : "Red",
- });
- }
- else
- {
- if (onePoint != null && onePoint.Length >= 2)
- {
- MFC4VerificationData.Add(new MFCVerificationDataListItem()
- {
- Setpoint = Convert.ToSingle(onePoint[0]),
- CalculateValue = Convert.ToSingle(onePoint[1]),
- });
- }
- }
- }
- }));
- }
- }
- _MFC4VerificationResult = value;
- }
- }
- private string _MFC5VerificationResult;
- [Subscription("MfcGas5.VerificationResult")]
- public string MFC5VerificationResult
- {
- get
- {
- return _MFC5VerificationResult;
- }
- set
- {
- if (_MFC5VerificationResult != value)
- {
- var results = value.Split(';');
- if (results != null && results.Length > 0)
- {
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- MFC5VerificationData.Clear();
- foreach (var item in results)
- {
- var onePoint = item.Split(',');
- if (onePoint != null && onePoint.Length >= 5)
- {
- MFC5VerificationData.Add(new MFCVerificationDataListItem()
- {
- Setpoint = Convert.ToSingle(onePoint[0]),
- CalculateValue = Convert.ToSingle(onePoint[1]),
- ElapseTime = Convert.ToSingle(onePoint[2]),
- Deviation = Convert.ToSingle(onePoint[3]),
- Result = onePoint[4],
- ResultBackground = Convert.ToBoolean(onePoint[4]) ? "Green" : "Red",
- });
- }
- else
- {
- if (onePoint != null && onePoint.Length >= 2)
- {
- MFC5VerificationData.Add(new MFCVerificationDataListItem()
- {
- Setpoint = Convert.ToSingle(onePoint[0]),
- CalculateValue = Convert.ToSingle(onePoint[1]),
- });
- }
- }
- }
- }));
- }
- }
- _MFC5VerificationResult = value;
- }
- }
- #endregion
- public bool MFC1IsEnable { get; set; }
- public bool MFC2IsEnable { get; set; }
- public bool MFC3IsEnable { get; set; }
- public bool MFC4IsEnable { get; set; }
- public bool MFC5IsEnable { get; set; }
- public bool IsMfc1Checked { get; set; }
- public bool IsMfc2Checked { get; set; }
- public bool IsMfc3Checked { get; set; }
- public bool IsMfc4Checked { get; set; }
- public bool IsMfc5Checked { get; set; }
- public bool[] IsMfcChecked
- {
- get
- {
- bool[] isMfcCheck = new bool[]
- {
- IsMfc1Checked,
- IsMfc2Checked,
- IsMfc3Checked,
- IsMfc4Checked,
- };
- return isMfcCheck;
- }
- }
- #endregion
- private string _pmStatus;
- [Subscription("FsmState")]
- public string PMStatus
- {
- get
- {
- return _pmStatus;
- }
- set
- {
- if (_pmStatus != value)
- Query();
- _pmStatus = value;
- }
- }
- [Subscription("IsOnline")]
- public bool IsOnline { get; set; }
- public string Setpoint { get; set; }
- public bool IsVerificationButtonEnable => PMStatus == "Idle" && !IsOnline;
-
- public bool IsPermission { get => this.Permission == 3; }
- public Visibility MFCQueryVisibility
- {
- get; set;
- }
- public ObservableCollection<IRenderableSeries> SelectedData { get; set; }
- private IRange _xValueRange;
- public IRange XValueRange
- {
- get { return _xValueRange; }
- set { _xValueRange = value; NotifyOfPropertyChange("XValueRange"); }
- }
- private IRange _yValueRange;
- public IRange YValueRange
- {
- get { return _yValueRange; }
- set { _yValueRange = value; NotifyOfPropertyChange("YValueRange"); }
- }
- public AutoRange ChartAutoRange
- {
- get { return EnableAutoZoom ? AutoRange.Always : AutoRange.Never; }
- }
- private bool _enableAutoZoom = true;
- public bool EnableAutoZoom
- {
- get { return _enableAutoZoom; }
- set
- {
- _enableAutoZoom = value;
- NotifyOfPropertyChange(nameof(EnableAutoZoom));
- NotifyOfPropertyChange(nameof(ChartAutoRange));
- }
- }
- private AutoRange _autoRangeX;
- public AutoRange AutoRangeX
- {
- get => _autoRangeX;
- set { _autoRangeX = value; NotifyOfPropertyChange(nameof(AutoRangeX)); }
- }
- private AutoRange _autoRangeY;
- public AutoRange AutoRangeY
- {
- get => _autoRangeY;
- set { _autoRangeY = value; NotifyOfPropertyChange(nameof(AutoRangeY)); }
- }
- public ObservableCollection<MFCVerificationDataListItem> MFC1VerificationData { get; set; }
- public ObservableCollection<MFCVerificationDataListItem> MFC2VerificationData { get; set; }
- public ObservableCollection<MFCVerificationDataListItem> MFC3VerificationData { get; set; }
- public ObservableCollection<MFCVerificationDataListItem> MFC4VerificationData { get; set; }
- public ObservableCollection<MFCVerificationDataListItem> MFC5VerificationData { get; set; }
- public ObservableCollection<MFCVerificationErrorRateListItem> VerificationErrorRate { get; set; }
- public ObservableCollection<int> MFC1VerificationPoints { get; set; }
- public ObservableCollection<int> MFC2VerificationPoints { get; set; }
- public ObservableCollection<int> MFC3VerificationPoints { get; set; }
- public ObservableCollection<int> MFC4VerificationPoints { get; set; }
- public ObservableCollection<int> MFC5VerificationPoints { get; set; }
- public ObservableCollection<MFCVerificationData> VerificationDataRecords { get; set; }//read form db
- private MFCVerificationData selectedVerificationData;
- public MFCVerificationData SelectedVerificationData
- {
- get { return this.selectedVerificationData; }
- set
- {
- this.selectedVerificationData = value;
- }
- }
- public DateTime SearchBeginTime { get; set; }
- public DateTime SearchEndTime { get; set; }
- private MFCVerificationView view;
- public Visibility MFC1Visibility => MFC1IsEnable ? Visibility.Visible : Visibility.Collapsed;
- public Visibility MFC2Visibility => MFC2IsEnable ? Visibility.Visible : Visibility.Collapsed;
- public Visibility MFC3Visibility => MFC3IsEnable ? Visibility.Visible : Visibility.Collapsed;
- public Visibility MFC4Visibility => MFC4IsEnable ? Visibility.Visible : Visibility.Collapsed;
- public string MFC1BackGround => !MFC1IsEnable ? "Gold" : "White";
- public string MFC2BackGround => !MFC2IsEnable ? "Gold" : "White";
- public string MFC3BackGround => !MFC3IsEnable ? "Gold" : "White";
- public string MFC4BackGround => !MFC4IsEnable ? "Gold" : "White";
- protected override void OnInitialize()
- {
- MFC1VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
- MFC2VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
- MFC3VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
- MFC4VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
- MFC5VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
- MFC1VerificationPoints = new ObservableCollection<int>();
- MFC2VerificationPoints = new ObservableCollection<int>();
- MFC3VerificationPoints = new ObservableCollection<int>();
- MFC4VerificationPoints = new ObservableCollection<int>();
- MFC5VerificationPoints = new ObservableCollection<int>();
- MFCQueryVisibility = Visibility.Collapsed;
- base.OnInitialize();
- YValueRange = new DoubleRange(0, 100);
- SelectedData = new ObservableCollection<IRenderableSeries>();
- AutoRangeX = AutoRange.Always;
- AutoRangeY = AutoRange.Always;//(bool)QueryDataClient.Instance.Service.GetConfig("System.IsCycleMode");
- }
- protected override void OnActivate()
- {
- XValueRange = new DoubleRange(0, MFC1DeviceData != null ? MFC1DeviceData.Scale : 100);
- base.OnActivate();
- Query();
- MFC1IsEnable = true;
- MFC2IsEnable = true;
- MFC3IsEnable = true;
- MFC4IsEnable = true;
- MFC5IsEnable = true;
- }
- protected override void OnViewLoaded(object _view)
- {
- base.OnViewLoaded(_view);
- this.view = (MFCVerificationView)_view;
- this.view.wfTimeFrom.Value = this.SearchBeginTime;
- this.view.wfTimeTo.Value = this.SearchEndTime;
- Query();
- }
- protected override void OnDeactivate(bool close)
- {
- base.OnDeactivate(close);
- }
- public void StartVerification(object oj1, object oj2, object oj3)
- {
- string gasName = oj1.ToString();
- float.TryParse(oj2.ToString(), out float flow);
- int.TryParse(oj3.ToString(), out int flowCount);
- InvokeClient.Instance.Service.DoOperation($"{SystemName}.MFCVerification", gasName, flow, flowCount);
- }
- public void StartAllCali()
- {
-
- bool IsSelectedMFC = false;
- foreach (bool IsCheck in IsMfcChecked)
- {
- if (IsCheck)
- IsSelectedMFC = true;
- }
- if (!IsSelectedMFC)
- {
- MessageBox.Show("Please select at least one Gas.", "Calibration", MessageBoxButton.OK, MessageBoxImage.Warning);
- return;
- }
- string[] gasName = new string[] { "MFC1", "MFC2", "MFC3", "MFC4" };
-
- InvokeClient.Instance.Service.DoOperation($"{SystemName}.AllMFCVerification", gasName, IsMfcChecked);
- }
- public void AcceptAll(object o)
- {
- string gasName = o.ToString();
- InvokeClient.Instance.Service.DoOperation($"{SystemName}.{gasName}.AcceptAllMFCVerification", gasName);
- }
- public void Back()
- {
- MFCQueryVisibility = Visibility.Collapsed;
- NotifyOfPropertyChange("RFCalVisibility");
- NotifyOfPropertyChange("MFCQueryVisibility");
- }
- public void SelectHistory()
- {
- if (SelectedVerificationData != null)
- {
- try
- {
- if (SelectedVerificationData.Name.Contains("Gas1"))
- XValueRange = new DoubleRange(0, MFC1DeviceData.Scale);
- else if (SelectedVerificationData.Name.Contains("Gas2"))
- XValueRange = new DoubleRange(0, MFC2DeviceData.Scale);
- else if (SelectedVerificationData.Name.Contains("Gas3"))
- XValueRange = new DoubleRange(0, MFC3DeviceData.Scale);
- else
- XValueRange = new DoubleRange(0, MFC4DeviceData.Scale);
- MFCQueryVisibility = Visibility.Visible;
- NotifyOfPropertyChange("MFCQueryVisibility");
- VerificationErrorRate = new ObservableCollection<MFCVerificationErrorRateListItem>();
- MFCVerificationErrorRateListItem errorRate = new MFCVerificationErrorRateListItem()
- {
- Setpoint = SelectedVerificationData.Percent10Setpoint,
- CalculateValue = SelectedVerificationData.Percent10Calculate,
- ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent10Setpoint - SelectedVerificationData.Percent10Calculate) / SelectedVerificationData.Percent10Setpoint * 100, 3))
- };
- VerificationErrorRate.Add(errorRate);
- errorRate = new MFCVerificationErrorRateListItem()
- {
- Setpoint = SelectedVerificationData.Percent20Setpoint,
- CalculateValue = SelectedVerificationData.Percent20Calculate,
- ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent20Setpoint - SelectedVerificationData.Percent20Calculate) / SelectedVerificationData.Percent20Setpoint * 100, 3))
- };
- VerificationErrorRate.Add(errorRate);
- errorRate = new MFCVerificationErrorRateListItem()
- {
- Setpoint = SelectedVerificationData.Percent30Setpoint,
- CalculateValue = SelectedVerificationData.Percent30Calculate,
- ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent30Setpoint - SelectedVerificationData.Percent30Calculate) / SelectedVerificationData.Percent30Setpoint * 100, 3))
- };
- VerificationErrorRate.Add(errorRate);
- errorRate = new MFCVerificationErrorRateListItem()
- {
- Setpoint = SelectedVerificationData.Percent40Setpoint,
- CalculateValue = SelectedVerificationData.Percent40Calculate,
- ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent40Setpoint - SelectedVerificationData.Percent40Calculate) / SelectedVerificationData.Percent40Setpoint * 100, 3))
- };
- VerificationErrorRate.Add(errorRate);
- errorRate = new MFCVerificationErrorRateListItem()
- {
- Setpoint = SelectedVerificationData.Percent50Setpoint,
- CalculateValue = SelectedVerificationData.Percent50Calculate,
- ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent50Setpoint - SelectedVerificationData.Percent50Calculate) / SelectedVerificationData.Percent50Setpoint * 100, 3))
- };
- VerificationErrorRate.Add(errorRate);
- errorRate = new MFCVerificationErrorRateListItem()
- {
- Setpoint = SelectedVerificationData.Percent60Setpoint,
- CalculateValue = SelectedVerificationData.Percent60Calculate,
- ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent60Setpoint - SelectedVerificationData.Percent60Calculate) / SelectedVerificationData.Percent60Setpoint * 100, 3))
- };
- VerificationErrorRate.Add(errorRate);
- errorRate = new MFCVerificationErrorRateListItem()
- {
- Setpoint = SelectedVerificationData.Percent70Setpoint,
- CalculateValue = SelectedVerificationData.Percent70Calculate,
- ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent70Setpoint - SelectedVerificationData.Percent70Calculate) / SelectedVerificationData.Percent70Setpoint * 100, 3))
- };
- VerificationErrorRate.Add(errorRate);
- errorRate = new MFCVerificationErrorRateListItem()
- {
- Setpoint = SelectedVerificationData.Percent80Setpoint,
- CalculateValue = SelectedVerificationData.Percent80Calculate,
- ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent80Setpoint - SelectedVerificationData.Percent80Calculate) / SelectedVerificationData.Percent80Setpoint * 100, 3))
- };
- VerificationErrorRate.Add(errorRate);
- errorRate = new MFCVerificationErrorRateListItem()
- {
- Setpoint = SelectedVerificationData.Percent90Setpoint,
- CalculateValue = SelectedVerificationData.Percent90Calculate,
- ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent90Setpoint - SelectedVerificationData.Percent90Calculate) / SelectedVerificationData.Percent90Setpoint * 100, 3))
- };
- VerificationErrorRate.Add(errorRate);
- errorRate = new MFCVerificationErrorRateListItem()
- {
- Setpoint = SelectedVerificationData.Percent100Setpoint,
- CalculateValue = SelectedVerificationData.Percent100Calculate,
- ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent100Setpoint - SelectedVerificationData.Percent100Calculate) / SelectedVerificationData.Percent100Setpoint * 100, 3))
- };
- VerificationErrorRate.Add(errorRate);//SelectedData
- ChartDataLine line = new ChartDataLine("MFCCalibration");
- VerificationErrorRate.ToList().ForEach(x => line.Append(x.Setpoint, x.ErrorRate));
- //foreach(var item in VerificationErrorRate)
- //{
- // line.Append(item.Setpoint,item.ErrorRate);
- //}
- SelectedData.Clear();
- SelectedData.Add(line);
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- public void Query()
- {
- if (view == null || view.wfTimeFrom == null || view.wfTimeFrom == null)
- return;
- try
- {
- this.SearchBeginTime = (System.DateTime)this.view.wfTimeFrom.Value;
- this.SearchEndTime = (System.DateTime)this.view.wfTimeTo.Value;
- if (SearchBeginTime > SearchEndTime)
- {
- MessageBox.Show("Time range invalid, start time should be early than end time");
- return;
- }
- string sql = string.Format(
- "SELECT * FROM \"mfc_verification_data\" where \"operate_time\" >= '{0}' and \"operate_time\" <= '{1}' and \"module\" = '{2}' order by \"operate_time\" ASC;",
- SearchBeginTime.ToString("yyyyMMdd HHmmss"), SearchEndTime.ToString("yyyyMMdd HHmmss"), SystemName);
- var result = QueryDataClient.Instance.Service.QueryData(sql);
- Application.Current.Dispatcher.BeginInvoke(new Action(() =>
- {
- VerificationDataRecords = new ObservableCollection<MFCVerificationData>();
- for (int i = 0; i < result.Rows.Count; i++)
- {
- MFCVerificationData data = new MFCVerificationData()
- {
- Module = result.Rows[i]["module"].ToString(),
- Name = result.Rows[i]["name"].ToString(),
- Time = ((DateTime)result.Rows[i]["operate_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff"),
- Percent10Setpoint = float.Parse(result.Rows[i]["percent10_setpoint"].ToString()),
- Percent10Calculate = float.Parse(result.Rows[i]["percent10_calculate"].ToString()),
- Percent20Setpoint = float.Parse(result.Rows[i]["percent20_setpoint"].ToString()),
- Percent20Calculate = float.Parse(result.Rows[i]["percent20_calculate"].ToString()),
- Percent30Setpoint = float.Parse(result.Rows[i]["percent30_setpoint"].ToString()),
- Percent30Calculate = float.Parse(result.Rows[i]["percent30_calculate"].ToString()),
- Percent40Setpoint = float.Parse(result.Rows[i]["percent40_setpoint"].ToString()),
- Percent40Calculate = float.Parse(result.Rows[i]["percent40_calculate"].ToString()),
- Percent50Setpoint = float.Parse(result.Rows[i]["percent50_setpoint"].ToString()),
- Percent50Calculate = float.Parse(result.Rows[i]["percent50_calculate"].ToString()),
- Percent60Setpoint = float.Parse(result.Rows[i]["percent60_setpoint"].ToString()),
- Percent60Calculate = float.Parse(result.Rows[i]["percent60_calculate"].ToString()),
- Percent70Setpoint = float.Parse(result.Rows[i]["percent70_setpoint"].ToString()),
- Percent70Calculate = float.Parse(result.Rows[i]["percent70_calculate"].ToString()),
- Percent80Setpoint = float.Parse(result.Rows[i]["percent80_setpoint"].ToString()),
- Percent80Calculate = float.Parse(result.Rows[i]["percent80_calculate"].ToString()),
- Percent90Setpoint = float.Parse(result.Rows[i]["percent90_setpoint"].ToString()),
- Percent90Calculate = float.Parse(result.Rows[i]["percent90_calculate"].ToString()),
- Percent100Setpoint = float.Parse(result.Rows[i]["percent100_setpoint"].ToString()),
- Percent100Calculate = float.Parse(result.Rows[i]["percent100_calculate"].ToString()),
- Setpoint = float.Parse(result.Rows[i]["setpoint"].ToString()),
- Calculate = float.Parse(result.Rows[i]["calculate"].ToString()),
- };
- VerificationDataRecords.Add(data);
- }
- NotifyOfPropertyChange("VerificationDataRecords");
- }));
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- }
- public void SetAsCurrent(object o)
- {
- int.TryParse(o.ToString(), out int selectIndex);
- if (selectIndex < 0 || selectIndex >= VerificationDataRecords.Count)
- {
- MessageBox.Show("Please select a row to set.", "Calibration", MessageBoxButton.OK, MessageBoxImage.Warning);
- return;
- }
- InvokeClient.Instance.Service.DoOperation($"{SystemName}.{VerificationDataRecords[selectIndex].Name}.UpdateCalibrationInfo",
- VerificationDataRecords[selectIndex].Percent10Calculate,
- VerificationDataRecords[selectIndex].Percent20Calculate,
- VerificationDataRecords[selectIndex].Percent30Calculate,
- VerificationDataRecords[selectIndex].Percent40Calculate,
- VerificationDataRecords[selectIndex].Percent50Calculate,
- VerificationDataRecords[selectIndex].Percent60Calculate,
- VerificationDataRecords[selectIndex].Percent70Calculate,
- VerificationDataRecords[selectIndex].Percent80Calculate,
- VerificationDataRecords[selectIndex].Percent90Calculate,
- VerificationDataRecords[selectIndex].Percent100Calculate);
- }
- public void Abort()
- {
- InvokeClient.Instance.Service.DoOperation($"{SystemName}.Abort");
- }
- }
- public class ChartDataLine : FastLineRenderableSeries, INotifyPropertyChanged
- {
- #region PropertyChanged
- public event PropertyChangedEventHandler PropertyChanged;
- public void InvokePropertyChanged(string propertyName)
- {
- PropertyChangedEventArgs eventArgs = new PropertyChangedEventArgs(propertyName);
- PropertyChangedEventHandler changed = PropertyChanged;
- if (changed != null)
- {
- changed(this, eventArgs);
- }
- }
- public void InvokePropertyChanged()
- {
- Type t = this.GetType();
- var ps = t.GetProperties();
- foreach (var p in ps)
- {
- InvokePropertyChanged(p.Name);
- }
- }
- #endregion
- public string UniqueId { get; set; }
- public List<Tuple<double, double>> Points
- {
- get
- {
- lock (_lockData)
- {
- return _queueRawData.ToList();
- }
- }
- }
- public string DataSource { get; set; }
- public string DataName { get; set; }
- public string DisplayName
- {
- get
- {
- return DataSeries.SeriesName;
- }
- set
- {
- DataSeries.SeriesName = value;
- }
- }
- public double LineThickness
- {
- get
- {
- return StrokeThickness;
- }
- set
- {
- var i = Convert.ToInt32(value);
- if (i < 1) i = 1;
- if (i > 100) i = 100;
- StrokeThickness = i;
- InvokePropertyChanged("LineThickness");
- }
- }
- private double _dataFactor = 1.0;
- public double DataFactor
- {
- get => _dataFactor;
- set
- {
- if (Math.Abs(_dataFactor - value) > 0.001)
- {
- _dataFactor = value;
- InvokePropertyChanged(nameof(DataFactor));
- UpdateChartSeriesValue();
- }
- }
- }
- private double _dataOffset = 0;
- public double DataOffset
- {
- get => _dataOffset;
- set
- {
- if (Math.Abs(_dataOffset - value) > 0.001)
- {
- _dataOffset = value;
- InvokePropertyChanged(nameof(DataFactor));
- UpdateChartSeriesValue();
- }
- }
- }
- private int _capacity = 10000;
- public int Capacity
- {
- get { return _capacity; }
- set
- {
- _capacity = value;
- DataSeries.FifoCapacity = value;
- }
- }
- private object _lockData = new object();
- private FixSizeQueue<Tuple<double, double>> _queueRawData;
- public ChartDataLine(string dataName)
- : this(dataName, dataName, Colors.Blue)
- {
- }
- public ChartDataLine(string dataName, string displayName, Color seriesColor)
- {
- UniqueId = Guid.NewGuid().ToString();
- _queueRawData = new FixSizeQueue<Tuple<double, double>>(_capacity);
- XAxisId = "DefaultAxisId";
- YAxisId = "DefaultAxisId";
- DataSeries = new XyDataSeries<double, double>(_capacity);
- DisplayName = displayName;
- DataName = dataName;
- Stroke = seriesColor;
- IsVisible = true;
- DataOffset = 0;
- LineThickness = 1;
- DataFactor = 1;
- }
- public void Append(double dt, double value)
- {
- lock (_lockData)
- {
- _queueRawData.Enqueue(Tuple.Create(dt, value));
- (DataSeries as XyDataSeries<double, double>)?.Append(dt, value * _dataFactor + _dataOffset);
- }
- }
- public void UpdateChartSeriesValue()
- {
- lock (_lockData)
- {
- using (DataSeries.SuspendUpdates())
- {
- XyDataSeries<double, double> s = DataSeries as XyDataSeries<double, double>;
- for (int i = 0; i < s.Count; i++)
- {
- s.Update(i, _queueRawData.ElementAt(i).Item2 * _dataFactor + _dataOffset);
- }
- }
- }
- }
- public void ClearData()
- {
- lock (_lockData)
- {
- _queueRawData.Clear();
- (DataSeries as XyDataSeries<double, double>)?.Clear();
- }
- }
- }
- }
|