Merge remote-tracking branch 'origin/dev_combine' into dev_release
# Conflicts: # Assets/Scenes/Test.unity # Assets/SoftMaskForUGUI-1.0.2/Samples~/Demo/Mobile.meta
This commit is contained in:
commit
bf3b0d2642
386 files changed
+26250
-66181
No files matched your search
@@ -1,60 +0,0 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis
|
||||
{
|
||||
public class RowerApi : ApiBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 上传划船记录到服务端
|
||||
/// </summary>
|
||||
/// <param name="interruptRecord"></param>
|
||||
public JsonResult<object> Add(RowerRecordModel record, List<string> fileNames)
|
||||
{
|
||||
var result = Upload("Rower/AddRecord", record, fileNames);
|
||||
var jsonResult = JsonConvert.DeserializeObject<JsonResult<object>>(result);
|
||||
return jsonResult;
|
||||
}
|
||||
|
||||
public async Task<JsonResult<List<JObject>>> GetList(int pageIndex, int pageSize)
|
||||
{
|
||||
return await GetAsync<JsonResult<List<JObject>>>($"Rower/GetList?pageIndex={pageIndex}&pageSize={pageSize}");
|
||||
}
|
||||
|
||||
public async Task<JsonResult<RowerResultModel>> GetDetail(string id)
|
||||
{
|
||||
return await GetAsync<JsonResult<RowerResultModel>>($"Rower/GetDetail?Id={id}");
|
||||
}
|
||||
|
||||
public async Task<JsonResult<RowerSegmentData>> GetSegmentDataAndRanking(string id)
|
||||
{
|
||||
return await GetAsync<JsonResult<RowerSegmentData>>($"Rower/GetSegmentDataAndRanking?Id={id}");
|
||||
}
|
||||
|
||||
public async Task<JsonResult<object>> Delete(string Id)
|
||||
{
|
||||
return await PostAsync<JsonResult<object>>($"Rower/Delete",new { Id});
|
||||
}
|
||||
|
||||
public async Task<JsonResult<List<RowerRank>>> GetShadowList(RowerTaskPanel.RowerType rowerType)
|
||||
{
|
||||
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}");
|
||||
}
|
||||
|
||||
public async Task<JsonResult<byte[]>> GetRecordSnapShot(string id)
|
||||
{
|
||||
return await GetAsync<JsonResult<byte[]>>($"Share/GetRowerRecordSnapShot?Id={id}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41164280104edad45bc16ffa81b9ab9f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-16
@@ -41,16 +41,6 @@ public static class App
|
||||
public static double longitude { get; internal set; }
|
||||
public static string is401 { get; set; }
|
||||
public static bool FromLogin => false;
|
||||
private static bool? _IsRowerMode = null;
|
||||
public static bool? IsRowerMode
|
||||
{
|
||||
get => _IsRowerMode;
|
||||
set
|
||||
{
|
||||
PlayerPrefs.SetString("IsRowerMode",value.ToString());
|
||||
_IsRowerMode = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 场景跳转传值
|
||||
@@ -262,12 +252,7 @@ public static class App
|
||||
{
|
||||
FB.ActivateApp();
|
||||
}
|
||||
var isRower = PlayerPrefs.GetString("IsRowerMode");
|
||||
if (!string.IsNullOrEmpty(isRower))
|
||||
{
|
||||
App._IsRowerMode = bool.Parse(isRower);
|
||||
}
|
||||
//App.ChangeLanguage("en");
|
||||
|
||||
globalMessageQueue = new Queue<LinkedMessageEvent>();
|
||||
multiNotifyContent = new Queue<string>();
|
||||
adQueue = new Queue<ActivityModel>();
|
||||
|
||||
@@ -69,15 +69,6 @@ namespace Assets.Scripts
|
||||
return _mapCompetitionApi;
|
||||
}
|
||||
}
|
||||
private static RowerApi _rowerApi;
|
||||
internal static RowerApi rowerApi
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_rowerApi == null) _rowerApi = new RowerApi();
|
||||
return _rowerApi;
|
||||
}
|
||||
}
|
||||
|
||||
private static MailApi _mailApi;
|
||||
internal static MailApi mailApi
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
using Assets.Scripts.Ble.Commands;
|
||||
using Assets.Scripts.Devices.Ble.Characteristic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ant.Interfaces
|
||||
{
|
||||
interface IRowerDevice
|
||||
{
|
||||
C2RowerData c2RowerData { get; }
|
||||
FtmsRowerData rowerData { get; }
|
||||
void Reset();
|
||||
void SetResistanceLevel(ushort v);
|
||||
void C2GetStatus(byte[] bs);
|
||||
void SendCommand(RowerCommand command,int data = 0);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4094cd7dbe5f1a489e9bdf431722ddc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -110,18 +110,6 @@ namespace Assets.Scripts.Devices.Ble
|
||||
var device1 = new SpeedCadence(device.Peripheral, hwInterface);
|
||||
discoveredDevices.Add(device.Peripheral.Address, device1);
|
||||
}
|
||||
else if (device.SensorType == Ant.SensorType.Rower)
|
||||
{
|
||||
var device1 = new FtmsRower(device.Peripheral, hwInterface);
|
||||
if (discoveredDevices.ContainsKey(device.Peripheral.Address))
|
||||
{
|
||||
discoveredDevices[device.Peripheral.Address] = device1;
|
||||
}
|
||||
else
|
||||
{
|
||||
discoveredDevices.Add(device.Peripheral.Address, device1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -1,224 +0,0 @@
|
||||
using Assets.Scripts.Ble;
|
||||
using Assets.Scripts.Devices.Ble.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
{
|
||||
public class C2RowerData : ICharacteristic, IRowerCommonData
|
||||
{
|
||||
public Guid Uuid => ServiceUuids.Characteristics.C2RowerData35;
|
||||
|
||||
public Guid ServiceUuid => ServiceUuids.Characteristics.C2Service;
|
||||
|
||||
public bool IsOptional => false;
|
||||
|
||||
public static event EventHandler EnableChanged;
|
||||
public static event EventHandler RowerTypeChanged;
|
||||
private static bool _isEnabled;
|
||||
public static bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set
|
||||
{
|
||||
_isEnabled = value;
|
||||
if (EnableChanged != null)
|
||||
{
|
||||
EnableChanged(_isEnabled, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//0.1 lbs of force, max=6553.5m 单位0.1磅
|
||||
public double PeakDriveForce { get; set; }
|
||||
public double AverageDriveForce { get; set; }
|
||||
|
||||
public event EventHandler PullChanged;
|
||||
private ushort _pullValue;
|
||||
public ushort PullValue
|
||||
{
|
||||
get { return _pullValue; }
|
||||
set
|
||||
{
|
||||
_pullValue = value;
|
||||
if (this.PullChanged != null)
|
||||
{
|
||||
this.PullChanged(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool isReadyStatus { get; private set; }
|
||||
public static RowerTaskPanel.RowerType rowerType = new RowerTaskPanel.RowerType() { type = 0 ,value = 0};
|
||||
public void HandleAttributeReceived(byte[] data)
|
||||
{
|
||||
|
||||
if (data[0] == 0x35)
|
||||
{
|
||||
PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10, true);
|
||||
AverageDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 15)) / 10, true);
|
||||
StrokeCount = BitConvertHelper.ToUInt16(data, 19);
|
||||
}
|
||||
else if (data[0] == 0x3d)
|
||||
{
|
||||
if (data[2] == 0)
|
||||
{
|
||||
PullValue = 0;
|
||||
}
|
||||
//老款表头不支持
|
||||
//List<ushort> r = new List<ushort>();
|
||||
for (int i = 3; i < data.Length; i += 2)
|
||||
{
|
||||
ushort pull = Convert.ToUInt16(Math.Round(LbsToNewton(data[i], true)));
|
||||
//r.Add(pull);
|
||||
PullValue = pull;
|
||||
}
|
||||
|
||||
// Debug.Log("拉力曲线:" + string.Join(",", r));
|
||||
}
|
||||
else if (data[0] == 0x31)
|
||||
{
|
||||
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
|
||||
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
|
||||
|
||||
int status = (int)data[7];
|
||||
int value = (data[17] << 16) + (data[16] << 8) + data[15];
|
||||
|
||||
int type = 0;
|
||||
//3 里程 5 时间 1直接划船
|
||||
if (status == 3)
|
||||
{
|
||||
type = 1;
|
||||
}
|
||||
if (status == 5)
|
||||
{
|
||||
type = 2;
|
||||
value /= 100;
|
||||
}
|
||||
//如果课程发生变化
|
||||
if (status != 0 && type > 0 && ( rowerType.type != type || rowerType.value != value))
|
||||
{
|
||||
Debug.Log($"status{status}-type{type}-value{value}");
|
||||
rowerType.type = type;
|
||||
rowerType.value = value;
|
||||
RowerTypeChanged?.Invoke(this,null);
|
||||
}
|
||||
|
||||
var time = ((data[3] << 16) + (data[2] << 8) + data[1]) / 100;
|
||||
Debug.Log("划船时间" + time);
|
||||
isReadyStatus = data[9] == 0;
|
||||
var hasChanged = data[19] != ResistanceLevel;
|
||||
ResistanceLevel = data[19];
|
||||
if (RowerResChanged != null && hasChanged)
|
||||
{
|
||||
RowerResChanged.Invoke(this, null);
|
||||
}
|
||||
//isReadyStatus = data[2] == 1 || data[2] == 129;
|
||||
}
|
||||
else if (data[0] == 0x32)
|
||||
{
|
||||
InstantaneousPace = (ushort)(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 8)) / 100);
|
||||
AveragePace = (ushort)(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 10)) / 100);
|
||||
//AveragePower = BitConvertHelper.ToUInt16(data, 17);
|
||||
StrokeRate = (uint)data[6];
|
||||
}
|
||||
else if (data[0] == 0x33)
|
||||
{
|
||||
TotalEnergy = BitConvertHelper.ToUInt16(data, 7);
|
||||
AveragePower = BitConvertHelper.ToUInt16(data, 5);
|
||||
}
|
||||
else if (data[0] == 0x36)
|
||||
{
|
||||
InstantaneousPower = BitConvertHelper.ToUInt16(data, 4);
|
||||
//TotalEnergy = BitConvertHelper.ToUInt16(data, 6);
|
||||
}
|
||||
else if (data[0] == 0x39)
|
||||
{
|
||||
TrainingTime = (Convert.ToDouble(BitConvertHelper.ToUInt24(data, 5)) / 100);
|
||||
ElapsedTime = (int)TrainingTime;
|
||||
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 8)) / 10);
|
||||
CompleteEvent?.Invoke(this, null);
|
||||
}
|
||||
Debug.Log("数据" + string.Join(",", data) + $" | {ElapsedTime}-{TotalDistance}");
|
||||
//else if (data[0] == 34)
|
||||
//{
|
||||
// isReadyStatus = data[2] == 1 || data[2] == 129;
|
||||
//}
|
||||
}
|
||||
public event EventHandler StartEvent;
|
||||
public event EventHandler CompleteEvent;
|
||||
private double LbsToNewton(double lbs,bool isKg = false) => 4.4482216 * lbs * (isKg ? (1f / 9.8f) : 1f);
|
||||
public void SetUnavailable()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 划桨频率
|
||||
/// </summary>
|
||||
public uint StrokeRate { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 划桨次数
|
||||
/// </summary>
|
||||
public UInt16 StrokeCount { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 平均划桨频率
|
||||
/// </summary>
|
||||
public int AverageStrokeRate { get; set; } = 0;
|
||||
private UInt32 _totalDistance = 1;
|
||||
public UInt32 TotalDistance
|
||||
{
|
||||
get => _totalDistance;
|
||||
set
|
||||
{
|
||||
if (_totalDistance == 0 && value != 0 && StartEvent != null)
|
||||
{
|
||||
StartEvent.Invoke(this, null);
|
||||
}
|
||||
_totalDistance = value;
|
||||
}
|
||||
}
|
||||
//private UInt16 _instantaneousPace = 0;
|
||||
/// <summary>
|
||||
/// 即时配速
|
||||
/// </summary>
|
||||
public UInt16 InstantaneousPace { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 平均配速
|
||||
/// </summary>
|
||||
public UInt16 AveragePace { get; set; } = 0;
|
||||
|
||||
public int InstantaneousPower { get; set; } = 0;
|
||||
|
||||
public int AveragePower { get; set; } = 0;
|
||||
public int ElapsedTime { get; set; } = 0;
|
||||
public double TrainingTime { get; set; } = 0;
|
||||
public int TotalEnergy { get; set; } = 0;
|
||||
public int EnergyPerHour { get; set; } = 0;
|
||||
public int EnergyPerMinute { get; set; } = 0;
|
||||
public event EventHandler RowerResChanged;
|
||||
public int ResistanceLevel { get; set; } = 0;
|
||||
public void Reset()
|
||||
{
|
||||
this.StrokeRate = 0;
|
||||
this.StrokeCount = 0;
|
||||
this.AverageStrokeRate = 0;
|
||||
this.TotalDistance = 0;
|
||||
this.InstantaneousPace = 0;
|
||||
this.AveragePace = 0;
|
||||
this.InstantaneousPower = 0;
|
||||
this.AveragePower = 0;
|
||||
this.ResistanceLevel = 0;
|
||||
this.TotalEnergy = 0;
|
||||
this.EnergyPerHour = 0;
|
||||
this.EnergyPerMinute = 0;
|
||||
this.ElapsedTime = 0;
|
||||
this.TrainingTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64ae3a6d26480b04c8fed17cc833d179
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,435 +0,0 @@
|
||||
using Assets.Scripts.Ble;
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
using Assets.Scripts.Devices.Ble.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Characteristic
|
||||
{
|
||||
public class FtmsRowerData : ICharacteristic, IRowerCommonData
|
||||
{
|
||||
/// <summary>
|
||||
/// 划桨频率
|
||||
/// </summary>
|
||||
public uint StrokeRate { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 划桨次数
|
||||
/// </summary>
|
||||
public UInt16 StrokeCount { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 平均划桨频率
|
||||
/// </summary>
|
||||
public int AverageStrokeRate { get; set; } = 0;
|
||||
|
||||
private UInt32 _totalDistance = 1;
|
||||
public UInt32 TotalDistance
|
||||
{
|
||||
get => _totalDistance;
|
||||
set
|
||||
{
|
||||
if (_totalDistance == 0 && value != 0 && StartEvent != null)
|
||||
{
|
||||
StartEvent.Invoke(this, null);
|
||||
}
|
||||
_totalDistance = value;
|
||||
}
|
||||
}
|
||||
//private UInt16 _instantaneousPace = 1;
|
||||
/// <summary>
|
||||
/// 即时配速
|
||||
/// </summary>
|
||||
public UInt16 InstantaneousPace { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 平均配速
|
||||
/// </summary>
|
||||
public UInt16 AveragePace { get; set; } = 0;
|
||||
|
||||
public int InstantaneousPower { get; set; } = 0;
|
||||
|
||||
public int AveragePower { get; set; } = 0;
|
||||
public event EventHandler RowerResChanged;
|
||||
private int commonRes = 50;
|
||||
private int thinkRes = 50;
|
||||
|
||||
public int ResistanceLevel
|
||||
{
|
||||
get
|
||||
{
|
||||
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
|
||||
if (device == null) return 0;
|
||||
if (device.Name.Contains("Think") || device.Name.Contains("PF"))
|
||||
{
|
||||
return thinkRes;
|
||||
}
|
||||
else
|
||||
{
|
||||
return commonRes;
|
||||
}
|
||||
}
|
||||
set { }
|
||||
}
|
||||
/// <summary>
|
||||
/// 运行时间
|
||||
/// </summary>
|
||||
public int ElapsedTime { get; set; } = 0;
|
||||
public double TrainingTime { get; set; } = 0;
|
||||
public int TotalEnergy { get; set; } = 0;
|
||||
public int EnergyPerHour { get; set; } = 0;
|
||||
public int EnergyPerMinute { get; set; } = 0;
|
||||
public double PeakDriveForce { get; set; } = 0;
|
||||
public double AverageDriveForce { get; set; } = 0;
|
||||
|
||||
public Guid Uuid => ServiceUuids.Characteristics.RowerData;
|
||||
|
||||
public Guid ServiceUuid => ServiceUuids.Get(ServiceUuids.Ftms).IdGuid;
|
||||
|
||||
public bool IsOptional => false;
|
||||
|
||||
public RowerDataFlag Flags;
|
||||
//拉力相关
|
||||
public event EventHandler PullChanged;
|
||||
//开始事件
|
||||
public event EventHandler StartEvent;
|
||||
//结束事件
|
||||
public event EventHandler CompleteEvent;
|
||||
//日志事件
|
||||
public event EventHandler LogEvent;
|
||||
private ushort _pullValue;
|
||||
public ushort PullValue
|
||||
{
|
||||
get { return _pullValue; }
|
||||
set
|
||||
{
|
||||
_pullValue = value;
|
||||
if (this.PullChanged != null)
|
||||
{
|
||||
this.PullChanged(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool MoreDataFlag
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Flags.HasFlag(RowerDataFlag.MoreData);
|
||||
}
|
||||
}
|
||||
private string[] deviceNamePool = new string[] {"Think","PF" };
|
||||
private List<ushort> tempPullList = new List<ushort>();
|
||||
|
||||
public void HandleAttributeReceived(byte[] data)
|
||||
{
|
||||
if (data == null || data.Length < 2)
|
||||
{
|
||||
throw new ArgumentException("数据异常" + string.Join(",", data));
|
||||
}
|
||||
//throw new NotImplementedException();
|
||||
//if(data[0] == 1)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
var output = "";
|
||||
output += "收到消息:" + string.Join(",", data);
|
||||
|
||||
this.Flags = (RowerDataFlag)BitConverter.ToUInt16(data, 0);
|
||||
int b = 2;
|
||||
if (!this.MoreDataFlag)
|
||||
{
|
||||
//this.instantSpeed = new double?((double)BitConverter.ToUInt16(data, (int)b) * 0.01);
|
||||
this.StrokeRate = (uint)Math.Round(BitConvertHelper.ToUInt8(data, b) / 2d);
|
||||
b += 1;
|
||||
this.StrokeCount = BitConvertHelper.ToUInt16(data, b);
|
||||
b += 2;
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.MoreData);
|
||||
}
|
||||
//平均浆频
|
||||
if (this.Flags.HasFlag(RowerDataFlag.AverageStrokeRate))
|
||||
{
|
||||
var vvv = BitConvertHelper.ToUInt8(data, (int)b) / 2;
|
||||
//Debug.WriteLine($"平均浆频:{ vvv }");
|
||||
output += $" 平均浆频:{ vvv }";
|
||||
this.AverageStrokeRate = vvv;
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.AverageStrokeRate);
|
||||
|
||||
//output += $" 次数:{ BitConvertHelper.ToUInt16(data, b) }";
|
||||
//b += 3;
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.TotalDistance))
|
||||
{
|
||||
var vvv = BitConvertHelper.ToUInt24(data, (int)b);
|
||||
output += $" 总距离{ vvv }米";
|
||||
if (vvv < 10)
|
||||
{
|
||||
LogEvent?.Invoke(DateTime.Now.ToString() + ":" + output,null);
|
||||
//App.cacheList.Add(DateTime.Now.ToString() + ":" + output);
|
||||
}
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.TotalDistance);
|
||||
|
||||
this.TotalDistance = vvv;
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.InstantaneousPace))
|
||||
{
|
||||
//this.InstantCadence = new int?((int)(BitConvertHelper.ToUInt16(data, (int)b) / 2));
|
||||
this.InstantaneousPace = BitConvertHelper.ToUInt16(data, b);
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.InstantaneousPace);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.AveragePace))
|
||||
{
|
||||
this.AveragePace = BitConvertHelper.ToUInt16(data, b);
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.AveragePace);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.InstantPower))
|
||||
{
|
||||
var power = new int?((int)BitConvertHelper.ToInt16(data, (int)b));
|
||||
output += $" 功率:{ power }";
|
||||
this.InstantaneousPower = power.GetValueOrDefault(0);
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.InstantPower);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.AveragePower))
|
||||
{
|
||||
//var power = new int?((int)BitConverter.ToInt16(data, (int)b));
|
||||
this.AveragePower = BitConvertHelper.ToInt16(data, b);
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.AveragePower);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.ResistanceLevel))
|
||||
{
|
||||
var newRes = BitConvertHelper.ToInt16(data, b);
|
||||
var resChanged = newRes != this.commonRes;
|
||||
this.commonRes = newRes;
|
||||
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
|
||||
if (resChanged && device != null && deviceNamePool.FirstOrDefault(x => device.Name.ToLower().Contains(x.ToLower())) == null && RowerResChanged != null)
|
||||
{
|
||||
RowerResChanged.Invoke(this, null);
|
||||
}
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.ResistanceLevel);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.ExpendedEnergy))
|
||||
{
|
||||
this.TotalEnergy = BitConvertHelper.ToInt16(data, b);
|
||||
b += 2;
|
||||
this.EnergyPerHour = BitConvertHelper.ToInt16(data, b);
|
||||
b += 2;
|
||||
this.EnergyPerMinute = data[b];
|
||||
b += 1;
|
||||
//b += this.SizeOfDataForFlag(RowerDataFlag.ExpendedEnergy);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.HeartRate))
|
||||
{
|
||||
//this.HeartRate = new int?((int)BitConverter.ToUInt8(data, (int)b));
|
||||
//(int)data[(int)b];
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.HeartRate);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.MetabolicEquivalent))
|
||||
{
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.MetabolicEquivalent);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.ElapsedTime))
|
||||
{
|
||||
this.ElapsedTime = BitConvertHelper.ToInt16(data, b);
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.ElapsedTime);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.RemainingTime))
|
||||
{
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.RemainingTime);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.ThinkDragFactor))
|
||||
{
|
||||
var originRes = BitConvertHelper.ToInt16(data, b + 1);
|
||||
var thinkResChanged = originRes != this.thinkRes;
|
||||
this.thinkRes = BitConvertHelper.ToInt16(data, b + 1);
|
||||
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
|
||||
if (thinkResChanged && device != null && deviceNamePool.FirstOrDefault(x=>device.Name.ToLower().Contains(x.ToLower()))!=null && RowerResChanged != null)
|
||||
{
|
||||
RowerResChanged.Invoke(this, null);
|
||||
}
|
||||
b += this.SizeOfDataForFlag(RowerDataFlag.ThinkDragFactor);
|
||||
}
|
||||
if (this.Flags.HasFlag(RowerDataFlag.Pull))
|
||||
{
|
||||
for (int pullB = 4; pullB < data.Length; pullB += 2)
|
||||
{
|
||||
var val = BitConverter.ToUInt16(data, pullB);
|
||||
val = Convert.ToUInt16(((double)val) /9.8f);
|
||||
tempPullList.Add(val);
|
||||
PullValue = val;
|
||||
}
|
||||
Debug.Log("拉力列表:" + string.Join(",", tempPullList));
|
||||
|
||||
if (pullList == null) pullList = new List<ushort>();
|
||||
foreach (var pull in tempPullList)
|
||||
{
|
||||
if (pull == 0)
|
||||
{
|
||||
if (pullList.Count != 0)
|
||||
{
|
||||
PeakDriveForce = pullList.Max();
|
||||
AverageDriveForce = (double)pullList.Average(x=>x);
|
||||
}
|
||||
pullList.Clear();
|
||||
}
|
||||
pullList.Add(pull);
|
||||
}
|
||||
tempPullList.Clear();
|
||||
|
||||
}
|
||||
}
|
||||
List<ushort> pullList { get; set; }
|
||||
public void Reset()
|
||||
{
|
||||
this.StrokeRate = 0;
|
||||
this.StrokeCount = 0;
|
||||
this.AverageStrokeRate = 0;
|
||||
//this.TotalDistance = 0;
|
||||
this.InstantaneousPace = 0;
|
||||
this.AveragePace = 0;
|
||||
this.InstantaneousPower = 0;
|
||||
this.AveragePower = 0;
|
||||
//this.commonRes = 50;
|
||||
//this.thinkRes = 50;
|
||||
//this.ResistanceLevel = 0;
|
||||
this.TotalEnergy = 0;
|
||||
this.EnergyPerHour = 0;
|
||||
this.EnergyPerMinute = 0;
|
||||
this.ElapsedTime = 0;
|
||||
this.TrainingTime = 0;
|
||||
}
|
||||
|
||||
public int SizeOfDataForFlag(RowerDataFlag flag)
|
||||
{
|
||||
int num = 0;
|
||||
switch (flag)
|
||||
{
|
||||
//case RowerDataFlag.MoreData:
|
||||
// break;
|
||||
case RowerDataFlag.AverageStrokeRate:
|
||||
num = 1;
|
||||
break;
|
||||
case RowerDataFlag.TotalDistance:
|
||||
num = 3;
|
||||
break;
|
||||
case RowerDataFlag.InstantaneousPace:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.AveragePace:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.InstantPower:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.AveragePower:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.ResistanceLevel:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.ExpendedEnergy:
|
||||
num = 5;
|
||||
break;
|
||||
case RowerDataFlag.HeartRate:
|
||||
num = 1;
|
||||
break;
|
||||
case RowerDataFlag.MetabolicEquivalent:
|
||||
num = 1;
|
||||
break;
|
||||
case RowerDataFlag.ElapsedTime:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.RemainingTime:
|
||||
num = 2;
|
||||
break;
|
||||
case RowerDataFlag.ThinkDragFactor:
|
||||
num = 5;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public void SetUnavailable()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
//254 0是前七字節 1 41是第二包 1 64是拉力
|
||||
[Flags]
|
||||
public enum RowerDataFlag
|
||||
{
|
||||
MoreData = 1,
|
||||
AverageStrokeRate = 2,
|
||||
TotalDistance = 4,
|
||||
InstantaneousPace = 8,
|
||||
AveragePace = 16,
|
||||
InstantPower = 32,
|
||||
AveragePower = 64,
|
||||
ResistanceLevel = 128,
|
||||
ExpendedEnergy = 256,
|
||||
HeartRate = 512,
|
||||
MetabolicEquivalent = 1024,
|
||||
ElapsedTime = 2048,
|
||||
RemainingTime = 4096,
|
||||
//单周期能耗
|
||||
SingleEnergy = 8192,
|
||||
//拉力曲綫
|
||||
Pull = 16384,
|
||||
//Think 阻力
|
||||
ThinkDragFactor = 32768
|
||||
}
|
||||
|
||||
|
||||
|
||||
private byte SizeOfDataForFlag1(RowerDataFlag flag)
|
||||
{
|
||||
if (flag <= RowerDataFlag.InstantPower)
|
||||
{
|
||||
//if (flag <= RowerDataFlag.AverageCadence)
|
||||
//{
|
||||
// if (flag - RowerDataFlag.MoreData > 1 && flag != RowerDataFlag.InstantCadence && flag != RowerDataFlag.AverageCadence)
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
{
|
||||
if (flag == RowerDataFlag.TotalDistance)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (flag != RowerDataFlag.ResistanceLevel && flag != RowerDataFlag.InstantPower)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (flag <= RowerDataFlag.HeartRate)
|
||||
{
|
||||
if (flag != RowerDataFlag.AveragePower)
|
||||
{
|
||||
if (flag == RowerDataFlag.ExpendedEnergy)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
if (flag != RowerDataFlag.HeartRate)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flag != RowerDataFlag.MetabolicEquivalent && flag != RowerDataFlag.ElapsedTime && flag != RowerDataFlag.RemainingTime)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87207b21c4f11ef4b866ac490a88620f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,9 +4,6 @@ using Assets.Scripts.Devices.Ble.Characteristic;
|
||||
using Assets.Scripts.Devices.Ble.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Devices
|
||||
@@ -17,8 +14,6 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
public int Power { get => _ftmsIndoorBikeData.InstantPower.GetValueOrDefault(0); set => throw new NotImplementedException(); }
|
||||
public double Speed { get => _ftmsIndoorBikeData.InstantSpeed.GetValueOrDefault(0); set => throw new NotImplementedException(); }
|
||||
public int Cadence { get => _ftmsIndoorBikeData.InstantCadence.GetValueOrDefault(0); set => throw new NotImplementedException(); }
|
||||
private FtmsRowerData _rowerData;
|
||||
public FtmsRowerData rowerData { get => _rowerData; }
|
||||
|
||||
private FtmsIndoorBikeData _ftmsIndoorBikeData;
|
||||
|
||||
@@ -29,9 +24,6 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
this._ftmsIndoorBikeData = new FtmsIndoorBikeData();
|
||||
base.Characteristics.Add(this._ftmsIndoorBikeData);
|
||||
base.Characteristics.Add(new FtmsFitnessMachineFeature());
|
||||
//划船机
|
||||
this._rowerData = new FtmsRowerData();
|
||||
base.Characteristics.Add(rowerData);
|
||||
bleWinHwInterface.CharacteristicReadEvent += CharacteristicReadMainCallback;
|
||||
}
|
||||
|
||||
@@ -58,17 +50,6 @@ namespace Assets.Scripts.Devices.Ble.Devices
|
||||
{
|
||||
this.controlPointCharacteristic = character;
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
{
|
||||
Debug.Log("划船机");
|
||||
this.hwInterface.SubscribeCharacteristic(character, (hw, cha, res) =>
|
||||
{
|
||||
//Debug.Log("1111111111111111111111");
|
||||
//Debug.WriteLine(res.ToString());
|
||||
var res1 = (res as BleResponse<byte[]>);
|
||||
Debug.Log("收到消息划船机:" + string.Join(",", res1));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,333 +0,0 @@
|
||||
using Assets.Scripts.Ble;
|
||||
using Assets.Scripts.Ble.Commands;
|
||||
using Assets.Scripts.Devices.Ant.Interfaces;
|
||||
using Assets.Scripts.Devices.Ble.Characteristic;
|
||||
using Assets.Scripts.Devices.Ble.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Devices
|
||||
{
|
||||
public class FtmsRower : BleDevice, IRowerDevice
|
||||
{
|
||||
private FtmsRowerData _rowerData;
|
||||
public FtmsRowerData rowerData { get => _rowerData; }
|
||||
|
||||
C2RowerData _c2RowerData;
|
||||
public C2RowerData c2RowerData { get => _c2RowerData; }
|
||||
private List<BleServiceInfo> Services;
|
||||
private BleCharacteristicInfo controlPointCharacteristic;
|
||||
private BleCharacteristicInfo c2Control { get; set; }
|
||||
|
||||
public FtmsRower(BlePeripheralInfo peripheralInfo, IBleWinHwInterface bleWinHwInterface) : base(peripheralInfo, bleWinHwInterface, Ant.SensorType.Rower)
|
||||
{
|
||||
Debug.Log(24);
|
||||
base.Characteristics.Add(new FtmsFitnessMachineFeature());
|
||||
//划船机
|
||||
this._rowerData = new FtmsRowerData();
|
||||
base.Characteristics.Add(rowerData);
|
||||
this._c2RowerData = new C2RowerData();
|
||||
base.Characteristics.Add(c2RowerData);
|
||||
bleWinHwInterface.CharacteristicReadEvent -= CharacteristicReadMainCallback;
|
||||
bleWinHwInterface.CharacteristicReadEvent += CharacteristicReadMainCallback;
|
||||
}
|
||||
|
||||
protected override void CreateServices(List<BleServiceInfo> discoveredServices)
|
||||
{
|
||||
this.Services = discoveredServices;
|
||||
Debug.Log("服务+" + string.Join(",", Services.Select(x => x.Id.ToString())));
|
||||
foreach (var service in this.Services)
|
||||
{
|
||||
hwInterface.DiscoverCharacteristic(service, (hwInterface, service1, response) =>
|
||||
{
|
||||
|
||||
foreach (var character in response.Data)
|
||||
{
|
||||
//Debug.Log(character.Id.ToString());
|
||||
if (character.MatchGuid(ServiceUuids.Characteristics.FitnessMachineControlPoint))
|
||||
{
|
||||
Debug.Log("中控台获取");
|
||||
this.controlPointCharacteristic = character;
|
||||
C2RowerData.IsEnabled = false;
|
||||
//Thread.Sleep(100);
|
||||
//Reset();
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
{
|
||||
Debug.Log("ftms划船机" + service.Id);
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData35))
|
||||
{
|
||||
Debug.Log("c2划船机基本数据" + service.Id);
|
||||
//C2RowerData.IsEnabled = true;
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData3d))
|
||||
{
|
||||
Debug.Log("c2划船机拉力数据" + service.Id);
|
||||
//C2RowerData.IsEnabled = true;
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData32))
|
||||
{
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData33))
|
||||
{
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData36))
|
||||
{
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData39))
|
||||
{
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
//else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerStatus))
|
||||
//{
|
||||
// Debug.Log("c2划船机响应数据" + service.Id);
|
||||
// //C2RowerData.IsEnabled = true;
|
||||
// this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
//}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerCourse))
|
||||
{
|
||||
Debug.Log("c2划船机课程数据" + service.Id);
|
||||
C2RowerData.IsEnabled = true;
|
||||
this.hwInterface.SubscribeCharacteristic(character, null);
|
||||
}
|
||||
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerControl))
|
||||
{
|
||||
Debug.Log($"c2划船机控制台{character.Id}");
|
||||
this.c2Control = character;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void CharacteristicReadMainCallback(IBleWinHwInterface hwInterface, BleCharacteristicInfo characteristic, BleResponse<byte[]> response)
|
||||
{
|
||||
|
||||
//var tc = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.C2RowerData);
|
||||
//tc.HandleAttributeReceived(new byte[] { 61, 89, 0, 0, 0, 33, 0, 33, 0, 46, 0, 46, 0, 53, 0, 60, 0, 60, 0, 68, 0, 68, 0, 0, 0 });
|
||||
//tc.HandleAttributeReceived(new byte[] { 53, 223, 211, 0, 162, 57, 0, 82, 62, 96, 0, 94, 2, 183, 3, 125, 2, 208, 7, 203, 0 });
|
||||
if (characteristic.MatchGuid(ServiceUuids.Characteristics.RowerData))
|
||||
{
|
||||
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.RowerData);
|
||||
if (c != null && !C2RowerData.IsEnabled)
|
||||
{
|
||||
c.HandleAttributeReceived(response.Data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.C2RowerData35);
|
||||
if (c != null)
|
||||
{
|
||||
var data = new byte[] { characteristic.Id.ToByteArray()[0] }.Concat(response.Data).ToArray();
|
||||
c.HandleAttributeReceived(data);
|
||||
}
|
||||
}
|
||||
//foreach (var item in base.Characteristics)
|
||||
//{
|
||||
// if (characteristic.MatchGuid(item.Uuid) || characteristic.Id == ServiceUuids.Characteristics.C2RowerData1)
|
||||
// {
|
||||
// if (item.Uuid == ServiceUuids.Characteristics.C2RowerData1)
|
||||
// {
|
||||
// Debug.Log("c2");
|
||||
// var data = new byte[] { item.Uuid.ToByteArray()[0] }.Concat(response.Data).ToArray();
|
||||
// item.HandleAttributeReceived(data);
|
||||
// }
|
||||
// else if (item.Uuid == ServiceUuids.Characteristics.RowerData)
|
||||
// {
|
||||
// Debug.Log("ftms");
|
||||
// item.HandleAttributeReceived(response.Data);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
public void C2GetStatus(byte[] bs)
|
||||
{
|
||||
if (C2RowerData.IsEnabled == true)
|
||||
{
|
||||
//等对csafe协议研究透彻后写
|
||||
if (this.c2Control != null)
|
||||
{
|
||||
var cmd = bs;
|
||||
byte a = cmd[0];
|
||||
for (int i = 1; i < cmd.Length; i++)
|
||||
{
|
||||
a ^= cmd[i];
|
||||
}
|
||||
cmd = new byte[] { 0xf1 }.Concat(cmd).Concat(new byte[] { a, 0xf2 }).ToArray();
|
||||
Debug.Log("发送获取命令" + string.Join(",", cmd));
|
||||
hwInterface.WriteCharacteristic(this.c2Control, cmd);
|
||||
//hwInterface.WriteCharacteristic(this.c2Control, new byte[] { 0xF1, 0x81, 0x81, 0xF2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SendCommand(RowerCommand command,int data = 0)
|
||||
{
|
||||
if (!C2RowerData.IsEnabled)
|
||||
return;
|
||||
switch (command)
|
||||
{
|
||||
case RowerCommand.JustRow:
|
||||
SetJustRow();
|
||||
break;
|
||||
case RowerCommand.FixedDistance:
|
||||
SetFixedDistance(data);
|
||||
break;
|
||||
case RowerCommand.FixedTime:
|
||||
SetFixedTime(data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (C2RowerData.IsEnabled == true)
|
||||
{
|
||||
////等对csafe协议研究透彻后写
|
||||
//if (this.c2Control != null)
|
||||
//{
|
||||
// Debug.Log("发送重置命令" + this.c2Control.ToString());
|
||||
// hwInterface.WriteCharacteristic(this.c2Control, new byte[] { 0xF1, 0x80, 0x80, 0xF2 });
|
||||
// //hwInterface.WriteCharacteristic(this.c2Control, new byte[] { 0xF1, 0x81, 0x81, 0xF2 });
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="workoutType">训练类型:0,1,2(里程不分段),3(里程分段),4(时间不分段),5,6,7,8~13</param>
|
||||
public void SetWorkoutType(int workoutType)
|
||||
{
|
||||
var typeHex = workoutType.ToString("X2");
|
||||
var checkSum = "00";
|
||||
var data = BitConvertHelper.HexToByteArray($"F1 76 03 01 01 {typeHex} {checkSum} F2");//"F1 76 03 01 01 03 76 F2"//03?
|
||||
checkSum = GetChecksumHexString(data);
|
||||
data = BitConvertHelper.HexToByteArray($"F1 76 03 01 01 {typeHex} {checkSum} F2");
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
Thread.Sleep(5);
|
||||
}
|
||||
public void SetConfigureWorkout()
|
||||
{
|
||||
var data = BitConvertHelper.HexToByteArray("F1 76 03 14 01 01 61 F2"); //03?
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
Thread.Sleep(5);
|
||||
}
|
||||
public void SetScreenState()
|
||||
{
|
||||
var data = BitConvertHelper.HexToByteArray("F1 76 04 13 02 01 01 63 F2"); //04?
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
}
|
||||
public void SetPoll()
|
||||
{
|
||||
var data = BitConvertHelper.HexToByteArray($"F1 76 07 8D 93 A3 A0 A8 B3 B6 C1 F2");
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
}
|
||||
public void SetJustRow()
|
||||
{
|
||||
var data = BitConvertHelper.HexToByteArray("F1 76 07 01 01 01 13 02 01 01 61 F2");
|
||||
Debug.Log($"SetJustRow:{string.Join(",", data)}");
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
Thread.Sleep(5);
|
||||
SetScreenState();
|
||||
}
|
||||
public void SetFixedDistance(int distance)
|
||||
{
|
||||
if (distance < 100)
|
||||
return;
|
||||
|
||||
SetWorkoutType(3);
|
||||
|
||||
var hexditance = distance.ToString("X4");
|
||||
var checkSum = "00";
|
||||
var data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 80 00 00 {hexditance} {checkSum} F2");//F1 76 07 03 05 80 00 00 {hexditance} {checkSum} F2
|
||||
checkSum = GetChecksumHexString(data);
|
||||
data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 80 00 00 {hexditance} {checkSum} F2");//07?
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
Thread.Sleep(5);
|
||||
|
||||
SetConfigureWorkout();
|
||||
|
||||
SetScreenState();
|
||||
|
||||
}
|
||||
private string GetChecksumHexString(byte[] data)
|
||||
{
|
||||
var res = data[1];
|
||||
for (int i = 2; i < data.Length-2; i++)
|
||||
{
|
||||
res ^= data[i];
|
||||
}
|
||||
return res.ToString("X2");
|
||||
}
|
||||
public void SetFixedTime(int mins)
|
||||
{
|
||||
SetWorkoutType(5);
|
||||
Thread.Sleep(5);
|
||||
var timeHex = (mins * 100).ToString("X6");
|
||||
var checkNum = "00";
|
||||
var data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 00 00 {timeHex} {checkNum} F2");
|
||||
checkNum = GetChecksumHexString(data);
|
||||
data = BitConvertHelper.HexToByteArray($"F1 76 07 03 05 00 00 {timeHex} {checkNum} F2");
|
||||
hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
Thread.Sleep(5);
|
||||
SetConfigureWorkout();
|
||||
Thread.Sleep(5);
|
||||
SetScreenState();
|
||||
}
|
||||
|
||||
public void SetResistanceLevel(ushort v)
|
||||
{
|
||||
if (C2RowerData.IsEnabled == true)
|
||||
{
|
||||
////等对csafe协议研究透彻后写
|
||||
//if (this.c2Control != null)
|
||||
//{
|
||||
//02312131 = > 03010103
|
||||
//var data = new byte[] { 0x76 }.Concat(BitConverter.GetBytes(v)).ToArray();
|
||||
//byte checksum = (byte)((byte)(data[0] ^ data[1]) ^ data[2]);
|
||||
//var r = new byte[] { 0xF1 }.Concat(data).Concat(new byte[] { checksum, 0xf2 }).ToArray();
|
||||
//Debug.Log($"设置阻力{v}, {string.Join(",", r)}");
|
||||
//
|
||||
// var data = BitConvertHelper.HexToByteArray("F1 76 07 01 01 01 13 02 01 01 61 F2");
|
||||
// hwInterface.WriteCharacteristic(this.c2Control, data);
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.controlPointCharacteristic != null)
|
||||
{
|
||||
//特注:81是think专有指令,后期可能需要兼容其他设备
|
||||
var r = new byte[] { 0x81 }.Concat(BitConverter.GetBytes((ushort)(50 + v))).ToArray();
|
||||
Debug.Log($"设置阻力{v}, {string.Join(",", r)}");
|
||||
hwInterface.WriteCharacteristic(this.controlPointCharacteristic, r);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e62cf4fc3378d5c4eb76643a9d3ca528
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,52 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Devices.Ble.Interfaces
|
||||
{
|
||||
interface IRowerCommonData
|
||||
{
|
||||
event EventHandler PullChanged;
|
||||
ushort PullValue { get; set; }
|
||||
double PeakDriveForce { get; set; }
|
||||
double AverageDriveForce { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 划桨频率
|
||||
/// </summary>
|
||||
uint StrokeRate { get; set; }
|
||||
/// <summary>
|
||||
/// 划桨次数
|
||||
/// </summary>
|
||||
UInt16 StrokeCount { get; set;}
|
||||
/// <summary>
|
||||
/// 平均划桨频率
|
||||
/// </summary>
|
||||
int AverageStrokeRate { get; set; }
|
||||
UInt32 TotalDistance { get; set; }
|
||||
/// <summary>
|
||||
/// 即时配速
|
||||
/// </summary>
|
||||
UInt16 InstantaneousPace { get; set; }
|
||||
/// <summary>
|
||||
/// 平均配速
|
||||
/// </summary>
|
||||
UInt16 AveragePace { get; set; }
|
||||
int InstantaneousPower { get; set; }
|
||||
int AveragePower { get; set; }
|
||||
int ElapsedTime { get; set; }
|
||||
double TrainingTime { get; set; }
|
||||
int TotalEnergy { get; set; }
|
||||
|
||||
int EnergyPerHour { get; set; }
|
||||
|
||||
int EnergyPerMinute { get; set; }
|
||||
int ResistanceLevel { get; set; }
|
||||
void Reset();
|
||||
event EventHandler StartEvent;
|
||||
event EventHandler CompleteEvent;//结束事件
|
||||
event EventHandler RowerResChanged;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b9b93075aa03cf4587d75a49b2bfaa8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -44,10 +44,7 @@ namespace Assets.Scripts.Ble
|
||||
(byte) 24,
|
||||
(byte) 38
|
||||
};
|
||||
public static readonly byte[] C2Rower = new byte[]
|
||||
{
|
||||
(byte)206,(byte)6
|
||||
};
|
||||
|
||||
public static readonly byte[] KineticInRide = new byte[16]
|
||||
{
|
||||
(byte) 233,
|
||||
@@ -168,8 +165,7 @@ namespace Assets.Scripts.Ble
|
||||
new ServiceUuid(new Guid("6e40fec1-b5a3-f393-e0a9-e50e24dcca9e"), ServiceUuids.TacxBle, true),
|
||||
new ServiceUuid(new Guid("01007b34-3576-8b40-8918-8ff3949ce592"), ServiceUuids.Elite, true),
|
||||
new ServiceUuid(new Guid("3a01f4c0-37a8-6541-bab9-654ef70747c6"), ServiceUuids.PowerBeam, true),
|
||||
new ServiceUuid(new Guid("CE060000-43E5-11E4-916C-0800200C9A66"), ServiceUuids.C2Rower,true),
|
||||
};
|
||||
};
|
||||
public static readonly IReadOnlyList<ServiceUuid> CyclingServices = ServiceUuids.Services.Where(s => s.IsCycling).ToList();
|
||||
|
||||
public static List<string> GetServiceUuidList()
|
||||
@@ -370,26 +366,6 @@ namespace Assets.Scripts.Ble
|
||||
|
||||
// Token: 0x04002908 RID: 10504
|
||||
public static Guid WahooFitnessSensorMeasurementInput = new Guid("A026E016-0A7D-4AB3-97FA-F1500F9FEB8B");
|
||||
|
||||
public static Guid RowerData = new Guid("00002AD1-0000-1000-8000-00805F9B34FB");
|
||||
|
||||
|
||||
public static Guid C2RowerControl = new Guid("ce060021-43e5-11e4-916c-0800200c9a66");
|
||||
//0x35 有峰力值和均力值
|
||||
public static Guid C2RowerData35 = new Guid("ce060035-43e5-11e4-916c-0800200c9a66");
|
||||
//拉力曲线
|
||||
public static Guid C2RowerData3d = new Guid("ce06003D-43e5-11e4-916c-0800200c9a66");
|
||||
//c2划船机状态
|
||||
public static Guid C2RowerStatus = new Guid("ce060022-43e5-11e4-916c-0800200c9a66");
|
||||
//c2划船机课程
|
||||
public static Guid C2RowerCourse = new Guid("CE060031-43E5-11E4-916C-0800200C9A66");
|
||||
public static Guid C2RowerData32 = new Guid("CE060032-43E5-11E4-916C-0800200C9A66");
|
||||
public static Guid C2RowerData33 = new Guid("CE060033-43E5-11E4-916C-0800200C9A66");
|
||||
public static Guid C2RowerData36 = new Guid("CE060036-43E5-11E4-916C-0800200C9A66");
|
||||
public static Guid C2RowerData39 = new Guid("CE060039-43E5-11E4-916C-0800200C9A66");
|
||||
public static Guid C2Service = new Guid("CE060030-43E5-11E4-916C-0800200C9A66");
|
||||
//ce060030-43e5-11e4-916c-0800200c9a66
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -140,15 +140,6 @@ namespace Assets.Scripts.Ble
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//Debug.Log($"設備{App.IsRowerMode}信息,{item.IdGuid},{string.Join(";", item.IdByteArray)}");
|
||||
if (item.IdByteArray == ServiceUuids.Ftms || item.IdByteArray == ServiceUuids.C2Rower)
|
||||
{
|
||||
sensor = SensorType.Rower;
|
||||
//else
|
||||
//{
|
||||
// sensor = SensorType.FtmsTrainer;
|
||||
//}
|
||||
}
|
||||
else if (item.IdByteArray == ServiceUuids.HeartRate)
|
||||
{
|
||||
sensor = SensorType.HeartRate;
|
||||
@@ -156,7 +147,6 @@ namespace Assets.Scripts.Ble
|
||||
else if (item.IdByteArray == ServiceUuids.CyclingPower)
|
||||
{
|
||||
sensor = SensorType.Power;
|
||||
//sensor = SensorType.Trainer;
|
||||
}
|
||||
else if (item.IdByteArray == ServiceUuids.CyclingSpeedCadence)
|
||||
{
|
||||
@@ -185,8 +175,6 @@ namespace Assets.Scripts.Ble
|
||||
}
|
||||
pCache[addressStr].SensorType = sensor;
|
||||
pCache[addressStr].Rssi = rssi;
|
||||
//Debug.Log(sensor);
|
||||
//pCache[address.ToString()].SensorType = sensor;
|
||||
|
||||
foreach (var item in uuids)
|
||||
{
|
||||
@@ -197,7 +185,6 @@ namespace Assets.Scripts.Ble
|
||||
if (pCache[addressStr].SensorType == SensorType.Power && pCache[addressStr].Services.Any(s => s.Equals(ServiceUuids.Get(ServiceUuids.TacxBle).IdGuid)))
|
||||
{
|
||||
pCache[addressStr].SensorType = SensorType.Trainer;
|
||||
//Debug.Log("纠正为trainer, "+ pCache[address.ToString()].Index);
|
||||
}
|
||||
|
||||
|
||||
@@ -214,9 +201,6 @@ namespace Assets.Scripts.Ble
|
||||
}
|
||||
}
|
||||
|
||||
List<BleServiceInfo> servicelist = new List<BleServiceInfo>();
|
||||
List<BleCharacteristicInfo> characteristilist = new List<BleCharacteristicInfo>();
|
||||
|
||||
public void ConnectPeripheral(BlePeripheralInfo info, Action<IBleWinHwInterface, BlePeripheralInfo, BleResponse> callback)
|
||||
{
|
||||
var exsit = this.callbacks.Where(c => c.Key.Address == info.Address).Any();
|
||||
|
||||
@@ -186,9 +186,6 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
case SensorType.Trainer:
|
||||
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType && d is ITrainerDevice).ToList();
|
||||
break;
|
||||
case SensorType.Rower:
|
||||
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType && d is IRowerDevice).ToList();
|
||||
break;
|
||||
case SensorType.VirtualPower:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -181,15 +181,7 @@ public class NewMainNav : MonoBehaviour
|
||||
Utils.DisplayHead(transform.Find("Avatar").GetComponent<Image>(), App.CurrentUser.WxHeadImg);
|
||||
UIManager.AddEvent(transform.Find("Avatar").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
if (App.IsRowerMode == true)
|
||||
{
|
||||
if (UIManager.Instance.RowerHomeScript.checkRowing()) return;
|
||||
UIManager.ShowEditUserPanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
}
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
UIManager.AddEvent(transform.Find("PF").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
@@ -199,25 +191,11 @@ public class NewMainNav : MonoBehaviour
|
||||
{
|
||||
SetExpand(false);
|
||||
});
|
||||
//var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
|
||||
//var rect = ((RectTransform)this.transform).rect;
|
||||
//material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
//this.GetComponent<Image>().material = material;
|
||||
|
||||
var device = this.transform.Find("Device");
|
||||
UIManager.AddEvent(device.gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
//Debug.Log("click device");
|
||||
if (App.IsRowerMode.HasValue && App.IsRowerMode.Value)
|
||||
{
|
||||
if (UIManager.Instance.RowerHomeScript.checkRowing()) return;
|
||||
UIManager.ShowRowerDevicePanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.ShowDevicePanel();
|
||||
}
|
||||
UIManager.ShowDevicePanel();
|
||||
});
|
||||
|
||||
home = this.transform.Find("Home").gameObject;
|
||||
|
||||
@@ -190,7 +190,6 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
|
||||
mYearDropdown.AddOptions(years);
|
||||
mYearDropdown.OnValueChange = (index) =>
|
||||
{
|
||||
//Debug.Log(index);
|
||||
SetDayDropdown();
|
||||
};
|
||||
|
||||
@@ -201,7 +200,7 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
|
||||
months.Add(i.ToString());
|
||||
}
|
||||
mMonthDropdown.AddOptions(months);
|
||||
//mMonthDropdown.SelectValue("9");
|
||||
|
||||
mMonthDropdown.OnValueChange = (index) =>
|
||||
{
|
||||
SetDayDropdown();
|
||||
@@ -210,12 +209,6 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
|
||||
mDayDropdown.ClearOptions();
|
||||
SetDayDropdown();
|
||||
|
||||
//mDayDropdown.AddOptions()
|
||||
|
||||
//mDayDropdown.AddOptions(new List<Dropdown.OptionData>
|
||||
//{
|
||||
// new Dropdown.OptionData()
|
||||
//});
|
||||
dict = new Dictionary<string, Selectable>
|
||||
{
|
||||
{"NickName",mNickName.GetComponent<InputField>() },
|
||||
@@ -229,13 +222,6 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
|
||||
{"ContactPhone",mPhone.GetComponent<InputField>() },
|
||||
{"ContactAddress",mAddr.GetComponent<InputField>() },
|
||||
};
|
||||
#region 划船机功能:隐藏骑行相关的
|
||||
if (App.IsRowerMode == true)
|
||||
{
|
||||
transform.Find("Panel/MainPanel/BW").gameObject.SetActive(false);
|
||||
transform.Find("Panel/MainPanel/WD").gameObject.SetActive(false);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
async Task Login()
|
||||
{
|
||||
|
||||
@@ -94,13 +94,6 @@ public class HomeController : PFUIPanel
|
||||
UIManager.ShowUserInfoPanel();
|
||||
//UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", null);
|
||||
});
|
||||
if (transform.Find("Other/BtnRower"))
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("Other/BtnRower").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowRowerPanel();
|
||||
});
|
||||
}
|
||||
|
||||
//GetSummary();
|
||||
dict = new Dictionary<string, Sprite[]>
|
||||
|
||||
@@ -582,11 +582,5 @@ public class MapListController : PFUIPanel
|
||||
{
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
Debug.Log("list empty");
|
||||
}
|
||||
protected override void OnDisable()
|
||||
{
|
||||
App.CurrentRouteType = "";
|
||||
}
|
||||
}
|
||||
@@ -100,13 +100,6 @@ public class NewHomeController : PFUIPanel
|
||||
UIManager.ShowUserInfoPanel();
|
||||
//UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", null);
|
||||
});
|
||||
if (transform.Find("Other/BtnRower"))
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("Other/BtnRower").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowRowerPanel();
|
||||
});
|
||||
}
|
||||
|
||||
//GetSummary();
|
||||
dict = new Dictionary<string, Sprite[]>
|
||||
|
||||
@@ -214,7 +214,7 @@ public class NewRouteOverviewController: PFUIPanel
|
||||
/// </summary>
|
||||
void ToList(string type)
|
||||
{
|
||||
App.CurrentRouteType = type;// "";
|
||||
App.CurrentRouteType = type;
|
||||
UIManager.ShowMapListPanel();
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 406120aa4593dd340844428cea64a7bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,7 +18,7 @@ public class ResultListController : PFUIPanel
|
||||
Transform scrollContent;
|
||||
Transform routeScroll, matchScroll, rowerScroll;
|
||||
Transform routeContent, matchContent, rowerContent;
|
||||
Transform btnRoute, btnMatch ,btnRower, searchInput;
|
||||
Transform btnRoute, btnMatch , searchInput;
|
||||
Color c1, c2;
|
||||
// Start is called before the first frame update
|
||||
int pageSize = 20;
|
||||
@@ -46,7 +46,6 @@ public class ResultListController : PFUIPanel
|
||||
scroll = transform.Find("ListPanel").Find("Scroll").GetComponent<ScrollRect>();
|
||||
btnMatch = transform.Find("ListPanel").Find("BtnMatch");
|
||||
btnRoute = transform.Find("ListPanel").Find("BtnRoute");
|
||||
btnRower = transform.Find("ListPanel").Find("BtnRower");
|
||||
searchInput = transform.Find("ListPanel").Find("SearchInput");
|
||||
scrollContent = scroll.transform.Find("Viewport").Find("Content");
|
||||
routeScroll = scrollContent.Find("RouteList");
|
||||
@@ -76,14 +75,7 @@ public class ResultListController : PFUIPanel
|
||||
});
|
||||
//btnMatch.GetComponent<Button>().onClick.AddListener(() => StartScroll(0));
|
||||
}
|
||||
if (btnRower != null)
|
||||
{
|
||||
UIManager.AddEvent(btnRower.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
StartScroll(2);
|
||||
});
|
||||
}
|
||||
btns = new Transform[] { btnRoute,btnMatch,btnRower };
|
||||
btns = new Transform[] { btnRoute,btnMatch };
|
||||
if (searchInput != null)
|
||||
{
|
||||
UIManager.AddEvent(searchInput.Find("Button").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
@@ -119,20 +111,6 @@ public class ResultListController : PFUIPanel
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
GetList(2);
|
||||
#endif
|
||||
btnRower.gameObject.SetActive(false);
|
||||
// #region 划船机功能:隐藏骑行记录
|
||||
//#if UNITY_ANDROID || UNITY_IOS
|
||||
// btnRower.transform.localPosition = new Vector3(btnRower.transform.localPosition.x, btnRoute.transform.localPosition.y, btnRower.transform.localPosition.z);
|
||||
// btnRoute.gameObject.SetActive(false);
|
||||
// btnMatch.gameObject.SetActive(false);
|
||||
// transform.Find("ListPanel/Line").gameObject.SetActive(false);
|
||||
// transform.Find("ListPanel/Line2").gameObject.SetActive(false);
|
||||
// StartScroll(2);
|
||||
// //scrollContent.localPosition = new Vector3(674 * -2, scrollContent.localPosition.y, scrollContent.localPosition.z);//.DOLocalMoveX(674 * index * -1, 0.3f);
|
||||
// //btnRower.GetComponent<Text>().color = Utils.HexToColor("#ffffff");
|
||||
//#endif
|
||||
// #endregion
|
||||
|
||||
}
|
||||
|
||||
public void Load()
|
||||
@@ -211,10 +189,7 @@ public class ResultListController : PFUIPanel
|
||||
{
|
||||
r = await ConfigHelper.mapInterruptRecordApi.GetMapInterruptRecord(name, pageIndex[index], 20, filterOptionDict[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = await ConfigHelper.rowerApi.GetList(pageIndex[index], 20);
|
||||
}
|
||||
|
||||
if (r.result)
|
||||
{
|
||||
if (r.data.Count == 0)
|
||||
@@ -375,7 +350,5 @@ public class ResultListController : PFUIPanel
|
||||
{
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
Debug.Log("list empty");
|
||||
}
|
||||
}
|
||||
@@ -139,18 +139,6 @@ public class RouteItem : MonoBehaviour
|
||||
//UIManager.ShowRowerResult(result.Id);
|
||||
});
|
||||
}
|
||||
btnReRide = right.Find("BtnRide");
|
||||
if (btnReRide)
|
||||
{
|
||||
UIManager.AddEvent(btnReRide.gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowConfirm("Re-Rowing", "Rowing again?", () =>
|
||||
{
|
||||
UIManager.CloseConfirm();
|
||||
UIManager.ShowRowerPanel(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
//UIManager.AddEvent(transform.gameObject, EventTriggerType.PointerClick, b => UIManager.ShowRowerResult(result.Id));
|
||||
}
|
||||
@@ -270,10 +258,6 @@ public class RouteItem : MonoBehaviour
|
||||
{
|
||||
r = await ConfigHelper.mapApi.DeleteRecord(routeResult.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = await ConfigHelper.rowerApi.Delete(rowerResult.Id);
|
||||
}
|
||||
UIManager.CloseConfirm();
|
||||
if (r.result)
|
||||
{
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 879e9656cc32a33448968cc1f71e5e10
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,83 +0,0 @@
|
||||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RowerAnimation : PFUIPanel
|
||||
{
|
||||
List<Sprite> sprites;
|
||||
Image image;
|
||||
public bool isFinish = false;
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
sprites = new List<Sprite>();
|
||||
for (int i = 1; i <= 30; i++)
|
||||
{
|
||||
sprites.Add(Resources.Load<Sprite>($"Images/Rower/序列帧/划船机{i.ToString("0000")}"));
|
||||
}
|
||||
image = transform.GetComponent<Image>();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
|
||||
//time = 0;
|
||||
|
||||
}
|
||||
int index = 0;
|
||||
//float time = 0;
|
||||
public override void Show()
|
||||
{
|
||||
//base.Show();
|
||||
|
||||
//index = 0;
|
||||
////time = 0;
|
||||
|
||||
//StartCoroutine(Animation());
|
||||
}
|
||||
public void StartAnimation()
|
||||
{
|
||||
index = 0;
|
||||
isFinish = false;
|
||||
StartCoroutine(Animation());
|
||||
}
|
||||
|
||||
IEnumerator Animation()
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
image.sprite = sprites[i];
|
||||
yield return new WaitForSeconds(0.02666f);
|
||||
}
|
||||
for (int i = 15; i < 30; i++)
|
||||
{
|
||||
image.sprite = sprites[i];
|
||||
yield return new WaitForSeconds(0.05333f);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
//time += Time.deltaTime;
|
||||
//if (time < 0.03)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//time = 0;
|
||||
//if (index % 79 == 0)
|
||||
//{
|
||||
// index = 0;
|
||||
//}
|
||||
//image.sprite = sprites[index];
|
||||
//index++;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
StopCoroutine(Animation());
|
||||
base.Close();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e84219e49caa1f46be9f0277fd3b7c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,73 +0,0 @@
|
||||
using Assets.Scripts;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Android;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RowerDevicePanel : PFUIPanel
|
||||
{
|
||||
protected override void Awake()
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("Container/Tools/Back").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
App.MainDeviceAdapter.StopScan();
|
||||
Close();
|
||||
});
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
print("开启扫描");
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
#if UNITY_ANDROID
|
||||
Utils.CallAndroidMethod("OpenLocationService");
|
||||
if (!Permission.HasUserAuthorizedPermission(Permission.CoarseLocation))
|
||||
{
|
||||
Permission.RequestUserPermission(Permission.CoarseLocation);
|
||||
Permission.RequestUserPermission(Permission.FineLocation);
|
||||
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Powerfun need location service permission,please open the location permission.")
|
||||
, () => {
|
||||
UIManager.CloseConfirm();
|
||||
}, 2
|
||||
, () => {
|
||||
UIManager.CloseConfirm();
|
||||
});
|
||||
}
|
||||
#endif
|
||||
App.MainDeviceAdapter.StartScan();
|
||||
#endif
|
||||
}
|
||||
float timer = 1f;
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
if (timer <= 0)
|
||||
{
|
||||
if (App.MainDeviceAdapter.GetState(Assets.Scripts.Devices.ConnectionInterface.BLE) == Assets.Scripts.Devices.DeviceAdapterState.On)
|
||||
{
|
||||
transform.Find("Container/Tools/BlueTooth").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/RowerNew/ICON_bluetooth_44_on");
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.Find("Container/Tools/BlueTooth").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/RowerNew/ICON_bluetooth_44");
|
||||
}
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
protected override void OnDisable()
|
||||
{
|
||||
App.MainDeviceAdapter.StopScan();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
App.MainDeviceAdapter.StopScan();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 169dd57411866874882869d55e047e57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,478 +0,0 @@
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
using Assets.Scripts.Devices.Ant.Interfaces;
|
||||
using Assets.Scripts.UI.UIEffect;
|
||||
using Assets.Scripts;
|
||||
using DG.Tweening;
|
||||
using Assets.Scripts.UI.Prefab.Device;
|
||||
using Assets.Scripts.Devices;
|
||||
using Assets.Scripts.Devices.Ble;
|
||||
|
||||
public class RowerDeviceView : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private SensorType mType;
|
||||
|
||||
private SensorType SensorType
|
||||
{
|
||||
get
|
||||
{
|
||||
//Debug.Log(mType);
|
||||
//Enum.TryParse(mType, out SensorType sensorType);
|
||||
return mType;
|
||||
}
|
||||
}
|
||||
|
||||
private GameObject mSearchButton;
|
||||
private GameObject mPairButton;
|
||||
private GameObject mDisconnectButton;
|
||||
private GameObject unconnectionPanel;
|
||||
private GameObject connectionPanel;
|
||||
private Text searchState,connSearchState;
|
||||
private ConnectDeviceModal deviceModal;
|
||||
private Text title;
|
||||
private Text noDevice;
|
||||
private Text powerValue;
|
||||
private Text powerUnit;
|
||||
//private Text cadenceValue;
|
||||
//private Text speedValue;
|
||||
//private Text heartRateValue;
|
||||
private Image logo;
|
||||
/// <summary>
|
||||
/// 没有设备的logo
|
||||
/// </summary>
|
||||
private Sprite sprite0;
|
||||
/// <summary>
|
||||
/// 连接中的logo
|
||||
/// </summary>
|
||||
private Sprite sprite1;
|
||||
/// <summary>
|
||||
/// 已连接的logo
|
||||
/// </summary>
|
||||
private Sprite sprite3;
|
||||
|
||||
private float timer = 0f;
|
||||
private void Awake()
|
||||
{
|
||||
title = this.transform.Find("Title").GetComponent<Text>();
|
||||
noDevice = this.transform.Find("NoDevice").GetComponent<Text>();
|
||||
unconnectionPanel = this.transform.Find("UnconnectionPanel").gameObject;
|
||||
mSearchButton = unconnectionPanel.transform.Find("SearchButton").gameObject;
|
||||
mPairButton = unconnectionPanel.transform.Find("PairButton").gameObject;
|
||||
searchState = unconnectionPanel.transform.Find("SearchState").GetComponent<Text>();
|
||||
//mPairButton.SetActive(false);
|
||||
connectionPanel = this.transform.Find("ConnectionPanel").gameObject;
|
||||
connSearchState = connectionPanel.transform.Find("SearchState").GetComponent<Text>();
|
||||
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.2f, 0));
|
||||
this.GetComponent<Image>().material = material;
|
||||
|
||||
var img1 = unconnectionPanel.GetComponent<Image>();
|
||||
if(img1 != null)
|
||||
{
|
||||
img1.material = material;
|
||||
|
||||
//var gradient = unconnectionPanel.GetComponent<UIGradient>();
|
||||
//if (gradient != null)
|
||||
//{
|
||||
// gradient.color1 = Utils.HexToColor("353543");
|
||||
// gradient.color2 = Utils.HexToColor("23232D");
|
||||
//}
|
||||
}
|
||||
|
||||
var img2 = connectionPanel.GetComponent<Image>();
|
||||
if(img2 != null)
|
||||
{
|
||||
img2.material = material;
|
||||
|
||||
//var gradient1 = connectionPanel.GetComponent<UIGradient>();
|
||||
//if (gradient1 != null)
|
||||
//{
|
||||
// gradient1.color1 = Utils.HexToColor("FF7485");
|
||||
// gradient1.color2 = Utils.HexToColor("F93086");
|
||||
//}
|
||||
}
|
||||
|
||||
logo = this.transform.Find("Logo").GetComponent<Image>();
|
||||
|
||||
|
||||
mDisconnectButton = connectionPanel.transform.Find("DisconnectBtn").gameObject;
|
||||
var powerValueObj = connectionPanel.transform.Find("PowerValue");
|
||||
if(powerValueObj != null)
|
||||
{
|
||||
powerValue = powerValueObj.gameObject.GetComponent<Text>();
|
||||
}
|
||||
|
||||
var powerUnitObj = connectionPanel.transform.Find("PowerUnit");
|
||||
if(powerUnitObj != null)
|
||||
{
|
||||
powerUnit = powerUnitObj.gameObject.GetComponent<Text>();
|
||||
}
|
||||
|
||||
InitLogo();
|
||||
title.text = GetTitle();
|
||||
|
||||
connectionPanel.SetActive(false);
|
||||
|
||||
UIManager.AddEvent(mPairButton, EventTriggerType.PointerClick, new UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
{
|
||||
connectButtonClick();
|
||||
}));
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
if (!mPairButton.activeInHierarchy && !mDisconnectButton.activeInHierarchy) return;
|
||||
var device = GetDevice();
|
||||
if (device != null && device.State == DeviceState.Connected)
|
||||
{
|
||||
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Disconnect the device?"), () =>
|
||||
{
|
||||
device.Disconnect(false);
|
||||
DeviceCache.Remove(device);
|
||||
UIManager.CloseConfirm();
|
||||
}, 2, () => {
|
||||
UIManager.CloseConfirm();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
connectButtonClick();
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(mDisconnectButton, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e => {
|
||||
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Disconnect the device?"), () =>
|
||||
{
|
||||
var device = GetDevice();
|
||||
if (device != null && device.State == DeviceState.Connected)
|
||||
{
|
||||
DeviceCache.Remove(device);
|
||||
device.Disconnect(false);
|
||||
}
|
||||
UIManager.CloseConfirm();
|
||||
}, 2, () => {
|
||||
UIManager.CloseConfirm();
|
||||
});
|
||||
return;
|
||||
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
var obj = Resources.Load("UI/Prefab/Device/Mobile/ConnectDeviceModal");
|
||||
#else
|
||||
var obj = Resources.Load("UI/Prefab/Device/ConnectDeviceModal");
|
||||
#endif
|
||||
GameObject gameObject = (GameObject)Instantiate(obj);
|
||||
deviceModal = gameObject.GetComponent<ConnectDeviceModal>();
|
||||
deviceModal.SensorType = this.SensorType;
|
||||
UIManager.Show(deviceModal, null, true);
|
||||
}));
|
||||
}
|
||||
void connectButtonClick()
|
||||
{
|
||||
if (deviceModal == null)
|
||||
{
|
||||
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
var obj = Resources.Load("UI/Prefab/Device/Mobile/ConnectDeviceModal");
|
||||
#else
|
||||
var obj = Resources.Load("UI/Prefab/Device/ConnectDeviceModal");
|
||||
#endif
|
||||
GameObject gameObject = (GameObject)Instantiate(obj);
|
||||
deviceModal = gameObject.GetComponent<ConnectDeviceModal>();
|
||||
}
|
||||
deviceModal.SensorType = this.SensorType;
|
||||
UIManager.Show(deviceModal, null, true);
|
||||
}
|
||||
void InitLogo()
|
||||
{
|
||||
if (SensorType == SensorType.Power)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Devices/Power_0");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Devices/Power_1");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Devices/Power_4");
|
||||
|
||||
powerUnit.text = "W";
|
||||
}
|
||||
else if (SensorType == SensorType.Speed)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Devices/Speed_0");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Devices/Speed_1");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Devices/Speed_4");
|
||||
|
||||
powerUnit.text = "KPH";
|
||||
}
|
||||
else if (SensorType == SensorType.Cadence || SensorType == SensorType.SpeedCadence)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Devices/Cadence_0");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Devices/Cadence_1");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Devices/Cadence_4");
|
||||
|
||||
powerUnit.text = "RPM";
|
||||
}
|
||||
else if (SensorType == SensorType.HeartRate)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Devices/Heart Rate_1");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Devices/Heart Rate_1");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Devices/Heart Rate_4");
|
||||
powerValue.text = "";
|
||||
powerUnit.text = "";
|
||||
}
|
||||
else if (SensorType == SensorType.Trainer)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Devices/Trainer_0");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Devices/Trainer_1");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Devices/Trainer_4");
|
||||
}
|
||||
else if (SensorType == SensorType.Rower)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Rower/设备 - 划船机 - 未连接");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Rower/设备 - 划船机 - 未连接");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Rower/设备 - 划船机");
|
||||
powerUnit.text = "";
|
||||
powerValue.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Main();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//if(SensorType != SensorType.Trainer)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
timer -= Time.deltaTime;
|
||||
if (timer <= 0)
|
||||
{
|
||||
Main();
|
||||
|
||||
timer = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void Main()
|
||||
{
|
||||
var connectedDevice = GetCurrentDevice();
|
||||
if(connectedDevice == null)
|
||||
{
|
||||
connectedDevice = GetDevice();
|
||||
}
|
||||
if(connectedDevice == null)
|
||||
{
|
||||
unconnectionPanel.SetActive(true);
|
||||
connectionPanel.SetActive(false);
|
||||
|
||||
logo.sprite = sprite0;
|
||||
|
||||
|
||||
var hasDevice = false;
|
||||
if (SensorType == SensorType.SpeedCadence)
|
||||
{
|
||||
hasDevice = App.MainDeviceAdapter.GetDevices().Any(d => d.Sensor == SensorType.SpeedCadence || d.Sensor == SensorType.Cadence);
|
||||
}
|
||||
else
|
||||
{
|
||||
hasDevice = App.MainDeviceAdapter.GetDevices().Any(d => d.Sensor == SensorType);
|
||||
}
|
||||
searchState.text = hasDevice ? App.GetLocalString("CHOOSE DEVICE") : App.GetLocalString("NO DEVICE");
|
||||
noDevice.text = "";// App.GetLocalString("NOCONN DEVICE"); //hasDevice ? App.GetLocalString("CHOOSE DEVICE") : ;
|
||||
if (hasDevice)
|
||||
{
|
||||
mSearchButton.SetActive(false);
|
||||
mPairButton.SetActive(true);
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
//searchState.gameObject.SetActive(false);
|
||||
#endif
|
||||
logo.sprite = sprite1;
|
||||
|
||||
//App.MainDeviceAdapter.GetDevices().First(d => d.Sensor == SensorType).Connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !(UNITY_IOS || UNITY_ANDROID)
|
||||
mSearchButton.SetActive(true);
|
||||
#endif
|
||||
//mPairButton.SetActive(false);
|
||||
}
|
||||
}
|
||||
else if(connectedDevice.State == DeviceState.Connecting)
|
||||
{
|
||||
unconnectionPanel.SetActive(true);
|
||||
connectionPanel.SetActive(false);
|
||||
logo.sprite = sprite1;
|
||||
|
||||
//title.text = connectedDevice.Name;
|
||||
if (connectedDevice.Network == NetworkType.BLE)
|
||||
{
|
||||
//noDevice.enabled = false;
|
||||
noDevice.text = connectedDevice.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
//noDevice.enabled = true;
|
||||
noDevice.text = connectedDevice.Name +" "+ connectedDevice.DeviceNumber.ToString();
|
||||
}
|
||||
#if (UNITY_IOS || UNITY_ANDROID)
|
||||
mPairButton.SetActive(true);
|
||||
searchState.gameObject.SetActive(true);
|
||||
#endif
|
||||
searchState.text = App.GetLocalString("Connecting...");
|
||||
|
||||
|
||||
}
|
||||
else if (connectedDevice.State == DeviceState.Connected)
|
||||
{
|
||||
unconnectionPanel.SetActive(false);
|
||||
|
||||
if (connectionPanel.activeInHierarchy == false)
|
||||
{
|
||||
var connectionCanvasGroup = connectionPanel.GetComponent<CanvasGroup>();
|
||||
connectionCanvasGroup.alpha = 0;
|
||||
connectionPanel.SetActive(true);
|
||||
connectionCanvasGroup.DOFade(1f, .3f).OnComplete(()=> {
|
||||
//if (logoSprite != null) {
|
||||
// logo.sprite = logoSprite;
|
||||
//}
|
||||
});
|
||||
DeviceCache.Add(connectedDevice);
|
||||
Debug.Log("connected");
|
||||
}
|
||||
|
||||
logo.sprite = sprite3;
|
||||
//title.text = connectedDevice.Name;
|
||||
if (connectedDevice.Network == NetworkType.BLE)
|
||||
{
|
||||
//noDevice.enabled = false;
|
||||
noDevice.text = connectedDevice.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
//noDevice.enabled = true;
|
||||
noDevice.text = connectedDevice.Name +" "+ connectedDevice.DeviceNumber.ToString();
|
||||
}
|
||||
noDevice.color = Utils.HexToColorHtml("#f93086");
|
||||
|
||||
//if (powerValue != null)
|
||||
//{
|
||||
// powerValue.text = GetValue(connectedDevice);
|
||||
//}
|
||||
}
|
||||
|
||||
//Debug.Log(Newtonsoft.Json.JsonConvert.SerializeObject(App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType)));
|
||||
}
|
||||
|
||||
string GetTitle()
|
||||
{
|
||||
switch (SensorType)
|
||||
{
|
||||
case SensorType.None:
|
||||
break;
|
||||
case SensorType.SpeedCadence:
|
||||
case SensorType.Cadence:
|
||||
return "Cadence Sensor";
|
||||
case SensorType.HeartRate:
|
||||
return "Heart Rate Monitor";
|
||||
case SensorType.Power:
|
||||
return "Power Meter";
|
||||
case SensorType.Speed:
|
||||
return "Speed Meter";
|
||||
case SensorType.Trainer:
|
||||
return "Smart Trainer";
|
||||
case SensorType.Rower:
|
||||
return "Rowing Machine";
|
||||
case SensorType.VirtualPower:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
string GetValue(AbstractDevice connectedDevice)
|
||||
{
|
||||
switch (SensorType)
|
||||
{
|
||||
case SensorType.None:
|
||||
break;
|
||||
case SensorType.SpeedCadence:
|
||||
case SensorType.Cadence:
|
||||
//cadenceValue.text = (connectedDevice as ICadenceDevice).Cadence.ToString();
|
||||
return (connectedDevice as ICadenceDevice).Cadence.ToString();
|
||||
case SensorType.HeartRate:
|
||||
return (connectedDevice as IHeartRateDevice).HeartRate.ToString();
|
||||
case SensorType.Power:
|
||||
return (connectedDevice as IPowerDevice).Power.ToString();
|
||||
case SensorType.Speed:
|
||||
return (connectedDevice as ISpeedDevice).Speed.ToString("f1");
|
||||
case SensorType.Trainer:
|
||||
//powerValue.text = (connectedDevice as IPowerDevice).Power.ToString();
|
||||
//cadenceValue.GetComponent<Text>().text = (connectedDevice as ICadenceDevice).Cadence.ToString();
|
||||
//speedValue.GetComponent<Text>().text = (connectedDevice as ISpeedDevice).Speed.ToString();
|
||||
break;
|
||||
case SensorType.VirtualPower:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
AbstractDevice GetCurrentDevice()
|
||||
{
|
||||
//return AntConnector.Instance().discoveredDevices.FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
|
||||
if(SensorType == SensorType.SpeedCadence || SensorType == SensorType.Cadence)
|
||||
{
|
||||
return App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && (d.Sensor == SensorType.SpeedCadence || d.Sensor == SensorType.Cadence));
|
||||
}
|
||||
return App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取已经连接的设备
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
AbstractDevice GetDevice()
|
||||
{
|
||||
//return AntConnector.Instance().discoveredDevices.FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
|
||||
var devices = App.MainDeviceAdapter.GetDevices().Where(d => (d.State == DeviceState.Connected));
|
||||
switch (SensorType)
|
||||
{
|
||||
case SensorType.None:
|
||||
break;
|
||||
case SensorType.SpeedCadence:
|
||||
case SensorType.Cadence:
|
||||
return devices.FirstOrDefault(d => d is ICadenceDevice);
|
||||
case SensorType.HeartRate:
|
||||
return devices.FirstOrDefault(d => d is IHeartRateDevice);
|
||||
case SensorType.Power:
|
||||
var item = devices.FirstOrDefault(d => d is IPowerDevice);
|
||||
//if (powerValue != null)
|
||||
//{
|
||||
// powerValue.GetComponent<Text>().text = (item as IPowerDevice).Power.ToString();
|
||||
//}
|
||||
return item;
|
||||
case SensorType.Speed:
|
||||
return devices.FirstOrDefault(d => d is ISpeedDevice);
|
||||
case SensorType.Rower:
|
||||
return devices.FirstOrDefault(d => d.Sensor == SensorType.Rower);
|
||||
case SensorType.Trainer:
|
||||
var item3 = devices.FirstOrDefault(d => d.Sensor == SensorType.Trainer);
|
||||
return item3;
|
||||
case SensorType.VirtualPower:
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 954bbf32f326f684c90a328ec1db5ff9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,123 +0,0 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using ChartAndGraph;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class RowerGraphChartFeed : MonoBehaviour
|
||||
{
|
||||
GraphChartBase graph { get; set; }
|
||||
GraphData dataSource { get; set; }
|
||||
|
||||
void Start ()
|
||||
{
|
||||
graph = GetComponent<GraphChartBase>();
|
||||
dataSource = graph.DataSource;
|
||||
//GraphChartBase graph = GetComponent<GraphChartBase>();
|
||||
//if (graph != null)
|
||||
//{
|
||||
// graph.Scrollable = false;
|
||||
// graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
|
||||
// graph.DataSource.StartBatch();
|
||||
// graph.DataSource.ClearCategory("Player 1");
|
||||
// graph.DataSource.ClearAndMakeBezierCurve("Player 2");
|
||||
|
||||
// for (int i = 0; i <10000; i++)
|
||||
// {
|
||||
// graph.DataSource.AddPointToCategory("Player 1",i*5,Random.value*10f + 20f);
|
||||
// if (i == 0)
|
||||
// graph.DataSource.SetCurveInitialPoint("Player 2",i*5, Random.value * 10f + 10f);
|
||||
// else
|
||||
// graph.DataSource.AddLinearCurveToCategory("Player 2",
|
||||
// new DoubleVector2(i*5 , Random.value * 10f + 10f));
|
||||
// }
|
||||
// graph.DataSource.MakeCurveCategorySmooth("Player 2");
|
||||
// graph.DataSource.EndBatch();
|
||||
//}
|
||||
// StartCoroutine(ClearAll());
|
||||
}
|
||||
public void SetPrePoint(double x, double y)
|
||||
{
|
||||
dataSource?.AddPointToCategoryRealtime("Player 1", x, 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);
|
||||
}
|
||||
public void ClearChart()
|
||||
{
|
||||
if (dataSource != null)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
var item = list2[i];
|
||||
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)
|
||||
{
|
||||
if (graph != null)
|
||||
{
|
||||
graph.Scrollable = false;
|
||||
//graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
|
||||
//graph.DataSource.StartBatch();
|
||||
//graph.DataSource.ClearCategory("Player 1");
|
||||
//graph.DataSource.ClearCategory("Player 2");
|
||||
//graph.ClearCache();
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
var item = list[i];
|
||||
graph.DataSource.AddPointToCategoryRealtime("Player 2", item.x, item.y);
|
||||
//if (i == 0)
|
||||
// graph.DataSource.SetCurveInitialPoint("Player 1", item.x, item.y);
|
||||
//else
|
||||
// graph.DataSource.AddLinearCurveToCategory("Player 1", new DoubleVector2(item.x, item.y));
|
||||
}
|
||||
if (list2 != null)
|
||||
{
|
||||
for (int i = 0; i < list2.Count; i++)
|
||||
{
|
||||
var item = list2[i];
|
||||
graph.DataSource.AddPointToCategoryRealtime("Player 1", item.x, item.y);
|
||||
}
|
||||
}
|
||||
//graph.DataSource.MakeCurveCategorySmooth("Player 1");
|
||||
//graph.DataSource.EndBatch();
|
||||
}
|
||||
}
|
||||
IEnumerator ClearAll()
|
||||
{
|
||||
yield return new WaitForSeconds(5f);
|
||||
GraphChartBase graph = GetComponent<GraphChartBase>();
|
||||
|
||||
graph.DataSource.Clear();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa4e07579b1f9574788e0b83b1fac799
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,145 +0,0 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public partial class RowerHoverText : MonoBehaviour
|
||||
{
|
||||
public Text TextPrefab;
|
||||
public int FontSize = 5;
|
||||
public Vector3 TextOffset = new Vector3();
|
||||
public string Title;
|
||||
public string Unit;
|
||||
int fractionDigits = 0;
|
||||
AnyChart mChart;
|
||||
|
||||
List<Text> mItems = new List<Text>();
|
||||
List<CharItemEffectController> mRemoved = new List<CharItemEffectController>();
|
||||
|
||||
partial void HoverStart();
|
||||
void Start ()
|
||||
{
|
||||
var graph = GetComponent<GraphChart>();
|
||||
|
||||
var labels = GetComponent<ItemLabels>();
|
||||
if (labels != null)
|
||||
fractionDigits = labels.FractionDigits;
|
||||
else
|
||||
fractionDigits = 2;
|
||||
|
||||
if (graph != null)
|
||||
{
|
||||
mChart = graph;
|
||||
graph.PointHovered.AddListener(GraphHover);
|
||||
graph.NonHovered.AddListener(NonHover);
|
||||
return;
|
||||
}
|
||||
|
||||
var bar = GetComponent<CanvasBarChart>();
|
||||
if (bar != null)
|
||||
{
|
||||
mChart = bar;
|
||||
bar.BarHovered.AddListener(BarHover);
|
||||
bar.NonHovered.AddListener(NonHover);
|
||||
return;
|
||||
}
|
||||
|
||||
HoverStart();
|
||||
}
|
||||
|
||||
void NonHover()
|
||||
{
|
||||
for (int i = 0; i < mItems.Count; i++)
|
||||
{
|
||||
RemoveText(mItems[i]);
|
||||
}
|
||||
mItems.Clear();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
mRemoved.RemoveAll(x =>
|
||||
{
|
||||
if(!x.enabled)
|
||||
{
|
||||
ChartCommon.SafeDestroy(x.gameObject);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
IEnumerator SelectText(Text text)
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
if (text != null)
|
||||
{
|
||||
ChartItemEvents e = text.GetComponent<ChartItemEvents>();
|
||||
if (e != null)
|
||||
{
|
||||
e.OnMouseHover.Invoke(e.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveText(Text text)
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
ChartItemEvents e = text.GetComponent<ChartItemEvents>();
|
||||
CharItemEffectController control = text.GetComponent<CharItemEffectController>();
|
||||
if (e != null && control != null)
|
||||
{
|
||||
e.OnMouseLeave.Invoke(e.gameObject);
|
||||
mRemoved.Add(control);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartCommon.SafeDestroy(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PopText(string data,Vector3 position,bool worldPositionStays)
|
||||
{
|
||||
var canvas = GetComponentInParent<Canvas>();
|
||||
if (canvas == null || TextPrefab == null)
|
||||
return;
|
||||
NonHover();
|
||||
GameObject obj =(GameObject) GameObject.Instantiate(TextPrefab.gameObject, position + TextOffset, Quaternion.identity);
|
||||
var text = obj.GetComponent<Text>();
|
||||
text.maskable = false;
|
||||
text.text = data;
|
||||
text.fontSize = FontSize;
|
||||
obj.transform.SetParent(transform, false);
|
||||
if (worldPositionStays)
|
||||
obj.transform.position = position + TextOffset;
|
||||
else
|
||||
obj.transform.localPosition = position + TextOffset;
|
||||
Vector3 local = obj.transform.localPosition;
|
||||
local.z = 0f;
|
||||
obj.transform.localPosition = local;
|
||||
mItems.Add(text);
|
||||
StartCoroutine(SelectText(text));
|
||||
}
|
||||
|
||||
void BarHover(BarChart.BarEventArgs args)
|
||||
{
|
||||
String data = ChartAdancedSettings.Instance.FormatFractionDigits(fractionDigits, args.Value);
|
||||
PopText(data, args.TopPosition,true);
|
||||
}
|
||||
void GraphHover(GraphChartBase.GraphEventArgs args)
|
||||
{
|
||||
var graph = mChart as GraphChart;
|
||||
var point = graph.DataSource.GetPoint(args.Category, args.Index);
|
||||
Vector3 position;
|
||||
if(graph.PointToWorldSpace(out position, point.x, point.y, args.Category))
|
||||
PopText($"{Title}\n{args.YString} {Unit}", position, true);
|
||||
else
|
||||
PopText($"{Title}\n{args.YString} {Unit}", args.Position,false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edce4d82bd7a8544982946c6318de49b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,245 +0,0 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using ChartAndGraph;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
public partial class RowerLargeDataFeed : MonoBehaviour, IComparer<DoubleVector2>
|
||||
{
|
||||
public string Category = "Player 1";
|
||||
public int DownSampleToPoints = 1000;
|
||||
List<DoubleVector2> mData = new List<DoubleVector2>(); // the data held by the chart
|
||||
double pageSize = 2f;
|
||||
double currentPagePosition = 0.0;
|
||||
double currentZoom = 0f;
|
||||
GraphChartBase graph;
|
||||
double mCurrentPageSizeFactor = double.NegativeInfinity;
|
||||
void Start()
|
||||
{
|
||||
graph = GetComponent<GraphChartBase>();
|
||||
//SetInitialData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// called with Start(). These will be used to load the data into the large data feed. You should replace this with your own loading logic.
|
||||
/// </summary>
|
||||
void SetInitialData()
|
||||
{
|
||||
List<DoubleVector2> data = new List<DoubleVector2>(75);
|
||||
double x = 0f;
|
||||
double y = 20f;
|
||||
for (int i = 0; i < 75; i++) // initialize with random data
|
||||
{
|
||||
y = 20 + UnityEngine.Random.value * 80;
|
||||
Debug.Log(y);
|
||||
x += 1;
|
||||
data.Add(new DoubleVector2(x, y));
|
||||
}
|
||||
SetData(data);
|
||||
}
|
||||
|
||||
public void SaveToFile(string path)
|
||||
{
|
||||
using (StreamWriter file = new StreamWriter(path))
|
||||
{
|
||||
file.WriteLine(mData.Count);
|
||||
for (int i = 0; i < mData.Count; i++)
|
||||
{
|
||||
DoubleVector2 item = mData[i];
|
||||
file.WriteLine(item.x);
|
||||
file.WriteLine(item.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void LoadFromFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<DoubleVector2> data = new List<DoubleVector2>();
|
||||
using (StreamReader file = new StreamReader(path))
|
||||
{
|
||||
int count = int.Parse(file.ReadLine());
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
double x = double.Parse(file.ReadLine());
|
||||
double y = double.Parse(file.ReadLine());
|
||||
data.Add(new DoubleVector2(x, y));
|
||||
}
|
||||
}
|
||||
SetData(data);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception("Invalid file format");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// vertify's that the graph data is sorted so it can be searched using a binary search.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool VerifySorted(List<DoubleVector2> data)
|
||||
{
|
||||
if (data == null)
|
||||
return true;
|
||||
for (int i = 1; i < data.Count; i++)
|
||||
{
|
||||
if (data[i].x < data[i - 1].x)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// set the data of the large data graph
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public void SetData(List<DoubleVector2> data)
|
||||
{
|
||||
if (data == null)
|
||||
data = new List<DoubleVector2>(); // set up an empty list instead of null
|
||||
if (VerifySorted(data) == false)
|
||||
{
|
||||
Debug.LogWarning("The data used with large data feed must be sorted acoording to the x value, aborting operation");
|
||||
return;
|
||||
}
|
||||
mData = data;
|
||||
LoadPage(currentPagePosition); // load the page at position 0
|
||||
}
|
||||
|
||||
int FindClosestIndex(double position) // if you want to know what is index is currently displayed . use binary search to find it
|
||||
{
|
||||
//NOTE :: this method assumes your data is sorted !!!
|
||||
int res = mData.BinarySearch(new DoubleVector2(position, 0.0), this);
|
||||
if (res >= 0)
|
||||
return res;
|
||||
return ~res;
|
||||
}
|
||||
|
||||
double PageSizeFactor
|
||||
{
|
||||
get
|
||||
{
|
||||
return pageSize * graph.DataSource.HorizontalViewSize;
|
||||
}
|
||||
}
|
||||
|
||||
void findPointsForPage(double position, out int start, out int end) // given a page position , find the right most and left most indices in the data for that page.
|
||||
{
|
||||
int index = FindClosestIndex(position); // use binary search to find the closest position to the current scroll point
|
||||
|
||||
double endPosition = position + PageSizeFactor;
|
||||
double startPosition = position - PageSizeFactor;
|
||||
|
||||
//starting from the current index , we find the page boundries
|
||||
for (start = index; start > 0; start--)
|
||||
{
|
||||
if (mData[start].x < startPosition) // take the first point that is out of the page. so the graph doesn't break at the edge
|
||||
break;
|
||||
}
|
||||
|
||||
for (end = index; end < mData.Count; end++)
|
||||
{
|
||||
if (mData[end].x > endPosition) // take the first point that is out of the page
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (graph != null)
|
||||
{
|
||||
//check the scrolling position of the graph. if we are past the view size , load a new page
|
||||
double pageStartThreshold = currentPagePosition - mCurrentPageSizeFactor;
|
||||
double pageEndThreshold = currentPagePosition + mCurrentPageSizeFactor - graph.DataSource.HorizontalViewSize;
|
||||
|
||||
if (graph.HorizontalScrolling < pageStartThreshold || graph.HorizontalScrolling > pageEndThreshold || currentZoom >= graph.DataSource.HorizontalViewSize * 2f)
|
||||
{
|
||||
currentZoom = graph.DataSource.HorizontalViewSize;
|
||||
mCurrentPageSizeFactor = PageSizeFactor * 0.9f;
|
||||
LoadPage(graph.HorizontalScrolling);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoadWithoutDownSampling(int start, int end)
|
||||
{
|
||||
for (int i = start; i < end; i++) // load the data
|
||||
{
|
||||
graph.DataSource.AddPointToCategory(Category, mData[i].x, mData[i].y);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadWithDownSampling(int start, int end)
|
||||
{
|
||||
int total = end - start;
|
||||
|
||||
if (DownSampleToPoints >= total)
|
||||
{
|
||||
LoadWithoutDownSampling(start, end);
|
||||
return;
|
||||
}
|
||||
|
||||
double sampleCount = ((double)total) / (double)DownSampleToPoints;
|
||||
// graph.DataSource.AddPointToCategory(Category, mData[start].x, mData[start].y);
|
||||
for (int i = 0; i < DownSampleToPoints; i++)
|
||||
{
|
||||
int fractionStart = start + (int)(i * sampleCount); // the first point with a fraction
|
||||
int fractionEnd = start + (int)((i + 1) * sampleCount); // the first point with a fraction
|
||||
fractionEnd = Math.Min(fractionEnd, mData.Count - 1);
|
||||
double x = 0, y = 0;
|
||||
double divide = 0.0;
|
||||
for (int j = fractionStart; j < fractionEnd; j++) // avarge the poins
|
||||
{
|
||||
x += mData[j].x;
|
||||
y += mData[j].y;
|
||||
divide++;
|
||||
}
|
||||
if (divide > 0.0)
|
||||
{
|
||||
x /= divide;
|
||||
y /= divide;
|
||||
graph.DataSource.AddPointToCategory(Category, x, y);
|
||||
}
|
||||
else
|
||||
Debug.Log("error");
|
||||
}
|
||||
// graph.DataSource.AddPointToCategory(Category, mData[last].x, mData[last].y);
|
||||
}
|
||||
|
||||
void LoadPage(double pagePosition)
|
||||
{
|
||||
if (graph != null)
|
||||
{
|
||||
|
||||
Debug.Log("Loading page :" + pagePosition);
|
||||
graph.DataSource.StartBatch(); // call start batch
|
||||
graph.DataSource.HorizontalViewOrigin = 0;
|
||||
int start, end;
|
||||
findPointsForPage(pagePosition, out start, out end); // get the page edges
|
||||
graph.DataSource.ClearCategory(Category); // clear the cateogry
|
||||
graph.DataSource.HorizontalViewSize = mData.Count;
|
||||
if (DownSampleToPoints <= 0)
|
||||
LoadWithoutDownSampling(start, end);
|
||||
else
|
||||
LoadWithDownSampling(start, end);
|
||||
graph.DataSource.EndBatch();
|
||||
graph.HorizontalScrolling = pagePosition;
|
||||
}
|
||||
currentPagePosition = pagePosition;
|
||||
}
|
||||
|
||||
|
||||
public int Compare(DoubleVector2 x, DoubleVector2 y)
|
||||
{
|
||||
if (x.x < y.x)
|
||||
return -1;
|
||||
if (x.x > y.x)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7916cf3d11e8e7b4ebd8712801923455
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee3b67ceb2893134a887a9e30922821e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,121 +0,0 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using ChartAndGraph;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RowerResult : PFUIPanel
|
||||
{
|
||||
RowerResultModel _model;
|
||||
private GraphChart chartPace, chartRate, chartHR;
|
||||
Transform dataContent;
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
var grid = transform.Find("Scroll View/Viewport/Content/Content/Table").GetComponent<GridLayoutGroup>();
|
||||
float width = (App.canvasWidth - 60 - 3) / 4;
|
||||
grid.cellSize = new Vector2(width, 37);
|
||||
var grid1 = transform.Find("Scroll View/Viewport/Content/Content/Other/Datas").GetComponent<GridLayoutGroup>();
|
||||
grid1.cellSize = new Vector2(width, 53);
|
||||
chartPace = transform.Find("Scroll View/Viewport/Content/Content/ChartPace/Chart").GetComponent<GraphChart>();
|
||||
chartPace.DataSource.VerticalViewOrigin = ChartDateUtility.TimeSpanToValue(TimeSpan.FromHours(15));
|
||||
chartPace.DataSource.VerticalViewSize = ChartDateUtility.TimeSpanToValue(TimeSpan.FromHours(15)) * -1;
|
||||
chartRate = transform.Find("Scroll View/Viewport/Content/Content/ChartRate/Chart").GetComponent<GraphChart>();
|
||||
chartHR = transform.Find("Scroll View/Viewport/Content/Content/ChartHeartRate/Chart").GetComponent<GraphChart>();
|
||||
dataContent = transform.Find("Scroll View/Viewport/Content/Content");
|
||||
UIManager.AddEvent(transform.Find("Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Close();
|
||||
});
|
||||
//var a = new List<ChartAndGraph.DoubleVector2>();
|
||||
//for (int i = 0; i < 100; i++)
|
||||
//{
|
||||
// a.Add(new ChartAndGraph.DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(300))));
|
||||
//}
|
||||
//transform.Find("Scroll View/Viewport/Content/Content/ChartPace/Chart").GetComponent<RowerLargeDataFeed>().SetData(a);
|
||||
}
|
||||
public async void Initial(string id)
|
||||
{
|
||||
transform.Find("Scroll View").GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
GetComponent<CanvasGroup>().alpha = 0;
|
||||
var res = await ConfigHelper.rowerApi.GetDetail(id);
|
||||
if (res.result)
|
||||
{
|
||||
_model = res.data;
|
||||
dataContent.Find("Title").GetComponent<Text>().text = $"{_model.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} Free Rowing";
|
||||
dataContent.Find("Time").GetComponent<Text>().text = $"{_model.StartTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} ~ {_model.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")}";
|
||||
dataContent.Find("TitleContent/Duration").GetComponent<Text>().text
|
||||
= $"<color=#5c5c6e>Rowing time :</color> {TimeSpan.FromSeconds(_model.TotalTime).ToString()}";
|
||||
dataContent.Find("TitleContent/Distance").GetComponent<Text>().text
|
||||
= $"<color=#5c5c6e>Distance :</color> {_model.TotalDistance}M";
|
||||
dataContent.Find("TitleContent/Device").GetComponent<Text>().text
|
||||
= $"<color=#5c5c6e>Rowing equipment :</color> {_model.ManufacturerName}";
|
||||
dataContent.Find("Table/AvgPower/Text").GetComponent<Text>().text
|
||||
= $"{TimeSpan.FromSeconds(_model.AvgPace).ToString(@"mm\:ss")} /500M";
|
||||
dataContent.Find("Table/AvgHR/Text").GetComponent<Text>().text
|
||||
= $"{_model.AvgHeartRate} BPM";
|
||||
dataContent.Find("Table/AvgRate/Text").GetComponent<Text>().text
|
||||
= $"{_model.AvgRate.ToString("#0")} SPM";
|
||||
dataContent.Find("Table/MaxPower/Text").GetComponent<Text>().text
|
||||
= $"{TimeSpan.FromSeconds(_model.MaxPace).ToString(@"mm\:ss")} /500M";
|
||||
dataContent.Find("Table/MaxHR/Text").GetComponent<Text>().text
|
||||
= $"{_model.MaxHeartRate} BPM";
|
||||
dataContent.Find("Table/MaxRate/Text").GetComponent<Text>().text
|
||||
= $"{_model.MaxRate.ToString("#0")} SPM";
|
||||
dataContent.Find("ChartPace/Avg/Value").GetComponent<Text>().text
|
||||
= $"{TimeSpan.FromSeconds(_model.AvgPace).ToString(@"mm\:ss")} /500M";
|
||||
dataContent.Find("ChartRate/Avg/Value").GetComponent<Text>().text
|
||||
= $"{_model.AvgRate.ToString("#0")} SPM";
|
||||
dataContent.Find("ChartHeartRate/Avg/Value").GetComponent<Text>().text
|
||||
= $"{_model.AvgHeartRate.ToString("#0")} BPM";
|
||||
dataContent.Find("ChartPace/Max/Value").GetComponent<Text>().text
|
||||
= $"{TimeSpan.FromSeconds(_model.MaxPace).ToString(@"mm\:ss")} /500M";
|
||||
dataContent.Find("ChartRate/Max/Value").GetComponent<Text>().text
|
||||
= $"{_model.MaxRate.ToString("#0")} SPM";
|
||||
dataContent.Find("ChartHeartRate/Max/Value").GetComponent<Text>().text
|
||||
= $"{_model.MaxHeartRate.ToString("#0")} BPM";
|
||||
dataContent.Find("Other/Datas/Calories/Value").GetComponent<Text>().text
|
||||
= $"{(_model.Kj ?? 0).ToString("#0")} KCAL";
|
||||
dataContent.Find("Other/Datas/StrokeCount/Value").GetComponent<Text>().text
|
||||
= _model.StrokeCount.ToString();
|
||||
//var b = _model.ChartList.Select((x, i) => new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace + UnityEngine.Random.value * 300)))).ToList();
|
||||
//Debug.Log(_model.ChartList.Select((x, i) => new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace + UnityEngine.Random.value * 300)))).ToList());
|
||||
//var a = new List<DoubleVector2>();
|
||||
//for (int i = 0; i < 100; i++)
|
||||
//{
|
||||
// a.Add(new DoubleVector2(i, UnityEngine.Random.value * 200));
|
||||
//}
|
||||
chartPace.GetComponent<RowerLargeDataFeed>()
|
||||
.SetData(_model.ChartList.Select((x, i) =>
|
||||
{
|
||||
if (x.Pace == 0)
|
||||
{
|
||||
return new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromHours(15)) - 2000);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace)));
|
||||
}
|
||||
|
||||
}).ToList());
|
||||
chartRate.GetComponent<RowerLargeDataFeed>()
|
||||
.SetData(_model.ChartList.Select((x, i) => new DoubleVector2(i, x.Rate)).ToList());
|
||||
chartHR.GetComponent<RowerLargeDataFeed>()
|
||||
//.SetData(a);
|
||||
.SetData(_model.ChartList.Select((x, i) => new DoubleVector2(i, x.HeartRate)).ToList());
|
||||
}
|
||||
GetComponent<CanvasGroup>().DOFade(1, 0.3f);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa3ab67bcc540104589072a282858e44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RowerSelector : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
var btnRide = transform.Find("Container/BtnRide").gameObject;
|
||||
if (btnRide)
|
||||
{
|
||||
UIManager.AddEvent(btnRide, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Close();
|
||||
UIManager.ShowHomePanel();
|
||||
});
|
||||
}
|
||||
|
||||
var btnRower = transform.Find("Container/BtnRower").gameObject;
|
||||
if (btnRower)
|
||||
{
|
||||
UIManager.AddEvent(btnRower, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Close();
|
||||
UIManager.ShowRowerPanel();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 062e7f4cad92a34488b81254ede4cbe9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,352 +0,0 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
|
||||
public class RowerTaskPanel : PFUIPanel
|
||||
{
|
||||
public class RowerType
|
||||
{
|
||||
/// <summary>
|
||||
/// 1 里程 2 时间
|
||||
/// </summary>
|
||||
public int type { get; set; }
|
||||
/// <summary>
|
||||
/// 里程:m 时间:s
|
||||
/// </summary>
|
||||
public float value { get; set; }
|
||||
public bool EqualTo(RowerType rowerType) {
|
||||
return this.type == rowerType.type && this.value == rowerType.value;
|
||||
}
|
||||
}
|
||||
Transform selector, distance, time;
|
||||
public RowerType rowerType { get; set; }
|
||||
|
||||
public Action<RowerType> callBack { get; set; }
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
distance = transform.Find("Main/Distance");
|
||||
time = transform.Find("Main/Time");
|
||||
rowerType = new RowerType();
|
||||
UIManager.AddEvent(transform.Find("Main/BtnGo").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Go();
|
||||
});
|
||||
UIManager.AddEvent(transform.Find("Main/BtnCancel").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Close();
|
||||
});
|
||||
UIManager.AddEvent(transform.Find("Main/BtnFreeMode").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
rowerType.type = 0;
|
||||
rowerType.value = 0;
|
||||
if (callBack != null)
|
||||
{
|
||||
callBack.Invoke(rowerType);
|
||||
}
|
||||
Close();
|
||||
});
|
||||
//var bg = transform.Find("Main/Time/Inputbg").gameObject;
|
||||
//UIManager.AddEvent(bg, UnityEngine.EventSystems.EventTriggerType.PointerEnter, b =>
|
||||
// {
|
||||
// bg.GetComponent<Outline>().enabled = true;
|
||||
// bg.GetComponent<Outline>().effectColor = Utils.HexToColorHtml("#353543");
|
||||
// });
|
||||
//UIManager.AddEvent(bg, UnityEngine.EventSystems.EventTriggerType.Select, b =>
|
||||
//{
|
||||
// bg.GetComponent<Outline>().enabled = true;
|
||||
// bg.GetComponent<Outline>().effectColor = Utils.HexToColorHtml("#f93086");
|
||||
//});
|
||||
//UIManager.AddEvent(bg, UnityEngine.EventSystems.EventTriggerType.Deselect, b =>
|
||||
//{
|
||||
// bg.GetComponent<Outline>().enabled = false;
|
||||
//});
|
||||
formList = new List<object>
|
||||
{
|
||||
distance.Find("Btn500").GetComponent<Button>(),
|
||||
distance.Find("Btn1000").GetComponent<Button>(),
|
||||
distance.Find("Btn2000").GetComponent<Button>(),
|
||||
distance.Find("Btn5000").GetComponent<Button>(),
|
||||
distance.Find("Btn10000").GetComponent<Button>(),
|
||||
distance.Find("Customize").GetComponent<PFUIInputField>(),
|
||||
time.Find("Btn30").GetComponent<Button>(),
|
||||
time.Find("CustomizeMin").GetComponent<PFUIInputField>(),
|
||||
time.Find("CustomizeS").GetComponent<PFUIInputField>(),
|
||||
};
|
||||
InitDistance();
|
||||
}
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
InitAll();
|
||||
InitValue();
|
||||
}
|
||||
private void Go()
|
||||
{
|
||||
if (rowerType.type == 0 || rowerType.value == 0)
|
||||
{
|
||||
Utils.showToast(null, "Please select a course.", isOnly:true);
|
||||
return;
|
||||
}
|
||||
if (rowerType.type == 1 && rowerType.value < 100)
|
||||
{
|
||||
Utils.showToast(null, "Minimum mileage is 100M.", isOnly: true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rowerType.type == 2 && rowerType.value < 20)
|
||||
{
|
||||
Utils.showToast(null, "Minimum time is 20s.", isOnly: true);
|
||||
return;
|
||||
}
|
||||
if (callBack != null)
|
||||
{
|
||||
callBack.Invoke(rowerType);
|
||||
}
|
||||
Close();
|
||||
}
|
||||
|
||||
List<object> formList = null;
|
||||
private void InitDistance()
|
||||
{
|
||||
Func<Transform, float, float, float> calc = (t, a, b) => t.parent.name == "Distance" ? a : a * 60 + b;
|
||||
AddListener(formList, (t, v) =>
|
||||
{
|
||||
if (t.parent.name == "Distance")
|
||||
{
|
||||
rowerType.type = 1;
|
||||
if (float.TryParse(v, out float f))
|
||||
{
|
||||
rowerType.value = f;
|
||||
}
|
||||
else
|
||||
{
|
||||
rowerType.value = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rowerType.type = 2;
|
||||
rowerType.value = 0;
|
||||
var min = time.Find("CustomizeMin").GetComponent<InputField>().text;
|
||||
var s = time.Find("CustomizeS").GetComponent<InputField>().text;
|
||||
if (float.TryParse(min, out float a))
|
||||
{
|
||||
rowerType.value += 60 * a;
|
||||
}
|
||||
if (float.TryParse(s, out float b))
|
||||
{
|
||||
if (b < 0 || b > 59)
|
||||
{
|
||||
Utils.showToast(null, "Please enter an integer between 0-59.");
|
||||
time.Find("CustomizeS").GetComponent<InputField>().text = "";
|
||||
return;
|
||||
}
|
||||
rowerType.value += b;
|
||||
}
|
||||
}
|
||||
}, calc);
|
||||
}
|
||||
private void AddListener(IEnumerable<object> list, UnityAction<Transform,string> inputCustomAction, Func<Transform, float,float,float> calcButton = null)
|
||||
{
|
||||
var btns = list.Where(x => x is Button).Select(x => x as Button);
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (item is Button)
|
||||
{
|
||||
var btn = item as Button;
|
||||
btn.onClick.RemoveAllListeners();
|
||||
btn.onClick.AddListener(() =>
|
||||
{
|
||||
InitAll();
|
||||
rowerType.type = btn.transform.parent.name == "Distance" ? 1 : 2;
|
||||
if (calcButton == null)
|
||||
{
|
||||
rowerType.value = float.Parse(btn.name.Replace("Btn", ""));
|
||||
}
|
||||
else
|
||||
{
|
||||
rowerType.value = calcButton.Invoke(btn.transform ,float.Parse(btn.name.Replace("Btn", "")), 0);
|
||||
}
|
||||
ClickDistanceBtn(btn, btns);
|
||||
});
|
||||
}
|
||||
else if (item is PFUIInputField)
|
||||
{
|
||||
var input = item as PFUIInputField;
|
||||
input.CustomSelect = () =>
|
||||
{
|
||||
string ignoreName = null;
|
||||
if (input.name == "CustomizeMin")
|
||||
{
|
||||
ignoreName = "CustomizeS";
|
||||
}
|
||||
else if (input.name == "CustomizeS")
|
||||
{
|
||||
ignoreName = "CustomizeMin";
|
||||
}
|
||||
InitAll(ignoreName);
|
||||
ClickDistanceBtn(null, btns);
|
||||
rowerType.type = input.transform.parent.name == "Distance" ? 1 : 2;
|
||||
SetTextColor(input.gameObject, true);
|
||||
SetBgColor(input,2);
|
||||
};
|
||||
input.CustomDeSelect = () =>
|
||||
{
|
||||
SetTextColor(input.gameObject, false);
|
||||
SetBgColor(input, 3);
|
||||
};
|
||||
input.CustomEnter = () =>
|
||||
{
|
||||
SetBgColor(input, 1);
|
||||
};
|
||||
if (inputCustomAction != null)
|
||||
{
|
||||
input.GetComponent<InputField>().onEndEdit.RemoveAllListeners();
|
||||
input.GetComponent<InputField>().onEndEdit.AddListener((v) => inputCustomAction(input.transform, v));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<string, int> inputStatusDict = null;
|
||||
private void SetBgColor(PFUIInputField input, int v)
|
||||
{
|
||||
if (inputStatusDict == null)
|
||||
{
|
||||
inputStatusDict = new Dictionary<string, int>
|
||||
{
|
||||
{"CustomizeMin",3 },{"CustomizeS",3 }
|
||||
};
|
||||
}
|
||||
if (!inputStatusDict.ContainsKey(input.name)) return;
|
||||
//只要有一个select,enter 常亮 两个都exit,deselect 关掉
|
||||
inputStatusDict[input.name] = v;
|
||||
var bg = transform.Find("Main/Time/Inputbg").gameObject;
|
||||
if (inputStatusDict.Count(x=>x.Value == 1) > 0)
|
||||
{
|
||||
bg.GetComponent<Outline>().enabled = true;
|
||||
bg.GetComponent<Outline>().effectColor = Utils.HexToColorHtml("#6E6E7D");
|
||||
}
|
||||
else if (inputStatusDict.Count(x => x.Value == 2) > 0)
|
||||
{
|
||||
bg.GetComponent<Outline>().enabled = true;
|
||||
bg.GetComponent<Outline>().effectColor = Utils.HexToColorHtml("#f93086");
|
||||
}
|
||||
else if(inputStatusDict.Count(x => x.Value == 3) == 2)
|
||||
{
|
||||
bg.GetComponent<Outline>().enabled = false;
|
||||
}
|
||||
}
|
||||
public readonly Dictionary<int, List<double>> stdList = new Dictionary<int, List<double>>
|
||||
{
|
||||
{ 1,new List<double>() { 500,1000,2000,5000,10000 }},
|
||||
{ 2,new List<double>() { 1800 }}
|
||||
};
|
||||
private void InitAll(string igName = null)
|
||||
{
|
||||
foreach (var item in formList)
|
||||
{
|
||||
if (item is Button)
|
||||
{
|
||||
var btn = item as Button;
|
||||
if (btn.name == igName) continue;
|
||||
SetButtonColor(btn, false);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var i = item as PFUIInputField;
|
||||
if (i.name == igName) continue;
|
||||
i.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
private void InitValue()
|
||||
{
|
||||
foreach (var item in formList)
|
||||
{
|
||||
if (item is Button)
|
||||
{
|
||||
var btn = item as Button;
|
||||
var flag = (rowerType.type == 1 && string.Equals(rowerType.value.ToString(), btn.name.Replace("Btn", ""))) ||
|
||||
(rowerType.type == 2 && rowerType.value == 1800 && btn.name == "Btn30");
|
||||
SetButtonColor(btn, flag);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var i = item as PFUIInputField;
|
||||
i.Text = "";
|
||||
if (stdList.ContainsKey(rowerType.type) && !stdList[rowerType.type].Contains(rowerType.value))
|
||||
{
|
||||
if (rowerType.type == 1 && i.name == "Customize")
|
||||
{
|
||||
i.Text = rowerType.value.ToString();
|
||||
}
|
||||
else if (rowerType.type == 2)
|
||||
{
|
||||
var ts = TimeSpan.FromSeconds(rowerType.value);
|
||||
if (i.name == "CustomizeMin")
|
||||
{
|
||||
i.Text = ts.Minutes.ToString();
|
||||
}
|
||||
else if (i.name == "CustomizeS")
|
||||
{
|
||||
i.Text = ts.Seconds.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ClickDistanceBtn(Button btn, IEnumerable<Button> list)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
SetButtonColor(item, false);
|
||||
}
|
||||
if (btn)
|
||||
{
|
||||
SetButtonColor(btn, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetButtonColor(Button btn, bool flag)
|
||||
{
|
||||
SetTextColor(btn.gameObject, flag);
|
||||
btn.gameObject.GetComponent<Image>().color = flag ? Utils.HexToColorHtml("#f93086") : Utils.HexToColorHtml("#23232d");
|
||||
}
|
||||
|
||||
private void SetTextColor(GameObject btn, bool flag)
|
||||
{
|
||||
if (btn.transform.Find("t1"))
|
||||
{
|
||||
btn.transform.Find("t1").GetComponent<Text>().color = flag ? Utils.HexToColorHtml("#ffffff") : Utils.HexToColorHtml("#9E9EAD");
|
||||
}
|
||||
|
||||
if (btn.transform.Find("t2"))
|
||||
{
|
||||
btn.transform.Find("t2").GetComponent<Text>().color = flag ? Utils.HexToColorHtml("#ffffff") : Utils.HexToColorHtml("#9E9EAD");
|
||||
}
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11dfa3e099daeb942b6e8e105572548c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,109 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using UnityEngine.UI;
|
||||
using Assets.Scripts;
|
||||
//using ZenFulcrum.EmbeddedBrowser;
|
||||
|
||||
public class RowerTraceAnimated : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
Vector3? v1, v2, v3;
|
||||
void Start()
|
||||
{
|
||||
//print(v1.Value.ToString() + v2.Value.ToString() + v3.Value.ToString());
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
if (!v1.HasValue) v1 = transform.localPosition;
|
||||
if (!v2.HasValue) v2 = transform.Find("p1").localPosition;
|
||||
if (!v3.HasValue) v3 = transform.Find("p2").localPosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
/// <param name="callback"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public Sequence startAnimation(float time, TweenCallback callback, int type = 0)
|
||||
{
|
||||
//if (sq != null && sq.IsPlaying())
|
||||
//{
|
||||
// return null;
|
||||
//}
|
||||
Transform c = transform, c1 = c.Find("p1"), c2 = c.Find("p2");
|
||||
var rect = c.GetComponent<RectTransform>();
|
||||
|
||||
var dirOffset = 0f;
|
||||
if (type == 1) dirOffset = -1f * rect.sizeDelta.y;
|
||||
|
||||
var offset = rect.sizeDelta.y / 2;
|
||||
var sq = DOTween.Sequence();
|
||||
sq.AppendCallback(() =>
|
||||
{
|
||||
c2.localPosition = v3.Value + new Vector3(0, dirOffset, 0);
|
||||
c2.localRotation = Quaternion.Euler(new Vector3(type == 1 ? 270 : 90, 0, 0));
|
||||
c2.GetComponent<Image>().color = Utils.HexToColorHtml("#353543FF");
|
||||
callback();
|
||||
//print(c.localPosition.ToString() + c.Find("p1").localPosition.ToString() + c.Find("p2").localPosition.ToString());
|
||||
});
|
||||
var sq1 = DOTween.Sequence();
|
||||
sq1.Join(c2.GetComponent<Image>().DOFade(0, time));
|
||||
sq1.Join(c.DORotate(new Vector3(type == 1 ? 90 : -90, 0, 0), time));
|
||||
sq1.Join(c.DOLocalMoveY(v1.Value.y + (type == 0 ? -offset : offset), time));
|
||||
sq1.Join(c.DOLocalMoveZ(v1.Value.z + offset, time));
|
||||
//var sq2 = DOTween.Sequence();
|
||||
//sq2.Append(c.DOLocalMoveZ(v1.Value.z + offset*0.14f, time * 0.5f));
|
||||
//sq2.Append(c.DOLocalMoveZ(v1.Value.z + offset, time * 0.5f));
|
||||
//sq1.Join(sq2);
|
||||
sq.Append(sq1);
|
||||
sq.AppendCallback(() =>
|
||||
{
|
||||
var tmp = c1;
|
||||
c1 = c2;
|
||||
c2 = tmp;
|
||||
c1.name = "p1";
|
||||
c2.name = "p2";
|
||||
c.localPosition = v1.Value;
|
||||
c1.localPosition = v2.Value;
|
||||
c2.localPosition = v3.Value + new Vector3(0, dirOffset, 0);
|
||||
c.localRotation = Quaternion.Euler(Vector3.zero);
|
||||
c1.localRotation = Quaternion.Euler(Vector3.zero);
|
||||
c2.localRotation = Quaternion.Euler(new Vector3(type == 1 ? 270 : 90, 0, 0));
|
||||
});
|
||||
sq.Play();
|
||||
return sq;
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
//var c = transform.Find("Container");
|
||||
//int i = 1;
|
||||
//UIManager.AddEvent(transform.Find("Button").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
// {
|
||||
// var sq = DOTween.Sequence();
|
||||
// i++;
|
||||
// sq.AppendCallback(() =>
|
||||
// {
|
||||
// c.Find("p1").SetAsLastSibling();
|
||||
// c.Find(i % 2 == 0 ? "p2" : "p3").SetAsLastSibling();
|
||||
// });
|
||||
// sq.Join(c.DORotate(new Vector3(90 * (i % 2 == 0 ? -1 : 1), 0, 0), 1));
|
||||
// sq.Join(c.DOLocalMoveY(50 * (i % 2 == 0 ? -1 : 1), 1f));
|
||||
// sq.Append(c.DOLocalMoveZ(0, 0.5f));
|
||||
// sq.Append(c.DOLocalMoveZ(50, 0.5f));
|
||||
// sq.Play();
|
||||
// });
|
||||
|
||||
|
||||
//int i = 1;
|
||||
//UIManager.AddEvent(transform.Find("Button").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
//{
|
||||
|
||||
//});
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7400b2488409db4cad823eb13d103b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,186 +0,0 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Facebook.Unity;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RowerWelldone : PFUIPanel
|
||||
{
|
||||
[SerializeField]
|
||||
GameObject AllRecord, Record,Rank;
|
||||
Dictionary<string, Texture> caches;
|
||||
Transform rankContent, gradeContent;
|
||||
private Action initFunc;
|
||||
|
||||
public string id { get; private set; }
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
Debug.Log("well done show");
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
protected override void Awake()
|
||||
{
|
||||
caches = new Dictionary<string, Texture>();
|
||||
rankContent = transform.Find("Container/Left/Scroll View").GetComponent<ScrollRect>().content;
|
||||
gradeContent = transform.Find("Container/Right/Scroll View").GetComponent<ScrollRect>().content;
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("Container/BtnDefine").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
CloseModal();
|
||||
//UIManager.ShowHomePanel();
|
||||
//UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
UIManager.AddEvent(transform.Find("Container/BtnView").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
CloseModal();
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
UIManager.ShowActivityPanel($"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}");
|
||||
#else
|
||||
Application.OpenURL($"{App.websiteDict[App.Host]}rower/record/{id}?Token={App.CurrentUser.cookie}");
|
||||
#endif
|
||||
});
|
||||
UIManager.AddEvent(transform.Find("Container/Share/Wx").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
if (data == null) return;
|
||||
App.weChatController.ShareWebpageToWX(0, $"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}", $"我在{data.info.TypeStr}的划船比赛中获得第{data.info.MyRankLeft}名!赶紧来一起划船吧!", $"By {App.CurrentUser.Nickname}", null);
|
||||
});
|
||||
|
||||
UIManager.AddEvent(transform.Find("Container/Share/WxMoment").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
if (data == null) return;
|
||||
App.weChatController.ShareWebpageToWX(1, $"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}", $"我在{data.info.TypeStr}的划船比赛中获得第{data.info.MyRankLeft}名!赶紧来一起划船吧!", $"By {App.CurrentUser.Nickname}", null);
|
||||
});
|
||||
|
||||
UIManager.AddEvent(transform.Find("Container/Share/Fb").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
if (data == null) return;
|
||||
FB.ShareLink(contentURL: new Uri($"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}"),
|
||||
contentTitle: $"PowerFun {data.info.TypeStr} Rowing",
|
||||
contentDescription: $"By {App.CurrentUser.Nickname}");
|
||||
//App.weChatController.ShareWebpageToWX(1, , , , null);
|
||||
});
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.touchCount > 0)
|
||||
{
|
||||
startTime = false;
|
||||
transform.Find("Container/BtnDefine/Text").GetComponent<Text>().text = $"{App.GetLocalString("DEFINE")}";
|
||||
}
|
||||
if (startTime)
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
if (timer <= 0)
|
||||
{
|
||||
remainTime--;
|
||||
if (remainTime == 0)
|
||||
{
|
||||
CloseModal();
|
||||
return;
|
||||
}
|
||||
transform.Find("Container/BtnDefine/Text").GetComponent<Text>().text = $"{App.GetLocalString("DEFINE")}({remainTime.ToString("#0")})";
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float timer = 1f, remainTime = 10f;
|
||||
bool startTime = false;
|
||||
RowerSegmentData data;
|
||||
public async void Initial(string id,Action init)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id)) return;
|
||||
this.initFunc = init;
|
||||
this.id = id;
|
||||
var res = await ConfigHelper.rowerApi.GetSegmentDataAndRanking(id);
|
||||
if (res.result)
|
||||
{
|
||||
this.data = res.data;
|
||||
DisplayData(res.data, caches);
|
||||
startTime = true;
|
||||
remainTime = 30f;
|
||||
timer = 1f;
|
||||
transform.Find("Container/BtnDefine/Text").GetComponent<Text>().text = $"{App.GetLocalString("DEFINE")}({remainTime.ToString("#0")})";
|
||||
}
|
||||
}
|
||||
|
||||
private void DisplayData(RowerSegmentData data, Dictionary<string, Texture> caches)
|
||||
{
|
||||
rankContent.DestroyChildren();
|
||||
gradeContent.DestroyChildren();
|
||||
for (int i = 0; i < data.ranks.Count; i++)
|
||||
{
|
||||
var item = data.ranks[i];
|
||||
var game = Instantiate<GameObject>(Rank);
|
||||
game.transform.Find("Content/Rank").GetComponent<Text>().text = item.rankNum.ToString("00");
|
||||
game.transform.Find("Content/NickName").GetComponent<Text>().text = item.NickName;
|
||||
Utils.DisplayImageTempDict(game.transform.Find("Content/Avatar").GetComponent<RawImage>(), item.WxHeadImg, caches);
|
||||
if (item.GradeStr.Contains("DNF"))
|
||||
{
|
||||
game.transform.Find("Content/Time").GetComponent<Text>().text = "DNF";
|
||||
}
|
||||
else
|
||||
{
|
||||
game.transform.Find("Content/Time").GetComponent<Text>().text = data.info.Type == 1 ? TimeSpan.FromSeconds(item.Ticks).ToString(@"hh\:mm\:ss") : item.TotalDistance.ToString("#0M");
|
||||
}
|
||||
game.transform.SetParent(rankContent);
|
||||
game.transform.localScale = Vector3.one;
|
||||
game.SetActive(true);
|
||||
if (new Guid(item.Id) == new Guid(id))
|
||||
{
|
||||
game.transform.Find("Content/Rank").GetComponent<Text>().color = Utils.HexToColorHtml("#f93086");
|
||||
game.transform.Find("Content/NickName").GetComponent<Text>().color = Utils.HexToColorHtml("#f93086");
|
||||
game.transform.Find("Content/Time").GetComponent<Text>().color = Utils.HexToColorHtml("#f93086");
|
||||
}
|
||||
else
|
||||
{
|
||||
game.transform.Find("Content/Rank").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
game.transform.Find("Content/NickName").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
game.transform.Find("Content/Time").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < data.segmentList.Count; i++)
|
||||
{
|
||||
var item = data.segmentList[i];
|
||||
var game = i == 0 ? Instantiate<GameObject>(AllRecord) : Instantiate<GameObject>(Record);
|
||||
var content = i != 0 ? game.transform.Find("Content") : game.transform;
|
||||
content.Find("Index").GetComponent<Text>().text = i == 0 ? "ALL" : i.ToString("00");
|
||||
content.Find("Time").GetComponent<Text>().text = i == 0 ? TimeSpan.FromSeconds(item.Ticks).ToString(@"hh\:mm\:ss\.ff"): TimeSpan.FromSeconds(item.Ticks).ToString(@"hh\:mm\:ss");
|
||||
content.Find("Distance").GetComponent<Text>().text = item.Distance.ToString("#0");
|
||||
content.Find("500").GetComponent<Text>().text = TimeSpan.FromSeconds(item.Speed).ToString().Substring(3, 5);
|
||||
content.Find("Power").GetComponent<Text>().text = item.Power.ToString("#0");
|
||||
content.Find("HR").GetComponent<Text>().text = item.HeartRate.ToString("#0");
|
||||
content.Find("Count").GetComponent<Text>().text = item.StrokeCount.ToString("#0");
|
||||
content.Find("Carlories").GetComponent<Text>().text = item.Rate.ToString("#0");
|
||||
//game.transform.Find("Content/Rank").GetComponent<Text>().text = (i + 1).ToString("00");
|
||||
//game.transform.Find("Content/NickName").GetComponent<Text>().text = item.NickName;
|
||||
//Utils.DisplayImageTempDict(game.transform.Find("Content/Avatar").GetComponent<RawImage>(), item.WxHeadImg, caches);
|
||||
//game.transform.Find("Content/Time").GetComponent<Text>().text = data.info.Type == 1 ? TimeSpan.FromSeconds(item.Time).ToString() : item.TotalDistance.ToString("#0");
|
||||
game.transform.SetParent(gradeContent);
|
||||
game.transform.localScale = Vector3.one;
|
||||
game.SetActive(true);
|
||||
}
|
||||
transform.Find("Container/Left/MyRank").GetComponent<Text>().text = data.info.MyRank;
|
||||
transform.Find("Container/Right/Time").GetComponent<Text>().text = data.info.CreateTime;
|
||||
}
|
||||
|
||||
public void CloseModal()
|
||||
{
|
||||
startTime = false;
|
||||
if (initFunc != null)
|
||||
{
|
||||
initFunc.Invoke();
|
||||
}
|
||||
Close();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0932c4066cf3c24da73e66759aaec1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-113
@@ -323,117 +323,6 @@ public class UIManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
/*比赛列表*/
|
||||
/*划船机页面*/
|
||||
//自由滑
|
||||
private RowerHomeScript mRowerHomeScript;
|
||||
public RowerHomeScript RowerHomeScript
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPanelInstance("RowerPanel", ref this.mRowerHomeScript);
|
||||
}
|
||||
}
|
||||
public static void ShowRowerPanel(RowerResultModel r = null)
|
||||
{
|
||||
App.IsRowerMode = true;
|
||||
// App.MainDeviceAdapter.ClearDevice();
|
||||
//#if UNITY_ANDROID || UNITY_IOS
|
||||
// App.MainDeviceAdapter.StartScan();
|
||||
//#endif
|
||||
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);
|
||||
}
|
||||
//结束页
|
||||
private RowerWelldone mRowerWelldone;
|
||||
public RowerWelldone RowerWelldone
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPanelInstance("RowerWelldone", ref this.mRowerWelldone);
|
||||
}
|
||||
}
|
||||
public static void ShowRowerWelldone(string id, Action init)
|
||||
{
|
||||
Debug.Log("進入welldone");
|
||||
UIManager.Show(UIManager.Instance.RowerWelldone, null, true);
|
||||
if (UIManager.Instance.RowerWelldone)
|
||||
{
|
||||
UIManager.Instance.RowerWelldone.Initial(id,init);
|
||||
}
|
||||
}
|
||||
//结果页
|
||||
private RowerResult mRowerResult;
|
||||
public RowerResult RowerResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPanelInstance("RowerResult", ref this.mRowerResult);
|
||||
}
|
||||
}
|
||||
public static void ShowRowerResult(string id)
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.RowerResult, null, true);
|
||||
if (UIManager.Instance.RowerResult)
|
||||
{
|
||||
UIManager.Instance.RowerResult.Initial(id);
|
||||
}
|
||||
}
|
||||
private RowerSelector mRowerSelector;
|
||||
public RowerSelector RowerSelector
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPanelInstance("RowerSelector", ref this.mRowerSelector);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
/*划船机页面*/
|
||||
#region 新版划船机页面
|
||||
private RowerDevicePanel mRowerDevicePanel;
|
||||
public RowerDevicePanel RowerDevicePanel
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPanelInstance("RowerDevicePanel", ref this.mRowerDevicePanel);
|
||||
}
|
||||
}
|
||||
public static void ShowRowerDevicePanel()
|
||||
{
|
||||
//App.MainDeviceAdapter.StartScan();
|
||||
UIManager.Show(UIManager.Instance.RowerDevicePanel, null, true);
|
||||
}
|
||||
|
||||
private RowerTaskPanel mRowerTaskPanel;
|
||||
public RowerTaskPanel RowerTaskPanel
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPanelInstance("RowerTaskPanel", ref this.mRowerTaskPanel);
|
||||
}
|
||||
}
|
||||
public static void ShowRowerTaskPanel(Action<RowerTaskPanel.RowerType> callBack, RowerTaskPanel.RowerType type)
|
||||
{
|
||||
UIManager.Instance.RowerTaskPanel.rowerType = new RowerTaskPanel.RowerType() { value = type.value,type= type.type };
|
||||
UIManager.Instance.RowerTaskPanel.callBack = callBack;
|
||||
UIManager.Show(UIManager.Instance.RowerTaskPanel, null, true);
|
||||
}
|
||||
#endregion
|
||||
#region 新版路线页面
|
||||
private NewRouteOverviewController mNewRouteOverviewController;
|
||||
public NewRouteOverviewController NewRouteOverviewPanel
|
||||
@@ -458,6 +347,7 @@ public class UIManager : MonoBehaviour
|
||||
}
|
||||
public static void ShowNewRouteDetailPanel(int areaId,string coverImage)
|
||||
{
|
||||
App.CurrentRouteType = "";
|
||||
UIManager.Show(UIManager.Instance.NewRouteDetailPanel, UIManager.Instance.MainPanel);
|
||||
UIManager.Instance.NewRouteDetailPanel.GetComponent<NewRouteDetailController>().Initial(areaId, coverImage);
|
||||
}
|
||||
@@ -945,7 +835,6 @@ public class UIManager : MonoBehaviour
|
||||
// ShowNewHomePanel();
|
||||
// return;
|
||||
//#endif
|
||||
App.IsRowerMode = false;
|
||||
stack.Clear();
|
||||
UIManager.Instance.MainPanel.GetComponent<Image>().sprite =
|
||||
Resources.Load<Sprite>("Images/main-bg");
|
||||
@@ -954,7 +843,6 @@ public class UIManager : MonoBehaviour
|
||||
|
||||
public static void ShowNewHomePanel()
|
||||
{
|
||||
App.IsRowerMode = false;
|
||||
stack.Clear();
|
||||
UIManager.Instance.MainPanel.GetComponent<Image>().sprite =
|
||||
Resources.Load<Sprite>("Images/main-bg");
|
||||
|
||||
Reference in new issue
Block a user