42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using Assets.Scripts.Devices.Ant.Pages.CalibrationPages;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Assets.Scripts.Devices.Ant.Pages
|
|
{
|
|
/// <summary>
|
|
/// 设备校准的处理函数
|
|
/// </summary>
|
|
public class CalibrationPageHandler : IPageHandler
|
|
{
|
|
private readonly IList<ICalibrationPage> _calibrationPageHandlers = new List<ICalibrationPage>()
|
|
{
|
|
new CtfCalibrationPage(),
|
|
new FecCalibrationPage(),
|
|
new FailureCalibrationPage(),
|
|
new SuccessCalibrationPage()
|
|
};
|
|
|
|
public bool CanHandle(byte pageNumber)
|
|
{
|
|
if ((int)pageNumber != 1)
|
|
{
|
|
return (int)pageNumber == 240;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public void Handle(byte[] dataPayload, AbstractAntDevice device)
|
|
{
|
|
var calibrationPage = this._calibrationPageHandlers.FirstOrDefault(ph => ph.CanHandle(dataPayload[1]));
|
|
if (calibrationPage == null)
|
|
return;
|
|
calibrationPage.Handle(dataPayload, device);
|
|
}
|
|
}
|
|
}
|