修改断线重连自动开始问题

This commit is contained in:
Caiyanpeng committed 2022-06-07 11:32:23 +08:00
1 parent bfc56dded5
commit ff878d5d50
9 files changed
+193 -182

No files matched your search

+1 -1
View File
@@ -235,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/";
@@ -155,7 +155,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
/// 平均划桨频率
/// </summary>
public int AverageStrokeRate { get; set; } = 0;
private UInt32 _totalDistance = 0;
private UInt32 _totalDistance = 1;
public UInt32 TotalDistance
{
get => _totalDistance;
@@ -25,7 +25,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
/// </summary>
public int AverageStrokeRate { get; set; } = 0;
private UInt32 _totalDistance = 0;
private UInt32 _totalDistance = 1;
public UInt32 TotalDistance
{
get => _totalDistance;
@@ -113,6 +113,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
return this.Flags.HasFlag(RowerDataFlag.MoreData);
}
}
private string[] deviceNamePool = new string[] {"Think","PF" };
public void HandleAttributeReceived(byte[] data)
{
@@ -127,7 +128,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
//}
var output = "";
output += "收到消息:" + string.Join(",", data);
Debug.Log(output);
this.Flags = (RowerDataFlag)BitConverter.ToUInt16(data, 0);
int b = 2;
if (!this.MoreDataFlag)
@@ -191,7 +192,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
{
this.commonRes = BitConvertHelper.ToInt16(data, b);
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
if (device != null && !device.Name.Contains("Think") && RowerResChanged != null)
if (device != null && deviceNamePool.FirstOrDefault(x => device.Name.ToLower().Contains(x.ToLower())) == null && RowerResChanged != null)
{
RowerResChanged.Invoke(this.commonRes, null);
}
@@ -230,7 +231,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
{
this.thinkRes = BitConvertHelper.ToInt16(data, b + 1);
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
if (device != null && device.Name.Contains("Think") && RowerResChanged != null)
if (device != null && deviceNamePool.FirstOrDefault(x=>device.Name.ToLower().Contains(x.ToLower()))!=null && RowerResChanged != null)
{
RowerResChanged.Invoke(this.thinkRes, null);
}
@@ -263,6 +264,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
}
//Debug.Log("拉力:" + string.Join(",",list));
}
//Debug.Log(output);
}
List<ushort> pullList;
public void Reset()
@@ -53,6 +53,7 @@ namespace Assets.Scripts.Devices.Ble.Devices
Debug.Log("中控台获取");
this.controlPointCharacteristic = character;
C2RowerData.IsEnabled = false;
Reset();
}
else if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
{
@@ -609,10 +609,10 @@ public class RowerHomeScript : PFUIPanel
{
Rower.Reset();
}
if (RowerData != null)
{
RowerData.Reset();
}
//if (RowerData != null)
//{
// RowerData.Reset();
//}
GetComponent<RowerMultiModeScript>().GetShadowList(rowerType, reRowData);
btnStart.tag = "Start";
btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
@@ -996,6 +996,10 @@ public class RowerHomeScript : PFUIPanel
{
Helper.DelectDir(dir);
UIManager.CloseConfirm();
if (Rower != null)
{
Rower.Reset();
}
});
}
else
@@ -1051,6 +1055,10 @@ public class RowerHomeScript : PFUIPanel
{
Helper.DelectDir(dir);
UIManager.CloseConfirm();
if (Rower != null)
{
Rower.Reset();
}
});
}
}
@@ -1292,7 +1300,7 @@ public class RowerHomeScript : PFUIPanel
{
isFirstReset = true;
Rower.Reset();
RowerData.Reset();
//RowerData.Reset();
}
}
if (transform.Find("Stopped").gameObject.activeInHierarchy)
@@ -464,11 +464,11 @@ public class RowerMultiModeScript : MonoBehaviour
}
}
//if(!data.isMine) diffWidth = 101;
t.Find("Left/Rank").GetComponent<Text>().text = (userList.FindIndex(x => x.UserId == data.UserId) + 1).ToString("00");
if (is0to100(diffWidth))
{
var tWidth = (diffWidth / 100f) * width;
t.Find("Main/Boat").gameObject.SetActive(true);
t.Find("Left/Rank").GetComponent<Text>().text = (userList.FindIndex(x => x.UserId == data.UserId) + 1).ToString("00");
if (isAni)
{
t.Find("Main/Boat").DOLocalMoveX(21.5f + tWidth, 0.9f);