404 lines
10 KiB
C#
404 lines
10 KiB
C#
using Community;
|
|
using Model.MotionControl;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Model
|
|
{
|
|
/// <summary>
|
|
/// 圆柱测量数据
|
|
/// </summary>
|
|
public class CylinderMeasurementModel : NotificationObject
|
|
{
|
|
public int ID { get; set; }
|
|
|
|
/// <summary>
|
|
/// 序号
|
|
/// </summary>
|
|
public int SerialNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// 上级ID
|
|
/// </summary>
|
|
public int SuperiorID { get; set; }
|
|
|
|
private string cmName;
|
|
/// <summary>
|
|
/// 名称
|
|
/// </summary>
|
|
public string CmName
|
|
{
|
|
get { return cmName; }
|
|
set
|
|
{
|
|
cmName = value;
|
|
RaisePropertyChanged("CmName");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 数据数量
|
|
/// </summary>
|
|
private int DataCount { get; set; }
|
|
/// <summary>
|
|
/// 数据综合
|
|
/// </summary>
|
|
private double DataTotal { get; set; }
|
|
|
|
/// <summary>
|
|
/// 累计误差值
|
|
/// </summary>
|
|
private double DrrorTotal { get; set; }
|
|
|
|
|
|
private string diamStr;
|
|
/// <summary>
|
|
/// 接收到的测量数据字符
|
|
/// </summary>
|
|
public string DiamStr
|
|
{
|
|
get { return diamStr; }
|
|
set { diamStr = value;
|
|
//RaisePropertyChanged("DiamStr");
|
|
if(!string.IsNullOrEmpty(value))
|
|
{
|
|
try
|
|
{
|
|
Diam = Convert.ToDouble(value);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private double diam;
|
|
/// <summary>
|
|
/// 外径
|
|
/// </summary>
|
|
public double Diam
|
|
{
|
|
get { return diam; }
|
|
set
|
|
{
|
|
diam = value;
|
|
RaisePropertyChanged("Diam");
|
|
if (value > MaxDiam)
|
|
{
|
|
MaxDiam = value;
|
|
}
|
|
else if (value < MinDiam || MinDiam <= 0)
|
|
{
|
|
MinDiam = value;
|
|
|
|
}
|
|
|
|
if (value > 0)
|
|
{
|
|
//平均外径
|
|
DataCount++;
|
|
DataTotal += value;
|
|
AverageDiam = Math.Round(DataTotal / DataCount, 2);
|
|
|
|
//跳动率
|
|
if (value > MaxDiam)
|
|
{
|
|
DataTotal += Math.Abs(value - MaxDiamS);
|
|
}
|
|
else if (value < MinDiam)
|
|
{
|
|
DataTotal += Math.Abs(value - MinDiamS);
|
|
}
|
|
|
|
BeatRate = Math.Round(DataTotal / DataCount, 2);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private double maxDiam;
|
|
/// <summary>
|
|
/// 当前最大外径
|
|
/// </summary>
|
|
public double MaxDiam
|
|
{
|
|
get { return maxDiam; }
|
|
set
|
|
{
|
|
maxDiam = value;
|
|
RaisePropertyChanged("MaxDiam");
|
|
}
|
|
}
|
|
|
|
|
|
private double maxDiamS;
|
|
/// <summary>
|
|
/// 标准最大半径
|
|
/// </summary>
|
|
public double MaxDiamS
|
|
{
|
|
get { return maxDiamS; }
|
|
set
|
|
{
|
|
maxDiamS = value;
|
|
if (value > 0 && MinDiamS > 0)
|
|
{
|
|
AverageDiamS = Math.Round((value + MinDiamS)/2, 2);
|
|
}
|
|
RaisePropertyChanged("MaxDiamS");
|
|
}
|
|
}
|
|
|
|
private double minDiam;
|
|
/// <summary>
|
|
/// 最小外径
|
|
/// </summary>
|
|
public double MinDiam
|
|
{
|
|
get { return minDiam; }
|
|
set
|
|
{
|
|
minDiam = value;
|
|
RaisePropertyChanged("MinDiam");
|
|
}
|
|
}
|
|
|
|
private double minDiamS;
|
|
/// <summary>
|
|
/// 标准最小半径
|
|
/// </summary>
|
|
public double MinDiamS
|
|
{
|
|
get { return minDiamS; }
|
|
set
|
|
{
|
|
minDiamS = value;
|
|
if(value>0&& MaxDiamS>0)
|
|
{
|
|
AverageDiamS = Math.Round((value + MaxDiamS)/2,2);
|
|
}
|
|
RaisePropertyChanged("MinDiamS");
|
|
}
|
|
}
|
|
|
|
private double averageDiam;
|
|
/// <summary>
|
|
/// 平均外径
|
|
/// </summary>
|
|
public double AverageDiam
|
|
{
|
|
get { return averageDiam; }
|
|
set
|
|
{
|
|
averageDiam = value;
|
|
RaisePropertyChanged("AverageDiam");
|
|
}
|
|
}
|
|
|
|
private double averageDiamS;
|
|
/// <summary>
|
|
/// 标准平均外径
|
|
/// </summary>
|
|
public double AverageDiamS
|
|
{
|
|
get { return averageDiamS; }
|
|
set
|
|
{
|
|
averageDiamS = value;
|
|
RaisePropertyChanged("AverageDiamS");
|
|
}
|
|
}
|
|
|
|
private double beatRate;
|
|
/// <summary>
|
|
/// 跳动率
|
|
/// </summary>
|
|
public double BeatRate
|
|
{
|
|
get { return beatRate; }
|
|
set
|
|
{
|
|
beatRate = value;
|
|
RaisePropertyChanged("BeatRate");
|
|
}
|
|
}
|
|
|
|
private double beatRateS;
|
|
/// <summary>
|
|
/// 标准跳动率
|
|
/// </summary>
|
|
public double BeatRateS
|
|
{
|
|
get { return beatRateS; }
|
|
set
|
|
{
|
|
beatRateS = value;
|
|
RaisePropertyChanged("BeatRateS");
|
|
}
|
|
}
|
|
|
|
|
|
private ShowInfo maxDiamState;
|
|
/// <summary>
|
|
/// 最大外径状态
|
|
/// </summary>
|
|
public ShowInfo MaxDiamState
|
|
{
|
|
get { return maxDiamState; }
|
|
set
|
|
{
|
|
maxDiamState = value;
|
|
RaisePropertyChanged("MaxDiamState");
|
|
}
|
|
}
|
|
|
|
private ShowInfo minDiamState;
|
|
/// <summary>
|
|
/// 最小外径
|
|
/// </summary>
|
|
public ShowInfo MinDiamState
|
|
{
|
|
get { return minDiamState; }
|
|
set
|
|
{
|
|
minDiamState = value;
|
|
RaisePropertyChanged("MinDiamState");
|
|
}
|
|
}
|
|
|
|
private ShowInfo averageDiamState;
|
|
/// <summary>
|
|
/// 平均外径状态
|
|
/// </summary>
|
|
public ShowInfo AverageDiamState
|
|
{
|
|
get { return averageDiamState; }
|
|
set
|
|
{
|
|
averageDiamState = value;
|
|
RaisePropertyChanged("AverageDiamState");
|
|
}
|
|
}
|
|
|
|
|
|
private ShowInfo beatRateState;
|
|
/// <summary>
|
|
/// 跳动率状态
|
|
/// </summary>
|
|
public ShowInfo BeatRateState
|
|
{
|
|
get { return beatRateState; }
|
|
set
|
|
{
|
|
beatRateState = value;
|
|
RaisePropertyChanged("BeatRateState");
|
|
}
|
|
}
|
|
|
|
|
|
#region 点位集合
|
|
private ObservableCollection<MotionPointModel> pointList;
|
|
/// <summary>
|
|
/// 点位集合
|
|
/// </summary>
|
|
public ObservableCollection<MotionPointModel> PointList
|
|
{
|
|
get { return pointList; }
|
|
set
|
|
{
|
|
pointList = value;
|
|
this.RaisePropertyChanged("PointList");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 当前项目运行中
|
|
/// </summary>
|
|
public bool ProjectRuning { get; set; }
|
|
|
|
/// <summary>
|
|
/// 测量结果
|
|
/// </summary>
|
|
public bool Result { get; set; }
|
|
|
|
public CylinderMeasurementModel()
|
|
{
|
|
MaxDiamState = new ShowInfo() { StatuInfo = "...", StatusBackground = ColorStr.Transparent };
|
|
MinDiamState = new ShowInfo() { StatuInfo = "...", StatusBackground = ColorStr.Transparent };
|
|
AverageDiamState = new ShowInfo() { StatuInfo = "...", StatusBackground = ColorStr.Transparent };
|
|
BeatRateState = new ShowInfo() { StatuInfo = "...", StatusBackground = ColorStr.Transparent };
|
|
PointList = new ObservableCollection<MotionPointModel>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断结果
|
|
/// </summary>
|
|
/// <param name="cm"></param>
|
|
/// <returns></returns>
|
|
public bool ResultDetermine()
|
|
{
|
|
Result = true;
|
|
if (this.MaxDiam <= MaxDiamS)
|
|
{
|
|
MaxDiamState.StatuInfo = "OK";
|
|
MaxDiamState.StatusBackground = ColorStr.Green;
|
|
}
|
|
else
|
|
{
|
|
MaxDiamState.StatuInfo = "NG";
|
|
MaxDiamState.StatusBackground = ColorStr.Red;
|
|
Result = false;
|
|
}
|
|
|
|
if (this.MinDiam >= MinDiamS)
|
|
{
|
|
MinDiamState.StatuInfo = "OK";
|
|
MinDiamState.StatusBackground = ColorStr.Green;
|
|
}
|
|
else
|
|
{
|
|
MinDiamState.StatuInfo = "NG";
|
|
MinDiamState.StatusBackground = ColorStr.Red;
|
|
Result = false;
|
|
}
|
|
|
|
//if (this.AverageDiam <= AverageDiamS || this.AverageDiam >= AverageMinDiam)
|
|
//{
|
|
// AverageDiamState.StatuInfo = "OK";
|
|
// AverageDiamState.StatusBackground = ColorStr.Green;
|
|
//}
|
|
//else
|
|
//{
|
|
// AverageDiamState.StatuInfo = "NG";
|
|
// AverageDiamState.StatusBackground = ColorStr.Red;
|
|
//}
|
|
|
|
if (this.BeatRate <= BeatRateS)
|
|
{
|
|
BeatRateState.StatuInfo = "OK";
|
|
BeatRateState.StatusBackground = ColorStr.Green;
|
|
}
|
|
else
|
|
{
|
|
BeatRateState.StatuInfo = "NG";
|
|
BeatRateState.StatusBackground = ColorStr.Red;
|
|
Result = false;
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
}
|
|
}
|