|
@@ -425,8 +425,13 @@ namespace TeamAAS_VP.ViewModels
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
private void InitLockCurvePlotModel()
|
|
private void InitLockCurvePlotModel()
|
|
|
{
|
|
{
|
|
|
- var model = new PlotModel { Title = Lang.锁付曲线, TitleFontSize = 16};
|
|
|
|
|
- // 设置图例
|
|
|
|
|
|
|
+ var model = new PlotModel
|
|
|
|
|
+ {
|
|
|
|
|
+ Title = Lang.锁付曲线,
|
|
|
|
|
+ TitleFontSize = 16
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 图例
|
|
|
var legend = new Legend
|
|
var legend = new Legend
|
|
|
{
|
|
{
|
|
|
LegendPosition = LegendPosition.TopRight,
|
|
LegendPosition = LegendPosition.TopRight,
|
|
@@ -435,10 +440,11 @@ namespace TeamAAS_VP.ViewModels
|
|
|
LegendBorderThickness = 0
|
|
LegendBorderThickness = 0
|
|
|
};
|
|
};
|
|
|
model.Legends.Add(legend);
|
|
model.Legends.Add(legend);
|
|
|
- // 设置X轴
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // X轴(圈数)
|
|
|
var xAxis = new LinearAxis
|
|
var xAxis = new LinearAxis
|
|
|
{
|
|
{
|
|
|
- Key="X",
|
|
|
|
|
|
|
+ Key = "X",
|
|
|
Position = AxisPosition.Bottom,
|
|
Position = AxisPosition.Bottom,
|
|
|
Title = Lang.锁付圈数,
|
|
Title = Lang.锁付圈数,
|
|
|
Minimum = 0,
|
|
Minimum = 0,
|
|
@@ -446,7 +452,8 @@ namespace TeamAAS_VP.ViewModels
|
|
|
MinorGridlineStyle = LineStyle.Dot
|
|
MinorGridlineStyle = LineStyle.Dot
|
|
|
};
|
|
};
|
|
|
model.Axes.Add(xAxis);
|
|
model.Axes.Add(xAxis);
|
|
|
- // 设置Y轴
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // Y轴(力矩)
|
|
|
var yAxis = new LinearAxis
|
|
var yAxis = new LinearAxis
|
|
|
{
|
|
{
|
|
|
Key = "Y",
|
|
Key = "Y",
|
|
@@ -456,16 +463,39 @@ namespace TeamAAS_VP.ViewModels
|
|
|
MinorGridlineStyle = LineStyle.Dot
|
|
MinorGridlineStyle = LineStyle.Dot
|
|
|
};
|
|
};
|
|
|
model.Axes.Add(yAxis);
|
|
model.Axes.Add(yAxis);
|
|
|
- // 添加示例数据系列
|
|
|
|
|
- var series = new LineSeries
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 实际锁付曲线
|
|
|
|
|
+ var torqueSeries = new LineSeries
|
|
|
{
|
|
{
|
|
|
Title = Lang.锁付力矩曲线,
|
|
Title = Lang.锁付力矩曲线,
|
|
|
StrokeThickness = 2,
|
|
StrokeThickness = 2,
|
|
|
MarkerSize = 3,
|
|
MarkerSize = 3,
|
|
|
MarkerType = MarkerType.Circle,
|
|
MarkerType = MarkerType.Circle,
|
|
|
CanTrackerInterpolatePoints = false,
|
|
CanTrackerInterpolatePoints = false,
|
|
|
|
|
+ Color = OxyColors.Blue
|
|
|
};
|
|
};
|
|
|
- model.Series.Add(series);
|
|
|
|
|
|
|
+ model.Series.Add(torqueSeries);
|
|
|
|
|
+
|
|
|
|
|
+ // 上限线
|
|
|
|
|
+ var upperLimitSeries = new LineSeries
|
|
|
|
|
+ {
|
|
|
|
|
+ Title = "Torque Upper Limit",
|
|
|
|
|
+ StrokeThickness = 2,
|
|
|
|
|
+ LineStyle = LineStyle.Dash,
|
|
|
|
|
+ Color = OxyColors.Red
|
|
|
|
|
+ };
|
|
|
|
|
+ model.Series.Add(upperLimitSeries);
|
|
|
|
|
+
|
|
|
|
|
+ // 下限线
|
|
|
|
|
+ var lowerLimitSeries = new LineSeries
|
|
|
|
|
+ {
|
|
|
|
|
+ Title = "Torque Lower Limit",
|
|
|
|
|
+ StrokeThickness = 2,
|
|
|
|
|
+ LineStyle = LineStyle.Dash,
|
|
|
|
|
+ Color = OxyColors.Green
|
|
|
|
|
+ };
|
|
|
|
|
+ model.Series.Add(lowerLimitSeries);
|
|
|
|
|
+
|
|
|
LockCurvePlotModel = model;
|
|
LockCurvePlotModel = model;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -473,7 +503,6 @@ namespace TeamAAS_VP.ViewModels
|
|
|
/// 螺丝锁付完成时调用
|
|
/// 螺丝锁付完成时调用
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <param name="result"></param>
|
|
/// <param name="result"></param>
|
|
|
- /// <exception cref="NotImplementedException"></exception>
|
|
|
|
|
private void OnLockFinish(LockResult result)
|
|
private void OnLockFinish(LockResult result)
|
|
|
{
|
|
{
|
|
|
//如果当前螺丝编号为1,则清除之前的结果
|
|
//如果当前螺丝编号为1,则清除之前的结果
|
|
@@ -481,24 +510,48 @@ namespace TeamAAS_VP.ViewModels
|
|
|
{
|
|
{
|
|
|
LockResults.Clear();
|
|
LockResults.Clear();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
LockResults.Add(result);
|
|
LockResults.Add(result);
|
|
|
|
|
|
|
|
- //更新曲线图
|
|
|
|
|
- App.Current.Dispatcher.BeginInvoke(new Action(() => {
|
|
|
|
|
|
|
+ App.Current.Dispatcher.BeginInvoke(new Action(() =>
|
|
|
|
|
+ {
|
|
|
try
|
|
try
|
|
|
{
|
|
{
|
|
|
- var series = LockCurvePlotModel.Series[0] as LineSeries;
|
|
|
|
|
- series.Points.Clear();
|
|
|
|
|
|
|
+ //获取三条曲线
|
|
|
|
|
+ var torqueSeries = LockCurvePlotModel.Series[0] as LineSeries; //实际扭矩
|
|
|
|
|
+ var upperSeries = LockCurvePlotModel.Series[1] as LineSeries; //上限
|
|
|
|
|
+ var lowerSeries = LockCurvePlotModel.Series[2] as LineSeries; //下限
|
|
|
|
|
+
|
|
|
|
|
+ torqueSeries.Points.Clear();
|
|
|
|
|
+ upperSeries.Points.Clear();
|
|
|
|
|
+ lowerSeries.Points.Clear();
|
|
|
|
|
+
|
|
|
|
|
+ //上下限值(根据你的工艺设置)
|
|
|
|
|
+ double upperLimit = result.TargetTorqueUpperLimit; //上限扭矩
|
|
|
|
|
+ double lowerLimit = result.TargetTorqueLowerLimit; //下限扭矩
|
|
|
|
|
+
|
|
|
foreach (var waveData in result.WaveDatas)
|
|
foreach (var waveData in result.WaveDatas)
|
|
|
{
|
|
{
|
|
|
- series.Points.Add(new OxyPlot.DataPoint(waveData.Turns, waveData.Torque));
|
|
|
|
|
|
|
+ //实际曲线
|
|
|
|
|
+ torqueSeries.Points.Add(new OxyPlot.DataPoint(waveData.Turns, waveData.Torque));
|
|
|
|
|
+ //上限曲线(固定扭矩)
|
|
|
|
|
+ upperSeries.Points.Add(new OxyPlot.DataPoint(waveData.Turns, upperLimit));
|
|
|
|
|
+ //下限曲线
|
|
|
|
|
+ lowerSeries.Points.Add(new OxyPlot.DataPoint(waveData.Turns, lowerLimit));
|
|
|
}
|
|
}
|
|
|
- // 重置所有轴的范围以适应新数据
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //刷新
|
|
|
LockCurvePlotModel.ResetAllAxes();
|
|
LockCurvePlotModel.ResetAllAxes();
|
|
|
LockCurvePlotModel.InvalidatePlot(true);
|
|
LockCurvePlotModel.InvalidatePlot(true);
|
|
|
|
|
+
|
|
|
|
|
+ //保存图片
|
|
|
if (!string.IsNullOrEmpty(result.LockCurveImagePath))
|
|
if (!string.IsNullOrEmpty(result.LockCurveImagePath))
|
|
|
{
|
|
{
|
|
|
- PngExporter.Export(LockCurvePlotModel, result.LockCurveImagePath, (int)LockCurvePlotModel.Width, (int)LockCurvePlotModel.Height);
|
|
|
|
|
|
|
+ PngExporter.Export(
|
|
|
|
|
+ LockCurvePlotModel,
|
|
|
|
|
+ result.LockCurveImagePath,
|
|
|
|
|
+ (int)LockCurvePlotModel.Width,
|
|
|
|
|
+ (int)LockCurvePlotModel.Height);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -506,7 +559,6 @@ namespace TeamAAS_VP.ViewModels
|
|
|
LogHelper.WriteLogError("更新曲线图和保存曲线图时出错!", ex);
|
|
LogHelper.WriteLogError("更新曲线图和保存曲线图时出错!", ex);
|
|
|
}
|
|
}
|
|
|
}));
|
|
}));
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|