Merge
This commit is contained in:
commit
edb2f26550
|
|
@ -447,7 +447,7 @@ namespace AgroBase.Forms.IHM
|
|||
var interfaces = EthernetService.ObterNomesInterfaces().Where(x => x.Contains("Ativa")).ToList();
|
||||
cmbInterface.Items.Clear();
|
||||
cmbInterface.Items.AddRange(interfaces.ToArray());
|
||||
cmbInterface.SelectedIndex = interfaces.IndexOf(interfaces.FirstOrDefault(x => x.Contains(p.rover_interface)));
|
||||
cmbInterface.SelectedIndex = interfaces.IndexOf(interfaces.FirstOrDefault(x => x.Contains(p.rover_interface ?? "")));
|
||||
}
|
||||
|
||||
private async void SalvarParametrosConfiguracao()
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ namespace AgroBase.Forms
|
|||
if (DalyBMSService.Iniciado)
|
||||
{
|
||||
var Bat = DalyBMSService.DadosLeitura;
|
||||
lblVBat.Text = $"Bateria: {Bat.Pack.TensaoTotal_V:F2}V {Bat.Pack.Corrente_A:F2}A {Bat.Pack.SOC_percent:F2}% {Bat.TemperaturaMax:Fw}ºC";
|
||||
lblVBat.Text = $"Bateria: {Bat.Pack.TensaoTotal_V:F2}V {Bat.Pack.Corrente_A:F2}A {Bat.Pack.SOC_percent:F2}% {Bat.TemperaturaMax:F2}ºC";
|
||||
}
|
||||
lblVBat.ForeColor = DalyBMSService.Iniciado ? Color.Green : Color.Red;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2456,6 +2456,7 @@ namespace AgroBase.Models
|
|||
var dadosBateria = _Bateria != null ? new OperacaoSensoriamentoLogBateriaModel()
|
||||
{
|
||||
Iniciado = _Bateria.Iniciado,
|
||||
BmsLigado = _Bateria.BmsLigado,
|
||||
_dt = _Bateria._dt,
|
||||
PercentualBateria = _Bateria.PercentualBateria,
|
||||
PercentualBateriaConsumida = _Bateria.PercentualConsumido,
|
||||
|
|
@ -2796,6 +2797,7 @@ namespace AgroBase.Models
|
|||
public class OperacaoSensoriamentoLogBateriaModel
|
||||
{
|
||||
public bool Iniciado { get; set; }
|
||||
public bool BmsLigado { get; set; }
|
||||
public double _dt { get; set; }
|
||||
public double PercentualBateria { get; set; }
|
||||
public double PercentualBateriaConsumida { get; set; }
|
||||
|
|
@ -2813,6 +2815,7 @@ namespace AgroBase.Models
|
|||
return new OperacaoSensoriamentoLogBateriaModel()
|
||||
{
|
||||
Iniciado = Iniciado,
|
||||
BmsLigado = BmsLigado,
|
||||
_dt = _dt,
|
||||
PercentualBateriaConsumida = PercentualBateriaConsumida,
|
||||
PercentualBateria = PercentualBateria,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ namespace AgroBase.Services
|
|||
private readonly Queue<double> _historicoCorrente = new Queue<double>();
|
||||
|
||||
public bool Iniciado { get; private set; }
|
||||
public bool BmsLigado { get; set; }
|
||||
private double CargaMaxima { get; set; }
|
||||
private double CargaAtual { get; set; }
|
||||
public double CargaAtualAmp
|
||||
|
|
@ -133,16 +134,17 @@ namespace AgroBase.Services
|
|||
double sen_soc = Math.Round(FuncoesMatematicas.Map(sen_tensao, VariaveisEquipamento.TensaoMinimaBateria, VariaveisEquipamento.TensaoMaximaBateria, 0.0, 100.0), 2);
|
||||
|
||||
Iniciado = bms_iniciado || sen_iniciado;
|
||||
BmsLigado = bms_iniciado;
|
||||
|
||||
if (!Iniciado)
|
||||
return;
|
||||
|
||||
//_dt = Sensor.ValoresLeituras.FirstOrDefault(x => x.funcao == FuncoesPinout.Corrente)?.atual?.dt ?? 0;
|
||||
_dt = (DateTime.Now - ((bms_iniciado ? bms_ultima_leitura : sen_ultima_leitura) ?? DateTime.Now)).TotalSeconds;
|
||||
TensaoInstantanea = bms_iniciado ? bms_tensao : sen_tensao;
|
||||
CorrenteInstantanea = bms_iniciado ? bms_corrente : sen_corrente;
|
||||
PotenciaInstantanea = bms_iniciado ? bms_potencia : sen_potencia;
|
||||
PercentualBateria = bms_iniciado ? bms_soc : sen_soc;
|
||||
_dt = (DateTime.Now - ((BmsLigado ? bms_ultima_leitura : sen_ultima_leitura) ?? DateTime.Now)).TotalSeconds;
|
||||
TensaoInstantanea = BmsLigado ? bms_tensao : sen_tensao;
|
||||
CorrenteInstantanea = BmsLigado ? bms_corrente : sen_corrente;
|
||||
PotenciaInstantanea = BmsLigado ? bms_potencia : sen_potencia;
|
||||
PercentualBateria = BmsLigado ? bms_soc : sen_soc;
|
||||
PercentualBateria = FuncoesMatematicas.Clamp(PercentualBateria, 0, 100);
|
||||
|
||||
// Verifique se as datas são válidas (não MinValue, MaxValue ou valores anômalos)
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ namespace AgroBase.Services
|
|||
|
||||
DadosLeitura.Pack.TensaoTotal_V = totalV;
|
||||
DadosLeitura.Pack.TensaoMedida_V = measV;
|
||||
DadosLeitura.Pack.Corrente_A = current;
|
||||
DadosLeitura.Pack.Corrente_A = -current;
|
||||
DadosLeitura.Pack.SOC_percent = soc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1012,9 +1012,9 @@ namespace AgroBase.Services
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var bico in Variaveis.OperacaoEmAndamento.Controle?.Bicos?.Where(x => x.Inicializado && x.Comandar))
|
||||
foreach (var bico in Variaveis.OperacaoEmAndamento.Controle?.Bicos ?? new List<Models.Modules.AtuadorBicoModel>())
|
||||
{
|
||||
if (bico._EstadoLeitura == Estado.Ligado)
|
||||
if (bico.Inicializado && bico.Comandar && bico._EstadoLeitura == Estado.Ligado)
|
||||
{
|
||||
bico.TrechosAtuado[bico.TrechosAtuado.Count - 1].Add(new double[] { UltimaLeitura.Latitude, UltimaLeitura.Longitude });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -388,7 +388,8 @@ namespace AgroBase.Services.Operadores
|
|||
RedisService.AtualizarCampos(RedisService.ModKey(Enums.T_Code.Sen),
|
||||
("timestamp", agora),
|
||||
("conectado", DadosSen.Conectado),
|
||||
("freq_base", DadosSen.FrequenciaBase)
|
||||
("freq_base", DadosSen.FrequenciaBase),
|
||||
("bms_ligado", _Sensoriamento.Bateria?.BmsLigado ?? false)
|
||||
);
|
||||
var senSensoresAtualizados = new List<(string caminho, object valor)>();
|
||||
var senSensoresAtivos = new List<string>();
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class CameraOak:
|
|||
_camera["modelo"] = self.modelo
|
||||
_camera["dispositivo"] = self.dispositivo.value
|
||||
_camera["tem_depht"] = self.tem_depth
|
||||
_camera["tem_imu"] = iniciar_imu and self.tem_imu
|
||||
_camera["tem_imu"] = self.tem_imu
|
||||
|
||||
# Criar processo para transmissao de video
|
||||
try:
|
||||
|
|
@ -130,7 +130,7 @@ class CameraOak:
|
|||
if self.tem_depth:
|
||||
self.q_depth = self.device.getOutputQueue(name="depth", maxSize=1, blocking=False)
|
||||
|
||||
if self.tem_imu:
|
||||
if self.tem_imu and iniciar_imu:
|
||||
self.q_imu = self.device.getOutputQueue(name="imu", maxSize=50, blocking=False)
|
||||
self.imu = IMUCamera(self.q_imu, freq=100, angulo_inicial=26.3)
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class IMUCamera(ModuloDiagnosticoBase):
|
|||
pitch=round(-pitch, 2), # frontal
|
||||
yaw=round(yaw, 2),
|
||||
vel_mps=round(velocidade_mps, 3),
|
||||
timestamp=t1,
|
||||
timestamp=(t1 * 1000),
|
||||
latencia=latencia,
|
||||
frequencia=f_tick
|
||||
)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
try:
|
||||
agora = time.time()
|
||||
motivos_gerais = []
|
||||
saude_mandatorios = 0
|
||||
total_mandatorios = 0
|
||||
saude_total = 0
|
||||
total_ativos = 0
|
||||
saude_individual = []
|
||||
|
|
@ -29,6 +31,7 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
FREQ_MIN = FREQ_BASE * 0.5
|
||||
SAUDE_MIN_ALERTA = 80
|
||||
|
||||
bms_ligado = dados_sen.get("bms_ligado", False)
|
||||
sensor_bateria_ativado = False
|
||||
|
||||
sensores_ativos = dados_sen.get("sensores", {}).get("ativos", [])
|
||||
|
|
@ -88,9 +91,11 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
"em_uso": aferir
|
||||
}
|
||||
saude_individual.append(saude_mod)
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if mandatorio:
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
total_mandatorios += 1
|
||||
saude_mandatorios += saude
|
||||
motivos_gerais.extend([f"{chave}: {m}" for m in motivos])
|
||||
dados_sensor["saude"] = saude_mod
|
||||
|
||||
|
|
@ -148,9 +153,11 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
"em_uso": controlar
|
||||
}
|
||||
saude_individual.append(saude_mod)
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if mandatorio:
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
total_mandatorios += 1
|
||||
saude_mandatorios += saude
|
||||
motivos_gerais.extend([f"{chave}: {m}" for m in motivos])
|
||||
dados_servo["saude"] = saude_mod
|
||||
|
||||
|
|
@ -198,9 +205,11 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
"em_uso": controlar
|
||||
}
|
||||
saude_individual.append(saude_mod)
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if mandatorio:
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
total_mandatorios += 1
|
||||
saude_mandatorios += saude
|
||||
motivos_gerais.extend([f"{chave}: {m}" for m in motivos])
|
||||
dados_rele["saude"] = saude_mod
|
||||
|
||||
|
|
@ -248,50 +257,54 @@ class ModuloSensoriamento(ModuloDiagnosticoBase):
|
|||
"em_uso": controlar
|
||||
}
|
||||
saude_individual.append(saude_mod)
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
if mandatorio:
|
||||
total_ativos += 1
|
||||
saude_total += saude
|
||||
total_mandatorios += 1
|
||||
saude_mandatorios += saude
|
||||
motivos_gerais.extend([f"{chave}: {m}" for m in motivos])
|
||||
dados_led["saude"] = saude_mod
|
||||
|
||||
|
||||
cond_op_mod = []
|
||||
penalidade_percentual_bateria = 0
|
||||
if sensor_bateria_ativado:
|
||||
_contexto = ContextoGlobalRedis.get_contexto()
|
||||
bateria_suficiente_corredor = _contexto.get("Trajetoria", {}).get("CorredorAtual", {}).get("bateria_ok", True)
|
||||
percent_atual = _contexto.get("Gerais", {}).get("percentual_bateria", 0.0)
|
||||
percent_min = ContextoGlobalRedis.get_equipamento().get("percentual_tensao_bateria_min", 5.0)
|
||||
if percent_atual < percent_min:
|
||||
penalidade_percentual_bateria = 70
|
||||
if not bms_ligado:
|
||||
if sensor_bateria_ativado:
|
||||
_contexto = ContextoGlobalRedis.get_contexto()
|
||||
bateria_suficiente_corredor = _contexto.get("Trajetoria", {}).get("CorredorAtual", {}).get("bateria_ok", True)
|
||||
percent_atual = _contexto.get("Gerais", {}).get("percentual_bateria", 0.0)
|
||||
percent_min = ContextoGlobalRedis.get_equipamento().get("percentual_tensao_bateria_min", 5.0)
|
||||
if percent_atual < percent_min:
|
||||
penalidade_percentual_bateria = 70
|
||||
cond_op_mod.append({
|
||||
"valor": percent_atual,
|
||||
"severidade": 100,
|
||||
"descricao": f"Nível da bateria abaixo do limite mínimo!"
|
||||
})
|
||||
elif percent_atual < 25.0:
|
||||
penalidade_percentual_bateria = 25
|
||||
cond_op_mod.append({
|
||||
"valor": percent_atual,
|
||||
"severidade": 30,
|
||||
"descricao": f"Nível da bateria baixo!"
|
||||
})
|
||||
if not bateria_suficiente_corredor:
|
||||
penalidade_percentual_bateria = 25
|
||||
_motivo_bat = _contexto.get("Trajetoria", {}).get("CorredorAtual", {}).get("motivo", "Bateria insuficiente")
|
||||
cond_op_mod.append({
|
||||
"valor": percent_atual,
|
||||
"severidade": 30,
|
||||
"descricao": _motivo_bat
|
||||
})
|
||||
else:
|
||||
cond_op_mod.append({
|
||||
"valor": percent_atual,
|
||||
"valor": 0,
|
||||
"severidade": 100,
|
||||
"descricao": f"Nível da bateria abaixo do limite mínimo!"
|
||||
"descricao": f"Sensor de nível da bateria desconectado!"
|
||||
})
|
||||
elif percent_atual < 25.0:
|
||||
penalidade_percentual_bateria = 25
|
||||
cond_op_mod.append({
|
||||
"valor": percent_atual,
|
||||
"severidade": 30,
|
||||
"descricao": f"Nível da bateria baixo!"
|
||||
})
|
||||
if not bateria_suficiente_corredor:
|
||||
penalidade_percentual_bateria = 25
|
||||
_motivo_bat = _contexto.get("Trajetoria", {}).get("CorredorAtual", {}).get("motivo", "Bateria insuficiente")
|
||||
cond_op_mod.append({
|
||||
"valor": percent_atual,
|
||||
"severidade": 30,
|
||||
"descricao": _motivo_bat
|
||||
})
|
||||
else:
|
||||
cond_op_mod.append({
|
||||
"valor": 0,
|
||||
"severidade": 100,
|
||||
"descricao": f"Sensor de nível da bateria desconectado!"
|
||||
})
|
||||
|
||||
saude_final = (saude_total // total_ativos) if total_ativos > 0 else 0
|
||||
saude_final = (saude_mandatorios // total_mandatorios) if total_mandatorios > 0 else 100
|
||||
#saude_final = (saude_total // total_ativos) if total_ativos > 0 else 0
|
||||
saude_final = saude_final - penalidade_percentual_bateria
|
||||
|
||||
status = StatusModulo.OPERANTE
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class CameraManager:
|
|||
det_config = load_det_config()
|
||||
|
||||
try:
|
||||
nova = CameraOak(self.mostrar_log, mx_id, modelo_ia_seg=None, modelo_ia_det=det_config)
|
||||
nova = CameraOak(self.mostrar_log, mx_id, modelo_ia_seg=None, modelo_ia_det=det_config, iniciar_imu=True)
|
||||
if nova.iniciado:
|
||||
self.camera = nova
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Reference in New Issue