拉力曲线性能优化&解决划船时间误差问题
This commit is contained in:
parent
6c9b3f825a
commit
573b96d86c
@ -1269,7 +1269,7 @@ MonoBehaviour:
|
|||||||
m_HorizontalOverflow: 1
|
m_HorizontalOverflow: 1
|
||||||
m_VerticalOverflow: 1
|
m_VerticalOverflow: 1
|
||||||
m_LineSpacing: 1
|
m_LineSpacing: 1
|
||||||
m_Text: Please make sure the device is powered on an awakened
|
m_Text: Please make sure the device is powered on and awakened
|
||||||
--- !u!114 &6648807303715948149
|
--- !u!114 &6648807303715948149
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -368,8 +368,9 @@
|
|||||||
"FINISH": "终点",
|
"FINISH": "终点",
|
||||||
"Continue the game?": "有中断的划船记录,是否继续?",
|
"Continue the game?": "有中断的划船记录,是否继续?",
|
||||||
"Save the game?": "有中断的划船记录,是否保存?",
|
"Save the game?": "有中断的划船记录,是否保存?",
|
||||||
"Please make sure the device is powered on an awakened": "请确保设备有电且已唤醒",
|
"Please make sure the device is powered on and awakened": "请确保设备有电且已唤醒",
|
||||||
"Powerfun need location service permission,please open the location permission.": "Powerfun需要定位服务权限,请打开定位服务权限!"
|
"Powerfun need location service permission,please open the location permission.": "Powerfun需要定位服务权限,请打开定位服务权限!",
|
||||||
|
"Disconnect the device?": "是否断开该设备?"
|
||||||
},
|
},
|
||||||
"en": {
|
"en": {
|
||||||
"HOT ROUTES": "HOT ROUTES",
|
"HOT ROUTES": "HOT ROUTES",
|
||||||
@ -732,7 +733,8 @@
|
|||||||
"FINISH": "FINISH",
|
"FINISH": "FINISH",
|
||||||
"Continue the game?": "Continue the game?",
|
"Continue the game?": "Continue the game?",
|
||||||
"Save the game?": "Save the game?",
|
"Save the game?": "Save the game?",
|
||||||
"Please make sure the device is powered on an awakened": "Please make sure the device is powered on an awakened",
|
"Please make sure the device is powered on and awakened": "Please make sure the device is powered on and awakened",
|
||||||
"Powerfun need location service permission,please open the location permission.": "Powerfun need location service permission,please open the location permission."
|
"Powerfun need location service permission,please open the location permission.": "Powerfun need location service permission,please open the location permission.",
|
||||||
|
"Disconnect the device?": "Disconnect the device?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,11 +51,13 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsUserDefined { get; set; }
|
||||||
|
|
||||||
public static bool isReadyStatus { get; private set; }
|
public static bool isReadyStatus { get; private set; }
|
||||||
public static RowerTaskPanel.RowerType rowerType { get; private set; }
|
public static RowerTaskPanel.RowerType rowerType { get; private set; }
|
||||||
public void HandleAttributeReceived(byte[] data)
|
public void HandleAttributeReceived(byte[] data)
|
||||||
{
|
{
|
||||||
Debug.Log("数据" + string.Join(",", data));
|
|
||||||
if (data[0] == 0x35)
|
if (data[0] == 0x35)
|
||||||
{
|
{
|
||||||
PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10, true);
|
PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10, true);
|
||||||
@ -63,7 +65,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
|||||||
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
|
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
|
||||||
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
|
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
|
||||||
StrokeCount = BitConvertHelper.ToUInt16(data, 19);
|
StrokeCount = BitConvertHelper.ToUInt16(data, 19);
|
||||||
Debug.Log($"峰力值:{PeakDriveForce} 均力值{AverageDriveForce}");
|
Debug.Log("数据" + string.Join(",", data) +$" | {ElapsedTime}-{TotalDistance}");
|
||||||
}
|
}
|
||||||
else if (data[0] == 0x3d)
|
else if (data[0] == 0x3d)
|
||||||
{
|
{
|
||||||
@ -71,7 +73,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
|||||||
//List<ushort> r = new List<ushort>();
|
//List<ushort> r = new List<ushort>();
|
||||||
for (int i = 3; i < data.Length; i += 2)
|
for (int i = 3; i < data.Length; i += 2)
|
||||||
{
|
{
|
||||||
ushort pull = data[i] < 5 ? (ushort)0 : Convert.ToUInt16(Math.Round(LbsToNewton(data[i], true)));
|
ushort pull = data[i] < 10 ? (ushort)0 : Convert.ToUInt16(Math.Round(LbsToNewton(data[i], true)));
|
||||||
//r.Add(pull);
|
//r.Add(pull);
|
||||||
PullValue = pull;
|
PullValue = pull;
|
||||||
}
|
}
|
||||||
@ -87,17 +89,21 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
|||||||
rowerType = new RowerTaskPanel.RowerType();
|
rowerType = new RowerTaskPanel.RowerType();
|
||||||
rowerType.type = 1;
|
rowerType.type = 1;
|
||||||
rowerType.value = value;
|
rowerType.value = value;
|
||||||
|
IsUserDefined = true;
|
||||||
}
|
}
|
||||||
else if (status == 0)
|
else if (status == 0)
|
||||||
{
|
{
|
||||||
rowerType = new RowerTaskPanel.RowerType();
|
rowerType = new RowerTaskPanel.RowerType();
|
||||||
rowerType.type = 2;
|
rowerType.type = 2;
|
||||||
rowerType.value = value / 100;
|
rowerType.value = value / 100;
|
||||||
|
IsUserDefined = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rowerType = null;
|
rowerType = null;
|
||||||
|
IsUserDefined = false;
|
||||||
}
|
}
|
||||||
|
Debug.Log($"里程:{TotalDistance}峰力值:{PeakDriveForce} 均力值{AverageDriveForce} ReadyStatus:{isReadyStatus} TIME{DateTime.Now}");
|
||||||
//isReadyStatus = data[9] == 0;
|
//isReadyStatus = data[9] == 0;
|
||||||
var time = ((data[3] << 16) + (data[2] << 8) + data[1]) / 100;
|
var time = ((data[3] << 16) + (data[2] << 8) + data[1]) / 100;
|
||||||
Debug.Log("划船时间" + time);
|
Debug.Log("划船时间" + time);
|
||||||
|
|||||||
@ -25,6 +25,7 @@ public class MainController : BaseScene
|
|||||||
Debug.Log("执行25");
|
Debug.Log("执行25");
|
||||||
Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>();
|
Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>();
|
||||||
Version.text = "V"+App.AppVersion;
|
Version.text = "V"+App.AppVersion;
|
||||||
|
transform.Find("Text").GetComponent<Text>().text = "2022-6-21-V1";
|
||||||
DeviceCache.Init(PFConstants.DeviceCacheFolder);
|
DeviceCache.Init(PFConstants.DeviceCacheFolder);
|
||||||
Loom.Initialize();
|
Loom.Initialize();
|
||||||
msg = transform.Find("GameObject/Message").GetComponent<CanvasGroup>();
|
msg = transform.Find("GameObject/Message").GetComponent<CanvasGroup>();
|
||||||
|
|||||||
@ -92,7 +92,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
Transform left, bottom, mid, rmydata;
|
Transform left, bottom, mid, rmydata;
|
||||||
Image leftImage;
|
Image leftImage;
|
||||||
Image rightImage;
|
Image rightImage;
|
||||||
float timer = 1.0f;
|
float timer = 0f;
|
||||||
List<DoubleVector2> pullList, historyPullList;
|
List<DoubleVector2> pullList, historyPullList;
|
||||||
public Dictionary<object, Sprite> spriteDict, spriteDict2;
|
public Dictionary<object, Sprite> spriteDict, spriteDict2;
|
||||||
List<string> records;
|
List<string> records;
|
||||||
@ -513,7 +513,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
truelyTime = historyTime;
|
truelyTime = historyTime;
|
||||||
//TimerTicks();
|
//TimerTicks();
|
||||||
openTimer = true;
|
openTimer = true;
|
||||||
timer = 1.0f;
|
timer = 0f;
|
||||||
}
|
}
|
||||||
transform.Find("Ready").gameObject.SetActive(false);
|
transform.Find("Ready").gameObject.SetActive(false);
|
||||||
//if (UIManager.Instance.RowerWelldone)
|
//if (UIManager.Instance.RowerWelldone)
|
||||||
@ -657,6 +657,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
|
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
|
ResetChart();
|
||||||
deviceName = "";
|
deviceName = "";
|
||||||
deviceNetwork = "";
|
deviceNetwork = "";
|
||||||
deviceAddress = "";
|
deviceAddress = "";
|
||||||
@ -833,7 +834,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
var heartRate = HeartRate ?? 0;
|
var heartRate = HeartRate ?? 0;
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
var a = tempList[(tempx++) % tempList.Count];
|
var a = tempList[(tempx++) % tempList.Count];
|
||||||
Debug.Log(a);
|
//Debug.Log(a);
|
||||||
PaintPullCurve((ushort)(a / 10));
|
PaintPullCurve((ushort)(a / 10));
|
||||||
if (RowerData == null) return;
|
if (RowerData == null) return;
|
||||||
#endif
|
#endif
|
||||||
@ -859,8 +860,9 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (RowerData == null) return;
|
if (RowerData == null) return;
|
||||||
//#endif
|
transform.Find("Text").GetComponent<Text>().text = $"{RowerData.ElapsedTime}:{RowerData.TotalDistance}";
|
||||||
//断线重连继续
|
//#endif
|
||||||
|
//断线重连继续()
|
||||||
var distance = (int)RowerData.TotalDistance + historyDistance;
|
var distance = (int)RowerData.TotalDistance + historyDistance;
|
||||||
var energy = RowerData.TotalEnergy + historyEnergy;
|
var energy = RowerData.TotalEnergy + historyEnergy;
|
||||||
var strokeCount = RowerData.StrokeCount + historyStrokeCount;
|
var strokeCount = RowerData.StrokeCount + historyStrokeCount;
|
||||||
@ -868,10 +870,24 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
var power = RowerData.InstantaneousPower;
|
var power = RowerData.InstantaneousPower;
|
||||||
var rate = RowerData.StrokeRate;
|
var rate = RowerData.StrokeRate;
|
||||||
truelyTime++;
|
truelyTime++;
|
||||||
|
Debug.Log($"ElapsedTime :{RowerData.ElapsedTime} : {truelyTime}-{RowerData.TotalDistance}");
|
||||||
TempRowerCalc tmpdata = null;
|
TempRowerCalc tmpdata = null;
|
||||||
|
|
||||||
|
//解决里程训练无法结束的问题
|
||||||
|
var c2notStop = rowerType.type == 1 && (rowerType.value-totalDistance) <= 5;
|
||||||
|
if (c2notStop)
|
||||||
|
{
|
||||||
|
distance = (int)rowerType.value;
|
||||||
|
KMText.text = "0";
|
||||||
|
records.Add($"{strokeCount},{RowerData.ElapsedTime},{rowerType.value},{RowerData.InstantaneousPower},{RowerData.InstantaneousPace},{RowerData.StrokeRate},{RowerData.ResistanceLevel},{heartRate},{energy},{RowerData.AveragePower},{truelyTime}");
|
||||||
|
tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = RowerData.InstantaneousPace, power = power, rate = rate, heartRate = heartRate, distance = (int)rowerType.value, energy = energy };
|
||||||
|
values.Add(tmpdata);
|
||||||
|
SendDataToRace(tmpdata);
|
||||||
|
HandleSaveDirect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
//里程停止逻辑
|
//里程停止逻辑
|
||||||
if (totalDistance == RowerData.TotalDistance + historyDistance)
|
if (totalDistance == RowerData.TotalDistance && !c2notStop)
|
||||||
{
|
{
|
||||||
//判定一次停止
|
//判定一次停止
|
||||||
stopSeconds++;
|
stopSeconds++;
|
||||||
@ -884,6 +900,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
if (stopSeconds >= 2)
|
if (stopSeconds >= 2)
|
||||||
{
|
{
|
||||||
if (UIManager.Instance.confirm != null && UIManager.Instance.confirm.IsActive()) {
|
if (UIManager.Instance.confirm != null && UIManager.Instance.confirm.IsActive()) {
|
||||||
|
Debug.Log("stopSeconds >= 2");
|
||||||
transform.Find("Stopped").gameObject.SetActive(false);
|
transform.Find("Stopped").gameObject.SetActive(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1012,10 +1029,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = pace, power = power, rate = rate, heartRate = heartRate, distance = distance, energy = energy };
|
tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = pace, power = power, rate = rate, heartRate = heartRate, distance = distance, energy = energy };
|
||||||
values.Add(tmpdata);
|
values.Add(tmpdata);
|
||||||
SendDataToRace(tmpdata);
|
SendDataToRace(tmpdata);
|
||||||
if (C2RowerData.IsEnabled == true && C2RowerData.isReadyStatus && values.Count()>10)
|
|
||||||
{
|
|
||||||
HandleSaveDirect();
|
|
||||||
}
|
|
||||||
if (ticks % 5 == 0)
|
if (ticks % 5 == 0)
|
||||||
{
|
{
|
||||||
SaveRealTimes();//实时保存数据
|
SaveRealTimes();//实时保存数据
|
||||||
@ -1036,6 +1050,10 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
if (files.Length == 0)
|
if (files.Length == 0)
|
||||||
return;
|
return;
|
||||||
var historyRowerTime = PlayerPrefs.GetString("historyRowerTime");
|
var historyRowerTime = PlayerPrefs.GetString("historyRowerTime");
|
||||||
|
deviceName = PlayerPrefs.GetString("deviceName");
|
||||||
|
deviceNetwork = PlayerPrefs.GetString("deviceNetwork");
|
||||||
|
deviceAddress = PlayerPrefs.GetString("deviceAddress");
|
||||||
|
deviceSensor = PlayerPrefs.GetString("deviceSensor");
|
||||||
if (!string.IsNullOrEmpty(historyRowerTime))
|
if (!string.IsNullOrEmpty(historyRowerTime))
|
||||||
{
|
{
|
||||||
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Save the game?"), () =>
|
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Save the game?"), () =>
|
||||||
@ -1102,7 +1120,12 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
}
|
}
|
||||||
File.WriteAllText(path, string.Join("\r\n", records));
|
File.WriteAllText(path, string.Join("\r\n", records));
|
||||||
File.WriteAllText($"{PFConstants.RowerRecordCacheFolder}/cache.txt", string.Join("\r\n", App.cacheList));
|
//File.WriteAllText($"{PFConstants.RowerRecordCacheFolder}/cache.txt", string.Join("\r\n", App.cacheList));
|
||||||
|
PlayerPrefs.SetString("deviceName", deviceName);
|
||||||
|
PlayerPrefs.SetString("deviceNetwork", deviceNetwork);
|
||||||
|
PlayerPrefs.SetString("deviceAddress", deviceAddress);
|
||||||
|
PlayerPrefs.SetString("deviceSensor", deviceSensor);
|
||||||
|
|
||||||
PlayerPrefs.SetString("historyRowerType", $"{rowerType.type},{rowerType.value}");
|
PlayerPrefs.SetString("historyRowerType", $"{rowerType.type},{rowerType.value}");
|
||||||
PlayerPrefs.SetString("historyRowerTime", UIManager.Now.GetDateTime().ToString());
|
PlayerPrefs.SetString("historyRowerTime", UIManager.Now.GetDateTime().ToString());
|
||||||
PlayerPrefs.SetString("historyRowerShadowIds", string.Join(",", GetComponent<RowerMultiModeScript>().shadowList.Select(x => x.Nid)));
|
PlayerPrefs.SetString("historyRowerShadowIds", string.Join(",", GetComponent<RowerMultiModeScript>().shadowList.Select(x => x.Nid)));
|
||||||
@ -1141,7 +1164,7 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
int pointCount = 0;
|
int pointCount = 0;
|
||||||
void PaintPullCurve(ushort y)
|
void PaintPullCurve(ushort y)
|
||||||
{
|
{
|
||||||
Debug.Log($"收到拉力 x={x} , y={y}");
|
//Debug.Log($"收到拉力 x={x} , y={y}");
|
||||||
//#if !UNITY_EDITOR
|
//#if !UNITY_EDITOR
|
||||||
// if (!openTimer)
|
// if (!openTimer)
|
||||||
// {
|
// {
|
||||||
@ -1162,7 +1185,6 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
if (rate > 1) rate = 1f;
|
if (rate > 1) rate = 1f;
|
||||||
leftImage.fillAmount = rate;
|
leftImage.fillAmount = rate;
|
||||||
rightImage.fillAmount = rate;
|
rightImage.fillAmount = rate;
|
||||||
|
|
||||||
//动画
|
//动画
|
||||||
//left.Find("Rower").GetComponent<Image>().sprite = spriteDict[y / 67];
|
//left.Find("Rower").GetComponent<Image>().sprite = spriteDict[y / 67];
|
||||||
//曲线
|
//曲线
|
||||||
@ -1171,9 +1193,9 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
//if (pullList.Count == 0)
|
//if (pullList.Count == 0)
|
||||||
if(pointCount == 0)
|
if(pointCount == 0)
|
||||||
{
|
{
|
||||||
ClearChart("Player 2");
|
ClearChart();
|
||||||
isPlay = true;
|
isPlay = true;
|
||||||
x = 0.1;
|
x = 0;
|
||||||
pointCount++;
|
pointCount++;
|
||||||
pullList.Add(new DoubleVector2(x, y));
|
pullList.Add(new DoubleVector2(x, y));
|
||||||
SetChartData(x, y);
|
SetChartData(x, y);
|
||||||
@ -1188,19 +1210,18 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
historyPullList = pullList.Select(x => x).ToList();
|
historyPullList = pullList.Select(x => x).ToList();
|
||||||
pullList.Clear();
|
pullList.Clear();
|
||||||
pointCount = 0;
|
pointCount = 0;
|
||||||
x = 0.1;
|
//x = 0.1;
|
||||||
//SetChartData(x, y);
|
//SetChartData(x, y);
|
||||||
pointCount = 1;
|
pointCount = 1;
|
||||||
//isPlay = true;
|
//isPlay = true;
|
||||||
pullList.Add(new DoubleVector2(x, y));
|
//pullList.Add(new DoubleVector2(x, y));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//只有0并且两秒没拉,曲线消失
|
//只有0并且两秒没拉,曲线消失
|
||||||
if (stopSeconds == 1)
|
if (stopSeconds == 1)
|
||||||
{
|
{
|
||||||
ClearChart("Player 1");
|
ClearChart();
|
||||||
ClearChart("Player 2");
|
|
||||||
//SetChartData(new List<DoubleVector2>(), new List<DoubleVector2>());
|
//SetChartData(new List<DoubleVector2>(), new List<DoubleVector2>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1209,9 +1230,9 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
{
|
{
|
||||||
if (pullList.Count(x => x.y == 0) == pullList.Count)
|
if (pullList.Count(x => x.y == 0) == pullList.Count)
|
||||||
{
|
{
|
||||||
ClearChart("Player 2");
|
ClearChart();
|
||||||
pointCount = 0;
|
pointCount = 0;
|
||||||
SetChartData(0.1, 0);
|
//SetChartData(0.1, 0);
|
||||||
}
|
}
|
||||||
x += 0.1;
|
x += 0.1;
|
||||||
pointCount++;
|
pointCount++;
|
||||||
@ -1239,18 +1260,25 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
// x += 0.1f;
|
// x += 0.1f;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
void ClearChart(string cateName)
|
void ClearChart()
|
||||||
{
|
{
|
||||||
rowerGraphChartFeed.ClearChart(cateName);
|
if (x > 0)
|
||||||
graphChartFeed.ClearChart(cateName);
|
{
|
||||||
|
rowerGraphChartFeed.ClearChart();
|
||||||
|
graphChartFeed.ClearChart();
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void ResetChart() {
|
||||||
|
rowerGraphChartFeed?.ResetChart();
|
||||||
|
graphChartFeed?.ResetChart();
|
||||||
}
|
}
|
||||||
double preX, preY;
|
|
||||||
void SetChartData(double x, double y)
|
void SetChartData(double x, double y)
|
||||||
{
|
{
|
||||||
if (M1.localPosition.x == 0)
|
if (M1.localPosition.x == 0)
|
||||||
{
|
{
|
||||||
rowerGraphChartFeed.SetCurrentPoint(x, y);
|
rowerGraphChartFeed.SetCurrentPoint(x, y);
|
||||||
rowerGraphChartFeed.SetHistoryData(historyPullList);
|
rowerGraphChartFeed.SetHistoryData(x, historyPullList);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1275,48 +1303,36 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
int ticks { get; set; } = 0;
|
int ticks { get; set; } = 0;
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
shortTimer -= Time.deltaTime;
|
||||||
if (openTimer || true)
|
if (shortTimer <= 0)
|
||||||
#else
|
|
||||||
if (openTimer)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
timer -= Time.deltaTime;
|
ShortUpdateData();
|
||||||
shortTimer -= Time.deltaTime;
|
shortTimer += 0.25f;
|
||||||
if (shortTimer <= 0)
|
}
|
||||||
{
|
|
||||||
ShortUpdateData();
|
timer -= Time.deltaTime;
|
||||||
shortTimer += 0.25f;
|
if (timer <= 0)
|
||||||
}
|
{
|
||||||
if (timer <= 0)
|
#if UNITY_EDITOR
|
||||||
|
if (openTimer || true)
|
||||||
|
#else
|
||||||
|
if (openTimer)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
TimerTicks();
|
TimerTicks();
|
||||||
ticks++;
|
ticks++;
|
||||||
timer = 1f + timer;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
staticTimer -= Time.deltaTime;
|
|
||||||
if (staticTimer <= 0)
|
|
||||||
{
|
|
||||||
var heartRate = HeartRate ?? 0;
|
var heartRate = HeartRate ?? 0;
|
||||||
BPMText.text = heartRate == 0 ? "---": heartRate.ToString();
|
BPMText.text = heartRate == 0 ? "---" : heartRate.ToString();
|
||||||
HandleStatic();
|
HandleStatic();
|
||||||
staticTimer += 1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
//shortTimer -= Time.deltaTime;
|
timer += 1f ;
|
||||||
//if (shortTimer <= 0)
|
}
|
||||||
//{
|
|
||||||
// if (openTimer)
|
|
||||||
// {
|
|
||||||
// ShortUpdateData();
|
|
||||||
// }
|
|
||||||
// shortTimer += 0.5f;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
void ShortUpdateData()
|
void ShortUpdateData()
|
||||||
{
|
{
|
||||||
|
if (!openTimer) return;
|
||||||
if (RowerData == null) return;
|
if (RowerData == null) return;
|
||||||
var power = RowerData.InstantaneousPower;
|
var power = RowerData.InstantaneousPower;
|
||||||
var rate = RowerData.StrokeRate;
|
var rate = RowerData.StrokeRate;
|
||||||
@ -1325,12 +1341,12 @@ public class RowerHomeScript : PFUIPanel
|
|||||||
var distance = (int)RowerData.TotalDistance + historyDistance;
|
var distance = (int)RowerData.TotalDistance + historyDistance;
|
||||||
var energy = RowerData.TotalEnergy + historyEnergy;
|
var energy = RowerData.TotalEnergy + historyEnergy;
|
||||||
var heartRate = HeartRate ?? 0;
|
var heartRate = HeartRate ?? 0;
|
||||||
if (rowerType.type == 1 && totalDistance >=rowerType.value && !createTime.HasValue)
|
if (rowerType.type == 1 && (rowerType.value - totalDistance) <= 5 && !createTime.HasValue)
|
||||||
{
|
{
|
||||||
openTimer = false;
|
openTimer = false;
|
||||||
KMText.text = "0";
|
KMText.text = "0";
|
||||||
records.Add($"{strokeCount},{RowerData.ElapsedTime},{distance},{power},{pace},{rate},{RowerData.ResistanceLevel},{heartRate},{energy},{RowerData.AveragePower},{truelyTime}");
|
records.Add($"{strokeCount},{RowerData.ElapsedTime},{rowerType.value},{power},{pace},{rate},{RowerData.ResistanceLevel},{heartRate},{energy},{RowerData.AveragePower},{truelyTime}");
|
||||||
var tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = pace, power = power, rate = rate, heartRate = heartRate, distance = distance, energy = energy };
|
var tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = pace, power = power, rate = rate, heartRate = heartRate, distance = (int)rowerType.value, energy = energy };
|
||||||
values.Add(tmpdata);
|
values.Add(tmpdata);
|
||||||
SendDataToRace(tmpdata);
|
SendDataToRace(tmpdata);
|
||||||
HandleSaveDirect();
|
HandleSaveDirect();
|
||||||
|
|||||||
@ -132,7 +132,7 @@ public class RowerDeviceView : MonoBehaviour
|
|||||||
var device = GetDevice();
|
var device = GetDevice();
|
||||||
if (device != null && device.State == DeviceState.Connected)
|
if (device != null && device.State == DeviceState.Connected)
|
||||||
{
|
{
|
||||||
UIManager.ShowConfirm("警告", "是否断开该设备?", () =>
|
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Disconnect the device?"), () =>
|
||||||
{
|
{
|
||||||
device.Disconnect(false);
|
device.Disconnect(false);
|
||||||
DeviceCache.Remove(device);
|
DeviceCache.Remove(device);
|
||||||
@ -147,7 +147,7 @@ public class RowerDeviceView : MonoBehaviour
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
UIManager.AddEvent(mDisconnectButton, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e => {
|
UIManager.AddEvent(mDisconnectButton, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e => {
|
||||||
UIManager.ShowConfirm("警告", "是否断开该设备?", () =>
|
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Disconnect the device?"), () =>
|
||||||
{
|
{
|
||||||
var device = GetDevice();
|
var device = GetDevice();
|
||||||
if (device != null && device.State == DeviceState.Connected)
|
if (device != null && device.State == DeviceState.Connected)
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using ChartAndGraph;
|
using ChartAndGraph;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public class RowerGraphChartFeed : MonoBehaviour
|
public class RowerGraphChartFeed : MonoBehaviour
|
||||||
@ -42,25 +43,44 @@ public class RowerGraphChartFeed : MonoBehaviour
|
|||||||
}
|
}
|
||||||
public void SetCurrentPoint(double x,double y)
|
public void SetCurrentPoint(double x,double y)
|
||||||
{
|
{
|
||||||
|
if(dataSource != null)
|
||||||
|
x += dataSource.HorizontalViewOrigin;
|
||||||
|
Debug.Log($"SetCurrentPoint:{x}-{y}");
|
||||||
|
|
||||||
dataSource?.AddPointToCategoryRealtime("Player 2", x, y);
|
dataSource?.AddPointToCategoryRealtime("Player 2", x, y);
|
||||||
}
|
}
|
||||||
public void ClearChart(string cat = "Player 2")
|
public void ClearChart()
|
||||||
{
|
{
|
||||||
dataSource?.ClearCategory(cat);
|
if (dataSource != null)
|
||||||
}
|
|
||||||
public void SetHistoryData(List<DoubleVector2> list2 = null)
|
|
||||||
{
|
|
||||||
if (list2 != null)
|
|
||||||
{
|
{
|
||||||
dataSource?.ClearCategory("Player 1");
|
dataSource.HorizontalViewOrigin += 10;
|
||||||
|
SetCurrentPoint(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetHistoryData(double x,List<DoubleVector2> list2 = null)
|
||||||
|
{
|
||||||
|
if (list2 != null && list2.Count > 0)
|
||||||
|
{
|
||||||
|
var offset = dataSource.HorizontalViewOrigin;
|
||||||
|
graph.DataSource.AddPointToCategoryRealtime("Player 1", offset, 0);
|
||||||
for (int i = 0; i < list2.Count; i++)
|
for (int i = 0; i < list2.Count; i++)
|
||||||
{
|
{
|
||||||
var item = list2[i];
|
var item = list2[i];
|
||||||
graph.DataSource.AddPointToCategoryRealtime("Player 1", item.x, item.y);
|
graph.DataSource.AddPointToCategoryRealtime("Player 1", item.x + offset, item.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetChart()
|
||||||
|
{
|
||||||
|
if (dataSource != null)
|
||||||
|
{
|
||||||
|
dataSource.HorizontalViewOrigin = -0.03;
|
||||||
|
dataSource.ClearCategory("Player 1");
|
||||||
|
dataSource.ClearCategory("Player 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void SetData(List<DoubleVector2> list,List<DoubleVector2> list2 = null)
|
public void SetData(List<DoubleVector2> list,List<DoubleVector2> list2 = null)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user