Commit 945d9eb7 authored by 潘栩锋's avatar 潘栩锋 🚴

1.优化 定点图 X轴,恢复 F1 格式

2.优化 CurveCollection, CurveCell 精简代码
parent cf55a664
...@@ -122,7 +122,7 @@ namespace FLY.Thick.Base.UI.UiModule ...@@ -122,7 +122,7 @@ namespace FLY.Thick.Base.UI.UiModule
{ {
int index = (int)x; int index = (int)x;
double s = Interval.TotalSeconds * index * values_scale; double s = Interval.TotalSeconds * index * values_scale;
return $"{s:F0}s"; return $"{s:F1}s";
}; };
YFormatter = (y) => y.ToString("F1"); YFormatter = (y) => y.ToString("F1");
......
using System; using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Misc;
using System.Xml;
using System.ComponentModel;
using System.Collections.ObjectModel;
namespace FLY.Thick.Base.Common namespace FLY.Thick.Base.Common
{ {
......
using System; using FLY.Thick.Base.Common;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using FLY.Thick.Base.Common;
namespace FLY.Thick.Base.IService namespace FLY.Thick.Base.IService
{ {
......
using System; using AutoMapper;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
using FLY.Thick.Base.Common; using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService; using FLY.Thick.Base.IService;
using AutoMapper;
using System.IO;
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace FLY.Thick.Base.Server namespace FLY.Thick.Base.Server
{ {
...@@ -32,11 +28,11 @@ namespace FLY.Thick.Base.Server ...@@ -32,11 +28,11 @@ namespace FLY.Thick.Base.Server
#endregion #endregion
public event ActiveEventHandler ActiveEvent;
public struct ExChange public struct ExChange
{ {
public ExChange(int orgAd, int currAd) { public ExChange(int orgAd, int currAd)
{
OrgAD = orgAd; OrgAD = orgAd;
CurrAD = currAd; CurrAD = currAd;
} }
...@@ -61,7 +57,8 @@ namespace FLY.Thick.Base.Server ...@@ -61,7 +57,8 @@ namespace FLY.Thick.Base.Server
this.param_path = param_path; this.param_path = param_path;
SetDefault(); SetDefault();
if (!Load()) { if (!Load())
{
Save(); Save();
} }
Curves = Curves.OrderBy(c => c.Value).ToArray(); Curves = Curves.OrderBy(c => c.Value).ToArray();
...@@ -94,7 +91,6 @@ namespace FLY.Thick.Base.Server ...@@ -94,7 +91,6 @@ namespace FLY.Thick.Base.Server
ClearExChange(); ClearExChange();
ReviseCurve(); ReviseCurve();
ActiveEvent?.Invoke(this);
Save(); Save();
} }
...@@ -170,7 +166,8 @@ namespace FLY.Thick.Base.Server ...@@ -170,7 +166,8 @@ namespace FLY.Thick.Base.Server
{ {
c.RevisedAD = (int)(c.AD * ux); c.RevisedAD = (int)(c.AD * ux);
} }
} break; }
break;
default: default:
//case CurveCorrectWay.OnePointIsOffset: //case CurveCorrectWay.OnePointIsOffset:
{ {
...@@ -180,7 +177,8 @@ namespace FLY.Thick.Base.Server ...@@ -180,7 +177,8 @@ namespace FLY.Thick.Base.Server
{ {
c.RevisedAD = c.AD + x; c.RevisedAD = c.AD + x;
} }
} break; }
break;
} }
return true; return true;
...@@ -201,7 +199,7 @@ namespace FLY.Thick.Base.Server ...@@ -201,7 +199,7 @@ namespace FLY.Thick.Base.Server
} }
} }
#region E #region Ad To Value
double AD2Value_E(int ad, AD2ValueFlag flag) double AD2Value_E(int ad, AD2ValueFlag flag)
{ {
...@@ -257,8 +255,8 @@ namespace FLY.Thick.Base.Server ...@@ -257,8 +255,8 @@ namespace FLY.Thick.Base.Server
return value; return value;
} }
#endregion
#region 线性
double AD2Value_Line(int ad, AD2ValueFlag flag) double AD2Value_Line(int ad, AD2ValueFlag flag)
{ {
int i; int i;
...@@ -295,7 +293,8 @@ namespace FLY.Thick.Base.Server ...@@ -295,7 +293,8 @@ namespace FLY.Thick.Base.Server
} }
} }
} }
else { else
{
if (isDescending)//降序排列 if (isDescending)//降序排列
{ {
for (i = 0; i < Curves.Count(); i++) for (i = 0; i < Curves.Count(); i++)
...@@ -338,7 +337,7 @@ namespace FLY.Thick.Base.Server ...@@ -338,7 +337,7 @@ namespace FLY.Thick.Base.Server
value = (ad2 - ad0) * u + c0.Value; value = (ad2 - ad0) * u + c0.Value;
return value; return value;
} }
#endregion
public double AD2Value(int ad, AD2ValueFlag flag) public double AD2Value(int ad, AD2ValueFlag flag)
{ {
...@@ -354,6 +353,108 @@ namespace FLY.Thick.Base.Server ...@@ -354,6 +353,108 @@ namespace FLY.Thick.Base.Server
} }
return value; return value;
} }
#endregion
#region Value To Ad
/// <summary>
/// 基本没有用
/// </summary>
/// <param name="value"></param>
/// <param name="flag"></param>
/// <returns></returns>
public int Value2Ad(double value, AD2ValueFlag flag) {
int ad;
switch (Flag)
{
case CurveType.Line:
ad = Value2Ad_Line(value, flag);
break;
default:
ad = Value2Ad_E(value, flag);
break;
}
return ad;
}
int Value2Ad_E(double value, AD2ValueFlag flag)
{
int i;
int ad;
if (Curves.Count() < 1) return -1;
for (i = 0; i < Curves.Count(); i++)
{
if (value > Curves[i].Value)
continue;
else
break;
}
if (i >= Curves.Count())
i = Curves.Count() - 1;
if (i == 0)
i = 1;
var c0 = Curves[i - 1];
var c1 = Curves[i];
double ad0, ad1, ad2;
if (flag == AD2ValueFlag.NoRevised)
{
ad0 = Math.Log(c0.AD, Math.E);
ad1 = Math.Log(c1.AD, Math.E);
//ad2 = Math.Log(ad, Math.E);
}
else
{
ad0 = Math.Log(c0.RevisedAD, Math.E);
ad1 = Math.Log(c1.RevisedAD, Math.E);
//ad2 = Math.Log(ad, Math.E);
}
double u = (c1.Value - c0.Value) / (ad1 - ad0);
ad2 = (value - c0.Value) / u + ad0;
ad = (int)Math.Round(Math.Pow(Math.E, ad2));
return ad;
}
int Value2Ad_Line(double value, AD2ValueFlag flag)
{
int i;
int ad;
if (Curves.Count() < 2) return -1;
for (i = 0; i < Curves.Count(); i++)
{
if (value > Curves[i].Value)
continue;
else
break;
}
if (i >= Curves.Count()) i = Curves.Count() - 1;
if (i == 0) i = 1;
var c0 = Curves[i - 1];
var c1 = Curves[i];
double ad0, ad1, ad2;
if (flag == AD2ValueFlag.NoRevised)
{
ad0 = c0.AD;
ad1 = c1.AD;
}
else
{
ad0 = c0.RevisedAD;
ad1 = c1.RevisedAD;
}
double u = (c1.Value - c0.Value) / (ad1 - ad0);
ad2 = (value - c0.Value) / u + ad0;
ad = (int)Math.Round(ad2);
return ad;
}
#endregion
public bool Load() public bool Load()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment