From d498dd914879df9887bc73bcc5385f20ce3d8c66 Mon Sep 17 00:00:00 2001 From: CaiYanPeng Date: Thu, 2 Jun 2022 15:52:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/App.cs | 3 +- .../Ble/Characteristic/FtmsRowerData.cs | 11 ++-- .../Scripts/Devices/Ble/Devices/FtmsRower.cs | 1 + .../UI/Prefab/Panel/RowerHomeScript.cs | 56 +++++++++++++------ .../AndroidResolverDependencies.xml | 2 +- ProjectSettings/ProjectSettings.asset | 4 +- 6 files changed, 52 insertions(+), 25 deletions(-) diff --git a/Assets/Scripts/App.cs b/Assets/Scripts/App.cs index e6dea461..59655aac 100644 --- a/Assets/Scripts/App.cs +++ b/Assets/Scripts/App.cs @@ -218,6 +218,7 @@ public static class App {"http://192.168.0.101:5083/","http://pfweb.juze.pro/" } }; + public static List cacheList = new List(); static App() { InitLanguage(); @@ -234,7 +235,7 @@ public static class App //Host = "http://192.168.0.101:5087/"; //UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000); //TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001); - //Debug.unityLogger.logEnabled = false; + Debug.unityLogger.logEnabled = false; #else //Host = "http://pf.juze.pro/"; //Host = "http://192.168.0.101:5087/"; diff --git a/Assets/Scripts/Devices/Ble/Characteristic/FtmsRowerData.cs b/Assets/Scripts/Devices/Ble/Characteristic/FtmsRowerData.cs index 143fd375..cc29c80c 100644 --- a/Assets/Scripts/Devices/Ble/Characteristic/FtmsRowerData.cs +++ b/Assets/Scripts/Devices/Ble/Characteristic/FtmsRowerData.cs @@ -127,8 +127,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic //} var output = ""; output += "收到消息:" + string.Join("\t", data); - - + Debug.Log(output); this.Flags = (RowerDataFlag)BitConverter.ToUInt16(data, 0); int b = 2; if (!this.MoreDataFlag) @@ -156,6 +155,10 @@ namespace Assets.Scripts.Devices.Ble.Characteristic { var vvv = BitConvertHelper.ToUInt24(data, (int)b); output += $" 总距离{ vvv }米"; + if (vvv < 10) + { + App.cacheList.Add(DateTime.Now.ToString() + ":" + output); + } b += this.SizeOfDataForFlag(RowerDataFlag.TotalDistance); this.TotalDistance = vvv; @@ -258,7 +261,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic } pullList.Add(pull); } - Debug.Log("拉力:" + string.Join(",",list)); + //Debug.Log("拉力:" + string.Join(",",list)); } } List pullList; @@ -267,7 +270,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic this.StrokeRate = 0; this.StrokeCount = 0; this.AverageStrokeRate = 0; - this.TotalDistance = 0; + //this.TotalDistance = 0; this.InstantaneousPace = 0; this.AveragePace = 0; this.InstantaneousPower = 0; diff --git a/Assets/Scripts/Devices/Ble/Devices/FtmsRower.cs b/Assets/Scripts/Devices/Ble/Devices/FtmsRower.cs index 0abd3633..c135ab84 100644 --- a/Assets/Scripts/Devices/Ble/Devices/FtmsRower.cs +++ b/Assets/Scripts/Devices/Ble/Devices/FtmsRower.cs @@ -188,6 +188,7 @@ namespace Assets.Scripts.Devices.Ble.Devices if (this.controlPointCharacteristic != null) { Debug.Log("发送重置命令" + this.controlPointCharacteristic.ToString()); + App.cacheList.Add(DateTime.Now.ToString() + ":发送重置命令" + this.controlPointCharacteristic.ToString()); hwInterface.WriteCharacteristic(this.controlPointCharacteristic, new byte[] { 0x01 }); } } diff --git a/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs b/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs index 09d78753..6d4651af 100644 --- a/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs +++ b/Assets/Scripts/UI/Prefab/Panel/RowerHomeScript.cs @@ -256,6 +256,7 @@ public class RowerHomeScript : PFUIPanel }, false); var c2 = new NewMainNav.CustomButton(Resources.Load("Images/RowerNew/记录"), () => { + if (checkRowing()) return; UIManager.ShowResultListPanel(); }, false); btnStart = transform.Find("MainNav-mobile/Custom2").gameObject; @@ -314,9 +315,26 @@ public class RowerHomeScript : PFUIPanel bottom.Find("Expected/Title").GetComponent().text = $"{App.GetLocalString("EST")}{dw}"; } } - + private void DeleteCacheDir() + { + //删除实时记录 + try + { + var dir = $"{PFConstants.RowerRecordCacheFolder}/{App.CurrentUser.Id}/"; + if (Directory.Exists(dir)) + { + Helper.DelectDir(dir); + //Directory.Delete(dir, true); + } + } + catch (Exception e) + { + Debug.LogError(e.ToString()); + } + } private void Discard() { + openTimer = false; if (Application.internetReachability == NetworkReachability.NotReachable) { transform.Find("Stopped").gameObject.SetActive(true); @@ -324,8 +342,9 @@ public class RowerHomeScript : PFUIPanel return; } transform.Find("Stopped").gameObject.SetActive(false); - openTimer = false; isPause = true; + DeleteCacheDir(); + historyTime = 0; if (C2RowerData.IsEnabled == true) { Utils.showToast(null, "Press \"Menu\" to save.", int.MaxValue, stopFunc: () => C2RowerData.isReadyStatus, endCallback: Init); @@ -479,6 +498,7 @@ public class RowerHomeScript : PFUIPanel { File.Delete(files[0]); } + DeleteCacheDir(); } catch (Exception ex) { @@ -572,14 +592,14 @@ public class RowerHomeScript : PFUIPanel private void Init() { print("初始化"); + if (Rower != null) + { + Rower.Reset(); + } if (RowerData != null) { RowerData.Reset(); } - if (Rower != null) - { - Rower.Reset(); - } GetComponent().GetShadowList(rowerType, reRowData); btnStart.tag = "Start"; btnStart.GetComponent().sprite = spriteDict["Start"]; @@ -936,11 +956,7 @@ public class RowerHomeScript : PFUIPanel if (!string.IsNullOrEmpty(_re)) { var datas = _re.Split(','); - historyStrokeCount = int.Parse(datas[0]); - historyDistance = int.Parse(datas[2]); historyTime = int.Parse(datas[10]); - seconds = historyTime; - historyEnergy = int.Parse(datas[8]); var historyRowerType = PlayerPrefs.GetString("historyRowerType"); if (!string.IsNullOrEmpty(historyRowerType)) { @@ -948,6 +964,11 @@ public class RowerHomeScript : PFUIPanel rowerType = new RowerType() { type = int.Parse(typeObject[0]), value = float.Parse(typeObject[1]) }; HandleSelectType(); } + historyTime = int.Parse(datas[10]); + historyStrokeCount = int.Parse(datas[0]); + historyDistance = int.Parse(datas[2]); + seconds = historyTime; + historyEnergy = int.Parse(datas[8]); } } Helper.DelectDir(dir); @@ -977,6 +998,7 @@ public class RowerHomeScript : PFUIPanel Directory.CreateDirectory(dir); } File.WriteAllText(path, string.Join("\r\n", records)); + File.WriteAllText($"{PFConstants.RowerRecordCacheFolder}/cache.txt", string.Join("\r\n", App.cacheList)); PlayerPrefs.SetString("historyRowerType", $"{rowerType.type},{rowerType.value}"); } catch (Exception e) @@ -1010,10 +1032,10 @@ public class RowerHomeScript : PFUIPanel float curTime = 0f; void PaintPullCurve(ushort y) { - if (curTime-preTime < 0.1f) - { - return; - } + //if (y!=0 && curTime-preTime < 0.1f) + //{ + // return; + //} preTime = curTime; Debug.Log("收到拉力" + y + ","+ DateTime.Now.Ticks); //#if !UNITY_EDITOR @@ -1153,9 +1175,9 @@ public class RowerHomeScript : PFUIPanel var power = RowerData.InstantaneousPower; var rate = RowerData.StrokeRate; var pace = RowerData.InstantaneousPace; - var strokeCount = RowerData.StrokeCount; - var distance = (int)RowerData.TotalDistance; - var energy = RowerData.TotalEnergy; + var strokeCount = RowerData.StrokeCount + historyStrokeCount; + var distance = (int)RowerData.TotalDistance + historyDistance; + var energy = RowerData.TotalEnergy + historyEnergy; var heartRate = HeartRate ?? 0; if (rowerType.type == 1 && totalDistance >=rowerType.value && !createTime.HasValue) { diff --git a/ProjectSettings/AndroidResolverDependencies.xml b/ProjectSettings/AndroidResolverDependencies.xml index c2cee6dc..79f001d5 100644 --- a/ProjectSettings/AndroidResolverDependencies.xml +++ b/ProjectSettings/AndroidResolverDependencies.xml @@ -13,7 +13,7 @@ - + diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index c4963e8f..669f8140 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -256,7 +256,7 @@ PlayerSettings: clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea templatePackageId: com.unity.template.3d@4.2.8 templateDefaultScene: Assets/Scenes/SampleScene.unity - AndroidTargetArchitectures: 1 + AndroidTargetArchitectures: 3 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} AndroidKeystoreName: '{inproject}: Assets/Plugins/Android/powerfun.keystore' @@ -868,7 +868,7 @@ PlayerSettings: platformArchitecture: iPhone: 1 scriptingBackend: - Android: 0 + Android: 1 Standalone: 0 il2cppCompilerConfiguration: Standalone: 0