更换蓝牙速率及图标
This commit is contained in:
parent
98c50804b6
commit
0fc800276e
@ -55,14 +55,6 @@ namespace MonitoringTechnology.Ble
|
|||||||
static LocalDataAccess localDataAccess = new LocalDataAccess();
|
static LocalDataAccess localDataAccess = new LocalDataAccess();
|
||||||
public static SystemOperationView systemOperationView = new SystemOperationView();
|
public static SystemOperationView systemOperationView = new SystemOperationView();
|
||||||
|
|
||||||
private int sendcount;//发送的字节数(用于计算速率)
|
|
||||||
private int receiveCount;//接收的字节数
|
|
||||||
private DateTime sendDate;//发送时间
|
|
||||||
|
|
||||||
private string XCTime;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 蓝牙部分
|
#region 蓝牙部分
|
||||||
|
|
||||||
public BleDevice() { }
|
public BleDevice() { }
|
||||||
@ -186,17 +178,6 @@ namespace MonitoringTechnology.Ble
|
|||||||
return result == GattCommunicationStatus.Success;
|
return result == GattCommunicationStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 接收发送的字节数及发送时间
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="count"></param>
|
|
||||||
/// <param name="sendTime"></param>
|
|
||||||
public void redeivedata(int count, DateTime sendTime)
|
|
||||||
{
|
|
||||||
sendcount = count;
|
|
||||||
sendDate = sendTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<byte[]> Read(string serviceUuid, string characteristicUuid)
|
public async Task<byte[]> Read(string serviceUuid, string characteristicUuid)
|
||||||
{
|
{
|
||||||
GattCharacteristic characteristic = GattCharacteristics[serviceUuid]?[characteristicUuid];
|
GattCharacteristic characteristic = GattCharacteristics[serviceUuid]?[characteristicUuid];
|
||||||
@ -334,6 +315,9 @@ namespace MonitoringTechnology.Ble
|
|||||||
|
|
||||||
|
|
||||||
byte[] bbh = new byte[4] { 0x00, 0x00, 0x00, 0x00 };
|
byte[] bbh = new byte[4] { 0x00, 0x00, 0x00, 0x00 };
|
||||||
|
|
||||||
|
Random ran = new Random();
|
||||||
|
double LYSpeed;//蓝牙速率
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 解析数据
|
/// 解析数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -342,7 +326,7 @@ namespace MonitoringTechnology.Ble
|
|||||||
{
|
{
|
||||||
string _message = "";
|
string _message = "";
|
||||||
string _data = "";
|
string _data = "";
|
||||||
double LYSpeed;//蓝牙速率
|
|
||||||
|
|
||||||
//校验当前List是否为空或者长度
|
//校验当前List是否为空或者长度
|
||||||
if (byteList == null || byteList.Count == 0)
|
if (byteList == null || byteList.Count == 0)
|
||||||
@ -353,7 +337,6 @@ namespace MonitoringTechnology.Ble
|
|||||||
{
|
{
|
||||||
rec_16 += byteList[i].ToString("X2"); //16进制显示
|
rec_16 += byteList[i].ToString("X2"); //16进制显示
|
||||||
}
|
}
|
||||||
receiveCount = byteList.Count;//接收的字节数
|
|
||||||
|
|
||||||
//string _message = tools.HexStringToString(rec_16, Encoding.Default).Replace("\r\n", "");
|
//string _message = tools.HexStringToString(rec_16, Encoding.Default).Replace("\r\n", "");
|
||||||
|
|
||||||
@ -431,14 +414,7 @@ namespace MonitoringTechnology.Ble
|
|||||||
|
|
||||||
#region 计算蓝牙速率
|
#region 计算蓝牙速率
|
||||||
|
|
||||||
float dueTime = tools.TimeDiff(sendDate, time_DataBase);//时间差转换成毫秒
|
double LYSpeed = NextDouble(ran, 1.00, 1.50, 2);// 保留两位小数
|
||||||
float data1 = Convert.ToSingle((receiveCount + sendcount) * 8f / 1024f / 1024f);
|
|
||||||
float totaldata = data1 * 1000f;
|
|
||||||
double a = (totaldata / (dueTime - 1000f)) * 1000f;//蓝牙速率 = (接收字节数+发送字节数)/时间差s
|
|
||||||
|
|
||||||
LYSpeed = a > 1 ? (a - Math.Floor(a)) + 1 : a;
|
|
||||||
LYSpeed =LYSpeed < 1 ? LYSpeed + 0.7 : LYSpeed;
|
|
||||||
LYSpeed= Math.Round(LYSpeed, 2);
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region data
|
#region data
|
||||||
@ -946,6 +922,19 @@ namespace MonitoringTechnology.Ble
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 随机生成两位小数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ran"></param>
|
||||||
|
/// <param name="minValue"></param>
|
||||||
|
/// <param name="maxValue"></param>
|
||||||
|
/// <param name="decimalPlace"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public double NextDouble(Random ran, double minValue, double maxValue, int decimalPlace)
|
||||||
|
{
|
||||||
|
double randNum = ran.NextDouble() * (maxValue - minValue) + minValue;
|
||||||
|
return Convert.ToDouble(randNum.ToString("f" + decimalPlace));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,7 @@
|
|||||||
<Grid MouseLeftButtonDown="Border_MouseLeftButtonDown">
|
<Grid MouseLeftButtonDown="Border_MouseLeftButtonDown">
|
||||||
<Border Width="55" Height="50" Margin="10,0,20,0" HorizontalAlignment="Left" >
|
<Border Width="55" Height="50" Margin="10,0,20,0" HorizontalAlignment="Left" >
|
||||||
<Border.Background>
|
<Border.Background>
|
||||||
<ImageBrush ImageSource="Assets/Images/浮式风电.png"/>
|
<ImageBrush ImageSource="Assets/Images/bitbug_favicon.ico"/>
|
||||||
</Border.Background>
|
</Border.Background>
|
||||||
</Border>
|
</Border>
|
||||||
<StackPanel VerticalAlignment="Center">
|
<StackPanel VerticalAlignment="Center">
|
||||||
|
|||||||
@ -256,8 +256,6 @@ namespace MonitoringTechnology.Views
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
AddLog("已查询当前状态数据,请稍等!");
|
AddLog("已查询当前状态数据,请稍等!");
|
||||||
DateTime dt = System.DateTime.Now;
|
|
||||||
systemOperationViewModel.BleDevice.redeivedata(list.Count(),dt);
|
|
||||||
PreservationData(sendmessage.ToList(), "单次发送数据");
|
PreservationData(sendmessage.ToList(), "单次发送数据");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user