实现连接设备界面

This commit is contained in:
suntao committed 2021-04-01 11:09:53 +08:00
1 parent 996f924719
commit ec7589096f
88 files changed
+11344 -156

No files matched your search

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Devices.Ant.Pages
{
public class CrankPowerPageHandler : IPageHandler
{
private readonly TorquePowerDataCalculator _torquePowerDataCalculator = new TorquePowerDataCalculator();
public bool CanHandle(byte pageNumber)
{
return (int)pageNumber == 18;
}
public void Handle(byte[] dataPayload, AbstractAntDevice device)
{
var powerDevice = device as PowerDevice;
if (powerDevice == null)
return;
byte eventCount = dataPayload[1];
int num = (int)dataPayload[3];
ushort period = (ushort)((uint)dataPayload[4] | (uint)dataPayload[5] << 8);
ushort accumulatedTorque = (ushort)(dataPayload[6] | (uint)dataPayload[7] << 8);
this._torquePowerDataCalculator.Update(eventCount, period, accumulatedTorque);
//powerDevice.UpdateCadence(new int?(this._torquePowerDataCalculator.Rpm));
//powerDevice.UpdatePower(new int?(this._torquePowerDataCalculator.Power));
powerDevice.Cadence = this._torquePowerDataCalculator.Rpm;
powerDevice.Power = this._torquePowerDataCalculator.Power;
}
}
}