423 lines
14 KiB
C#
423 lines
14 KiB
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using static AgroBase.Models.Enums;
|
|
|
|
namespace AgroBase.Models.Operadores
|
|
{
|
|
public class WeedWorkerModel
|
|
{
|
|
public bool Iniciado { get; set; }
|
|
public DateTime IniciadoEm { get; set; }
|
|
public bool Pronto { get; set; }
|
|
public DateTime ProntoEm { get; set; }
|
|
public DateTime UltimaMensagem { get; set; }
|
|
[JsonIgnore]
|
|
public Dictionary<TipoFrameCamera, OAKCameraFrameModel> CameraFrames { get; set; } = new Dictionary<TipoFrameCamera, OAKCameraFrameModel>();
|
|
public WeedWorkerAnaliseModel Analise { get; set; } = new WeedWorkerAnaliseModel();
|
|
public OAKImuModel Imu { get; set; } = new OAKImuModel();
|
|
public WeedWorkerPerformanceModel Performance { get; set; } = new WeedWorkerPerformanceModel();
|
|
public WeedWorkerAnaliseMetricasModel MetricasAnalise { get; set; } = new WeedWorkerAnaliseMetricasModel();
|
|
public WeedWorkerRedisTimestampsModel Timestamps { get; set; } = new WeedWorkerRedisTimestampsModel();
|
|
|
|
|
|
public WeedWorkerModel Clone()
|
|
{
|
|
return new WeedWorkerModel
|
|
{
|
|
Iniciado = Iniciado,
|
|
IniciadoEm = IniciadoEm,
|
|
Pronto = Pronto,
|
|
ProntoEm = ProntoEm,
|
|
UltimaMensagem = UltimaMensagem,
|
|
|
|
Imu = Imu?.Clone(),
|
|
|
|
Analise = Analise?.Clone()
|
|
?? new WeedWorkerAnaliseModel(),
|
|
|
|
MetricasAnalise = MetricasAnalise?.Clone()
|
|
?? new WeedWorkerAnaliseMetricasModel(),
|
|
|
|
Performance = Performance?.Clone()
|
|
?? new WeedWorkerPerformanceModel(),
|
|
|
|
Timestamps = Timestamps?.Clone()
|
|
?? new WeedWorkerRedisTimestampsModel()
|
|
};
|
|
}
|
|
|
|
public void ReiniciarEstado()
|
|
{
|
|
Iniciado = false;
|
|
IniciadoEm = DateTime.MinValue;
|
|
|
|
Pronto = false;
|
|
ProntoEm = DateTime.MinValue;
|
|
|
|
UltimaMensagem = DateTime.MinValue;
|
|
|
|
CameraFrames =
|
|
new Dictionary<TipoFrameCamera, OAKCameraFrameModel>();
|
|
|
|
Analise = new WeedWorkerAnaliseModel();
|
|
Imu = new OAKImuModel();
|
|
MetricasAnalise = new WeedWorkerAnaliseMetricasModel();
|
|
Performance = new WeedWorkerPerformanceModel();
|
|
Timestamps = new WeedWorkerRedisTimestampsModel();
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerAnaliseMetricasModel
|
|
{
|
|
public double ts_analise { get; set; }
|
|
|
|
public double fps_model { get; set; }
|
|
public double fps_inferencia { get; set; }
|
|
|
|
public double infer_ms { get; set; }
|
|
public double infer_gpu_ms { get; set; }
|
|
|
|
public WeedWorkerAnaliseMetricasModel Clone()
|
|
{
|
|
return (WeedWorkerAnaliseMetricasModel)MemberwiseClone();
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerAnaliseEnvelopeModel
|
|
{
|
|
public double ts_analise { get; set; }
|
|
|
|
public double fps_model { get; set; }
|
|
public double fps_inferencia { get; set; }
|
|
|
|
public double infer_ms { get; set; }
|
|
public double infer_gpu_ms { get; set; }
|
|
|
|
public WeedWorkerAnaliseModel analise { get; set; }
|
|
= new WeedWorkerAnaliseModel();
|
|
|
|
[JsonExtensionData]
|
|
public IDictionary<string, JToken> Extra { get; set; }
|
|
= new Dictionary<string, JToken>();
|
|
|
|
public WeedWorkerAnaliseEnvelopeModel Clone()
|
|
{
|
|
return new WeedWorkerAnaliseEnvelopeModel
|
|
{
|
|
ts_analise = ts_analise,
|
|
fps_model = fps_model,
|
|
fps_inferencia = fps_inferencia,
|
|
infer_ms = infer_ms,
|
|
infer_gpu_ms = infer_gpu_ms,
|
|
|
|
analise = analise?.Clone()
|
|
?? new WeedWorkerAnaliseModel(),
|
|
|
|
Extra = Extra?.ToDictionary(
|
|
x => x.Key,
|
|
x => x.Value?.DeepClone()
|
|
) ?? new Dictionary<string, JToken>()
|
|
};
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerAnaliseModel
|
|
{
|
|
public DateTime Timestamp
|
|
{
|
|
get
|
|
{
|
|
return FuncoesGlobais.UnixToDateTime(timestamp.ToString());
|
|
}
|
|
}
|
|
public double timestamp { get; set; }
|
|
public int height { get; set; }
|
|
public int width { get; set; }
|
|
public Dictionary<int, bool> controle { get; set; } = new Dictionary<int, bool>();
|
|
public bool ervas_no_radar { get; set; }
|
|
public double fracao_ervas_no_radar { get; set; }
|
|
public double percentual_ervas_no_radar { get; set; }
|
|
public WeedWorkerAnaliseEstatisticasModel estatisticas { get; set; } = new WeedWorkerAnaliseEstatisticasModel();
|
|
|
|
public WeedWorkerAnaliseModel Clone()
|
|
{
|
|
return new WeedWorkerAnaliseModel()
|
|
{
|
|
timestamp = timestamp,
|
|
controle = new Dictionary<int, bool>(controle ?? new Dictionary<int, bool>()),
|
|
height = height,
|
|
width = width,
|
|
ervas_no_radar = ervas_no_radar,
|
|
fracao_ervas_no_radar = fracao_ervas_no_radar,
|
|
percentual_ervas_no_radar = percentual_ervas_no_radar,
|
|
estatisticas = estatisticas?.Clone()
|
|
};
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerAnaliseEstatisticasModel
|
|
{
|
|
public WeedWorkerAnaliseEstatisticasErvasModel erva { get; set; } = new WeedWorkerAnaliseEstatisticasErvasModel();
|
|
public WeedWorkerAnaliseEstatisticasBicosModel bicos { get; set; } = new WeedWorkerAnaliseEstatisticasBicosModel();
|
|
|
|
public WeedWorkerAnaliseEstatisticasModel Clone()
|
|
{
|
|
return new WeedWorkerAnaliseEstatisticasModel()
|
|
{
|
|
erva = erva?.Clone(),
|
|
bicos = bicos?.Clone()
|
|
};
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerAnaliseEstatisticasErvasModel
|
|
{
|
|
public double frac_global { get; set; }
|
|
public double ema_global { get; set; }
|
|
public double thr_on_global { get; set; }
|
|
public double thr_off_global { get; set; }
|
|
public double vel_adj { get; set; }
|
|
|
|
public WeedWorkerAnaliseEstatisticasErvasModel Clone()
|
|
{
|
|
return new WeedWorkerAnaliseEstatisticasErvasModel()
|
|
{
|
|
ema_global = ema_global,
|
|
frac_global = frac_global,
|
|
thr_off_global = thr_off_global,
|
|
thr_on_global = thr_on_global,
|
|
vel_adj = vel_adj,
|
|
};
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerAnaliseEstatisticasBicosModel
|
|
{
|
|
public string motivo { get; set; }
|
|
|
|
public List<double> frac_erva_por_bico { get; set; }
|
|
= new List<double>();
|
|
|
|
public List<double> ema_frac_por_bico { get; set; }
|
|
= new List<double>();
|
|
|
|
public WeedWorkerAnaliseEstatisticasBicosFaixaModel faixa { get; set; }
|
|
= new WeedWorkerAnaliseEstatisticasBicosFaixaModel();
|
|
|
|
public List<double> larguras { get; set; }
|
|
= new List<double>();
|
|
|
|
public int shift_px { get; set; }
|
|
|
|
public double thr_on_eff { get; set; }
|
|
public double thr_off_eff { get; set; }
|
|
|
|
public List<int> on_cnt { get; set; }
|
|
= new List<int>();
|
|
|
|
public List<int> off_cnt { get; set; }
|
|
= new List<int>();
|
|
|
|
public List<bool> estado_bico { get; set; }
|
|
= new List<bool>();
|
|
|
|
[JsonExtensionData]
|
|
public IDictionary<string, JToken> Extra { get; set; }
|
|
= new Dictionary<string, JToken>();
|
|
|
|
public WeedWorkerAnaliseEstatisticasBicosModel Clone()
|
|
{
|
|
return new WeedWorkerAnaliseEstatisticasBicosModel
|
|
{
|
|
motivo = motivo,
|
|
frac_erva_por_bico =
|
|
new List<double>(frac_erva_por_bico ?? new List<double>()),
|
|
ema_frac_por_bico =
|
|
new List<double>(ema_frac_por_bico ?? new List<double>()),
|
|
faixa = faixa?.Clone()
|
|
?? new WeedWorkerAnaliseEstatisticasBicosFaixaModel(),
|
|
larguras =
|
|
new List<double>(larguras ?? new List<double>()),
|
|
shift_px = shift_px,
|
|
thr_on_eff = thr_on_eff,
|
|
thr_off_eff = thr_off_eff,
|
|
on_cnt = new List<int>(on_cnt ?? new List<int>()),
|
|
off_cnt = new List<int>(off_cnt ?? new List<int>()),
|
|
estado_bico =
|
|
new List<bool>(estado_bico ?? new List<bool>()),
|
|
Extra = Extra?.ToDictionary(
|
|
x => x.Key,
|
|
x => x.Value?.DeepClone()
|
|
) ?? new Dictionary<string, JToken>()
|
|
};
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerAnaliseEstatisticasBicosFaixaModel
|
|
{
|
|
public int y_top { get; set; }
|
|
public int y_bot { get; set; }
|
|
|
|
public WeedWorkerAnaliseEstatisticasBicosFaixaModel Clone()
|
|
{
|
|
return new WeedWorkerAnaliseEstatisticasBicosFaixaModel()
|
|
{
|
|
y_bot = y_bot,
|
|
y_top = y_top,
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
public class WeedWorkerPerformanceModel
|
|
{
|
|
public double timestamp { get; set; }
|
|
|
|
public Dictionary<string, WeedWorkerPerformanceLoopModel> loops { get; set; }
|
|
= new Dictionary<string, WeedWorkerPerformanceLoopModel>();
|
|
|
|
public JObject sync { get; set; } = new JObject();
|
|
|
|
public WeedWorkerPerformanceCacheModel weed_cache { get; set; }
|
|
= new WeedWorkerPerformanceCacheModel();
|
|
|
|
public WeedWorkerPerformancePublicacaoModel pub_debug { get; set; }
|
|
= new WeedWorkerPerformancePublicacaoModel();
|
|
|
|
public JObject contadores { get; set; } = new JObject();
|
|
|
|
[JsonExtensionData]
|
|
public IDictionary<string, JToken> Extra { get; set; }
|
|
= new Dictionary<string, JToken>();
|
|
|
|
public WeedWorkerPerformanceModel Clone()
|
|
{
|
|
return new WeedWorkerPerformanceModel
|
|
{
|
|
timestamp = timestamp,
|
|
|
|
loops = loops?.ToDictionary(
|
|
x => x.Key,
|
|
x => x.Value?.Clone()
|
|
) ?? new Dictionary<string, WeedWorkerPerformanceLoopModel>(),
|
|
|
|
sync = sync != null
|
|
? (JObject)sync.DeepClone()
|
|
: new JObject(),
|
|
|
|
weed_cache = weed_cache?.Clone()
|
|
?? new WeedWorkerPerformanceCacheModel(),
|
|
|
|
pub_debug = pub_debug?.Clone()
|
|
?? new WeedWorkerPerformancePublicacaoModel(),
|
|
|
|
contadores = contadores != null
|
|
? (JObject)contadores.DeepClone()
|
|
: new JObject(),
|
|
|
|
Extra = Extra?.ToDictionary(
|
|
x => x.Key,
|
|
x => x.Value?.DeepClone()
|
|
) ?? new Dictionary<string, JToken>()
|
|
};
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerPerformanceLoopModel
|
|
{
|
|
public double fps_real { get; set; }
|
|
|
|
public JObject periodo_ms { get; set; } = new JObject();
|
|
public JObject latencia_ms { get; set; } = new JObject();
|
|
|
|
public Dictionary<string, JObject> metrics_ms { get; set; }
|
|
= new Dictionary<string, JObject>();
|
|
|
|
[Newtonsoft.Json.JsonExtensionData]
|
|
public IDictionary<string, JToken> Extra { get; set; }
|
|
= new Dictionary<string, JToken>();
|
|
|
|
public WeedWorkerPerformanceLoopModel Clone()
|
|
{
|
|
return new WeedWorkerPerformanceLoopModel
|
|
{
|
|
fps_real = fps_real,
|
|
|
|
periodo_ms = periodo_ms != null
|
|
? (JObject)periodo_ms.DeepClone()
|
|
: new JObject(),
|
|
|
|
latencia_ms = latencia_ms != null
|
|
? (JObject)latencia_ms.DeepClone()
|
|
: new JObject(),
|
|
|
|
metrics_ms = metrics_ms?.ToDictionary(
|
|
x => x.Key,
|
|
x => x.Value != null
|
|
? (JObject)x.Value.DeepClone()
|
|
: new JObject()
|
|
) ?? new Dictionary<string, JObject>(),
|
|
|
|
Extra = Extra?.ToDictionary(
|
|
x => x.Key,
|
|
x => x.Value?.DeepClone()
|
|
) ?? new Dictionary<string, JToken>()
|
|
};
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerPerformanceCacheModel
|
|
{
|
|
public double tensor_ts { get; set; }
|
|
public double? tensor_age_ms { get; set; }
|
|
public double tensor_consumido_ts { get; set; }
|
|
public bool tem_tensor { get; set; }
|
|
|
|
public WeedWorkerPerformanceCacheModel Clone()
|
|
{
|
|
return (WeedWorkerPerformanceCacheModel)MemberwiseClone();
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerPerformancePublicacaoModel
|
|
{
|
|
public double ts { get; set; }
|
|
public int publicou { get; set; }
|
|
public int campos { get; set; }
|
|
public double redis_ms { get; set; }
|
|
|
|
public WeedWorkerPerformancePublicacaoModel Clone()
|
|
{
|
|
return (WeedWorkerPerformancePublicacaoModel)MemberwiseClone();
|
|
}
|
|
}
|
|
|
|
public class WeedWorkerRedisTimestampsModel
|
|
{
|
|
public double analise { get; set; }
|
|
public double analise_weed { get; set; }
|
|
public double performance_weed { get; set; }
|
|
|
|
public WeedWorkerRedisTimestampsModel Clone()
|
|
{
|
|
return (WeedWorkerRedisTimestampsModel)MemberwiseClone();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public enum WeedWorkerCommandType
|
|
{
|
|
ScriptCarregado = 1,
|
|
IniciarCameraManager = 2,
|
|
AtualizarSaudeCamera = 3,
|
|
GetCameraFrame = 4,
|
|
SaveCameraFrames = 5,
|
|
EnviarDadosControle = 6,
|
|
ReiniciarDeteccoes = 7
|
|
}
|
|
}
|