4.14修改,设备连接去掉ftms骑行台
This commit is contained in:
1 parent
29e7219c21
commit
f383c54507
18 files changed
+2511
-10695
No files matched your search
@@ -46,5 +46,10 @@ namespace Assets.Scripts.Apis
|
||||
{
|
||||
return await GetAsync<JsonResult<List<RowerRank>>>($"Rower/GetShadowList?type={rowerType.type}&typeValue={rowerType.value}");
|
||||
}
|
||||
|
||||
public async Task<JsonResult<List<RowerRank>>> GetReRowShadowList(string id)
|
||||
{
|
||||
return await GetAsync<JsonResult<List<RowerRank>>>($"Rower/GetReRowShadowList?Id={id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,8 @@ namespace Assets.Scripts.Devices.Ant
|
||||
SpeedCadence,
|
||||
Trainer,
|
||||
VirtualPower,
|
||||
Rower
|
||||
Rower,
|
||||
FtmsTrainer
|
||||
}
|
||||
|
||||
public enum NetworkType
|
||||
|
||||
@@ -57,18 +57,30 @@ namespace Assets.Scripts.Devices.Ble
|
||||
}
|
||||
|
||||
public override void StartScan()
|
||||
{
|
||||
{
|
||||
hwInterface.StartScan((device) =>
|
||||
{
|
||||
{
|
||||
if (!discoveredDevices.ContainsKey(device.Peripheral.Address))
|
||||
{
|
||||
Debug.Log($"发现设备{ device.Peripheral.Address }, \t\tName:{ device.Peripheral.Name }, type:{ device.SensorType }");
|
||||
Debug.Log($"发现设备{ device.Peripheral.Address }, \t\tName:{ device.Peripheral.Name }, type:{ device.SensorType } 服务:{string.Join(",", device.Services)}");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(device.Peripheral.Name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (device.SensorType == Ant.SensorType.Trainer)
|
||||
if (device.SensorType == Ant.SensorType.FtmsTrainer)
|
||||
{
|
||||
var device1 = new Ftms(device.Peripheral, hwInterface);
|
||||
if (discoveredDevices.ContainsKey(device.Peripheral.Address))
|
||||
{
|
||||
discoveredDevices[device.Peripheral.Address] = device1;
|
||||
}
|
||||
else
|
||||
{
|
||||
discoveredDevices.Add(device.Peripheral.Address, device1);
|
||||
}
|
||||
}
|
||||
else if (device.SensorType == Ant.SensorType.Trainer)
|
||||
{
|
||||
//var device1 = new Ftms(device.Peripheral, hwInterface);
|
||||
//discoveredDevices.Add(device.Peripheral.Address, device0);
|
||||
@@ -122,7 +134,21 @@ namespace Assets.Scripts.Devices.Ble
|
||||
{
|
||||
//TODO:取消注释,自动连接设备
|
||||
//Debug.Log("自动连接" + device111.Id);
|
||||
device111.Connect();
|
||||
|
||||
if (App.IsRowerMode == true)
|
||||
{
|
||||
if (device111.Sensor == Ant.SensorType.Rower || device111.Sensor == Ant.SensorType.HeartRate)
|
||||
{
|
||||
device111.Connect();
|
||||
}
|
||||
}
|
||||
else if(App.IsRowerMode == false)
|
||||
{
|
||||
if (device111.Sensor != Ant.SensorType.Rower)
|
||||
{
|
||||
device111.Connect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
//Debug.Log("数据" + string.Join(",", data));
|
||||
if (data[0] == 53)
|
||||
{
|
||||
PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10);
|
||||
AverageDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 15)) / 10);
|
||||
PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10,true);
|
||||
AverageDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 15)) / 10, true);
|
||||
Debug.Log($"峰力值:{PeakDriveForce} 均力值{AverageDriveForce}");
|
||||
}
|
||||
else if (data[0] == 61)
|
||||
@@ -67,7 +67,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
List<ushort> r = new List<ushort>();
|
||||
for (int i = 3; i < data.Length; i += 2)
|
||||
{
|
||||
ushort pull = data[i] < 10 ? (ushort)0 : Convert.ToUInt16(Math.Round(LbsToNewton(data[i])));
|
||||
ushort pull = data[i] < 10 ? (ushort)0 : Convert.ToUInt16(Math.Round(LbsToNewton(data[i], true)));
|
||||
r.Add(pull);
|
||||
PullValue = pull;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
// isReadyStatus = data[2] == 1 || data[2] == 129;
|
||||
//}
|
||||
}
|
||||
private double LbsToNewton(double lbs) => 4.4482216 * lbs;
|
||||
private double LbsToNewton(double lbs,bool isKg = false) => 4.4482216 * lbs * (isKg ? (1f / 9.8f) : 1f);
|
||||
public void SetUnavailable()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
|
||||
@@ -226,6 +226,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
for (int pullB = 4; pullB < data.Length; pullB += 2)
|
||||
{
|
||||
var val = BitConverter.ToUInt16(data, pullB);
|
||||
val = Convert.ToUInt16(((double)val) /9.8f);
|
||||
list.Add(val);
|
||||
PullValue = val;
|
||||
|
||||
|
||||
@@ -102,13 +102,19 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
if (characteristic.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
{
|
||||
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.RowerData);
|
||||
c.HandleAttributeReceived(response.Data);
|
||||
if (c != null)
|
||||
{
|
||||
c.HandleAttributeReceived(response.Data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.C2RowerData);
|
||||
var data = new byte[] { characteristic.Id.ToByteArray()[0] }.Concat(response.Data).ToArray();
|
||||
c.HandleAttributeReceived(data);
|
||||
if (c != null)
|
||||
{
|
||||
var data = new byte[] { characteristic.Id.ToByteArray()[0] }.Concat(response.Data).ToArray();
|
||||
c.HandleAttributeReceived(data);
|
||||
}
|
||||
}
|
||||
//foreach (var item in base.Characteristics)
|
||||
//{
|
||||
|
||||
@@ -134,17 +134,14 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//Debug.Log($"設備信息,{item.IdGuid},{string.Join(";", item.IdByteArray)}");
|
||||
//Debug.Log($"設備{App.IsRowerMode}信息,{item.IdGuid},{string.Join(";", item.IdByteArray)}");
|
||||
if (item.IdByteArray == ServiceUuids.Ftms)
|
||||
{
|
||||
if (App.IsRowerMode == true)
|
||||
{
|
||||
sensor = SensorType.Rower;
|
||||
}
|
||||
else
|
||||
{
|
||||
sensor = SensorType.Trainer;
|
||||
}
|
||||
sensor = SensorType.Rower;
|
||||
//else
|
||||
//{
|
||||
// sensor = SensorType.FtmsTrainer;
|
||||
//}
|
||||
}
|
||||
else if (item.IdByteArray == ServiceUuids.HeartRate)
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ public class HomeController : PFUIPanel
|
||||
nav.SetButtonActive(new List<int> { 1, 3, 4, 6 },null,new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_mode_44"), () =>
|
||||
{
|
||||
UIManager.ShowRowerSelector();
|
||||
}));
|
||||
},false));
|
||||
newNav = nav;
|
||||
UIManager.AddEvent(transform.Find("TodayData/Datas/Distance").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
|
||||
@@ -227,6 +227,26 @@ public class RowerHomeScript : PFUIPanel
|
||||
}
|
||||
Init();
|
||||
}
|
||||
|
||||
RowerResultModel reRowData = null;
|
||||
public void ReRow(RowerResultModel r)
|
||||
{
|
||||
this.reRowData = r;
|
||||
if (r!= null && r.Type.HasValue)
|
||||
{
|
||||
rowerType = new RowerType { type = r.Type.Value,value = (float)r.TypeValue.Value };
|
||||
if (Rower != null)
|
||||
{
|
||||
Rower.Reset();
|
||||
}
|
||||
//RowerPanel/Rower/Bottom/Expected/Title
|
||||
//var dw = rowerType.type == 1 ? $"{rowerType.value}M" : $"{(rowerType.value / 60).ToString("#0.00")}Min";
|
||||
//bottom.Find("Expected/Title").GetComponent<Text>().text = $"EST\n/ {dw}";
|
||||
var dw = rowerType.type == 1 ? $"" : $"\nM";
|
||||
bottom.Find("Expected/Title").GetComponent<Text>().text = $"{App.GetLocalString("EST")}{dw}";
|
||||
}
|
||||
}
|
||||
|
||||
private void Discard()
|
||||
{
|
||||
transform.Find("Stopped").gameObject.SetActive(false);
|
||||
@@ -264,8 +284,8 @@ public class RowerHomeScript : PFUIPanel
|
||||
//mainNav.ShowRowerTab();
|
||||
|
||||
transform.MyDOFade();
|
||||
Debug.Log("140,开始扫描");
|
||||
App.MainDeviceAdapter.StartScan();
|
||||
//Debug.Log("140,开始扫描");
|
||||
//App.MainDeviceAdapter.StartScan();
|
||||
Init();
|
||||
//transform.Find("Left/Rower").GetComponent<RowerAnimation>().StartAnimation();
|
||||
}
|
||||
@@ -484,7 +504,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
{
|
||||
Rower.Reset();
|
||||
}
|
||||
GetComponent<RowerMultiModeScript>().GetShadowList(rowerType);
|
||||
GetComponent<RowerMultiModeScript>().GetShadowList(rowerType, reRowData);
|
||||
btnStart.tag = "Start";
|
||||
btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
|
||||
left.Find("Rower").GetComponent<Image>().sprite = spriteDict[0];
|
||||
@@ -558,7 +578,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
private void ResChanged(object sender, EventArgs e)
|
||||
{
|
||||
print("收到阻力" + sender);
|
||||
if ((Convert.ToSingle(sender) > 50) && slider)
|
||||
if ((Convert.ToSingle(sender) >= 50) && slider)
|
||||
{
|
||||
slider.GetComponent<PFUISlider>().SetValue((Convert.ToSingle(sender) - 50) / 300f);
|
||||
}
|
||||
@@ -578,7 +598,7 @@ public class RowerHomeScript : PFUIPanel
|
||||
private void ReturnHome()
|
||||
{
|
||||
if (checkRowing()) return;
|
||||
Disconnect();
|
||||
//Disconnect();
|
||||
UIManager.ShowHomePanel();
|
||||
UIManager.ShowRowerSelector();
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class RouteItem : MonoBehaviour
|
||||
UIManager.ShowConfirm("Re-Rowing", "Rowing again?", () =>
|
||||
{
|
||||
UIManager.CloseConfirm();
|
||||
UIManager.ShowRowerPanel();
|
||||
UIManager.ShowRowerPanel(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections;
|
||||
using Assets.Scripts;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -16,6 +17,17 @@ public class RowerDevicePanel : PFUIPanel
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
print("开启扫描");
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
App.MainDeviceAdapter.StartScan();
|
||||
#if UNITY_ANDROID
|
||||
Utils.CallAndroidMethod("OpenLocationService");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
float timer = 1f;
|
||||
// Update is called once per frame
|
||||
|
||||
@@ -172,11 +172,11 @@ public class RowerMultiModeScript : MonoBehaviour
|
||||
public int sumdiff { get; set; }
|
||||
}
|
||||
public Dictionary<int, RankDiff> rankDiffDict;
|
||||
public async void GetShadowList(RowerTaskPanel.RowerType rowerType)
|
||||
public async void GetShadowList(RowerTaskPanel.RowerType rowerType, RowerResultModel reRowData)
|
||||
{
|
||||
this.rowerType = rowerType;
|
||||
currentSecond = -1;
|
||||
var res = await ConfigHelper.rowerApi.GetShadowList(rowerType);
|
||||
var res = reRowData ==null? await ConfigHelper.rowerApi.GetShadowList(rowerType): await ConfigHelper.rowerApi.GetReRowShadowList(reRowData.Id);
|
||||
shadowList = res.data;
|
||||
//foreach (var t in traceList)
|
||||
//{
|
||||
@@ -304,7 +304,7 @@ public class RowerMultiModeScript : MonoBehaviour
|
||||
|
||||
var width = t.Find("Main").GetComponent<RectTransform>().sizeDelta.x - t.Find("Main/Boat").GetComponent<RectTransform>().sizeDelta.x;
|
||||
var diffWidth = data.currentDistance - mineData.currentDistance + 50;
|
||||
if (data.currentDistance <= 50)
|
||||
if (data.currentDistance <= 50 && mineData.currentDistance <= 50)
|
||||
{
|
||||
diffWidth = data.currentDistance;
|
||||
}
|
||||
@@ -335,22 +335,31 @@ public class RowerMultiModeScript : MonoBehaviour
|
||||
{
|
||||
var ani = DOTween.Sequence();
|
||||
var _d = data.list[currentSecond];
|
||||
if (currentSecond > 0)
|
||||
if (currentSecond > 0 && _d.Pace > 0)
|
||||
{
|
||||
var _pred = data.list[currentSecond - 1];
|
||||
if (_pred.StrokeCount != _d.StrokeCount)
|
||||
var spDict = GetComponent<RowerHomeScript>().spriteDict;
|
||||
int spDictIndex = 0;
|
||||
ani.Join(DOTween.To(() => spDictIndex, x => t.Find("Main/Boat").GetComponent<Image>().sprite = spDict[x], 14, 0.2f));
|
||||
ani.AppendCallback(() =>
|
||||
{
|
||||
//上次划桨次数和这次不一样 说明需要划桨一次
|
||||
var spDict = GetComponent<RowerHomeScript>().spriteDict;
|
||||
int spDictIndex = 0;
|
||||
ani.Join(DOTween.To(() => spDictIndex, x => t.Find("Main/Boat").GetComponent<Image>().sprite = spDict[x], 14, 0.2f));
|
||||
ani.AppendCallback(() =>
|
||||
{
|
||||
int spDictIndex2 = 14;
|
||||
DOTween.To(() => spDictIndex2, x => t.Find("Main/Boat").GetComponent<Image>().sprite = spDict[x], 0, 0.4f);
|
||||
});
|
||||
ani.Play();
|
||||
}
|
||||
int spDictIndex2 = 14;
|
||||
DOTween.To(() => spDictIndex2, x => t.Find("Main/Boat").GetComponent<Image>().sprite = spDict[x], 0, 0.4f);
|
||||
});
|
||||
ani.Play();
|
||||
//var _pred = data.list[currentSecond - 1];
|
||||
//if (_pred.StrokeCount != _d.StrokeCount)
|
||||
//{
|
||||
// //上次划桨次数和这次不一样 说明需要划桨一次
|
||||
// var spDict = GetComponent<RowerHomeScript>().spriteDict;
|
||||
// int spDictIndex = 0;
|
||||
// ani.Join(DOTween.To(() => spDictIndex, x => t.Find("Main/Boat").GetComponent<Image>().sprite = spDict[x], 14, 0.2f));
|
||||
// ani.AppendCallback(() =>
|
||||
// {
|
||||
// int spDictIndex2 = 14;
|
||||
// DOTween.To(() => spDictIndex2, x => t.Find("Main/Boat").GetComponent<Image>().sprite = spDict[x], 0, 0.4f);
|
||||
// });
|
||||
// ani.Play();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -432,7 +441,17 @@ public class RowerMultiModeScript : MonoBehaviour
|
||||
|
||||
if (diff.diff != 0)
|
||||
{
|
||||
sq.Join(t.parent.DOLocalMoveY(-47 * (diff.rank - 1) - 21.5f, 0.9f).SetEase(Ease.OutBounce));
|
||||
//if (diff.diff > 0)
|
||||
//{
|
||||
// t.parent.SetAsLastSibling();
|
||||
//}
|
||||
sq.Join(t.parent.DOLocalMoveY(-47 * (diff.rank - 1) - 21.5f, 0.9f));
|
||||
var sq1 = DOTween.Sequence();
|
||||
sq1.Append(t.GetComponent<CanvasGroup>().DOFade(0.2f, 0.45f));
|
||||
sq1.Append(t.GetComponent<CanvasGroup>().DOFade(1f, 0.45f));
|
||||
//sq1.SetEase(Ease.InOutCubic);
|
||||
sq.Join(sq1);
|
||||
sq.SetEase(Ease.InOutCubic);
|
||||
//sq.Append(t.GetComponent)
|
||||
}
|
||||
t.parent.name = i.ToString();
|
||||
@@ -701,12 +720,12 @@ public class RowerMultiModeScript : MonoBehaviour
|
||||
{
|
||||
game.transform.Find("Content/Rank").GetComponent<Text>().text = item.currentRank.ToString("00");
|
||||
game.transform.Find("Content/NickName").GetComponent<Text>().text = item.NickName;
|
||||
Utils.DisplayImageTempDict(game.transform.Find("Content/Avatar").GetComponent<RawImage>(), item.Avatar, caches);
|
||||
var _c = countryList.FirstOrDefault(x => item.Country == x.country);
|
||||
if (_c != null)
|
||||
{
|
||||
game.transform.Find("Content/Country").GetComponent<Image>().sprite = Resources.Load<Sprite>(_c.source);
|
||||
}
|
||||
//Utils.DisplayImageTempDict(game.transform.Find("Content/Avatar").GetComponent<RawImage>(), item.Avatar, caches);
|
||||
//var _c = countryList.FirstOrDefault(x => item.Country == x.country);
|
||||
//if (_c != null)
|
||||
//{
|
||||
// game.transform.Find("Content/Country").GetComponent<Image>().sprite = Resources.Load<Sprite>(_c.source);
|
||||
//}
|
||||
int _d = 0, _p = 0;
|
||||
if (currentSecond < 0 || item.list.Count == 0)
|
||||
{
|
||||
@@ -955,6 +974,7 @@ public class RowerMultiModeScript : MonoBehaviour
|
||||
void Update()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
//return;
|
||||
timer -= Time.deltaTime;
|
||||
if (timer < 0)
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ using System;
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Threading;
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
|
||||
public class UIManager : MonoBehaviour
|
||||
{
|
||||
@@ -269,7 +270,7 @@ public class UIManager : MonoBehaviour
|
||||
return this.GetPanelInstance("RowerPanel", ref this.mRowerHomeScript);
|
||||
}
|
||||
}
|
||||
public static void ShowRowerPanel()
|
||||
public static void ShowRowerPanel(RowerResultModel r = null)
|
||||
{
|
||||
App.IsRowerMode = true;
|
||||
// App.MainDeviceAdapter.ClearDevice();
|
||||
@@ -279,6 +280,7 @@ public class UIManager : MonoBehaviour
|
||||
stack.Clear();
|
||||
UIManager.Instance.MainPanel.GetComponent<Image>().sprite =
|
||||
Resources.Load<Sprite>("Images/RowerNew/bg_huachuanji");
|
||||
UIManager.Instance.RowerHomeScript.ReRow(r);
|
||||
UIManager.Show(UIManager.Instance.RowerHomeScript, UIManager.Instance.MainPanel);
|
||||
}
|
||||
//结束页
|
||||
@@ -327,6 +329,14 @@ public class UIManager : MonoBehaviour
|
||||
public static void ShowRowerSelector()
|
||||
{
|
||||
Debug.Log("进入Rower");
|
||||
foreach (var d in App.MainDeviceAdapter.GetDevices())
|
||||
{
|
||||
if (d.State == DeviceState.Connected || d.State == DeviceState.Connecting)// && (d.Sensor == SensorType.Trainer || d.Sensor == SensorType.Rower || d.Sensor == SensorType.HeartRate)
|
||||
{
|
||||
d.Disconnect();
|
||||
}
|
||||
}
|
||||
App.MainDeviceAdapter.StopScan();
|
||||
UIManager.Show(UIManager.Instance.RowerSelector, null, true);
|
||||
}
|
||||
/*划船机页面*/
|
||||
@@ -341,6 +351,7 @@ public class UIManager : MonoBehaviour
|
||||
}
|
||||
public static void ShowRowerDevicePanel()
|
||||
{
|
||||
//App.MainDeviceAdapter.StartScan();
|
||||
UIManager.Show(UIManager.Instance.RowerDevicePanel, null, true);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user