ajustes nas operacoes
This commit is contained in:
parent
0dab81aad7
commit
2ba82fd286
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -109,8 +109,9 @@ namespace AgroBase.Forms.IHM
|
|||
|
||||
if (
|
||||
Variaveis.OperacaoEmAndamento.DispAtu == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Atu) ||
|
||||
Variaveis.OperacaoEmAndamento.DispDir == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Dir) ||
|
||||
Variaveis.OperacaoEmAndamento.DispMov == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Mov) ||
|
||||
//Variaveis.OperacaoEmAndamento.DispDir == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Dir) ||
|
||||
//Variaveis.OperacaoEmAndamento.DispMov == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Mov) ||
|
||||
Variaveis.OperacaoEmAndamento.DispMvd == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Mvd) ||
|
||||
Variaveis.OperacaoEmAndamento.DispSen == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Sen)
|
||||
)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -543,17 +543,22 @@ namespace AgroBase.Forms.Operacoes
|
|||
|
||||
MvdMotorMOVSensorimanetoGrafico Log = null;
|
||||
|
||||
var Modulo = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.FirstOrDefault(x => x.Modulo_ID == "ET" && x.MovMotor.LogGrafico.Any());
|
||||
|
||||
if (Modulo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Modulo.MovMotor.LogGrafico.Count > 0)
|
||||
{
|
||||
Log = Modulo.MovMotor.LogGrafico.Last();
|
||||
}
|
||||
// Primeiro, coletar todos os logs alinhados por índice em uma lista de tuplas (index, moduloLog)
|
||||
var Logs = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos
|
||||
.SelectMany(m => m.MovMotor.LogGrafico.Select((log, index) => new { Index = index, Log = log }))
|
||||
.GroupBy(x => x.Index) // Agrupa por índice
|
||||
.OrderBy(g => g.Key) // Ordena pelos índices (opcional, mas ajuda na leitura)
|
||||
.Select(g => new MvdMotorMOVSensorimanetoGrafico()
|
||||
{
|
||||
// Calcula a média de cada propriedade no grupo
|
||||
Momento = new DateTime((long)g.Average(x => x.Log.Momento.Ticks)),
|
||||
Velocidade = g.Average(x => x.Log.Velocidade),
|
||||
RPM = Convert.ToInt32(g.Average(x => x.Log.RPM)),
|
||||
RPM_SP = Convert.ToInt32(g.Average(x => x.Log.RPM_SP)),
|
||||
Temperatura = g.Average(x => x.Log.Temperatura),
|
||||
Tensao = g.Average(x => x.Log.Tensao),
|
||||
})
|
||||
.ToList();
|
||||
|
||||
double Minimo = 0;
|
||||
double Maximo = 0;
|
||||
|
|
@ -561,7 +566,7 @@ namespace AgroBase.Forms.Operacoes
|
|||
Chart chart = chartGraficos;
|
||||
chart.Titles.Clear();
|
||||
//chart.Titles.Add("Acompanhamento");
|
||||
var Logs = (Modulo.MovMotor.LogGrafico.Count > MovimentacaoModel.LogsManter ? Modulo.MovMotor.LogGrafico.Skip(Math.Max(0, Modulo.MovMotor.LogGrafico.Count - MovimentacaoModel.LogsManter)).Take(MovimentacaoModel.LogsManter).ToList() : Modulo.MovMotor.LogGrafico).Where(log => log.Modulo_ID == Modulo.Modulo_ID).ToList();
|
||||
//var Logs = (Modulo.MovMotor.LogGrafico.Count > MovimentacaoModel.LogsManter ? Modulo.MovMotor.LogGrafico.Skip(Math.Max(0, Modulo.MovMotor.LogGrafico.Count - MovimentacaoModel.LogsManter)).Take(MovimentacaoModel.LogsManter).ToList() : Modulo.MovMotor.LogGrafico).Where(log => log.Modulo_ID == Modulo.Modulo_ID).ToList();
|
||||
chart.Series.Clear();
|
||||
List<string> Momentos = Logs.Select(x => x.Momento.ToString("mm:ss:fff")).ToList();
|
||||
|
||||
|
|
|
|||
|
|
@ -280,12 +280,26 @@ namespace AgroBase.Forms.Operacoes
|
|||
{
|
||||
MvdMotorMOVSensorimanetoGrafico Log = null;
|
||||
|
||||
var Modulo = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.FirstOrDefault(x => x.Modulo_ID == "ET" && x.MovMotor.LogGrafico.Any());
|
||||
var Motor = Modulo.MovMotor;
|
||||
// Primeiro, coletar todos os logs alinhados por índice em uma lista de tuplas (index, moduloLog)
|
||||
var Logs = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos
|
||||
.SelectMany(m => m.MovMotor.LogGrafico.Select((log, index) => new { Index = index, Log = log }))
|
||||
.GroupBy(x => x.Index) // Agrupa por índice
|
||||
.OrderBy(g => g.Key) // Ordena pelos índices (opcional, mas ajuda na leitura)
|
||||
.Select(g => new MvdMotorMOVSensorimanetoGrafico()
|
||||
{
|
||||
// Calcula a média de cada propriedade no grupo
|
||||
Momento = new DateTime((long)g.Average(x => x.Log.Momento.Ticks)),
|
||||
Velocidade = g.Average(x => x.Log.Velocidade),
|
||||
RPM = Convert.ToInt32(g.Average(x => x.Log.RPM)),
|
||||
RPM_SP = Convert.ToInt32(g.Average(x => x.Log.RPM_SP)),
|
||||
Temperatura = g.Average(x => x.Log.Temperatura),
|
||||
Tensao = g.Average(x => x.Log.Tensao),
|
||||
})
|
||||
.ToList();
|
||||
|
||||
if (Motor.LogGrafico.Count > 0)
|
||||
if (Logs.Count > 0)
|
||||
{
|
||||
Log = Motor.LogGrafico.Last();
|
||||
Log = Logs.Last();
|
||||
}
|
||||
|
||||
double Minimo = 0;
|
||||
|
|
@ -294,7 +308,7 @@ namespace AgroBase.Forms.Operacoes
|
|||
Chart chart = chartGraficos;
|
||||
chart.Titles.Clear();
|
||||
chart.Titles.Add("Acompanhamento");
|
||||
var Logs = (Motor.LogGrafico.Count > MovimentacaoModel.LogsManter ? Motor.LogGrafico.Skip(Math.Max(0, Motor.LogGrafico.Count - MovimentacaoModel.LogsManter)).Take(MovimentacaoModel.LogsManter).ToList() : Motor.LogGrafico).Where(log => log.Modulo_ID == Modulo.Modulo_ID).ToList();
|
||||
//var Logs = (Motor.LogGrafico.Count > MovimentacaoModel.LogsManter ? Motor.LogGrafico.Skip(Math.Max(0, Motor.LogGrafico.Count - MovimentacaoModel.LogsManter)).Take(MovimentacaoModel.LogsManter).ToList() : Motor.LogGrafico).Where(log => log.Modulo_ID == Modulo.Modulo_ID).ToList();
|
||||
chart.Series.Clear();
|
||||
List<string> Momentos = Logs.Select(x => x.Momento.ToString("mm:ss:fff")).ToList();
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,10 @@ namespace AgroBase.Forms
|
|||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(278, 152);
|
||||
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.Name = "frmInstancial";
|
||||
this.Text = "frmInstancial";
|
||||
this.Load += new System.EventHandler(this.frmInstancial_Load);
|
||||
this.Shown += new System.EventHandler(this.frmInstancial_Shown);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
using AgroBase.Forms.Movimentacao;
|
||||
using AgroBase.Forms.IHM;
|
||||
using AgroBase.Forms.Movimentacao;
|
||||
using AgroBase.Models;
|
||||
using AgroBase.Models.Modules;
|
||||
using AgroBase.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -9,14 +12,25 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static AgroBase.Models.Enuns;
|
||||
|
||||
namespace AgroBase.Forms
|
||||
{
|
||||
public partial class frmInstancial : Form
|
||||
{
|
||||
public bool DebugMode = true;
|
||||
|
||||
public static bool Fechando = false;
|
||||
|
||||
public static frmPrincipal frmPrincipal = new frmPrincipal();
|
||||
public static frmJoystick frmJoystick = new frmJoystick();
|
||||
public static frmAcompanhamento frmAcompanhamento = new frmAcompanhamento();
|
||||
public static frmIHM frmIHM = new frmIHM()
|
||||
{
|
||||
FormBorderStyle = FormBorderStyle.None,
|
||||
WindowState = FormWindowState.Maximized,
|
||||
TopMost = true
|
||||
};
|
||||
|
||||
public frmInstancial()
|
||||
{
|
||||
|
|
@ -26,9 +40,64 @@ namespace AgroBase.Forms
|
|||
|
||||
private void frmInstancial_Shown(object sender, EventArgs e)
|
||||
{
|
||||
frmPrincipal.Show();
|
||||
if (DebugMode)
|
||||
{
|
||||
frmPrincipal.FormClosing += frmPrincipal_FormClosing;
|
||||
frmPrincipal.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
frmIHM.FormClosing += frmPrincipal_FormClosing;
|
||||
frmIHM.Show();
|
||||
}
|
||||
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
private void frmInstancial_Load(object sender, EventArgs e)
|
||||
{
|
||||
FuncoesGlobais.AddApplicationToStartup();
|
||||
IniciarConexaoMqtt();
|
||||
}
|
||||
|
||||
private async void IniciarConexaoMqtt()
|
||||
{
|
||||
await Variaveis.MqttService.ConnectAsync();
|
||||
}
|
||||
|
||||
public static async Task EncerrarProcessos()
|
||||
{
|
||||
Fechando = true;
|
||||
|
||||
foreach (var Disp in Variaveis.DispositivosConectados)
|
||||
{
|
||||
if (Disp._Porta.IsOpen)
|
||||
{
|
||||
Disp.btnConectar_Click(new object(), new EventArgs());
|
||||
}
|
||||
if (Disp.Dispositivo == T_Code.Sen)
|
||||
{
|
||||
((SensoriamentoModel)Disp.Dados).ultimoFrameSoloE = null;
|
||||
((SensoriamentoModel)Disp.Dados).ultimoFrameSoloD = null;
|
||||
((SensoriamentoModel)Disp.Dados).ultimoFrameCaminho = null;
|
||||
}
|
||||
Disp.SalvarParametros(Disp.Dados);
|
||||
}
|
||||
|
||||
while (!FilaService.Liberado)
|
||||
{
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
|
||||
private void frmPrincipal_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
EncerrarProcessos().ConfigureAwait(false);
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ namespace AgroBase
|
|||
this.gpbControleDirecional = new System.Windows.Forms.GroupBox();
|
||||
this.gpbAtalhos = new System.Windows.Forms.GroupBox();
|
||||
this.pnlAtalhos = new System.Windows.Forms.Panel();
|
||||
this.btnMKS = new System.Windows.Forms.Button();
|
||||
this.btnBLD300R = new System.Windows.Forms.Button();
|
||||
this.btnWT901C = new System.Windows.Forms.Button();
|
||||
this.btnLoRaConfig = new System.Windows.Forms.Button();
|
||||
|
|
@ -93,7 +94,6 @@ namespace AgroBase
|
|||
this.btnIniciarOperacao = new System.Windows.Forms.Button();
|
||||
this.lblModoOperacao = new System.Windows.Forms.Label();
|
||||
this.cmbModoOperacao = new System.Windows.Forms.ComboBox();
|
||||
this.btnMKS = new System.Windows.Forms.Button();
|
||||
this.gpbAcoes.SuspendLayout();
|
||||
this.erroStrip.SuspendLayout();
|
||||
this.pnlLateral.SuspendLayout();
|
||||
|
|
@ -623,6 +623,17 @@ namespace AgroBase
|
|||
this.pnlAtalhos.Size = new System.Drawing.Size(112, 286);
|
||||
this.pnlAtalhos.TabIndex = 0;
|
||||
//
|
||||
// btnMKS
|
||||
//
|
||||
this.btnMKS.Location = new System.Drawing.Point(5, 367);
|
||||
this.btnMKS.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnMKS.Name = "btnMKS";
|
||||
this.btnMKS.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnMKS.TabIndex = 29;
|
||||
this.btnMKS.Text = "MKS 057D";
|
||||
this.btnMKS.UseVisualStyleBackColor = true;
|
||||
this.btnMKS.Click += new System.EventHandler(this.btnMKS_Click);
|
||||
//
|
||||
// btnBLD300R
|
||||
//
|
||||
this.btnBLD300R.Location = new System.Drawing.Point(5, 343);
|
||||
|
|
@ -815,17 +826,6 @@ namespace AgroBase
|
|||
this.cmbModoOperacao.TabIndex = 13;
|
||||
this.cmbModoOperacao.SelectedIndexChanged += new System.EventHandler(this.cmbModoOperacao_SelectedIndexChanged);
|
||||
//
|
||||
// btnMKS
|
||||
//
|
||||
this.btnMKS.Location = new System.Drawing.Point(5, 367);
|
||||
this.btnMKS.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnMKS.Name = "btnMKS";
|
||||
this.btnMKS.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnMKS.TabIndex = 29;
|
||||
this.btnMKS.Text = "MKS 057D";
|
||||
this.btnMKS.UseVisualStyleBackColor = true;
|
||||
this.btnMKS.Click += new System.EventHandler(this.btnMKS_Click);
|
||||
//
|
||||
// frmPrincipal
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
|
@ -843,7 +843,6 @@ namespace AgroBase
|
|||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Agro Base";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmPrincipal_FormClosing);
|
||||
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.frmPrincipal_FormClosed);
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
this.gpbAcoes.ResumeLayout(false);
|
||||
this.gpbAcoes.PerformLayout();
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@ namespace AgroBase
|
|||
{
|
||||
public partial class frmPrincipal : Form
|
||||
{
|
||||
|
||||
public static bool Fechando = false;
|
||||
|
||||
|
||||
public frmPrincipal()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
|
@ -41,50 +37,14 @@ namespace AgroBase
|
|||
{
|
||||
timerDispositivos.Enabled = true;
|
||||
AtualizaDadosGerais();
|
||||
|
||||
|
||||
IniciarConexaoMqtt();
|
||||
}
|
||||
|
||||
|
||||
private void frmPrincipal_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
EncerrarProcessos().ConfigureAwait(false);
|
||||
frmInstancial.EncerrarProcessos().ConfigureAwait(false);
|
||||
e.Cancel = true;
|
||||
}
|
||||
|
||||
private async Task EncerrarProcessos()
|
||||
{
|
||||
Fechando = true;
|
||||
|
||||
foreach (var Disp in Variaveis.DispositivosConectados)
|
||||
{
|
||||
if (Disp._Porta.IsOpen)
|
||||
{
|
||||
Disp.btnConectar_Click(new object(), new EventArgs());
|
||||
}
|
||||
if (Disp.Dispositivo == T_Code.Sen)
|
||||
{
|
||||
((SensoriamentoModel)Disp.Dados).ultimoFrameSoloE = null;
|
||||
((SensoriamentoModel)Disp.Dados).ultimoFrameSoloD = null;
|
||||
((SensoriamentoModel)Disp.Dados).ultimoFrameCaminho = null;
|
||||
}
|
||||
Disp.SalvarParametros(Disp.Dados);
|
||||
}
|
||||
|
||||
while (!FilaService.Liberado)
|
||||
{
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private async void IniciarConexaoMqtt()
|
||||
{
|
||||
await Variaveis.MqttService.ConnectAsync();
|
||||
}
|
||||
|
||||
public void AtualizaDadosGerais()
|
||||
{
|
||||
btnJoyAtt_Click(new object(), new EventArgs());
|
||||
|
|
@ -98,6 +58,9 @@ namespace AgroBase
|
|||
cmbModoOperacao.SelectedIndex = (int)Variaveis.OperacaoEmAndamento.Modo;
|
||||
}
|
||||
|
||||
|
||||
#region DISPOSITIVOS
|
||||
|
||||
private void btnNovoDispositivo_Click(object sender, EventArgs e)
|
||||
{
|
||||
gpbNovoDispositivo.Enabled = true;
|
||||
|
|
@ -145,23 +108,6 @@ namespace AgroBase
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void btnJoyAtt_Click(object sender, EventArgs e)
|
||||
{
|
||||
GeneralJoystick.AtualizaDispositivo();
|
||||
}
|
||||
|
||||
private void btnJoyEdt_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void btnVer_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmInstancial.frmJoystick.Show();
|
||||
}
|
||||
|
||||
private void timerDispositivos_Tick(object sender, EventArgs e)
|
||||
{
|
||||
lstDisponiveis.Items.Clear();
|
||||
|
|
@ -170,18 +116,18 @@ namespace AgroBase
|
|||
.GroupBy(x => x.Dispositivo)
|
||||
.Select(x => new ListViewItem()
|
||||
{
|
||||
Text =
|
||||
x.FirstOrDefault().PortaCOM + " - " + Enum.GetName(typeof(T_Code), x.Key) + " v" + x.FirstOrDefault().Versao +
|
||||
Text =
|
||||
x.FirstOrDefault().PortaCOM + " - " + Enum.GetName(typeof(T_Code), x.Key) + " v" + x.FirstOrDefault().Versao +
|
||||
|
||||
(x.FirstOrDefault().Dispositivo == T_Code.Mvd ? (" (" + string.Join(", ", x.Select(y => y.Mod_ID)) + ")") :
|
||||
(x.FirstOrDefault().Dispositivo == T_Code.Bld ? (" (" + string.Join(", ", x.Select(y => y.Mod_ID)) + ")") :
|
||||
"")) + " - " +
|
||||
(x.FirstOrDefault().Dispositivo == T_Code.Mvd ? (" (" + string.Join(", ", x.Select(y => y.Mod_ID)) + ")") :
|
||||
(x.FirstOrDefault().Dispositivo == T_Code.Bld ? (" (" + string.Join(", ", x.Select(y => y.Mod_ID)) + ")") :
|
||||
"")) + " - " +
|
||||
|
||||
(x.FirstOrDefault().Dispositivo == T_Code.Gps ? (GPSService.Iniciado ? "Conectado" : "Desconectado") :
|
||||
x.FirstOrDefault().Dispositivo == T_Code.Pzm ? (PZEMService.Iniciado ? "Conectado" : "Desconectado") :
|
||||
x.FirstOrDefault().Dispositivo == T_Code.Lra ? (LoRaService.Iniciado ? "Conectado" : "Desconectado") :
|
||||
x.FirstOrDefault().Dispositivo == T_Code.Wit ? (WT901CService.Iniciado ? "Conectado" : "Desconectado") :
|
||||
x.FirstOrDefault().Dispositivo == T_Code.Bld ? (Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.Any(y => y.MovMotor.DadosDriver.Iniciado) ? "Conectado" : "Desconectado") :
|
||||
(x.FirstOrDefault().Dispositivo == T_Code.Gps ? (GPSService.Iniciado ? "Conectado" : "Desconectado") :
|
||||
x.FirstOrDefault().Dispositivo == T_Code.Pzm ? (PZEMService.Iniciado ? "Conectado" : "Desconectado") :
|
||||
x.FirstOrDefault().Dispositivo == T_Code.Lra ? (LoRaService.Iniciado ? "Conectado" : "Desconectado") :
|
||||
x.FirstOrDefault().Dispositivo == T_Code.Wit ? (WT901CService.Iniciado ? "Conectado" : "Desconectado") :
|
||||
x.FirstOrDefault().Dispositivo == T_Code.Bld ? (Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.Any(y => y.MovMotor.DadosDriver.Iniciado) ? "Conectado" : "Desconectado") :
|
||||
(Variaveis.DispositivosConectados.FirstOrDefault(y => y.PortaCOM() == x.FirstOrDefault().PortaCOM)?.StatusPorta() ?? "Desconectado"))
|
||||
}).ToArray()
|
||||
);
|
||||
|
|
@ -189,12 +135,12 @@ namespace AgroBase
|
|||
{
|
||||
Variaveis.DispositivosConectados.Where(x => x.Dados.GetStatusConexao()).ToList().ForEach(x => x.AcaoDesconectar());
|
||||
}
|
||||
//SerialService.RealizarVarreduraPortasUSB().ConfigureAwait(false);
|
||||
SerialService.RealizarVarreduraPortasUSB().ConfigureAwait(false);
|
||||
|
||||
if (
|
||||
Variaveis.OperacaoEmAndamento.DispAtu == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Atu) ||
|
||||
Variaveis.OperacaoEmAndamento.DispDir == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Dir) ||
|
||||
Variaveis.OperacaoEmAndamento.DispMov == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Mov) ||
|
||||
//Variaveis.OperacaoEmAndamento.DispDir == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Dir) ||
|
||||
//Variaveis.OperacaoEmAndamento.DispMov == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Mov) ||
|
||||
Variaveis.OperacaoEmAndamento.DispMvd == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Mvd) ||
|
||||
Variaveis.OperacaoEmAndamento.DispSen == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Sen)
|
||||
)
|
||||
|
|
@ -214,119 +160,15 @@ namespace AgroBase
|
|||
});
|
||||
}
|
||||
|
||||
private void frmPrincipal_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
PythonService.EncerrarProcessos();
|
||||
Environment.Exit(0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void btnDiagnosticos_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmMovDiagnosticos frm = new frmMovDiagnosticos();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
|
||||
public void AtualizaRPM(int valor)
|
||||
{
|
||||
if (valor >= trkRPM.Minimum && valor <= trkRPM.Maximum)
|
||||
{
|
||||
double Velocidade = MovimentacaoModel.CalculaVelocidadeRPM(valor);
|
||||
trkRPM.Value = valor;
|
||||
trkKmh.Value = Convert.ToInt32(Velocidade);
|
||||
|
||||
GeneralJoystick.RPM = trkRPM.Value;
|
||||
lblRPM.Text = "RPM: " + GeneralJoystick.RPM;
|
||||
lblKmh.Text = "Velocidade: " + Velocidade.ToString("0.00") + " km/h";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void btnMovConfig_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmMovConfig frm = new frmMovConfig();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
private void cmbDispositivos_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
btnJoyAtt_Click(sender, e);
|
||||
}
|
||||
|
||||
private void tkbPotencia_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
GeneralJoystick.Velocidade = tkbVelocidade.Value;
|
||||
lblVelocidade.Text = "Velocidade: " + GeneralJoystick.Velocidade + "%";
|
||||
}
|
||||
|
||||
private void tkbRampa_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
GeneralJoystick.Angulo = tkbAngulo.Value;
|
||||
lblAngulo.Text = "Angulo: " + GeneralJoystick.Angulo + "º";
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
private void trkRPM_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int RPM = ((TrackBar)sender).Value;
|
||||
AtualizaRPM(RPM);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void trkKmh_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int RPM = Convert.ToInt32(MovimentacaoModel.CalculaRPMVelocidade(((TrackBar)sender).Value));
|
||||
AtualizaRPM(RPM);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void btnAcompanhamento_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmInstancial.frmAcompanhamento.Show();
|
||||
}
|
||||
|
||||
private void btnCamera_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmAtuCamera frmCamera = new frmAtuCamera();
|
||||
frmCamera.Show();
|
||||
}
|
||||
|
||||
private void btnMapas_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmMapa frmMapa = new frmMapa();
|
||||
frmMapa.Show();
|
||||
}
|
||||
|
||||
private void btnGPS_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmGPS frmGps = new frmGPS();
|
||||
frmGps.Show();
|
||||
}
|
||||
|
||||
private void btnSenCamera_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmSenCamera frmCamera = new frmSenCamera();
|
||||
frmCamera.Show();
|
||||
}
|
||||
#region OPERACAO
|
||||
|
||||
private void cmbModoOperacao_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
|
@ -357,6 +199,117 @@ namespace AgroBase
|
|||
frmParametrizacaoOperacao.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region CONTROLE
|
||||
|
||||
private void btnJoyAtt_Click(object sender, EventArgs e)
|
||||
{
|
||||
GeneralJoystick.AtualizaDispositivo();
|
||||
}
|
||||
|
||||
private void btnJoyEdt_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void btnVer_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmInstancial.frmJoystick.Show();
|
||||
}
|
||||
|
||||
public void AtualizaRPM(int valor)
|
||||
{
|
||||
if (valor >= trkRPM.Minimum && valor <= trkRPM.Maximum)
|
||||
{
|
||||
double Velocidade = MovimentacaoModel.CalculaVelocidadeRPM(valor);
|
||||
trkRPM.Value = valor;
|
||||
trkKmh.Value = Convert.ToInt32(Velocidade);
|
||||
|
||||
GeneralJoystick.RPM = trkRPM.Value;
|
||||
lblRPM.Text = "RPM: " + GeneralJoystick.RPM;
|
||||
lblKmh.Text = "Velocidade: " + Velocidade.ToString("0.00") + " km/h";
|
||||
}
|
||||
}
|
||||
|
||||
private void tkbPotencia_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
GeneralJoystick.Velocidade = tkbVelocidade.Value;
|
||||
lblVelocidade.Text = "Velocidade: " + GeneralJoystick.Velocidade + "%";
|
||||
}
|
||||
|
||||
private void tkbRampa_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
GeneralJoystick.Angulo = tkbAngulo.Value;
|
||||
lblAngulo.Text = "Angulo: " + GeneralJoystick.Angulo + "º";
|
||||
}
|
||||
|
||||
private void trkRPM_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int RPM = ((TrackBar)sender).Value;
|
||||
AtualizaRPM(RPM);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void trkKmh_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
int RPM = Convert.ToInt32(MovimentacaoModel.CalculaRPMVelocidade(((TrackBar)sender).Value));
|
||||
AtualizaRPM(RPM);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ATALHOS
|
||||
|
||||
private void btnDiagnosticos_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmMovDiagnosticos frm = new frmMovDiagnosticos();
|
||||
frm.ShowDialog();
|
||||
}
|
||||
|
||||
private void btnAcompanhamento_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmInstancial.frmAcompanhamento.Show();
|
||||
}
|
||||
|
||||
private void btnCamera_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmAtuCamera frmCamera = new frmAtuCamera();
|
||||
frmCamera.Show();
|
||||
}
|
||||
|
||||
private void btnMapas_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmMapa frmMapa = new frmMapa();
|
||||
frmMapa.Show();
|
||||
}
|
||||
|
||||
private void btnGPS_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmGPS frmGps = new frmGPS();
|
||||
frmGps.Show();
|
||||
}
|
||||
|
||||
private void btnSenCamera_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmSenCamera frmCamera = new frmSenCamera();
|
||||
frmCamera.Show();
|
||||
}
|
||||
|
||||
private void btnIHM_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmIHM frmIHM = new frmIHM();
|
||||
|
|
@ -443,5 +396,8 @@ namespace AgroBase
|
|||
frmMKS frm = new frmMKS();
|
||||
frm.Show();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
public class MKS057DModel
|
||||
{
|
||||
public byte Endereco { get; set; }
|
||||
public bool Iniciado { get; set; }
|
||||
public double ErroCarregado { get; set; }
|
||||
public string ErroCarregado_Hex { get; set; }
|
||||
|
|
@ -34,6 +35,7 @@ namespace AgroBase.Models
|
|||
|
||||
public class MKS057ComandoModel
|
||||
{
|
||||
public bool Get { get; set; }
|
||||
public byte Comando { get; set; }
|
||||
public string Endereco { get; set; }
|
||||
public double Angulo { get; set; }
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ namespace AgroBase.Models
|
|||
|
||||
if (RuaEsquerda.Any())
|
||||
{
|
||||
distancia = DistanciaAteRua(RuaEsquerda);
|
||||
distancia = DistanciaAteRua(RuaEsquerda, VariaveisEquipamento.LarguraEsquerda);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -273,7 +273,7 @@ namespace AgroBase.Models
|
|||
|
||||
if (RuaDireita.Any())
|
||||
{
|
||||
distancia = DistanciaAteRua(RuaDireita);
|
||||
distancia = DistanciaAteRua(RuaDireita, VariaveisEquipamento.LarguraDireita);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -463,7 +463,7 @@ namespace AgroBase.Models
|
|||
return menorDistancia;
|
||||
}
|
||||
|
||||
public double DistanciaAteRua(List<GPSModel> Rua)
|
||||
public double DistanciaAteRua(List<GPSModel> Rua, double larguraRobo)
|
||||
{
|
||||
GPSModel pontoAtual = GPSService.UltimaLeitura;
|
||||
|
||||
|
|
@ -479,7 +479,7 @@ namespace AgroBase.Models
|
|||
|
||||
double distancia = FuncoesMatematicas.CalcularAlturaTriangulo(a, b, c);
|
||||
|
||||
distancia -= (VariaveisEquipamento.Largura / 2.0 / 100.0);
|
||||
distancia -= (larguraRobo / 100.0);
|
||||
|
||||
return distancia;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ namespace AgroBase.Models.Modules
|
|||
{
|
||||
Conectado = conecatdo;
|
||||
|
||||
Variaveis.OperacaoEmAndamento.DispDir.AcaoConexao();
|
||||
//Variaveis.OperacaoEmAndamento.DispDir.AcaoConexao();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -275,7 +275,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
Conectado = conecatdo;
|
||||
|
||||
Variaveis.OperacaoEmAndamento.DispMov.AcaoConexao();
|
||||
//Variaveis.OperacaoEmAndamento.DispMov.AcaoConexao();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -512,7 +512,7 @@ namespace AgroBase.Models
|
|||
|
||||
if (Inicializado && (!AlarmeAnterior || Adicionado) && AlarmeAtual) // Motor iniciado, Não estava em alarme anteriormente ou foi adicionado agora, alarme atual
|
||||
{
|
||||
Variaveis.OperacaoEmAndamento.DispMov.AdicionarMensagemFila(Variaveis.OperacaoEmAndamento.DispMov.Dados.Modulo_ID, ProtocoloComando(Direcao.Frente, true), true, false);
|
||||
//Variaveis.OperacaoEmAndamento.DispMov.AdicionarMensagemFila(Variaveis.OperacaoEmAndamento.DispMov.Dados.Modulo_ID, ProtocoloComando(Direcao.Frente, true), true, false);
|
||||
}
|
||||
|
||||
Alm.Valor = _Alarme.Valor;
|
||||
|
|
|
|||
|
|
@ -111,55 +111,35 @@ namespace AgroBase.Models.Modules
|
|||
{
|
||||
case S_Code.sBLD:
|
||||
{
|
||||
Modulo.MovMotor.Inicializado = Dados[2] == "1";
|
||||
double rpm = 0;
|
||||
double.TryParse(Dados[2].Replace(".", ","), out rpm);
|
||||
double.TryParse(Dados[3].Replace(".", ","), out rpm);
|
||||
Modulo.MovMotor.RPM = rpm;
|
||||
double temperatura = 0;
|
||||
double.TryParse(Dados[3].Replace(".", ","), out temperatura);
|
||||
temperatura = FuncoesMatematicas.CalcularTemperatura(temperatura, -1.038);
|
||||
double.TryParse(Dados[4].Replace(".", ","), out temperatura);
|
||||
temperatura = FuncoesMatematicas.CalcularTemperatura(temperatura, 0.0);
|
||||
Modulo.MovMotor.Temperatura = temperatura;
|
||||
double tensao = 0;
|
||||
double.TryParse(Dados[4].Replace(".", ","), out tensao);
|
||||
double.TryParse(Dados[5].Replace(".", ","), out tensao);
|
||||
Modulo.MovMotor.Tensao = tensao;
|
||||
double corrente_max = 0;
|
||||
double.TryParse(Dados[5].Replace(".", ","), out corrente_max);
|
||||
corrente_max = FuncoesMatematicas.Map(corrente_max, 15780, 16799, 0, 20.6);
|
||||
double.TryParse(Dados[6].Replace(".", ","), out corrente_max);
|
||||
Modulo.MovMotor.Corrente_Max = corrente_max;
|
||||
bool ligado = Dados[6] == "1";
|
||||
bool ligado = Dados[7] == "1";
|
||||
Modulo.MovMotor.Ligado = ligado;
|
||||
int sentido = 0;
|
||||
int.TryParse(Dados[7], out sentido);
|
||||
int.TryParse(Dados[8], out sentido);
|
||||
Modulo.MovMotor.Sentido = (Sentido)sentido;
|
||||
bool freio = Dados[8] == "1";
|
||||
bool freio = Dados[9] == "1";
|
||||
Modulo.MovMotor.Freio = freio;
|
||||
int codAlarme = 0;
|
||||
int.TryParse(Dados[9], out codAlarme);
|
||||
int.TryParse(Dados[10], out codAlarme);
|
||||
Modulo.MovMotor.CodigoAlarme = codAlarme;
|
||||
double tempDriver = 0;
|
||||
double.TryParse(Dados[10].Replace(".", ","), out tempDriver);
|
||||
tempDriver = FuncoesMatematicas.CalcularTemperatura(tempDriver, 0);
|
||||
double.TryParse(Dados[11].Replace(".", ","), out tempDriver);
|
||||
Modulo.MovMotor.TemperaturaDriver = tempDriver;
|
||||
|
||||
Modulo.MovMotor.LogGrafico.Add(new MvdMotorMOVSensorimanetoGrafico()
|
||||
{
|
||||
Momento = DateTime.Now,
|
||||
Modulo_ID = Modulo.Modulo_ID,
|
||||
RPM_SP = Modulo.MovMotor.RPM_SP,
|
||||
RPM = Modulo.MovMotor.RPM,
|
||||
Corrente = Modulo.MovMotor.Corrente,
|
||||
Sentido = Modulo.MovMotor.Sentido,
|
||||
Temperatura = Modulo.MovMotor.Temperatura,
|
||||
TemperaturaDriver = Modulo.MovMotor.TemperaturaDriver,
|
||||
Tensao = Modulo.MovMotor.Tensao,
|
||||
Velocidade = Modulo.MovMotor.VelocidadeInstantanea
|
||||
});
|
||||
|
||||
if (Modulo.MovMotor.LogGrafico.Count > 60)
|
||||
{
|
||||
Modulo.MovMotor.LogGrafico.RemoveAt(0);
|
||||
}
|
||||
|
||||
frmInstancial.frmAcompanhamento.AtualizaGrafico();
|
||||
RegistrarLog(Modulo);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
@ -361,6 +341,8 @@ namespace AgroBase.Models.Modules
|
|||
{
|
||||
string Protocolo = Modulo.ProtocoloAquisicaoDados();
|
||||
Variaveis.OperacaoEmAndamento.DispMvd.AdicionarMensagemFila(Modulo.Modulo_ID, Protocolo, false, false);
|
||||
|
||||
Modulo.DirMotor.ProtocoloAquisicaoDados();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -426,10 +408,10 @@ namespace AgroBase.Models.Modules
|
|||
{
|
||||
Config.Add(MovMotor.ProtocoloConfiguracao(Conectar));
|
||||
}
|
||||
if (DirMotor.Comandar)
|
||||
/*if (DirMotor.Comandar)
|
||||
{
|
||||
Config.Add(DirMotor.ProtocoloConfiguracao(Conectar));
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!Conectar)
|
||||
{
|
||||
|
|
@ -666,8 +648,6 @@ namespace AgroBase.Models.Modules
|
|||
public ConfiguracaoSentidoMotor ConfigSentidos { get; set; }
|
||||
public List<FuncoesPinout> Funcoes { get; set; }
|
||||
|
||||
public MKS057DModel DadosDriver { get; set; } = new MKS057DModel();
|
||||
|
||||
|
||||
public static MvdMotorPasso CarregarParametrosIniciais(string Mod_ID, string _Endereco)
|
||||
{
|
||||
|
|
@ -716,7 +696,8 @@ namespace AgroBase.Models.Modules
|
|||
|
||||
public string ProtocoloComando(Direcao Direcao)
|
||||
{
|
||||
if ((Inicializado || (MKS057DService.Iniciado && DadosDriver.Iniciado)) && Comandar && (Controlar))
|
||||
bool mksIniciado = MKS057DService.DadosLeitura.Any(x => x.Iniciado && Convert.ToByte(Endereco.Replace("0x", ""), 16) == x.Endereco);
|
||||
if ((Inicializado || mksIniciado) && Comandar && (Controlar))
|
||||
{
|
||||
Sentido_SP =
|
||||
Direcao == Direcao.Cima ? ConfigSentidos.Direita :
|
||||
|
|
@ -735,12 +716,13 @@ namespace AgroBase.Models.Modules
|
|||
Angulo_SP.ToString() + SerialService.SplitParams +
|
||||
Velocidade.ToString();
|
||||
|
||||
if (MKS057DService.Iniciado && DadosDriver.Iniciado)
|
||||
if (mksIniciado)
|
||||
{
|
||||
int mx = Sentido_SP == Sentido.Antihorario ? -1 : 1;
|
||||
|
||||
MKS057DService.EnviarComandoControle(new MKS057ComandoModel()
|
||||
{
|
||||
Get = false,
|
||||
Comando = Convert.ToByte("13"),
|
||||
Endereco = Endereco,
|
||||
Angulo = Angulo_SP * mx,
|
||||
|
|
@ -760,13 +742,21 @@ namespace AgroBase.Models.Modules
|
|||
|
||||
public string ProtocoloAquisicaoDados()
|
||||
{
|
||||
if (Inicializado)
|
||||
bool mksIniciado = MKS057DService.DadosLeitura.Any(x => x.Iniciado && Convert.ToByte(Endereco.Replace("0x", ""), 16) == x.Endereco);
|
||||
if (Inicializado || mksIniciado)
|
||||
{
|
||||
string ProtocoloMotor =
|
||||
((int)F_Code.Req).ToString() + SerialService.SplitMessage +
|
||||
ID + SerialService.SplitParams +
|
||||
"";
|
||||
|
||||
if (mksIniciado)
|
||||
{
|
||||
MKS057DService.EnviarComandoRequisicao(Endereco).ConfigureAwait(false);
|
||||
|
||||
ProtocoloMotor = "";
|
||||
}
|
||||
|
||||
return ProtocoloMotor;
|
||||
}
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -660,7 +660,7 @@ namespace AgroBase.Models.Modules
|
|||
if (
|
||||
Variaveis.OperacaoEmAndamento.Sensoriamento.SonarFrontal.DesvioNecessario &&
|
||||
Variaveis.OperacaoEmAndamento.Sensoriamento.SonarFrontal.DirecaoDesvio == Direcao.Parado &&
|
||||
Variaveis.OperacaoEmAndamento.DispMov.Dados.Conectado
|
||||
Variaveis.OperacaoEmAndamento.DispMvd.Dados.Conectado
|
||||
)
|
||||
{
|
||||
foreach (var Modulo in Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos)
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ namespace AgroBase.Models
|
|||
{
|
||||
this.Modo = Modo;
|
||||
|
||||
this.DispMov = Mov;
|
||||
this.DispDir = Dir;
|
||||
//this.DispMov = Mov;
|
||||
//this.DispDir = Dir;
|
||||
this.DispAtu = Atu;
|
||||
|
||||
if (Modo == ModoOperacao.MapaGPS)
|
||||
|
|
@ -91,8 +91,8 @@ namespace AgroBase.Models
|
|||
public OperacaoManualModel OpManual { get; set; } = new OperacaoManualModel();
|
||||
public DispositivosService<MovimentacaoUnificadaModel> DispMvd { get; set; }
|
||||
public DispositivosService<SensoriamentoModel> DispSen { get; set; }
|
||||
public DispositivosService<MovimentacaoModel> DispMov { get; set; }
|
||||
public DispositivosService<DirecionalModel> DispDir { get; set; }
|
||||
/*public DispositivosService<MovimentacaoModel> DispMov { get; set; }
|
||||
public DispositivosService<DirecionalModel> DispDir { get; set; }*/
|
||||
public DispositivosService<AtuadorModel> DispAtu { get; set; }
|
||||
public MapasModel Mapa { get; set; } = new MapasModel();
|
||||
public OperacaoSensoriamentoLogModel Sensoriamento { get; set; }
|
||||
|
|
@ -183,16 +183,16 @@ namespace AgroBase.Models
|
|||
{
|
||||
if (Modulo.Dispositivo == T_Code.Gps)
|
||||
{
|
||||
Modulo.Conectado = GPSService.PortaGPS != null;
|
||||
Modulo.Conectado = GPSService.Iniciado;
|
||||
}
|
||||
else
|
||||
{
|
||||
Modulo.Conectado = !Modulo.Mandatorio || Variaveis.DispositivosConectados.Any(x => x.Dispositivo == Modulo.Dispositivo && x._Porta.IsOpen);
|
||||
Modulo.Conectado = Variaveis.DispositivosConectados.Any(x => x.Dispositivo == Modulo.Dispositivo && x._Porta.IsOpen);
|
||||
}
|
||||
});
|
||||
|
||||
bool _modulosConectados =
|
||||
(ModulosMandatorios.Where(x => x.Mandatorio).All(x => x.Conectado) && ModulosMandatorios.Any(x => x.Mandatorio)) ||
|
||||
(ModulosMandatorios.Any(x => x.Mandatorio) && ModulosMandatorios.Where(x => x.Mandatorio).All(x => x.Conectado)) ||
|
||||
(ModulosMandatorios.All(x => !x.Mandatorio) && ModulosMandatorios.Any(x => x.Conectado));
|
||||
|
||||
|
||||
|
|
@ -254,8 +254,8 @@ namespace AgroBase.Models
|
|||
public static OperacaoModel CarregarParametrosOperacaoPadrao(ModoOperacao Modo)
|
||||
{
|
||||
var SenConectado = (DispositivosService<SensoriamentoModel>)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Sen);
|
||||
var MovConectado = (DispositivosService<MovimentacaoModel>)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Mov);
|
||||
var DirConectado = (DispositivosService<DirecionalModel>)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Dir);
|
||||
//var MovConectado = (DispositivosService<MovimentacaoModel>)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Mov);
|
||||
//var DirConectado = (DispositivosService<DirecionalModel>)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Dir);
|
||||
var AtuConectado = (DispositivosService<AtuadorModel>)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Atu);
|
||||
|
||||
var MvdConectado = (DispositivosService<MovimentacaoUnificadaModel>)Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Mvd);
|
||||
|
|
@ -268,8 +268,8 @@ namespace AgroBase.Models
|
|||
TimestampInicio = 0,
|
||||
TimestampFim = 0,
|
||||
DispAtu = AtuConectado,
|
||||
DispDir = DirConectado,
|
||||
DispMov = MovConectado,
|
||||
/*DispDir = DirConectado,
|
||||
DispMov = MovConectado,*/
|
||||
DispSen = SenConectado,
|
||||
DispMvd = MvdConectado,
|
||||
Sensoriamento = new OperacaoSensoriamentoLogModel(),
|
||||
|
|
@ -298,6 +298,13 @@ namespace AgroBase.Models
|
|||
Comandos = new List<string>(),
|
||||
UltimoComando = DateTime.Now
|
||||
},
|
||||
new OperacaoControleTipoModel()
|
||||
{
|
||||
Tipo = T_Code.Atu,
|
||||
DelayEnvioComando = 10,
|
||||
Comandos = new List<string>(),
|
||||
UltimoComando = DateTime.Now
|
||||
}
|
||||
},
|
||||
};
|
||||
OperacaoCarregar.ModulosMandatorios = new List<OperacaoModulosMandatoriosModel>()
|
||||
|
|
@ -305,8 +312,18 @@ namespace AgroBase.Models
|
|||
new OperacaoModulosMandatoriosModel()
|
||||
{
|
||||
Dispositivo = T_Code.Mvd,
|
||||
Mandatorio = true,
|
||||
Mandatorio = false
|
||||
},
|
||||
new OperacaoModulosMandatoriosModel()
|
||||
{
|
||||
Dispositivo = T_Code.Mks,
|
||||
Mandatorio = false
|
||||
},
|
||||
new OperacaoModulosMandatoriosModel()
|
||||
{
|
||||
Dispositivo = T_Code.Atu,
|
||||
Mandatorio = false
|
||||
}
|
||||
};
|
||||
OperacaoCarregar.ParametrosMandatorios = new List<OperacaoParametrosMandatoriosModel>()
|
||||
{
|
||||
|
|
@ -357,12 +374,12 @@ namespace AgroBase.Models
|
|||
{
|
||||
new OperacaoModulosMandatoriosModel()
|
||||
{
|
||||
Dispositivo = T_Code.Mov,
|
||||
Dispositivo = T_Code.Mvd,
|
||||
Mandatorio = true,
|
||||
},
|
||||
new OperacaoModulosMandatoriosModel()
|
||||
{
|
||||
Dispositivo = T_Code.Dir,
|
||||
Dispositivo = T_Code.Mks,
|
||||
Mandatorio = true,
|
||||
},
|
||||
new OperacaoModulosMandatoriosModel()
|
||||
|
|
@ -379,6 +396,16 @@ namespace AgroBase.Models
|
|||
{
|
||||
Dispositivo = T_Code.Sen,
|
||||
Mandatorio = false,
|
||||
},
|
||||
new OperacaoModulosMandatoriosModel()
|
||||
{
|
||||
Dispositivo = T_Code.Wit,
|
||||
Mandatorio = true,
|
||||
},
|
||||
new OperacaoModulosMandatoriosModel()
|
||||
{
|
||||
Dispositivo = T_Code.Pzm,
|
||||
Mandatorio = true,
|
||||
}
|
||||
};
|
||||
OperacaoCarregar.ParametrosMandatorios = new List<OperacaoParametrosMandatoriosModel>()
|
||||
|
|
@ -883,11 +910,30 @@ namespace AgroBase.Models
|
|||
{
|
||||
if (DispSen != null && DispSen.Dados.Conectado)
|
||||
{
|
||||
DispSen.Dados.Sinaleiros.FirstOrDefault(x => x.ID == "LEDOP").Comportamento = Variaveis.ComportamentoPorStatus();
|
||||
DispSen.Dados.Sinaleiros.FirstOrDefault(x => x.ID == "LEDAT").Comportamento.statusLED = Modo == ModoOperacao.MapaGPS ? StatusLED.Aceso : StatusLED.Apagado;
|
||||
DispSen.Dados.Sinaleiros.FirstOrDefault(x => x.ID == "LEDMN").Comportamento.statusLED = Modo == ModoOperacao.Manual ? StatusLED.Aceso : StatusLED.Apagado;
|
||||
|
||||
DispSen.Dados.Sinaleiros.ForEach(x => DispSen.AdicionarMensagemFila(DispSen.Dados.Modulo_ID, x.ProtocoloComando(), true, false));
|
||||
var ledOP = DispSen.Dados.Sinaleiros.FirstOrDefault(x => x.ID == "LEDOP");
|
||||
var ledAT = DispSen.Dados.Sinaleiros.FirstOrDefault(x => x.ID == "LEDAT");
|
||||
var ledMN = DispSen.Dados.Sinaleiros.FirstOrDefault(x => x.ID == "LEDMN");
|
||||
|
||||
var comportamento = Variaveis.ComportamentoPorStatus();
|
||||
if (ledOP.Comportamento != comportamento)
|
||||
{
|
||||
ledOP.Comportamento = comportamento;
|
||||
DispSen.AdicionarMensagemFila(DispSen.Dados.Modulo_ID, ledOP.ProtocoloComando(), true, false);
|
||||
}
|
||||
|
||||
var statusLedAt = Modo == ModoOperacao.MapaGPS ? StatusLED.Aceso : StatusLED.Apagado;
|
||||
if (ledAT.Comportamento.statusLED != statusLedAt)
|
||||
{
|
||||
ledAT.Comportamento.statusLED = statusLedAt;
|
||||
DispSen.AdicionarMensagemFila(DispSen.Dados.Modulo_ID, ledAT.ProtocoloComando(), true, false);
|
||||
}
|
||||
|
||||
var statusLedMn = Modo == ModoOperacao.Manual ? StatusLED.Aceso : StatusLED.Apagado;
|
||||
if (ledMN.Comportamento.statusLED != statusLedMn)
|
||||
{
|
||||
ledMN.Comportamento.statusLED = statusLedMn;
|
||||
DispSen.AdicionarMensagemFila(DispSen.Dados.Modulo_ID, ledMN.ProtocoloComando(), true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -627,7 +627,7 @@ namespace AgroBase.Models
|
|||
if (Adireita && !Aesquerda)
|
||||
{
|
||||
//return DistanciaInicial + SonarModel.MargemSegurancaDesvio;
|
||||
double deslocamento = (VariaveisEquipamento.Largura / 2) - DistanciaFinal + SonarModel.MargemSegurancaDesvio;
|
||||
double deslocamento = VariaveisEquipamento.LarguraDireita - DistanciaFinal + SonarModel.MargemSegurancaDesvio;
|
||||
if (deslocamento < 0)
|
||||
{
|
||||
deslocamento = 0;
|
||||
|
|
@ -637,7 +637,7 @@ namespace AgroBase.Models
|
|||
else if (Aesquerda && !Adireita)
|
||||
{
|
||||
//return DistanciaFinal + SonarModel.MargemSegurancaDesvio + (VariaveisEquipamento.Largura / 2);
|
||||
double deslocamento = (VariaveisEquipamento.Largura / 2) + DistanciaFinal + SonarModel.MargemSegurancaDesvio;
|
||||
double deslocamento = VariaveisEquipamento.LarguraEsquerda + DistanciaFinal + SonarModel.MargemSegurancaDesvio;
|
||||
if (deslocamento < 0)
|
||||
{
|
||||
deslocamento = 0;
|
||||
|
|
@ -646,7 +646,7 @@ namespace AgroBase.Models
|
|||
}
|
||||
else if (Adireita && Aesquerda)
|
||||
{
|
||||
double deslocamento = (VariaveisEquipamento.Largura / 2) + DistanciaFinal + SonarModel.MargemSegurancaDesvio;
|
||||
double deslocamento = ((VariaveisEquipamento.LarguraEsquerda + VariaveisEquipamento.LarguraDireita) / 2) + DistanciaFinal + SonarModel.MargemSegurancaDesvio;
|
||||
if (deslocamento < 0)
|
||||
{
|
||||
deslocamento = 0;
|
||||
|
|
@ -666,7 +666,7 @@ namespace AgroBase.Models
|
|||
if (Adireita && !Aesquerda)
|
||||
{
|
||||
//return DistanciaInicial + SonarModel.MargemSegurancaDesvio + (VariaveisEquipamento.Largura / 2);
|
||||
double deslocamento = (VariaveisEquipamento.Largura / 2) + DistanciaInicial + SonarModel.MargemSegurancaDesvio;
|
||||
double deslocamento = VariaveisEquipamento.LarguraDireita + DistanciaInicial + SonarModel.MargemSegurancaDesvio;
|
||||
if(deslocamento < 0)
|
||||
{
|
||||
deslocamento = 0;
|
||||
|
|
@ -676,7 +676,7 @@ namespace AgroBase.Models
|
|||
else if (Aesquerda && !Adireita)
|
||||
{
|
||||
//return DistanciaFinal + SonarModel.MargemSegurancaDesvio;
|
||||
double deslocamento = (VariaveisEquipamento.Largura / 2) - DistanciaInicial + SonarModel.MargemSegurancaDesvio;
|
||||
double deslocamento = VariaveisEquipamento.LarguraEsquerda - DistanciaInicial + SonarModel.MargemSegurancaDesvio;
|
||||
if (deslocamento < 0)
|
||||
{
|
||||
deslocamento = 0;
|
||||
|
|
@ -685,7 +685,7 @@ namespace AgroBase.Models
|
|||
}
|
||||
else if (Adireita && Aesquerda)
|
||||
{
|
||||
double deslocamento = (VariaveisEquipamento.Largura / 2) + DistanciaInicial + SonarModel.MargemSegurancaDesvio;
|
||||
double deslocamento = ((VariaveisEquipamento.LarguraEsquerda + VariaveisEquipamento.LarguraDireita) / 2) + DistanciaInicial + SonarModel.MargemSegurancaDesvio;
|
||||
if (deslocamento < 0)
|
||||
{
|
||||
deslocamento = 0;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ using System.Threading.Tasks;
|
|||
using System.Windows.Forms;
|
||||
using static AgroBase.Models.Enuns;
|
||||
using System.Drawing.Drawing2D;
|
||||
using Microsoft.Win32;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AgroBase.Models
|
||||
{
|
||||
|
|
@ -116,9 +118,11 @@ namespace AgroBase.Models
|
|||
|
||||
public static class VariaveisEquipamento
|
||||
{
|
||||
public static double Largura { get; } = 80;
|
||||
public static double LarguraEsquerda { get; } = 40;
|
||||
public static double LarguraDireita { get; } = 40;
|
||||
public static double DiametroRoda { get; set; } = 0.3556;
|
||||
public static double BateriaMax { get; set; } = 20;
|
||||
public static double ReducaoDirecional { get; set; } = 20.0;
|
||||
public static LoRaParametrosModel ComunicacaoLoRaBaseConfig { get; set; } = new LoRaParametrosModel()
|
||||
{
|
||||
address = 0x01,
|
||||
|
|
@ -135,6 +139,18 @@ namespace AgroBase.Models
|
|||
|
||||
public static class FuncoesGlobais
|
||||
{
|
||||
public static void AddApplicationToStartup()
|
||||
{
|
||||
string appName = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyTitleAttribute>()?.Title ?? "DefaultAppName";
|
||||
string appPath = Application.ExecutablePath;
|
||||
|
||||
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
|
||||
if (registryKey.GetValue(appName) == null)
|
||||
{
|
||||
registryKey.SetValue(appName, appPath);
|
||||
}
|
||||
}
|
||||
|
||||
public static string TimestampToDate(double timestamp, string Formatacao = "HH:mm:ss.fff")
|
||||
{
|
||||
// Converta o timestamp Unix para DateTime
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace AgroBase.Comum
|
|||
public string _Nome { get; set; }
|
||||
public string _Descricao { get; set; }
|
||||
public DateTime _CriadoEm { get; set; }
|
||||
public SerialPort _Porta { get; set; }
|
||||
public SerialPort _Porta { get; set; } = null;
|
||||
public GroupBox gpbItem { get; set; }
|
||||
public ComboBox cmbPorta { get; set; }
|
||||
public ComboBox cmbBaudRate { get; set; }
|
||||
|
|
@ -85,7 +85,7 @@ namespace AgroBase.Comum
|
|||
if (!cmbPorta.Items.Contains(DispositivosTipo[i].PortaCOM))
|
||||
{
|
||||
string PortaCom = DispositivosTipo[i].PortaCOM;
|
||||
SerialPort _Porta = new SerialPort() { PortName = PortaCom };
|
||||
var _Porta = new SerialPort() { PortName = PortaCom, BaudRate = 115200 };
|
||||
try
|
||||
{
|
||||
_Porta.Open();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
using AgroBase.Models;
|
||||
using CefSharp.DevTools.Page;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using SharpDX.DirectInput;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
|
|
@ -28,13 +31,29 @@ namespace AgroBase.Services
|
|||
|
||||
foreach (var Modulo in Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos)
|
||||
{
|
||||
try
|
||||
{
|
||||
Addr = Convert.ToByte(Modulo.DirMotor.Endereco, 16);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Erro ao definir endereco");
|
||||
}
|
||||
|
||||
if (DadosLeitura.Any(x => x.Endereco == Addr && x.Iniciado))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
DataSended = Convert.ToByte("43");
|
||||
|
||||
await SendRelevantData(QueryCommand[DataSended], Modulo.DirMotor.Endereco);
|
||||
await SendRelevantData(QueryCommand[DataSended]);
|
||||
await Task.Delay(500);
|
||||
//ProcessarDadosRecebidos();
|
||||
|
||||
Modulo.DirMotor.DadosDriver.Iniciado = !string.IsNullOrEmpty(HV) && !string.IsNullOrEmpty(FV);
|
||||
if (!DadosLeitura.Any(x => x.Endereco == Addr))
|
||||
{
|
||||
DadosLeitura.Add(new MKS057DModel() { Endereco = Addr });
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(oldHV) && !string.IsNullOrEmpty(HV))
|
||||
{
|
||||
|
|
@ -51,7 +70,7 @@ namespace AgroBase.Services
|
|||
HV = oldHV;
|
||||
FV = oldFV;
|
||||
|
||||
Iniciado = !string.IsNullOrEmpty(HV) && !string.IsNullOrEmpty(FV);
|
||||
Iniciado = DadosLeitura.Any(x => x.Iniciado);
|
||||
|
||||
if (Iniciado)
|
||||
{
|
||||
|
|
@ -240,20 +259,34 @@ namespace AgroBase.Services
|
|||
public static string _VelocidadeRetornoOrigem { get; set; } = "2";
|
||||
public static string _TipoLimiteZero { get; set; } = "Definir";
|
||||
|
||||
public static string _Velocidade { get; set; } = "600";
|
||||
public static ModosControle _ModoControle { get; set; } = ModosControle.AnguloAbsoluto;
|
||||
public static Sentido _Sentido { get; set; } = Sentido.Parado;
|
||||
public static string _Angulo { get; set; } = "0";
|
||||
public static Dictionary<byte, string> _Velocidade { get; set; } = new Dictionary<byte, string>();
|
||||
public static Dictionary<byte, ModosControle> _ModoControle { get; set; } = new Dictionary<byte, ModosControle>();
|
||||
public static Dictionary<byte, Sentido> _Sentido { get; set; } = new Dictionary<byte, Sentido>();
|
||||
public static Dictionary<byte, string> _Angulo { get; set; } = new Dictionary<byte, string>();
|
||||
|
||||
#endregion
|
||||
|
||||
public static MKS057DModel DadosLeitura = new MKS057DModel();
|
||||
public static List<MKS057DModel> DadosLeitura = new List<MKS057DModel>();
|
||||
public static bool EnvioLiberado = true;
|
||||
public static bool FilaEmEspera = false;
|
||||
public static bool Respondido = false;
|
||||
|
||||
|
||||
|
||||
public static async Task EnviarComandoRequisicao(string Endereco)
|
||||
{
|
||||
await EnviarComandoControle(
|
||||
new MKS057ComandoModel()
|
||||
{
|
||||
Get = true,
|
||||
Comando = Convert.ToByte("1"),
|
||||
Endereco = Endereco,
|
||||
Angulo = -1,
|
||||
AguardaResposta = true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static async Task EnviarComandoControle(MKS057ComandoModel Comando)
|
||||
{
|
||||
while (!EnvioLiberado)
|
||||
|
|
@ -266,13 +299,43 @@ namespace AgroBase.Services
|
|||
FilaEmEspera = false;
|
||||
Respondido = false;
|
||||
|
||||
_Angulo = ConverterAnguloParaValor(Comando.Angulo).ToString();
|
||||
_Velocidade = Comando.Velocidade.ToString();
|
||||
_ModoControle = Comando.ModoControle;
|
||||
_Sentido = Comando._Sentido;
|
||||
try
|
||||
{
|
||||
Addr = Convert.ToByte(Comando.Endereco, 16);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Erro ao definir endereco");
|
||||
}
|
||||
|
||||
if (!Comando.Get)
|
||||
{
|
||||
if (!_Angulo.ContainsKey(Addr))
|
||||
{
|
||||
_Angulo.Add(Addr, "0");
|
||||
}
|
||||
if (!_Velocidade.ContainsKey(Addr))
|
||||
{
|
||||
_Velocidade.Add(Addr, "0");
|
||||
}
|
||||
if (!_ModoControle.ContainsKey(Addr))
|
||||
{
|
||||
_ModoControle.Add(Addr, Comando.ModoControle);
|
||||
}
|
||||
if (!_Sentido.ContainsKey(Addr))
|
||||
{
|
||||
_Sentido.Add(Addr, Comando._Sentido);
|
||||
}
|
||||
|
||||
_Angulo[Addr] = ConverterAnguloParaValor(Comando.Angulo).ToString();
|
||||
_Velocidade[Addr] = Comando.Velocidade.ToString();
|
||||
_ModoControle[Addr] = Comando.ModoControle;
|
||||
_Sentido[Addr] = Comando._Sentido;
|
||||
}
|
||||
|
||||
DataSended = Comando.Comando;
|
||||
|
||||
await SendRelevantData(QueryCommand[DataSended], Comando.Endereco);
|
||||
await SendRelevantData(QueryCommand[DataSended]);
|
||||
|
||||
DateTime Inicio = DateTime.Now;
|
||||
|
||||
|
|
@ -289,23 +352,45 @@ namespace AgroBase.Services
|
|||
public static int ConverterAnguloParaValor(double _angulo)
|
||||
{
|
||||
int val = 0;
|
||||
double reducao = 20.0;
|
||||
|
||||
|
||||
if (_ModoControle == ModosControle.Pulsos)
|
||||
if (_ModoControle[Addr] == ModosControle.Pulsos)
|
||||
{
|
||||
int.TryParse(_MStep, out int mstep);
|
||||
double pulsos = mstep * 200;
|
||||
double relacao = (pulsos * reducao) / 360.0;
|
||||
double relacao = (pulsos * VariaveisEquipamento.ReducaoDirecional) / 360.0;
|
||||
val = Convert.ToInt32(_angulo * relacao);
|
||||
}
|
||||
else
|
||||
{
|
||||
val = Convert.ToInt32(_angulo * reducao);
|
||||
val = Convert.ToInt32(_angulo * VariaveisEquipamento.ReducaoDirecional);
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
private static double ConverterPulsosParaAngulo(int pulsos)
|
||||
{
|
||||
double relacao = (pulsos * VariaveisEquipamento.ReducaoDirecional) / 360.0;
|
||||
double angulo = pulsos * relacao;
|
||||
|
||||
return angulo;
|
||||
}
|
||||
|
||||
private static void DefinirDadosModulo(MKS057DModel leitura)
|
||||
{
|
||||
if (Variaveis.OperacaoEmAndamento.DispMvd != null)
|
||||
{
|
||||
var Modulo = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.FirstOrDefault(x => Convert.ToByte(x.DirMotor.Endereco, 16) == Addr);
|
||||
if (Modulo != null)
|
||||
{
|
||||
Modulo.DirMotor.Angulo = ConverterPulsosParaAngulo(leitura.NumeroPulsos);
|
||||
Modulo.DirMotor.Sentido = leitura.Direcao;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region METODOS PRINCIPAIS
|
||||
|
||||
private static void WriteByteToSerialPort(byte[] data, byte start, byte length)
|
||||
|
|
@ -335,7 +420,7 @@ namespace AgroBase.Services
|
|||
{
|
||||
SerialBuffer_RX = new byte[11] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // SerialBuffer_RX[0] Cabeçalho do quadro [1] Endereço do escravo [2] Número da instrução
|
||||
Data_Number = _PortaMKS.BytesToRead; // Número de bytes recebidos
|
||||
if (_PortaMKS.BytesToRead > 0)
|
||||
if (_PortaMKS.BytesToRead > 0 && _PortaMKS.BytesToRead <= SerialBuffer_RX.Length)
|
||||
{
|
||||
for (int a = 0; a <= Data_Number - 1; a++)
|
||||
{
|
||||
|
|
@ -345,7 +430,7 @@ namespace AgroBase.Services
|
|||
}
|
||||
}
|
||||
|
||||
private static async Task SendRelevantData(int data, string slaveAddress) // Verifica o tipo de dados e envia
|
||||
private static async Task SendRelevantData(int data) // Verifica o tipo de dados e envia
|
||||
{
|
||||
ushort SpeedText;
|
||||
ushort SpeedText2;
|
||||
|
|
@ -365,14 +450,6 @@ namespace AgroBase.Services
|
|||
byte HomeTrig = 0x00, HomeDir = 0x00, EndLimit = 0x00;
|
||||
byte Mode_0 = 0x00, Set_0 = 0x00, Speed_0 = 0x00, Dir_0 = 0x00;
|
||||
|
||||
try
|
||||
{
|
||||
Addr = Convert.ToByte(slaveAddress, 16);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Erro ao definir endereco");
|
||||
}
|
||||
if (Addr <= 0xff && Addr >= 0x00)
|
||||
{
|
||||
if (DataSended < 6 || DataSended == 37 || DataSended == 39 || DataSended == 40 || DataSended == 43 || DataSended == 46)
|
||||
|
|
@ -498,25 +575,25 @@ namespace AgroBase.Services
|
|||
{
|
||||
try
|
||||
{
|
||||
SpeedText2 = Convert.ToUInt16(_Velocidade, 10);
|
||||
SpeedText2 = Convert.ToUInt16(_Velocidade[Addr], 10);
|
||||
Speed_2 = BitConverter.GetBytes(SpeedText2);
|
||||
if (_ModoControle == ModosControle.Pulsos) // Se o controle for através de pulsos
|
||||
if (_ModoControle[Addr] == ModosControle.Pulsos) // Se o controle for através de pulsos
|
||||
{
|
||||
try
|
||||
{
|
||||
PulseText = Convert.ToUInt32(_Angulo, 10);
|
||||
PulseText = Convert.ToUInt32(_Angulo[Addr], 10);
|
||||
Pulse = BitConverter.GetBytes(PulseText);
|
||||
if (SpeedText2 <= 3000 && SpeedText2 >= 1)
|
||||
{
|
||||
if (PulseText <= 4294967295 && PulseText >= 1)
|
||||
{
|
||||
if (_Sentido == Sentido.Antihorario)
|
||||
if (_Sentido[Addr] == Sentido.Antihorario)
|
||||
{
|
||||
//Speed2 = Convert.ToByte(SpeedText2 | RWD);
|
||||
Speed_2[1] |= RWD;
|
||||
//Pulse = Convert.ToByte(PulseText);
|
||||
}
|
||||
else if (_Sentido == Sentido.Horario)
|
||||
else if (_Sentido[Addr] == Sentido.Horario)
|
||||
{
|
||||
//Speed2 = Convert.ToByte(SpeedText2 | FWD);
|
||||
Speed_2[1] |= FWD;
|
||||
|
|
@ -541,29 +618,29 @@ namespace AgroBase.Services
|
|||
Console.WriteLine("Erro ao definir controle Pulses");
|
||||
}
|
||||
}
|
||||
else if (_ModoControle == ModosControle.AnguloRelativo)
|
||||
else if (_ModoControle[Addr] == ModosControle.AnguloRelativo)
|
||||
{
|
||||
DataSended = 44;
|
||||
data = 0xF4;
|
||||
try
|
||||
{
|
||||
Text_BUF = _Angulo;
|
||||
Text_BUF = _Angulo[Addr];
|
||||
if (Text_BUF.Length > 1)
|
||||
{
|
||||
if (Text_BUF[0] == '0' && (Text_BUF[1] == 'x' || Text_BUF[1] == 'X'))
|
||||
{
|
||||
RelAxisText = Convert.ToInt32(_Angulo, 16);
|
||||
RelAxisText = Convert.ToInt32(_Angulo[Addr], 16);
|
||||
RelAxis = BitConverter.GetBytes(RelAxisText);
|
||||
}
|
||||
else
|
||||
{
|
||||
RelAxisText = Convert.ToInt32(_Angulo, 10);
|
||||
RelAxisText = Convert.ToInt32(_Angulo[Addr], 10);
|
||||
RelAxis = BitConverter.GetBytes(RelAxisText * 16384 / 360);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RelAxisText = Convert.ToInt32(_Angulo, 10);
|
||||
RelAxisText = Convert.ToInt32(_Angulo[Addr], 10);
|
||||
RelAxis = BitConverter.GetBytes(RelAxisText * 16384 / 360);
|
||||
}
|
||||
if (SpeedText2 <= 3000 && SpeedText2 >= 1)
|
||||
|
|
@ -583,29 +660,29 @@ namespace AgroBase.Services
|
|||
Console.WriteLine("Erro ao definir controle RelAxis");
|
||||
}
|
||||
}
|
||||
else if (_ModoControle == ModosControle.AnguloAbsoluto)
|
||||
else if (_ModoControle[Addr] == ModosControle.AnguloAbsoluto)
|
||||
{
|
||||
DataSended = 45;
|
||||
data = 0xF5;
|
||||
try
|
||||
{
|
||||
Text_BUF = _Angulo;
|
||||
Text_BUF = _Angulo[Addr];
|
||||
if (Text_BUF.Length > 1)
|
||||
{
|
||||
if (Text_BUF[0] == '0' && (Text_BUF[1] == 'x' || Text_BUF[1] == 'X'))
|
||||
{
|
||||
AbsAxisText = Convert.ToInt32(_Angulo, 16);
|
||||
AbsAxisText = Convert.ToInt32(_Angulo[Addr], 16);
|
||||
AbsAxis = BitConverter.GetBytes(AbsAxisText);
|
||||
}
|
||||
else
|
||||
{
|
||||
AbsAxisText = Convert.ToInt32(_Angulo, 10);
|
||||
AbsAxisText = Convert.ToInt32(_Angulo[Addr], 10);
|
||||
AbsAxis = BitConverter.GetBytes(AbsAxisText * 16384 / 360);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AbsAxisText = Convert.ToInt32(_Angulo, 10);
|
||||
AbsAxisText = Convert.ToInt32(_Angulo[Addr], 10);
|
||||
AbsAxis = BitConverter.GetBytes(AbsAxisText * 16384 / 360);
|
||||
}
|
||||
if (SpeedText2 <= 3000 && SpeedText2 >= 1)
|
||||
|
|
@ -1143,15 +1220,15 @@ namespace AgroBase.Services
|
|||
|
||||
if (DataSended == 38) //(38 Parar modo de controle de posição do motor)
|
||||
{
|
||||
if (_ModoControle == ModosControle.Pulsos)
|
||||
if (_ModoControle[Addr] == ModosControle.Pulsos)
|
||||
{
|
||||
|
||||
}
|
||||
else if (_ModoControle == ModosControle.AnguloRelativo)
|
||||
else if (_ModoControle[Addr] == ModosControle.AnguloRelativo)
|
||||
{
|
||||
data = 0xF4;
|
||||
}
|
||||
else if (_ModoControle == ModosControle.AnguloAbsoluto)
|
||||
else if (_ModoControle[Addr] == ModosControle.AnguloAbsoluto)
|
||||
{
|
||||
data = 0xF5;
|
||||
}
|
||||
|
|
@ -1294,6 +1371,17 @@ namespace AgroBase.Services
|
|||
{
|
||||
rxDisplay(); //计算rCHK
|
||||
|
||||
byte addr = SerialBuffer_RX[1];
|
||||
MKS057DModel leitura = DadosLeitura.FirstOrDefault(x => x.Endereco == addr);
|
||||
if (leitura == null)
|
||||
{
|
||||
leitura = new MKS057DModel()
|
||||
{
|
||||
Endereco = addr,
|
||||
};
|
||||
DadosLeitura.Add(leitura);
|
||||
}
|
||||
|
||||
if ((byte)rCHK == SerialBuffer_RX[Data_Number - 1])
|
||||
{
|
||||
switch (SerialBuffer_RX[2])
|
||||
|
|
@ -1301,18 +1389,18 @@ namespace AgroBase.Services
|
|||
case 0x30: // 0 Encoder de valor em modo posicional FB + 01 + 30 + int32_t valor posicional + uint16_t valor do encoder + CRC
|
||||
if (ModoLeitura == "Hex") // Hexadecimal
|
||||
{
|
||||
DadosLeitura.ErroCarregado_Hex = "";
|
||||
leitura.ErroCarregado_Hex = "";
|
||||
|
||||
DadosLeitura.ErroCarregado_Hex += "0x";
|
||||
leitura.ErroCarregado_Hex += "0x";
|
||||
for (int a = 3; a < 9; a++)
|
||||
{
|
||||
str = Convert.ToString(SerialBuffer_RX[a], 16).ToUpper();
|
||||
DadosLeitura.ErroCarregado_Hex += str.Length == 1 ? "0" + str : str;
|
||||
leitura.ErroCarregado_Hex += str.Length == 1 ? "0" + str : str;
|
||||
}
|
||||
}
|
||||
else if (ModoLeitura == "Decimal") // Decimal
|
||||
{
|
||||
DadosLeitura.ErroCarregado = 0;
|
||||
leitura.ErroCarregado = 0;
|
||||
|
||||
word32 = "0";
|
||||
for (int a = 3; a < 7; a++)
|
||||
|
|
@ -1332,7 +1420,7 @@ namespace AgroBase.Services
|
|||
|
||||
str = Convert.ToString(data32 * 360 + data16 * 360 / 16384, 10);
|
||||
double.TryParse(str, out double val);
|
||||
DadosLeitura.ErroCarregado = val;
|
||||
leitura.ErroCarregado = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1343,18 +1431,18 @@ namespace AgroBase.Services
|
|||
case 0x33: // 1 Contagem acumulada de pulsos FB + 01 + 33 + int32_t contagem acumulada de pulsos + CRC
|
||||
if (ModoLeitura == "Hex") // Hexadecimal
|
||||
{
|
||||
DadosLeitura.NumeroPulsos_Hex = "";
|
||||
leitura.NumeroPulsos_Hex = "";
|
||||
|
||||
DadosLeitura.NumeroPulsos_Hex += "0x";
|
||||
leitura.NumeroPulsos_Hex += "0x";
|
||||
for (int a = 3; a < 7; a++)
|
||||
{
|
||||
str = Convert.ToString(SerialBuffer_RX[a], 16).ToUpper();
|
||||
DadosLeitura.NumeroPulsos_Hex += str.Length == 1 ? "0" + str : str;
|
||||
leitura.NumeroPulsos_Hex += str.Length == 1 ? "0" + str : str;
|
||||
}
|
||||
}
|
||||
else if (ModoLeitura == "Decimal") // Decimal
|
||||
{
|
||||
DadosLeitura.NumeroPulsos = 0;
|
||||
leitura.NumeroPulsos = 0;
|
||||
|
||||
word32 = "0";
|
||||
for (int a = 3; a < 7; a++)
|
||||
|
|
@ -1366,7 +1454,9 @@ namespace AgroBase.Services
|
|||
|
||||
str = Convert.ToString(data32, 10);
|
||||
int.TryParse(str, out int val);
|
||||
DadosLeitura.NumeroPulsos = val;
|
||||
leitura.NumeroPulsos = val;
|
||||
|
||||
DefinirDadosModulo(leitura);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1377,17 +1467,17 @@ namespace AgroBase.Services
|
|||
case 0x39: // 2 Erro de ângulo de posição FB + 01 + 39 + int32_t erro de ângulo de posição + CRC
|
||||
if (ModoLeitura == "Hex") // Hexadecimal
|
||||
{
|
||||
DadosLeitura.ErroAngulo_Hex = "";
|
||||
DadosLeitura.ErroAngulo_Hex += "0x";
|
||||
leitura.ErroAngulo_Hex = "";
|
||||
leitura.ErroAngulo_Hex += "0x";
|
||||
for (int a = 3; a < 7; a++)
|
||||
{
|
||||
str = Convert.ToString(SerialBuffer_RX[a], 16).ToUpper();
|
||||
DadosLeitura.ErroAngulo_Hex += str.Length == 1 ? "0" + str : str;
|
||||
leitura.ErroAngulo_Hex += str.Length == 1 ? "0" + str : str;
|
||||
}
|
||||
}
|
||||
else if (ModoLeitura == "Decimal") // Decimal
|
||||
{
|
||||
DadosLeitura.ErroAngulo = 0;
|
||||
leitura.ErroAngulo = 0;
|
||||
word32 = "0";
|
||||
for (int a = 3; a < 7; a++)
|
||||
{
|
||||
|
|
@ -1398,7 +1488,7 @@ namespace AgroBase.Services
|
|||
|
||||
str = Convert.ToString(data32, 10);
|
||||
double.TryParse(str, out double val);
|
||||
DadosLeitura.ErroAngulo = val;
|
||||
leitura.ErroAngulo = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1409,8 +1499,8 @@ namespace AgroBase.Services
|
|||
case 0x3A: // 3 Estado de habilitação da placa de acionamento FB + 01 + 3A + uint8_t estado de habilitação do loop fechado da placa de acionamento + CRC
|
||||
// Habilitado: 01
|
||||
// Desabilitado: 00
|
||||
DadosLeitura.StatusDriver = SerialBuffer_RX[3] == EN_STATE_ON ? Estado.Ligado : SerialBuffer_RX[3] == EN_STATE_OFF ? Estado.Desligado : Estado.Reset;
|
||||
if (DadosLeitura.StatusDriver == Estado.Reset)
|
||||
leitura.StatusDriver = SerialBuffer_RX[3] == EN_STATE_ON ? Estado.Ligado : SerialBuffer_RX[3] == EN_STATE_OFF ? Estado.Desligado : Estado.Reset;
|
||||
if (leitura.StatusDriver == Estado.Reset)
|
||||
{
|
||||
MessageBox.Show("Erro ao ler dados de driver habilitado"); // Erro de dados
|
||||
}
|
||||
|
|
@ -1422,15 +1512,15 @@ namespace AgroBase.Services
|
|||
// Falha ao retornar para a posição inicial: 02
|
||||
if (SerialBuffer_RX[3] == 0x00)
|
||||
{
|
||||
DadosLeitura.StatusModoLimiteZero = StatusComando.Retornando; // Texto1 de retorno para zero
|
||||
leitura.StatusModoLimiteZero = StatusComando.Retornando; // Texto1 de retorno para zero
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01)
|
||||
{
|
||||
DadosLeitura.StatusModoLimiteZero = StatusComando.Sucesso; // Texto2 de retorno para zero
|
||||
leitura.StatusModoLimiteZero = StatusComando.Sucesso; // Texto2 de retorno para zero
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x02)
|
||||
{
|
||||
DadosLeitura.StatusModoLimiteZero = StatusComando.Falha; // Texto3 de retorno para zero
|
||||
leitura.StatusModoLimiteZero = StatusComando.Falha; // Texto3 de retorno para zero
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1439,15 +1529,15 @@ namespace AgroBase.Services
|
|||
// Não bloqueado: 00
|
||||
if (SerialBuffer_RX[3] == 0x01)
|
||||
{
|
||||
DadosLeitura.StatusTravaMotor = Estado.Ligado; // Texto1 de bloqueio
|
||||
leitura.StatusTravaMotor = Estado.Ligado; // Texto1 de bloqueio
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x00)
|
||||
{
|
||||
DadosLeitura.StatusTravaMotor = Estado.Desligado; // Texto2 de bloqueio
|
||||
leitura.StatusTravaMotor = Estado.Desligado; // Texto2 de bloqueio
|
||||
}
|
||||
else
|
||||
{
|
||||
DadosLeitura.StatusTravaMotor = Estado.Reset;
|
||||
leitura.StatusTravaMotor = Estado.Reset;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1456,11 +1546,11 @@ namespace AgroBase.Services
|
|||
// Falha no desbloqueio: retorna FB 01 3D 00 39
|
||||
if (SerialBuffer_RX[3] == 0x01)
|
||||
{
|
||||
DadosLeitura.StatusBloqueioMotor = StatusComando.Sucesso; // Texto1 de bloqueio
|
||||
leitura.StatusBloqueioMotor = StatusComando.Sucesso; // Texto1 de bloqueio
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x00)
|
||||
{
|
||||
DadosLeitura.StatusBloqueioMotor = StatusComando.Falha; // Texto2 de bloqueio
|
||||
leitura.StatusBloqueioMotor = StatusComando.Falha; // Texto2 de bloqueio
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1469,48 +1559,52 @@ namespace AgroBase.Services
|
|||
{
|
||||
if (SerialBuffer_RX[3] == 0x01) // Sucesso
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Completo; // Texto1 de movimento
|
||||
leitura.StatusMovimentoMotor = StatusComando.Completo; // Texto1 de movimento
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x00) // Falha
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha; // Texto3 de movimento
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha; // Texto3 de movimento
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Erro; // Texto1 de erro de comunicação
|
||||
leitura.StatusMovimentoMotor = StatusComando.Erro; // Texto1 de erro de comunicação
|
||||
break;
|
||||
}
|
||||
double.TryParse(_Velocidade, out double vel);
|
||||
double.TryParse(_Velocidade[addr], out double vel);
|
||||
double.TryParse(Start_ACC[0].ToString(), out double acl);
|
||||
DadosLeitura.Direcao = _Sentido;
|
||||
DadosLeitura.Velocidade = vel;
|
||||
DadosLeitura.Aceleracao = acl;
|
||||
leitura.Direcao = _Sentido[addr];
|
||||
leitura.Velocidade = vel;
|
||||
leitura.Aceleracao = acl;
|
||||
|
||||
DefinirDadosModulo(leitura);
|
||||
}
|
||||
else if (DataSended == 9)
|
||||
{
|
||||
if (SerialBuffer_RX[3] == 0x02) // Concluído
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Sucesso; // Texto2 de parada
|
||||
leitura.StatusMovimentoMotor = StatusComando.Sucesso; // Texto2 de parada
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01) // Iniciado
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Parando; // Texto4 de parada
|
||||
leitura.StatusMovimentoMotor = StatusComando.Parando; // Texto4 de parada
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x00) // Falha
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha; // Texto3 de parada
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha; // Texto3 de parada
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Erro; // Texto1 de erro de comunicação
|
||||
leitura.StatusMovimentoMotor = StatusComando.Erro; // Texto1 de erro de comunicação
|
||||
break;
|
||||
}
|
||||
double.TryParse(Stop_ACC[0].ToString(), out double acl);
|
||||
DadosLeitura.Direcao = Sentido.Parado; // Texto3 de direção
|
||||
DadosLeitura.Velocidade = 0; // Velocidade alvo zero
|
||||
DadosLeitura.Aceleracao = acl; // Aceleração alvo de parada
|
||||
leitura.Direcao = Sentido.Parado; // Texto3 de direção
|
||||
leitura.Velocidade = 0; // Velocidade alvo zero
|
||||
leitura.Aceleracao = acl; // Aceleração alvo de parada
|
||||
|
||||
DefinirDadosModulo(leitura);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1519,54 +1613,58 @@ namespace AgroBase.Services
|
|||
{
|
||||
if (SerialBuffer_RX[3] == 0x02) // Concluído
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Sucesso; // Texto2 de movimento
|
||||
leitura.StatusMovimentoMotor = StatusComando.Sucesso; // Texto2 de movimento
|
||||
break;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01) // Iniciado
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Movendo; // Texto4 de movimento
|
||||
leitura.StatusMovimentoMotor = StatusComando.Movendo; // Texto4 de movimento
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x00) // Falha
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha; // Texto3 de movimento
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha; // Texto3 de movimento
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Erro; // Texto1 de erro de comunicação
|
||||
leitura.StatusMovimentoMotor = StatusComando.Erro; // Texto1 de erro de comunicação
|
||||
break;
|
||||
}
|
||||
DadosLeitura.Direcao = _Sentido;
|
||||
double.TryParse(_Velocidade, out double vel);
|
||||
leitura.Direcao = _Sentido[addr];
|
||||
double.TryParse(_Velocidade[addr], out double vel);
|
||||
double.TryParse(Start_ACC[0].ToString(), out double acl);
|
||||
DadosLeitura.Velocidade = vel; // Velocidade alvo
|
||||
DadosLeitura.Aceleracao = acl; // Aceleração alvo
|
||||
leitura.Velocidade = vel; // Velocidade alvo
|
||||
leitura.Aceleracao = acl; // Aceleração alvo
|
||||
|
||||
DefinirDadosModulo(leitura);
|
||||
}
|
||||
else if (DataSended == 38)
|
||||
{
|
||||
if (SerialBuffer_RX[3] == 0x02) // Concluído
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Sucesso; // Texto2 de parada
|
||||
leitura.StatusMovimentoMotor = StatusComando.Sucesso; // Texto2 de parada
|
||||
break;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01) // Iniciado
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Parando; // Texto4 de parada
|
||||
leitura.StatusMovimentoMotor = StatusComando.Parando; // Texto4 de parada
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x00) // Falha
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha; // Texto3 de parada
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha; // Texto3 de parada
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Erro; // Texto1 de erro de comunicação
|
||||
leitura.StatusMovimentoMotor = StatusComando.Erro; // Texto1 de erro de comunicação
|
||||
break;
|
||||
}
|
||||
DadosLeitura.Direcao = Sentido.Parado; // Texto3 de direção
|
||||
DadosLeitura.Velocidade = 0; // Velocidade alvo zero
|
||||
leitura.Direcao = Sentido.Parado; // Texto3 de direção
|
||||
leitura.Velocidade = 0; // Velocidade alvo zero
|
||||
double.TryParse(Stop_ACC[0].ToString(), out double acl);
|
||||
DadosLeitura.Aceleracao = acl; // Aceleração alvo de parada
|
||||
leitura.Aceleracao = acl; // Aceleração alvo de parada
|
||||
|
||||
DefinirDadosModulo(leitura);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1575,53 +1673,55 @@ namespace AgroBase.Services
|
|||
{
|
||||
if (SerialBuffer_RX[3] == 0x02) // Completo
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
break;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01) // Iniciar
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Movendo;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Movendo;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x00) // Falha
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Erro;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Erro;
|
||||
break;
|
||||
}
|
||||
double.TryParse(_Velocidade, out double vel);
|
||||
double.TryParse(_Velocidade[addr], out double vel);
|
||||
double.TryParse(Start_ACC[0].ToString(), out double acl);
|
||||
DadosLeitura.Velocidade = vel; // Velocidade alvo
|
||||
DadosLeitura.Aceleracao = acl; // Aceleração alvo
|
||||
leitura.Velocidade = vel; // Velocidade alvo
|
||||
leitura.Aceleracao = acl; // Aceleração alvo
|
||||
}
|
||||
else if (DataSended == 38)
|
||||
{
|
||||
if (SerialBuffer_RX[3] == 0x02) // Completo
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
break;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01) // Iniciar
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Parando;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Parando;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x00) // Falha
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Erro;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Erro;
|
||||
break;
|
||||
}
|
||||
double.TryParse(Start_ACC[0].ToString(), out double acl);
|
||||
DadosLeitura.Direcao = Sentido.Parado;
|
||||
DadosLeitura.Velocidade = 0;
|
||||
DadosLeitura.Aceleracao = acl;
|
||||
leitura.Direcao = Sentido.Parado;
|
||||
leitura.Velocidade = 0;
|
||||
leitura.Aceleracao = acl;
|
||||
|
||||
DefinirDadosModulo(leitura);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1630,72 +1730,74 @@ namespace AgroBase.Services
|
|||
{
|
||||
if (SerialBuffer_RX[3] == 0x02) // Completo
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
break;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01) // Iniciar
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Movendo;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Movendo;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x00) // Falha
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Erro;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Erro;
|
||||
break;
|
||||
}
|
||||
double.TryParse(_Velocidade, out double vel);
|
||||
double.TryParse(_Velocidade[addr], out double vel);
|
||||
double.TryParse(Start_ACC[0].ToString(), out double acl);
|
||||
DadosLeitura.Velocidade = vel; // Velocidade alvo
|
||||
DadosLeitura.Aceleracao = acl; // Aceleração alvo
|
||||
leitura.Velocidade = vel; // Velocidade alvo
|
||||
leitura.Aceleracao = acl; // Aceleração alvo
|
||||
}
|
||||
else if (DataSended == 38)
|
||||
{
|
||||
if (SerialBuffer_RX[3] == 0x02) // Completo
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
break;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01) // Iniciar
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Parando;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Parando;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x00) // Falha
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Erro;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Erro;
|
||||
break;
|
||||
}
|
||||
DadosLeitura.Direcao = Sentido.Parado;
|
||||
double.TryParse(_Velocidade, out double vel);
|
||||
leitura.Direcao = Sentido.Parado;
|
||||
double.TryParse(_Velocidade[addr], out double vel);
|
||||
double.TryParse(Start_ACC[0].ToString(), out double acl);
|
||||
DadosLeitura.Velocidade = vel; // Velocidade alvo
|
||||
DadosLeitura.Aceleracao = acl; // Aceleração alvo
|
||||
leitura.Velocidade = vel; // Velocidade alvo
|
||||
leitura.Aceleracao = acl; // Aceleração alvo
|
||||
|
||||
DefinirDadosModulo(leitura);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x31:// 39 Valor do Codificador Incremental FB + 01 + 31 + Valor do Codificador uint48_t + CRC
|
||||
if (ModoLeitura == "Hex") // Hexadecimal
|
||||
{
|
||||
DadosLeitura.ErroCarregado_Hex = "";
|
||||
leitura.ErroCarregado_Hex = "";
|
||||
|
||||
DadosLeitura.ErroCarregado_Hex += "0x";
|
||||
leitura.ErroCarregado_Hex += "0x";
|
||||
for (int a = 3; a < 9; a++)
|
||||
{
|
||||
str = Convert.ToString(SerialBuffer_RX[a], 16).ToUpper();
|
||||
DadosLeitura.ErroCarregado_Hex += str.Length == 1 ? "0" + str : str;
|
||||
leitura.ErroCarregado_Hex += str.Length == 1 ? "0" + str : str;
|
||||
}
|
||||
}
|
||||
else if (ModoLeitura == "Decimal") // Decimal
|
||||
{
|
||||
DadosLeitura.ErroCarregado = 0;
|
||||
leitura.ErroCarregado = 0;
|
||||
|
||||
word64 = "0";
|
||||
for (int a = 3; a < 9; a++)
|
||||
|
|
@ -1715,7 +1817,7 @@ namespace AgroBase.Services
|
|||
|
||||
str = Convert.ToString(data64 * 360 / 16384, 10);
|
||||
double.TryParse(str, out double val);
|
||||
DadosLeitura.ErroCarregado = val;
|
||||
leitura.ErroCarregado = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1726,17 +1828,17 @@ namespace AgroBase.Services
|
|||
case 0x32:// 40 Velocidade Atual do Motor
|
||||
if (ModoLeitura == "Hex") // Hexadecimal
|
||||
{
|
||||
DadosLeitura.RPM_Hex = "";
|
||||
DadosLeitura.RPM_Hex += "0x";
|
||||
leitura.RPM_Hex = "";
|
||||
leitura.RPM_Hex += "0x";
|
||||
for (int a = 3; a < 5; a++)
|
||||
{
|
||||
str = Convert.ToString(SerialBuffer_RX[a], 16).ToUpper();
|
||||
DadosLeitura.RPM_Hex += str.Length == 1 ? "0" + str : str;
|
||||
leitura.RPM_Hex += str.Length == 1 ? "0" + str : str;
|
||||
}
|
||||
}
|
||||
else if (ModoLeitura == "Decimal") // Decimal
|
||||
{
|
||||
DadosLeitura.RPM = 0;
|
||||
leitura.RPM = 0;
|
||||
word16 = "0";
|
||||
for (int a = 3; a < 5; a++)
|
||||
{
|
||||
|
|
@ -1746,7 +1848,7 @@ namespace AgroBase.Services
|
|||
data16 = Convert.ToInt16(word16, 16);
|
||||
str = Convert.ToString(data16, 10);
|
||||
double.TryParse(str, out double val);
|
||||
DadosLeitura.RPM = val;
|
||||
leitura.RPM = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1757,15 +1859,15 @@ namespace AgroBase.Services
|
|||
case 0x80:// 14 Calibrar Codificador
|
||||
if (SerialBuffer_RX[3] == 0x00)
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Calibrando;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Calibrando;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01)
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x02)
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1793,11 +1895,11 @@ namespace AgroBase.Services
|
|||
Temp1++;
|
||||
if (SerialBuffer_RX[3] == 0x00)
|
||||
{
|
||||
DadosLeitura.Mensagem = "Erro ao configurar: (" + Temp1 + ")";
|
||||
leitura.Mensagem = "Erro ao configurar: (" + Temp1 + ")";
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01)
|
||||
{
|
||||
DadosLeitura.Mensagem = "Sucesso ao configurar: (" + Temp1 + ")";
|
||||
leitura.Mensagem = "Sucesso ao configurar: (" + Temp1 + ")";
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
|
@ -1809,26 +1911,26 @@ namespace AgroBase.Services
|
|||
case 0x91:// 32 Reiniciar Limites
|
||||
if (SerialBuffer_RX[3] == 0x00)
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01)
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Retornando;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Retornando;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x02)
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x92:// 33 Reinicialização Direta
|
||||
if (SerialBuffer_RX[3] == 0x00)
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Falha;
|
||||
}
|
||||
else if (SerialBuffer_RX[3] == 0x01)
|
||||
{
|
||||
DadosLeitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
leitura.StatusMovimentoMotor = StatusComando.Sucesso;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -1843,7 +1945,7 @@ namespace AgroBase.Services
|
|||
}
|
||||
if (DataSended == 43)
|
||||
{
|
||||
if (Iniciado)
|
||||
if (leitura.Iniciado)
|
||||
{
|
||||
MessageBox.Show("Versão do hardware: " + HV + "\nVersão da firmware: " + FV, "Versão");
|
||||
}
|
||||
|
|
@ -1900,6 +2002,8 @@ namespace AgroBase.Services
|
|||
}
|
||||
}
|
||||
|
||||
leitura.Iniciado = true;
|
||||
|
||||
Respondido = true;
|
||||
}
|
||||
|
||||
|
|
@ -1926,6 +2030,8 @@ namespace AgroBase.Services
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using AgroBase.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
|
|
@ -19,6 +20,10 @@ namespace AgroBase.Services
|
|||
{
|
||||
get
|
||||
{
|
||||
if (!SerialService.DispositivosMapeados.Any(x => SerialService.DispositivosModbus.Contains(x.Dispositivo)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_PortaModbus != null && !_PortaModbus.IsOpen)
|
||||
{
|
||||
try
|
||||
|
|
@ -45,7 +50,7 @@ namespace AgroBase.Services
|
|||
|
||||
FilaEmEspera = false;
|
||||
|
||||
if (frmPrincipal.Fechando)
|
||||
if (frmInstancial.Fechando)
|
||||
{
|
||||
EnvioLiberado = true;
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ namespace AgroBase.Services
|
|||
|
||||
var comando = ComandoGetParametro(Parametros["AlarmeTensaoMaxima"]);
|
||||
EnviarComando(porta, comando);
|
||||
await Task.Delay(1000);
|
||||
var resposta = SerialService.VerificarRespostaPortasDesconhecidas(porta);
|
||||
var resposta = SerialService.LerDadosDaPortaSerial(porta, 7, 1000);
|
||||
//var resposta = SerialService.VerificarRespostaPortasDesconhecidas(porta);
|
||||
|
||||
ModbusService.Verificando = false;
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ namespace AgroBase.Services
|
|||
|
||||
byte[] resposta = SerialService.VerificarRespostaPortasDesconhecidas(ModbusService._PortaModbus);
|
||||
|
||||
Iniciado = DecifrarRespostaAquisicao(resposta) != null;
|
||||
DecifrarRespostaAquisicao(resposta);
|
||||
|
||||
ContadorCarga.AtualizarConsumo();
|
||||
|
||||
|
|
@ -167,10 +167,16 @@ namespace AgroBase.Services
|
|||
Variaveis.OperacaoEmAndamento.Sensoriamento.BateriaConsumida = ContadorCarga.PercentualConsumido;
|
||||
|
||||
|
||||
|
||||
await Task.Delay(TaxaAmostragem);
|
||||
|
||||
return await ReceberDados();
|
||||
if (ModbusService.Iniciado)
|
||||
{
|
||||
return await ReceberDados();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#region Comandos
|
||||
|
|
@ -359,7 +365,10 @@ namespace AgroBase.Services
|
|||
{
|
||||
var parametro_raw = "0x" + resposta[3].ToString("X") + resposta[4].ToString("X");
|
||||
double Valor = Convert.ToInt16(parametro_raw, 16) * 0.01;
|
||||
MessageBox.Show("Valor do parâmetro: " + Valor);
|
||||
if (Iniciado)
|
||||
{
|
||||
MessageBox.Show("Valor do parâmetro: " + Valor);
|
||||
}
|
||||
}
|
||||
else if (resposta[1] == CodigosFuncoes["GravacaoParametro"])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using AgroBase.Forms;
|
||||
using AgroBase.Models;
|
||||
using CefSharp.DevTools.Network;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
|
@ -41,117 +42,124 @@ namespace AgroBase.Services
|
|||
|
||||
public static async Task RealizarVarreduraPortasUSB()
|
||||
{
|
||||
if (VarreduraEmAndamento || frmPrincipal.Fechando)
|
||||
if (VarreduraEmAndamento || frmInstancial.Fechando)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VarreduraEmAndamento = true;
|
||||
|
||||
var dispositivosMapeados = DispositivosMapeados.ToList();
|
||||
|
||||
var Portas = SerialPort.GetPortNames();
|
||||
var PortasNaoMapeadas = Portas.Where(x => !dispositivosMapeados.Select(y => y.PortaCOM).Contains(x)).ToList();
|
||||
|
||||
for (int i = 0; i < PortasNaoMapeadas.Count(); i++)
|
||||
try
|
||||
{
|
||||
string PortaCom = PortasNaoMapeadas[i].ToString();
|
||||
SerialPort _Porta = new SerialPort() { PortName = PortaCom, BaudRate = 115200 };
|
||||
var dispositivosMapeados = DispositivosMapeados.ToList();
|
||||
|
||||
bool PortaDispositivoProprio = false;
|
||||
var Portas = SerialPort.GetPortNames();
|
||||
var PortasNaoMapeadas = Portas.Where(x => !dispositivosMapeados.Select(y => y.PortaCOM).Contains(x)).ToList();
|
||||
|
||||
if (Variaveis.OperacaoEmAndamento.DispMvd == null)
|
||||
for (int i = 0; i < PortasNaoMapeadas.Count(); i++)
|
||||
{
|
||||
//await TentarIdentificarDispositivo(_Porta);
|
||||
continue;
|
||||
}
|
||||
string PortaCom = PortasNaoMapeadas[i].ToString();
|
||||
Console.WriteLine("Procurando dispositivos conectados à porta " + PortaCom + "...");
|
||||
SerialPort _Porta = new SerialPort() { PortName = PortaCom, BaudRate = 115200 };
|
||||
|
||||
try
|
||||
{
|
||||
_Porta.Open();
|
||||
bool PortaDispositivoProprio = false;
|
||||
|
||||
bool DispositivoMvd = false;
|
||||
foreach (var Modulo in Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos)
|
||||
if (Variaveis.OperacaoEmAndamento.DispMvd == null)
|
||||
{
|
||||
string ProtocoloCheck = Modulo.ProtocoloVerificacao(true);
|
||||
//await TentarIdentificarDispositivo(_Porta);
|
||||
continue;
|
||||
}
|
||||
|
||||
_Porta.Write(ProtocoloCheck);
|
||||
|
||||
await AguardaRespostaPorta(_Porta, 1000);
|
||||
|
||||
bool respondeu = ProcessarRespostaDispositivo(_Porta);
|
||||
if (!DispositivoMvd)
|
||||
{
|
||||
DispositivoMvd = respondeu;
|
||||
}
|
||||
};
|
||||
bool DispositivoAtu = false;
|
||||
if (!DispositivoMvd)
|
||||
try
|
||||
{
|
||||
bool DispositivoAtu = false;
|
||||
bool DispositivoSen = false;
|
||||
bool DispositivoMvd = false;
|
||||
|
||||
string ProtocoloCheck = Variaveis.OperacaoEmAndamento.DispAtu.Dados.ProtocoloVerificacao(true);
|
||||
|
||||
_Porta.Open();
|
||||
_Porta.Write(ProtocoloCheck);
|
||||
|
||||
await AguardaRespostaPorta(_Porta, 1000);
|
||||
|
||||
bool respondeu = ProcessarRespostaDispositivo(_Porta);
|
||||
DispositivoAtu = ProcessarRespostaDispositivo(_Porta);
|
||||
_Porta.Close();
|
||||
if (!DispositivoAtu)
|
||||
{
|
||||
DispositivoAtu = respondeu;
|
||||
ProtocoloCheck = Variaveis.OperacaoEmAndamento.DispSen.Dados.ProtocoloVerificacao(true);
|
||||
|
||||
_Porta.Open();
|
||||
_Porta.Write(ProtocoloCheck);
|
||||
|
||||
await AguardaRespostaPorta(_Porta, 1000);
|
||||
|
||||
DispositivoSen = ProcessarRespostaDispositivo(_Porta);
|
||||
_Porta.Close();
|
||||
if (!DispositivoSen)
|
||||
{
|
||||
DispositivoMvd = await ProcuraDispositivoMvd(_Porta);
|
||||
}
|
||||
}
|
||||
|
||||
PortaDispositivoProprio = DispositivoMvd || DispositivoAtu || DispositivoSen;
|
||||
}
|
||||
bool DispositivoSen = false;
|
||||
if (!DispositivoMvd && !DispositivoAtu)
|
||||
catch (Exception ex)
|
||||
{
|
||||
string ProtocoloCheck = Variaveis.OperacaoEmAndamento.DispSen.Dados.ProtocoloVerificacao(true);
|
||||
|
||||
_Porta.Write(ProtocoloCheck);
|
||||
|
||||
await AguardaRespostaPorta(_Porta, 1000);
|
||||
|
||||
bool respondeu = ProcessarRespostaDispositivo(_Porta);
|
||||
if (!DispositivoSen)
|
||||
{
|
||||
DispositivoSen = respondeu;
|
||||
}
|
||||
Console.WriteLine(ex.Message.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
_Porta.Close();
|
||||
}
|
||||
|
||||
if (!PortaDispositivoProprio)
|
||||
{
|
||||
await TentarIdentificarDispositivo(_Porta);
|
||||
}
|
||||
|
||||
PortaDispositivoProprio = DispositivoMvd || DispositivoAtu || DispositivoSen;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
var DispositivosRemovidos = dispositivosMapeados.Where(x => !Portas.Contains(x.PortaCOM)).ToList();
|
||||
foreach (var Dispositivo in DispositivosRemovidos)
|
||||
{
|
||||
Console.WriteLine(ex.Message.ToString());
|
||||
DispositivosMapeados.Remove(Dispositivo);
|
||||
}
|
||||
finally
|
||||
|
||||
if (!Variaveis.CaminhoSistema.Contains("AgroMonitor"))
|
||||
{
|
||||
_Porta.Close();
|
||||
AtualizarDispositivos();
|
||||
}
|
||||
|
||||
if (!PortaDispositivoProprio)
|
||||
// Se algum dispositivo no barramento RS485 para Modbus já foi identificado
|
||||
if (ModbusService.Iniciado)
|
||||
{
|
||||
await TentarIdentificarDispositivo(_Porta);
|
||||
await ProcuraDispositivoModbus(ModbusService._PortaModbus, false);
|
||||
}
|
||||
|
||||
if (MKS057DService.Iniciado)
|
||||
{
|
||||
if (DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Mks))
|
||||
{
|
||||
await ProcuraDispositivoMKS(MKS057DService._PortaMKS);
|
||||
}
|
||||
else
|
||||
{
|
||||
MKS057DService.Iniciado = false;
|
||||
}
|
||||
}
|
||||
/*if (DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Mvd) && Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.Any(x => !DispositivosMapeados.Any(y => y.Mod_ID == x.Modulo_ID)))
|
||||
{
|
||||
await ProcuraDispositivoMvd(new SerialPort() { PortName = DispositivosMapeados.First(x => x.Dispositivo == T_Code.Mvd).PortaCOM, BaudRate = 115200 });
|
||||
}*/
|
||||
}
|
||||
|
||||
var DispositivosRemovidos = dispositivosMapeados.Where(x => !Portas.Contains(x.PortaCOM)).ToList();
|
||||
foreach (var Dispositivo in DispositivosRemovidos)
|
||||
catch (Exception ex)
|
||||
{
|
||||
DispositivosMapeados.Remove(Dispositivo);
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
|
||||
if (!Variaveis.CaminhoSistema.Contains("AgroMonitor"))
|
||||
finally
|
||||
{
|
||||
AtualizarDispositivos();
|
||||
VarreduraEmAndamento = false;
|
||||
}
|
||||
|
||||
// Se algum dispositivo no barramento RS485 para Modbus já foi identificado
|
||||
if (ModbusService.Iniciado && (DispositivosMapeados.Where(x => DispositivosModbus.Contains(x.Dispositivo)).Count() != DispositivosModbus.Count()))
|
||||
{
|
||||
await ProcuraDispositivoModbus(ModbusService._PortaModbus, false);
|
||||
}
|
||||
|
||||
VarreduraEmAndamento = false;
|
||||
}
|
||||
|
||||
private static bool ProcessarRespostaDispositivo(SerialPort Porta)
|
||||
|
|
@ -177,9 +185,20 @@ namespace AgroBase.Services
|
|||
|
||||
var Dados = Recebido.Split(SplitMessage[0]);
|
||||
|
||||
if (Dados.Length <= 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
string Mod_ID = Dados[0];
|
||||
|
||||
int.TryParse(Dados[1], out int check);
|
||||
|
||||
if (check == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Verificacao = (F_Code)check;
|
||||
|
||||
if (Verificacao == F_Code.Msg)
|
||||
|
|
@ -251,14 +270,12 @@ namespace AgroBase.Services
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!MKS057DService.Iniciado)
|
||||
bool DispMks = await ProcuraDispositivoMKS(porta);
|
||||
if (DispMks)
|
||||
{
|
||||
bool Encontrado = await MKS057DService.VerificaPortaMKS(porta);
|
||||
if (Encontrado)
|
||||
{
|
||||
return Encontrado;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!LoRaService.Iniciado)
|
||||
{
|
||||
bool Encontrado = await LoRaService.VerificaPortaLoRa(porta);
|
||||
|
|
@ -295,11 +312,62 @@ namespace AgroBase.Services
|
|||
return false;
|
||||
}
|
||||
|
||||
private static async Task<bool> ProcuraDispositivoMvd(SerialPort porta)
|
||||
{
|
||||
bool DispositivoMvd = false;
|
||||
|
||||
if (porta == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Mvd) && porta.PortName != DispositivosMapeados.First(x => x.Dispositivo == T_Code.Mvd).PortaCOM)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool conectado = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Conectado;
|
||||
|
||||
if (!conectado)
|
||||
{
|
||||
porta.Open();
|
||||
}
|
||||
|
||||
foreach (var Modulo in Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.Where(x => !DispositivosMapeados.Select(y => y.Mod_ID).Contains(x.Modulo_ID)))
|
||||
{
|
||||
try
|
||||
{
|
||||
string ProtocoloCheck = Modulo.ProtocoloVerificacao(true);
|
||||
|
||||
porta.Write(ProtocoloCheck);
|
||||
|
||||
await AguardaRespostaPorta(porta, 1000);
|
||||
|
||||
bool respondeu = ProcessarRespostaDispositivo(porta);
|
||||
if (!DispositivoMvd)
|
||||
{
|
||||
DispositivoMvd = respondeu;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
if (!conectado)
|
||||
{
|
||||
porta.Close();
|
||||
}
|
||||
|
||||
return DispositivoMvd;
|
||||
}
|
||||
|
||||
private static async Task<bool> ProcuraDispositivoModbus(SerialPort porta, bool PararAoEncontrar)
|
||||
{
|
||||
bool Encontrado = false;
|
||||
|
||||
if (!PZEMService.Iniciado)
|
||||
if (!PZEMService.Iniciado || !DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Pzm))
|
||||
{
|
||||
Encontrado = await PZEMService.VerificaPortaPZEM(ModbusService.Iniciado ? ModbusService._PortaModbus : porta);
|
||||
|
||||
|
|
@ -308,7 +376,7 @@ namespace AgroBase.Services
|
|||
return Encontrado;
|
||||
}
|
||||
}
|
||||
if (!WT901CService.Iniciado)
|
||||
if (!WT901CService.Iniciado || !DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Wit))
|
||||
{
|
||||
Encontrado = await WT901CService.VerificaPortaWT901C(ModbusService.Iniciado ? ModbusService._PortaModbus : porta);
|
||||
if (Encontrado && PararAoEncontrar)
|
||||
|
|
@ -335,6 +403,25 @@ namespace AgroBase.Services
|
|||
return Encontrado;
|
||||
}
|
||||
|
||||
private static async Task<bool> ProcuraDispositivoMKS(SerialPort porta)
|
||||
{
|
||||
if (MKS057DService.Iniciado && porta.PortName != MKS057DService._PortaMKS.PortName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!MKS057DService.Iniciado || MKS057DService.DadosLeitura.Any(x => !x.Iniciado))
|
||||
{
|
||||
bool Encontrado = await MKS057DService.VerificaPortaMKS(porta);
|
||||
if (Encontrado)
|
||||
{
|
||||
return Encontrado;
|
||||
}
|
||||
}
|
||||
|
||||
return MKS057DService.Iniciado;
|
||||
}
|
||||
|
||||
public static byte[] VerificarRespostaPortasDesconhecidas(SerialPort Porta)
|
||||
{
|
||||
if (Porta != null && Porta.IsOpen)
|
||||
|
|
@ -351,11 +438,11 @@ namespace AgroBase.Services
|
|||
}
|
||||
}
|
||||
|
||||
public static byte[] LerDadosDaPortaSerial(SerialPort porta, int tamanhoEsperado)
|
||||
public static byte[] LerDadosDaPortaSerial(SerialPort porta, int tamanhoEsperado, int Timeout = 500)
|
||||
{
|
||||
DateTime inicio = DateTime.Now;
|
||||
List<byte> buffer = new List<byte>();
|
||||
while (buffer.Count < tamanhoEsperado && inicio.AddMilliseconds(500) > DateTime.Now)
|
||||
while (buffer.Count < tamanhoEsperado && inicio.AddMilliseconds(Timeout) > DateTime.Now)
|
||||
{
|
||||
int bytesDisponiveis = porta.BytesToRead;
|
||||
if (bytesDisponiveis > 0)
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ namespace AgroBase.Services
|
|||
var comando = ModbusService.ComandoGetParametro(slaveAddress, new ModbusParametrosModel() { FuncaoGet = 0x03, N_Registros = 2, Registro = 0x2e });
|
||||
|
||||
EnviarComando(porta, comando);
|
||||
await Task.Delay(1000);
|
||||
var resposta = SerialService.VerificarRespostaPortasDesconhecidas(porta);
|
||||
var resposta = SerialService.LerDadosDaPortaSerial(porta, 7, 1000);
|
||||
//var resposta = SerialService.VerificarRespostaPortasDesconhecidas(porta);
|
||||
|
||||
ModbusService.Verificando = false;
|
||||
|
||||
|
|
@ -112,7 +112,14 @@ namespace AgroBase.Services
|
|||
|
||||
await Task.Delay(TaxaAmostragem);
|
||||
|
||||
return await ReceberDados();
|
||||
if (ModbusService.Iniciado)
|
||||
{
|
||||
return await ReceberDados();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DefinirDispositivo()
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-01T15:05:41.5766417-03:00","Protocolo":"@1;EF;258;EF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T15:05:41.5866629-03:00","Protocolo":"EF;655;1;$\r","Enviado":false},{"Momento":"2024-07-01T15:05:41.5981854-03:00","Protocolo":"@2;EF;258;Mov,1,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T15:05:42.6209546-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T15:05:43.1162914-03:00","Protocolo":"@3;EF;244;check$","Enviado":true},{"Momento":"2024-07-01T15:05:43.631607-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T15:05:43.6421232-03:00","Protocolo":"EF;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-01T15:05:51.0157092-03:00","Protocolo":"@2;EF;258;Mov,1,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T15:05:51.0157092-03:00","Protocolo":"EF;655;2;$\r","Enviado":false},{"Momento":"2024-07-01T15:05:51.0373094-03:00","Protocolo":"EF;244;109;6;0;$\r","Enviado":false},{"Momento":"2024-07-01T15:05:56.2348606-03:00","Protocolo":"@4;EF;258;EF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T15:05:56.245383-03:00","Protocolo":"EF;655;4;$\r","Enviado":false},{"Momento":"2024-07-01T15:05:56.2539003-03:00","Protocolo":"@5;EF;258;Mov,1,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T15:05:57.2749672-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T15:05:57.7630299-03:00","Protocolo":"@6;EF;244;check$","Enviado":true},{"Momento":"2024-07-01T15:05:58.2880203-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T15:05:58.2985504-03:00","Protocolo":"EF;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-01T15:05:59.0915496-03:00","Protocolo":"EF;655;5;$\r","Enviado":false},{"Momento":"2024-07-01T15:05:59.1156242-03:00","Protocolo":"EF;244;109;6;0;$\r","Enviado":false},{"Momento":"2024-07-01T15:17:06.942396-03:00","Protocolo":"@7;EF;258;EF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T15:17:06.9479533-03:00","Protocolo":"EF;655;7;$\r","Enviado":false},{"Momento":"2024-07-01T15:17:06.9710638-03:00","Protocolo":"@8;EF;258;Mov,1,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T15:17:06.9856542-03:00","Protocolo":"Comando enviado: 02 06 00 B6 00 01 A9 DF \r","Enviado":false},{"Momento":"2024-07-01T15:17:07.9946172-03:00","Protocolo":"Resposta recebida: 00 00 \r","Enviado":false},{"Momento":"2024-07-01T15:17:07.9996372-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T15:17:08.4820396-03:00","Protocolo":"@9;EF;244;check$","Enviado":true},{"Momento":"2024-07-01T15:17:09.0068392-03:00","Protocolo":"Comando enviado: 02 06 00 B6 00 01 A9 DF \r","Enviado":false},{"Momento":"2024-07-01T15:17:09.0173991-03:00","Protocolo":"Resposta recebida: 00 00 00 \r","Enviado":false},{"Momento":"2024-07-01T15:17:09.0223991-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T15:17:09.0329467-03:00","Protocolo":"EF;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-01T15:17:26.4745571-03:00","Protocolo":"@8;EF;258;Mov,1,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T15:17:26.4755659-03:00","Protocolo":"EF;655;8;$\r","Enviado":false}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-01T17:07:29.7995304-03:00","Protocolo":"@1;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T17:07:29.8090452-03:00","Protocolo":"ET;655;1;$\r","Enviado":false},{"Momento":"2024-07-01T17:07:29.8280756-03:00","Protocolo":"@2;ET;258;Mov,1,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T17:07:30.8523896-03:00","Protocolo":"Timeout ao aguardar resposta Modbus\r","Enviado":false},{"Momento":"2024-07-01T17:07:31.3392217-03:00","Protocolo":"@3;ET;244;check$","Enviado":true},{"Momento":"2024-07-01T17:07:31.8623533-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T17:07:31.8653714-03:00","Protocolo":"Timeout ao aguardar resposta Modbus\r","Enviado":false},{"Momento":"2024-07-01T17:07:31.87492-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T17:07:31.8874769-03:00","Protocolo":"ET;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-01T17:07:31.8980268-03:00","Protocolo":"ET;655;2;$\r","Enviado":false},{"Momento":"2024-07-01T17:07:32.8670773-03:00","Protocolo":"@3;ET;244;check$","Enviado":true},{"Momento":"2024-07-01T17:07:32.8755927-03:00","Protocolo":"ET;244;109;6;0;$\r","Enviado":false}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-01T16:19:14.4014585-03:00","Protocolo":"@1;EF;258;EF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T16:19:25.2140235-03:00","Protocolo":"@4;EF;258;EF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-01T16:20:10.7655198-03:00","Protocolo":"@1;DT;258;DT,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T16:20:10.7750364-03:00","Protocolo":"DT;655;1;$\r","Enviado":false},{"Momento":"2024-07-01T16:20:10.7885544-03:00","Protocolo":"@2;DT;258;Mov,1,0x03,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T16:20:11.1643318-03:00","Protocolo":"DT;#211;Mov;1$\r","Enviado":false},{"Momento":"2024-07-01T16:20:11.1748552-03:00","Protocolo":"DT;655;2;$\r","Enviado":false},{"Momento":"2024-07-01T16:20:11.1808579-03:00","Protocolo":"@3;DT;244;check$","Enviado":true},{"Momento":"2024-07-01T16:20:11.1959024-03:00","Protocolo":"DT;244;109;6;1;$\r","Enviado":false},{"Momento":"2024-07-01T16:20:11.1988791-03:00","Protocolo":"DT;655;3;$\r","Enviado":false},{"Momento":"2024-07-01T16:20:12.6182727-03:00","Protocolo":"DT;#544;DT;1;0.00;447.00;41.21;19.05;0;0;0;0;21.92$\r","Enviado":false},{"Momento":"2024-07-01T16:20:15.9472225-03:00","Protocolo":"DT;#544;DT;1;0.00;769.93;41.21;19.05;0;0;0;0;21.94$\r","Enviado":false},{"Momento":"2024-07-01T16:20:15.9492205-03:00","Protocolo":"DT;#544;DT;1;0.00;856.23;41.21;19.05;0;0;0;0;21.94$\r","Enviado":false},{"Momento":"2024-07-01T16:20:17.1243159-03:00","Protocolo":"DT;#544;DT;1;0.00;875.23;41.21;19.05;0;0;0;0;21.96$\r","Enviado":false},{"Momento":"2024-07-01T16:20:18.628605-03:00","Protocolo":"DT;#544;DT;1;0.00;880.92;41.21;19.05;0;0;0;0;21.82$\r","Enviado":false},{"Momento":"2024-07-01T16:20:20.1319475-03:00","Protocolo":"DT;#544;DT;1;0.00;885.04;41.21;19.05;0;0;0;0;21.94$\r","Enviado":false},{"Momento":"2024-07-01T16:20:21.6346446-03:00","Protocolo":"DT;#544;DT;1;0.00;887.41;41.21;19.05;0;0;0;0;21.92$\r","Enviado":false},{"Momento":"2024-07-01T16:20:23.1368609-03:00","Protocolo":"DT;#544;DT;1;0.00;888.13;41.18;19.05;0;0;0;0;21.96$\r","Enviado":false},{"Momento":"2024-07-01T16:20:24.6405794-03:00","Protocolo":"DT;#544;DT;1;0.00;888.28;41.21;19.05;0;0;0;0;21.99$\r","Enviado":false},{"Momento":"2024-07-01T16:20:26.1436377-03:00","Protocolo":"DT;#544;DT;1;0.00;888.82;41.21;19.05;0;0;0;0;21.94$\r","Enviado":false},{"Momento":"2024-07-01T16:20:27.6465654-03:00","Protocolo":"DT;#544;DT;1;0.00;889.10;41.24;19.13;0;0;0;0;21.96$\r","Enviado":false},{"Momento":"2024-07-01T16:20:29.1489593-03:00","Protocolo":"DT;#544;DT;1;0.00;889.20;41.18;19.13;0;0;0;0;21.94$\r","Enviado":false},{"Momento":"2024-07-01T16:20:30.6522056-03:00","Protocolo":"DT;#544;DT;1;0.00;878.90;41.21;19.05;0;0;0;0;21.96$\r","Enviado":false},{"Momento":"2024-07-01T16:20:32.1557643-03:00","Protocolo":"DT;#544;DT;1;0.00;880.80;41.21;19.05;0;0;0;0;21.90$\r","Enviado":false},{"Momento":"2024-07-01T16:20:33.6589372-03:00","Protocolo":"DT;#544;DT;1;0.00;885.23;41.18;19.13;0;0;0;0;21.96$\r","Enviado":false},{"Momento":"2024-07-01T16:20:35.1623014-03:00","Protocolo":"DT;#544;DT;1;0.00;886.10;41.21;19.05;0;0;0;0;21.96$\r","Enviado":false},{"Momento":"2024-07-01T16:20:36.6653807-03:00","Protocolo":"DT;#544;DT;1;0.00;887.15;41.21;19.05;0;0;0;0;21.96$\r","Enviado":false},{"Momento":"2024-07-01T16:20:37.5990319-03:00","Protocolo":"@4;DT;258;Mov,0,0x03,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T16:20:37.6110532-03:00","Protocolo":"DT;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-01T16:20:37.6215745-03:00","Protocolo":"DT;655;4;$\r","Enviado":false},{"Momento":"2024-07-01T16:20:37.6336199-03:00","Protocolo":"@5;DT;258;DT,0,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T16:20:37.6431506-03:00","Protocolo":"DT;655;5;$\r","Enviado":false},{"Momento":"2024-07-01T16:20:37.6471488-03:00","Protocolo":"@6;DT;244;check$","Enviado":true},{"Momento":"2024-07-01T16:20:37.6556667-03:00","Protocolo":"DT;244;109;6;0;$\r","Enviado":false}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-01T16:46:39.382281-03:00","Protocolo":"@1;EF;258;EF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T16:46:39.3953104-03:00","Protocolo":"EF;655;1;$\r","Enviado":false},{"Momento":"2024-07-01T16:46:39.4089249-03:00","Protocolo":"@2;EF;258;Mov,1,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T16:46:39.4220675-03:00","Protocolo":"Comando enviado: 02 06 00 B6 00 01 A9 DF \r","Enviado":false},{"Momento":"2024-07-01T16:46:39.431588-03:00","Protocolo":"Resposta recebida: 00 00 00 00 00 FC \r","Enviado":false},{"Momento":"2024-07-01T16:46:39.4391127-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T16:46:39.4451111-03:00","Protocolo":"Comando enviado: 02 06 00 B6 00 01 A9 DF \r","Enviado":false},{"Momento":"2024-07-01T16:46:39.4466241-03:00","Protocolo":"Resposta recebida: 00 06 00 6C 00 01 52 57 \r","Enviado":false},{"Momento":"2024-07-01T16:46:39.4536327-03:00","Protocolo":"Comando enviado: 02 06 00 76 00 00 68 23 \r","Enviado":false},{"Momento":"2024-07-01T16:46:39.4591666-03:00","Protocolo":"Resposta recebida: 00 00 00 00 00 \r","Enviado":false},{"Momento":"2024-07-01T16:46:40.4653109-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T16:46:40.4713485-03:00","Protocolo":"Comando enviado: 02 06 00 76 00 00 68 23 \r","Enviado":false},{"Momento":"2024-07-01T16:46:40.4778937-03:00","Protocolo":"Resposta recebida: 00 00 \r","Enviado":false},{"Momento":"2024-07-01T16:46:40.9191857-03:00","Protocolo":"@3;EF;244;check$","Enviado":true},{"Momento":"2024-07-01T16:46:40.9257011-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-01T16:46:40.9362684-03:00","Protocolo":"EF;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-01T16:46:42.433345-03:00","Protocolo":"@2;EF;258;Mov,1,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T16:46:42.4473955-03:00","Protocolo":"EF;655;2;$\r","Enviado":false},{"Momento":"2024-07-01T16:46:42.4579375-03:00","Protocolo":"EF;244;109;5;0;$\r","Enviado":false},{"Momento":"2024-07-01T16:47:12.2362802-03:00","Protocolo":"@4;DT;258;DT,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T16:47:12.2453068-03:00","Protocolo":"DT;655;4;$\r","Enviado":false},{"Momento":"2024-07-01T16:47:12.2578446-03:00","Protocolo":"@5;DT;258;Mov,1,0x03,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T16:47:12.6350457-03:00","Protocolo":"DT;#211;Mov;1$\r","Enviado":false},{"Momento":"2024-07-01T16:47:12.6450758-03:00","Protocolo":"DT;655;5;$\r","Enviado":false},{"Momento":"2024-07-01T16:47:12.6520963-03:00","Protocolo":"@6;DT;244;check$","Enviado":true},{"Momento":"2024-07-01T16:47:12.6651185-03:00","Protocolo":"DT;244;109;6;1;$\r","Enviado":false},{"Momento":"2024-07-01T16:47:12.6691323-03:00","Protocolo":"DT;655;6;$\r","Enviado":false},{"Momento":"2024-07-01T16:47:13.7678779-03:00","Protocolo":"DT;#544;DT;1;0.00;448.50;41.13;19.13;0;0;0;0;21.44$\r","Enviado":false},{"Momento":"2024-07-01T16:47:15.2703629-03:00","Protocolo":"DT;#544;DT;1;0.00;767.63;41.21;19.13;0;0;0;0;21.42$\r","Enviado":false},{"Momento":"2024-07-01T16:47:15.751294-03:00","Protocolo":"@7;DT;258;Mov,0,0x03,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T16:47:15.7618177-03:00","Protocolo":"DT;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-01T16:47:15.7723351-03:00","Protocolo":"DT;655;7;$\r","Enviado":false},{"Momento":"2024-07-01T16:47:15.7853634-03:00","Protocolo":"@8;DT;258;DT,0,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T16:47:15.7949692-03:00","Protocolo":"DT;655;8;$\r","Enviado":false},{"Momento":"2024-07-01T16:47:15.8124159-03:00","Protocolo":"@9;DT;244;check$","Enviado":true},{"Momento":"2024-07-01T16:47:15.8264561-03:00","Protocolo":"DT;244;109;6;0;$\r","Enviado":false}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-01T15:59:05.6689452-03:00","Protocolo":"@1;DT;258;DT,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-01T15:59:05.6789809-03:00","Protocolo":"DT;655;1;$\r","Enviado":false},{"Momento":"2024-07-01T15:59:05.6960121-03:00","Protocolo":"@2;DT;258;Mov,1,0x03,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-01T15:59:05.7180603-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-02T10:06:55.7761418-03:00","Protocolo":"@1;EF;258;EF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T10:06:55.7846587-03:00","Protocolo":"EF;655;1;$\r","Enviado":false},{"Momento":"2024-07-02T10:06:55.7951734-03:00","Protocolo":"@2;EF;258;Mov,1,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-02T10:06:56.1689644-03:00","Protocolo":"EF;#211;Mov;1$\r","Enviado":false},{"Momento":"2024-07-02T10:06:56.1794878-03:00","Protocolo":"EF;655;2;$\r","Enviado":false},{"Momento":"2024-07-02T10:06:56.18801-03:00","Protocolo":"@3;EF;244;check$","Enviado":true},{"Momento":"2024-07-02T10:06:56.2005353-03:00","Protocolo":"EF;244;109;6;1;$\r","Enviado":false},{"Momento":"2024-07-02T10:06:56.2050522-03:00","Protocolo":"EF;655;3;$\r","Enviado":false},{"Momento":"2024-07-02T10:06:57.3108786-03:00","Protocolo":"EF;#544;EF;1;0.00;439.50;41.13;19.67;0;0;0;0;21.63$\r","Enviado":false},{"Momento":"2024-07-02T10:06:58.8136483-03:00","Protocolo":"EF;#544;EF;1;0.00;798.07;41.13;19.67;0;0;0;0;21.65$\r","Enviado":false},{"Momento":"2024-07-02T10:07:00.3162692-03:00","Protocolo":"EF;#544;EF;1;0.00;859.61;41.13;19.75;0;0;0;0;21.65$\r","Enviado":false},{"Momento":"2024-07-02T10:07:00.7138593-03:00","Protocolo":"@4;EF;258;Mov,0,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-02T10:07:00.7243793-03:00","Protocolo":"EF;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-02T10:07:00.7349001-03:00","Protocolo":"EF;655;4;$\r","Enviado":false},{"Momento":"2024-07-02T10:07:00.7444234-03:00","Protocolo":"@5;EF;258;EF,0,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T10:07:00.752936-03:00","Protocolo":"EF;655;5;$\r","Enviado":false},{"Momento":"2024-07-02T10:07:00.7604417-03:00","Protocolo":"@6;EF;244;check$","Enviado":true},{"Momento":"2024-07-02T10:07:00.7659588-03:00","Protocolo":"EF;244;109;6;0;$\r","Enviado":false}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-02T14:16:01.6876639-03:00","Protocolo":"@1;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T14:16:26.7060724-03:00","Protocolo":"@4;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-02T13:40:36.7513825-03:00","Protocolo":"@1;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:40:41.8023838-03:00","Protocolo":"@4;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:40:45.8183834-03:00","Protocolo":"@7;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:40:47.3233887-03:00","Protocolo":"@8;ET;258;Mov,1,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-02T13:40:50.1303837-03:00","Protocolo":"@10;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:40:51.6473902-03:00","Protocolo":"@11;ET;258;Mov,1,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-02T13:40:53.1633901-03:00","Protocolo":"@12;ET;244;check$","Enviado":true},{"Momento":"2024-07-02T13:41:05.5953845-03:00","Protocolo":"@13;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:41:07.0983914-03:00","Protocolo":"@14;ET;258;Mov,1,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-02T14:42:01.1721753-03:00","Protocolo":"@1;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-02T13:41:35.7213848-03:00","Protocolo":"@1;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:41:45.3223839-03:00","Protocolo":"@4;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:42:20.7403868-03:00","Protocolo":"@7;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:44:16.8354146-03:00","Protocolo":"@10;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:44:24.8144133-03:00","Protocolo":"@11;ET;258;Mov,1,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-02T13:44:42.8924123-03:00","Protocolo":"@13;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:44:50.537414-03:00","Protocolo":"@16;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:45:03.5784113-03:00","Protocolo":"@19;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T13:45:05.0816261-03:00","Protocolo":"@20;ET;258;Mov,1,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-02T13:45:06.5846258-03:00","Protocolo":"@21;ET;244;check$","Enviado":true}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-02T14:43:05.8390975-03:00","Protocolo":"@1;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T14:43:07.3511092-03:00","Protocolo":"@2;ET;258;Mov,1,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-02T14:43:08.8655774-03:00","Protocolo":"@3;ET;244;check$","Enviado":true}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-02T14:46:55.9307038-03:00","Protocolo":"@1;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T14:46:55.9417027-03:00","Protocolo":"ET;655;1;$\r","Enviado":false},{"Momento":"2024-07-02T14:46:55.9627025-03:00","Protocolo":"@2;ET;258;Mov,1,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-02T14:47:08.3827704-03:00","Protocolo":"@4;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T14:47:08.3917657-03:00","Protocolo":"ET;655;4;$\r","Enviado":false},{"Momento":"2024-07-02T14:47:08.3937664-03:00","Protocolo":"@5;ET;258;Mov,1,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-02T14:47:08.4057692-03:00","Protocolo":"ET;#211;Mov;1$\r","Enviado":false},{"Momento":"2024-07-02T14:47:08.4167688-03:00","Protocolo":"ET;655;5;$\r","Enviado":false},{"Momento":"2024-07-02T14:47:08.425767-03:00","Protocolo":"@6;ET;244;check$","Enviado":true},{"Momento":"2024-07-02T14:47:08.4387662-03:00","Protocolo":"ET;244;109;6;1;$\r","Enviado":false},{"Momento":"2024-07-02T14:47:08.4427681-03:00","Protocolo":"ET;655;6;$\r","Enviado":false},{"Momento":"2024-07-02T14:47:09.7313394-03:00","Protocolo":"ET;#544;ET;1;0.00;806.37;41.00;20.68;0;0;0;0;26.72$\r","Enviado":false},{"Momento":"2024-07-02T14:47:11.2341578-03:00","Protocolo":"ET;#544;ET;1;0.00;805.18;41.00;20.68;0;0;0;0;26.72$\r","Enviado":false},{"Momento":"2024-07-02T14:47:12.741659-03:00","Protocolo":"ET;#544;ET;1;0.00;804.34;41.00;20.68;0;0;0;0;26.74$\r","Enviado":false},{"Momento":"2024-07-02T14:47:14.2414984-03:00","Protocolo":"ET;#544;ET;1;0.00;803.72;41.00;20.68;0;0;0;0;26.72$\r","Enviado":false},{"Momento":"2024-07-02T14:47:15.7445207-03:00","Protocolo":"ET;#544;ET;1;0.00;804.65;41.00;20.68;0;0;0;0;26.74$\r","Enviado":false},{"Momento":"2024-07-02T14:47:17.1747863-03:00","Protocolo":"@7;ET;258;Mov,0,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-02T14:47:17.1857852-03:00","Protocolo":"ET;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-02T14:47:17.196786-03:00","Protocolo":"ET;655;7;$\r","Enviado":false},{"Momento":"2024-07-02T14:47:17.2037861-03:00","Protocolo":"@8;ET;258;ET,0,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-02T14:47:17.2117862-03:00","Protocolo":"ET;655;8;$\r","Enviado":false},{"Momento":"2024-07-02T14:47:17.2197842-03:00","Protocolo":"@9;ET;244;check$","Enviado":true},{"Momento":"2024-07-02T14:47:17.2337846-03:00","Protocolo":"ET;244;109;6;0;$\r","Enviado":false}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-03T08:03:16.0067748-03:00","Protocolo":"@1;EF;258;EF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-03T08:03:16.0152317-03:00","Protocolo":"EF;655;1;$\r","Enviado":false},{"Momento":"2024-07-03T08:03:16.0227417-03:00","Protocolo":"@2;EF;258;Mov,1,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-03T08:03:16.4002018-03:00","Protocolo":"EF;#211;Mov;1$\r","Enviado":false},{"Momento":"2024-07-03T08:03:16.4102826-03:00","Protocolo":"EF;655;2;$\r","Enviado":false},{"Momento":"2024-07-03T08:03:16.4178209-03:00","Protocolo":"@3;EF;244;check$","Enviado":true},{"Momento":"2024-07-03T08:03:16.4369132-03:00","Protocolo":"EF;244;109;6;1;$\r","Enviado":false},{"Momento":"2024-07-03T08:03:16.4424487-03:00","Protocolo":"EF;655;3;$\r","Enviado":false},{"Momento":"2024-07-03T08:03:17.8351622-03:00","Protocolo":"EF;#544;EF;1;0.00;430.50;41.00;19.75;0;0;0;0;20.75$\r","Enviado":false},{"Momento":"2024-07-03T08:03:19.3415777-03:00","Protocolo":"EF;#544;EF;1;0.00;731.52;41.00;19.83;0;0;0;0;20.64$\r","Enviado":false},{"Momento":"2024-07-03T08:03:20.8403695-03:00","Protocolo":"EF;#544;EF;1;0.00;809.19;41.00;19.83;0;0;0;0;20.62$\r","Enviado":false},{"Momento":"2024-07-03T08:03:22.3432764-03:00","Protocolo":"EF;#544;EF;1;0.00;827.26;41.00;19.83;0;0;0;0;20.64$\r","Enviado":false},{"Momento":"2024-07-03T08:03:23.8462365-03:00","Protocolo":"EF;#544;EF;1;0.00;832.46;41.00;19.83;0;0;0;0;20.64$\r","Enviado":false},{"Momento":"2024-07-03T08:03:25.3486867-03:00","Protocolo":"EF;#544;EF;1;0.00;836.94;41.00;19.83;0;0;0;0;20.66$\r","Enviado":false},{"Momento":"2024-07-03T08:03:26.8517726-03:00","Protocolo":"EF;#544;EF;1;0.00;842.40;41.03;19.83;0;0;0;0;20.66$\r","Enviado":false},{"Momento":"2024-07-03T08:03:28.3539953-03:00","Protocolo":"EF;#544;EF;1;0.00;838.97;41.00;19.83;0;0;0;0;20.66$\r","Enviado":false},{"Momento":"2024-07-03T08:03:29.8582352-03:00","Protocolo":"EF;#544;EF;1;0.00;836.40;41.00;19.83;0;0;0;0;20.66$\r","Enviado":false},{"Momento":"2024-07-03T08:03:31.3612161-03:00","Protocolo":"EF;#544;EF;1;0.00;837.81;41.00;19.83;0;0;0;0;20.68$\r","Enviado":false},{"Momento":"2024-07-03T08:03:32.8638224-03:00","Protocolo":"EF;#544;EF;1;0.00;838.72;41.00;19.83;0;0;0;0;20.66$\r","Enviado":false},{"Momento":"2024-07-03T08:03:34.3667377-03:00","Protocolo":"EF;#544;EF;1;0.00;839.41;41.00;19.90;0;0;0;0;20.71$\r","Enviado":false},{"Momento":"2024-07-03T08:03:35.8713877-03:00","Protocolo":"EF;#544;EF;1;0.00;840.08;41.00;19.83;0;0;0;0;20.68$\r","Enviado":false},{"Momento":"2024-07-03T08:03:37.2997493-03:00","Protocolo":"@4;EF;293;Mov,2,60,0$","Enviado":true},{"Momento":"2024-07-03T08:03:37.3063096-03:00","Protocolo":"EF;655;4;$\r","Enviado":false},{"Momento":"2024-07-03T08:03:37.3725603-03:00","Protocolo":"EF;#544;EF;1;0.00;840.07;41.00;19.83;0;0;0;0;20.71$\r","Enviado":false},{"Momento":"2024-07-03T08:03:37.8269301-03:00","Protocolo":"@5;EF;293;Mov,0,0,0$","Enviado":true},{"Momento":"2024-07-03T08:03:37.8334815-03:00","Protocolo":"EF;655;5;$\r","Enviado":false},{"Momento":"2024-07-03T08:03:38.8200076-03:00","Protocolo":"@6;EF;293;Mov,1,60,0$","Enviado":true},{"Momento":"2024-07-03T08:03:38.8270766-03:00","Protocolo":"EF;655;6;$\r","Enviado":false},{"Momento":"2024-07-03T08:03:38.8768161-03:00","Protocolo":"EF;#544;EF;1;190.00;858.03;41.00;19.90;0;0;0;0;20.68$\r","Enviado":false},{"Momento":"2024-07-03T08:03:39.9146446-03:00","Protocolo":"@7;EF;293;Mov,0,0,0$","Enviado":true},{"Momento":"2024-07-03T08:03:39.9211572-03:00","Protocolo":"EF;655;7;$\r","Enviado":false},{"Momento":"2024-07-03T08:03:40.3792426-03:00","Protocolo":"EF;#544;EF;1;234.00;852.01;41.03;19.90;0;0;0;0;20.71$\r","Enviado":false},{"Momento":"2024-07-03T08:03:41.8823805-03:00","Protocolo":"EF;#544;EF;1;0.00;850.58;41.00;19.83;0;0;0;0;20.73$\r","Enviado":false},{"Momento":"2024-07-03T08:03:43.3856267-03:00","Protocolo":"EF;#544;EF;1;0.00;848.65;41.03;19.83;0;0;0;0;20.73$\r","Enviado":false},{"Momento":"2024-07-03T08:03:44.4825858-03:00","Protocolo":"@8;EF;258;Mov,0,0x02,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-03T08:03:44.4941174-03:00","Protocolo":"EF;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-03T08:03:44.504633-03:00","Protocolo":"EF;655;8;$\r","Enviado":false},{"Momento":"2024-07-03T08:03:44.5086355-03:00","Protocolo":"@9;EF;258;EF,0,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-03T08:03:44.5181534-03:00","Protocolo":"EF;655;9;$\r","Enviado":false},{"Momento":"2024-07-03T08:03:44.5266739-03:00","Protocolo":"@10;EF;244;check$","Enviado":true},{"Momento":"2024-07-03T08:03:44.5337079-03:00","Protocolo":"EF;244;109;6;0;$\r","Enviado":false}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-03T08:07:38.7427778-03:00","Protocolo":"@1;ET;258;ET,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-03T08:07:40.2556601-03:00","Protocolo":"@2;ET;258;Mov,1,0x01,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-03T08:07:41.7718449-03:00","Protocolo":"@3;ET;244;check$","Enviado":true},{"Momento":"2024-07-03T08:07:56.0820628-03:00","Protocolo":"@4;DT;258;DT,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-03T08:07:56.093596-03:00","Protocolo":"DT;655;4;$\r","Enviado":false},{"Momento":"2024-07-03T08:07:56.1091191-03:00","Protocolo":"@5;DT;258;Mov,1,0x03,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-03T08:07:56.4848871-03:00","Protocolo":"DT;#211;Mov;1$\r","Enviado":false},{"Momento":"2024-07-03T08:07:56.4954026-03:00","Protocolo":"DT;655;5;$\r","Enviado":false},{"Momento":"2024-07-03T08:07:56.4974034-03:00","Protocolo":"@6;DT;244;check$","Enviado":true},{"Momento":"2024-07-03T08:07:56.5144433-03:00","Protocolo":"DT;244;109;6;1;$\r","Enviado":false},{"Momento":"2024-07-03T08:07:56.5194423-03:00","Protocolo":"DT;655;6;$\r","Enviado":false},{"Momento":"2024-07-03T08:07:57.8915909-03:00","Protocolo":"DT;#544;DT;1;0.00;436.50;40.92;19.13;0;0;0;0;20.89$\r","Enviado":false},{"Momento":"2024-07-03T08:07:59.394042-03:00","Protocolo":"DT;#544;DT;1;0.00;750.82;41.00;19.13;0;0;0;0;20.94$\r","Enviado":false},{"Momento":"2024-07-03T08:08:00.8964969-03:00","Protocolo":"DT;#544;DT;1;0.00;830.40;40.92;19.05;0;0;0;0;20.94$\r","Enviado":false},{"Momento":"2024-07-03T08:08:02.4007584-03:00","Protocolo":"DT;#544;DT;1;0.00;868.87;40.92;19.05;0;0;0;0;20.92$\r","Enviado":false},{"Momento":"2024-07-03T08:08:03.9032067-03:00","Protocolo":"DT;#544;DT;1;0.00;869.34;40.98;19.13;0;0;0;0;20.92$\r","Enviado":false},{"Momento":"2024-07-03T08:08:05.407401-03:00","Protocolo":"DT;#544;DT;1;0.00;869.83;40.92;19.05;0;0;0;0;20.92$\r","Enviado":false},{"Momento":"2024-07-03T08:08:05.9093508-03:00","Protocolo":"@7;DT;258;Mov,0,0x03,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-03T08:08:05.9203753-03:00","Protocolo":"DT;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-03T08:08:05.9308924-03:00","Protocolo":"DT;655;7;$\r","Enviado":false},{"Momento":"2024-07-03T08:08:05.9424234-03:00","Protocolo":"@8;DT;258;DT,0,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-03T08:08:05.9519341-03:00","Protocolo":"DT;655;8;$\r","Enviado":false},{"Momento":"2024-07-03T08:08:05.95694-03:00","Protocolo":"@9;DT;244;check$","Enviado":true},{"Momento":"2024-07-03T08:08:05.9719791-03:00","Protocolo":"DT;244;109;6;0;$\r","Enviado":false}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-03T08:13:32.5920904-03:00","Protocolo":"@1;DF;258;DF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-03T08:13:32.5996011-03:00","Protocolo":"DF;655;1;$\r","Enviado":false},{"Momento":"2024-07-03T08:13:32.6131281-03:00","Protocolo":"@2;DF;258;Mov,1,0x04,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-03T08:13:32.6266407-03:00","Protocolo":"Comando enviado: 04 06 00 B6 00 01 A9 B9 \r","Enviado":false},{"Momento":"2024-07-03T08:13:40.9629534-03:00","Protocolo":"@4;DF;258;DF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-03T08:13:40.9704664-03:00","Protocolo":"DF;655;4;$\r","Enviado":false},{"Momento":"2024-07-03T08:13:40.9809855-03:00","Protocolo":"@5;DF;258;Mov,1,0x04,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-03T08:13:40.9950171-03:00","Protocolo":"Comando enviado: 04 06 00 B6 00 01 A9 B9 \r","Enviado":false},{"Momento":"2024-07-03T08:13:42.0055264-03:00","Protocolo":"Timeout ao aguardar resposta Modbus\r","Enviado":false},{"Momento":"2024-07-03T08:13:42.0100325-03:00","Protocolo":"Erro ao enviar comando\r","Enviado":false},{"Momento":"2024-07-03T08:13:42.4945025-03:00","Protocolo":"@6;DF;244;check$","Enviado":true},{"Momento":"2024-07-03T08:13:43.0166751-03:00","Protocolo":"Comando enviado: 04 06 00 B6 00 01 A9 B9 \r","Enviado":false},{"Momento":"2024-07-03T08:13:43.0221978-03:00","Protocolo":"Timeout ao aguardar resposta Modbus\r","Enviado":false}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-07-03T08:34:40.7595203-03:00","Protocolo":"@1;DF;258;DF,1,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-03T08:34:40.7700388-03:00","Protocolo":"DF;655;1;$\r","Enviado":false},{"Momento":"2024-07-03T08:34:40.7805525-03:00","Protocolo":"@2;DF;258;Mov,1,0x04,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-03T08:34:41.1582696-03:00","Protocolo":"DF;#211;Mov;1$\r","Enviado":false},{"Momento":"2024-07-03T08:34:41.1683627-03:00","Protocolo":"DF;655;2;$\r","Enviado":false},{"Momento":"2024-07-03T08:34:41.1753574-03:00","Protocolo":"@3;DF;244;check$","Enviado":true},{"Momento":"2024-07-03T08:34:41.197001-03:00","Protocolo":"DF;244;109;6;1;$\r","Enviado":false},{"Momento":"2024-07-03T08:34:41.1990117-03:00","Protocolo":"DF;655;3;$\r","Enviado":false},{"Momento":"2024-07-03T08:34:42.5418196-03:00","Protocolo":"DF;#544;DF;1;0.00;444.00;41.13;20.83;0;0;0;0;21.55$\r","Enviado":false},{"Momento":"2024-07-03T08:34:44.0440589-03:00","Protocolo":"DF;#544;DF;1;0.00;768.65;41.13;20.83;0;0;0;0;21.55$\r","Enviado":false},{"Momento":"2024-07-03T08:34:45.5471152-03:00","Protocolo":"DF;#544;DF;1;0.00;857.33;41.18;20.83;0;0;0;0;21.57$\r","Enviado":false},{"Momento":"2024-07-03T08:34:47.0498507-03:00","Protocolo":"DF;#544;DF;1;0.00;880.11;41.13;20.83;0;0;0;0;21.57$\r","Enviado":false},{"Momento":"2024-07-03T08:34:48.5530613-03:00","Protocolo":"DF;#544;DF;1;0.00;885.96;41.18;20.83;0;0;0;0;21.55$\r","Enviado":false},{"Momento":"2024-07-03T08:34:50.0570751-03:00","Protocolo":"DF;#544;DF;1;0.00;887.76;41.13;20.83;0;0;0;0;21.55$\r","Enviado":false},{"Momento":"2024-07-03T08:34:51.5593049-03:00","Protocolo":"DF;#544;DF;1;0.00;890.16;41.13;20.75;0;0;0;0;21.55$\r","Enviado":false},{"Momento":"2024-07-03T08:34:52.2368098-03:00","Protocolo":"@4;DF;293;Mov,1,60,0$","Enviado":true},{"Momento":"2024-07-03T08:34:52.2438165-03:00","Protocolo":"DF;655;4;$\r","Enviado":false},{"Momento":"2024-07-03T08:34:52.8771095-03:00","Protocolo":"@5;DF;293;Mov,0,0,0$","Enviado":true},{"Momento":"2024-07-03T08:34:52.8836393-03:00","Protocolo":"DF;655;5;$\r","Enviado":false},{"Momento":"2024-07-03T08:34:53.1241492-03:00","Protocolo":"DF;#544;DF;1;71.00;892.10;41.13;20.75;1;1;0;0;21.57$\r","Enviado":false},{"Momento":"2024-07-03T08:34:53.3955492-03:00","Protocolo":"@6;DF;293;Mov,2,60,0$","Enviado":true},{"Momento":"2024-07-03T08:34:53.4020702-03:00","Protocolo":"DF;655;6;$\r","Enviado":false},{"Momento":"2024-07-03T08:34:53.9123079-03:00","Protocolo":"@7;DF;293;Mov,0,0,0$","Enviado":true},{"Momento":"2024-07-03T08:34:53.9188248-03:00","Protocolo":"DF;655;7;$\r","Enviado":false},{"Momento":"2024-07-03T08:34:54.6273978-03:00","Protocolo":"DF;#544;DF;1;243.00;892.26;41.13;20.75;0;0;0;0;21.57$\r","Enviado":false},{"Momento":"2024-07-03T08:34:56.1297469-03:00","Protocolo":"DF;#544;DF;1;0.00;896.48;41.13;20.68;0;0;0;0;21.61$\r","Enviado":false},{"Momento":"2024-07-03T08:34:57.6332603-03:00","Protocolo":"DF;#544;DF;1;0.00;896.85;41.18;20.75;0;0;0;0;21.63$\r","Enviado":false},{"Momento":"2024-07-03T08:34:58.687728-03:00","Protocolo":"@8;DF;258;Mov,0,0x04,2,0,800,0,34,0,14,0,12,0,27,0,26$","Enviado":true},{"Momento":"2024-07-03T08:34:58.6987596-03:00","Protocolo":"DF;#211;Mov;0$\r","Enviado":false},{"Momento":"2024-07-03T08:34:58.7092826-03:00","Protocolo":"DF;655;8;$\r","Enviado":false},{"Momento":"2024-07-03T08:34:58.7198045-03:00","Protocolo":"@9;DF;258;DF,0,1000,0,0,1,0,3,0,17,0,16,0,4$","Enviado":true},{"Momento":"2024-07-03T08:34:58.7293252-03:00","Protocolo":"DF;655;9;$\r","Enviado":false},{"Momento":"2024-07-03T08:34:58.736838-03:00","Protocolo":"@10;DF;244;check$","Enviado":true},{"Momento":"2024-07-03T08:34:58.7438433-03:00","Protocolo":"DF;244;109;6;0;$\r","Enviado":false}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
{"Modulo_ID":"Atu","RequisitarDados":false,"Conectado":false,"QuantidadeBicos":4,"DensidadeHerbicida":1.05,"CapacidadeReservatorio":30.0,"AtuacaoNivelAlto":true,"BicosPulverizadores":[{"ID":"B01","Posicao":1,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":17.1964398137526},{"ID":"B02","Posicao":2,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":14.876485059544191},{"ID":"B03","Posicao":3,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":18.103588945512129},{"ID":"B04","Posicao":4,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":18.437319738098896}],"BombaPressurizadora":{"ID":"BOMBA","BombaAtuada":true,"Ligado":true,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[14,35,36,37,5],"PressaoSP":85.0,"Pressao":103.82,"Potencia":0.0},"Sensores":[{"LogGrafico":[],"ID":"FLXLN","Prioridade":23,"Descricao":"Fluxo na linha principal","Componente":198,"Aferir":true,"DelayAmostragem":300,"Inicializado":false,"Testando":false,"Funcoes":[25],"Parametros":[],"UnidadeMedida":"mL/s","Leituras":[0.0,0.0],"ValorMinimo":0.0,"ValorMaximo":25222.0,"LimiteMaximo":0.0,"LimiteMinimo":0.0},{"LogGrafico":[],"ID":"MASRS","Prioridade":3,"Descricao":"Massa do reservatório de herbicida","Componente":532,"Aferir":true,"DelayAmostragem":1000,"Inicializado":false,"Testando":false,"Funcoes":[22,23],"Parametros":[],"UnidadeMedida":"Kg","Leituras":[1188069.0],"ValorMinimo":-1.281631101976581E+32,"ValorMaximo":2.8836731440342142E+24,"LimiteMaximo":50.0,"LimiteMinimo":5.0},{"LogGrafico":[],"ID":"PRSLN","Prioridade":3,"Descricao":"Pressão na linha principal","Componente":333,"Aferir":true,"DelayAmostragem":1000,"Inicializado":false,"Testando":false,"Funcoes":[24],"Parametros":[["Vmin","000.00"],["Vmax","004.50"],["Pmax","174.04"]],"UnidadeMedida":"psi","Leituras":[103.82],"ValorMinimo":0.0,"ValorMaximo":127.63,"LimiteMaximo":120.0,"LimiteMinimo":60.0}],"PercentualInicioPulverizacao":0.3,"ScriptDeteccaoErvas":"weed-detector-v7.py","_MassaRef":0.8,"_MassaLeituraRef":40876.37,"_MassaLeituraExtra":1895800.0,"_MassaLeitura":1188069.0,"MassaReservatorio":13.851151655589771,"VolumeReservatorio":13.191573005323591,"PercentualReservatorio":43.9719100177453,"VolumeVazaoAferido":102.0,"_FluxoMlRef":102.0,"_FluxoPulsoRef":80.0,"_LeituraPulsos":0,"_LeituraPeriodo":0,"VazaoFluxoMLpS":0.0,"VolumeVazaoML":880.33879833854928,"_PressaoVmin":0.0,"_PressaoVmax":4.5,"_PressaoMax":174.045,"_LeituraPressao":3331.0,"PressaoLinha":103.82,"PressaoLinhaCalc":103.82064053724054}
|
||||
{"Modulo_ID":"Atu","RequisitarDados":false,"Conectado":false,"QuantidadeBicos":4,"DensidadeHerbicida":1.05,"CapacidadeReservatorio":30.0,"AtuacaoNivelAlto":true,"BicosPulverizadores":[{"ID":"B01","Posicao":1,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":17.1964398137526},{"ID":"B02","Posicao":2,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":14.876485059544191},{"ID":"B03","Posicao":3,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":18.103588945512129},{"ID":"B04","Posicao":4,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":18.437319738098896}],"BombaPressurizadora":{"ID":"BOMBA","BombaAtuada":false,"Ligado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[14,35,36,37,5],"PressaoSP":85.0,"Pressao":46.61,"Potencia":0.0},"Sensores":[{"LogGrafico":[],"ID":"FLXLN","Prioridade":23,"Descricao":"Fluxo na linha principal","Componente":198,"Aferir":true,"DelayAmostragem":300,"Inicializado":false,"Testando":false,"Funcoes":[25],"Parametros":[],"UnidadeMedida":"mL/s","Leituras":[0.0,0.0],"ValorMinimo":0.0,"ValorMaximo":25222.0,"LimiteMaximo":0.0,"LimiteMinimo":0.0},{"LogGrafico":[],"ID":"MASRS","Prioridade":3,"Descricao":"Massa do reservatório de herbicida","Componente":532,"Aferir":true,"DelayAmostragem":1000,"Inicializado":false,"Testando":false,"Funcoes":[22,23],"Parametros":[],"UnidadeMedida":"Kg","Leituras":[2010623.62],"ValorMinimo":-1.281631101976581E+32,"ValorMaximo":2.8836731440342142E+24,"LimiteMaximo":50.0,"LimiteMinimo":5.0},{"LogGrafico":[],"ID":"PRSLN","Prioridade":3,"Descricao":"Pressão na linha principal","Componente":333,"Aferir":true,"DelayAmostragem":1000,"Inicializado":true,"Testando":false,"Funcoes":[24],"Parametros":[["Vmin","000.00"],["Vmax","004.50"],["Pmax","174.04"]],"UnidadeMedida":"psi","Leituras":[46.61],"ValorMinimo":0.0,"ValorMaximo":127.63,"LimiteMaximo":120.0,"LimiteMinimo":60.0}],"PercentualInicioPulverizacao":0.3,"ScriptDeteccaoErvas":"weed-detector-v7.py","_MassaRef":0.8,"_MassaLeituraRef":40876.37,"_MassaLeituraExtra":1895800.0,"_MassaLeitura":2010623.62,"MassaReservatorio":-2.2472371201258845,"VolumeReservatorio":-2.1402258286913183,"PercentualReservatorio":-7.1340860956377279,"VolumeVazaoAferido":102.0,"_FluxoMlRef":102.0,"_FluxoPulsoRef":80.0,"_LeituraPulsos":0,"_LeituraPeriodo":0,"VazaoFluxoMLpS":0.0,"VolumeVazaoML":978.53188147416961,"_PressaoVmin":0.0,"_PressaoVmax":4.5,"_PressaoMax":174.045,"_LeituraPressao":1495.64,"PressaoLinha":46.61,"PressaoLinhaCalc":46.616122129426124}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -25,7 +25,7 @@
|
|||
<meta name="viewport" content="width=device-width,
|
||||
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<style>
|
||||
#map_487150d07168e27859c014539a529f87 {
|
||||
#map_85649393d37d95a04d4a673695a1001c {
|
||||
position: relative;
|
||||
width: 100.0%;
|
||||
height: 100.0%;
|
||||
|
|
@ -39,14 +39,14 @@
|
|||
<body>
|
||||
|
||||
|
||||
<div class="folium-map" id="map_487150d07168e27859c014539a529f87" ></div>
|
||||
<div class="folium-map" id="map_85649393d37d95a04d4a673695a1001c" ></div>
|
||||
|
||||
</body>
|
||||
<script>
|
||||
|
||||
|
||||
var map_487150d07168e27859c014539a529f87 = L.map(
|
||||
"map_487150d07168e27859c014539a529f87",
|
||||
var map_85649393d37d95a04d4a673695a1001c = L.map(
|
||||
"map_85649393d37d95a04d4a673695a1001c",
|
||||
{
|
||||
center: [0.0, 0.0],
|
||||
crs: L.CRS.EPSG3857,
|
||||
|
|
@ -60,13 +60,13 @@
|
|||
|
||||
|
||||
|
||||
var tile_layer_ce5a855eda901aed36e6d1496051253f = L.tileLayer(
|
||||
var tile_layer_a738e8dfc73e3a6f0518a4edcb353236 = L.tileLayer(
|
||||
"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}
|
||||
);
|
||||
|
||||
|
||||
tile_layer_ce5a855eda901aed36e6d1496051253f.addTo(map_487150d07168e27859c014539a529f87);
|
||||
tile_layer_a738e8dfc73e3a6f0518a4edcb353236.addTo(map_85649393d37d95a04d4a673695a1001c);
|
||||
|
||||
</script>
|
||||
|
||||
|
|
@ -87,7 +87,7 @@
|
|||
}
|
||||
trajeto_json_add({"features": []});
|
||||
|
||||
trajeto_json.addTo(map_487150d07168e27859c014539a529f87);
|
||||
trajeto_json.addTo(map_85649393d37d95a04d4a673695a1001c);
|
||||
|
||||
function adicionarGeometria(novaGeometria) {
|
||||
trajeto_json.addData(novaGeometria);
|
||||
|
|
@ -145,7 +145,7 @@
|
|||
|
||||
var marcadorDinamico = L.marker([0, 0], {
|
||||
icon: customIcon
|
||||
}).addTo(map_487150d07168e27859c014539a529f87);
|
||||
}).addTo(map_85649393d37d95a04d4a673695a1001c);
|
||||
|
||||
// Conectar ao broker MQTT
|
||||
const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexão segura
|
||||
|
|
@ -183,7 +183,7 @@
|
|||
marcadorDinamico.setRotationAngle(angulo);
|
||||
|
||||
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
|
||||
map_487150d07168e27859c014539a529f87.setView(novaPosicao, map_487150d07168e27859c014539a529f87.getZoom());
|
||||
map_85649393d37d95a04d4a673695a1001c.setView(novaPosicao, map_85649393d37d95a04d4a673695a1001c.getZoom());
|
||||
});
|
||||
|
||||
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
|
@ -277,8 +277,9 @@ String MontarDadosProtocoloSonarM(int distancias[36], int angulos[36], int posic
|
|||
}
|
||||
|
||||
|
||||
String MontarDadosProtocoloBLD(float rpm, double temperatura, double tensao, double corrente_max, bool ligado, Sentido sentido, bool freio, int codigo_alarme, double temp_driver) {
|
||||
String Protocolo =
|
||||
String MontarDadosProtocoloBLD(bool iniciado, float rpm, double temperatura, double tensao, double corrente_max, bool ligado, Sentido sentido, bool freio, int codigo_alarme, double temp_driver) {
|
||||
String Protocolo = (String)"" +
|
||||
(iniciado ? "1" : "0") + SplitMessage +
|
||||
(String)rpm + SplitMessage +
|
||||
(String)temperatura + SplitMessage +
|
||||
(String)tensao + SplitMessage +
|
||||
|
|
|
|||
|
|
@ -0,0 +1,476 @@
|
|||
// Dispositivo: Movimentação e Direcional Unificados
|
||||
// Versão Firmware: 6
|
||||
// Ultima atualização: 01/07/2024
|
||||
// Atualização: Removido dados do motor de passo
|
||||
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\ModbusService.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\utils.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\Pinout.h"
|
||||
#include <SimpleKalmanFilter.h>
|
||||
|
||||
#define D_Code Mvd
|
||||
#define VERSION 6
|
||||
String Mod_ID = "";
|
||||
|
||||
#define _pinoAddr0 36
|
||||
#define _pinoAddr1 39
|
||||
|
||||
int _pinModbusRX = 16;
|
||||
int _pinModbusTX = 17;
|
||||
int _pinModbusMD = 4;
|
||||
|
||||
void AtualizarEnderecoModulo() {
|
||||
bool A0 = digitalRead(_pinoAddr0) == 1;
|
||||
bool A1 = digitalRead(_pinoAddr1) == 1;
|
||||
|
||||
if (!A0 && !A1) {
|
||||
Mod_ID = "ET";
|
||||
}
|
||||
else if (A0 && !A1) {
|
||||
Mod_ID = "EF";
|
||||
}
|
||||
else if (!A0 && A1) {
|
||||
Mod_ID = "DT";
|
||||
}
|
||||
else if (A0 && A1) {
|
||||
Mod_ID = "DF";
|
||||
}
|
||||
}
|
||||
|
||||
long _baudRate = 115200;
|
||||
volatile bool Conectado = false;
|
||||
volatile int _TaxaAmostragem = 500;
|
||||
volatile bool RequisitarDados = false;
|
||||
|
||||
|
||||
class MotorBLDC {
|
||||
public:
|
||||
String _ID = "Mov";
|
||||
int _canal = 4;
|
||||
|
||||
volatile bool Iniciado = false;
|
||||
bool Testando = false;
|
||||
|
||||
PinoModel _pinoEN;
|
||||
PinoModel _pinoFR;
|
||||
PinoModel _pinoSV;
|
||||
PinoModel _pinoBK;
|
||||
|
||||
PinoModel _pinoTMP;
|
||||
SimpleKalmanFilter tempKalman = SimpleKalmanFilter(2, 2, 0.01);
|
||||
|
||||
byte _endereco;
|
||||
int _numPolos;
|
||||
int _rampa;
|
||||
int _rpmMax;
|
||||
|
||||
// Consumo
|
||||
double RPM;
|
||||
double RPM_SP;
|
||||
double Temperatura;
|
||||
double TemperaturaDriver;
|
||||
double Tensao;
|
||||
double CorrenteMax;
|
||||
bool Ligado;
|
||||
bool Freio;
|
||||
Sentido _Sentido = Parado;
|
||||
int CodAlarme;
|
||||
|
||||
// Entrada de dados
|
||||
double _RPM_SP;
|
||||
bool _Ligado = false;
|
||||
bool _Freio = false;
|
||||
Sentido _SentidoSP = Parado;
|
||||
|
||||
volatile bool ComandoEnviado = false;
|
||||
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
Iniciado = ConfigurarDriver();
|
||||
|
||||
if (_pinoEN.Definido()) {
|
||||
_pinoEN.Conectar(true);
|
||||
}
|
||||
if (_pinoFR.Definido()) {
|
||||
_pinoFR.Conectar();
|
||||
}
|
||||
if (_pinoBK.Definido()) {
|
||||
_pinoBK.Conectar(true);
|
||||
}
|
||||
if (_pinoSV.Definido()) {
|
||||
AtualizarPWM();
|
||||
}
|
||||
|
||||
if (_pinoTMP.Definido()) {
|
||||
_pinoTMP.Conectar();
|
||||
}
|
||||
|
||||
if (Iniciado) {
|
||||
AtualizarDadosControle(true);
|
||||
}
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
//EnviarDadosSerial(Mod_ID, _ID + " nao esta inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Parar a execução das tarefas
|
||||
//vTaskDelete(MovTaskHandle);
|
||||
|
||||
// Redefinir as configurações para os valores iniciais
|
||||
_pinoEN.Desconectar();
|
||||
_pinoFR.Desconectar();
|
||||
_pinoSV.Desconectar();
|
||||
_pinoBK.Desconectar();
|
||||
_pinoTMP.Desconectar();
|
||||
|
||||
//EnviarDadosSerial(Mod_ID, _ID + " Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
|
||||
AtualizarDadosControle(true);
|
||||
}
|
||||
|
||||
void AtualizarDadosControle(bool reset = false) {
|
||||
if (!Iniciado) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (reset) {
|
||||
_Ligado = false;
|
||||
_Freio = false;
|
||||
_SentidoSP = Parado;
|
||||
_RPM_SP = 0;
|
||||
}
|
||||
|
||||
int val = map(_RPM_SP, 0, _rpmMax, 0, 1023);
|
||||
ledcWrite(_canal, val);
|
||||
_pinoFR.set(_SentidoSP == Horario ? false : true);
|
||||
_pinoBK.set(!_Freio);
|
||||
_pinoEN.set(!_Ligado);
|
||||
|
||||
|
||||
/*ComandoEnviado = true;
|
||||
EnviarComandoModbus(_endereco, 0x06, 0x006D, _SentidoSP == Horario ? 1 : 0, false);
|
||||
EnviarComandoModbus(_endereco, 0x06, 0x0056, _RPM_SP, false);
|
||||
EnviarComandoModbus(_endereco, 0x06, 0x006A, _Freio ? 1 : 0, false);
|
||||
EnviarComandoModbus(_endereco, 0x06, 0x0066, _Ligado ? 1 : 0, false);
|
||||
vTaskDelay(100);
|
||||
ComandoEnviado = false;*/
|
||||
}
|
||||
|
||||
void RequisitarDados() {
|
||||
AferirDadosDriver();
|
||||
AferirTemperatura();
|
||||
|
||||
//EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sBLD, _ID, MontarDadosProtocoloBLD(RPM, Temperatura, Tensao, CorrenteMax, Ligado, _Sentido, Freio, CodAlarme, TemperaturaDriver)));
|
||||
}
|
||||
|
||||
private:
|
||||
ModbusGetResponse EnviarComandoModbus(byte endereco, byte funcao, byte registro, int valor, bool aguardarResposta = true) {
|
||||
const int maxTentativas = 2;
|
||||
int tentativas = 0;
|
||||
bool sucesso = false;
|
||||
ModbusGetResponse resposta;
|
||||
|
||||
while (tentativas < maxTentativas && !sucesso) {
|
||||
uint8_t response[256];
|
||||
uint8_t length = 0;
|
||||
|
||||
sendModbusCommand(endereco, funcao, registro, valor, response, length, aguardarResposta);
|
||||
|
||||
if (aguardarResposta) {
|
||||
if (funcao == 0x03) {
|
||||
if (length >= 5) {
|
||||
resposta._success = true;
|
||||
resposta._address = response[0];
|
||||
resposta._command_code = response[1];
|
||||
resposta._num_registers = response[2];
|
||||
|
||||
if (resposta._num_registers == 2) {
|
||||
uint16_t value = (response[3] << 8) | response[4];
|
||||
resposta._value = static_cast<double>(value);
|
||||
sucesso = true;
|
||||
} else if (resposta._num_registers == 4 && length >= 7) {
|
||||
uint16_t highBytes = (response[3] << 8) | response[4];
|
||||
uint16_t lowBytes = (response[5] << 8) | response[6];
|
||||
|
||||
// Combinar os bytes de alta e baixa ordem em um valor de 32 bits
|
||||
uint32_t combined = (static_cast<uint32_t>(highBytes) << 16) | lowBytes;
|
||||
|
||||
// Reinterpretar o valor combinado como um float
|
||||
float floatValue;
|
||||
memcpy(&floatValue, &combined, sizeof(floatValue));
|
||||
|
||||
resposta._value = static_cast<double>(floatValue);
|
||||
|
||||
sucesso = true;
|
||||
} else {
|
||||
resposta._success = false;
|
||||
}
|
||||
} else {
|
||||
resposta._success = false;
|
||||
}
|
||||
} else if (funcao == 0x06) {
|
||||
if (length >= 8) {
|
||||
resposta._success = true;
|
||||
resposta._address = response[0];
|
||||
resposta._command_code = response[1];
|
||||
resposta._num_registers = 0;
|
||||
resposta._value = (response[4] << 8) | response[5];
|
||||
sucesso = true;
|
||||
} else {
|
||||
Serial.println("Erro ao enviar comando");
|
||||
resposta._success = false;
|
||||
}
|
||||
}
|
||||
|
||||
tentativas++;
|
||||
} else {
|
||||
sucesso = true;
|
||||
resposta._success = sucesso;
|
||||
}
|
||||
}
|
||||
|
||||
return resposta;
|
||||
}
|
||||
|
||||
bool ConfigurarDriver() {
|
||||
ModbusGetResponse a = EnviarComandoModbus(_endereco, 0x06, 0x00B6, 1);
|
||||
if (a._success) {
|
||||
ModbusGetResponse b = EnviarComandoModbus(_endereco, 0x06, 0x0076, 0);
|
||||
if (b._success) {
|
||||
ModbusGetResponse c = EnviarComandoModbus(_endereco, 0x06, 0x0086, _numPolos);
|
||||
if (c._success) {
|
||||
ModbusGetResponse d = EnviarComandoModbus(_endereco, 0x06, 0x008A, _rampa);
|
||||
if (d._success) {
|
||||
ModbusGetResponse e = EnviarComandoModbus(_endereco, 0x06, 0x0092, _rpmMax);
|
||||
if (e._success) {
|
||||
ModbusGetResponse f = EnviarComandoModbus(_endereco, 0x06, 0x00B6, 0);
|
||||
return f._success;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AferirDadosDriver() {
|
||||
AguardaEnvioComando();
|
||||
RPM_SP = EnviarComandoModbus(_endereco, 0x03, 0x0056, 1)._value;
|
||||
AguardaEnvioComando();
|
||||
RPM = EnviarComandoModbus(_endereco, 0x03, 0x005F, 1)._value;
|
||||
AguardaEnvioComando();
|
||||
Ligado = EnviarComandoModbus(_endereco, 0x03, 0x0066, 1)._value == 1;
|
||||
AguardaEnvioComando();
|
||||
Freio = EnviarComandoModbus(_endereco, 0x03, 0x006A, 1)._value == 1;
|
||||
AguardaEnvioComando();
|
||||
_Sentido = Ligado ? EnviarComandoModbus(_endereco, 0x03, 0x006D, 1)._value == 1 ? Horario : Antihorario : Parado;
|
||||
AguardaEnvioComando();
|
||||
CodAlarme = EnviarComandoModbus(_endereco, 0x03, 0x0076, 1)._value;
|
||||
AguardaEnvioComando();
|
||||
Tensao = EnviarComandoModbus(_endereco, 0x03, 0x00C8, 2)._value;
|
||||
AguardaEnvioComando();
|
||||
CorrenteMax = EnviarComandoModbus(_endereco, 0x03, 0x0096, 2)._value;
|
||||
AguardaEnvioComando();
|
||||
TemperaturaDriver = EnviarComandoModbus(_endereco, 0x03, 0x00D2, 2)._value;
|
||||
}
|
||||
|
||||
void AferirTemperatura() {
|
||||
int leitura = _pinoTMP.get();
|
||||
float leituraNormalizada = tempKalman.updateEstimate(leitura);
|
||||
Temperatura = leituraNormalizada;
|
||||
}
|
||||
|
||||
void AguardaEnvioComando() {
|
||||
while (ComandoEnviado) {
|
||||
vTaskDelay(50);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MotorBLDC MotorMOV;
|
||||
|
||||
void AtualizarPWM() {
|
||||
if (MotorMOV.Iniciado && MotorMOV._pinoSV.Definido()) {
|
||||
ledcSetup(MotorMOV._canal, 1000, 10);
|
||||
ledcAttachPin(MotorMOV._pinoSV.num, MotorMOV._canal);
|
||||
ledcWrite(MotorMOV._canal, MotorMOV._RPM_SP);
|
||||
}
|
||||
}
|
||||
|
||||
void SensoriamentoTask(void *pvParameters);
|
||||
TaskHandle_t SensoriamentoTaskHandle = NULL;
|
||||
|
||||
void setup() {
|
||||
pinMode(_pinoAddr0, INPUT);
|
||||
pinMode(_pinoAddr1, INPUT);
|
||||
|
||||
AtualizarEnderecoModulo();
|
||||
|
||||
Serial.begin(_baudRate, SERIAL_8N1, 1, 3);
|
||||
//Serial.begin(_baudRate);
|
||||
|
||||
analogReadResolution(10);
|
||||
|
||||
delay(10);
|
||||
|
||||
ConfigurarModbus(true, _pinModbusRX, _pinModbusTX, _pinModbusMD);
|
||||
|
||||
delay(10);
|
||||
|
||||
if (xTaskCreatePinnedToCore(SensoriamentoTask, "SensoriamentoTask", 8000, NULL, 5, &SensoriamentoTaskHandle, tskNO_AFFINITY) != pdPASS) {
|
||||
Serial.println("Erro ao criar tarefa SensoriamentoTask");
|
||||
}
|
||||
}
|
||||
|
||||
void SensoriamentoTask(void *pvParameters) {
|
||||
while (1)
|
||||
{
|
||||
Conectado = MotorMOV.Iniciado;
|
||||
|
||||
if (!RequisitarDados && Conectado) {
|
||||
ProcessarReq();
|
||||
}
|
||||
vTaskDelay(_TaxaAmostragem);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
std::vector<ProtocoloSerial> protocolos = LerBufferSerialFila(Mod_ID);
|
||||
|
||||
for (int i = 0; i < protocolos.size(); i++) {
|
||||
ProcessarProtocolo(protocolos[i]);
|
||||
}
|
||||
|
||||
delay(1);
|
||||
}
|
||||
|
||||
void ProcessarProtocolo(ProtocoloSerial Mensagem) {
|
||||
switch (Mensagem.funcao) {
|
||||
case Chk:
|
||||
ProcessarChk(Mensagem);
|
||||
break;
|
||||
case Cfg:
|
||||
ProcessarCfg(Mensagem);
|
||||
break;
|
||||
case Cmd:
|
||||
ProcessarCmd(Mensagem);
|
||||
break;
|
||||
case Req:
|
||||
ProcessarReq();
|
||||
break;
|
||||
}
|
||||
|
||||
if (Mensagem.idMensagem > 0) {
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloMensagemRecebida(Mensagem.idMensagem));
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarChk(ProtocoloSerial Mensagem) {
|
||||
Conectado = MotorMOV.Iniciado;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloVerificacao(D_Code, VERSION, Conectado));
|
||||
}
|
||||
|
||||
void ProcessarCfg(ProtocoloSerial Mensagem) {
|
||||
std::vector<String> Partes = SplitString(Mensagem.protocolo, SplitParams);
|
||||
|
||||
String ID = Partes[0];
|
||||
bool Conectar = Partes[1] == "1";
|
||||
|
||||
if (ID == Mod_ID) {
|
||||
_TaxaAmostragem = Partes[2].toInt();
|
||||
RequisitarDados = Partes[3].toInt();
|
||||
TiposBarramentos txB = (TiposBarramentos)Partes[4].toInt();
|
||||
int txP = Partes[5].toInt();
|
||||
TiposBarramentos rxB = (TiposBarramentos)Partes[6].toInt();
|
||||
int rxP = Partes[7].toInt();
|
||||
TiposBarramentos MtxB = (TiposBarramentos)Partes[8].toInt();
|
||||
int MtxP = Partes[9].toInt();
|
||||
TiposBarramentos MrxB = (TiposBarramentos)Partes[10].toInt();
|
||||
int MrxP = Partes[11].toInt();
|
||||
TiposBarramentos MmdB = (TiposBarramentos)Partes[12].toInt();
|
||||
int MmdP = Partes[13].toInt();
|
||||
_pinModbusMD = MmdP;
|
||||
_pinModbusRX = MrxP;
|
||||
_pinModbusTX = MtxP;
|
||||
|
||||
//ConfigurarModbus(Conectar, _pinModbusRX, _pinModbusTX, _pinModbusMD);
|
||||
}
|
||||
else if (ID == MotorMOV._ID) {
|
||||
if (Conectar) {
|
||||
MotorMOV._endereco = stringToByte(Partes[2]);
|
||||
MotorMOV._numPolos = Partes[3].toInt();
|
||||
MotorMOV._rampa = Partes[4].toInt();
|
||||
MotorMOV._rpmMax = Partes[5].toInt();
|
||||
MotorMOV._pinoTMP = PinoModel(Partes[7].toInt(), (TiposBarramentos)Partes[6].toInt(), _INPUT, ANALOGICO);
|
||||
MotorMOV._pinoEN = PinoModel(Partes[9].toInt(), (TiposBarramentos)Partes[8].toInt(), _OUTPUT);
|
||||
MotorMOV._pinoFR = PinoModel(Partes[11].toInt(), (TiposBarramentos)Partes[10].toInt(), _OUTPUT);
|
||||
MotorMOV._pinoSV = PinoModel(Partes[13].toInt(), (TiposBarramentos)Partes[12].toInt(), _PWM);
|
||||
MotorMOV._pinoBK = PinoModel(Partes[15].toInt(), (TiposBarramentos)Partes[14].toInt(), _OUTPUT);
|
||||
|
||||
MotorMOV.Inicializar();
|
||||
}
|
||||
else {
|
||||
MotorMOV.Desligar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarCmd(ProtocoloSerial Mensagem) {
|
||||
std::vector<String> Partes = SplitString(Mensagem.protocolo, SplitParams);
|
||||
|
||||
String ID = Partes[0];
|
||||
|
||||
if (ID == MotorMOV._ID && MotorMOV.Iniciado) {
|
||||
MotorMOV._SentidoSP = (Sentido)Partes[1].toInt();
|
||||
MotorMOV._Ligado = MotorMOV._SentidoSP != Parado;
|
||||
MotorMOV._RPM_SP = Partes[2].toInt();
|
||||
MotorMOV._Freio = Partes[3] == "1";
|
||||
|
||||
MotorMOV.AtualizarDadosControle();
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarReq() {
|
||||
//std::vector<String> Partes = SplitString(Mensagem.protocolo, SplitParams);
|
||||
//Serial.println("Processando req...");
|
||||
if (MotorMOV.Iniciado) {
|
||||
MotorMOV.RequisitarDados();
|
||||
}
|
||||
|
||||
if (MotorMOV.Iniciado) {
|
||||
//Serial.println("Enviando dados...");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sBLD, Mod_ID, MontarDadosProtocoloBLD(
|
||||
MotorMOV.Iniciado,
|
||||
MotorMOV.RPM,
|
||||
MotorMOV.Temperatura,
|
||||
MotorMOV.Tensao,
|
||||
MotorMOV.CorrenteMax,
|
||||
MotorMOV.Ligado,
|
||||
MotorMOV._Sentido,
|
||||
MotorMOV.Freio,
|
||||
MotorMOV.CodAlarme,
|
||||
MotorMOV.TemperaturaDriver
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// Dispositivo: Sensoriamento
|
||||
// Versão Firmware: 9
|
||||
// Ultima atualização: 28/06/2024
|
||||
// Ultima atualização: 01/07/2024
|
||||
// Atualização: Atualizado protocolo de comunicação padrão
|
||||
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
|
||||
|
|
@ -254,14 +254,22 @@ class SensorCorrente {
|
|||
return;
|
||||
}
|
||||
if (_Endereco > 0x00) {
|
||||
if (_INA == 219) {
|
||||
sINA219 = new Adafruit_INA219(_Endereco);
|
||||
Iniciado = sINA219->begin();
|
||||
Wire.beginTransmission(_Endereco);
|
||||
byte error = Wire.endTransmission();
|
||||
if (error == 0) {
|
||||
if (_INA == 219) {
|
||||
sINA219 = new Adafruit_INA219(_Endereco);
|
||||
Iniciado = sINA219->begin();
|
||||
}
|
||||
else if (_INA == 226) {
|
||||
sINA226 = new INA226(_Endereco);
|
||||
Iniciado = sINA226->begin();
|
||||
sINA226->setMaxCurrentShunt(1, 0.002);
|
||||
}
|
||||
}
|
||||
else if (_INA == 226) {
|
||||
sINA226 = new INA226(_Endereco);
|
||||
Iniciado = sINA226->begin();
|
||||
sINA226->setMaxCurrentShunt(1, 0.002);
|
||||
else {
|
||||
Iniciado = false;
|
||||
EnviarDadosSerial(Mod_ID, _ID + " não iniciado, endereço " + _Endereco + " não encontrado!");
|
||||
}
|
||||
|
||||
if (Iniciado) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
import cv2
|
||||
import os
|
||||
import numpy as np
|
||||
|
||||
def process_image(image_path, output_image_path, output_label_path):
|
||||
# Carregar a imagem
|
||||
image = cv2.imread(image_path)
|
||||
|
||||
# Converter para escala de cinza
|
||||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
|
||||
# Aplicar blur para reduzir o ruído
|
||||
blurred = cv2.GaussianBlur(gray, (5, 5), 0)
|
||||
|
||||
# Aplicar a detecção de borda (Canny)
|
||||
edges = cv2.Canny(blurred, 50, 150)
|
||||
|
||||
# Encontrar contornos
|
||||
contours, _ = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
||||
|
||||
# Encontrar a maior área de contorno, assumindo que é a erva daninha
|
||||
if contours:
|
||||
contour = max(contours, key=cv2.contourArea)
|
||||
|
||||
# Obter a caixa delimitadora da erva daninha
|
||||
x, y, w, h = cv2.boundingRect(contour)
|
||||
|
||||
# Desenhar a caixa delimitadora na imagem para visualização
|
||||
cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)
|
||||
|
||||
# Salvar a imagem com a caixa delimitadora
|
||||
cv2.imwrite(output_image_path, image)
|
||||
|
||||
# Normalizar as coordenadas
|
||||
height, width = image.shape[:2]
|
||||
x_center = (x + x + w) / 2 / width
|
||||
y_center = (y + y + h) / 2 / height
|
||||
bbox_width = w / width
|
||||
bbox_height = h / height
|
||||
|
||||
# Classe (por exemplo, 0 se for a primeira classe)
|
||||
class_id = 0
|
||||
|
||||
# Escrever o label no formato YOLO
|
||||
label = f"{class_id} {x_center:.6f} {y_center:.6f} {bbox_width:.6f} {bbox_height:.6f}"
|
||||
print(f"Label for {image_path}: {label}")
|
||||
|
||||
# Salvar o label em um arquivo .txt
|
||||
with open(output_label_path, 'w') as f:
|
||||
f.write(label)
|
||||
else:
|
||||
print(f"No contours found for {image_path}")
|
||||
|
||||
def process_images(input_dir, output_dir):
|
||||
if not os.path.exists(output_dir):
|
||||
os.makedirs(output_dir)
|
||||
|
||||
for filename in os.listdir(input_dir):
|
||||
if filename.endswith(".jpg"):
|
||||
image_path = os.path.join(input_dir, filename)
|
||||
output_image_path = os.path.join(output_dir, filename)
|
||||
output_label_path = os.path.join(output_dir, filename.replace('.jpg', '.txt'))
|
||||
|
||||
process_image(image_path, output_image_path, output_label_path)
|
||||
|
||||
input_dir = 'C:\\Users\\USER\\Downloads\\weed-datasets-master\\corn weed datasets\\bluegrass' # Substitua pelo caminho da sua pasta de entrada
|
||||
output_dir = 'C:\\train\\yolov7\\train\\new_ervas\\dataset\\images\\train' # Substitua pelo caminho da sua pasta de saída
|
||||
|
||||
process_images(input_dir, output_dir)
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
import os
|
||||
import requests
|
||||
from PIL import Image, ImageDraw
|
||||
import numpy as np
|
||||
import json
|
||||
|
||||
# Função para enviar requisição para o ChatGPT e obter a resposta
|
||||
def get_gpt_response(image_path):
|
||||
# Dados do formulário
|
||||
form = {
|
||||
"model": "gpt-3.5-turbo",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Identify the weed in this image, returning just label in yolov7 format",
|
||||
}
|
||||
]
|
||||
}
|
||||
formData = json.dumps(form)
|
||||
|
||||
# Abrir a imagem como arquivo binário
|
||||
with open(image_path, 'rb') as f:
|
||||
image_data = f.read()
|
||||
|
||||
# Configuração da requisição
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer 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",
|
||||
}
|
||||
url = "https://api.openai.com/v1/chat/completions"
|
||||
|
||||
# Fazendo a requisição POST
|
||||
response = requests.post(url, headers=headers, data=formData)
|
||||
|
||||
if response.status_code == 200:
|
||||
return response.json()['choices'][0]['message']['content']
|
||||
else:
|
||||
print(f"Erro ao obter resposta do ChatGPT: {response.status_code}")
|
||||
try:
|
||||
error_data = response.json()
|
||||
print(error_data)
|
||||
except ValueError:
|
||||
print("Resposta inválida do servidor")
|
||||
return None
|
||||
|
||||
# Função para gerar arquivo de rótulos no formato YOLOv7
|
||||
def generate_yolov7_label(label_file, class_name, bbox_coords, image_size):
|
||||
x_center = bbox_coords[0] + bbox_coords[2] / 2.0
|
||||
y_center = bbox_coords[1] + bbox_coords[3] / 2.0
|
||||
width = bbox_coords[2]
|
||||
height = bbox_coords[3]
|
||||
|
||||
x_center /= image_size[0]
|
||||
y_center /= image_size[1]
|
||||
width /= image_size[0]
|
||||
height /= image_size[1]
|
||||
|
||||
with open(label_file, 'w') as f:
|
||||
f.write(f"{class_name} {x_center:.6f} {y_center:.6f} {width:.6f} {height:.6f}\n")
|
||||
|
||||
# Função para desenhar o bbox na imagem
|
||||
def draw_bbox(image_path, bbox_coords, output_image_path):
|
||||
image = Image.open(image_path)
|
||||
draw = ImageDraw.Draw(image)
|
||||
draw.rectangle(bbox_coords, outline='red', width=3)
|
||||
image.save(output_image_path)
|
||||
|
||||
# Pasta de entrada e saída
|
||||
input_folder = 'imagens/'
|
||||
output_folder = 'saida/'
|
||||
|
||||
# Iterar sobre todas as imagens na pasta de entrada
|
||||
for filename in os.listdir(input_folder):
|
||||
if filename.endswith('.jpg') or filename.endswith('.png'):
|
||||
image_path = os.path.join(input_folder, filename)
|
||||
output_label_file = os.path.join(output_folder, f"{os.path.splitext(filename)[0]}.txt")
|
||||
output_image_path = os.path.join(output_folder, filename)
|
||||
|
||||
# Obter rótulo do ChatGPT
|
||||
label = get_gpt_response(image_path)
|
||||
|
||||
print(label)
|
||||
|
||||
# Suponha que o ChatGPT retorna algo como "weed: dandelion, bbox: [x, y, width, height]"
|
||||
if label.startswith("weed:"):
|
||||
parts = label.split(',')
|
||||
class_name = parts[0].split(':')[1].strip()
|
||||
bbox_coords = list(map(int, parts[1].split(':')[1].strip()[1:-1].split()))
|
||||
|
||||
# Gerar arquivo de rótulo YOLOv7
|
||||
image_size = Image.open(image_path).size
|
||||
generate_yolov7_label(output_label_file, class_name, bbox_coords, image_size)
|
||||
|
||||
# Desenhar o bbox na imagem
|
||||
draw_bbox(image_path, bbox_coords, output_image_path)
|
||||
|
||||
print(f"Processado: {filename}")
|
||||
else:
|
||||
print(f"Não foi possível identificar a erva em: {filename}")
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 223 KiB |
Loading…
Reference in New Issue