154 lines
4.5 KiB
C#
154 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Threading.Tasks;
|
|
using static AgroBase.Models.Enums;
|
|
using static AgroBase.Models.Operadores.OperadoresModels;
|
|
|
|
namespace AgroBase.Models
|
|
{
|
|
public class OAKCameraModel
|
|
{
|
|
public T_Code Dispositivo { get; set; }
|
|
public int Index { get; set; }
|
|
public string Id { get; set; }
|
|
public string Name { get; set; }
|
|
public string Description
|
|
{
|
|
get
|
|
{
|
|
return $"({Index}) {Name}";
|
|
}
|
|
}
|
|
public string State { get; set; }
|
|
public string Usb_Speed { get; set; }
|
|
public string[] Available_Camera_Sensors { get; set; }
|
|
public string Version { get; set; }
|
|
public OAKCameraMemoryUsageModel Memory_Usage { get; set; }
|
|
public OAKCameraTemperaturaModel Temperature { get; set; }
|
|
public string Bootloader_Version { get; set; }
|
|
public bool Is_Pipeline_Running { get; set; }
|
|
public double fx { get; set; }
|
|
public double baseline { get; set; }
|
|
|
|
public Dictionary<TipoComando, Bitmap> frames { get; set; } = new Dictionary<TipoComando, Bitmap>();
|
|
|
|
public bool newData { get; set; }
|
|
public void setVisto() => newData = false;
|
|
|
|
public async Task<Bitmap> GetFrame(TipoComando tipo = TipoComando.GetCameraFrame)
|
|
{
|
|
VariaveisOperacao.Operadores.HealthWorker.AdicionarComandoNaFila(tipo, new { mx_id = Id });
|
|
await VariaveisOperacao.Operadores.HealthWorker.AguardarNovosDados(tipo, 10000);
|
|
Bitmap bmp = (VariaveisOperacao.Operadores.HealthWorker.DadosLeitura.Leitura.obj?.frame ?? new OAKCameraFrameModel()).image;
|
|
frames[tipo] = bmp;
|
|
return bmp;
|
|
}
|
|
|
|
public OAKCameraModel Clone()
|
|
{
|
|
return new OAKCameraModel()
|
|
{
|
|
Dispositivo = Dispositivo,
|
|
Index = Index,
|
|
Id = Id,
|
|
Name = Name,
|
|
State = State,
|
|
Usb_Speed = Usb_Speed,
|
|
Available_Camera_Sensors = Available_Camera_Sensors,
|
|
Bootloader_Version = Bootloader_Version,
|
|
Is_Pipeline_Running = Is_Pipeline_Running,
|
|
Memory_Usage = Memory_Usage?.Clone(),
|
|
Temperature = Temperature?.Clone(),
|
|
Version = Version,
|
|
fx = fx,
|
|
baseline = baseline,
|
|
frames = new Dictionary<TipoComando, Bitmap>(frames),
|
|
newData = true
|
|
};
|
|
}
|
|
}
|
|
|
|
public class OAKCameraMemoryUsageModel
|
|
{
|
|
public double Remaining { get; set; }
|
|
public double Total { get; set; }
|
|
public double Used { get; set; }
|
|
public double Percent
|
|
{
|
|
get
|
|
{
|
|
return Math.Round((Used / Total) * 100, 2);
|
|
}
|
|
}
|
|
|
|
public OAKCameraMemoryUsageModel Clone()
|
|
{
|
|
return new OAKCameraMemoryUsageModel()
|
|
{
|
|
Remaining = Remaining,
|
|
Total = Total,
|
|
Used = Used
|
|
};
|
|
}
|
|
}
|
|
|
|
public class OAKCameraTemperaturaModel
|
|
{
|
|
public double css { get; set; }
|
|
public double mss { get; set; }
|
|
public double upa { get; set; }
|
|
public double dss { get; set; }
|
|
|
|
public OAKCameraTemperaturaModel Clone()
|
|
{
|
|
return new OAKCameraTemperaturaModel()
|
|
{
|
|
css = css,
|
|
mss = mss,
|
|
upa = upa,
|
|
dss = dss
|
|
};
|
|
}
|
|
}
|
|
|
|
public class OAKCameraFrameModel
|
|
{
|
|
public long timestamp { get; set; }
|
|
public string frame { get; set; }
|
|
public Bitmap image { get; set; } = null;
|
|
|
|
private bool _newData = true;
|
|
public bool newData
|
|
{
|
|
get
|
|
{
|
|
if (_newData)
|
|
{
|
|
_newData = false;
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
_newData = value;
|
|
}
|
|
}
|
|
public OAKCameraFrameModel Clone()
|
|
{
|
|
return new OAKCameraFrameModel()
|
|
{
|
|
timestamp = timestamp,
|
|
frame = frame,
|
|
image = FuncoesGlobais.Base64ToBitmap(frame),
|
|
newData = true
|
|
};
|
|
}
|
|
}
|
|
|
|
}
|