forked from powerfun/udpservice
一些功能调整
增加tcp协议支持; 增加模拟多用户的功能;
This commit is contained in:
1 parent
e8b6418aa6
commit
0e931a3ac9
21 files changed
+890
-174
No files matched your search
+21
-3
@@ -1,4 +1,5 @@
|
||||
using Prism.Mvvm;
|
||||
using OnlineUserPool.Services;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
@@ -50,9 +51,26 @@ namespace OnlineUserPool.Model
|
||||
/// </summary>
|
||||
public List<int> ShowRouteId { get; set; }
|
||||
|
||||
///// <summary>
|
||||
///// 是否展示在线的人
|
||||
///// </summary>
|
||||
//public bool ShowVirtual { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否展示在线的人
|
||||
/// 客户端支持的消息格式的版本号
|
||||
/// </summary>
|
||||
public bool ShowVirtual { get; set; }
|
||||
public int V { get; set; }
|
||||
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public IService Service { get; set; }
|
||||
|
||||
|
||||
public String ServiceName
|
||||
{
|
||||
get
|
||||
{
|
||||
return Service.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using Newtonsoft.Json;
|
||||
using OnlineUserPool.Unility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OnlineUserPool.Model
|
||||
{
|
||||
public class MapDataModel
|
||||
{
|
||||
public string Type => "LineString";
|
||||
/// <summary>
|
||||
/// 总距离(km)
|
||||
/// </summary>
|
||||
public double TotalDistance { get; set; }
|
||||
|
||||
private List<Item> _List;
|
||||
public List<Item> List
|
||||
{
|
||||
get
|
||||
{
|
||||
return _List;
|
||||
}
|
||||
set
|
||||
{
|
||||
_List = value;
|
||||
if (_List == null) return;
|
||||
this.CalcDistance();
|
||||
this.CalcGrade();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void CalcDistance()
|
||||
{
|
||||
for (int i = 0; i < _List.Count - 1; i++)
|
||||
{
|
||||
var value = CommonHelper.GetDistances(_List[i].Point[1], _List[i].Point[0], _List[i + 1].Point[1], _List[i + 1].Point[0]);
|
||||
//var value = Turf.Distance(pt1, pt2, "kilometers") * 1000;
|
||||
_List[i].Distance = Math.Round(value, 2);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算坡度数据
|
||||
/// </summary>
|
||||
private void CalcGrade()
|
||||
{
|
||||
for (int i = 0; i < this._List.Count - 1; i++)
|
||||
{
|
||||
var a = _List[i + 1].Elevation - _List[i].Elevation;
|
||||
if (a == 0)
|
||||
{
|
||||
//grade.Add(0);
|
||||
_List[i].Grade = 0;
|
||||
continue;
|
||||
}
|
||||
//勾股定理
|
||||
var c = _List[i].Distance;//如果车停了下来,c为0
|
||||
if (c == 0 && i > 0)
|
||||
{
|
||||
_List[i].Grade = _List[i - 1].Grade;
|
||||
}
|
||||
else
|
||||
{
|
||||
var b = Math.Sqrt(c * c - a * a);
|
||||
if (b == 0)//如果b等于,这就是垂直的墙壁
|
||||
{
|
||||
_List[i].Grade = _List[i - 1].Grade;
|
||||
}
|
||||
else
|
||||
{
|
||||
_List[i].Grade = Math.Round(a / b * 100, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MapDataModel()
|
||||
{
|
||||
//_List = new List<Item>();
|
||||
}
|
||||
|
||||
public class Item
|
||||
{
|
||||
/// <summary>
|
||||
/// 坐标(lat,lon)
|
||||
/// </summary>
|
||||
public double[] Point { get; set; }
|
||||
/// <summary>
|
||||
/// 距离(单位米)
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public double Distance { get; set; }
|
||||
/// <summary>
|
||||
/// 海拔m
|
||||
/// </summary>
|
||||
public double Elevation { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public double Grade { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-2
@@ -25,13 +25,13 @@ namespace OnlineUserPool.Model
|
||||
/// <summary>
|
||||
/// 是否展示在线的人
|
||||
/// </summary>
|
||||
public bool ShowVirtual { get; set; }
|
||||
//public bool ShowVirtual { get; set; }
|
||||
/// <summary>
|
||||
/// 命令类型,0命令,1消息
|
||||
/// </summary>
|
||||
public byte CommandType { get; set; }
|
||||
|
||||
public bool IsVirtual { get; set; }
|
||||
//public bool IsVirtual { get; set; }
|
||||
|
||||
//public double Power { get; set; }
|
||||
//public double Weight { get; set; }
|
||||
@@ -43,5 +43,15 @@ namespace OnlineUserPool.Model
|
||||
public int Competitionid { get; set; }
|
||||
|
||||
public bool Saved { get; set; }
|
||||
/// <summary>
|
||||
/// 能处理的消息格式的版本号
|
||||
/// </summary>
|
||||
public int V { get; set; }
|
||||
|
||||
|
||||
public string ToString(int v)
|
||||
{
|
||||
return $"{ RouteId },{ MemberId },{ string.Join(":", Point) },{ Convert.ToInt32(IsCompleted) },{ Speed },{ PreDistance },{ EndDistance },{ WeightKg },{ Competitionid },{ Convert.ToInt32(Saved) }";
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -46,7 +46,11 @@ namespace OnlineUserPool.Model
|
||||
target._Speed = double.Parse(split[2]);
|
||||
target._Distance = double.Parse(split[3]);
|
||||
target._Cadence = double.Parse(split[4]);
|
||||
target._HeartRate = int.Parse(split[5]);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(split[5]) && split[5] != "null")
|
||||
{
|
||||
target._HeartRate = int.Parse(split[5]);
|
||||
}
|
||||
if (split.Length > 6)
|
||||
{
|
||||
target._Lat = double.Parse(split[6]);
|
||||
|
||||
Reference in new issue
Block a user