From 17eaccb72e93a5bce10bd7824ab15b5715e3785e Mon Sep 17 00:00:00 2001 From: lishuo Date: Fri, 4 Jun 2021 19:23:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=93=9D=E7=89=99=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/Ride/Scripts/CyclingController.cs | 8 +- .../Ride/Scripts/DeviceServiceMonoBase.cs | 93 ++++++++++++------- Assets/Scenes/Ride/Scripts/Helper.cs | 22 +++++ .../Ride/Scripts/Model/RecorderDataModel.cs | 2 +- .../Scenes/Ride/Scripts/PlayerController.cs | 5 +- Assets/Scripts/Devices/Ble/Devices/Tacx.cs | 3 +- .../Scripts/Devices/Ble/Win/ServiceUuids.cs | 21 ++++- 7 files changed, 111 insertions(+), 43 deletions(-) diff --git a/Assets/Scenes/Ride/Scripts/CyclingController.cs b/Assets/Scenes/Ride/Scripts/CyclingController.cs index 236d9d46..0e3b6d64 100644 --- a/Assets/Scenes/Ride/Scripts/CyclingController.cs +++ b/Assets/Scenes/Ride/Scripts/CyclingController.cs @@ -600,7 +600,9 @@ public class CyclingController : DeviceServiceMonoBase var list = mapData.List.Select(c => (float)c.Elevation).ToArray(); return list; } -#endregion - - + #endregion + private void OnApplicationQuit() + { + App.MainDeviceAdapter.Dispose(); + } } diff --git a/Assets/Scenes/Ride/Scripts/DeviceServiceMonoBase.cs b/Assets/Scenes/Ride/Scripts/DeviceServiceMonoBase.cs index 55352561..47d205b8 100644 --- a/Assets/Scenes/Ride/Scripts/DeviceServiceMonoBase.cs +++ b/Assets/Scenes/Ride/Scripts/DeviceServiceMonoBase.cs @@ -1,5 +1,8 @@ -using Assets.Scripts.Devices.Ant; +using Assets.Scripts.Ble; +using Assets.Scripts.Devices; +using Assets.Scripts.Devices.Ant; using Assets.Scripts.Devices.Ant.Interfaces; +using Assets.Scripts.Devices.Ble; using System; using System.Collections.Generic; using System.Linq; @@ -11,7 +14,7 @@ namespace Assets.Scenes.Ride.Scripts { public void TrackResistance(double grade) { - var device = (CurrentTrainer as FitDevice); + var device = (CurrentTrainer as ITrainerDevice); if (device != null) { device.SetTrackResistance(grade); @@ -19,10 +22,10 @@ namespace Assets.Scenes.Ride.Scripts } #region 获取设备数据 - public AbstractAntDevice CurrentTrainer + public AbstractDevice CurrentTrainer { get { - var devices = AntConnector.Instance().discoveredDevices.Where(d => d.State == DeviceState.Connected && (d.Sensor == SensorType.Trainer)); + var devices = App.MainDeviceAdapter.GetDevices().Where(d => d.State == DeviceState.Connected && (d.Sensor == SensorType.Trainer)); _device = null;//重置设备状态 if (devices.Count() > 0) { @@ -32,9 +35,18 @@ namespace Assets.Scenes.Ride.Scripts { (_device as IRequiresRiderWeight).RiderWeight = App.CurrentUser.Weight; } - ManufacturerId = _device.ManufacturerId; - DeviceNumber = $"{ _device.DeviceNumber },{ _device.DeviceType }"; - AntModelId = _device.AntModelId; + if (_device.Network == NetworkType.ANT) + { + var antDevice = _device as AbstractAntDevice; + ManufacturerId = antDevice.ManufacturerId; + AntModelId = antDevice.AntModelId; + DeviceNumber = $"{ antDevice.DeviceNumber },{ antDevice.DeviceType}"; + } + else + { + var bleDevice = _device as BleDevice; + DeviceNumber = $"{ Helper.FormateMacAddress(bleDevice.Address) },{ ServiceUuids.GetBySensor(bleDevice.Sensor) }"; + } } return _device; @@ -69,7 +81,8 @@ namespace Assets.Scenes.Ride.Scripts /// public double UpdatePower() { - return PowerDevice == null ? 0 : PowerDevice.Power; + var t = PowerDevice == null ? 0 : PowerDevice.Power; + return t; } /// /// 更新踏频 @@ -94,10 +107,10 @@ namespace Assets.Scenes.Ride.Scripts #region field - protected AbstractAntDevice _device; + protected AbstractDevice _device; protected AntConnector _antConnector; - public int ManufacturerId { get; private set; } + public int? ManufacturerId { get; private set; } public string DeviceNumber { get; private set; } public int? AntModelId { get; private set; } @@ -111,8 +124,8 @@ namespace Assets.Scenes.Ride.Scripts #endregion public bool CheckAnt() { - _antConnector = AntConnector.Instance(); - var devices = _antConnector.discoveredDevices.Where(d => d.State == DeviceState.Connected && (d.Sensor == SensorType.Trainer || d.Sensor == SensorType.Power)); + //_antConnector = AntConnector.Instance(); + var devices = App.MainDeviceAdapter.GetDevices().Where(d => d.State == DeviceState.Connected && (d.Sensor == SensorType.Trainer || d.Sensor == SensorType.Power)); if (devices.Count() > 0) { _device = devices.OrderByDescending(d => d.Sensor == SensorType.Trainer).First(); @@ -120,9 +133,19 @@ namespace Assets.Scenes.Ride.Scripts { (_device as IRequiresRiderWeight).RiderWeight = App.CurrentUser.Weight; } - ManufacturerId = _device.ManufacturerId; - DeviceNumber = $"{ _device.DeviceNumber },{ _device.DeviceType }"; - AntModelId = _device.AntModelId; + if (_device.Network == NetworkType.ANT) + { + var antDevice = _device as AbstractAntDevice; + ManufacturerId = antDevice.ManufacturerId; + AntModelId = antDevice.AntModelId; + DeviceNumber = $"{ antDevice.DeviceNumber },{ antDevice.DeviceType}"; + } + else + { + var bleDevice =_device as BleDevice; + DeviceNumber = $"{ bleDevice.Address },{ bleDevice.Sensor }"; + } + } else { @@ -146,11 +169,11 @@ namespace Assets.Scenes.Ride.Scripts get { //速度和踏频一体的传感器,里面的速度是不可以读的,只允许读 踏频,切记 - if (_antConnector == null) - { - return null; - } - var device = _antConnector.discoveredDevices.Where(d => d.State == DeviceState.Connected && d is ISpeedDevice).FirstOrDefault(); + //if (_antConnector == null) + //{ + // return null; + //} + var device = App.MainDeviceAdapter.GetDevices().Where(d => d.State == DeviceState.Connected && d is ISpeedDevice).FirstOrDefault(); if (device != null) { return (ISpeedDevice)device; @@ -165,11 +188,11 @@ namespace Assets.Scenes.Ride.Scripts { get { - if (_antConnector == null) - { - return null; - } - var device = _antConnector.discoveredDevices.Where(d => d.State == DeviceState.Connected && d is IHeartRateDevice).FirstOrDefault(); + //if (_antConnector == null) + //{ + // return null; + //} + var device = App.MainDeviceAdapter.GetDevices().Where(d => d.State == DeviceState.Connected && d is IHeartRateDevice).FirstOrDefault(); if (device != null) { return (IHeartRateDevice)device; @@ -184,11 +207,11 @@ namespace Assets.Scenes.Ride.Scripts { get { - if (_antConnector == null) - { - return null; - } - var powerDevices = _antConnector.discoveredDevices.Where(d => d.State == DeviceState.Connected && d is IPowerDevice).ToList(); + //if (_antConnector == null) + //{ + // return null; + //} + var powerDevices = App.MainDeviceAdapter.GetDevices().Where(d => d.State == DeviceState.Connected && d is IPowerDevice).ToList(); var power = powerDevices.FirstOrDefault(d => d.Sensor == SensorType.Power); if (power != null) { @@ -210,11 +233,11 @@ namespace Assets.Scenes.Ride.Scripts { get { - if (_antConnector == null) - { - return null; - } - var cadences = _antConnector.discoveredDevices.Where(d => d.State == DeviceState.Connected && d is ICadenceDevice).ToList(); + //if (_antConnector == null) + //{ + // return null; + //} + var cadences = App.MainDeviceAdapter.GetDevices().Where(d => d.State == DeviceState.Connected && d is ICadenceDevice).ToList(); var cadence = cadences.FirstOrDefault(d => d.Sensor == SensorType.Cadence); if (cadence != null) { diff --git a/Assets/Scenes/Ride/Scripts/Helper.cs b/Assets/Scenes/Ride/Scripts/Helper.cs index d0ab3a84..5fa57849 100644 --- a/Assets/Scenes/Ride/Scripts/Helper.cs +++ b/Assets/Scenes/Ride/Scripts/Helper.cs @@ -108,6 +108,28 @@ namespace Assets.Scenes.Ride.Scripts S = s.ToString(); return $"{H}:{M}:{S}"; } + public static string FormateMacAddress(string v) + { + try + { + var s = Convert.ToInt64(v).ToString("x8").ToUpperInvariant(); + var array = s.ToCharArray(); + StringBuilder newLsit = new StringBuilder(); + for (int i = array.Length - 1; i >= 0; i--) + { + newLsit.Append(array[i]); + if (i % 2 == 0 && i > 0) + { + newLsit.Append(":"); + } + } + return newLsit.ToString(); + } + catch (Exception) + { + return v; + } + } /// /// 计算速度 /// 参考 http://bikecalculator.com/index.html diff --git a/Assets/Scenes/Ride/Scripts/Model/RecorderDataModel.cs b/Assets/Scenes/Ride/Scripts/Model/RecorderDataModel.cs index ca6e4125..1731e506 100644 --- a/Assets/Scenes/Ride/Scripts/Model/RecorderDataModel.cs +++ b/Assets/Scenes/Ride/Scripts/Model/RecorderDataModel.cs @@ -62,7 +62,7 @@ namespace Assets.Scenes.Ride.Scripts.Model /// /// 厂商Id /// - public int ManufacturerId { get; set; } + public int? ManufacturerId { get; set; } public int? AntModelId { get; set; } /// diff --git a/Assets/Scenes/Ride/Scripts/PlayerController.cs b/Assets/Scenes/Ride/Scripts/PlayerController.cs index 6c773ca0..08f0424f 100644 --- a/Assets/Scenes/Ride/Scripts/PlayerController.cs +++ b/Assets/Scenes/Ride/Scripts/PlayerController.cs @@ -56,12 +56,13 @@ namespace Assets.Scenes.Ride.Scripts bicycleWeight = App.CurrentUser.BicycleWeight; //#if UNITY_EDITOR System.Random rd = new System.Random(); - power = 1000; //rd.Next(150, 300);//测试功率 + //power = 1000; //rd.Next(150, 300);//测试功率 //#endif mainController.TrackResistance(currentSlope * App.rideSetting.sensitivity / 100); } - catch (Exception) + catch (Exception ex) { + Debug.Log(ex.Message); heartRate = 0; power = 0; cadance = 0; diff --git a/Assets/Scripts/Devices/Ble/Devices/Tacx.cs b/Assets/Scripts/Devices/Ble/Devices/Tacx.cs index e995f866..ebb156a6 100644 --- a/Assets/Scripts/Devices/Ble/Devices/Tacx.cs +++ b/Assets/Scripts/Devices/Ble/Devices/Tacx.cs @@ -11,11 +11,12 @@ using UnityEngine; namespace Assets.Scripts.Devices.Ble.Devices { - public class Tacx : BleDevice, IPowerDevice, ICadenceDevice, ISpeedDevice, ITrainerDevice + public class Tacx : BleDevice, IPowerDevice, ICadenceDevice, ISpeedDevice, ITrainerDevice, IRequiresRiderWeight { public int Power { get => tacxFecNotify.Power; set => throw new NotImplementedException(); } public int Cadence { get => tacxFecNotify.Cadence; set => throw new NotImplementedException(); } public double Speed { get => tacxFecNotify.Speed; set => throw new NotImplementedException(); } + public double RiderWeight { get; set; } private List Services; diff --git a/Assets/Scripts/Devices/Ble/Win/ServiceUuids.cs b/Assets/Scripts/Devices/Ble/Win/ServiceUuids.cs index ac77290a..03942c89 100644 --- a/Assets/Scripts/Devices/Ble/Win/ServiceUuids.cs +++ b/Assets/Scripts/Devices/Ble/Win/ServiceUuids.cs @@ -1,4 +1,5 @@ -using System; +using Assets.Scripts.Devices.Ant; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -171,6 +172,24 @@ namespace Assets.Scripts.Ble return ServiceUuids.Services.Single(s => s.IdByteArray == type); } + public static Guid GetBySensor(SensorType sensor) + { + switch (sensor) + { + case SensorType.Cadence: + case SensorType.SpeedCadence: + return Get(ServiceUuids.CyclingSpeedCadence).IdGuid; + case SensorType.HeartRate: + return Get(ServiceUuids.HeartRate).IdGuid; + case SensorType.Power: + return Get(ServiceUuids.PowerBeam).IdGuid; + case SensorType.Trainer: + return Get(ServiceUuids.TacxBle).IdGuid; + default: + return Guid.Empty; + } + } + public static class Characteristics { From b6d70e68566b8f6b7be4182f6172e37d624812c9 Mon Sep 17 00:00:00 2001 From: lishuo Date: Mon, 7 Jun 2021 17:05:49 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E5=B7=AE=E5=BC=82=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Mapbox/Unity/Map/AbstractMap.cs | 2 +- Assets/Scenes/Ride/Scripts/Model/TargetData.cs | 16 ++++++++-------- Assets/Scenes/Ride/Scripts/PlayerController.cs | 2 +- Assets/Scripts/Apis/MapApi.cs | 5 +++-- Assets/Scripts/App.cs | 8 ++++---- .../Scripts/UI/Prefab/Panel/BigMapController.cs | 3 ++- .../Scripts/UI/Prefab/Panel/EarthController.cs | 4 ++-- .../UI/Prefab/Panel/EditUserController.cs | 13 +++++++------ 8 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Assets/Mapbox/Unity/Map/AbstractMap.cs b/Assets/Mapbox/Unity/Map/AbstractMap.cs index a1cf4d1f..b8c88bff 100644 --- a/Assets/Mapbox/Unity/Map/AbstractMap.cs +++ b/Assets/Mapbox/Unity/Map/AbstractMap.cs @@ -1137,7 +1137,7 @@ namespace Mapbox.Unity.Map public virtual void SetCenterLatitudeLongitude(Vector2d centerLatitudeLongitude) { - _options.locationOptions.latitudeLongitude = string.Format("{0}, {1}", centerLatitudeLongitude.x, centerLatitudeLongitude.y); + _options.locationOptions.latitudeLongitude = string.Format("{0}, {1}", centerLatitudeLongitude.x.ToString(CultureInfo.InvariantCulture), centerLatitudeLongitude.y.ToString(CultureInfo.InvariantCulture)); _centerLatitudeLongitude = centerLatitudeLongitude; } diff --git a/Assets/Scenes/Ride/Scripts/Model/TargetData.cs b/Assets/Scenes/Ride/Scripts/Model/TargetData.cs index 7f5fc5d1..af2c69d4 100644 --- a/Assets/Scenes/Ride/Scripts/Model/TargetData.cs +++ b/Assets/Scenes/Ride/Scripts/Model/TargetData.cs @@ -53,19 +53,19 @@ namespace Assets.Scenes.Ride.Scripts.Model { string[] split = data.Split(','); var target = new TargetData(); - target.Ticks = int.Parse(split[0]); - target._Power = double.Parse(split[1]); - target._Speed = double.Parse(split[2]); - target._Distance = double.Parse(split[3]); - target._Cadence = double.Parse(split[4]); + target.Ticks = Convert.ToInt32(split[0], CultureInfo.InvariantCulture); //int.Parse(split[0]); + target._Power = Convert.ToDouble(split[1], CultureInfo.InvariantCulture); + target._Speed = Convert.ToDouble(split[2], CultureInfo.InvariantCulture);// double.Parse(split[2]); + target._Distance = Convert.ToDouble(split[3], CultureInfo.InvariantCulture); //double.Parse(split[3]); + target._Cadence = Convert.ToDouble(split[4], CultureInfo.InvariantCulture); //double.Parse(split[4]); if (!string.IsNullOrWhiteSpace(split[5]) && split[5] != "null") { - target._HeartRate = int.Parse(split[5]); + target._HeartRate = Convert.ToInt32(split[5], CultureInfo.InvariantCulture); //int.Parse(split[5]); } if (split.Length > 6) { - target._Lat = double.Parse(split[6]); - target._Lon = double.Parse(split[7]); + target._Lat = Convert.ToDouble(split[6], CultureInfo.InvariantCulture); //double.Parse(split[6]); + target._Lon = Convert.ToDouble(split[7], CultureInfo.InvariantCulture); //double.Parse(split[7]); //target._Bearing = double.Parse(split[8]); } return target; diff --git a/Assets/Scenes/Ride/Scripts/PlayerController.cs b/Assets/Scenes/Ride/Scripts/PlayerController.cs index 08f0424f..109c9f8a 100644 --- a/Assets/Scenes/Ride/Scripts/PlayerController.cs +++ b/Assets/Scenes/Ride/Scripts/PlayerController.cs @@ -56,7 +56,7 @@ namespace Assets.Scenes.Ride.Scripts bicycleWeight = App.CurrentUser.BicycleWeight; //#if UNITY_EDITOR System.Random rd = new System.Random(); - //power = 1000; //rd.Next(150, 300);//测试功率 + power = 1000; //rd.Next(150, 300);//测试功率 //#endif mainController.TrackResistance(currentSlope * App.rideSetting.sensitivity / 100); } diff --git a/Assets/Scripts/Apis/MapApi.cs b/Assets/Scripts/Apis/MapApi.cs index 1bddc2eb..958dc1ea 100644 --- a/Assets/Scripts/Apis/MapApi.cs +++ b/Assets/Scripts/Apis/MapApi.cs @@ -3,6 +3,7 @@ using Assets.Scenes.Ride.Scripts.Model; using Assets.Scripts.Apis.Models; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -91,7 +92,7 @@ namespace Assets.Scripts.Apis public async Task>> GetNearRouteAsync(float lat, float lng, float zoom, string bounds) { - var res = await GetAsync>>($"/Map/GetNearRoute?lat={ lat }&lng={ lng }&zoom={zoom}&bounds={ bounds }"); + var res = await GetAsync>>($"/Map/GetNearRoute?lat={ lat.ToString(CultureInfo.InvariantCulture) }&lng={ lng.ToString(CultureInfo.InvariantCulture) }&zoom={zoom.ToString(CultureInfo.InvariantCulture)}&bounds={ bounds }"); //var result = System.Text.Encoding.UTF8.GetString(res); return res; @@ -142,7 +143,7 @@ namespace Assets.Scripts.Apis public async Task> GetEarthData(double lat, double lon) { //CultureInfo.InvariantCulture - var result = await GetAsync>($"Map/GetEarthData?lat={ lat }&lon={ lon }"); + var result = await GetAsync>($"Map/GetEarthData?lat={ lat.ToString(CultureInfo.InvariantCulture) }&lon={ lon.ToString(CultureInfo.InvariantCulture) }"); return result; } diff --git a/Assets/Scripts/App.cs b/Assets/Scripts/App.cs index b22a285c..f6cc6593 100644 --- a/Assets/Scripts/App.cs +++ b/Assets/Scripts/App.cs @@ -66,10 +66,10 @@ public static class App static App() { - CultureInfo currentCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone(); - currentCulture.NumberFormat.NumberDecimalSeparator = "."; - Thread.CurrentThread.CurrentCulture = currentCulture; - System.Globalization.CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + //CultureInfo currentCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone(); + //currentCulture.NumberFormat.NumberDecimalSeparator = "."; + //Thread.CurrentThread.CurrentCulture = currentCulture; + //System.Globalization.CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; #if !UNITY_EDITOR // Host = "http://pf.juze.pro/"; // UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000); diff --git a/Assets/Scripts/UI/Prefab/Panel/BigMapController.cs b/Assets/Scripts/UI/Prefab/Panel/BigMapController.cs index b9ccc4c2..b38d1daa 100644 --- a/Assets/Scripts/UI/Prefab/Panel/BigMapController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/BigMapController.cs @@ -16,6 +16,7 @@ using UnityEngine.EventSystems; using UnityEngine.SceneManagement; using Mapbox.Examples; using DG.Tweening; +using System.Globalization; public class BigMapController : PFUIPanel { @@ -241,7 +242,7 @@ public class BigMapController : PFUIPanel //Screen.width //map.WorldToGeoPosition(start) - var bounds = $"{ start.y },{ start.x };{ end.y },{ end.x }"; + var bounds = $"{ start.y.ToString(CultureInfo.InvariantCulture) },{ start.x.ToString(CultureInfo.InvariantCulture) };{ end.y.ToString(CultureInfo.InvariantCulture) },{ end.x.ToString(CultureInfo.InvariantCulture) }"; var res = await mapApi.GetNearRouteAsync((float)mapManager.CenterLatitudeLongitude.x, (float)mapManager.CenterLatitudeLongitude.y, mapManager.Zoom, bounds); if(res.result == false) diff --git a/Assets/Scripts/UI/Prefab/Panel/EarthController.cs b/Assets/Scripts/UI/Prefab/Panel/EarthController.cs index 57c04780..e8f48b64 100644 --- a/Assets/Scripts/UI/Prefab/Panel/EarthController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/EarthController.cs @@ -243,8 +243,8 @@ public class EarthController : PFUIPanel { //Debug.Log("click"); - Vector2 latLon = Conversion.GetLatLonFromSpherePoint(sphereLocation); - Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y); + //Vector2 latLon = Conversion.GetLatLonFromSpherePoint(sphereLocation); + //Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y); } diff --git a/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs b/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs index 8223f349..7e355e24 100644 --- a/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json.Linq; using System; using System.Collections; using System.Collections.Generic; +using System.Globalization; using System.Runtime.InteropServices; using System.Threading.Tasks; using UnityEngine; @@ -308,12 +309,12 @@ public class EditUserController : PFUIPanel Utils.showToast(gameObject, "Please fill in the information");//请填写相关信息 return; } - user.FTP = int.Parse(mFTP.Text); - user.Height = int.Parse(mHeight.Text); - user.Weight = double.Parse(mWeight.Text); - user.MaxHeartRate = int.Parse(mMHR.Text); - user.BicycleWeight = double.Parse(mBW.Text); - user.WheelDiameter = int.Parse(mWD.Text); + user.FTP = Convert.ToInt32(mFTP.Text, CultureInfo.InvariantCulture); //int.Parse(mFTP.Text); + user.Height = Convert.ToInt32(mHeight.Text, CultureInfo.InvariantCulture); //int.Parse(mHeight.Text); + user.Weight = Convert.ToDouble(mWeight.Text, CultureInfo.InvariantCulture); //double.Parse(mWeight.Text); + user.MaxHeartRate = Convert.ToInt32(mMHR.Text, CultureInfo.InvariantCulture); //int.Parse(mMHR.Text); + user.BicycleWeight = Convert.ToDouble(mBW.Text, CultureInfo.InvariantCulture); //double.Parse(mBW.Text); + user.WheelDiameter = Convert.ToInt32(mWD.Text, CultureInfo.InvariantCulture); //int.Parse(mWD.Text); user.Unit = mUnitDropdown.SelectedIndex; user.Contact = mName.Text; user.ContactPhone = mPhone.Text; From 35b50efdedd725a0ae29ac5f28da15731c0a0f07 Mon Sep 17 00:00:00 2001 From: lishuo Date: Tue, 8 Jun 2021 11:32:06 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=B8=8E=E8=B7=AF=E4=B9=A6=E5=88=97=E8=A1=A8=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E5=8C=BA=E5=9F=9F=E5=8C=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Apis/ThirdPartApi.cs | 3 ++- Assets/Scripts/UI/Prefab/Panel/EditUserController.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/Apis/ThirdPartApi.cs b/Assets/Scripts/Apis/ThirdPartApi.cs index 794bbf57..c0503bb5 100644 --- a/Assets/Scripts/Apis/ThirdPartApi.cs +++ b/Assets/Scripts/Apis/ThirdPartApi.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -26,7 +27,7 @@ namespace Assets.Scripts.Apis } public async Task GetMapImage(IpToGeoModel locationInfo) { - return await GetThirdPartStreamAsync($"https://api.mapbox.com/styles/v1/juzetest/ckmkdjwsa1nvt17nr1ps4fqgs/static/{locationInfo.longitude},{locationInfo.latitude},12,0/1280x1280?access_token=pk.eyJ1IjoianV6ZXRlc3QiLCJhIjoiY2ttazhsbnpiMGVrdjJucGhyNnh6eXcxYSJ9.6zj2U9eFCNJRMljNlMxjVg"); + return await GetThirdPartStreamAsync($"https://api.mapbox.com/styles/v1/juzetest/ckmkdjwsa1nvt17nr1ps4fqgs/static/{locationInfo.longitude.ToString(CultureInfo.InvariantCulture)},{locationInfo.latitude.ToString(CultureInfo.InvariantCulture)},12,0/1280x1280?access_token=pk.eyJ1IjoianV6ZXRlc3QiLCJhIjoiY2ttazhsbnpiMGVrdjJucGhyNnh6eXcxYSJ9.6zj2U9eFCNJRMljNlMxjVg"); //pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA //pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA } diff --git a/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs b/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs index 7e355e24..6d81b620 100644 --- a/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/EditUserController.cs @@ -309,12 +309,12 @@ public class EditUserController : PFUIPanel Utils.showToast(gameObject, "Please fill in the information");//请填写相关信息 return; } - user.FTP = Convert.ToInt32(mFTP.Text, CultureInfo.InvariantCulture); //int.Parse(mFTP.Text); - user.Height = Convert.ToInt32(mHeight.Text, CultureInfo.InvariantCulture); //int.Parse(mHeight.Text); - user.Weight = Convert.ToDouble(mWeight.Text, CultureInfo.InvariantCulture); //double.Parse(mWeight.Text); - user.MaxHeartRate = Convert.ToInt32(mMHR.Text, CultureInfo.InvariantCulture); //int.Parse(mMHR.Text); - user.BicycleWeight = Convert.ToDouble(mBW.Text, CultureInfo.InvariantCulture); //double.Parse(mBW.Text); - user.WheelDiameter = Convert.ToInt32(mWD.Text, CultureInfo.InvariantCulture); //int.Parse(mWD.Text); + user.FTP = Convert.ToInt32(mFTP.Text, CultureInfo.InstalledUICulture); //int.Parse(mFTP.Text); + user.Height = Convert.ToInt32(mHeight.Text, CultureInfo.InstalledUICulture); //int.Parse(mHeight.Text); + user.Weight = Convert.ToDouble(mWeight.Text, CultureInfo.InstalledUICulture); //double.Parse(mWeight.Text); + user.MaxHeartRate = Convert.ToInt32(mMHR.Text, CultureInfo.InstalledUICulture); //int.Parse(mMHR.Text); + user.BicycleWeight = Convert.ToDouble(mBW.Text, CultureInfo.InstalledUICulture); //double.Parse(mBW.Text); + user.WheelDiameter = Convert.ToInt32(mWD.Text, CultureInfo.InstalledUICulture); //int.Parse(mWD.Text); user.Unit = mUnitDropdown.SelectedIndex; user.Contact = mName.Text; user.ContactPhone = mPhone.Text;