内存优化

This commit is contained in:
lishuo committed 2024-01-24 15:23:28 +08:00
1 parent 8f0845faaa
commit b07be239fd
6 files changed
+368 -202

No files matched your search

+133 -25
View File
@@ -1,31 +1,85 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System;
namespace OnlineUserPool.Model
{
public class MsgModel : ReceiveModel
{
public int RouteId { get; set; }
public int MemberId { get; set; }
public double[] Point { get; set; }
public bool IsCompleted { get; set; }
private int _RouteId = 0;
public int RouteId {
get {
return _RouteId;
}
set {
SetProperty(ref _RouteId, value);
}
}
public bool exit = false;
public double Speed { get; set; }
public double HeartRate { get; set; }
public double Power { get; set; }
public double Cadence { get; set; }
public int TotalTicks { get; set; }
private int _MemberId = 0;
public int MemberId {
get => _MemberId;
set => SetProperty(ref _MemberId, value);
}
public double[] Point { get; set; }
private bool _IsCompleted;
public bool IsCompleted {
get => _IsCompleted;
set => SetProperty(ref _IsCompleted, value);
}
private bool _exit;
public bool Exit {
get => _exit;
set => SetProperty(ref _exit, value);
}
private double _Speed = 0;
public double Speed {
get => _Speed;
set => SetProperty(ref _Speed, value);
}
private double _HeartRate = 0;
public double HeartRate {
get => _HeartRate;
set => SetProperty(ref _HeartRate, value);
}
private double _Power = 0;
public double Power {
get => _Power;
set => SetProperty(ref _Power, value);
}
private double _Cadence = 0;
public double Cadence {
get => _Cadence;
set => SetProperty(ref _Cadence, value);
}
private int _TotalTicks = 0;
public int TotalTicks {
get => _TotalTicks;
set => SetProperty(ref _TotalTicks, value);
}
///// <summary>
///// 需要展示的属性
///// </summary>
//public string Prop { get; set; }
public double PreDistance { get; set; }
private double _PreDistance = 0;
public double PreDistance {
get => _PreDistance;
set => SetProperty(ref _PreDistance, value);
}
public double EndDistance { get; set; }
private double _EndDistance = 0;
public double EndDistance {
get => _EndDistance;
set => SetProperty(ref _EndDistance, value);
}
//public bool IsVirtual { get; set; }
@@ -34,30 +88,84 @@ namespace OnlineUserPool.Model
/// <summary>
/// 功率体重比
/// </summary>
public double WeightKg { get; set; }
private double _WeightKg = 0;
public double WeightKg {
get => _WeightKg;
set => SetProperty(ref _WeightKg, value);
}
public int Competitionid { get; set; }
private int _CompetitionId = 0;
public int CompetitionId {
get => _CompetitionId;
set => SetProperty(ref _CompetitionId, value);
}
public bool Saved { get; set; }
private bool _Saved ;
public bool Saved {
get => _Saved;
set => SetProperty(ref _Saved, value);
}
//public bool ShowVirtual { get; set; }
public int FrameRate { get; set; }
public int RoomId { get; set; }
private int _FrameRate = 0;
public int FrameRate {
get => _FrameRate;
set => SetProperty(ref _FrameRate, value);
}
private int _RoomId = 0;
public int RoomId {
get => _RoomId;
set => SetProperty(ref _RoomId, value);
}
public DateTime? StartTime { get; set; }
public string Request { get; set; }
private string _Request;
public string Request {
get => _Request;
set => SetProperty(ref _Request, value);
}
public string Model { get; set; }
private string _Model;
public string Model {
get => _Model;
set => SetProperty(ref _Model, value);
}
public string ToString(int v)
{
if (v == 2)
{
return $"{ RouteId },{ MemberId },{ string.Join(":", Point) },{ Convert.ToInt32(IsCompleted) },{ Speed },{ PreDistance },{ EndDistance },{ WeightKg },{ Competitionid },{ Convert.ToInt32(Saved)},{ Power} ,{ HeartRate},{ Cadence},{ TotalTicks},{ FrameRate},{RoomId},{StartTime}";
return $"{ RouteId },{ MemberId },{ string.Join(":", Point) },{ Convert.ToInt32(IsCompleted) },{ Speed },{ PreDistance },{ EndDistance },{ WeightKg },{ CompetitionId },{ Convert.ToInt32(Saved)},{ Power} ,{ HeartRate},{ Cadence},{ TotalTicks},{ FrameRate},{RoomId},{StartTime}";
}
return $"{ RouteId },{ MemberId },{ string.Join(":", Point) },{ Convert.ToInt32(IsCompleted) },{ Speed },{ PreDistance },{ EndDistance },{ WeightKg },{ Competitionid },{ Convert.ToInt32(Saved)}";
return $"{ RouteId },{ MemberId },{ string.Join(":", Point) },{ Convert.ToInt32(IsCompleted) },{ Speed },{ PreDistance },{ EndDistance },{ WeightKg },{ CompetitionId },{ Convert.ToInt32(Saved)}";
}
public void Update(MsgModel model)
{
this.CompetitionId = model.CompetitionId;
this.EndDistance = model.EndDistance;
this.HeartRate = model.HeartRate;
this.IsCompleted = model.IsCompleted;
this.MemberId = model.MemberId;
this.Point = model.Point;
this.PreDistance = model.PreDistance;
this.RouteId = model.RouteId;
this.Speed = model.Speed;
this.WeightKg = model.WeightKg;
this.Saved = model.Saved;
this.HeartRate = model.HeartRate;
this.Cadence = model.Cadence;
this.TotalTicks = model.TotalTicks;
this.FrameRate = model.FrameRate;
this.RoomId = model.RoomId;
this.StartTime = model.StartTime;
this.Request = model.Request;
this.Power = model.Power;
this.Exit = model.Exit;
this.Model = model.Model;
}
}
}
+2 -1
View File
@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
using Prism.Mvvm;
namespace OnlineUserPool.Model
{
public class ReceiveModel
public class ReceiveModel : BindableBase
{
/// <summary>
/// 命令类型,0ping命令,1消息, 2设置客户端信息, 3观察者模式
+12 -11
View File
@@ -44,31 +44,32 @@ namespace OnlineUserPool.Model
return string.Format($"{Ticks},{_Power},{_Speed},{_Distance},{_Cadence},{_HeartRate},{_Lat},{_Lon},{_Bearing}");
}
private static TargetData _target = new TargetData();
public static TargetData Read(string data)
{
string[] split = data.Split(',');
var target = new TargetData();
target.Ticks = int.Parse(split[0]);
target._Power = double.Parse(split[1]);
target._Speed = double.Parse(split[2]);
target._Distance = double.Parse(split[3]);
target._Cadence = double.Parse(split[4]);
_target.Ticks = int.Parse(split[0]);
_target._Power = double.Parse(split[1]);
_target._Speed = double.Parse(split[2]);
_target._Distance = double.Parse(split[3]);
_target._Cadence = double.Parse(split[4]);
if (!string.IsNullOrWhiteSpace(split[5]) && split[5] != "null")
{
target._HeartRate = int.Parse(split[5]);
_target._HeartRate = int.Parse(split[5]);
}
if (split.Length > 6)
{
target._Lat = double.Parse(split[6]);
target._Lon = double.Parse(split[7]);
_target._Lat = double.Parse(split[6]);
_target._Lon = double.Parse(split[7]);
if (split.Length >= 9)
{
target._Bearing = double.Parse(split[8]);
_target._Bearing = double.Parse(split[8]);
}
}
return target;
return _target;
}
}
}