finalizado integracao com ina228 e refinado gy91
This commit is contained in:
parent
669ce4f9e1
commit
18c44ca27c
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -771,7 +771,7 @@ namespace AgroBase.Forms.IHM
|
||||||
idx = PreencheDadosLinha(grid, Testes, idx, ServoFreio != null ? Testes[idx].ValorAferido : -1);
|
idx = PreencheDadosLinha(grid, Testes, idx, ServoFreio != null ? Testes[idx].ValorAferido : -1);
|
||||||
|
|
||||||
var SensorAB7V2 = Modulo_Sen.DadosLeitura.SensoresCorrente.FirstOrDefault(x => x.ID == "AB7V2");
|
var SensorAB7V2 = Modulo_Sen.DadosLeitura.SensoresCorrente.FirstOrDefault(x => x.ID == "AB7V2");
|
||||||
double CorrenteFreio = SensorAB7V2 != null ? SensorAB7V2.Current ?? 0 : -1;
|
double CorrenteFreio = SensorAB7V2 != null ? SensorAB7V2.Current : -1;
|
||||||
double TensaoFreio = SensorAB7V2 != null ? SensorAB7V2.BusVoltage : -1;
|
double TensaoFreio = SensorAB7V2 != null ? SensorAB7V2.BusVoltage : -1;
|
||||||
|
|
||||||
(bool desatuar, int angDesativar) = Modulo.MovMotor.ConfigFreio.AtualizarDadosFreio(false);
|
(bool desatuar, int angDesativar) = Modulo.MovMotor.ConfigFreio.AtualizarDadosFreio(false);
|
||||||
|
|
@ -1214,23 +1214,24 @@ namespace AgroBase.Forms.IHM
|
||||||
var grid = Diagnostico.grid;
|
var grid = Diagnostico.grid;
|
||||||
var Testes = Diagnostico.Testes;
|
var Testes = Diagnostico.Testes;
|
||||||
|
|
||||||
|
var Modulo_Sen = Variaveis.OperacaoEmAndamento.DispSen.Dados;
|
||||||
|
|
||||||
bool PzmConectado = SerialService.DispositivosMapeados.Any(x => x.Dispositivo == Enums.T_Code.Pzm);
|
bool PzmConectado = SerialService.DispositivosMapeados.Any(x => x.Dispositivo == Enums.T_Code.Pzm);
|
||||||
idx = PreencheDadosLinha(grid, Testes, idx, PzmConectado ? 1 : 0);
|
idx = PreencheDadosLinha(grid, Testes, idx, PzmConectado ? 1 : 0);
|
||||||
|
|
||||||
bool PzmInicializado = PZEMService.Iniciado;
|
var S36V = ((FirmwareSensorCorrente)Modulo_Sen.Sensores.FirstOrDefault(x => x.ID == "AB36V").Leitura);
|
||||||
idx = PreencheDadosLinha(grid, Testes, idx, PzmInicializado ? 1 : 0);
|
bool S36VInicializado = S36V?.Iniciado ?? false;
|
||||||
|
idx = PreencheDadosLinha(grid, Testes, idx, S36VInicializado ? 1 : 0);
|
||||||
|
|
||||||
double Tensao = PzmInicializado ? PZEMService.UltimaLeitura.Tensao : -1;
|
double Tensao = S36VInicializado ? S36V.BusVoltage : -1;
|
||||||
idx = PreencheDadosLinha(grid, Testes, idx, Tensao);
|
idx = PreencheDadosLinha(grid, Testes, idx, Tensao);
|
||||||
|
|
||||||
double Corrente = PzmInicializado ? PZEMService.UltimaLeitura.Corrente : -1;
|
double Corrente = S36VInicializado ? S36V.Current : -1;
|
||||||
idx = PreencheDadosLinha(grid, Testes, idx, Corrente);
|
idx = PreencheDadosLinha(grid, Testes, idx, Corrente);
|
||||||
|
|
||||||
bool SenConectado = SerialService.DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Sen);
|
bool SenConectado = SerialService.DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Sen);
|
||||||
idx = PreencheDadosLinha(grid, Testes, idx, SenConectado ? 1 : 0);
|
idx = PreencheDadosLinha(grid, Testes, idx, SenConectado ? 1 : 0);
|
||||||
|
|
||||||
var Modulo_Sen = Variaveis.OperacaoEmAndamento.DispSen.Dados;
|
|
||||||
|
|
||||||
bool SenIniciado = Modulo_Sen.Conectado;
|
bool SenIniciado = Modulo_Sen.Conectado;
|
||||||
idx = PreencheDadosLinha(grid, Testes, idx, SenIniciado ? 1 : 0);
|
idx = PreencheDadosLinha(grid, Testes, idx, SenIniciado ? 1 : 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -416,6 +416,7 @@ namespace AgroBase.Forms.Operacoes
|
||||||
gridDados.Rows.Add("Nível de Bateria", "", "%");
|
gridDados.Rows.Add("Nível de Bateria", "", "%");
|
||||||
gridDados.Rows.Add("Tensão da Bateria", "", "v");
|
gridDados.Rows.Add("Tensão da Bateria", "", "v");
|
||||||
gridDados.Rows.Add("Corrente da Bateria", "", "A");
|
gridDados.Rows.Add("Corrente da Bateria", "", "A");
|
||||||
|
gridDados.Rows.Add("Tempo Estimado Restante", "", "Min");
|
||||||
gridDados.Rows.Add("Barramento 3V", "", "V");
|
gridDados.Rows.Add("Barramento 3V", "", "V");
|
||||||
gridDados.Rows.Add("Barramento 3V", "", "mA");
|
gridDados.Rows.Add("Barramento 3V", "", "mA");
|
||||||
gridDados.Rows.Add("Barramento 5V", "", "V");
|
gridDados.Rows.Add("Barramento 5V", "", "V");
|
||||||
|
|
@ -424,6 +425,10 @@ namespace AgroBase.Forms.Operacoes
|
||||||
gridDados.Rows.Add("Barramento 7,2V", "", "mA");
|
gridDados.Rows.Add("Barramento 7,2V", "", "mA");
|
||||||
gridDados.Rows.Add("Barramento 12V", "", "V");
|
gridDados.Rows.Add("Barramento 12V", "", "V");
|
||||||
gridDados.Rows.Add("Barramento 12V", "", "mA");
|
gridDados.Rows.Add("Barramento 12V", "", "mA");
|
||||||
|
gridDados.Rows.Add("Barramento 19V", "", "V");
|
||||||
|
gridDados.Rows.Add("Barramento 19V", "", "mA");
|
||||||
|
gridDados.Rows.Add("Barramento 24V", "", "V");
|
||||||
|
gridDados.Rows.Add("Barramento 24V", "", "mA");
|
||||||
gridDados.Rows.Add("Nível do Reservatório", "", "%");
|
gridDados.Rows.Add("Nível do Reservatório", "", "%");
|
||||||
gridDados.Rows.Add("Volume do Reservatório", "", "L");
|
gridDados.Rows.Add("Volume do Reservatório", "", "L");
|
||||||
gridDados.Rows.Add("Pressão da Linha", "", "psi");
|
gridDados.Rows.Add("Pressão da Linha", "", "psi");
|
||||||
|
|
@ -449,6 +454,8 @@ namespace AgroBase.Forms.Operacoes
|
||||||
var AB5V = _SensoresCorrente.FirstOrDefault(x => x.ID == "AB5V");
|
var AB5V = _SensoresCorrente.FirstOrDefault(x => x.ID == "AB5V");
|
||||||
var AB7V2 = _SensoresCorrente.FirstOrDefault(x => x.ID == "AB7V2");
|
var AB7V2 = _SensoresCorrente.FirstOrDefault(x => x.ID == "AB7V2");
|
||||||
var AB12V = _SensoresCorrente.FirstOrDefault(x => x.ID == "AB12V");
|
var AB12V = _SensoresCorrente.FirstOrDefault(x => x.ID == "AB12V");
|
||||||
|
var AB19V = _SensoresCorrente.FirstOrDefault(x => x.ID == "AB19V");
|
||||||
|
var AB24V = _SensoresCorrente.FirstOrDefault(x => x.ID == "AB24V");
|
||||||
var _Sensoriamento = Variaveis.OperacaoEmAndamento.Sensoriamento;
|
var _Sensoriamento = Variaveis.OperacaoEmAndamento.Sensoriamento;
|
||||||
var _SensorIMU = Variaveis.OperacaoEmAndamento.DispSen.Dados.DadosLeitura.SensoresIMU.FirstOrDefault();
|
var _SensorIMU = Variaveis.OperacaoEmAndamento.DispSen.Dados.DadosLeitura.SensoresIMU.FirstOrDefault();
|
||||||
|
|
||||||
|
|
@ -459,28 +466,33 @@ namespace AgroBase.Forms.Operacoes
|
||||||
gridDados.Rows[4].Cells[1].Value = (_Sensoriamento.Bateria.PorcentagemBateria.ToString("00.00"));
|
gridDados.Rows[4].Cells[1].Value = (_Sensoriamento.Bateria.PorcentagemBateria.ToString("00.00"));
|
||||||
gridDados.Rows[5].Cells[1].Value = (_Sensoriamento.Bateria.TensaoInstantanea.ToString("0.00"));
|
gridDados.Rows[5].Cells[1].Value = (_Sensoriamento.Bateria.TensaoInstantanea.ToString("0.00"));
|
||||||
gridDados.Rows[6].Cells[1].Value = (_Sensoriamento.Bateria.CorrenteInstantanea.ToString("0.00"));
|
gridDados.Rows[6].Cells[1].Value = (_Sensoriamento.Bateria.CorrenteInstantanea.ToString("0.00"));
|
||||||
gridDados.Rows[7].Cells[1].Value = (AB3V != null ? AB3V.BusVoltage : 0).ToString("0.00");
|
gridDados.Rows[7].Cells[1].Value = (_Sensoriamento.Bateria.TempoEstimadoRestanteMinutos.ToString("0.00"));
|
||||||
gridDados.Rows[8].Cells[1].Value = (AB3V != null ? (double)AB3V.Current : 0).ToString("0.00");
|
gridDados.Rows[8].Cells[1].Value = (AB3V != null ? AB3V.BusVoltage : 0).ToString("0.00");
|
||||||
gridDados.Rows[9].Cells[1].Value = (AB5V != null ? AB5V.BusVoltage : 0).ToString("0.00");
|
gridDados.Rows[9].Cells[1].Value = (AB3V != null ? (double)AB3V.Current : 0).ToString("0.00");
|
||||||
gridDados.Rows[10].Cells[1].Value = (AB5V != null ? (double)AB5V.Current : 0).ToString("0.00");
|
gridDados.Rows[10].Cells[1].Value = (AB5V != null ? AB5V.BusVoltage : 0).ToString("0.00");
|
||||||
gridDados.Rows[11].Cells[1].Value = (AB7V2 != null ? AB7V2.BusVoltage : 0).ToString("0.00");
|
gridDados.Rows[11].Cells[1].Value = (AB5V != null ? (double)AB5V.Current : 0).ToString("0.00");
|
||||||
gridDados.Rows[12].Cells[1].Value = (AB7V2 != null ? (double)AB7V2.Current : 0).ToString("0.00");
|
gridDados.Rows[12].Cells[1].Value = (AB7V2 != null ? AB7V2.BusVoltage : 0).ToString("0.00");
|
||||||
gridDados.Rows[13].Cells[1].Value = (AB12V != null ? AB12V.BusVoltage : 0).ToString("0.00");
|
gridDados.Rows[13].Cells[1].Value = (AB7V2 != null ? (double)AB7V2.Current : 0).ToString("0.00");
|
||||||
gridDados.Rows[14].Cells[1].Value = (AB12V != null ? (double)AB12V.Current : 0).ToString("0.00");
|
gridDados.Rows[14].Cells[1].Value = (AB12V != null ? AB12V.BusVoltage : 0).ToString("0.00");
|
||||||
gridDados.Rows[15].Cells[1].Value = _Sensoriamento.Atuador.PercentualReservatorio.ToString("00.00");
|
gridDados.Rows[15].Cells[1].Value = (AB12V != null ? (double)AB12V.Current : 0).ToString("0.00");
|
||||||
gridDados.Rows[16].Cells[1].Value = _Sensoriamento.Atuador.VolumeReservatorio.ToString("0.000");
|
gridDados.Rows[16].Cells[1].Value = (AB19V != null ? AB19V.BusVoltage : 0).ToString("0.00");
|
||||||
gridDados.Rows[17].Cells[1].Value = _Sensoriamento.Atuador.PressaoLinha.ToString("0.00");
|
gridDados.Rows[17].Cells[1].Value = (AB19V != null ? (double)AB19V.Current : 0).ToString("0.00");
|
||||||
gridDados.Rows[18].Cells[1].Value = _Sensoriamento.Atuador.LeituraPotenciaBomba.ToString("0.00");
|
gridDados.Rows[18].Cells[1].Value = (AB24V != null ? AB24V.BusVoltage : 0).ToString("0.00");
|
||||||
gridDados.Rows[19].Cells[1].Value = _Sensoriamento.Atuador.VazaoInstantanea.ToString("0.00");
|
gridDados.Rows[19].Cells[1].Value = (AB24V != null ? (double)AB24V.Current : 0).ToString("0.00");
|
||||||
gridDados.Rows[20].Cells[1].Value = _Sensoriamento.Atuador.VazaoMedia.ToString("0.00");
|
gridDados.Rows[20].Cells[1].Value = _Sensoriamento.Atuador.PercentualReservatorio.ToString("00.00");
|
||||||
gridDados.Rows[21].Cells[1].Value = _Sensoriamento.Atuador.VolumeVazaoMl.ToString("0.00");
|
gridDados.Rows[21].Cells[1].Value = _Sensoriamento.Atuador.VolumeReservatorio.ToString("0.000");
|
||||||
gridDados.Rows[22].Cells[1].Value = "";
|
gridDados.Rows[22].Cells[1].Value = _Sensoriamento.Atuador.PressaoLinha.ToString("0.00");
|
||||||
gridDados.Rows[23].Cells[1].Value = (_SensorIMU?.Roll ?? 0).ToString("0.00");
|
gridDados.Rows[23].Cells[1].Value = _Sensoriamento.Atuador.LeituraPotenciaBomba.ToString("0.00");
|
||||||
gridDados.Rows[24].Cells[1].Value = (_SensorIMU?.Pitch ?? 0).ToString("0.00");
|
gridDados.Rows[24].Cells[1].Value = _Sensoriamento.Atuador.VazaoInstantanea.ToString("0.00");
|
||||||
gridDados.Rows[25].Cells[1].Value = (_SensorIMU?.Yaw ?? 0).ToString("0.00");
|
gridDados.Rows[25].Cells[1].Value = _Sensoriamento.Atuador.VazaoMedia.ToString("0.00");
|
||||||
gridDados.Rows[26].Cells[1].Value = (_SensorIMU?.Temperatura ?? 0).ToString("0.00");
|
gridDados.Rows[26].Cells[1].Value = _Sensoriamento.Atuador.VolumeVazaoMl.ToString("0.00");
|
||||||
gridDados.Rows[27].Cells[1].Value = (_SensorIMU?.Pressao ?? 0).ToString("0.00");
|
gridDados.Rows[27].Cells[1].Value = "";
|
||||||
gridDados.Rows[28].Cells[1].Value = (_SensorIMU?.Altitude ?? 0).ToString("0.00");
|
gridDados.Rows[28].Cells[1].Value = (_SensorIMU?.Roll ?? 0).ToString("0.00");
|
||||||
|
gridDados.Rows[29].Cells[1].Value = (_SensorIMU?.Pitch ?? 0).ToString("0.00");
|
||||||
|
gridDados.Rows[30].Cells[1].Value = (_SensorIMU?.Yaw ?? 0).ToString("0.00");
|
||||||
|
gridDados.Rows[31].Cells[1].Value = (_SensorIMU?.Temperatura ?? 0).ToString("0.00");
|
||||||
|
gridDados.Rows[32].Cells[1].Value = (_SensorIMU?.Pressao ?? 0).ToString("0.00");
|
||||||
|
gridDados.Rows[33].Cells[1].Value = (_SensorIMU?.Altitude ?? 0).ToString("0.00");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ namespace AgroBase.Forms.Operacoes
|
||||||
List<MovSensoriamentoLogModel> LogsMovimentacao = new List<MovSensoriamentoLogModel>();
|
List<MovSensoriamentoLogModel> LogsMovimentacao = new List<MovSensoriamentoLogModel>();
|
||||||
List<AtuSensoriamentoLogModel> LogsAtuador = new List<AtuSensoriamentoLogModel>();
|
List<AtuSensoriamentoLogModel> LogsAtuador = new List<AtuSensoriamentoLogModel>();
|
||||||
List<SensoriamentoMensagemJsonModel> LogsSensoriamento = new List<SensoriamentoMensagemJsonModel>();
|
List<SensoriamentoMensagemJsonModel> LogsSensoriamento = new List<SensoriamentoMensagemJsonModel>();
|
||||||
List<PzmSensoriamentoLogModel> LogsPzem = new List<PzmSensoriamentoLogModel>();
|
|
||||||
List<UltrasonicA05Model> LogsA05 = new List<UltrasonicA05Model>();
|
List<UltrasonicA05Model> LogsA05 = new List<UltrasonicA05Model>();
|
||||||
List<SonarCamModel> LogsSonar = new List<SonarCamModel>();
|
List<SonarCamModel> LogsSonar = new List<SonarCamModel>();
|
||||||
List<List<CamSoloSensoriamentoLogModel>> LogsCam_Solo = new List<List<CamSoloSensoriamentoLogModel>>();
|
List<List<CamSoloSensoriamentoLogModel>> LogsCam_Solo = new List<List<CamSoloSensoriamentoLogModel>>();
|
||||||
|
|
@ -131,7 +130,6 @@ namespace AgroBase.Forms.Operacoes
|
||||||
LogsMovimentacao = JsonConvert.DeserializeObject<MovSensoriamentoLogModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.mov ?? Enums.T_Code.Mov.ToString())).ToList();
|
LogsMovimentacao = JsonConvert.DeserializeObject<MovSensoriamentoLogModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.mov ?? Enums.T_Code.Mov.ToString())).ToList();
|
||||||
LogsAtuador = JsonConvert.DeserializeObject<AtuSensoriamentoLogModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.atu ?? Enums.T_Code.Atu.ToString())).ToList();
|
LogsAtuador = JsonConvert.DeserializeObject<AtuSensoriamentoLogModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.atu ?? Enums.T_Code.Atu.ToString())).ToList();
|
||||||
LogsSensoriamento = JsonConvert.DeserializeObject<SensoriamentoMensagemJsonModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.sen ?? Enums.T_Code.Sen.ToString())).ToList();
|
LogsSensoriamento = JsonConvert.DeserializeObject<SensoriamentoMensagemJsonModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.sen ?? Enums.T_Code.Sen.ToString())).ToList();
|
||||||
LogsPzem = JsonConvert.DeserializeObject<PzmSensoriamentoLogModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.pzm ?? Enums.T_Code.Pzm.ToString())).ToList();
|
|
||||||
LogsA05 = JsonConvert.DeserializeObject<UltrasonicA05Model[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.a05 ?? Enums.T_Code.A05.ToString())).ToList();
|
LogsA05 = JsonConvert.DeserializeObject<UltrasonicA05Model[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.a05 ?? Enums.T_Code.A05.ToString())).ToList();
|
||||||
LogsSonar = JsonConvert.DeserializeObject<SonarCamModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.snr ?? Enums.T_Code.Snr.ToString())).ToList();
|
LogsSonar = JsonConvert.DeserializeObject<SonarCamModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.snr ?? Enums.T_Code.Snr.ToString())).ToList();
|
||||||
LogsCam_Caminho = JsonConvert.DeserializeObject<CamCaminhoSensoriamentoLogModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.cam_caminho)).ToList();
|
LogsCam_Caminho = JsonConvert.DeserializeObject<CamCaminhoSensoriamentoLogModel[]>(OperacaoModel.DeserializarDadosOperacao(ofd.FileName, data.cam_caminho)).ToList();
|
||||||
|
|
@ -628,18 +626,32 @@ namespace AgroBase.Forms.Operacoes
|
||||||
},
|
},
|
||||||
new GraficoInterativoSerieModel()
|
new GraficoInterativoSerieModel()
|
||||||
{
|
{
|
||||||
Titulo = "V Bat",
|
Titulo = "V 24v",
|
||||||
Valores = LogsPzem.Select(x => x?.Tensao ?? 0).ToList(),
|
Valores = LogsSensoriamento.Select(x => x?.SensoresCorrente?.FirstOrDefault(y => y.ID.Contains("24V"))?.BusVoltage ?? 0).ToList(),
|
||||||
Visivel = true,
|
Visivel = true,
|
||||||
MostrarValor = true
|
MostrarValor = true
|
||||||
},
|
},
|
||||||
new GraficoInterativoSerieModel()
|
new GraficoInterativoSerieModel()
|
||||||
{
|
{
|
||||||
Titulo = "A Bat",
|
Titulo = "A 24v",
|
||||||
Valores = LogsPzem.Select(x => x?.Corrente ?? 0).ToList(),
|
Valores = LogsSensoriamento.Select(x => x?.SensoresCorrente?.FirstOrDefault(y => y.ID.Contains("24V"))?.Current ?? 0).ToList(),
|
||||||
Visivel = true,
|
Visivel = true,
|
||||||
MostrarValor = true
|
MostrarValor = true
|
||||||
}
|
},
|
||||||
|
new GraficoInterativoSerieModel()
|
||||||
|
{
|
||||||
|
Titulo = "V 36v",
|
||||||
|
Valores = LogsSensoriamento.Select(x => x?.SensoresCorrente?.FirstOrDefault(y => y.ID.Contains("36V"))?.BusVoltage ?? 0).ToList(),
|
||||||
|
Visivel = true,
|
||||||
|
MostrarValor = true
|
||||||
|
},
|
||||||
|
new GraficoInterativoSerieModel()
|
||||||
|
{
|
||||||
|
Titulo = "A 36v",
|
||||||
|
Valores = LogsSensoriamento.Select(x => x?.SensoresCorrente?.FirstOrDefault(y => y.ID.Contains("36V"))?.Current ?? 0).ToList(),
|
||||||
|
Visivel = true,
|
||||||
|
MostrarValor = true
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
graficoCpu = new GraficoInterativoModel(chartCpu, Momentos, new List<GraficoInterativoSerieModel>()
|
graficoCpu = new GraficoInterativoModel(chartCpu, Momentos, new List<GraficoInterativoSerieModel>()
|
||||||
|
|
@ -1121,7 +1133,6 @@ namespace AgroBase.Forms.Operacoes
|
||||||
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Sen, LogsSensoriamento[idxMomentoAtual].Conectado, LogsSensoriamento[idxMomentoAtual].UltimoComandoRespondido));
|
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Sen, LogsSensoriamento[idxMomentoAtual].Conectado, LogsSensoriamento[idxMomentoAtual].UltimoComandoRespondido));
|
||||||
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Mov, LogsMovimentacao[idxMomentoAtual].Inicializado, LogsMovimentacao[idxMomentoAtual].UltimoComandoRespondido));
|
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Mov, LogsMovimentacao[idxMomentoAtual].Inicializado, LogsMovimentacao[idxMomentoAtual].UltimoComandoRespondido));
|
||||||
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Dir, LogsDirecional[idxMomentoAtual].Inicializado, LogsDirecional[idxMomentoAtual].UltimoComandoRespondido));
|
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Dir, LogsDirecional[idxMomentoAtual].Inicializado, LogsDirecional[idxMomentoAtual].UltimoComandoRespondido));
|
||||||
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Pzm, LogsPzem[idxMomentoAtual].Inicializado, LogsPzem[idxMomentoAtual].UltimoComandoRespondido));
|
|
||||||
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.A05, LogsA05[idxMomentoAtual].Conectado, LogsA05[idxMomentoAtual].UltimoComandoRespondido));
|
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.A05, LogsA05[idxMomentoAtual].Conectado, LogsA05[idxMomentoAtual].UltimoComandoRespondido));
|
||||||
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Gps, LogsGPS[idxMomentoAtual].Inicializado, LogsGPS[idxMomentoAtual].UltimoComandoRespondido));
|
noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Gps, LogsGPS[idxMomentoAtual].Inicializado, LogsGPS[idxMomentoAtual].UltimoComandoRespondido));
|
||||||
//noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Knt, LogsCam_Caminho[idxMomentoAtual].Inicializado, LogsCam_Caminho[idxMomentoAtual].UltimaMensagemRecebida));
|
//noModulos.Nodes.Add(AtualizarTextoStatusModulo(Enums.T_Code.Knt, LogsCam_Caminho[idxMomentoAtual].Inicializado, LogsCam_Caminho[idxMomentoAtual].UltimaMensagemRecebida));
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,10 @@ namespace AgroBase.Forms.Sensoriamento
|
||||||
|
|
||||||
PreencheParametrosSensores();
|
PreencheParametrosSensores();
|
||||||
|
|
||||||
cmbBateriaParametro.Items.Clear();
|
/*cmbBateriaParametro.Items.Clear();
|
||||||
cmbBateriaParametro.Items.Add("Carga Consumida");
|
cmbBateriaParametro.Items.Add("Carga Consumida");
|
||||||
cmbBateriaParametro.Items.AddRange(PZEMService.Parametros.Keys.ToArray());
|
cmbBateriaParametro.Items.AddRange(PZEMService.Parametros.Keys.ToArray());
|
||||||
cmbBateriaParametro.SelectedIndex = 0;
|
cmbBateriaParametro.SelectedIndex = 0;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AtualizarCameras()
|
private void AtualizarCameras()
|
||||||
|
|
@ -220,7 +220,7 @@ namespace AgroBase.Forms.Sensoriamento
|
||||||
|
|
||||||
private void btnBateriaVer_Click(object sender, EventArgs e)
|
private void btnBateriaVer_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (cmbBateriaParametro.SelectedIndex == 0)
|
/*if (cmbBateriaParametro.SelectedIndex == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Carga consumida da bateria: " + PZEMService.ContadorCarga.PercentualConsumido + "%");
|
MessageBox.Show("Carga consumida da bateria: " + PZEMService.ContadorCarga.PercentualConsumido + "%");
|
||||||
}
|
}
|
||||||
|
|
@ -241,12 +241,12 @@ namespace AgroBase.Forms.Sensoriamento
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
PZEMService.ModoLeitura = false;
|
PZEMService.ModoLeitura = false;
|
||||||
});
|
});
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnBateriaDefinir_Click(object sender, EventArgs e)
|
private void btnBateriaDefinir_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (cmbBateriaParametro.SelectedIndex == 0)
|
/*if (cmbBateriaParametro.SelectedIndex == 0)
|
||||||
{
|
{
|
||||||
double consumidoAtual = Convert.ToDouble(nudBateriaValor.Value);
|
double consumidoAtual = Convert.ToDouble(nudBateriaValor.Value);
|
||||||
PZEMService.ContadorCarga.AtualizarValorConsumido(consumidoAtual);
|
PZEMService.ContadorCarga.AtualizarValorConsumido(consumidoAtual);
|
||||||
|
|
@ -261,18 +261,18 @@ namespace AgroBase.Forms.Sensoriamento
|
||||||
Comando = PZEMService.ComandoSetParametro(PZEMService.Parametros[cmbBateriaParametro.Text], Convert.ToInt32(nudBateriaValor.Value))
|
Comando = PZEMService.ComandoSetParametro(PZEMService.Parametros[cmbBateriaParametro.Text], Convert.ToInt32(nudBateriaValor.Value))
|
||||||
};
|
};
|
||||||
ModbusService.AdicionarComandoNaFila(Comando);
|
ModbusService.AdicionarComandoNaFila(Comando);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnBateriaCalibrar_Click(object sender, EventArgs e)
|
private void btnBateriaCalibrar_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var Comando = new ModbusComandoModel()
|
/*var Comando = new ModbusComandoModel()
|
||||||
{
|
{
|
||||||
Dispositivo = T_Code.Pzm,
|
Dispositivo = T_Code.Pzm,
|
||||||
Endereco = PZEMService.slaveAddress,
|
Endereco = PZEMService.slaveAddress,
|
||||||
Comando = PZEMService.ComandoCalibragem()
|
Comando = PZEMService.ComandoCalibragem()
|
||||||
};
|
};
|
||||||
ModbusService.AdicionarComandoNaFila(Comando);
|
ModbusService.AdicionarComandoNaFila(Comando);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ namespace AgroBase.Forms
|
||||||
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmAcompanhamento));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmAcompanhamento));
|
||||||
this.pnlFundo = new System.Windows.Forms.Panel();
|
this.pnlFundo = new System.Windows.Forms.Panel();
|
||||||
|
this.lblB24V = new System.Windows.Forms.Label();
|
||||||
|
this.lblGPSDetalhes = new System.Windows.Forms.Label();
|
||||||
this.lblPerformance = new System.Windows.Forms.Label();
|
this.lblPerformance = new System.Windows.Forms.Label();
|
||||||
this.lblMagnetometro = new System.Windows.Forms.Label();
|
this.lblMagnetometro = new System.Windows.Forms.Label();
|
||||||
this.lblGPS = new System.Windows.Forms.Label();
|
this.lblGPS = new System.Windows.Forms.Label();
|
||||||
|
|
@ -52,15 +54,12 @@ namespace AgroBase.Forms
|
||||||
this.lblU1 = new System.Windows.Forms.Label();
|
this.lblU1 = new System.Windows.Forms.Label();
|
||||||
this.lblU4 = new System.Windows.Forms.Label();
|
this.lblU4 = new System.Windows.Forms.Label();
|
||||||
this.lblU3 = new System.Windows.Forms.Label();
|
this.lblU3 = new System.Windows.Forms.Label();
|
||||||
this.lblUL_A05 = new System.Windows.Forms.Label();
|
|
||||||
this.lblUL_Wit = new System.Windows.Forms.Label();
|
|
||||||
this.lblUL_Pzm = new System.Windows.Forms.Label();
|
|
||||||
this.lblB12V = new System.Windows.Forms.Label();
|
this.lblB12V = new System.Windows.Forms.Label();
|
||||||
this.lblB7V2 = new System.Windows.Forms.Label();
|
this.lblB7V2 = new System.Windows.Forms.Label();
|
||||||
this.lblB5V = new System.Windows.Forms.Label();
|
this.lblB5V = new System.Windows.Forms.Label();
|
||||||
this.lblB3V = new System.Windows.Forms.Label();
|
this.lblB3V = new System.Windows.Forms.Label();
|
||||||
this.lblTemperatura = new System.Windows.Forms.Label();
|
this.lblTemperatura = new System.Windows.Forms.Label();
|
||||||
this.lblTensao = new System.Windows.Forms.Label();
|
this.lblB36V = new System.Windows.Forms.Label();
|
||||||
this.lblDistanciaParcial = new System.Windows.Forms.Label();
|
this.lblDistanciaParcial = new System.Windows.Forms.Label();
|
||||||
this.lblDistanciaTotal = new System.Windows.Forms.Label();
|
this.lblDistanciaTotal = new System.Windows.Forms.Label();
|
||||||
this.lblTempoEmMovimento = new System.Windows.Forms.Label();
|
this.lblTempoEmMovimento = new System.Windows.Forms.Label();
|
||||||
|
|
@ -126,7 +125,7 @@ namespace AgroBase.Forms
|
||||||
this.lblEFA_SP = new System.Windows.Forms.Label();
|
this.lblEFA_SP = new System.Windows.Forms.Label();
|
||||||
this.lblM_EF = new System.Windows.Forms.Label();
|
this.lblM_EF = new System.Windows.Forms.Label();
|
||||||
this.picEF = new System.Windows.Forms.PictureBox();
|
this.picEF = new System.Windows.Forms.PictureBox();
|
||||||
this.lblGPSDetalhes = new System.Windows.Forms.Label();
|
this.lblB19V = new System.Windows.Forms.Label();
|
||||||
this.pnlFundo.SuspendLayout();
|
this.pnlFundo.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.chartET)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.chartET)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.chartDT)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.chartDT)).BeginInit();
|
||||||
|
|
@ -143,6 +142,8 @@ namespace AgroBase.Forms
|
||||||
//
|
//
|
||||||
this.pnlFundo.AutoScroll = true;
|
this.pnlFundo.AutoScroll = true;
|
||||||
this.pnlFundo.BackColor = System.Drawing.Color.White;
|
this.pnlFundo.BackColor = System.Drawing.Color.White;
|
||||||
|
this.pnlFundo.Controls.Add(this.lblB19V);
|
||||||
|
this.pnlFundo.Controls.Add(this.lblB24V);
|
||||||
this.pnlFundo.Controls.Add(this.lblGPSDetalhes);
|
this.pnlFundo.Controls.Add(this.lblGPSDetalhes);
|
||||||
this.pnlFundo.Controls.Add(this.lblPerformance);
|
this.pnlFundo.Controls.Add(this.lblPerformance);
|
||||||
this.pnlFundo.Controls.Add(this.lblMagnetometro);
|
this.pnlFundo.Controls.Add(this.lblMagnetometro);
|
||||||
|
|
@ -153,15 +154,12 @@ namespace AgroBase.Forms
|
||||||
this.pnlFundo.Controls.Add(this.lblU1);
|
this.pnlFundo.Controls.Add(this.lblU1);
|
||||||
this.pnlFundo.Controls.Add(this.lblU4);
|
this.pnlFundo.Controls.Add(this.lblU4);
|
||||||
this.pnlFundo.Controls.Add(this.lblU3);
|
this.pnlFundo.Controls.Add(this.lblU3);
|
||||||
this.pnlFundo.Controls.Add(this.lblUL_A05);
|
|
||||||
this.pnlFundo.Controls.Add(this.lblUL_Wit);
|
|
||||||
this.pnlFundo.Controls.Add(this.lblUL_Pzm);
|
|
||||||
this.pnlFundo.Controls.Add(this.lblB12V);
|
this.pnlFundo.Controls.Add(this.lblB12V);
|
||||||
this.pnlFundo.Controls.Add(this.lblB7V2);
|
this.pnlFundo.Controls.Add(this.lblB7V2);
|
||||||
this.pnlFundo.Controls.Add(this.lblB5V);
|
this.pnlFundo.Controls.Add(this.lblB5V);
|
||||||
this.pnlFundo.Controls.Add(this.lblB3V);
|
this.pnlFundo.Controls.Add(this.lblB3V);
|
||||||
this.pnlFundo.Controls.Add(this.lblTemperatura);
|
this.pnlFundo.Controls.Add(this.lblTemperatura);
|
||||||
this.pnlFundo.Controls.Add(this.lblTensao);
|
this.pnlFundo.Controls.Add(this.lblB36V);
|
||||||
this.pnlFundo.Controls.Add(this.lblDistanciaParcial);
|
this.pnlFundo.Controls.Add(this.lblDistanciaParcial);
|
||||||
this.pnlFundo.Controls.Add(this.lblDistanciaTotal);
|
this.pnlFundo.Controls.Add(this.lblDistanciaTotal);
|
||||||
this.pnlFundo.Controls.Add(this.lblTempoEmMovimento);
|
this.pnlFundo.Controls.Add(this.lblTempoEmMovimento);
|
||||||
|
|
@ -234,6 +232,27 @@ namespace AgroBase.Forms
|
||||||
this.pnlFundo.Size = new System.Drawing.Size(1473, 811);
|
this.pnlFundo.Size = new System.Drawing.Size(1473, 811);
|
||||||
this.pnlFundo.TabIndex = 0;
|
this.pnlFundo.TabIndex = 0;
|
||||||
//
|
//
|
||||||
|
// lblB24V
|
||||||
|
//
|
||||||
|
this.lblB24V.AutoSize = true;
|
||||||
|
this.lblB24V.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.lblB24V.Location = new System.Drawing.Point(656, 708);
|
||||||
|
this.lblB24V.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.lblB24V.Name = "lblB24V";
|
||||||
|
this.lblB24V.Size = new System.Drawing.Size(129, 12);
|
||||||
|
this.lblB24V.TabIndex = 191;
|
||||||
|
this.lblB24V.Text = "Barramento 24V: 0,00V 0,00A";
|
||||||
|
//
|
||||||
|
// lblGPSDetalhes
|
||||||
|
//
|
||||||
|
this.lblGPSDetalhes.AutoSize = true;
|
||||||
|
this.lblGPSDetalhes.Location = new System.Drawing.Point(674, 115);
|
||||||
|
this.lblGPSDetalhes.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.lblGPSDetalhes.Name = "lblGPSDetalhes";
|
||||||
|
this.lblGPSDetalhes.Size = new System.Drawing.Size(118, 13);
|
||||||
|
this.lblGPSDetalhes.TabIndex = 190;
|
||||||
|
this.lblGPSDetalhes.Text = "SemCorrecao - 0,00 cm";
|
||||||
|
//
|
||||||
// lblPerformance
|
// lblPerformance
|
||||||
//
|
//
|
||||||
this.lblPerformance.AutoSize = true;
|
this.lblPerformance.AutoSize = true;
|
||||||
|
|
@ -331,39 +350,6 @@ namespace AgroBase.Forms
|
||||||
this.lblU3.TabIndex = 181;
|
this.lblU3.TabIndex = 181;
|
||||||
this.lblU3.Text = "U3: 0 mm";
|
this.lblU3.Text = "U3: 0 mm";
|
||||||
//
|
//
|
||||||
// lblUL_A05
|
|
||||||
//
|
|
||||||
this.lblUL_A05.AutoSize = true;
|
|
||||||
this.lblUL_A05.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
||||||
this.lblUL_A05.Location = new System.Drawing.Point(656, 755);
|
|
||||||
this.lblUL_A05.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
|
||||||
this.lblUL_A05.Name = "lblUL_A05";
|
|
||||||
this.lblUL_A05.Size = new System.Drawing.Size(122, 12);
|
|
||||||
this.lblUL_A05.TabIndex = 180;
|
|
||||||
this.lblUL_A05.Text = "Ultima Leitura A05: 00:00:00";
|
|
||||||
//
|
|
||||||
// lblUL_Wit
|
|
||||||
//
|
|
||||||
this.lblUL_Wit.AutoSize = true;
|
|
||||||
this.lblUL_Wit.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
||||||
this.lblUL_Wit.Location = new System.Drawing.Point(656, 743);
|
|
||||||
this.lblUL_Wit.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
|
||||||
this.lblUL_Wit.Name = "lblUL_Wit";
|
|
||||||
this.lblUL_Wit.Size = new System.Drawing.Size(122, 12);
|
|
||||||
this.lblUL_Wit.TabIndex = 179;
|
|
||||||
this.lblUL_Wit.Text = "Ultima Leitura WIT: 00:00:00";
|
|
||||||
//
|
|
||||||
// lblUL_Pzm
|
|
||||||
//
|
|
||||||
this.lblUL_Pzm.AutoSize = true;
|
|
||||||
this.lblUL_Pzm.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
|
||||||
this.lblUL_Pzm.Location = new System.Drawing.Point(656, 731);
|
|
||||||
this.lblUL_Pzm.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
|
||||||
this.lblUL_Pzm.Name = "lblUL_Pzm";
|
|
||||||
this.lblUL_Pzm.Size = new System.Drawing.Size(126, 12);
|
|
||||||
this.lblUL_Pzm.TabIndex = 178;
|
|
||||||
this.lblUL_Pzm.Text = "Ultima Leitura PZM: 00:00:00";
|
|
||||||
//
|
|
||||||
// lblB12V
|
// lblB12V
|
||||||
//
|
//
|
||||||
this.lblB12V.AutoSize = true;
|
this.lblB12V.AutoSize = true;
|
||||||
|
|
@ -412,23 +398,23 @@ namespace AgroBase.Forms
|
||||||
//
|
//
|
||||||
this.lblTemperatura.AutoSize = true;
|
this.lblTemperatura.AutoSize = true;
|
||||||
this.lblTemperatura.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.lblTemperatura.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.lblTemperatura.Location = new System.Drawing.Point(656, 692);
|
this.lblTemperatura.Location = new System.Drawing.Point(656, 758);
|
||||||
this.lblTemperatura.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
this.lblTemperatura.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
this.lblTemperatura.Name = "lblTemperatura";
|
this.lblTemperatura.Name = "lblTemperatura";
|
||||||
this.lblTemperatura.Size = new System.Drawing.Size(33, 12);
|
this.lblTemperatura.Size = new System.Drawing.Size(33, 12);
|
||||||
this.lblTemperatura.TabIndex = 173;
|
this.lblTemperatura.TabIndex = 173;
|
||||||
this.lblTemperatura.Text = "0,00ºC";
|
this.lblTemperatura.Text = "0,00ºC";
|
||||||
//
|
//
|
||||||
// lblTensao
|
// lblB36V
|
||||||
//
|
//
|
||||||
this.lblTensao.AutoSize = true;
|
this.lblB36V.AutoSize = true;
|
||||||
this.lblTensao.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
this.lblB36V.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.lblTensao.Location = new System.Drawing.Point(656, 611);
|
this.lblB36V.Location = new System.Drawing.Point(656, 724);
|
||||||
this.lblTensao.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
this.lblB36V.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
this.lblTensao.Name = "lblTensao";
|
this.lblB36V.Name = "lblB36V";
|
||||||
this.lblTensao.Size = new System.Drawing.Size(136, 12);
|
this.lblB36V.Size = new System.Drawing.Size(129, 12);
|
||||||
this.lblTensao.TabIndex = 171;
|
this.lblB36V.TabIndex = 171;
|
||||||
this.lblTensao.Text = "Bateria: 0,00 V - 0,00 A - 0,00 W";
|
this.lblB36V.Text = "Barramento 36V: 0,00V 0,00A";
|
||||||
//
|
//
|
||||||
// lblDistanciaParcial
|
// lblDistanciaParcial
|
||||||
//
|
//
|
||||||
|
|
@ -1109,15 +1095,16 @@ namespace AgroBase.Forms
|
||||||
this.picEF.TabIndex = 90;
|
this.picEF.TabIndex = 90;
|
||||||
this.picEF.TabStop = false;
|
this.picEF.TabStop = false;
|
||||||
//
|
//
|
||||||
// lblGPSDetalhes
|
// lblB19V
|
||||||
//
|
//
|
||||||
this.lblGPSDetalhes.AutoSize = true;
|
this.lblB19V.AutoSize = true;
|
||||||
this.lblGPSDetalhes.Location = new System.Drawing.Point(674, 115);
|
this.lblB19V.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
this.lblGPSDetalhes.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
this.lblB19V.Location = new System.Drawing.Point(656, 692);
|
||||||
this.lblGPSDetalhes.Name = "lblGPSDetalhes";
|
this.lblB19V.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
this.lblGPSDetalhes.Size = new System.Drawing.Size(118, 13);
|
this.lblB19V.Name = "lblB19V";
|
||||||
this.lblGPSDetalhes.TabIndex = 190;
|
this.lblB19V.Size = new System.Drawing.Size(129, 12);
|
||||||
this.lblGPSDetalhes.Text = "SemCorrecao - 0,00 cm";
|
this.lblB19V.TabIndex = 192;
|
||||||
|
this.lblB19V.Text = "Barramento 19V: 0,00V 0,00A";
|
||||||
//
|
//
|
||||||
// frmAcompanhamento
|
// frmAcompanhamento
|
||||||
//
|
//
|
||||||
|
|
@ -1214,16 +1201,13 @@ namespace AgroBase.Forms
|
||||||
private System.Windows.Forms.Label lblDistanciaTotal;
|
private System.Windows.Forms.Label lblDistanciaTotal;
|
||||||
private System.Windows.Forms.Label lblTempoEmMovimento;
|
private System.Windows.Forms.Label lblTempoEmMovimento;
|
||||||
private System.Windows.Forms.Label lblTempoConectado;
|
private System.Windows.Forms.Label lblTempoConectado;
|
||||||
public System.Windows.Forms.Label lblTensao;
|
public System.Windows.Forms.Label lblB36V;
|
||||||
public System.Windows.Forms.Label lblTemperatura;
|
public System.Windows.Forms.Label lblTemperatura;
|
||||||
public System.Windows.Forms.Label lblB12V;
|
public System.Windows.Forms.Label lblB12V;
|
||||||
public System.Windows.Forms.Label lblB7V2;
|
public System.Windows.Forms.Label lblB7V2;
|
||||||
public System.Windows.Forms.Label lblB5V;
|
public System.Windows.Forms.Label lblB5V;
|
||||||
public System.Windows.Forms.Label lblB3V;
|
public System.Windows.Forms.Label lblB3V;
|
||||||
private System.Windows.Forms.Label lblEFM_Tensao;
|
private System.Windows.Forms.Label lblEFM_Tensao;
|
||||||
public System.Windows.Forms.Label lblUL_Wit;
|
|
||||||
public System.Windows.Forms.Label lblUL_Pzm;
|
|
||||||
public System.Windows.Forms.Label lblUL_A05;
|
|
||||||
private System.Windows.Forms.Label lblU4;
|
private System.Windows.Forms.Label lblU4;
|
||||||
private System.Windows.Forms.Label lblU3;
|
private System.Windows.Forms.Label lblU3;
|
||||||
private System.Windows.Forms.Label lblU2;
|
private System.Windows.Forms.Label lblU2;
|
||||||
|
|
@ -1234,5 +1218,7 @@ namespace AgroBase.Forms
|
||||||
private System.Windows.Forms.Panel pnlOrientacaoGPS;
|
private System.Windows.Forms.Panel pnlOrientacaoGPS;
|
||||||
private System.Windows.Forms.Label lblPerformance;
|
private System.Windows.Forms.Label lblPerformance;
|
||||||
private System.Windows.Forms.Label lblGPSDetalhes;
|
private System.Windows.Forms.Label lblGPSDetalhes;
|
||||||
|
public System.Windows.Forms.Label lblB24V;
|
||||||
|
public System.Windows.Forms.Label lblB19V;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -50,16 +50,9 @@ namespace AgroBase.Forms
|
||||||
|
|
||||||
AtualzarDadosMovimentacao();
|
AtualzarDadosMovimentacao();
|
||||||
|
|
||||||
lblUL_Pzm.ForeColor = PZEMService.Iniciado ? Color.Green : Color.Red;
|
|
||||||
if (PZEMService.Iniciado)
|
|
||||||
{
|
|
||||||
lblUL_Pzm.Text = "Ultima Leitura PZM: " + PZEMService.UltimaLeitura.DataHora.ToString("HH:mm:ss");
|
|
||||||
lblTensao.Text = "Bateria: " + PZEMService.UltimaLeitura.Tensao.ToString("0.00") + " V - " + PZEMService.UltimaLeitura.Corrente.ToString("0.00") + " A - " + PZEMService.UltimaLeitura.Potencia.ToString("0.00") + " W";
|
|
||||||
}
|
|
||||||
lblUL_A05.ForeColor = UltrasonicA05Service.Iniciado ? Color.Green : Color.Red;
|
|
||||||
if (UltrasonicA05Service.Iniciado)
|
if (UltrasonicA05Service.Iniciado)
|
||||||
{
|
{
|
||||||
lblUL_A05.Text = "Ultima Leitura A05: " + UltrasonicA05Service.DadosLeitura.Momento.ToString("HH:mm:ss");
|
//lblUL_A05.Text = "Ultima Leitura A05: " + UltrasonicA05Service.DadosLeitura.Momento.ToString("HH:mm:ss");
|
||||||
lblU1.Text = "U1: " + UltrasonicA05Service.DadosLeitura.Configuracao.Sensores[0].LeituraCm.ToString("") + " cm";
|
lblU1.Text = "U1: " + UltrasonicA05Service.DadosLeitura.Configuracao.Sensores[0].LeituraCm.ToString("") + " cm";
|
||||||
lblU2.Text = "U2: " + UltrasonicA05Service.DadosLeitura.Configuracao.Sensores[1].LeituraCm.ToString("") + " cm";
|
lblU2.Text = "U2: " + UltrasonicA05Service.DadosLeitura.Configuracao.Sensores[1].LeituraCm.ToString("") + " cm";
|
||||||
lblU3.Text = "U3: " + UltrasonicA05Service.DadosLeitura.Configuracao.Sensores[2].LeituraCm.ToString("") + " cm";
|
lblU3.Text = "U3: " + UltrasonicA05Service.DadosLeitura.Configuracao.Sensores[2].LeituraCm.ToString("") + " cm";
|
||||||
|
|
@ -71,7 +64,9 @@ namespace AgroBase.Forms
|
||||||
AtualizarDadosSensorCorrente("AB5V", lblB5V);
|
AtualizarDadosSensorCorrente("AB5V", lblB5V);
|
||||||
AtualizarDadosSensorCorrente("AB7V2", lblB7V2);
|
AtualizarDadosSensorCorrente("AB7V2", lblB7V2);
|
||||||
AtualizarDadosSensorCorrente("AB12V", lblB12V);
|
AtualizarDadosSensorCorrente("AB12V", lblB12V);
|
||||||
AtualizarDadosSensorCorrente("AB36V", lblTensao);
|
AtualizarDadosSensorCorrente("AB19V", lblB19V);
|
||||||
|
AtualizarDadosSensorCorrente("AB24V", lblB24V);
|
||||||
|
AtualizarDadosSensorCorrente("AB36V", lblB36V);
|
||||||
}
|
}
|
||||||
|
|
||||||
lblMagnetometro.ForeColor = (Variaveis.OperacaoEmAndamento.DispSen?.Dados?.DadosLeitura?.SensoresIMU?.DefaultIfEmpty()?.FirstOrDefault()?.Iniciado ?? false) ? Color.Green : Color.Red;
|
lblMagnetometro.ForeColor = (Variaveis.OperacaoEmAndamento.DispSen?.Dados?.DadosLeitura?.SensoresIMU?.DefaultIfEmpty()?.FirstOrDefault()?.Iniciado ?? false) ? Color.Green : Color.Red;
|
||||||
|
|
@ -91,7 +86,7 @@ namespace AgroBase.Forms
|
||||||
var sensor = Variaveis.OperacaoEmAndamento.DispSen.Dados.DadosLeitura.SensoresCorrente.FirstOrDefault(x => x.ID == id);
|
var sensor = Variaveis.OperacaoEmAndamento.DispSen.Dados.DadosLeitura.SensoresCorrente.FirstOrDefault(x => x.ID == id);
|
||||||
if (sensor != null)
|
if (sensor != null)
|
||||||
{
|
{
|
||||||
lbl.Text = $"{id.Replace("AB", "Barramento ")}: {sensor.BusVoltage.ToString("0.00")} V, {(sensor.Current ?? -1).ToString("0.00")} mA, {sensor.Power.ToString("0.00")} W, {sensor.Temperature.ToString("0.00")} ºC, {sensor.Energy.ToString("0.00")} Wh";
|
lbl.Text = $"{id.Replace("AB", "Barramento ")}: {sensor.BusVoltage.ToString("0.00")} V, {sensor.Current.ToString("0.00")} mA, {sensor.Power.ToString("0.00")} W, {sensor.Temperature.ToString("0.00")} ºC, {sensor.Energy.ToString("0.00")} Wh";
|
||||||
lbl.ForeColor = sensor.Iniciado ? Color.Green : Color.Red;
|
lbl.ForeColor = sensor.Iniciado ? Color.Green : Color.Red;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,13 @@
|
||||||
Corredores = 3
|
Corredores = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum TiposShuntCorrente
|
||||||
|
{
|
||||||
|
INA219_3A2 = 0,
|
||||||
|
INA228_10A = 1,
|
||||||
|
INA228_50A = 2,
|
||||||
|
INA228_100A = 3,
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using AgroBase.Forms.IHM;
|
using AgroBase.Forms.IHM;
|
||||||
using AgroBase.Services;
|
using AgroBase.Services;
|
||||||
|
using OpenHardwareMonitor.Hardware;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
@ -441,16 +442,18 @@ namespace AgroBase.Models.Modules
|
||||||
config.AddRange(protocoloMOD);
|
config.AddRange(protocoloMOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool configurarTodos = !DadosLeitura.Conectado && Conectar;
|
||||||
|
|
||||||
// Adicionar configurações dos Sensores que devem ser aferidos
|
// Adicionar configurações dos Sensores que devem ser aferidos
|
||||||
List<byte[]> sensoresConfig = SensoresConfig(Conectar);
|
List<byte[]> sensoresConfig = SensoresConfig(Conectar, configurarTodos);
|
||||||
config.AddRange(sensoresConfig);
|
config.AddRange(sensoresConfig);
|
||||||
|
|
||||||
// Adicionar configurações dos Bicos
|
// Adicionar configurações dos Bicos
|
||||||
List<byte[]> bicosConfig = BicosConfig(Conectar);
|
List<byte[]> bicosConfig = BicosConfig(Conectar, configurarTodos);
|
||||||
config.AddRange(bicosConfig);
|
config.AddRange(bicosConfig);
|
||||||
|
|
||||||
// Adicionar configurações das Bombas
|
// Adicionar configurações das Bombas
|
||||||
List<byte[]> bombasConfig = BombasConfig(Conectar);
|
List<byte[]> bombasConfig = BombasConfig(Conectar, configurarTodos);
|
||||||
config.AddRange(bombasConfig);
|
config.AddRange(bombasConfig);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
|
|
@ -483,12 +486,16 @@ namespace AgroBase.Models.Modules
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<byte[]> SensoresConfig(bool Conectar)
|
private List<byte[]> SensoresConfig(bool Conectar, bool ConfigurarTodos)
|
||||||
{
|
{
|
||||||
var config = new List<byte[]>();
|
var config = new List<byte[]>();
|
||||||
|
|
||||||
foreach (var sensor in Sensores.Where(x => x.Aferir && x.Inicializado != Conectar))
|
foreach (var sensor in Sensores.Where(x => (x.Aferir && (ConfigurarTodos ? true : x.Inicializado != Conectar)) || (!x.Aferir && x.Inicializado)))
|
||||||
{
|
{
|
||||||
|
if (!sensor.Aferir && sensor.Inicializado)
|
||||||
|
{
|
||||||
|
Conectar = false;
|
||||||
|
}
|
||||||
byte[] payload = sensor.ProtocoloConfiguracao(Pinout, Conectar, Dispositivo);
|
byte[] payload = sensor.ProtocoloConfiguracao(Pinout, Conectar, Dispositivo);
|
||||||
if (payload != null)
|
if (payload != null)
|
||||||
{
|
{
|
||||||
|
|
@ -499,12 +506,16 @@ namespace AgroBase.Models.Modules
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<byte[]> BicosConfig(bool Conectar)
|
private List<byte[]> BicosConfig(bool Conectar, bool ConfigurarTodos)
|
||||||
{
|
{
|
||||||
var config = new List<byte[]>();
|
var config = new List<byte[]>();
|
||||||
|
|
||||||
foreach (var bico in BicosPulverizadores.Where(x => x.Comandar && x.Inicializado != Conectar))
|
foreach (var bico in BicosPulverizadores.Where(x => (x.Comandar && (ConfigurarTodos ? true : x.Inicializado != Conectar)) || (!x.Comandar && x.Inicializado)))
|
||||||
{
|
{
|
||||||
|
if (!bico.Comandar && bico.Inicializado)
|
||||||
|
{
|
||||||
|
Conectar = false;
|
||||||
|
}
|
||||||
var payload = bico.ProtocoloConfiguracao(Pinout, Conectar);
|
var payload = bico.ProtocoloConfiguracao(Pinout, Conectar);
|
||||||
if (payload != null)
|
if (payload != null)
|
||||||
{
|
{
|
||||||
|
|
@ -515,12 +526,16 @@ namespace AgroBase.Models.Modules
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<byte[]> BombasConfig(bool Conectar)
|
private List<byte[]> BombasConfig(bool Conectar, bool ConfigurarTodos)
|
||||||
{
|
{
|
||||||
var config = new List<byte[]>();
|
var config = new List<byte[]>();
|
||||||
|
|
||||||
foreach (var bomba in BombasPressurizadoras.Where(x => x.Comandar && x.Inicializado != Conectar))
|
foreach (var bomba in BombasPressurizadoras.Where(x => (x.Comandar && (ConfigurarTodos ? true : x.Inicializado != Conectar)) || (!x.Comandar && x.Inicializado)))
|
||||||
{
|
{
|
||||||
|
if (!bomba.Comandar && bomba.Inicializado)
|
||||||
|
{
|
||||||
|
Conectar = false;
|
||||||
|
}
|
||||||
var payload = bomba.ProtocoloConfiguracao(Pinout, Conectar);
|
var payload = bomba.ProtocoloConfiguracao(Pinout, Conectar);
|
||||||
if (payload != null)
|
if (payload != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,6 @@ namespace AgroBase.Models.Modules
|
||||||
public string CameraID_Caminho { get; set; } = "";
|
public string CameraID_Caminho { get; set; } = "";
|
||||||
public List<string> CameraID_Solo { get; set; } = new List<string>();
|
public List<string> CameraID_Solo { get; set; } = new List<string>();
|
||||||
public UltrasonicA05Configuracoes ConfiguracaoSensorUltrassom { get; set; }
|
public UltrasonicA05Configuracoes ConfiguracaoSensorUltrassom { get; set; }
|
||||||
public double BateriaCargaConsumida { get; set; }
|
|
||||||
public SensoriamentoMensagemJsonModel DadosLeitura { get; set; } = new SensoriamentoMensagemJsonModel();
|
public SensoriamentoMensagemJsonModel DadosLeitura { get; set; } = new SensoriamentoMensagemJsonModel();
|
||||||
private SenHandler _SenHandler = new SenHandler();
|
private SenHandler _SenHandler = new SenHandler();
|
||||||
public LoRaParametrosModel LoRaParametrosBase { get; set; } = new LoRaParametrosModel()
|
public LoRaParametrosModel LoRaParametrosBase { get; set; } = new LoRaParametrosModel()
|
||||||
|
|
@ -61,7 +60,7 @@ namespace AgroBase.Models.Modules
|
||||||
worCycle = LoRaService.CodigosWorCycles[4000],
|
worCycle = LoRaService.CodigosWorCycles[4000],
|
||||||
power = LoRaService.CodigosPowers[22],
|
power = LoRaService.CodigosPowers[22],
|
||||||
};
|
};
|
||||||
|
public CoulombCounterService ContadorCarga = new CoulombCounterService(VariaveisEquipamento.CorrenteMaximaBateria);
|
||||||
public AsyncTaskTimerModel tmrRegistrador;
|
public AsyncTaskTimerModel tmrRegistrador;
|
||||||
private int _TempoReconexaoComponentes = 5;
|
private int _TempoReconexaoComponentes = 5;
|
||||||
private int _VezesLeituraReconexao = 0;
|
private int _VezesLeituraReconexao = 0;
|
||||||
|
|
@ -253,17 +252,25 @@ namespace AgroBase.Models.Modules
|
||||||
new SensorParametroModel()
|
new SensorParametroModel()
|
||||||
{
|
{
|
||||||
Descricao = "Endereço I2C",
|
Descricao = "Endereço I2C",
|
||||||
Valor = "0x45",
|
Valor = "0x40",
|
||||||
QtdBytes = 1,
|
QtdBytes = 1,
|
||||||
Escalar = false,
|
Escalar = false,
|
||||||
Enviar = true
|
Enviar = true
|
||||||
},
|
},
|
||||||
new SensorParametroModel()
|
new SensorParametroModel()
|
||||||
{
|
{
|
||||||
Descricao = "Corrente Máx",
|
Descricao = "Shunt",
|
||||||
Valor = (3.2).ToString(),
|
Valor = ((int)TiposShuntCorrente.INA219_3A2).ToString(),
|
||||||
QtdBytes = 2,
|
QtdBytes = 1,
|
||||||
Escalar = true,
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Canal MUX",
|
||||||
|
Valor = "0",
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
Enviar = true
|
Enviar = true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -285,17 +292,25 @@ namespace AgroBase.Models.Modules
|
||||||
new SensorParametroModel()
|
new SensorParametroModel()
|
||||||
{
|
{
|
||||||
Descricao = "Endereço I2C",
|
Descricao = "Endereço I2C",
|
||||||
Valor = "0x41",
|
Valor = "0x40",
|
||||||
QtdBytes = 1,
|
QtdBytes = 1,
|
||||||
Escalar = false,
|
Escalar = false,
|
||||||
Enviar = true
|
Enviar = true
|
||||||
},
|
},
|
||||||
new SensorParametroModel()
|
new SensorParametroModel()
|
||||||
{
|
{
|
||||||
Descricao = "Corrente Máx",
|
Descricao = "Shunt",
|
||||||
Valor = (3.2).ToString(),
|
Valor = ((int)TiposShuntCorrente.INA219_3A2).ToString(),
|
||||||
QtdBytes = 2,
|
QtdBytes = 1,
|
||||||
Escalar = true,
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Canal MUX",
|
||||||
|
Valor = "1",
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
Enviar = true
|
Enviar = true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -317,17 +332,25 @@ namespace AgroBase.Models.Modules
|
||||||
new SensorParametroModel()
|
new SensorParametroModel()
|
||||||
{
|
{
|
||||||
Descricao = "Endereço I2C",
|
Descricao = "Endereço I2C",
|
||||||
Valor = "0x44",
|
Valor = "0x40",
|
||||||
QtdBytes = 1,
|
QtdBytes = 1,
|
||||||
Escalar = false,
|
Escalar = false,
|
||||||
Enviar = true
|
Enviar = true
|
||||||
},
|
},
|
||||||
new SensorParametroModel()
|
new SensorParametroModel()
|
||||||
{
|
{
|
||||||
Descricao = "Corrente Máx",
|
Descricao = "Shunt",
|
||||||
Valor = (50).ToString(),
|
Valor = ((int)TiposShuntCorrente.INA219_3A2).ToString(),
|
||||||
QtdBytes = 2,
|
QtdBytes = 1,
|
||||||
Escalar = true,
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Canal MUX",
|
||||||
|
Valor = "2",
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
Enviar = true
|
Enviar = true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -356,10 +379,98 @@ namespace AgroBase.Models.Modules
|
||||||
},
|
},
|
||||||
new SensorParametroModel()
|
new SensorParametroModel()
|
||||||
{
|
{
|
||||||
Descricao = "Corrente Máx",
|
Descricao = "Shunt",
|
||||||
Valor = (100).ToString(),
|
Valor = ((int)TiposShuntCorrente.INA228_50A).ToString(),
|
||||||
QtdBytes = 2,
|
QtdBytes = 1,
|
||||||
Escalar = true,
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Canal MUX",
|
||||||
|
Valor = "3",
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new SensorModel()
|
||||||
|
{
|
||||||
|
ID = "AB19V",
|
||||||
|
Descricao = "Corrente no Barramento 19V",
|
||||||
|
ID_Num = 15,
|
||||||
|
Componente = S_Code.sCOR,
|
||||||
|
Aferir = true,
|
||||||
|
Funcoes = new List<FuncoesPinout>()
|
||||||
|
{
|
||||||
|
FuncoesPinout.I2C,
|
||||||
|
},
|
||||||
|
UnidadeMedida = "mA",
|
||||||
|
Parametros = new List<SensorParametroModel>()
|
||||||
|
{
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Endereço I2C",
|
||||||
|
Valor = "0x40",
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Shunt",
|
||||||
|
Valor = ((int)TiposShuntCorrente.INA228_10A).ToString(),
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Canal MUX",
|
||||||
|
Valor = "4",
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new SensorModel()
|
||||||
|
{
|
||||||
|
ID = "AB24V",
|
||||||
|
Descricao = "Corrente no Barramento 24V",
|
||||||
|
ID_Num = 16,
|
||||||
|
Componente = S_Code.sCOR,
|
||||||
|
Aferir = true,
|
||||||
|
Funcoes = new List<FuncoesPinout>()
|
||||||
|
{
|
||||||
|
FuncoesPinout.I2C,
|
||||||
|
},
|
||||||
|
UnidadeMedida = "mA",
|
||||||
|
Parametros = new List<SensorParametroModel>()
|
||||||
|
{
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Endereço I2C",
|
||||||
|
Valor = "0x40",
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Shunt",
|
||||||
|
Valor = ((int)TiposShuntCorrente.INA228_50A).ToString(),
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Canal MUX",
|
||||||
|
Valor = "5",
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
Enviar = true
|
Enviar = true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -368,7 +479,7 @@ namespace AgroBase.Models.Modules
|
||||||
{
|
{
|
||||||
ID = "AB36V",
|
ID = "AB36V",
|
||||||
Descricao = "Corrente no Barramento 36V",
|
Descricao = "Corrente no Barramento 36V",
|
||||||
ID_Num = 15,
|
ID_Num = 17,
|
||||||
Componente = S_Code.sCOR,
|
Componente = S_Code.sCOR,
|
||||||
Aferir = true,
|
Aferir = true,
|
||||||
Funcoes = new List<FuncoesPinout>()
|
Funcoes = new List<FuncoesPinout>()
|
||||||
|
|
@ -388,10 +499,18 @@ namespace AgroBase.Models.Modules
|
||||||
},
|
},
|
||||||
new SensorParametroModel()
|
new SensorParametroModel()
|
||||||
{
|
{
|
||||||
Descricao = "Corrente Máx",
|
Descricao = "Shunt",
|
||||||
Valor = (100).ToString(),
|
Valor = ((int)TiposShuntCorrente.INA228_100A).ToString(),
|
||||||
QtdBytes = 2,
|
QtdBytes = 1,
|
||||||
Escalar = true,
|
Escalar = false,
|
||||||
|
Enviar = true
|
||||||
|
},
|
||||||
|
new SensorParametroModel()
|
||||||
|
{
|
||||||
|
Descricao = "Canal MUX",
|
||||||
|
Valor = "6",
|
||||||
|
QtdBytes = 1,
|
||||||
|
Escalar = false,
|
||||||
Enviar = true
|
Enviar = true
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -695,20 +814,22 @@ namespace AgroBase.Models.Modules
|
||||||
config.AddRange(protocoloMOD);
|
config.AddRange(protocoloMOD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool configurarTodos = !DadosLeitura.Conectado && Conectar;
|
||||||
|
|
||||||
// Adicionar configurações dos Sinaleiros
|
// Adicionar configurações dos Sinaleiros
|
||||||
List<byte[]> sinaleirosConfig = SinaleirosConfig(Conectar);
|
List<byte[]> sinaleirosConfig = SinaleirosConfig(Conectar, configurarTodos);
|
||||||
config.AddRange(sinaleirosConfig);
|
config.AddRange(sinaleirosConfig);
|
||||||
|
|
||||||
// Adicionar configurações dos Servos
|
// Adicionar configurações dos Servos
|
||||||
List<byte[]> servosConfig = ServosConfig(Conectar);
|
List<byte[]> servosConfig = ServosConfig(Conectar, configurarTodos);
|
||||||
config.AddRange(servosConfig);
|
config.AddRange(servosConfig);
|
||||||
|
|
||||||
// Adicionar configurações dos Reles
|
// Adicionar configurações dos Reles
|
||||||
List<byte[]> relesConfig = RelesConfig(Conectar);
|
List<byte[]> relesConfig = RelesConfig(Conectar, configurarTodos);
|
||||||
config.AddRange(relesConfig);
|
config.AddRange(relesConfig);
|
||||||
|
|
||||||
// Adicionar configurações dos Sensores que devem ser aferidos
|
// Adicionar configurações dos Sensores que devem ser aferidos
|
||||||
List<byte[]> sensoresConfig = SensoresConfig(Conectar);
|
List<byte[]> sensoresConfig = SensoresConfig(Conectar, configurarTodos);
|
||||||
config.AddRange(sensoresConfig);
|
config.AddRange(sensoresConfig);
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
|
|
@ -741,12 +862,16 @@ namespace AgroBase.Models.Modules
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<byte[]> SensoresConfig(bool Conectar)
|
public List<byte[]> SensoresConfig(bool Conectar, bool ConfigurarTodos)
|
||||||
{
|
{
|
||||||
var config = new List<byte[]>();
|
var config = new List<byte[]>();
|
||||||
|
|
||||||
foreach (var sensor in Sensores.Where(x => x.Aferir && x.Inicializado != Conectar))
|
foreach (var sensor in Sensores.Where(x => (x.Aferir && (ConfigurarTodos ? true : x.Inicializado != Conectar)) || (!x.Aferir && x.Inicializado)))
|
||||||
{
|
{
|
||||||
|
if (!sensor.Aferir && sensor.Inicializado)
|
||||||
|
{
|
||||||
|
Conectar = false;
|
||||||
|
}
|
||||||
byte[] payload = sensor.ProtocoloConfiguracao(Pinout, Conectar, Dispositivo);
|
byte[] payload = sensor.ProtocoloConfiguracao(Pinout, Conectar, Dispositivo);
|
||||||
if (payload != null)
|
if (payload != null)
|
||||||
{
|
{
|
||||||
|
|
@ -757,11 +882,11 @@ namespace AgroBase.Models.Modules
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<byte[]> SinaleirosConfig(bool Conectar)
|
private List<byte[]> SinaleirosConfig(bool Conectar, bool ConfigurarTodos)
|
||||||
{
|
{
|
||||||
var config = new List<byte[]>();
|
var config = new List<byte[]>();
|
||||||
|
|
||||||
foreach (var sinaleiro in Sinaleiros.Where(x => x.Inicializado != Conectar))
|
foreach (var sinaleiro in Sinaleiros.Where(x => (ConfigurarTodos ? true : x.Inicializado != Conectar)))
|
||||||
{
|
{
|
||||||
var payload = sinaleiro.ProtocoloConfiguracao(Pinout, Conectar);
|
var payload = sinaleiro.ProtocoloConfiguracao(Pinout, Conectar);
|
||||||
if (payload != null)
|
if (payload != null)
|
||||||
|
|
@ -773,12 +898,16 @@ namespace AgroBase.Models.Modules
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<byte[]> RelesConfig(bool Conectar)
|
private List<byte[]> RelesConfig(bool Conectar, bool ConfigurarTodos)
|
||||||
{
|
{
|
||||||
var config = new List<byte[]>();
|
var config = new List<byte[]>();
|
||||||
|
|
||||||
foreach (var rele in Reles.Where(x => x.Controlar && x.Inicializado != Conectar))
|
foreach (var rele in Reles.Where(x => (x.Controlar && (ConfigurarTodos ? true : x.Inicializado != Conectar)) || (!x.Controlar && x.Inicializado)))
|
||||||
{
|
{
|
||||||
|
if (!rele.Controlar && rele.Inicializado)
|
||||||
|
{
|
||||||
|
Conectar = false;
|
||||||
|
}
|
||||||
var payload = rele.ProtocoloConfiguracao(Pinout, Conectar);
|
var payload = rele.ProtocoloConfiguracao(Pinout, Conectar);
|
||||||
if (payload != null)
|
if (payload != null)
|
||||||
{
|
{
|
||||||
|
|
@ -789,12 +918,16 @@ namespace AgroBase.Models.Modules
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<byte[]> ServosConfig(bool Conectar)
|
private List<byte[]> ServosConfig(bool Conectar, bool ConfigurarTodos)
|
||||||
{
|
{
|
||||||
var config = new List<byte[]>();
|
var config = new List<byte[]>();
|
||||||
|
|
||||||
foreach (var servo in Servos.Where(x => x.Controlar && x.Inicializado != Conectar))
|
foreach (var servo in Servos.Where(x => (x.Controlar && (ConfigurarTodos ? true : x.Inicializado != Conectar)) || (!x.Controlar && x.Inicializado)))
|
||||||
{
|
{
|
||||||
|
if (!servo.Controlar && servo.Inicializado)
|
||||||
|
{
|
||||||
|
Conectar = false;
|
||||||
|
}
|
||||||
var payload = servo.ProtocoloConfiguracao(Pinout, Conectar);
|
var payload = servo.ProtocoloConfiguracao(Pinout, Conectar);
|
||||||
if (payload != null)
|
if (payload != null)
|
||||||
{
|
{
|
||||||
|
|
@ -1360,7 +1493,7 @@ namespace AgroBase.Models.Modules
|
||||||
|
|
||||||
public byte[] InterpretarParametro()
|
public byte[] InterpretarParametro()
|
||||||
{
|
{
|
||||||
string valor = Valor.Trim();
|
string valor = Valor.Replace(",", ".").Trim();
|
||||||
|
|
||||||
// HEX direto
|
// HEX direto
|
||||||
if (valor.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
|
if (valor.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
|
||||||
|
|
@ -1444,21 +1577,42 @@ namespace AgroBase.Models.Modules
|
||||||
|
|
||||||
public class FirmwareSensorCorrente : IFirmwareSensorBase
|
public class FirmwareSensorCorrente : IFirmwareSensorBase
|
||||||
{
|
{
|
||||||
public DateTime Momento { get; set; }
|
private DateTime _momento;
|
||||||
|
public DateTime Momento
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _momento;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
double dt = (value - _momento).TotalSeconds;
|
||||||
|
if (dt > 0)
|
||||||
|
{
|
||||||
|
_dt = dt;
|
||||||
|
}
|
||||||
|
_momento = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
public string ID { get; set; }
|
public string ID { get; set; }
|
||||||
public int ID_Num { get; set; }
|
public int ID_Num { get; set; }
|
||||||
public bool Iniciado { get; set; }
|
public bool Iniciado { get; set; }
|
||||||
public double BusVoltage { get; set; }
|
public double BusVoltage { get; set; }
|
||||||
public double ShuntVoltage { get; set; }
|
public double ShuntVoltage { get; set; }
|
||||||
public double? Current
|
public double Current
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _atual;
|
return _atual;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_atual = value ?? 0;
|
_atual = value;
|
||||||
|
|
||||||
|
if (ID == "AB36V")
|
||||||
|
{
|
||||||
|
Variaveis.OperacaoEmAndamento.DispSen?.Dados?.ContadorCarga?.AtualizarConsumo();
|
||||||
|
}
|
||||||
|
|
||||||
AtualizarExtremos();
|
AtualizarExtremos();
|
||||||
}
|
}
|
||||||
|
|
@ -1494,6 +1648,7 @@ namespace AgroBase.Models.Modules
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double _dt { get; set; }
|
||||||
|
|
||||||
private double _atual = 0;
|
private double _atual = 0;
|
||||||
private void AtualizarExtremos()
|
private void AtualizarExtremos()
|
||||||
|
|
|
||||||
|
|
@ -612,16 +612,6 @@ namespace AgroBase.Models
|
||||||
{
|
{
|
||||||
Dispositivo = T_Code.Sen,
|
Dispositivo = T_Code.Sen,
|
||||||
Mandatorio = true,
|
Mandatorio = true,
|
||||||
},
|
|
||||||
new OperacaoModulosMandatoriosModel()
|
|
||||||
{
|
|
||||||
Dispositivo = T_Code.Wit,
|
|
||||||
Mandatorio = false,
|
|
||||||
},
|
|
||||||
new OperacaoModulosMandatoriosModel()
|
|
||||||
{
|
|
||||||
Dispositivo = T_Code.Pzm,
|
|
||||||
Mandatorio = true,
|
|
||||||
},
|
},
|
||||||
new OperacaoModulosMandatoriosModel()
|
new OperacaoModulosMandatoriosModel()
|
||||||
{
|
{
|
||||||
|
|
@ -2003,7 +1993,7 @@ namespace AgroBase.Models
|
||||||
};
|
};
|
||||||
SalvarLog(T_Code.Sen.ToString(), logSen, false);
|
SalvarLog(T_Code.Sen.ToString(), logSen, false);
|
||||||
|
|
||||||
PzmSensoriamentoLogModel logPzm = new PzmSensoriamentoLogModel()
|
/*PzmSensoriamentoLogModel logPzm = new PzmSensoriamentoLogModel()
|
||||||
{
|
{
|
||||||
Momento = Agora,
|
Momento = Agora,
|
||||||
Inicializado = PZEMService.Iniciado,
|
Inicializado = PZEMService.Iniciado,
|
||||||
|
|
@ -2019,7 +2009,7 @@ namespace AgroBase.Models
|
||||||
CargaConsumidaPercentual = PZEMService.ContadorCarga.PercentualConsumido,
|
CargaConsumidaPercentual = PZEMService.ContadorCarga.PercentualConsumido,
|
||||||
UltimoComandoRespondido = PZEMService.UltimaLeitura.DataHora,
|
UltimoComandoRespondido = PZEMService.UltimaLeitura.DataHora,
|
||||||
};
|
};
|
||||||
SalvarLog(T_Code.Pzm.ToString(), logPzm, Fim);
|
SalvarLog(T_Code.Pzm.ToString(), logPzm, Fim);*/
|
||||||
|
|
||||||
UltrasonicA05Model logA05 = new UltrasonicA05Model()
|
UltrasonicA05Model logA05 = new UltrasonicA05Model()
|
||||||
{
|
{
|
||||||
|
|
@ -3009,6 +2999,7 @@ namespace AgroBase.Models
|
||||||
var _OpMapaGPS = Variaveis.OperacaoEmAndamento.OpMapaGPS;
|
var _OpMapaGPS = Variaveis.OperacaoEmAndamento.OpMapaGPS;
|
||||||
var _DispMvd = Variaveis.OperacaoEmAndamento.DispMvd;
|
var _DispMvd = Variaveis.OperacaoEmAndamento.DispMvd;
|
||||||
var _DispAtu = Variaveis.OperacaoEmAndamento.DispAtu;
|
var _DispAtu = Variaveis.OperacaoEmAndamento.DispAtu;
|
||||||
|
var _DispSen = Variaveis.OperacaoEmAndamento.DispSen;
|
||||||
var _Controle = Variaveis.OperacaoEmAndamento.Controle;
|
var _Controle = Variaveis.OperacaoEmAndamento.Controle;
|
||||||
|
|
||||||
Variaveis.OperacaoEmAndamento.AtualizarDispositiviosIndividuaisConectados();
|
Variaveis.OperacaoEmAndamento.AtualizarDispositiviosIndividuaisConectados();
|
||||||
|
|
@ -3054,13 +3045,18 @@ namespace AgroBase.Models
|
||||||
MovDir_Status = _DispMvd.Dados.StatusModulosMOV(Direcao.Direita)
|
MovDir_Status = _DispMvd.Dados.StatusModulosMOV(Direcao.Direita)
|
||||||
} : new OperacaoSensoriamentoLogMvdModel();
|
} : new OperacaoSensoriamentoLogMvdModel();
|
||||||
|
|
||||||
var dadosBateria = new OperacaoSensoriamentoLogBateriaModel()
|
var S36V = _DispSen?.Dados?.DadosLeitura?.SensoresCorrente?.FirstOrDefault(x => x.ID == "AB36V");
|
||||||
|
var dadosBateria = S36V != null ? new OperacaoSensoriamentoLogBateriaModel()
|
||||||
{
|
{
|
||||||
PorcentagemBateria = FuncoesMatematicas.Clamp(PZEMService.ContadorCarga.PercentualBateria, 0, 100),
|
_dt = S36V?._dt ?? 0,
|
||||||
BateriaConsumida = FuncoesMatematicas.Clamp(PZEMService.ContadorCarga.PercentualConsumido, 0, 100),
|
PorcentagemBateria = FuncoesMatematicas.Clamp(_DispSen.Dados.ContadorCarga.PercentualBateria, 0, 100),
|
||||||
CorrenteInstantanea = PZEMService.UltimaLeitura.Corrente,
|
BateriaConsumida = FuncoesMatematicas.Clamp(_DispSen.Dados.ContadorCarga.PercentualConsumido, 0, 100),
|
||||||
TensaoInstantanea = PZEMService.UltimaLeitura.Tensao
|
TempoEstimadoRestanteMinutos = _DispSen.Dados.ContadorCarga.TempoEstimadoMinutos,
|
||||||
};
|
CorrenteInstantanea = (S36V?.Current ?? 0) / 1000.0,
|
||||||
|
TensaoInstantanea = S36V?.BusVoltage ?? 0,
|
||||||
|
PotenciaInstantanea = S36V?.Power ?? 0,
|
||||||
|
PotenciaAcumulada = S36V?.Energy ?? 0
|
||||||
|
} : new OperacaoSensoriamentoLogBateriaModel();
|
||||||
|
|
||||||
var dadosTrajetoria = new OperacaoSensoriamentoLogTrajetoriaModel()
|
var dadosTrajetoria = new OperacaoSensoriamentoLogTrajetoriaModel()
|
||||||
{
|
{
|
||||||
|
|
@ -3226,19 +3222,27 @@ namespace AgroBase.Models
|
||||||
|
|
||||||
public class OperacaoSensoriamentoLogBateriaModel
|
public class OperacaoSensoriamentoLogBateriaModel
|
||||||
{
|
{
|
||||||
|
public double _dt { get; set; }
|
||||||
public double PorcentagemBateria { get; set; }
|
public double PorcentagemBateria { get; set; }
|
||||||
public double BateriaConsumida { get; set; }
|
public double BateriaConsumida { get; set; }
|
||||||
public double CorrenteInstantanea { get; set; }
|
public double CorrenteInstantanea { get; set; }
|
||||||
public double TensaoInstantanea { get; set; }
|
public double TensaoInstantanea { get; set; }
|
||||||
|
public double PotenciaInstantanea { get; set; }
|
||||||
|
public double PotenciaAcumulada { get; set; }
|
||||||
|
public double TempoEstimadoRestanteMinutos { get; set; }
|
||||||
|
|
||||||
public OperacaoSensoriamentoLogBateriaModel Clone()
|
public OperacaoSensoriamentoLogBateriaModel Clone()
|
||||||
{
|
{
|
||||||
return new OperacaoSensoriamentoLogBateriaModel()
|
return new OperacaoSensoriamentoLogBateriaModel()
|
||||||
{
|
{
|
||||||
|
_dt = _dt,
|
||||||
BateriaConsumida = BateriaConsumida,
|
BateriaConsumida = BateriaConsumida,
|
||||||
PorcentagemBateria = PorcentagemBateria,
|
PorcentagemBateria = PorcentagemBateria,
|
||||||
CorrenteInstantanea = CorrenteInstantanea,
|
CorrenteInstantanea = CorrenteInstantanea,
|
||||||
TensaoInstantanea = TensaoInstantanea
|
TensaoInstantanea = TensaoInstantanea,
|
||||||
|
PotenciaInstantanea = PotenciaInstantanea,
|
||||||
|
PotenciaAcumulada = PotenciaAcumulada,
|
||||||
|
TempoEstimadoRestanteMinutos = TempoEstimadoRestanteMinutos
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,9 @@ namespace AgroBase.Models
|
||||||
return ((LarguraEsquerda + LarguraDireita + 20.0) * 10.0);
|
return ((LarguraEsquerda + LarguraDireita + 20.0) * 10.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static double TensaoMinimaBateria { get; set; } = 20.0;
|
||||||
|
public static double TensaoMaximaBateria { get; set; } = 20.0;
|
||||||
|
public static double CorrenteMaximaBateria { get; set; } = 20.0;
|
||||||
public static double PercentualTensaoBateriaMin { get; set; } = 25.0;
|
public static double PercentualTensaoBateriaMin { get; set; } = 25.0;
|
||||||
public static double PercentualReservatorioMin { get; set; } = 5.0;
|
public static double PercentualReservatorioMin { get; set; } = 5.0;
|
||||||
public static double PercentualToleranciaPressaoLinha { get; set; } = 0.15;
|
public static double PercentualToleranciaPressaoLinha { get; set; } = 0.15;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
using AgroBase.Models;
|
using AgroBase.Models;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AgroBase.Services
|
namespace AgroBase.Services
|
||||||
{
|
{
|
||||||
|
|
@ -9,11 +11,18 @@ namespace AgroBase.Services
|
||||||
{
|
{
|
||||||
double coulombsMax = _max_Amp * 3600;
|
double coulombsMax = _max_Amp * 3600;
|
||||||
CargaMaxima = coulombsMax;
|
CargaMaxima = coulombsMax;
|
||||||
double consumo = (Variaveis.OperacaoEmAndamento.DispSen?.Dados?.BateriaCargaConsumida ?? 0);
|
//double consumo = (Variaveis.OperacaoEmAndamento.DispSen?.Dados?.BateriaCargaConsumida ?? 0);
|
||||||
Consumido = consumo < CargaMaxima ? consumo : 0;
|
//Consumido = consumo < CargaMaxima ? consumo : 0;
|
||||||
|
Consumido = 0;
|
||||||
CargaAtual = CargaMaxima - Consumido;
|
CargaAtual = CargaMaxima - Consumido;
|
||||||
|
//double consumoW = (Variaveis.OperacaoEmAndamento.DispSen?.Dados?.BateriaCargaConsumidaWatts ?? 0);
|
||||||
|
//ConsumidoWatts = consumoW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double TempoEstimadoMinutos { get; private set; }
|
||||||
|
private const int BufferSize = 30; // últimos 3 segundos se chamada a cada 100ms
|
||||||
|
private readonly Queue<double> _historicoCorrente = new Queue<double>();
|
||||||
|
|
||||||
private double CargaMaxima { get; set; }
|
private double CargaMaxima { get; set; }
|
||||||
private double CargaAtual { get; set; }
|
private double CargaAtual { get; set; }
|
||||||
public double CargaAtualAmp
|
public double CargaAtualAmp
|
||||||
|
|
@ -53,39 +62,47 @@ namespace AgroBase.Services
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public double PercentualBateria { get; private set; }
|
public double PercentualBateria { get; private set; }
|
||||||
|
public double ConsumidoWatts { get; set; }
|
||||||
|
|
||||||
public void AtualizarConsumo()
|
public void AtualizarConsumo()
|
||||||
{
|
{
|
||||||
PercentualBateria = Math.Round(FuncoesMatematicas.Map(PZEMService.UltimaLeitura.Tensao, PZEMService.TensaoMinima, PZEMService.TensaoMaxima, 0.0, 100.0), 2);
|
var Bateria = Variaveis.OperacaoEmAndamento.Sensoriamento.Bateria;
|
||||||
|
|
||||||
// Obtenha as datas das leituras
|
PercentualBateria = Math.Round(FuncoesMatematicas.Map(Bateria.TensaoInstantanea, VariaveisEquipamento.TensaoMinimaBateria, VariaveisEquipamento.TensaoMaximaBateria, 0.0, 100.0), 2);
|
||||||
DateTime ultimaLeitura = PZEMService.UltimaLeitura.DataHora;
|
|
||||||
DateTime penultimaLeitura = PZEMService.PenultimaLeitura.DataHora;
|
|
||||||
|
|
||||||
// Verifique se as datas são válidas (não MinValue, MaxValue ou valores anômalos)
|
// Verifique se as datas são válidas (não MinValue, MaxValue ou valores anômalos)
|
||||||
if (ultimaLeitura == DateTime.MinValue || ultimaLeitura == DateTime.MaxValue ||
|
if (Bateria._dt == 0 || Bateria._dt > 10)
|
||||||
penultimaLeitura == DateTime.MinValue || penultimaLeitura == DateTime.MaxValue)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("Erro: Leitura inválida detectada.");
|
Console.WriteLine("Erro: Leitura inválida detectada.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcule a diferença de tempo em segundos
|
|
||||||
double DifTempo = (ultimaLeitura - penultimaLeitura).TotalSeconds;
|
|
||||||
|
|
||||||
// Defina um limite para a diferença de tempo (por exemplo, 3600 segundos = 1 hora)
|
|
||||||
double limiteTempo = 3600; // Ajuste conforme necessário
|
|
||||||
if (DifTempo <= 0 || DifTempo > limiteTempo)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"Erro: Diferença de tempo inválida detectada: {DifTempo} segundos.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calcule os coulombs e atualize os valores
|
// Calcule os coulombs e atualize os valores
|
||||||
double coulombsLeitura = (PZEMService.UltimaLeitura.Corrente) * DifTempo;
|
double coulombsLeitura = Bateria.CorrenteInstantanea * Bateria._dt;
|
||||||
|
|
||||||
Consumido += coulombsLeitura;
|
Consumido += coulombsLeitura;
|
||||||
CargaAtual -= coulombsLeitura;
|
CargaAtual -= coulombsLeitura;
|
||||||
|
|
||||||
|
ConsumidoWatts += Bateria.PotenciaAcumulada - ConsumidoWatts;
|
||||||
|
|
||||||
|
// Armazena a corrente instantânea
|
||||||
|
_historicoCorrente.Enqueue(Bateria.CorrenteInstantanea);
|
||||||
|
|
||||||
|
if (_historicoCorrente.Count > BufferSize)
|
||||||
|
_historicoCorrente.Dequeue();
|
||||||
|
|
||||||
|
// Calcular corrente média (em A)
|
||||||
|
double correnteMedia = _historicoCorrente.Average();
|
||||||
|
|
||||||
|
// Verifica se a tensão está acima da mínima
|
||||||
|
if (Bateria.TensaoInstantanea > VariaveisEquipamento.TensaoMinimaBateria && correnteMedia > 0)
|
||||||
|
{
|
||||||
|
TempoEstimadoMinutos = (CargaAtualAmp / correnteMedia) * 60;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TempoEstimadoMinutos = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AtualizarValorConsumido(double _consumo_Amp)
|
public void AtualizarValorConsumido(double _consumo_Amp)
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -25,7 +25,7 @@
|
||||||
<meta name="viewport" content="width=device-width,
|
<meta name="viewport" content="width=device-width,
|
||||||
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
<style>
|
<style>
|
||||||
#map_627e1913ffb6ce0524d1e3cdac7f538e {
|
#map_82b7108ea8cddae8bf3da5e9af968baa {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100.0%;
|
width: 100.0%;
|
||||||
height: 100.0%;
|
height: 100.0%;
|
||||||
|
|
@ -39,14 +39,14 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
<div class="folium-map" id="map_627e1913ffb6ce0524d1e3cdac7f538e" ></div>
|
<div class="folium-map" id="map_82b7108ea8cddae8bf3da5e9af968baa" ></div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
||||||
var map_627e1913ffb6ce0524d1e3cdac7f538e = L.map(
|
var map_82b7108ea8cddae8bf3da5e9af968baa = L.map(
|
||||||
"map_627e1913ffb6ce0524d1e3cdac7f538e",
|
"map_82b7108ea8cddae8bf3da5e9af968baa",
|
||||||
{
|
{
|
||||||
center: [0.0, 0.0],
|
center: [0.0, 0.0],
|
||||||
crs: L.CRS.EPSG3857,
|
crs: L.CRS.EPSG3857,
|
||||||
|
|
@ -60,13 +60,13 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var tile_layer_ae5289bcde884732f0a974c70cdf1be8 = L.tileLayer(
|
var tile_layer_605bd35e89ca1ea18b377645f630a519 = L.tileLayer(
|
||||||
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||||
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
|
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
tile_layer_ae5289bcde884732f0a974c70cdf1be8.addTo(map_627e1913ffb6ce0524d1e3cdac7f538e);
|
tile_layer_605bd35e89ca1ea18b377645f630a519.addTo(map_82b7108ea8cddae8bf3da5e9af968baa);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
}
|
}
|
||||||
trajeto_json_add({"features": []});
|
trajeto_json_add({"features": []});
|
||||||
|
|
||||||
trajeto_json.addTo(map_627e1913ffb6ce0524d1e3cdac7f538e);
|
trajeto_json.addTo(map_82b7108ea8cddae8bf3da5e9af968baa);
|
||||||
|
|
||||||
function adicionarGeometria(novaGeometria) {
|
function adicionarGeometria(novaGeometria) {
|
||||||
trajeto_json.addData(novaGeometria);
|
trajeto_json.addData(novaGeometria);
|
||||||
|
|
@ -145,7 +145,7 @@
|
||||||
|
|
||||||
var marcadorDinamico = L.marker([0, 0], {
|
var marcadorDinamico = L.marker([0, 0], {
|
||||||
icon: customIcon
|
icon: customIcon
|
||||||
}).addTo(map_627e1913ffb6ce0524d1e3cdac7f538e);
|
}).addTo(map_82b7108ea8cddae8bf3da5e9af968baa);
|
||||||
|
|
||||||
// Conectar ao broker MQTT
|
// Conectar ao broker MQTT
|
||||||
const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexão segura
|
const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexão segura
|
||||||
|
|
@ -183,7 +183,7 @@
|
||||||
marcadorDinamico.setRotationAngle(angulo);
|
marcadorDinamico.setRotationAngle(angulo);
|
||||||
|
|
||||||
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
|
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
|
||||||
map_627e1913ffb6ce0524d1e3cdac7f538e.setView(novaPosicao, map_627e1913ffb6ce0524d1e3cdac7f538e.getZoom());
|
map_82b7108ea8cddae8bf3da5e9af968baa.setView(novaPosicao, map_82b7108ea8cddae8bf3da5e9af968baa.getZoom());
|
||||||
});
|
});
|
||||||
|
|
||||||
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {
|
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -30,8 +30,6 @@
|
||||||
{
|
{
|
||||||
this.gpbModulos = new System.Windows.Forms.GroupBox();
|
this.gpbModulos = new System.Windows.Forms.GroupBox();
|
||||||
this.pnlModulos = new System.Windows.Forms.Panel();
|
this.pnlModulos = new System.Windows.Forms.Panel();
|
||||||
this.rtbA05 = new System.Windows.Forms.RichTextBox();
|
|
||||||
this.chbA05 = new System.Windows.Forms.CheckBox();
|
|
||||||
this.rtbKnt = new System.Windows.Forms.RichTextBox();
|
this.rtbKnt = new System.Windows.Forms.RichTextBox();
|
||||||
this.chbSnr = new System.Windows.Forms.CheckBox();
|
this.chbSnr = new System.Windows.Forms.CheckBox();
|
||||||
this.rtbLRA = new System.Windows.Forms.RichTextBox();
|
this.rtbLRA = new System.Windows.Forms.RichTextBox();
|
||||||
|
|
@ -44,12 +42,8 @@
|
||||||
this.chbDir = new System.Windows.Forms.CheckBox();
|
this.chbDir = new System.Windows.Forms.CheckBox();
|
||||||
this.chbGps = new System.Windows.Forms.CheckBox();
|
this.chbGps = new System.Windows.Forms.CheckBox();
|
||||||
this.rtbMKS = new System.Windows.Forms.RichTextBox();
|
this.rtbMKS = new System.Windows.Forms.RichTextBox();
|
||||||
this.rtbWIT = new System.Windows.Forms.RichTextBox();
|
|
||||||
this.chbSen = new System.Windows.Forms.CheckBox();
|
this.chbSen = new System.Windows.Forms.CheckBox();
|
||||||
this.chbWit = new System.Windows.Forms.CheckBox();
|
|
||||||
this.rtbSEN = new System.Windows.Forms.RichTextBox();
|
this.rtbSEN = new System.Windows.Forms.RichTextBox();
|
||||||
this.rtbPZM = new System.Windows.Forms.RichTextBox();
|
|
||||||
this.chbPzm = new System.Windows.Forms.CheckBox();
|
|
||||||
this.cmbModosOperacao = new System.Windows.Forms.ComboBox();
|
this.cmbModosOperacao = new System.Windows.Forms.ComboBox();
|
||||||
this.lblModoOperacao = new System.Windows.Forms.Label();
|
this.lblModoOperacao = new System.Windows.Forms.Label();
|
||||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||||
|
|
@ -88,6 +82,8 @@
|
||||||
this.lblCapacidadeReservatorio = new System.Windows.Forms.Label();
|
this.lblCapacidadeReservatorio = new System.Windows.Forms.Label();
|
||||||
this.lblPercentualAtuacao1 = new System.Windows.Forms.Label();
|
this.lblPercentualAtuacao1 = new System.Windows.Forms.Label();
|
||||||
this.gpbDirecional = new System.Windows.Forms.GroupBox();
|
this.gpbDirecional = new System.Windows.Forms.GroupBox();
|
||||||
|
this.lblTipoMovimentoDirecional = new System.Windows.Forms.Label();
|
||||||
|
this.cmbTipoMovimentoDirecional = new System.Windows.Forms.ComboBox();
|
||||||
this.lblPercentual1 = new System.Windows.Forms.Label();
|
this.lblPercentual1 = new System.Windows.Forms.Label();
|
||||||
this.lblAngulo = new System.Windows.Forms.Label();
|
this.lblAngulo = new System.Windows.Forms.Label();
|
||||||
this.txtVelocidadeDirecional = new System.Windows.Forms.TextBox();
|
this.txtVelocidadeDirecional = new System.Windows.Forms.TextBox();
|
||||||
|
|
@ -107,8 +103,6 @@
|
||||||
this.btnCarregar = new System.Windows.Forms.Button();
|
this.btnCarregar = new System.Windows.Forms.Button();
|
||||||
this.txtDescricao = new System.Windows.Forms.TextBox();
|
this.txtDescricao = new System.Windows.Forms.TextBox();
|
||||||
this.lblDescricao = new System.Windows.Forms.Label();
|
this.lblDescricao = new System.Windows.Forms.Label();
|
||||||
this.cmbTipoMovimentoDirecional = new System.Windows.Forms.ComboBox();
|
|
||||||
this.lblTipoMovimentoDirecional = new System.Windows.Forms.Label();
|
|
||||||
this.gpbModulos.SuspendLayout();
|
this.gpbModulos.SuspendLayout();
|
||||||
this.pnlModulos.SuspendLayout();
|
this.pnlModulos.SuspendLayout();
|
||||||
this.tabControl1.SuspendLayout();
|
this.tabControl1.SuspendLayout();
|
||||||
|
|
@ -142,8 +136,6 @@
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.pnlModulos.AutoScroll = true;
|
this.pnlModulos.AutoScroll = true;
|
||||||
this.pnlModulos.Controls.Add(this.rtbA05);
|
|
||||||
this.pnlModulos.Controls.Add(this.chbA05);
|
|
||||||
this.pnlModulos.Controls.Add(this.rtbKnt);
|
this.pnlModulos.Controls.Add(this.rtbKnt);
|
||||||
this.pnlModulos.Controls.Add(this.chbSnr);
|
this.pnlModulos.Controls.Add(this.chbSnr);
|
||||||
this.pnlModulos.Controls.Add(this.rtbLRA);
|
this.pnlModulos.Controls.Add(this.rtbLRA);
|
||||||
|
|
@ -156,46 +148,18 @@
|
||||||
this.pnlModulos.Controls.Add(this.chbDir);
|
this.pnlModulos.Controls.Add(this.chbDir);
|
||||||
this.pnlModulos.Controls.Add(this.chbGps);
|
this.pnlModulos.Controls.Add(this.chbGps);
|
||||||
this.pnlModulos.Controls.Add(this.rtbMKS);
|
this.pnlModulos.Controls.Add(this.rtbMKS);
|
||||||
this.pnlModulos.Controls.Add(this.rtbWIT);
|
|
||||||
this.pnlModulos.Controls.Add(this.chbSen);
|
this.pnlModulos.Controls.Add(this.chbSen);
|
||||||
this.pnlModulos.Controls.Add(this.chbWit);
|
|
||||||
this.pnlModulos.Controls.Add(this.rtbSEN);
|
this.pnlModulos.Controls.Add(this.rtbSEN);
|
||||||
this.pnlModulos.Controls.Add(this.rtbPZM);
|
|
||||||
this.pnlModulos.Controls.Add(this.chbPzm);
|
|
||||||
this.pnlModulos.Location = new System.Drawing.Point(6, 19);
|
this.pnlModulos.Location = new System.Drawing.Point(6, 19);
|
||||||
this.pnlModulos.Name = "pnlModulos";
|
this.pnlModulos.Name = "pnlModulos";
|
||||||
this.pnlModulos.Size = new System.Drawing.Size(204, 475);
|
this.pnlModulos.Size = new System.Drawing.Size(204, 475);
|
||||||
this.pnlModulos.TabIndex = 6;
|
this.pnlModulos.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// rtbA05
|
|
||||||
//
|
|
||||||
this.rtbA05.BackColor = System.Drawing.SystemColors.Control;
|
|
||||||
this.rtbA05.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
|
||||||
this.rtbA05.Location = new System.Drawing.Point(3, 666);
|
|
||||||
this.rtbA05.Name = "rtbA05";
|
|
||||||
this.rtbA05.ReadOnly = true;
|
|
||||||
this.rtbA05.Size = new System.Drawing.Size(174, 42);
|
|
||||||
this.rtbA05.TabIndex = 18;
|
|
||||||
this.rtbA05.Text = "Responsável por monitorar obstáculos absolutos nas posições extremas dos quatro c" +
|
|
||||||
"antos do equipamento";
|
|
||||||
//
|
|
||||||
// chbA05
|
|
||||||
//
|
|
||||||
this.chbA05.AutoSize = true;
|
|
||||||
this.chbA05.BackColor = System.Drawing.SystemColors.Control;
|
|
||||||
this.chbA05.Location = new System.Drawing.Point(3, 643);
|
|
||||||
this.chbA05.Name = "chbA05";
|
|
||||||
this.chbA05.Size = new System.Drawing.Size(45, 17);
|
|
||||||
this.chbA05.TabIndex = 19;
|
|
||||||
this.chbA05.Text = "A05";
|
|
||||||
this.chbA05.UseVisualStyleBackColor = false;
|
|
||||||
this.chbA05.CheckedChanged += new System.EventHandler(this.chbModulo_CheckedChanged);
|
|
||||||
//
|
|
||||||
// rtbKnt
|
// rtbKnt
|
||||||
//
|
//
|
||||||
this.rtbKnt.BackColor = System.Drawing.SystemColors.Control;
|
this.rtbKnt.BackColor = System.Drawing.SystemColors.Control;
|
||||||
this.rtbKnt.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
this.rtbKnt.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
this.rtbKnt.Location = new System.Drawing.Point(3, 595);
|
this.rtbKnt.Location = new System.Drawing.Point(3, 447);
|
||||||
this.rtbKnt.Name = "rtbKnt";
|
this.rtbKnt.Name = "rtbKnt";
|
||||||
this.rtbKnt.ReadOnly = true;
|
this.rtbKnt.ReadOnly = true;
|
||||||
this.rtbKnt.Size = new System.Drawing.Size(174, 42);
|
this.rtbKnt.Size = new System.Drawing.Size(174, 42);
|
||||||
|
|
@ -206,7 +170,7 @@
|
||||||
//
|
//
|
||||||
this.chbSnr.AutoSize = true;
|
this.chbSnr.AutoSize = true;
|
||||||
this.chbSnr.BackColor = System.Drawing.SystemColors.Control;
|
this.chbSnr.BackColor = System.Drawing.SystemColors.Control;
|
||||||
this.chbSnr.Location = new System.Drawing.Point(3, 572);
|
this.chbSnr.Location = new System.Drawing.Point(3, 424);
|
||||||
this.chbSnr.Name = "chbSnr";
|
this.chbSnr.Name = "chbSnr";
|
||||||
this.chbSnr.Size = new System.Drawing.Size(49, 17);
|
this.chbSnr.Size = new System.Drawing.Size(49, 17);
|
||||||
this.chbSnr.TabIndex = 17;
|
this.chbSnr.TabIndex = 17;
|
||||||
|
|
@ -218,7 +182,7 @@
|
||||||
//
|
//
|
||||||
this.rtbLRA.BackColor = System.Drawing.SystemColors.Control;
|
this.rtbLRA.BackColor = System.Drawing.SystemColors.Control;
|
||||||
this.rtbLRA.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
this.rtbLRA.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
this.rtbLRA.Location = new System.Drawing.Point(3, 524);
|
this.rtbLRA.Location = new System.Drawing.Point(3, 376);
|
||||||
this.rtbLRA.Name = "rtbLRA";
|
this.rtbLRA.Name = "rtbLRA";
|
||||||
this.rtbLRA.ReadOnly = true;
|
this.rtbLRA.ReadOnly = true;
|
||||||
this.rtbLRA.Size = new System.Drawing.Size(174, 42);
|
this.rtbLRA.Size = new System.Drawing.Size(174, 42);
|
||||||
|
|
@ -229,7 +193,7 @@
|
||||||
//
|
//
|
||||||
this.chbLra.AutoSize = true;
|
this.chbLra.AutoSize = true;
|
||||||
this.chbLra.BackColor = System.Drawing.SystemColors.Control;
|
this.chbLra.BackColor = System.Drawing.SystemColors.Control;
|
||||||
this.chbLra.Location = new System.Drawing.Point(3, 501);
|
this.chbLra.Location = new System.Drawing.Point(3, 353);
|
||||||
this.chbLra.Name = "chbLra";
|
this.chbLra.Name = "chbLra";
|
||||||
this.chbLra.Size = new System.Drawing.Size(47, 17);
|
this.chbLra.Size = new System.Drawing.Size(47, 17);
|
||||||
this.chbLra.TabIndex = 15;
|
this.chbLra.TabIndex = 15;
|
||||||
|
|
@ -241,7 +205,7 @@
|
||||||
//
|
//
|
||||||
this.rtbATU.BackColor = System.Drawing.SystemColors.Control;
|
this.rtbATU.BackColor = System.Drawing.SystemColors.Control;
|
||||||
this.rtbATU.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
this.rtbATU.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
this.rtbATU.Location = new System.Drawing.Point(3, 459);
|
this.rtbATU.Location = new System.Drawing.Point(3, 311);
|
||||||
this.rtbATU.Name = "rtbATU";
|
this.rtbATU.Name = "rtbATU";
|
||||||
this.rtbATU.ReadOnly = true;
|
this.rtbATU.ReadOnly = true;
|
||||||
this.rtbATU.Size = new System.Drawing.Size(174, 36);
|
this.rtbATU.Size = new System.Drawing.Size(174, 36);
|
||||||
|
|
@ -263,7 +227,7 @@
|
||||||
//
|
//
|
||||||
this.chbAtu.AutoSize = true;
|
this.chbAtu.AutoSize = true;
|
||||||
this.chbAtu.BackColor = System.Drawing.SystemColors.Control;
|
this.chbAtu.BackColor = System.Drawing.SystemColors.Control;
|
||||||
this.chbAtu.Location = new System.Drawing.Point(3, 436);
|
this.chbAtu.Location = new System.Drawing.Point(3, 288);
|
||||||
this.chbAtu.Name = "chbAtu";
|
this.chbAtu.Name = "chbAtu";
|
||||||
this.chbAtu.Size = new System.Drawing.Size(48, 17);
|
this.chbAtu.Size = new System.Drawing.Size(48, 17);
|
||||||
this.chbAtu.TabIndex = 13;
|
this.chbAtu.TabIndex = 13;
|
||||||
|
|
@ -285,7 +249,7 @@
|
||||||
//
|
//
|
||||||
this.rtbGPS.BackColor = System.Drawing.SystemColors.Control;
|
this.rtbGPS.BackColor = System.Drawing.SystemColors.Control;
|
||||||
this.rtbGPS.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
this.rtbGPS.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
this.rtbGPS.Location = new System.Drawing.Point(3, 394);
|
this.rtbGPS.Location = new System.Drawing.Point(3, 246);
|
||||||
this.rtbGPS.Name = "rtbGPS";
|
this.rtbGPS.Name = "rtbGPS";
|
||||||
this.rtbGPS.ReadOnly = true;
|
this.rtbGPS.ReadOnly = true;
|
||||||
this.rtbGPS.Size = new System.Drawing.Size(174, 36);
|
this.rtbGPS.Size = new System.Drawing.Size(174, 36);
|
||||||
|
|
@ -307,7 +271,7 @@
|
||||||
//
|
//
|
||||||
this.chbGps.AutoSize = true;
|
this.chbGps.AutoSize = true;
|
||||||
this.chbGps.BackColor = System.Drawing.SystemColors.Control;
|
this.chbGps.BackColor = System.Drawing.SystemColors.Control;
|
||||||
this.chbGps.Location = new System.Drawing.Point(3, 371);
|
this.chbGps.Location = new System.Drawing.Point(3, 223);
|
||||||
this.chbGps.Name = "chbGps";
|
this.chbGps.Name = "chbGps";
|
||||||
this.chbGps.Size = new System.Drawing.Size(48, 17);
|
this.chbGps.Size = new System.Drawing.Size(48, 17);
|
||||||
this.chbGps.TabIndex = 11;
|
this.chbGps.TabIndex = 11;
|
||||||
|
|
@ -325,18 +289,6 @@
|
||||||
this.rtbMKS.Size = new System.Drawing.Size(174, 35);
|
this.rtbMKS.Size = new System.Drawing.Size(174, 35);
|
||||||
this.rtbMKS.TabIndex = 2;
|
this.rtbMKS.TabIndex = 2;
|
||||||
this.rtbMKS.Text = "Responsável pelo controle direcional do equipamento";
|
this.rtbMKS.Text = "Responsável pelo controle direcional do equipamento";
|
||||||
//
|
|
||||||
// rtbWIT
|
|
||||||
//
|
|
||||||
this.rtbWIT.BackColor = System.Drawing.SystemColors.Control;
|
|
||||||
this.rtbWIT.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
|
||||||
this.rtbWIT.Location = new System.Drawing.Point(3, 320);
|
|
||||||
this.rtbWIT.Name = "rtbWIT";
|
|
||||||
this.rtbWIT.ReadOnly = true;
|
|
||||||
this.rtbWIT.Size = new System.Drawing.Size(174, 45);
|
|
||||||
this.rtbWIT.TabIndex = 8;
|
|
||||||
this.rtbWIT.Text = "Responsável exclusivamente pelo monitramento da orientação e inclinação do equipa" +
|
|
||||||
"mento";
|
|
||||||
//
|
//
|
||||||
// chbSen
|
// chbSen
|
||||||
//
|
//
|
||||||
|
|
@ -350,18 +302,6 @@
|
||||||
this.chbSen.UseVisualStyleBackColor = false;
|
this.chbSen.UseVisualStyleBackColor = false;
|
||||||
this.chbSen.CheckedChanged += new System.EventHandler(this.chbModulo_CheckedChanged);
|
this.chbSen.CheckedChanged += new System.EventHandler(this.chbModulo_CheckedChanged);
|
||||||
//
|
//
|
||||||
// chbWit
|
|
||||||
//
|
|
||||||
this.chbWit.AutoSize = true;
|
|
||||||
this.chbWit.BackColor = System.Drawing.SystemColors.Control;
|
|
||||||
this.chbWit.Location = new System.Drawing.Point(3, 297);
|
|
||||||
this.chbWit.Name = "chbWit";
|
|
||||||
this.chbWit.Size = new System.Drawing.Size(47, 17);
|
|
||||||
this.chbWit.TabIndex = 9;
|
|
||||||
this.chbWit.Text = "WIT";
|
|
||||||
this.chbWit.UseVisualStyleBackColor = false;
|
|
||||||
this.chbWit.CheckedChanged += new System.EventHandler(this.chbModulo_CheckedChanged);
|
|
||||||
//
|
|
||||||
// rtbSEN
|
// rtbSEN
|
||||||
//
|
//
|
||||||
this.rtbSEN.BackColor = System.Drawing.SystemColors.Control;
|
this.rtbSEN.BackColor = System.Drawing.SystemColors.Control;
|
||||||
|
|
@ -373,29 +313,6 @@
|
||||||
this.rtbSEN.TabIndex = 4;
|
this.rtbSEN.TabIndex = 4;
|
||||||
this.rtbSEN.Text = "Responsável pelo monitoramento dos sensores gerais do equipamento, como também do" +
|
this.rtbSEN.Text = "Responsável pelo monitoramento dos sensores gerais do equipamento, como também do" +
|
||||||
"s sinaleiros indicativos";
|
"s sinaleiros indicativos";
|
||||||
//
|
|
||||||
// rtbPZM
|
|
||||||
//
|
|
||||||
this.rtbPZM.BackColor = System.Drawing.SystemColors.Control;
|
|
||||||
this.rtbPZM.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
|
||||||
this.rtbPZM.Location = new System.Drawing.Point(3, 246);
|
|
||||||
this.rtbPZM.Name = "rtbPZM";
|
|
||||||
this.rtbPZM.ReadOnly = true;
|
|
||||||
this.rtbPZM.Size = new System.Drawing.Size(174, 45);
|
|
||||||
this.rtbPZM.TabIndex = 6;
|
|
||||||
this.rtbPZM.Text = "Responsável exclusivamente pelo monitoramento da bateria do equipamento";
|
|
||||||
//
|
|
||||||
// chbPzm
|
|
||||||
//
|
|
||||||
this.chbPzm.AutoSize = true;
|
|
||||||
this.chbPzm.BackColor = System.Drawing.SystemColors.Control;
|
|
||||||
this.chbPzm.Location = new System.Drawing.Point(3, 223);
|
|
||||||
this.chbPzm.Name = "chbPzm";
|
|
||||||
this.chbPzm.Size = new System.Drawing.Size(49, 17);
|
|
||||||
this.chbPzm.TabIndex = 7;
|
|
||||||
this.chbPzm.Text = "PZM";
|
|
||||||
this.chbPzm.UseVisualStyleBackColor = false;
|
|
||||||
this.chbPzm.CheckedChanged += new System.EventHandler(this.chbModulo_CheckedChanged);
|
|
||||||
//
|
//
|
||||||
// cmbModosOperacao
|
// cmbModosOperacao
|
||||||
//
|
//
|
||||||
|
|
@ -797,6 +714,24 @@
|
||||||
this.gpbDirecional.TabStop = false;
|
this.gpbDirecional.TabStop = false;
|
||||||
this.gpbDirecional.Text = "Direcional";
|
this.gpbDirecional.Text = "Direcional";
|
||||||
//
|
//
|
||||||
|
// lblTipoMovimentoDirecional
|
||||||
|
//
|
||||||
|
this.lblTipoMovimentoDirecional.AutoSize = true;
|
||||||
|
this.lblTipoMovimentoDirecional.Location = new System.Drawing.Point(6, 94);
|
||||||
|
this.lblTipoMovimentoDirecional.Name = "lblTipoMovimentoDirecional";
|
||||||
|
this.lblTipoMovimentoDirecional.Size = new System.Drawing.Size(330, 13);
|
||||||
|
this.lblTipoMovimentoDirecional.TabIndex = 7;
|
||||||
|
this.lblTipoMovimentoDirecional.Text = "Tipo de controle usado na tomada de decições do módulo direcional";
|
||||||
|
//
|
||||||
|
// cmbTipoMovimentoDirecional
|
||||||
|
//
|
||||||
|
this.cmbTipoMovimentoDirecional.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.cmbTipoMovimentoDirecional.FormattingEnabled = true;
|
||||||
|
this.cmbTipoMovimentoDirecional.Location = new System.Drawing.Point(358, 91);
|
||||||
|
this.cmbTipoMovimentoDirecional.Name = "cmbTipoMovimentoDirecional";
|
||||||
|
this.cmbTipoMovimentoDirecional.Size = new System.Drawing.Size(100, 21);
|
||||||
|
this.cmbTipoMovimentoDirecional.TabIndex = 6;
|
||||||
|
//
|
||||||
// lblPercentual1
|
// lblPercentual1
|
||||||
//
|
//
|
||||||
this.lblPercentual1.AutoSize = true;
|
this.lblPercentual1.AutoSize = true;
|
||||||
|
|
@ -987,24 +922,6 @@
|
||||||
this.lblDescricao.TabIndex = 7;
|
this.lblDescricao.TabIndex = 7;
|
||||||
this.lblDescricao.Text = "Descrição";
|
this.lblDescricao.Text = "Descrição";
|
||||||
//
|
//
|
||||||
// cmbTipoMovimentoDirecional
|
|
||||||
//
|
|
||||||
this.cmbTipoMovimentoDirecional.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
||||||
this.cmbTipoMovimentoDirecional.FormattingEnabled = true;
|
|
||||||
this.cmbTipoMovimentoDirecional.Location = new System.Drawing.Point(358, 91);
|
|
||||||
this.cmbTipoMovimentoDirecional.Name = "cmbTipoMovimentoDirecional";
|
|
||||||
this.cmbTipoMovimentoDirecional.Size = new System.Drawing.Size(100, 21);
|
|
||||||
this.cmbTipoMovimentoDirecional.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// lblTipoMovimentoDirecional
|
|
||||||
//
|
|
||||||
this.lblTipoMovimentoDirecional.AutoSize = true;
|
|
||||||
this.lblTipoMovimentoDirecional.Location = new System.Drawing.Point(6, 94);
|
|
||||||
this.lblTipoMovimentoDirecional.Name = "lblTipoMovimentoDirecional";
|
|
||||||
this.lblTipoMovimentoDirecional.Size = new System.Drawing.Size(330, 13);
|
|
||||||
this.lblTipoMovimentoDirecional.TabIndex = 7;
|
|
||||||
this.lblTipoMovimentoDirecional.Text = "Tipo de controle usado na tomada de decições do módulo direcional";
|
|
||||||
//
|
|
||||||
// frmAjustesOperacao
|
// frmAjustesOperacao
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
|
@ -1051,8 +968,6 @@
|
||||||
|
|
||||||
private System.Windows.Forms.GroupBox gpbModulos;
|
private System.Windows.Forms.GroupBox gpbModulos;
|
||||||
private System.Windows.Forms.CheckBox chbMov;
|
private System.Windows.Forms.CheckBox chbMov;
|
||||||
private System.Windows.Forms.RichTextBox rtbPZM;
|
|
||||||
private System.Windows.Forms.CheckBox chbPzm;
|
|
||||||
private System.Windows.Forms.RichTextBox rtbSEN;
|
private System.Windows.Forms.RichTextBox rtbSEN;
|
||||||
private System.Windows.Forms.CheckBox chbSen;
|
private System.Windows.Forms.CheckBox chbSen;
|
||||||
private System.Windows.Forms.RichTextBox rtbMKS;
|
private System.Windows.Forms.RichTextBox rtbMKS;
|
||||||
|
|
@ -1060,8 +975,6 @@
|
||||||
private System.Windows.Forms.RichTextBox rtbMVD;
|
private System.Windows.Forms.RichTextBox rtbMVD;
|
||||||
private System.Windows.Forms.RichTextBox rtbGPS;
|
private System.Windows.Forms.RichTextBox rtbGPS;
|
||||||
private System.Windows.Forms.CheckBox chbGps;
|
private System.Windows.Forms.CheckBox chbGps;
|
||||||
private System.Windows.Forms.RichTextBox rtbWIT;
|
|
||||||
private System.Windows.Forms.CheckBox chbWit;
|
|
||||||
private System.Windows.Forms.RichTextBox rtbATU;
|
private System.Windows.Forms.RichTextBox rtbATU;
|
||||||
private System.Windows.Forms.CheckBox chbAtu;
|
private System.Windows.Forms.CheckBox chbAtu;
|
||||||
private System.Windows.Forms.ComboBox cmbModosOperacao;
|
private System.Windows.Forms.ComboBox cmbModosOperacao;
|
||||||
|
|
@ -1111,8 +1024,6 @@
|
||||||
private System.Windows.Forms.Label lblDuracaoAtuacao;
|
private System.Windows.Forms.Label lblDuracaoAtuacao;
|
||||||
private System.Windows.Forms.TextBox txtDescricao;
|
private System.Windows.Forms.TextBox txtDescricao;
|
||||||
private System.Windows.Forms.Label lblDescricao;
|
private System.Windows.Forms.Label lblDescricao;
|
||||||
private System.Windows.Forms.RichTextBox rtbA05;
|
|
||||||
private System.Windows.Forms.CheckBox chbA05;
|
|
||||||
private System.Windows.Forms.RichTextBox rtbKnt;
|
private System.Windows.Forms.RichTextBox rtbKnt;
|
||||||
private System.Windows.Forms.CheckBox chbSnr;
|
private System.Windows.Forms.CheckBox chbSnr;
|
||||||
private System.Windows.Forms.Panel pnlParametros;
|
private System.Windows.Forms.Panel pnlParametros;
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -137,4 +137,11 @@ enum CanMessagePosicaoDados
|
||||||
Command5 = 105,
|
Command5 = 105,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum TiposShuntCorrente {
|
||||||
|
INA219_3A2 = 0,
|
||||||
|
INA228_10A = 1,
|
||||||
|
INA228_50A = 2,
|
||||||
|
INA228_100A = 3,
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
#ifndef MuxService_h
|
||||||
|
#define MuxService_h
|
||||||
|
|
||||||
|
#include "SerialService.h"
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
|
class MuxService {
|
||||||
|
public:
|
||||||
|
static const uint8_t enderecoMux = 0x70; // Padrão do TCA9548A
|
||||||
|
static bool Iniciado;
|
||||||
|
static int canalAtivo;
|
||||||
|
|
||||||
|
static void IniciarMUX() {
|
||||||
|
PrintTela("[MUX] Iniciando TCA9548A...");
|
||||||
|
Wire.beginTransmission(enderecoMux);
|
||||||
|
Iniciado = (Wire.endTransmission() == 0);
|
||||||
|
if (Iniciado) {
|
||||||
|
canalAtivo = -1; // Nenhum canal ativo ainda
|
||||||
|
PrintTela("[MUX] TCA9548A Iniciado");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PrintTela("[MUX] TCA9548A nao Iniciado, endereco " + String(enderecoMux) + " nao encontrado no barramento");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SelecionarCanal(uint8_t canal) {
|
||||||
|
if (!Iniciado) return;
|
||||||
|
if (canalAtivo == canal) return; // Já está no canal certo
|
||||||
|
|
||||||
|
Wire.beginTransmission(enderecoMux);
|
||||||
|
Wire.write(1 << canal);
|
||||||
|
Wire.endTransmission();
|
||||||
|
|
||||||
|
PrintTela("[MUX] Canal alterado de " + String(canalAtivo) + " para " + String(canal));
|
||||||
|
|
||||||
|
canalAtivo = canal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool MuxService::Iniciado = false;
|
||||||
|
int MuxService::canalAtivo = -1;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,193 +0,0 @@
|
||||||
#ifndef SensorCorrenteINA228Model
|
|
||||||
#define SensorCorrenteINA228Model
|
|
||||||
|
|
||||||
#include "SerialService.h"
|
|
||||||
#include "Pinout.h"
|
|
||||||
#include "Utils.h"
|
|
||||||
#include <Wire.h>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
class SensorCorrenteINA228 {
|
|
||||||
public:
|
|
||||||
SensorCorrenteINA228(String _modID, String _id) {
|
|
||||||
Mod_ID = _modID;
|
|
||||||
_ID = _id;
|
|
||||||
}
|
|
||||||
|
|
||||||
String Mod_ID = "";
|
|
||||||
String _ID;
|
|
||||||
int ID_Num;
|
|
||||||
byte _Endereco;
|
|
||||||
float _A_Shunt = 10.0;
|
|
||||||
|
|
||||||
bool Iniciado = false;
|
|
||||||
float busVoltage = 0;
|
|
||||||
float current = 0;
|
|
||||||
float power = 0;
|
|
||||||
float energy = 0;
|
|
||||||
float temperature = 0;
|
|
||||||
|
|
||||||
void Inicializar() {
|
|
||||||
if (Iniciado) {
|
|
||||||
PrintTela(_ID + " ja inicializado");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Wire.beginTransmission(_Endereco);
|
|
||||||
byte error = Wire.endTransmission();
|
|
||||||
if (error == 0) {
|
|
||||||
Iniciado = true;
|
|
||||||
EscreverRegistradorINA(0x00, 0x8000); // Bit 15 = 1 → RESET
|
|
||||||
delay(2);
|
|
||||||
if (_A_Shunt == 10.0) {
|
|
||||||
currentLSB = 0.0001; // Mantém como já aprovado nos testes
|
|
||||||
} else if (_A_Shunt == 50.0) {
|
|
||||||
currentLSB = 0.00005; // 50 / 0.00005 = 1.000.000 → perto do limite
|
|
||||||
} else if (_A_Shunt == 100.0) {
|
|
||||||
currentLSB = 0.0001; // 100 / 0.0001 = 1.000.000 → ótimo
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Iniciado = false;
|
|
||||||
PrintTela(_ID + " nao iniciado, endereco " + _Endereco + " nao encontrado!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Desligar() {
|
|
||||||
if (!Iniciado) {
|
|
||||||
PrintTela(_ID + " nao esta inicializado");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Iniciado = false;
|
|
||||||
PrintTela(_ID + " Desligado");
|
|
||||||
}
|
|
||||||
|
|
||||||
void RequisitarDados() {
|
|
||||||
if (!Iniciado) return;
|
|
||||||
AferirCorrente();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<uint8_t> MontarMensagemCAN(CanMessagePosicaoDados posicao) {
|
|
||||||
std::vector<uint8_t> data;
|
|
||||||
data.push_back(ID_Num);
|
|
||||||
data.push_back(static_cast<uint8_t>(posicao));
|
|
||||||
|
|
||||||
switch (posicao) {
|
|
||||||
case CanMessagePosicaoDados::Status: {
|
|
||||||
data.push_back(Iniciado ? 1 : 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CanMessagePosicaoDados::Dados1: {
|
|
||||||
uint16_t volts = busVoltage * 100;
|
|
||||||
uint16_t amps = current * 100;
|
|
||||||
uint16_t watts = power * 10;
|
|
||||||
data.push_back(volts >> 8); data.push_back(volts & 0xFF);
|
|
||||||
data.push_back(amps >> 8); data.push_back(amps & 0xFF);
|
|
||||||
data.push_back(watts >> 8); data.push_back(watts & 0xFF);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CanMessagePosicaoDados::Dados2: {
|
|
||||||
uint16_t wh = energy * 10;
|
|
||||||
uint16_t temp = temperature * 100;
|
|
||||||
data.push_back(wh >> 8); data.push_back(wh & 0xFF);
|
|
||||||
data.push_back(temp >> 8); data.push_back(temp & 0xFF);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::vector<uint8_t> ConfigurarSensor(std::vector<SensorCorrenteINA228*>& lista, std::vector<uint8_t>& data, const String& Mod_ID) {
|
|
||||||
std::vector<uint8_t> status;
|
|
||||||
if (data.size() < 3) return status;
|
|
||||||
uint8_t idNum = data[1];
|
|
||||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[2];
|
|
||||||
auto it = std::find_if(lista.begin(), lista.end(), [idNum](SensorCorrenteINA228* s) { return s->ID_Num == idNum; });
|
|
||||||
bool jaExiste = it != lista.end();
|
|
||||||
SensorCorrenteINA228* sensor;
|
|
||||||
|
|
||||||
switch (posicao) {
|
|
||||||
case CanMessagePosicaoDados::Config1: {
|
|
||||||
if (data.size() < 8) return status;
|
|
||||||
bool conectar = data[4] == 1;
|
|
||||||
uint8_t endereco = data[5];
|
|
||||||
uint16_t aMaxInt = ((uint16_t)data[6] << 8) | data[7];
|
|
||||||
float aMax = aMaxInt / 100.0;
|
|
||||||
|
|
||||||
if (conectar) {
|
|
||||||
if (!jaExiste) {
|
|
||||||
sensor = new SensorCorrenteINA228(Mod_ID, "sCOR_" + String(idNum));
|
|
||||||
} else {
|
|
||||||
sensor = *it;
|
|
||||||
}
|
|
||||||
if (!sensor->Iniciado) {
|
|
||||||
sensor->ID_Num = idNum;
|
|
||||||
sensor->_Endereco = endereco;
|
|
||||||
sensor->_A_Shunt = aMax;
|
|
||||||
sensor->Inicializar();
|
|
||||||
if (!jaExiste) {
|
|
||||||
lista.push_back(sensor);
|
|
||||||
PrintTela("Sensor INA228 adicionado via CAN: sCOR_" + String(idNum));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
|
||||||
} else {
|
|
||||||
if (jaExiste) {
|
|
||||||
sensor = *it;
|
|
||||||
sensor->Desligar();
|
|
||||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
|
||||||
delete sensor;
|
|
||||||
lista.erase(it);
|
|
||||||
PrintTela("Sensor INA228 removido via CAN: sCOR_" + String(idNum));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
float shuntLSB = 1.0e-6;
|
|
||||||
float currentLSB = 0.000003;
|
|
||||||
float VbusLSB = 1.23e-5;
|
|
||||||
|
|
||||||
uint32_t LerRegistradorINA(uint8_t reg, uint8_t bytes) {
|
|
||||||
Wire.beginTransmission(_Endereco);
|
|
||||||
Wire.write(reg);
|
|
||||||
Wire.endTransmission(false);
|
|
||||||
Wire.requestFrom(_Endereco, bytes);
|
|
||||||
|
|
||||||
uint32_t valor = 0;
|
|
||||||
for (uint8_t i = 0; i < bytes; i++) {
|
|
||||||
valor = (valor << 8) | Wire.read();
|
|
||||||
}
|
|
||||||
return valor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EscreverRegistradorINA(uint8_t reg, uint16_t valor) {
|
|
||||||
Wire.beginTransmission(_Endereco);
|
|
||||||
Wire.write(reg);
|
|
||||||
Wire.write((valor >> 8) & 0xFF); // MSB
|
|
||||||
Wire.write(valor & 0xFF); // LSB
|
|
||||||
Wire.endTransmission();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AferirCorrente() {
|
|
||||||
if (!Iniciado) return;
|
|
||||||
|
|
||||||
uint32_t rawBus = LerRegistradorINA(0x05, 3);
|
|
||||||
uint32_t rawCurrent = LerRegistradorINA(0x07, 3);
|
|
||||||
uint32_t rawPower = LerRegistradorINA(0x08, 3);
|
|
||||||
uint64_t rawEnergy = ((uint64_t)LerRegistradorINA(0x0A, 3) << 16) | LerRegistradorINA(0x0B, 2);
|
|
||||||
uint16_t rawTemp = LerRegistradorINA(0x0F, 2);
|
|
||||||
|
|
||||||
//busVoltage = rawBus * 3.125e-6;
|
|
||||||
busVoltage = rawBus * VbusLSB;
|
|
||||||
power = rawPower * currentLSB * 3.125;
|
|
||||||
current = rawCurrent * currentLSB;
|
|
||||||
energy = rawEnergy * currentLSB * 3.125 * 16 / 3600.0;
|
|
||||||
temperature = ((int16_t)rawTemp) * 0.0078125;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,59 +1,54 @@
|
||||||
#include "SerialService.h"
|
|
||||||
#include "Pinout.h"
|
|
||||||
#include "Utils.h"
|
|
||||||
#include <Adafruit_INA219.h>
|
|
||||||
|
|
||||||
#ifndef SensorCorrenteModel
|
#ifndef SensorCorrenteModel
|
||||||
#define SensorCorrenteModel
|
#define SensorCorrenteModel
|
||||||
|
|
||||||
|
#include "SerialService.h"
|
||||||
|
#include "Pinout.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
#include "MuxService.h"
|
||||||
|
#include <Wire.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <Adafruit_INA219.h>
|
||||||
|
|
||||||
class SensorCorrente {
|
class SensorCorrente {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static std::vector<uint8_t> ConfigurarSensor(std::vector<SensorCorrente*>& lista, std::vector<uint8_t>& data, const String& Mod_ID);
|
|
||||||
|
|
||||||
SensorCorrente(String _modID, String _id) {
|
SensorCorrente(String _modID, String _id) {
|
||||||
Mod_ID = _modID;
|
Mod_ID = _modID;
|
||||||
_ID = _id;
|
_ID = _id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variáveis
|
|
||||||
Adafruit_INA219 sINA219;
|
|
||||||
|
|
||||||
// Definições
|
|
||||||
String Mod_ID = "";
|
String Mod_ID = "";
|
||||||
String _ID;
|
String _ID;
|
||||||
int ID_Num;
|
int ID_Num;
|
||||||
byte _Endereco;
|
byte _Endereco;
|
||||||
double _A_Shunt;
|
TiposShuntCorrente _A_Shunt = TiposShuntCorrente::INA228_10A;
|
||||||
|
int _CanalMUX;
|
||||||
|
bool isINA219 = false;
|
||||||
|
|
||||||
bool Iniciado = false;
|
bool Iniciado = false;
|
||||||
float busVoltage = 0;
|
float busVoltage = 0;
|
||||||
float shuntVoltage = 0;
|
|
||||||
float current = 0;
|
float current = 0;
|
||||||
float power = 0;
|
float power = 0;
|
||||||
|
float energy = 0;
|
||||||
|
float temperature = 0;
|
||||||
|
|
||||||
void Inicializar() {
|
void Inicializar() {
|
||||||
if (Iniciado) {
|
if (Iniciado) {
|
||||||
PrintTela(_ID + " ja inicializado");
|
PrintTela(_ID + " ja inicializado");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_Endereco > 0x00) {
|
isINA219 = _A_Shunt == TiposShuntCorrente::INA219_3A2;
|
||||||
Wire.beginTransmission(_Endereco);
|
|
||||||
byte error = Wire.endTransmission();
|
MuxService::SelecionarCanal(_CanalMUX);
|
||||||
if (error == 0) {
|
|
||||||
|
Wire.beginTransmission(_Endereco);
|
||||||
|
byte error = Wire.endTransmission();
|
||||||
|
if (error == 0) {
|
||||||
|
if (isINA219) {
|
||||||
sINA219 = Adafruit_INA219(_Endereco);
|
sINA219 = Adafruit_INA219(_Endereco);
|
||||||
Iniciado = sINA219.begin();
|
Iniciado = sINA219.begin();
|
||||||
if (Iniciado) {
|
if (Iniciado) {
|
||||||
if (_A_Shunt == 3.2) {
|
sINA219.setCalibration_32V_2A();
|
||||||
sINA219.setCalibration_32V_2A();
|
|
||||||
}
|
|
||||||
else if (_A_Shunt == 50) {
|
|
||||||
sINA219.setCalibration_50A_75mV();
|
|
||||||
}
|
|
||||||
else if (_A_Shunt == 100) {
|
|
||||||
sINA219.setCalibration_100A_75mV();
|
|
||||||
}
|
|
||||||
PrintTela(_ID + " iniciado");
|
PrintTela(_ID + " iniciado");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -61,12 +56,25 @@ class SensorCorrente {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Iniciado = false;
|
Iniciado = true;
|
||||||
PrintTela(_ID + " nao iniciado, endereco " + _Endereco + " nao encontrado!");
|
EscreverRegistradorINA(0x00, 0x8000); // Bit 15 = 1 → RESET
|
||||||
}
|
delay(2);
|
||||||
}
|
switch (_A_Shunt) {
|
||||||
else {
|
case TiposShuntCorrente::INA228_10A:
|
||||||
PrintTela("Endereco incorreto!");
|
currentLSB = currentLSB_10A;
|
||||||
|
break;
|
||||||
|
case TiposShuntCorrente::INA228_50A:
|
||||||
|
currentLSB = currentLSB_50A;
|
||||||
|
break;
|
||||||
|
case TiposShuntCorrente::INA228_100A:
|
||||||
|
currentLSB = currentLSB_100A;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
PrintTela(_ID + " iniciado");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Iniciado = false;
|
||||||
|
PrintTela(_ID + " nao iniciado, endereco " + _Endereco + " nao encontrado!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,12 +84,13 @@ class SensorCorrente {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintTela(_ID + " Desligado");
|
|
||||||
|
|
||||||
Iniciado = false;
|
Iniciado = false;
|
||||||
|
PrintTela(_ID + " Desligado");
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequisitarDados() {
|
void RequisitarDados() {
|
||||||
|
if (!Iniciado) return;
|
||||||
|
MuxService::SelecionarCanal(_CanalMUX);
|
||||||
AferirCorrente();
|
AferirCorrente();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,91 +98,136 @@ class SensorCorrente {
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
data.push_back(ID_Num);
|
data.push_back(ID_Num);
|
||||||
data.push_back(static_cast<uint8_t>(posicao));
|
data.push_back(static_cast<uint8_t>(posicao));
|
||||||
|
|
||||||
switch (posicao) {
|
switch (posicao) {
|
||||||
case CanMessagePosicaoDados::Status: {
|
case CanMessagePosicaoDados::Status: {
|
||||||
data.push_back(Iniciado ? 1 : 0);
|
data.push_back(Iniciado ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CanMessagePosicaoDados::Dados1: {
|
case CanMessagePosicaoDados::Dados1: {
|
||||||
// BusVoltage com 2 bytes, precisão x100
|
uint16_t volts = busVoltage * 100;
|
||||||
uint16_t busVoltsInt = (uint16_t)(busVoltage * 100);
|
uint16_t amps = current * 100;
|
||||||
data.push_back((uint8_t)(busVoltsInt >> 8));
|
uint16_t watts = power * 10;
|
||||||
data.push_back((uint8_t)(busVoltsInt & 0xFF));
|
data.push_back(volts >> 8); data.push_back(volts & 0xFF);
|
||||||
// Corrente com 2 bytes (em mA)
|
data.push_back(amps >> 8); data.push_back(amps & 0xFF);
|
||||||
uint16_t correnteInt = (uint16_t)(current);
|
data.push_back(watts >> 8); data.push_back(watts & 0xFF);
|
||||||
data.push_back((uint8_t)(correnteInt >> 8));
|
break;
|
||||||
data.push_back((uint8_t)(correnteInt & 0xFF));
|
}
|
||||||
// Potência com 2 bytes
|
case CanMessagePosicaoDados::Dados2: {
|
||||||
uint16_t potenciaInt = (uint16_t)(power);
|
if (isINA219) break;
|
||||||
data.push_back((uint8_t)(potenciaInt >> 8));
|
uint16_t wh = energy * 10;
|
||||||
data.push_back((uint8_t)(potenciaInt & 0xFF));
|
uint16_t temp = temperature * 100;
|
||||||
|
data.push_back(wh >> 8); data.push_back(wh & 0xFF);
|
||||||
|
data.push_back(temp >> 8); data.push_back(temp & 0xFF);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::vector<uint8_t> ConfigurarSensor(std::vector<SensorCorrente*>& lista, std::vector<uint8_t>& data, const String& Mod_ID) {
|
||||||
|
std::vector<uint8_t> status;
|
||||||
|
if (data.size() < 3) return status;
|
||||||
|
uint8_t idNum = data[1];
|
||||||
|
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[2];
|
||||||
|
auto it = std::find_if(lista.begin(), lista.end(), [idNum](SensorCorrente* s) { return s->ID_Num == idNum; });
|
||||||
|
bool jaExiste = it != lista.end();
|
||||||
|
SensorCorrente* sensor;
|
||||||
|
|
||||||
|
switch (posicao) {
|
||||||
|
case CanMessagePosicaoDados::Config1: {
|
||||||
|
if (data.size() < 8) return status;
|
||||||
|
bool conectar = data[4] == 1;
|
||||||
|
uint8_t endereco = data[5];
|
||||||
|
TiposShuntCorrente aMax = (TiposShuntCorrente)data[6];
|
||||||
|
int canalMux = data[7];
|
||||||
|
|
||||||
|
if (conectar) {
|
||||||
|
if (!jaExiste) {
|
||||||
|
sensor = new SensorCorrente(Mod_ID, "sCOR_" + String(idNum));
|
||||||
|
} else {
|
||||||
|
sensor = *it;
|
||||||
|
}
|
||||||
|
if (!sensor->Iniciado) {
|
||||||
|
sensor->ID_Num = idNum;
|
||||||
|
sensor->_Endereco = endereco;
|
||||||
|
sensor->_A_Shunt = aMax;
|
||||||
|
sensor->_CanalMUX = canalMux;
|
||||||
|
sensor->Inicializar();
|
||||||
|
if (!jaExiste) {
|
||||||
|
lista.push_back(sensor);
|
||||||
|
PrintTela("Sensor de corrente adicionado via CAN: sCOR_" + String(idNum));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||||
|
} else {
|
||||||
|
if (jaExiste) {
|
||||||
|
sensor = *it;
|
||||||
|
sensor->Desligar();
|
||||||
|
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
||||||
|
delete sensor;
|
||||||
|
lista.erase(it);
|
||||||
|
PrintTela("Sensor de corrente removido via CAN: sCOR_" + String(idNum));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Adafruit_INA219 sINA219;
|
||||||
|
static constexpr float currentLSB_10A = 0.0001;
|
||||||
|
static constexpr float currentLSB_50A = 0.00119;
|
||||||
|
static constexpr float currentLSB_100A = 0.00243;
|
||||||
|
static constexpr float shuntLSB = 1.0e-6;
|
||||||
|
static constexpr float vBusLSB = 1.23e-5;
|
||||||
|
float currentLSB = 0.0001;
|
||||||
|
|
||||||
|
uint32_t LerRegistradorINA(uint8_t reg, uint8_t bytes) {
|
||||||
|
Wire.beginTransmission(_Endereco);
|
||||||
|
Wire.write(reg);
|
||||||
|
Wire.endTransmission(false);
|
||||||
|
Wire.requestFrom(_Endereco, bytes);
|
||||||
|
|
||||||
|
uint32_t valor = 0;
|
||||||
|
for (uint8_t i = 0; i < bytes; i++) {
|
||||||
|
valor = (valor << 8) | Wire.read();
|
||||||
|
}
|
||||||
|
return valor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EscreverRegistradorINA(uint8_t reg, uint16_t valor) {
|
||||||
|
Wire.beginTransmission(_Endereco);
|
||||||
|
Wire.write(reg);
|
||||||
|
Wire.write((valor >> 8) & 0xFF); // MSB
|
||||||
|
Wire.write(valor & 0xFF); // LSB
|
||||||
|
Wire.endTransmission();
|
||||||
|
}
|
||||||
|
|
||||||
void AferirCorrente() {
|
void AferirCorrente() {
|
||||||
if (!Iniciado) return;
|
if (!Iniciado) return;
|
||||||
|
|
||||||
busVoltage = sINA219.getBusVoltage_V();
|
if (isINA219) {
|
||||||
//shuntVoltage = sINA219.getShuntVoltage_mV();
|
busVoltage = sINA219.getBusVoltage_V();
|
||||||
current = sINA219.getCurrent_mA();
|
current = sINA219.getCurrent_mA() / 10000.0;
|
||||||
power = sINA219.getPower_mW();
|
power = sINA219.getPower_mW() / 100.0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uint32_t rawBus = LerRegistradorINA(0x05, 3);
|
||||||
|
uint32_t rawCurrent = LerRegistradorINA(0x07, 3);
|
||||||
|
uint32_t rawPower = LerRegistradorINA(0x08, 3);
|
||||||
|
uint64_t rawEnergy = ((uint64_t)LerRegistradorINA(0x0A, 3) << 16) | LerRegistradorINA(0x0B, 2);
|
||||||
|
uint16_t rawTemp = LerRegistradorINA(0x0F, 2);
|
||||||
|
|
||||||
|
busVoltage = rawBus * vBusLSB;
|
||||||
|
power = rawPower * currentLSB * 3.125;
|
||||||
|
current = rawCurrent * currentLSB;
|
||||||
|
energy = rawEnergy * currentLSB * 3.125 * 16 / 3600.0;
|
||||||
|
temperature = ((int16_t)rawTemp) * 0.0078125;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<uint8_t> SensorCorrente::ConfigurarSensor(std::vector<SensorCorrente*>& lista, std::vector<uint8_t>& data, const String& Mod_ID) {
|
|
||||||
std::vector<uint8_t> status;
|
|
||||||
if (data.size() < 3) return status;
|
|
||||||
uint8_t idNum = data[1];
|
|
||||||
CanMessagePosicaoDados posicao = (CanMessagePosicaoDados)data[2];
|
|
||||||
auto it = std::find_if(lista.begin(), lista.end(), [idNum](SensorCorrente* s) { return s->ID_Num == idNum; });
|
|
||||||
bool jaExiste = it != lista.end();
|
|
||||||
SensorCorrente* sensor;
|
|
||||||
switch (posicao) {
|
|
||||||
case CanMessagePosicaoDados::Config1: {
|
|
||||||
if (data.size() < 8) return status;
|
|
||||||
bool conectar = data[4] == 1;
|
|
||||||
uint8_t endereco = data[5];
|
|
||||||
// _a_max vem como float*100 => uint16_t
|
|
||||||
uint16_t aMaxInt = ((uint16_t)data[6] << 8) | data[7];
|
|
||||||
float aMax = aMaxInt / 100.0;
|
|
||||||
if (conectar) {
|
|
||||||
if (!jaExiste) {
|
|
||||||
sensor = new SensorCorrente(Mod_ID, "sCOR_" + String(idNum));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sensor = *it;
|
|
||||||
}
|
|
||||||
if (!sensor->Iniciado) {
|
|
||||||
sensor->ID_Num = idNum;
|
|
||||||
sensor->_Endereco = endereco;
|
|
||||||
sensor->_A_Shunt = aMax;
|
|
||||||
sensor->Inicializar();
|
|
||||||
if (!jaExiste) {
|
|
||||||
lista.push_back(sensor);
|
|
||||||
PrintTela("Sensor de corrente adicionado via CAN: sCOR_" + String(idNum));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
|
||||||
} else {
|
|
||||||
if (jaExiste) {
|
|
||||||
sensor = *it;
|
|
||||||
sensor->Desligar();
|
|
||||||
status = sensor->MontarMensagemCAN(CanMessagePosicaoDados::Status);
|
|
||||||
delete sensor;
|
|
||||||
lista.erase(it);
|
|
||||||
PrintTela("Sensor de corrente removido via CAN: sCOR_" + String(idNum));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef SensorIMUModel
|
#ifndef SensorIMUModel
|
||||||
#define SensorIMUModel
|
#define SensorIMUModel
|
||||||
|
|
||||||
#include <MPU9250_WE.h>
|
#include <MPU9250_asukiaaa.h>
|
||||||
#include <Adafruit_BMP280.h>
|
#include <Adafruit_BMP280.h>
|
||||||
#include <MadgwickAHRS.h>
|
#include <MadgwickAHRS.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
@ -25,12 +25,15 @@ class SensorIMU {
|
||||||
byte _EnderecoBMP; // 0x76
|
byte _EnderecoBMP; // 0x76
|
||||||
|
|
||||||
// MPU9250 (IMU 9 eixos)
|
// MPU9250 (IMU 9 eixos)
|
||||||
MPU9250_WE* mpu;
|
MPU9250_asukiaaa mpu;
|
||||||
|
|
||||||
// BMP280 (Temperatura, Pressão, Altitude)
|
// BMP280 (Temperatura, Pressão, Altitude)
|
||||||
Adafruit_BMP280 bmp;
|
Adafruit_BMP280 bmp;
|
||||||
|
|
||||||
Madgwick filter;
|
Madgwick filter;
|
||||||
|
float filterHz = 250.0f;
|
||||||
|
float filterBeta = 0.2f;
|
||||||
|
int filterDelay = 1000.0f / filterHz;
|
||||||
|
|
||||||
// Leituras principais
|
// Leituras principais
|
||||||
float AccX = 0, AccY = 0, AccZ = 0;
|
float AccX = 0, AccY = 0, AccZ = 0;
|
||||||
|
|
@ -54,36 +57,40 @@ class SensorIMU {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mpu = new MPU9250_WE(_EnderecoMPU);
|
Wire.beginTransmission(_EnderecoMPU);
|
||||||
MpuIniciado = mpu->init();
|
byte errorMpu = Wire.endTransmission();
|
||||||
if (!MpuIniciado) {
|
MpuIniciado = errorMpu == 0;
|
||||||
PrintTela("MPU9250 nao encontrado no endereco " + String(_EnderecoMPU));
|
|
||||||
delete mpu;
|
|
||||||
mpu = nullptr;
|
|
||||||
//return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MpuIniciado) {
|
if (MpuIniciado) {
|
||||||
mpu->autoOffsets();
|
mpu.setWire(&Wire);
|
||||||
mpu->setSampleRateDivider(5);
|
mpu.beginAccel();
|
||||||
mpu->setAccRange(MPU9250_ACC_RANGE_2G);
|
mpu.beginGyro();
|
||||||
mpu->enableAccDLPF(true);
|
mpu.beginMag();
|
||||||
mpu->setAccDLPF(MPU9250_DLPF_6);
|
|
||||||
|
filter.begin(filterHz);
|
||||||
|
filter.setBeta(filterBeta);
|
||||||
|
} else {
|
||||||
|
PrintTela("MPU9250 nao encontrado no endereco " + String(_EnderecoMPU));
|
||||||
}
|
}
|
||||||
|
|
||||||
BmpIniciado = bmp.begin(_EnderecoBMP);
|
Wire.beginTransmission(_EnderecoBMP);
|
||||||
if (!BmpIniciado) {
|
byte errorBmp = Wire.endTransmission();
|
||||||
PrintTela("BMP280 nao encontrado no endereco " + String(_EnderecoBMP));
|
bool BmpEncontrado = errorBmp == 0;
|
||||||
//return;
|
if (BmpEncontrado) {
|
||||||
|
BmpIniciado = bmp.begin(_EnderecoBMP);
|
||||||
|
if (BmpIniciado) {
|
||||||
|
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,
|
||||||
|
Adafruit_BMP280::SAMPLING_X2,
|
||||||
|
Adafruit_BMP280::SAMPLING_X16,
|
||||||
|
Adafruit_BMP280::FILTER_X16,
|
||||||
|
Adafruit_BMP280::STANDBY_MS_500);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PrintTela("Erro ao iniciar BMP280");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PrintTela("BMP280 nao encontrado no endereco " + String(_EnderecoBMP));
|
||||||
}
|
}
|
||||||
|
|
||||||
bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,
|
|
||||||
Adafruit_BMP280::SAMPLING_X2,
|
|
||||||
Adafruit_BMP280::SAMPLING_X16,
|
|
||||||
Adafruit_BMP280::FILTER_X16,
|
|
||||||
Adafruit_BMP280::STANDBY_MS_500);
|
|
||||||
|
|
||||||
filter.begin(100); // 100 Hz
|
|
||||||
|
|
||||||
Iniciado = MpuIniciado || BmpIniciado;
|
Iniciado = MpuIniciado || BmpIniciado;
|
||||||
if (Iniciado) {
|
if (Iniciado) {
|
||||||
|
|
@ -98,11 +105,6 @@ class SensorIMU {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mpu != nullptr) {
|
|
||||||
delete mpu;
|
|
||||||
mpu = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parar a execução das tarefas
|
// Parar a execução das tarefas
|
||||||
if (IMUTaskHandle != NULL) {
|
if (IMUTaskHandle != NULL) {
|
||||||
vTaskDelete(IMUTaskHandle);
|
vTaskDelete(IMUTaskHandle);
|
||||||
|
|
@ -208,34 +210,53 @@ class SensorIMU {
|
||||||
if (Iniciado) {
|
if (Iniciado) {
|
||||||
AferirDados();
|
AferirDados();
|
||||||
}
|
}
|
||||||
vTaskDelay(pdMS_TO_TICKS(10)); // 10ms → 100 Hz
|
vTaskDelay(pdMS_TO_TICKS(filterDelay));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AferirDados() {
|
void AferirDados() {
|
||||||
if (!Iniciado) return;
|
if (!Iniciado) return;
|
||||||
|
|
||||||
if (MpuIniciado && mpu != nullptr) {
|
if (MpuIniciado) {
|
||||||
xyzFloat acc = mpu->getGValues();
|
mpu.accelUpdate();
|
||||||
xyzFloat gyr = mpu->getGyrValues();
|
mpu.gyroUpdate();
|
||||||
xyzFloat mag = mpu->getMagValues();
|
mpu.magUpdate();
|
||||||
|
|
||||||
AccX = acc.x;
|
AccX = mpu.accelX();
|
||||||
AccY = acc.y;
|
AccY = mpu.accelY();
|
||||||
AccZ = acc.z;
|
AccZ = mpu.accelZ();
|
||||||
|
|
||||||
GyroX = gyr.x;
|
|
||||||
GyroY = gyr.y;
|
|
||||||
GyroZ = gyr.z;
|
|
||||||
|
|
||||||
MagX = mag.x;
|
|
||||||
MagY = mag.y;
|
|
||||||
MagZ = mag.z;
|
|
||||||
|
|
||||||
filter.update(GyroX, GyroY, GyroZ, AccX, AccY, AccZ, MagX, MagY, MagZ);
|
GyroX = mpu.gyroX();
|
||||||
Roll = filter.getRoll();
|
GyroY = mpu.gyroY();
|
||||||
Pitch = filter.getPitch();
|
GyroZ = mpu.gyroZ();
|
||||||
Yaw = filter.getYaw();
|
|
||||||
|
MagX = mpu.magX();
|
||||||
|
MagY = mpu.magY();
|
||||||
|
MagZ = mpu.magZ();
|
||||||
|
|
||||||
|
if (true || MagX == 0 && MagY == 0 && MagZ == 0) {
|
||||||
|
filter.updateIMU(GyroX, GyroY, GyroZ, AccX, AccY, AccZ);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
filter.update(GyroX, GyroY, GyroZ, AccX, AccY, AccZ, MagX, MagY, MagZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera os quaternions
|
||||||
|
float q0 = filter.getQ0();
|
||||||
|
float q1 = filter.getQ1();
|
||||||
|
float q2 = filter.getQ2();
|
||||||
|
float q3 = filter.getQ3();
|
||||||
|
|
||||||
|
// Vetor "up"
|
||||||
|
float upX = 2 * (q1 * q3 - q0 * q2);
|
||||||
|
float upY = 2 * (q2 * q3 + q0 * q1);
|
||||||
|
float upZ = 1 - 2 * (q1 * q1 + q2 * q2);
|
||||||
|
|
||||||
|
// Calcula os ângulos corrigidos
|
||||||
|
Roll = atan2(upY, upZ) * RAD_TO_DEG;
|
||||||
|
Roll = (Roll > 0) ? Roll - 180 : Roll + 180;
|
||||||
|
Pitch = -(atan2(-upX, sqrt(upY * upY + upZ * upZ)) * RAD_TO_DEG);
|
||||||
|
Yaw = atan2(2.0f * (q1 * q2 + q0 * q3), q0*q0 + q1*q1 - q2*q2 - q3*q3) * RAD_TO_DEG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BmpIniciado) {
|
if (BmpIniciado) {
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,11 @@
|
||||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
|
||||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\CanService.h"
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\CanService.h"
|
||||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\EepromService.h"
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\EepromService.h"
|
||||||
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\MuxService.h"
|
||||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\Utils.h"
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\Utils.h"
|
||||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\Pinout.h"
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\Pinout.h"
|
||||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorTemperaturaModel.h"
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorTemperaturaModel.h"
|
||||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorCorrenteINA228Model.h"
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorCorrenteModel.h"
|
||||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorIMUModel.h"
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SensorIMUModel.h"
|
||||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SinaleiroModel.h"
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SinaleiroModel.h"
|
||||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\ReleModel.h"
|
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\ReleModel.h"
|
||||||
|
|
@ -41,7 +42,7 @@ PinoModel _pinoSCL = PinoModel(2, CONTROLADOR, _INPUT);
|
||||||
|
|
||||||
|
|
||||||
std::vector<SensorTemperatura*> listaSensoresTemperatura;
|
std::vector<SensorTemperatura*> listaSensoresTemperatura;
|
||||||
std::vector<SensorCorrenteINA228*> listaSensoresCorrente;
|
std::vector<SensorCorrente*> listaSensoresCorrente;
|
||||||
std::vector<Sinaleiro*> listaSinaleiros;
|
std::vector<Sinaleiro*> listaSinaleiros;
|
||||||
std::vector<Rele*> listaReles;
|
std::vector<Rele*> listaReles;
|
||||||
std::vector<ServoFreio*> listaServoFreios;
|
std::vector<ServoFreio*> listaServoFreios;
|
||||||
|
|
@ -53,6 +54,7 @@ void setup() {
|
||||||
|
|
||||||
iniciarMCP(D_Code, Mod_ID, _pinoSDA.num, _pinoSCL.num, 0x20, false);
|
iniciarMCP(D_Code, Mod_ID, _pinoSDA.num, _pinoSCL.num, 0x20, false);
|
||||||
iniciarADS(D_Code, Mod_ID, _pinoSDA.num, _pinoSCL.num, 0x48, false);
|
iniciarADS(D_Code, Mod_ID, _pinoSDA.num, _pinoSCL.num, 0x48, false);
|
||||||
|
MuxService::IniciarMUX();
|
||||||
|
|
||||||
// Registrar callback para processar mensagens CAN recebidas
|
// Registrar callback para processar mensagens CAN recebidas
|
||||||
canService.setReceiveCallback([](int packetSize, int senderId, byte funcCode, byte* data, int dataLength) {
|
canService.setReceiveCallback([](int packetSize, int senderId, byte funcCode, byte* data, int dataLength) {
|
||||||
|
|
@ -174,7 +176,7 @@ void enviarDadosSensores() {
|
||||||
|
|
||||||
|
|
||||||
void EnviarDadosCAN(std::vector<uint8_t> data) {
|
void EnviarDadosCAN(std::vector<uint8_t> data) {
|
||||||
if (data.size() > 0) {
|
if (data.size() > 2) {
|
||||||
canService.enviarMensagem(data);
|
canService.enviarMensagem(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -230,13 +232,15 @@ void ProcessarCfg(std::vector<uint8_t> data) {
|
||||||
_pinoSCL = PinoModel(pinoSCL, CONTROLADOR, _INPUT);
|
_pinoSCL = PinoModel(pinoSCL, CONTROLADOR, _INPUT);
|
||||||
Wire.end();
|
Wire.end();
|
||||||
Wire.begin(_pinoSDA.num, _pinoSCL.num);
|
Wire.begin(_pinoSDA.num, _pinoSCL.num);
|
||||||
PrintTela("I2C inicializado nos pinos SDA=" + String(pinoSDA) + " e SCL=" + String(pinoSCL));
|
PrintTela("[SEN] I2C inicializado nos pinos SDA=" + String(pinoSDA) + " e SCL=" + String(pinoSCL));
|
||||||
|
|
||||||
|
MuxService::IniciarMUX();
|
||||||
}
|
}
|
||||||
vTaskDelay(pdMS_TO_TICKS(100));
|
vTaskDelay(pdMS_TO_TICKS(100));
|
||||||
Conectado = Conectar;
|
Conectado = Conectar;
|
||||||
_chkRx = canService.MontarFrameChk(D_Code, Conectado, VERSION);
|
_chkRx = canService.MontarFrameChk(D_Code, Conectado, VERSION);
|
||||||
LimparListasComponentes();
|
LimparListasComponentes();
|
||||||
PrintTela("Configuracao do modulo concluida");
|
PrintTela("[SEN] Configuracao do modulo concluida");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -247,7 +251,7 @@ void ProcessarCfg(std::vector<uint8_t> data) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case sCOR: {
|
case sCOR: {
|
||||||
_chkRx = SensorCorrenteINA228::ConfigurarSensor(listaSensoresCorrente, data, Mod_ID);
|
_chkRx = SensorCorrente::ConfigurarSensor(listaSensoresCorrente, data, Mod_ID);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case sLED: {
|
case sLED: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue