2021-05-19 14:38:48 +08:00
|
|
|
|
using Assets.Scripts.Devices.Ant;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Assets.Scripts.Devices
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract class AbstractDevice
|
|
|
|
|
|
{
|
|
|
|
|
|
public virtual DeviceState State { get; set; } = DeviceState.Disconnected;
|
|
|
|
|
|
|
|
|
|
|
|
public SensorType Sensor { get; protected set; }
|
|
|
|
|
|
|
2021-06-04 18:28:11 +08:00
|
|
|
|
public string Id
|
|
|
|
|
|
{
|
|
|
|
|
|
get; protected set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-05-19 14:38:48 +08:00
|
|
|
|
public virtual string Name
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
protected set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual ushort DeviceNumber { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public virtual int Priority
|
|
|
|
|
|
{
|
|
|
|
|
|
get; protected set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-06-04 10:35:58 +08:00
|
|
|
|
public NetworkType Network { get; internal set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 信号强度
|
|
|
|
|
|
/// 信号从0dbm~97dbm,个人建议是0~30是强,30~70是中,70~97是弱。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int SignalStrength { get; internal set; }
|
|
|
|
|
|
|
2022-06-09 14:51:03 +08:00
|
|
|
|
public DateTime LastActiveTime { get; internal set; }
|
|
|
|
|
|
|
|
|
|
|
|
public string ErrorMsg { get; internal set; }
|
|
|
|
|
|
|
2021-06-04 18:28:11 +08:00
|
|
|
|
protected AbstractDevice(string id, NetworkType networkType)
|
2021-06-04 10:35:58 +08:00
|
|
|
|
{
|
2021-06-04 18:28:11 +08:00
|
|
|
|
this.Id = id;
|
2021-06-04 10:35:58 +08:00
|
|
|
|
this.Network = networkType;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-09 14:51:03 +08:00
|
|
|
|
public abstract void Connect(Action<string> callback = null);
|
2021-05-19 14:38:48 +08:00
|
|
|
|
|
|
|
|
|
|
public abstract void Disconnect(bool save = true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|