inclusao do driver BLD300R ao modulo de movimentacao

This commit is contained in:
Diego Freitas 2024-06-03 20:05:50 -03:00
parent 49fafae50e
commit 28db8a77b5
58 changed files with 2958 additions and 1158 deletions

View File

@ -1,5 +1,10 @@
{
"files.associations": {
"vector": "cpp"
"vector": "cpp",
"deque": "cpp",
"initializer_list": "cpp",
"list": "cpp",
"xstring": "cpp",
"xutility": "cpp"
}
}

Binary file not shown.

View File

@ -1,12 +1,37 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\ZendionINC\\agrobot_base\\AgroBase\\",
"Documents": [],
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|c:\\zendioninc\\agrobot_base\\agrobase\\agrobase\\models\\modules\\pinoutmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{C54B41C0-1D21-4E3E-949E-0F86BBC86A33}|AgroBase\\AgroBase.csproj|solutionrelative:agrobase\\models\\modules\\pinoutmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": []
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "PinoutModel.cs",
"DocumentMoniker": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\PinoutModel.cs",
"RelativeDocumentMoniker": "AgroBase\\Models\\Modules\\PinoutModel.cs",
"ToolTip": "C:\\ZendionINC\\agrobot_base\\AgroBase\\AgroBase\\Models\\Modules\\PinoutModel.cs",
"RelativeToolTip": "AgroBase\\Models\\Modules\\PinoutModel.cs",
"ViewState": "AQIAAA0AAAAAAAAAAAAzwLYAAABFAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-06-03T22:54:24.905Z",
"EditorCaption": ""
}
]
}
]
}
]
}

File diff suppressed because one or more lines are too long

View File

@ -205,6 +205,12 @@
<Compile Include="Forms\Atuador\frmAtuCamera.Designer.cs">
<DependentUpon>frmAtuCamera.cs</DependentUpon>
</Compile>
<Compile Include="Forms\frmBLD.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\frmBLD.Designer.cs">
<DependentUpon>frmBLD.cs</DependentUpon>
</Compile>
<Compile Include="Forms\frmGPS.cs">
<SubType>Form</SubType>
</Compile>
@ -338,6 +344,7 @@
<DependentUpon>frmSonar.cs</DependentUpon>
</Compile>
<Compile Include="Models\AlarmeModel.cs" />
<Compile Include="Models\BLD300RModel.cs" />
<Compile Include="Models\CameraCaminhoModel.cs" />
<Compile Include="Models\CameraModel.cs" />
<Compile Include="Models\CameraSoloModel.cs" />
@ -428,6 +435,7 @@
<Compile Include="Models\SonarModel.cs" />
<Compile Include="Models\Variaveis.cs" />
<Compile Include="Services\APIService.cs" />
<Compile Include="Services\BLD300RService.cs" />
<Compile Include="Services\CameraService.cs" />
<Compile Include="Services\CoulombCounterService.cs" />
<Compile Include="Services\DispositivosService.cs" />
@ -446,9 +454,11 @@
<Compile Include="Services\LoRaSerializer.cs" />
<Compile Include="Services\LoRaService.cs" />
<Compile Include="Services\MapasService.cs" />
<Compile Include="Services\ModbusService.cs" />
<Compile Include="Services\MqttService.cs" />
<Compile Include="Services\PythonService.cs" />
<Compile Include="Services\PZEMService.cs" />
<Compile Include="Services\RS485Service.cs" />
<Compile Include="Services\SerialService.cs" />
<Compile Include="Services\SocketService.cs" />
<Compile Include="Services\WT901CService.cs" />
@ -624,6 +634,9 @@
<EmbeddedResource Include="Forms\Atuador\frmAtuCamera.resx">
<DependentUpon>frmAtuCamera.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\frmBLD.resx">
<DependentUpon>frmBLD.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\frmGPS.resx">
<DependentUpon>frmGPS.cs</DependentUpon>
</EmbeddedResource>

View File

@ -71,6 +71,10 @@ namespace AgroBase.Forms.IHM
{
DispositivoConectado = WT901CService.Iniciado;
}
else if (Modulo.Dispositivo == T_Code.Bld)
{
DispositivoConectado = BLD300RService.Iniciado;
}
else
{
IDispositivosService dispositivoService = Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == Modulo.Dispositivo && x._Porta.PortName == Modulo.PortaCOM);

File diff suppressed because it is too large Load Diff

View File

@ -21,17 +21,8 @@ namespace AgroBase.Forms.Movimentacao
private void frmMovConfig_Load(object sender, EventArgs e)
{
nudRampaMin.Value = MovimentacaoModel.RampaMin;
nudRampaMax.Value = MovimentacaoModel.RampaMax;
nudPPR.Value = MovimentacaoModel.PulsosPorRevolucao;
nudDelayBalancemaneto.Value = MovimentacaoModel._DelayBalanceamento;
nudMargemRPM.Value = MovimentacaoModel._MargemRPM;
nudMaxOffsetRPM.Value = MovimentacaoModel._MaxOffsetRPM;
chbMalhaFechada.Checked = MovimentacaoModel._FOC;
txtKd.Text = MovimentacaoModel.Kd.ToString();
txtKp.Text = MovimentacaoModel.Kp.ToString();
txtKi.Text = MovimentacaoModel.Ki.ToString();
nudDiametroRoda.Value = Convert.ToInt32(MovimentacaoModel.DiametroRoda * 1000);
if (Disp == null)
{
return;
@ -66,12 +57,22 @@ namespace AgroBase.Forms.Movimentacao
}
cmb.SelectedItem = Enum.GetName(typeof(Sentido), sentido);
nudNumPolos.Value = Motor.NumeroPolos;
nudRampa.Value = Motor.Rampa;
nudRPMMax.Value = Motor.RPM_Max;
}
}
}
private void btnSalvarSentido_Click(object sender, EventArgs e)
private void frmMovConfig_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
this.Visible = false;
}
private void btnSalvar_Click(object sender, EventArgs e)
{
var cmbsSentido = gpbET.Controls.OfType<ComboBox>().ToList().Union(gpbEF.Controls.OfType<ComboBox>().ToList()).Union(gpbDT.Controls.OfType<ComboBox>().ToList()).Union(gpbDF.Controls.OfType<ComboBox>().ToList()).ToList();
foreach (var cmb in cmbsSentido)
@ -96,80 +97,34 @@ namespace AgroBase.Forms.Movimentacao
{
Motor.ConfigSentidos.Direita = sentido;
}
Motor.NumeroPolos = MovimentacaoModel.NumPolos;
Motor.Rampa = MovimentacaoModel.Rampa;
Motor.RPM_Max = MovimentacaoModel.RPM_Max;
}
}
Disp.SalvarParametros(Disp.Dados);
}
private void frmMovConfig_FormClosing(object sender, FormClosingEventArgs e)
private void nudRampa_ValueChanged(object sender, EventArgs e)
{
e.Cancel = true;
this.Visible = false;
MovimentacaoModel.Rampa = Convert.ToInt32(nudRampa.Value);
}
private void chbMalhaFechada_CheckedChanged(object sender, EventArgs e)
private void nudNumPolos_ValueChanged(object sender, EventArgs e)
{
MovimentacaoModel._FOC = chbMalhaFechada.Checked;
txtKp.Enabled = MovimentacaoModel._FOC;
txtKi.Enabled = MovimentacaoModel._FOC;
txtKd.Enabled = MovimentacaoModel._FOC;
btnSalvarPID.Enabled = MovimentacaoModel._FOC;
MovimentacaoModel.NumPolos = Convert.ToInt32(nudNumPolos.Value);
}
private void btnSalvarPID_Click(object sender, EventArgs e)
private void nudRPMMax_ValueChanged(object sender, EventArgs e)
{
if (btnSalvarPID.Text == "Editar")
{
btnSalvarPID.Text = "Salvar";
}
else
{
btnSalvarPID.Text = "Editar";
if (double.TryParse(txtKp.Text, out double kp))
{
MovimentacaoModel.Kp = kp;
}
if (double.TryParse(txtKi.Text, out double ki))
{
MovimentacaoModel.Ki = ki;
}
if (double.TryParse(txtKd.Text, out double kd))
{
MovimentacaoModel.Kd = kd;
}
}
gpbPID.Enabled = btnSalvarPID.Text == "Salvar";
MovimentacaoModel.RPM_Max = Convert.ToInt32(nudRPMMax.Value);
}
private void nudRampaMin_ValueChanged(object sender, EventArgs e)
private void nudDiametroRoda_ValueChanged(object sender, EventArgs e)
{
MovimentacaoModel.RampaMin = Convert.ToInt32(nudRampaMin.Value);
}
private void nudRampaMax_ValueChanged(object sender, EventArgs e)
{
MovimentacaoModel.RampaMax = Convert.ToInt32(nudRampaMax.Value);
}
private void nudPPR_ValueChanged(object sender, EventArgs e)
{
MovimentacaoModel.PulsosPorRevolucao = Convert.ToInt32(nudPPR.Value);
}
private void nudDelayBalancemaneto_ValueChanged(object sender, EventArgs e)
{
MovimentacaoModel._DelayBalanceamento = Convert.ToInt32(nudDelayBalancemaneto.Value);
}
private void nudMargemRPM_ValueChanged(object sender, EventArgs e)
{
MovimentacaoModel._MargemRPM = Convert.ToInt32(nudMargemRPM.Value);
}
private void nudMaxOffsetRPM_ValueChanged(object sender, EventArgs e)
{
MovimentacaoModel._MaxOffsetRPM = Convert.ToInt32(nudMaxOffsetRPM.Value);
MovimentacaoModel.DiametroRoda = Convert.ToInt32(nudDiametroRoda.Value) / 1000;
}
}
}

View File

@ -70,20 +70,6 @@ namespace AgroBase.Forms
Minimo = Logs.Min(x => x.RPM) < Minimo ? Logs.Min(x => x.RPM) : Minimo;
Maximo = Logs.Max(x => x.RPM) > Maximo ? Logs.Max(x => x.RPM) : Maximo;
/*var seriePotenciaSP = new Series("Potencia SP: " + (Log != null ? Log.PotenciaSP : 0));
seriePotenciaSP.Points.DataBindXY(Momentos, Logs.Select(x => x.PotenciaSP).ToList());
seriePotenciaSP.ChartType = SeriesChartType.Line;
chart.Series.Add(seriePotenciaSP);
Minimo = Logs.Min(x => x.PotenciaSP) < Minimo ? Logs.Min(x => x.PotenciaSP) : Minimo;
Maximo = Logs.Min(x => x.PotenciaSP) > Maximo ? Logs.Min(x => x.PotenciaSP) : Maximo;*/
var seriePotencia = new Series("Potencia: " + (Log != null ? Log.Potencia : 0));
seriePotencia.Points.DataBindXY(Momentos, Logs.Select(x => x.Potencia).ToList());
seriePotencia.ChartType = SeriesChartType.Line;
chart.Series.Add(seriePotencia);
Minimo = Logs.Min(x => x.Potencia) < Minimo ? Logs.Min(x => x.Potencia) : Minimo;
Maximo = Logs.Max(x => x.Potencia) > Maximo ? Logs.Max(x => x.Potencia) : Maximo;
var serieTemperatura = new Series("Temperatura: " + (Log != null ? Log.Temperatura : 0));
serieTemperatura.Points.DataBindXY(Momentos, Logs.Select(x => x.Temperatura).ToList());
serieTemperatura.ChartType = SeriesChartType.Line;

View File

@ -126,7 +126,6 @@ namespace AgroBase.Forms.Operacoes
lblCorrente.Text = PZEMService.UltimaLeitura.Corrente.ToString("0.00") + " A";
lblRPM.Text = Variaveis.OperacaoEmAndamento.DispMov.Dados.Motores.Average(x => x.RPM).ToString("0") + " rpm";
lblVelocidade.Text = Variaveis.OperacaoEmAndamento.DispMov.Dados.Motores.Average(x => x.VelocidadeInstantanea).ToString("0.00");
lblPotencia.Text = Variaveis.OperacaoEmAndamento.DispMov.Dados.Motores.Average(x => x.Potencia).ToString("0.00") + "%";
chbSonar.Enabled = Variaveis.OperacaoEmAndamento.DispSen.Dados.Sensores.Any(x => x.Componente == S_Code.sSNR && x.Inicializado);
if (!chbSonar.Enabled)
@ -497,13 +496,6 @@ namespace AgroBase.Forms.Operacoes
Minimo = Logs.Min(x => x.RPM_SP) < Minimo ? Logs.Min(x => x.RPM_SP) : Minimo;
Maximo = Logs.Max(x => x.RPM_SP) > Maximo ? Logs.Max(x => x.RPM_SP) : Maximo;
var seriePotencia = new Series("Potencia: " + (Log != null ? Log.Potencia : 0));
seriePotencia.Points.DataBindXY(Momentos, Logs.Select(x => x.Potencia).ToList());
seriePotencia.ChartType = SeriesChartType.Line;
chart.Series.Add(seriePotencia);
Minimo = Logs.Min(x => x.Potencia) < Minimo ? Logs.Min(x => x.Potencia) : Minimo;
Maximo = Logs.Max(x => x.Potencia) > Maximo ? Logs.Max(x => x.Potencia) : Maximo;
var serieTemperatura = new Series("Temperatura: " + (Log != null ? Log.Temperatura : 0));
serieTemperatura.Points.DataBindXY(Momentos, Logs.Select(x => x.Temperatura).ToList());
serieTemperatura.ChartType = SeriesChartType.Line;

View File

@ -311,13 +311,6 @@ namespace AgroBase.Forms.Operacoes
Minimo = Logs.Min(x => x.RPM_SP) < Minimo ? Logs.Min(x => x.RPM_SP) : Minimo;
Maximo = Logs.Max(x => x.RPM_SP) > Maximo ? Logs.Max(x => x.RPM_SP) : Maximo;
var seriePotencia = new Series("Potencia: " + (Log != null ? Log.Potencia : 0));
seriePotencia.Points.DataBindXY(Momentos, Logs.Select(x => x.Potencia).ToList());
seriePotencia.ChartType = SeriesChartType.Line;
chart.Series.Add(seriePotencia);
Minimo = Logs.Min(x => x.Potencia) < Minimo ? Logs.Min(x => x.Potencia) : Minimo;
Maximo = Logs.Max(x => x.Potencia) > Maximo ? Logs.Max(x => x.Potencia) : Maximo;
var serieTemperatura = new Series("Temperatura: " + (Log != null ? Log.Temperatura : 0));
serieTemperatura.Points.DataBindXY(Momentos, Logs.Select(x => x.Temperatura).ToList());
serieTemperatura.ChartType = SeriesChartType.Line;

View File

@ -28,24 +28,21 @@
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea7 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend7 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series7 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea8 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend8 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series8 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea9 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend9 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series9 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea10 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend10 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea11 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend11 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series11 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea12 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend12 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend5 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series5 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.trbMomento = new System.Windows.Forms.TrackBar();
this.panel1 = new System.Windows.Forms.Panel();
this.pnlOrientacaoDif = new System.Windows.Forms.Panel();
@ -138,8 +135,6 @@
this.tabControl2 = new System.Windows.Forms.TabControl();
this.tabMovVelocidade = new System.Windows.Forms.TabPage();
this.chartMovVelocidade = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.tabMovPotencia = new System.Windows.Forms.TabPage();
this.chartMovPotencia = new System.Windows.Forms.DataVisualization.Charting.Chart();
this.tabMovTemperatura = new System.Windows.Forms.TabPage();
this.gpbMOV_Temperatura_Analise = new System.Windows.Forms.GroupBox();
this.txtMOV_Temperatura_Mediana = new System.Windows.Forms.TextBox();
@ -284,8 +279,6 @@
this.tabControl2.SuspendLayout();
this.tabMovVelocidade.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chartMovVelocidade)).BeginInit();
this.tabMovPotencia.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chartMovPotencia)).BeginInit();
this.tabMovTemperatura.SuspendLayout();
this.gpbMOV_Temperatura_Analise.SuspendLayout();
this.gpbMOV_Temperatura_DF.SuspendLayout();
@ -1223,7 +1216,6 @@
// tabControl2
//
this.tabControl2.Controls.Add(this.tabMovVelocidade);
this.tabControl2.Controls.Add(this.tabMovPotencia);
this.tabControl2.Controls.Add(this.tabMovTemperatura);
this.tabControl2.Controls.Add(this.tabMovGreal);
this.tabControl2.Location = new System.Drawing.Point(6, 6);
@ -1245,49 +1237,21 @@
//
// chartMovVelocidade
//
chartArea7.Name = "ChartArea1";
this.chartMovVelocidade.ChartAreas.Add(chartArea7);
legend7.Name = "Legend1";
this.chartMovVelocidade.Legends.Add(legend7);
chartArea1.Name = "ChartArea1";
this.chartMovVelocidade.ChartAreas.Add(chartArea1);
legend1.Name = "Legend1";
this.chartMovVelocidade.Legends.Add(legend1);
this.chartMovVelocidade.Location = new System.Drawing.Point(6, 5);
this.chartMovVelocidade.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.chartMovVelocidade.Name = "chartMovVelocidade";
series7.ChartArea = "ChartArea1";
series7.Legend = "Legend1";
series7.Name = "Series1";
this.chartMovVelocidade.Series.Add(series7);
series1.ChartArea = "ChartArea1";
series1.Legend = "Legend1";
series1.Name = "Series1";
this.chartMovVelocidade.Series.Add(series1);
this.chartMovVelocidade.Size = new System.Drawing.Size(632, 438);
this.chartMovVelocidade.TabIndex = 96;
this.chartMovVelocidade.Text = "chart1";
//
// tabMovPotencia
//
this.tabMovPotencia.Controls.Add(this.chartMovPotencia);
this.tabMovPotencia.Location = new System.Drawing.Point(4, 25);
this.tabMovPotencia.Name = "tabMovPotencia";
this.tabMovPotencia.Padding = new System.Windows.Forms.Padding(3);
this.tabMovPotencia.Size = new System.Drawing.Size(644, 605);
this.tabMovPotencia.TabIndex = 2;
this.tabMovPotencia.Text = "Potência";
this.tabMovPotencia.UseVisualStyleBackColor = true;
//
// chartMovPotencia
//
chartArea8.Name = "ChartArea1";
this.chartMovPotencia.ChartAreas.Add(chartArea8);
legend8.Name = "Legend1";
this.chartMovPotencia.Legends.Add(legend8);
this.chartMovPotencia.Location = new System.Drawing.Point(6, 5);
this.chartMovPotencia.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.chartMovPotencia.Name = "chartMovPotencia";
series8.ChartArea = "ChartArea1";
series8.Legend = "Legend1";
series8.Name = "Series1";
this.chartMovPotencia.Series.Add(series8);
this.chartMovPotencia.Size = new System.Drawing.Size(632, 438);
this.chartMovPotencia.TabIndex = 95;
this.chartMovPotencia.Text = "chart1";
//
// tabMovTemperatura
//
this.tabMovTemperatura.Controls.Add(this.gpbMOV_Temperatura_Analise);
@ -1651,17 +1615,17 @@
//
// chartMovTemperatura
//
chartArea9.Name = "ChartArea1";
this.chartMovTemperatura.ChartAreas.Add(chartArea9);
legend9.Name = "Legend1";
this.chartMovTemperatura.Legends.Add(legend9);
chartArea2.Name = "ChartArea1";
this.chartMovTemperatura.ChartAreas.Add(chartArea2);
legend2.Name = "Legend1";
this.chartMovTemperatura.Legends.Add(legend2);
this.chartMovTemperatura.Location = new System.Drawing.Point(6, 5);
this.chartMovTemperatura.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.chartMovTemperatura.Name = "chartMovTemperatura";
series9.ChartArea = "ChartArea1";
series9.Legend = "Legend1";
series9.Name = "Series1";
this.chartMovTemperatura.Series.Add(series9);
series2.ChartArea = "ChartArea1";
series2.Legend = "Legend1";
series2.Name = "Series1";
this.chartMovTemperatura.Series.Add(series2);
this.chartMovTemperatura.Size = new System.Drawing.Size(632, 413);
this.chartMovTemperatura.TabIndex = 95;
this.chartMovTemperatura.Text = "chart1";
@ -2017,17 +1981,17 @@
//
// chartMovGeral
//
chartArea10.Name = "ChartArea1";
this.chartMovGeral.ChartAreas.Add(chartArea10);
legend10.Name = "Legend1";
this.chartMovGeral.Legends.Add(legend10);
chartArea3.Name = "ChartArea1";
this.chartMovGeral.ChartAreas.Add(chartArea3);
legend3.Name = "Legend1";
this.chartMovGeral.Legends.Add(legend3);
this.chartMovGeral.Location = new System.Drawing.Point(6, 5);
this.chartMovGeral.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.chartMovGeral.Name = "chartMovGeral";
series10.ChartArea = "ChartArea1";
series10.Legend = "Legend1";
series10.Name = "Series1";
this.chartMovGeral.Series.Add(series10);
series3.ChartArea = "ChartArea1";
series3.Legend = "Legend1";
series3.Name = "Series1";
this.chartMovGeral.Series.Add(series3);
this.chartMovGeral.Size = new System.Drawing.Size(632, 438);
this.chartMovGeral.TabIndex = 94;
this.chartMovGeral.Text = "chart1";
@ -2048,17 +2012,17 @@
//
// chartAtuador
//
chartArea11.Name = "ChartArea1";
this.chartAtuador.ChartAreas.Add(chartArea11);
legend11.Name = "Legend1";
this.chartAtuador.Legends.Add(legend11);
chartArea4.Name = "ChartArea1";
this.chartAtuador.ChartAreas.Add(chartArea4);
legend4.Name = "Legend1";
this.chartAtuador.Legends.Add(legend4);
this.chartAtuador.Location = new System.Drawing.Point(6, 340);
this.chartAtuador.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.chartAtuador.Name = "chartAtuador";
series11.ChartArea = "ChartArea1";
series11.Legend = "Legend1";
series11.Name = "Series1";
this.chartAtuador.Series.Add(series11);
series4.ChartArea = "ChartArea1";
series4.Legend = "Legend1";
series4.Name = "Series1";
this.chartAtuador.Series.Add(series4);
this.chartAtuador.Size = new System.Drawing.Size(652, 297);
this.chartAtuador.TabIndex = 95;
this.chartAtuador.Text = "chart1";
@ -2322,17 +2286,17 @@
//
// chartSensoriamento
//
chartArea12.Name = "ChartArea1";
this.chartSensoriamento.ChartAreas.Add(chartArea12);
legend12.Name = "Legend1";
this.chartSensoriamento.Legends.Add(legend12);
chartArea5.Name = "ChartArea1";
this.chartSensoriamento.ChartAreas.Add(chartArea5);
legend5.Name = "Legend1";
this.chartSensoriamento.Legends.Add(legend5);
this.chartSensoriamento.Location = new System.Drawing.Point(3, 5);
this.chartSensoriamento.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.chartSensoriamento.Name = "chartSensoriamento";
series12.ChartArea = "ChartArea1";
series12.Legend = "Legend1";
series12.Name = "Series1";
this.chartSensoriamento.Series.Add(series12);
series5.ChartArea = "ChartArea1";
series5.Legend = "Legend1";
series5.Name = "Series1";
this.chartSensoriamento.Series.Add(series5);
this.chartSensoriamento.Size = new System.Drawing.Size(655, 479);
this.chartSensoriamento.TabIndex = 95;
this.chartSensoriamento.Text = "chart1";
@ -2659,8 +2623,6 @@
this.tabControl2.ResumeLayout(false);
this.tabMovVelocidade.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chartMovVelocidade)).EndInit();
this.tabMovPotencia.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.chartMovPotencia)).EndInit();
this.tabMovTemperatura.ResumeLayout(false);
this.gpbMOV_Temperatura_Analise.ResumeLayout(false);
this.gpbMOV_Temperatura_Analise.PerformLayout();
@ -2745,7 +2707,6 @@
private System.Windows.Forms.PictureBox picDIR_ET;
private System.Windows.Forms.TabControl tabControl2;
private System.Windows.Forms.TabPage tabMovVelocidade;
private System.Windows.Forms.TabPage tabMovPotencia;
private System.Windows.Forms.TabPage tabMovTemperatura;
private System.Windows.Forms.TabPage tabMovGreal;
public System.Windows.Forms.DataVisualization.Charting.Chart chartMovGeral;
@ -2876,7 +2837,6 @@
private System.Windows.Forms.Label label61;
private System.Windows.Forms.Button btnMOV_Geral_Buscar;
private System.Windows.Forms.Button btnMOV_Geral_Redefinir;
public System.Windows.Forms.DataVisualization.Charting.Chart chartMovPotencia;
public System.Windows.Forms.DataVisualization.Charting.Chart chartMovVelocidade;
private System.Windows.Forms.GroupBox gpbSEN_Filtro;
private System.Windows.Forms.Button btnSen_Redefinir;

View File

@ -156,13 +156,6 @@ namespace AgroBase.Forms.Operacoes
MostrarValor = true
},
new GraficoInterativoSerieModel()
{
Titulo = "EF Offset",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "EF").Select(x => x.RPM_Offset).ToList(),
Visivel = false,
MostrarValor = true,
},
new GraficoInterativoSerieModel()
{
Titulo = "ET",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "ET").Select(x => x.RPM).ToList(),
@ -170,13 +163,6 @@ namespace AgroBase.Forms.Operacoes
MostrarValor = true
},
new GraficoInterativoSerieModel()
{
Titulo = "ET Offset",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "ET").Select(x => x.RPM_Offset).ToList(),
Visivel = false,
MostrarValor = true
},
new GraficoInterativoSerieModel()
{
Titulo = "DT",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "DT").Select(x => x.RPM).ToList(),
@ -184,26 +170,12 @@ namespace AgroBase.Forms.Operacoes
MostrarValor = true
},
new GraficoInterativoSerieModel()
{
Titulo = "DT Offset",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "DT").Select(x => x.RPM_Offset).ToList(),
Visivel = false,
MostrarValor = true
},
new GraficoInterativoSerieModel()
{
Titulo = "DF",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "DF").Select(x => x.RPM).ToList(),
Visivel = true,
MostrarValor = true
},
new GraficoInterativoSerieModel()
{
Titulo = "DF Offset",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "DF").Select(x => x.RPM_Offset).ToList(),
Visivel = false,
MostrarValor = true
},
});
graficoMovTemperatura = new GraficoInterativoModel(chartMovTemperatura, Momentos, new List<GraficoInterativoSerieModel>()
@ -262,38 +234,6 @@ namespace AgroBase.Forms.Operacoes
},
});
graficoMovPotencia = new GraficoInterativoModel(chartMovPotencia, Momentos, new List<GraficoInterativoSerieModel>()
{
new GraficoInterativoSerieModel()
{
Titulo = "EF",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "EF").Select(x => x.Potencia).ToList(),
Visivel = true,
MostrarValor = true
},
new GraficoInterativoSerieModel()
{
Titulo = "ET",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "ET").Select(x => x.Potencia).ToList(),
Visivel = true,
MostrarValor = true
},
new GraficoInterativoSerieModel()
{
Titulo = "DT",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "DT").Select(x => x.Potencia).ToList(),
Visivel = true,
MostrarValor = true
},
new GraficoInterativoSerieModel()
{
Titulo = "DF",
Valores = LogsMovimentacao.Where(x => x.ComponenteID == "DF").Select(x => x.Potencia).ToList(),
Visivel = true,
MostrarValor = true
},
});
graficoAtu = new GraficoInterativoModel(chartAtuador, Momentos, new List<GraficoInterativoSerieModel>()
{
new GraficoInterativoSerieModel()

View File

@ -29,18 +29,18 @@ namespace AgroBase.Forms
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea9 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend9 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series9 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea10 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend10 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series10 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea11 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend11 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series11 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea12 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend12 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series12 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend2 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea3 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend3 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series3 = new System.Windows.Forms.DataVisualization.Charting.Series();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea4 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.Legend legend4 = new System.Windows.Forms.DataVisualization.Charting.Legend();
System.Windows.Forms.DataVisualization.Charting.Series series4 = new System.Windows.Forms.DataVisualization.Charting.Series();
this.pnlFundo = new System.Windows.Forms.Panel();
this.lblB12V = new System.Windows.Forms.Label();
this.lblB7V2 = new System.Windows.Forms.Label();
@ -70,7 +70,7 @@ namespace AgroBase.Forms
this.lblDTM_Sentido = new System.Windows.Forms.Label();
this.lblDTM_SentidoSP = new System.Windows.Forms.Label();
this.lblDTM_RPMSP = new System.Windows.Forms.Label();
this.lblDTM_Potencia = new System.Windows.Forms.Label();
this.lblDTM_Tensao = new System.Windows.Forms.Label();
this.lblDTM_Velocidade = new System.Windows.Forms.Label();
this.lblDTM_RPM = new System.Windows.Forms.Label();
this.lblDFM_Corrente = new System.Windows.Forms.Label();
@ -78,7 +78,7 @@ namespace AgroBase.Forms
this.lblDFM_Sentido = new System.Windows.Forms.Label();
this.lblDFM_SentidoSP = new System.Windows.Forms.Label();
this.lblDFM_RPMSP = new System.Windows.Forms.Label();
this.lblDFM_Potencia = new System.Windows.Forms.Label();
this.lblDFM_Tensao = new System.Windows.Forms.Label();
this.lblDFM_Velocidade = new System.Windows.Forms.Label();
this.lblDFM_RPM = new System.Windows.Forms.Label();
this.lblETM_Corrente = new System.Windows.Forms.Label();
@ -86,7 +86,7 @@ namespace AgroBase.Forms
this.lblETM_Sentido = new System.Windows.Forms.Label();
this.lblETM_SentidoSP = new System.Windows.Forms.Label();
this.lblETM_RPMSP = new System.Windows.Forms.Label();
this.lblETM_Potencia = new System.Windows.Forms.Label();
this.lblETM_Tensao = new System.Windows.Forms.Label();
this.lblETM_Velocidade = new System.Windows.Forms.Label();
this.lblETM_RPM = new System.Windows.Forms.Label();
this.lblEFM_Corrente = new System.Windows.Forms.Label();
@ -94,7 +94,6 @@ namespace AgroBase.Forms
this.lblEFM_Sentido = new System.Windows.Forms.Label();
this.lblEFM_SentidoSP = new System.Windows.Forms.Label();
this.lblEFM_RPMSP = new System.Windows.Forms.Label();
this.lblEFM_Potencia = new System.Windows.Forms.Label();
this.lblEFM_Velocidade = new System.Windows.Forms.Label();
this.lblEFM_RPM = new System.Windows.Forms.Label();
this.btnDTReverter = new System.Windows.Forms.Button();
@ -129,6 +128,7 @@ namespace AgroBase.Forms
this.btnEFReferenciar = new System.Windows.Forms.Button();
this.lblM1 = new System.Windows.Forms.Label();
this.picEF = new System.Windows.Forms.PictureBox();
this.lblEFM_Tensao = new System.Windows.Forms.Label();
this.pnlFundo.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.chartET)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.chartDT)).BeginInit();
@ -173,7 +173,7 @@ namespace AgroBase.Forms
this.pnlFundo.Controls.Add(this.lblDTM_Sentido);
this.pnlFundo.Controls.Add(this.lblDTM_SentidoSP);
this.pnlFundo.Controls.Add(this.lblDTM_RPMSP);
this.pnlFundo.Controls.Add(this.lblDTM_Potencia);
this.pnlFundo.Controls.Add(this.lblDTM_Tensao);
this.pnlFundo.Controls.Add(this.lblDTM_Velocidade);
this.pnlFundo.Controls.Add(this.lblDTM_RPM);
this.pnlFundo.Controls.Add(this.lblDFM_Corrente);
@ -181,7 +181,7 @@ namespace AgroBase.Forms
this.pnlFundo.Controls.Add(this.lblDFM_Sentido);
this.pnlFundo.Controls.Add(this.lblDFM_SentidoSP);
this.pnlFundo.Controls.Add(this.lblDFM_RPMSP);
this.pnlFundo.Controls.Add(this.lblDFM_Potencia);
this.pnlFundo.Controls.Add(this.lblDFM_Tensao);
this.pnlFundo.Controls.Add(this.lblDFM_Velocidade);
this.pnlFundo.Controls.Add(this.lblDFM_RPM);
this.pnlFundo.Controls.Add(this.lblETM_Corrente);
@ -189,7 +189,7 @@ namespace AgroBase.Forms
this.pnlFundo.Controls.Add(this.lblETM_Sentido);
this.pnlFundo.Controls.Add(this.lblETM_SentidoSP);
this.pnlFundo.Controls.Add(this.lblETM_RPMSP);
this.pnlFundo.Controls.Add(this.lblETM_Potencia);
this.pnlFundo.Controls.Add(this.lblETM_Tensao);
this.pnlFundo.Controls.Add(this.lblETM_Velocidade);
this.pnlFundo.Controls.Add(this.lblETM_RPM);
this.pnlFundo.Controls.Add(this.lblEFM_Corrente);
@ -197,7 +197,7 @@ namespace AgroBase.Forms
this.pnlFundo.Controls.Add(this.lblEFM_Sentido);
this.pnlFundo.Controls.Add(this.lblEFM_SentidoSP);
this.pnlFundo.Controls.Add(this.lblEFM_RPMSP);
this.pnlFundo.Controls.Add(this.lblEFM_Potencia);
this.pnlFundo.Controls.Add(this.lblEFM_Tensao);
this.pnlFundo.Controls.Add(this.lblEFM_Velocidade);
this.pnlFundo.Controls.Add(this.lblEFM_RPM);
this.pnlFundo.Controls.Add(this.btnDTReverter);
@ -236,7 +236,7 @@ namespace AgroBase.Forms
this.pnlFundo.Location = new System.Drawing.Point(0, 0);
this.pnlFundo.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.pnlFundo.Name = "pnlFundo";
this.pnlFundo.Size = new System.Drawing.Size(1979, 922);
this.pnlFundo.Size = new System.Drawing.Size(1924, 922);
this.pnlFundo.TabIndex = 0;
//
// lblB12V
@ -425,68 +425,68 @@ namespace AgroBase.Forms
//
// chartET
//
chartArea9.Name = "ChartArea1";
this.chartET.ChartAreas.Add(chartArea9);
legend9.Name = "Legend1";
this.chartET.Legends.Add(legend9);
chartArea1.Name = "ChartArea1";
this.chartET.ChartAreas.Add(chartArea1);
legend1.Name = "Legend1";
this.chartET.Legends.Add(legend1);
this.chartET.Location = new System.Drawing.Point(268, 505);
this.chartET.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.chartET.Name = "chartET";
series9.ChartArea = "ChartArea1";
series9.Legend = "Legend1";
series9.Name = "Series1";
this.chartET.Series.Add(series9);
series1.ChartArea = "ChartArea1";
series1.Legend = "Legend1";
series1.Name = "Series1";
this.chartET.Series.Add(series1);
this.chartET.Size = new System.Drawing.Size(579, 480);
this.chartET.TabIndex = 94;
this.chartET.Text = "chart1";
//
// chartDT
//
chartArea10.Name = "ChartArea1";
this.chartDT.ChartAreas.Add(chartArea10);
legend10.Name = "Legend1";
this.chartDT.Legends.Add(legend10);
chartArea2.Name = "ChartArea1";
this.chartDT.ChartAreas.Add(chartArea2);
legend2.Name = "Legend1";
this.chartDT.Legends.Add(legend2);
this.chartDT.Location = new System.Drawing.Point(1112, 505);
this.chartDT.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.chartDT.Name = "chartDT";
series10.ChartArea = "ChartArea1";
series10.Legend = "Legend1";
series10.Name = "Series1";
this.chartDT.Series.Add(series10);
series2.ChartArea = "ChartArea1";
series2.Legend = "Legend1";
series2.Name = "Series1";
this.chartDT.Series.Add(series2);
this.chartDT.Size = new System.Drawing.Size(577, 480);
this.chartDT.TabIndex = 110;
this.chartDT.Text = "chart1";
//
// chartDF
//
chartArea11.Name = "ChartArea1";
this.chartDF.ChartAreas.Add(chartArea11);
legend11.Name = "Legend1";
this.chartDF.Legends.Add(legend11);
chartArea3.Name = "ChartArea1";
this.chartDF.ChartAreas.Add(chartArea3);
legend3.Name = "Legend1";
this.chartDF.Legends.Add(legend3);
this.chartDF.Location = new System.Drawing.Point(1112, 5);
this.chartDF.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.chartDF.Name = "chartDF";
series11.ChartArea = "ChartArea1";
series11.Legend = "Legend1";
series11.Name = "Series1";
this.chartDF.Series.Add(series11);
series3.ChartArea = "ChartArea1";
series3.Legend = "Legend1";
series3.Name = "Series1";
this.chartDF.Series.Add(series3);
this.chartDF.Size = new System.Drawing.Size(577, 480);
this.chartDF.TabIndex = 109;
this.chartDF.Text = "chart1";
//
// chartEF
//
chartArea12.Name = "ChartArea1";
this.chartEF.ChartAreas.Add(chartArea12);
legend12.Name = "Legend1";
this.chartEF.Legends.Add(legend12);
chartArea4.Name = "ChartArea1";
this.chartEF.ChartAreas.Add(chartArea4);
legend4.Name = "Legend1";
this.chartEF.Legends.Add(legend4);
this.chartEF.Location = new System.Drawing.Point(268, 5);
this.chartEF.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.chartEF.Name = "chartEF";
series12.ChartArea = "ChartArea1";
series12.Legend = "Legend1";
series12.Name = "Series1";
this.chartEF.Series.Add(series12);
series4.ChartArea = "ChartArea1";
series4.Legend = "Legend1";
series4.Name = "Series1";
this.chartEF.Series.Add(series4);
this.chartEF.Size = new System.Drawing.Size(579, 480);
this.chartEF.TabIndex = 93;
this.chartEF.Text = "chart1";
@ -547,14 +547,14 @@ namespace AgroBase.Forms
this.lblDTM_RPMSP.TabIndex = 153;
this.lblDTM_RPMSP.Text = "RPM SP: 0";
//
// lblDTM_Potencia
// lblDTM_Tensao
//
this.lblDTM_Potencia.AutoSize = true;
this.lblDTM_Potencia.Location = new System.Drawing.Point(1697, 903);
this.lblDTM_Potencia.Name = "lblDTM_Potencia";
this.lblDTM_Potencia.Size = new System.Drawing.Size(85, 16);
this.lblDTM_Potencia.TabIndex = 152;
this.lblDTM_Potencia.Text = "Potência: 0%";
this.lblDTM_Tensao.AutoSize = true;
this.lblDTM_Tensao.Location = new System.Drawing.Point(1697, 903);
this.lblDTM_Tensao.Name = "lblDTM_Tensao";
this.lblDTM_Tensao.Size = new System.Drawing.Size(76, 16);
this.lblDTM_Tensao.TabIndex = 152;
this.lblDTM_Tensao.Text = "Tensão: 0V";
//
// lblDTM_Velocidade
//
@ -619,14 +619,14 @@ namespace AgroBase.Forms
this.lblDFM_RPMSP.TabIndex = 145;
this.lblDFM_RPMSP.Text = "RPM SP: 0";
//
// lblDFM_Potencia
// lblDFM_Tensao
//
this.lblDFM_Potencia.AutoSize = true;
this.lblDFM_Potencia.Location = new System.Drawing.Point(1697, 405);
this.lblDFM_Potencia.Name = "lblDFM_Potencia";
this.lblDFM_Potencia.Size = new System.Drawing.Size(85, 16);
this.lblDFM_Potencia.TabIndex = 144;
this.lblDFM_Potencia.Text = "Potência: 0%";
this.lblDFM_Tensao.AutoSize = true;
this.lblDFM_Tensao.Location = new System.Drawing.Point(1697, 405);
this.lblDFM_Tensao.Name = "lblDFM_Tensao";
this.lblDFM_Tensao.Size = new System.Drawing.Size(76, 16);
this.lblDFM_Tensao.TabIndex = 144;
this.lblDFM_Tensao.Text = "Tensão: 0V";
//
// lblDFM_Velocidade
//
@ -691,14 +691,14 @@ namespace AgroBase.Forms
this.lblETM_RPMSP.TabIndex = 137;
this.lblETM_RPMSP.Text = "RPM SP: 0";
//
// lblETM_Potencia
// lblETM_Tensao
//
this.lblETM_Potencia.AutoSize = true;
this.lblETM_Potencia.Location = new System.Drawing.Point(13, 903);
this.lblETM_Potencia.Name = "lblETM_Potencia";
this.lblETM_Potencia.Size = new System.Drawing.Size(85, 16);
this.lblETM_Potencia.TabIndex = 136;
this.lblETM_Potencia.Text = "Potência: 0%";
this.lblETM_Tensao.AutoSize = true;
this.lblETM_Tensao.Location = new System.Drawing.Point(13, 903);
this.lblETM_Tensao.Name = "lblETM_Tensao";
this.lblETM_Tensao.Size = new System.Drawing.Size(76, 16);
this.lblETM_Tensao.TabIndex = 136;
this.lblETM_Tensao.Text = "Tensão: 0V";
//
// lblETM_Velocidade
//
@ -763,15 +763,6 @@ namespace AgroBase.Forms
this.lblEFM_RPMSP.TabIndex = 129;
this.lblEFM_RPMSP.Text = "RPM SP: 0";
//
// lblEFM_Potencia
//
this.lblEFM_Potencia.AutoSize = true;
this.lblEFM_Potencia.Location = new System.Drawing.Point(13, 405);
this.lblEFM_Potencia.Name = "lblEFM_Potencia";
this.lblEFM_Potencia.Size = new System.Drawing.Size(85, 16);
this.lblEFM_Potencia.TabIndex = 128;
this.lblEFM_Potencia.Text = "Potência: 0%";
//
// lblEFM_Velocidade
//
this.lblEFM_Velocidade.AutoSize = true;
@ -1090,11 +1081,20 @@ namespace AgroBase.Forms
this.picEF.TabIndex = 90;
this.picEF.TabStop = false;
//
// lblEFM_Tensao
//
this.lblEFM_Tensao.AutoSize = true;
this.lblEFM_Tensao.Location = new System.Drawing.Point(13, 405);
this.lblEFM_Tensao.Name = "lblEFM_Tensao";
this.lblEFM_Tensao.Size = new System.Drawing.Size(76, 16);
this.lblEFM_Tensao.TabIndex = 128;
this.lblEFM_Tensao.Text = "Tensão: 0V";
//
// frmAcompanhamento
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1979, 922);
this.ClientSize = new System.Drawing.Size(1924, 922);
this.Controls.Add(this.pnlFundo);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "frmAcompanhamento";
@ -1131,7 +1131,7 @@ namespace AgroBase.Forms
private System.Windows.Forms.Label lblDTM_Sentido;
private System.Windows.Forms.Label lblDTM_SentidoSP;
private System.Windows.Forms.Label lblDTM_RPMSP;
private System.Windows.Forms.Label lblDTM_Potencia;
private System.Windows.Forms.Label lblDTM_Tensao;
private System.Windows.Forms.Label lblDTM_Velocidade;
private System.Windows.Forms.Label lblDTM_RPM;
private System.Windows.Forms.Label lblDFM_Corrente;
@ -1139,7 +1139,7 @@ namespace AgroBase.Forms
private System.Windows.Forms.Label lblDFM_Sentido;
private System.Windows.Forms.Label lblDFM_SentidoSP;
private System.Windows.Forms.Label lblDFM_RPMSP;
private System.Windows.Forms.Label lblDFM_Potencia;
private System.Windows.Forms.Label lblDFM_Tensao;
private System.Windows.Forms.Label lblDFM_Velocidade;
private System.Windows.Forms.Label lblDFM_RPM;
private System.Windows.Forms.Label lblETM_Corrente;
@ -1147,7 +1147,7 @@ namespace AgroBase.Forms
private System.Windows.Forms.Label lblETM_Sentido;
private System.Windows.Forms.Label lblETM_SentidoSP;
private System.Windows.Forms.Label lblETM_RPMSP;
private System.Windows.Forms.Label lblETM_Potencia;
private System.Windows.Forms.Label lblETM_Tensao;
private System.Windows.Forms.Label lblETM_Velocidade;
private System.Windows.Forms.Label lblETM_RPM;
private System.Windows.Forms.Label lblEFM_Corrente;
@ -1155,7 +1155,6 @@ namespace AgroBase.Forms
private System.Windows.Forms.Label lblEFM_Sentido;
private System.Windows.Forms.Label lblEFM_SentidoSP;
private System.Windows.Forms.Label lblEFM_RPMSP;
private System.Windows.Forms.Label lblEFM_Potencia;
private System.Windows.Forms.Label lblEFM_Velocidade;
private System.Windows.Forms.Label lblEFM_RPM;
private System.Windows.Forms.Button btnDTReverter;
@ -1208,5 +1207,6 @@ namespace AgroBase.Forms
public System.Windows.Forms.Label lblB7V2;
public System.Windows.Forms.Label lblB5V;
public System.Windows.Forms.Label lblB3V;
private System.Windows.Forms.Label lblEFM_Tensao;
}
}

View File

@ -119,8 +119,6 @@ namespace AgroBase.Forms
lblM_RPM.Text = "RPM: " + Motor.RPM.ToString("0.00");
Label lblM_Velocidade = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + Motor.ID + "M_Velocidade");
lblM_Velocidade.Text = "Velocidade: " + Motor.VelocidadeInstantanea.ToString("0.00") + " Km/h";
Label lblM_Potencia = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + Motor.ID + "M_Potencia");
lblM_Potencia.Text = "Potencia: " + Motor.Potencia.ToString("0.00") + "%";
Label lblM_SentidoSP = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + Motor.ID + "M_SentidoSP");
lblM_SentidoSP.Text = "Sentido SP: " + Enum.GetName(typeof(Sentido), Motor.Sentido_SP);
Label lblM_Sentido = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + Motor.ID + "M_Sentido");
@ -130,6 +128,8 @@ namespace AgroBase.Forms
lblM_Temperatura.ForeColor = Motor.Alarmes.Any(x => x.Tipo == S_Code.sTMP && (x.Maximo || x.Minimo)) ? Color.Red : Color.Black;
Label lblM_Corrente = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + Motor.ID + "M_Corrente");
lblM_Corrente.Text = "Corrente: " + Motor.Corrente.ToString("0.00") + "A";
Label lblM_Tensao = pnlFundo.Controls.OfType<Label>().FirstOrDefault(ctrl => ctrl.Name == "lbl" + Motor.ID + "M_Tensao");
lblTensao.Text = "Tensão: " + Motor.Tensao.ToString("0.00") + "V";
MovSensorimanetoGrafico Log = null;
if (Motor.LogGrafico.Count > 0)
@ -164,20 +164,6 @@ namespace AgroBase.Forms
Minimo = Logs.Min(x => x.RPM) < Minimo ? Logs.Min(x => x.RPM) : Minimo;
Maximo = Logs.Max(x => x.RPM) > Maximo ? Logs.Max(x => x.RPM) : Maximo;
var serieRPMOffset = new Series("RPM Offset: " + (Log != null ? Log.RPM_Offset : 0));
serieRPMOffset.Points.DataBindXY(Momentos, Logs.Select(x => x.RPM_Offset).ToList());
serieRPMOffset.ChartType = SeriesChartType.Spline;
chart.Series.Add(serieRPMOffset);
Minimo = Logs.Min(x => x.RPM_Offset) < Minimo ? Logs.Min(x => x.RPM_Offset) : Minimo;
Maximo = Logs.Max(x => x.RPM_Offset) > Maximo ? Logs.Max(x => x.RPM_Offset) : Maximo;
var seriePotencia = new Series("Potencia: " + (Log != null ? Log.Potencia : 0));
seriePotencia.Points.DataBindXY(Momentos, Logs.Select(x => x.Potencia).ToList());
seriePotencia.ChartType = SeriesChartType.Line;
chart.Series.Add(seriePotencia);
Minimo = Logs.Min(x => x.Potencia) < Minimo ? Logs.Min(x => x.Potencia) : Minimo;
Maximo = Logs.Max(x => x.Potencia) > Maximo ? Logs.Max(x => x.Potencia) : Maximo;
var serieTemperatura = new Series("Temperatura: " + (Log != null ? Log.Temperatura : 0));
serieTemperatura.Points.DataBindXY(Momentos, Logs.Select(x => x.Temperatura).ToList());
serieTemperatura.ChartType = SeriesChartType.Line;

510
AgroBase/AgroBase/Forms/frmBLD.Designer.cs generated Normal file
View File

@ -0,0 +1,510 @@
namespace AgroBase.Forms
{
partial class frmBLD
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.trbRPMSP = new System.Windows.Forms.TrackBar();
this.label1 = new System.Windows.Forms.Label();
this.pgbRPMSP = new System.Windows.Forms.ProgressBar();
this.pgbRPM = new System.Windows.Forms.ProgressBar();
this.lblRPMSP = new System.Windows.Forms.Label();
this.lblRPM = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label9 = new System.Windows.Forms.Label();
this.nudEndereco = new System.Windows.Forms.NumericUpDown();
this.btnSalvar = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.nudRampa = new System.Windows.Forms.NumericUpDown();
this.label6 = new System.Windows.Forms.Label();
this.nudRPMMax = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.nudNumPolos = new System.Windows.Forms.NumericUpDown();
this.chbControleSerial = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.btnFrear = new System.Windows.Forms.Button();
this.btnSentido = new System.Windows.Forms.Button();
this.btnAtivar = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.btnAtualizar = new System.Windows.Forms.Button();
this.label8 = new System.Windows.Forms.Label();
this.txtCodAlarme = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.txtTensao = new System.Windows.Forms.TextBox();
this.txtTemperatura = new System.Windows.Forms.TextBox();
this.txtCorrente = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.trbRPMSP)).BeginInit();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudEndereco)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudRampa)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudRPMMax)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.nudNumPolos)).BeginInit();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// trbRPMSP
//
this.trbRPMSP.Location = new System.Drawing.Point(6, 37);
this.trbRPMSP.Name = "trbRPMSP";
this.trbRPMSP.Size = new System.Drawing.Size(420, 56);
this.trbRPMSP.TabIndex = 0;
this.trbRPMSP.MouseUp += new System.Windows.Forms.MouseEventHandler(this.trbRPMSP_MouseUp);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 18);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(58, 16);
this.label1.TabIndex = 1;
this.label1.Text = "RPM SP";
//
// pgbRPMSP
//
this.pgbRPMSP.Location = new System.Drawing.Point(9, 32);
this.pgbRPMSP.Name = "pgbRPMSP";
this.pgbRPMSP.Size = new System.Drawing.Size(276, 26);
this.pgbRPMSP.TabIndex = 2;
//
// pgbRPM
//
this.pgbRPM.Location = new System.Drawing.Point(9, 64);
this.pgbRPM.Name = "pgbRPM";
this.pgbRPM.Size = new System.Drawing.Size(276, 26);
this.pgbRPM.TabIndex = 3;
//
// lblRPMSP
//
this.lblRPMSP.AutoSize = true;
this.lblRPMSP.Location = new System.Drawing.Point(291, 42);
this.lblRPMSP.Name = "lblRPMSP";
this.lblRPMSP.Size = new System.Drawing.Size(47, 16);
this.lblRPMSP.TabIndex = 4;
this.lblRPMSP.Text = "0 RPM";
//
// lblRPM
//
this.lblRPM.AutoSize = true;
this.lblRPM.Location = new System.Drawing.Point(291, 74);
this.lblRPM.Name = "lblRPM";
this.lblRPM.Size = new System.Drawing.Size(47, 16);
this.lblRPM.TabIndex = 5;
this.lblRPM.Text = "0 RPM";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label9);
this.groupBox1.Controls.Add(this.nudEndereco);
this.groupBox1.Controls.Add(this.btnSalvar);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.nudRampa);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.nudRPMMax);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.nudNumPolos);
this.groupBox1.Controls.Add(this.chbControleSerial);
this.groupBox1.Location = new System.Drawing.Point(12, 205);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(438, 138);
this.groupBox1.TabIndex = 6;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Parametrização";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(147, 18);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(66, 16);
this.label9.TabIndex = 18;
this.label9.Text = "Endereço";
//
// nudEndereco
//
this.nudEndereco.Location = new System.Drawing.Point(150, 37);
this.nudEndereco.Maximum = new decimal(new int[] {
7,
0,
0,
0});
this.nudEndereco.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.nudEndereco.Name = "nudEndereco";
this.nudEndereco.Size = new System.Drawing.Size(135, 22);
this.nudEndereco.TabIndex = 17;
this.nudEndereco.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.nudEndereco.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// btnSalvar
//
this.btnSalvar.Location = new System.Drawing.Point(291, 33);
this.btnSalvar.Name = "btnSalvar";
this.btnSalvar.Size = new System.Drawing.Size(135, 29);
this.btnSalvar.TabIndex = 12;
this.btnSalvar.Text = "Editar";
this.btnSalvar.UseVisualStyleBackColor = true;
this.btnSalvar.Click += new System.EventHandler(this.btnSalvar_Click);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(288, 79);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(143, 20);
this.label7.TabIndex = 16;
this.label7.Text = "Rampa (x 100 ms)";
//
// nudRampa
//
this.nudRampa.Location = new System.Drawing.Point(291, 98);
this.nudRampa.Maximum = new decimal(new int[] {
150,
0,
0,
0});
this.nudRampa.Name = "nudRampa";
this.nudRampa.Size = new System.Drawing.Size(135, 22);
this.nudRampa.TabIndex = 15;
this.nudRampa.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(147, 79);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(87, 16);
this.label6.TabIndex = 14;
this.label6.Text = "RPM Máximo";
//
// nudRPMMax
//
this.nudRPMMax.Location = new System.Drawing.Point(150, 98);
this.nudRPMMax.Maximum = new decimal(new int[] {
20000,
0,
0,
0});
this.nudRPMMax.Name = "nudRPMMax";
this.nudRPMMax.Size = new System.Drawing.Size(135, 22);
this.nudRPMMax.TabIndex = 13;
this.nudRPMMax.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(6, 79);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(112, 16);
this.label5.TabIndex = 12;
this.label5.Text = "Número de Polos";
//
// nudNumPolos
//
this.nudNumPolos.Location = new System.Drawing.Point(9, 98);
this.nudNumPolos.Maximum = new decimal(new int[] {
254,
0,
0,
0});
this.nudNumPolos.Name = "nudNumPolos";
this.nudNumPolos.Size = new System.Drawing.Size(135, 22);
this.nudNumPolos.TabIndex = 1;
this.nudNumPolos.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.nudNumPolos.Value = new decimal(new int[] {
2,
0,
0,
0});
//
// chbControleSerial
//
this.chbControleSerial.AutoSize = true;
this.chbControleSerial.Location = new System.Drawing.Point(18, 38);
this.chbControleSerial.Name = "chbControleSerial";
this.chbControleSerial.Size = new System.Drawing.Size(117, 20);
this.chbControleSerial.TabIndex = 0;
this.chbControleSerial.Text = "Controle Serial";
this.chbControleSerial.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.btnFrear);
this.groupBox2.Controls.Add(this.btnSentido);
this.groupBox2.Controls.Add(this.btnAtivar);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.trbRPMSP);
this.groupBox2.Location = new System.Drawing.Point(12, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(438, 187);
this.groupBox2.TabIndex = 7;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Controle";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(338, 111);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(38, 16);
this.label4.TabIndex = 11;
this.label4.Text = "Freio";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(192, 111);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 16);
this.label3.TabIndex = 10;
this.label3.Text = "Sentido";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(55, 111);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 16);
this.label2.TabIndex = 9;
this.label2.Text = "Motor";
//
// btnFrear
//
this.btnFrear.Location = new System.Drawing.Point(291, 140);
this.btnFrear.Name = "btnFrear";
this.btnFrear.Size = new System.Drawing.Size(135, 29);
this.btnFrear.TabIndex = 8;
this.btnFrear.Text = "Ligar";
this.btnFrear.UseVisualStyleBackColor = true;
this.btnFrear.Click += new System.EventHandler(this.btnFrear_Click);
//
// btnSentido
//
this.btnSentido.Location = new System.Drawing.Point(150, 140);
this.btnSentido.Name = "btnSentido";
this.btnSentido.Size = new System.Drawing.Size(135, 29);
this.btnSentido.TabIndex = 7;
this.btnSentido.Text = "Horário";
this.btnSentido.UseVisualStyleBackColor = true;
this.btnSentido.Click += new System.EventHandler(this.btnSentido_Click);
//
// btnAtivar
//
this.btnAtivar.Location = new System.Drawing.Point(9, 140);
this.btnAtivar.Name = "btnAtivar";
this.btnAtivar.Size = new System.Drawing.Size(135, 29);
this.btnAtivar.TabIndex = 6;
this.btnAtivar.Text = "Ligar";
this.btnAtivar.UseVisualStyleBackColor = true;
this.btnAtivar.Click += new System.EventHandler(this.btnAtivar_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.txtCorrente);
this.groupBox3.Controls.Add(this.txtTemperatura);
this.groupBox3.Controls.Add(this.txtTensao);
this.groupBox3.Controls.Add(this.label10);
this.groupBox3.Controls.Add(this.label11);
this.groupBox3.Controls.Add(this.label12);
this.groupBox3.Controls.Add(this.btnAtualizar);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Controls.Add(this.txtCodAlarme);
this.groupBox3.Controls.Add(this.pgbRPMSP);
this.groupBox3.Controls.Add(this.pgbRPM);
this.groupBox3.Controls.Add(this.lblRPMSP);
this.groupBox3.Controls.Add(this.lblRPM);
this.groupBox3.Location = new System.Drawing.Point(12, 349);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(438, 218);
this.groupBox3.TabIndex = 8;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Monitor";
//
// btnAtualizar
//
this.btnAtualizar.Location = new System.Drawing.Point(291, 175);
this.btnAtualizar.Name = "btnAtualizar";
this.btnAtualizar.Size = new System.Drawing.Size(135, 29);
this.btnAtualizar.TabIndex = 13;
this.btnAtualizar.Text = "Atualizar";
this.btnAtualizar.UseVisualStyleBackColor = true;
this.btnAtualizar.Click += new System.EventHandler(this.btnAtualizar_Click);
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(6, 188);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(97, 16);
this.label8.TabIndex = 12;
this.label8.Text = "Código Alarme";
//
// txtCodAlarme
//
this.txtCodAlarme.Font = new System.Drawing.Font("Microsoft Sans Serif", 22.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtCodAlarme.Location = new System.Drawing.Point(128, 163);
this.txtCodAlarme.Name = "txtCodAlarme";
this.txtCodAlarme.ReadOnly = true;
this.txtCodAlarme.Size = new System.Drawing.Size(157, 49);
this.txtCodAlarme.TabIndex = 6;
this.txtCodAlarme.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(291, 102);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(108, 16);
this.label10.TabIndex = 22;
this.label10.Text = "Corrente Máxima";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(147, 102);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(85, 16);
this.label11.TabIndex = 20;
this.label11.Text = "Temperatura";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(6, 102);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(54, 16);
this.label12.TabIndex = 18;
this.label12.Text = "Tensão";
//
// txtTensao
//
this.txtTensao.Location = new System.Drawing.Point(9, 121);
this.txtTensao.Name = "txtTensao";
this.txtTensao.ReadOnly = true;
this.txtTensao.Size = new System.Drawing.Size(135, 22);
this.txtTensao.TabIndex = 23;
this.txtTensao.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// txtTemperatura
//
this.txtTemperatura.Location = new System.Drawing.Point(150, 121);
this.txtTemperatura.Name = "txtTemperatura";
this.txtTemperatura.ReadOnly = true;
this.txtTemperatura.Size = new System.Drawing.Size(135, 22);
this.txtTemperatura.TabIndex = 24;
this.txtTemperatura.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// txtCorrente
//
this.txtCorrente.Location = new System.Drawing.Point(291, 121);
this.txtCorrente.Name = "txtCorrente";
this.txtCorrente.ReadOnly = true;
this.txtCorrente.Size = new System.Drawing.Size(135, 22);
this.txtCorrente.TabIndex = 25;
this.txtCorrente.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// frmBLD
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(459, 579);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.MaximizeBox = false;
this.Name = "frmBLD";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Driver BLD-300R";
this.Load += new System.EventHandler(this.frmBLD_Load);
((System.ComponentModel.ISupportInitialize)(this.trbRPMSP)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudEndereco)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudRampa)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudRPMMax)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.nudNumPolos)).EndInit();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TrackBar trbRPMSP;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ProgressBar pgbRPMSP;
private System.Windows.Forms.ProgressBar pgbRPM;
private System.Windows.Forms.Label lblRPMSP;
private System.Windows.Forms.Label lblRPM;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button btnAtivar;
private System.Windows.Forms.Button btnFrear;
private System.Windows.Forms.Button btnSentido;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.CheckBox chbControleSerial;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.NumericUpDown nudNumPolos;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.NumericUpDown nudRPMMax;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.NumericUpDown nudRampa;
private System.Windows.Forms.Button btnSalvar;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox txtCodAlarme;
private System.Windows.Forms.Button btnAtualizar;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.NumericUpDown nudEndereco;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.TextBox txtCorrente;
private System.Windows.Forms.TextBox txtTemperatura;
private System.Windows.Forms.TextBox txtTensao;
}
}

View File

@ -0,0 +1,164 @@
using AgroBase.Models;
using AgroBase.Services;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AgroBase.Forms
{
public partial class frmBLD : Form
{
public frmBLD()
{
InitializeComponent();
}
private void frmBLD_Load(object sender, EventArgs e)
{
btnAtualizar_Click(sender, e);
LoopAtualizacao().ConfigureAwait(false);
this.Text += " - " + BLD300RService.PortaBLD.PortName;
}
private async Task LoopAtualizacao()
{
if (BLD300RService.Iniciado)
{
if (btnSalvar.Text == "Editar")
{
AtualizarDadosTela();
}
btnAtivar.Text = BLD300RService.UltimaLeitura.Ativado ? "Desligar" : "Ligar";
btnSentido.Text = BLD300RService.UltimaLeitura.Direcao == Enuns.Sentido.Horario ? "Antihorário" : "Horário";
btnFrear.Text = BLD300RService.UltimaLeitura.Freado ? "Desligar" : "Ligar";
lblRPM.Text = BLD300RService.UltimaLeitura.RPM.ToString();
lblRPMSP.Text = BLD300RService.UltimaLeitura.RPM_SP.ToString();
FuncoesGlobais.PreencheValorProgressBar(pgbRPM, BLD300RService.UltimaLeitura.RPM);
FuncoesGlobais.PreencheValorProgressBar(pgbRPMSP, BLD300RService.UltimaLeitura.RPM_SP);
txtCodAlarme.Text = BLD300RService.UltimaLeitura.CodigoAlarme.ToString();
}
btnAtivar.Enabled = btnSalvar.Text == "Editar";
btnSentido.Enabled = btnSalvar.Text == "Editar";
btnFrear.Enabled = btnSalvar.Text == "Editar";
trbRPMSP.Enabled = btnSalvar.Text == "Editar";
chbControleSerial.Enabled = btnSalvar.Text != "Editar";
nudEndereco.Enabled = btnSalvar.Text != "Editar";
nudNumPolos.Enabled = btnSalvar.Text != "Editar";
nudRPMMax.Enabled = btnSalvar.Text != "Editar";
nudRampa.Enabled = btnSalvar.Text != "Editar";
await Task.Delay(200);
await LoopAtualizacao();
}
private void AtualizarDadosTela()
{
nudEndereco.Value = BLD300RService.slaveAddress;
trbRPMSP.Maximum = BLD300RService.UltimaLeitura.RPM_Max;
pgbRPM.Maximum = trbRPMSP.Maximum;
pgbRPMSP.Maximum = trbRPMSP.Maximum;
chbControleSerial.Checked = BLD300RService.UltimaLeitura.ControleRS485;
nudNumPolos.Value = BLD300RService.UltimaLeitura.NumeroPolos;
nudRPMMax.Value = BLD300RService.UltimaLeitura.RPM_Max;
nudRampa.Value = BLD300RService.UltimaLeitura.Rampa;
txtTensao.Text = BLD300RService.UltimaLeitura.Tensao.ToString("0.00");
txtTemperatura.Text = BLD300RService.UltimaLeitura.Temperatura.ToString("0.00");
txtCorrente.Text = BLD300RService.UltimaLeitura.CorrenteMax.ToString("0.00");
}
private void btnAtualizar_Click(object sender, EventArgs e)
{
if (BLD300RService.Iniciado)
{
BLD300RService.AtualizarDadosDriver().ConfigureAwait(false);
}
}
private void btnSalvar_Click(object sender, EventArgs e)
{
if (btnSalvar.Text == "Editar")
{
btnSalvar.Text = "Salvar";
}
else
{
BLD300RService.slaveAddress = (byte)nudEndereco.Value;
if (chbControleSerial.Checked != BLD300RService.UltimaLeitura.ControleRS485)
{
var parametro = BLD300RService.Parametros.First(x => x.Chave == "ControleRS485");
var comando = ModbusService.ComandoSetParametro(BLD300RService.slaveAddress, parametro, chbControleSerial.Checked ? 1 : 0);
BLD300RService.EnviarComando(BLD300RService.PortaBLD, comando, parametro).ConfigureAwait(false);
}
if (Convert.ToInt32(nudNumPolos.Value) != BLD300RService.UltimaLeitura.NumeroPolos)
{
var parametro = BLD300RService.Parametros.First(x => x.Chave == "NumPolos");
var comando = ModbusService.ComandoSetParametro(BLD300RService.slaveAddress, parametro, Convert.ToInt32(nudNumPolos.Value));
BLD300RService.EnviarComando(BLD300RService.PortaBLD, comando, parametro).ConfigureAwait(false);
}
if (Convert.ToInt32(nudRPMMax.Value) != BLD300RService.UltimaLeitura.RPM_Max)
{
var parametro = BLD300RService.Parametros.First(x => x.Chave == "RPM_Max");
var comando = ModbusService.ComandoSetParametro(BLD300RService.slaveAddress, parametro, Convert.ToInt32(nudRPMMax.Value));
BLD300RService.EnviarComando(BLD300RService.PortaBLD, comando, parametro).ConfigureAwait(false);
}
if (Convert.ToInt32(nudRampa.Value) != BLD300RService.UltimaLeitura.Rampa)
{
var parametro = BLD300RService.Parametros.First(x => x.Chave == "Rampa");
var comando = ModbusService.ComandoSetParametro(BLD300RService.slaveAddress, parametro, Convert.ToInt32(nudRampa.Value));
BLD300RService.EnviarComando(BLD300RService.PortaBLD, comando, parametro).ConfigureAwait(false);
}
btnSalvar.Text = "Editar";
}
}
private void btnAtivar_Click(object sender, EventArgs e)
{
var parametro = BLD300RService.Parametros.First(x => x.Chave == "Enabled");
var comando = ModbusService.ComandoSetParametro(BLD300RService.slaveAddress, parametro, BLD300RService.UltimaLeitura.Ativado ? 0 : 1);
BLD300RService.EnviarComando(BLD300RService.PortaBLD, comando, parametro).ConfigureAwait(false);
}
private void btnSentido_Click(object sender, EventArgs e)
{
var parametro = BLD300RService.Parametros.First(x => x.Chave == "Direction");
var comando = ModbusService.ComandoSetParametro(BLD300RService.slaveAddress, parametro, BLD300RService.UltimaLeitura.Direcao == Enuns.Sentido.Horario ? 0 : 1);
BLD300RService.EnviarComando(BLD300RService.PortaBLD, comando, parametro).ConfigureAwait(false);
}
private void btnFrear_Click(object sender, EventArgs e)
{
var parametro = BLD300RService.Parametros.First(x => x.Chave == "Breaked");
var comando = ModbusService.ComandoSetParametro(BLD300RService.slaveAddress, parametro, BLD300RService.UltimaLeitura.Freado ? 0 : 1);
BLD300RService.EnviarComando(BLD300RService.PortaBLD, comando, parametro).ConfigureAwait(false);
}
private void trbRPMSP_MouseUp(object sender, MouseEventArgs e)
{
var parametro = BLD300RService.Parametros.First(x => x.Chave == "RPM_SP");
var comando = ModbusService.ComandoSetParametro(BLD300RService.slaveAddress, parametro, trbRPMSP.Value);
BLD300RService.EnviarComando(BLD300RService.PortaBLD, comando, parametro).ConfigureAwait(false);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -67,9 +67,6 @@ namespace AgroBase
this.btnJoyEdt = new System.Windows.Forms.Button();
this.cmbJoysticks = new System.Windows.Forms.ComboBox();
this.timerDispositivos = new System.Windows.Forms.Timer(this.components);
this.gpbSensoriamento = new System.Windows.Forms.GroupBox();
this.lblSenMotores = new System.Windows.Forms.Label();
this.gridSenMotores = new System.Windows.Forms.DataGridView();
this.btnDiagnosticos = new System.Windows.Forms.Button();
this.btnAcompanhamento = new System.Windows.Forms.Button();
this.btnAtuCamera = new System.Windows.Forms.Button();
@ -79,6 +76,8 @@ namespace AgroBase
this.gpbControleDirecional = new System.Windows.Forms.GroupBox();
this.gpbAtalhos = new System.Windows.Forms.GroupBox();
this.pnlAtalhos = new System.Windows.Forms.Panel();
this.btnBLD300R = new System.Windows.Forms.Button();
this.btnWT901C = new System.Windows.Forms.Button();
this.btnLoRaConfig = new System.Windows.Forms.Button();
this.btnResultados = new System.Windows.Forms.Button();
this.btnKinect = new System.Windows.Forms.Button();
@ -94,7 +93,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.btnWT901C = new System.Windows.Forms.Button();
this.gpbAcoes.SuspendLayout();
this.erroStrip.SuspendLayout();
this.pnlLateral.SuspendLayout();
@ -106,8 +104,6 @@ namespace AgroBase
((System.ComponentModel.ISupportInitialize)(this.trkRPM)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tkbAngulo)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tkbVelocidade)).BeginInit();
this.gpbSensoriamento.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.gridSenMotores)).BeginInit();
this.gpbJoystick.SuspendLayout();
this.gpbControleDirecional.SuspendLayout();
this.gpbAtalhos.SuspendLayout();
@ -498,45 +494,6 @@ namespace AgroBase
this.timerDispositivos.Interval = 5000;
this.timerDispositivos.Tick += new System.EventHandler(this.timerDispositivos_Tick);
//
// gpbSensoriamento
//
this.gpbSensoriamento.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gpbSensoriamento.Controls.Add(this.lblSenMotores);
this.gpbSensoriamento.Controls.Add(this.gridSenMotores);
this.gpbSensoriamento.Location = new System.Drawing.Point(12, 508);
this.gpbSensoriamento.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.gpbSensoriamento.Name = "gpbSensoriamento";
this.gpbSensoriamento.Padding = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.gpbSensoriamento.Size = new System.Drawing.Size(609, 212);
this.gpbSensoriamento.TabIndex = 13;
this.gpbSensoriamento.TabStop = false;
this.gpbSensoriamento.Text = "Sensoriamento";
//
// lblSenMotores
//
this.lblSenMotores.AutoSize = true;
this.lblSenMotores.Location = new System.Drawing.Point(12, 23);
this.lblSenMotores.Name = "lblSenMotores";
this.lblSenMotores.Size = new System.Drawing.Size(56, 16);
this.lblSenMotores.TabIndex = 1;
this.lblSenMotores.Text = "Motores";
//
// gridSenMotores
//
this.gridSenMotores.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gridSenMotores.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.gridSenMotores.Location = new System.Drawing.Point(5, 43);
this.gridSenMotores.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.gridSenMotores.Name = "gridSenMotores";
this.gridSenMotores.RowHeadersWidth = 51;
this.gridSenMotores.RowTemplate.Height = 24;
this.gridSenMotores.Size = new System.Drawing.Size(597, 162);
this.gridSenMotores.TabIndex = 0;
//
// btnDiagnosticos
//
this.btnDiagnosticos.Location = new System.Drawing.Point(7, 8);
@ -637,6 +594,7 @@ namespace AgroBase
// pnlAtalhos
//
this.pnlAtalhos.AutoScroll = true;
this.pnlAtalhos.Controls.Add(this.btnBLD300R);
this.pnlAtalhos.Controls.Add(this.btnWT901C);
this.pnlAtalhos.Controls.Add(this.btnLoRaConfig);
this.pnlAtalhos.Controls.Add(this.btnResultados);
@ -656,6 +614,28 @@ namespace AgroBase
this.pnlAtalhos.Size = new System.Drawing.Size(150, 352);
this.pnlAtalhos.TabIndex = 0;
//
// btnBLD300R
//
this.btnBLD300R.Location = new System.Drawing.Point(7, 422);
this.btnBLD300R.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnBLD300R.Name = "btnBLD300R";
this.btnBLD300R.Size = new System.Drawing.Size(112, 25);
this.btnBLD300R.TabIndex = 28;
this.btnBLD300R.Text = "BLD300R";
this.btnBLD300R.UseVisualStyleBackColor = true;
this.btnBLD300R.Click += new System.EventHandler(this.btnBLD300R_Click);
//
// btnWT901C
//
this.btnWT901C.Location = new System.Drawing.Point(7, 393);
this.btnWT901C.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnWT901C.Name = "btnWT901C";
this.btnWT901C.Size = new System.Drawing.Size(112, 25);
this.btnWT901C.TabIndex = 27;
this.btnWT901C.Text = "WT901C485";
this.btnWT901C.UseVisualStyleBackColor = true;
this.btnWT901C.Click += new System.EventHandler(this.btnWT901C_Click);
//
// btnLoRaConfig
//
this.btnLoRaConfig.Location = new System.Drawing.Point(7, 364);
@ -825,17 +805,6 @@ namespace AgroBase
this.cmbModoOperacao.TabIndex = 13;
this.cmbModoOperacao.SelectedIndexChanged += new System.EventHandler(this.cmbModoOperacao_SelectedIndexChanged);
//
// btnWT901C
//
this.btnWT901C.Location = new System.Drawing.Point(7, 393);
this.btnWT901C.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnWT901C.Name = "btnWT901C";
this.btnWT901C.Size = new System.Drawing.Size(112, 25);
this.btnWT901C.TabIndex = 27;
this.btnWT901C.Text = "WT901C485";
this.btnWT901C.UseVisualStyleBackColor = true;
this.btnWT901C.Click += new System.EventHandler(this.btnWT901C_Click);
//
// frmPrincipal
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
@ -846,7 +815,6 @@ namespace AgroBase
this.Controls.Add(this.gpbControleDirecional);
this.Controls.Add(this.gpbJoystick);
this.Controls.Add(this.gpbMovimentacao);
this.Controls.Add(this.gpbSensoriamento);
this.Controls.Add(this.generalStrip);
this.Controls.Add(this.gpbAcoes);
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
@ -873,9 +841,6 @@ namespace AgroBase
((System.ComponentModel.ISupportInitialize)(this.trkRPM)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tkbAngulo)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tkbVelocidade)).EndInit();
this.gpbSensoriamento.ResumeLayout(false);
this.gpbSensoriamento.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.gridSenMotores)).EndInit();
this.gpbJoystick.ResumeLayout(false);
this.gpbControleDirecional.ResumeLayout(false);
this.gpbControleDirecional.PerformLayout();
@ -915,7 +880,6 @@ namespace AgroBase
private System.Windows.Forms.TrackBar tkbVelocidade;
private System.Windows.Forms.TrackBar tkbAngulo;
private System.Windows.Forms.Label lblAngulo;
private System.Windows.Forms.GroupBox gpbSensoriamento;
private System.Windows.Forms.Label lblRPM;
private System.Windows.Forms.Button btnDiagnosticos;
public System.Windows.Forms.TrackBar trkRPM;
@ -927,8 +891,6 @@ namespace AgroBase
private System.Windows.Forms.Button btnMapas;
private System.Windows.Forms.Button btnSenCamera;
private System.Windows.Forms.GroupBox gpbJoystick;
private System.Windows.Forms.Label lblSenMotores;
public System.Windows.Forms.DataGridView gridSenMotores;
private System.Windows.Forms.GroupBox gpbControleDirecional;
private System.Windows.Forms.GroupBox gpbAtalhos;
private System.Windows.Forms.GroupBox gpbOperacao;
@ -955,6 +917,7 @@ namespace AgroBase
private System.Windows.Forms.Panel pnlAtalhos;
private System.Windows.Forms.Button btnLoRaConfig;
private System.Windows.Forms.Button btnWT901C;
private System.Windows.Forms.Button btnBLD300R;
}
}

View File

@ -171,6 +171,7 @@ namespace AgroBase
x.Dispositivo == T_Code.Pzm ? (PZEMService.Iniciado ? "Conectado" : "Desconectado") :
x.Dispositivo == T_Code.Lra ? (LoRaService.Iniciado ? "Conectado" : "Desconectado") :
x.Dispositivo == T_Code.Wit ? (WT901CService.Iniciado ? "Conectado" : "Desconectado") :
x.Dispositivo == T_Code.Bld ? (BLD300RService.Iniciado ? "Conectado" : "Desconectado") :
(Variaveis.DispositivosConectados.FirstOrDefault(y => y.PortaCOM() == x.PortaCOM)?.StatusPorta() ?? "Desconectado"))
}).ToArray()
);
@ -387,5 +388,18 @@ namespace AgroBase
MessageBox.Show("Módulo WT901C485 não está conectado!");
}
}
private void btnBLD300R_Click(object sender, EventArgs e)
{
if (BLD300RService.Iniciado || true)
{
frmBLD frm = new frmBLD();
frm.Show();
}
else
{
MessageBox.Show("Driver BLD-300R não está conectado!");
}
}
}
}

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static AgroBase.Models.Enuns;
namespace AgroBase.Models
{
public class BLD300RModel
{
public int Versao { get; set; }
public bool ControleRS485 { get; set; }
public int CodigoAlarme { get; set; }
public int NumeroPolos { get; set; }
public int RPM_Max { get; set; }
public int Rampa { get; set; }
public int RPM_SP { get; set; }
public int RPM { get; set; }
public bool Ativado { get; set; }
public bool Freado { get; set; }
private bool _direcao;
public Sentido Direcao
{
get
{
return _direcao ? Sentido.Horario : Sentido.Antihorario;
}
set
{
_direcao = value == Sentido.Horario ? true : false;
}
}
public double Tensao { get; set; }
public double Temperatura { get; set; }
public double CorrenteMax { get; set; }
}
}

View File

@ -55,6 +55,7 @@ namespace AgroBase.Models
Pzm = 105,
Lra = 106,
Wit = 107,
Bld = 108,
}
public enum F_Code
@ -86,6 +87,7 @@ namespace AgroBase.Models
sBMB = 325,
sLED = 445,
sSNR = 532,
sBLD = 544,
}
public enum BotoesJoystick

View File

@ -419,16 +419,6 @@ namespace AgroBase.Models.Modules
return Conectado;
}
public void PopulaGridSensoriamento()
{
}
public void AtualizaGridSensoriamento()
{
}
public void IniciarRegistrador()
{

View File

@ -287,16 +287,6 @@ namespace AgroBase.Models.Modules
return Conectado;
}
public void PopulaGridSensoriamento()
{
}
public void AtualizaGridSensoriamento()
{
}
public PinoutDataModel CarregarPinout(string nomeArquivo)
{
if (!File.Exists(nomeArquivo))

View File

@ -16,8 +16,6 @@ namespace AgroBase.Models
void SetTaxaAmostragem(int TaxaAmostragem);
bool GetStatusConexao();
List<string> ProtocoloConfiguracao(bool Conectar);
void PopulaGridSensoriamento();
void AtualizaGridSensoriamento();
void IniciarRegistrador();
}

View File

@ -25,19 +25,14 @@ namespace AgroBase.Models
return _MensagemConexaoRecebida;
}
public static int _TaxaAmostragem { get; set; } = 500;
public static int RampaMin { get; set; } = 0;
public static int RampaMax { get; set; } = 1023;
public static int PulsosPorRevolucao { get; set; } = 22;
public static bool _FOC { get; set; } = true;
public static double Kp { get; set; } = 1.75;
public static double Ki { get; set; } = 2.1;
public static double Kd { get; set; } = 0.08;
public static int _DelayBalanceamento { get; set; } = 500;
public static int _MargemRPM { get; set; } = 5;
public static int _MaxOffsetRPM { get; set; } = 25;
public static double DiametroRoda { get; set; } = 0.3556;
public bool Conectado { get; set; } = false;
public static int _TaxaAmostragem { get; set; } = 500;
public static int NumPolos { get; set; } = 0;
public static int Rampa { get; set; } = 0;
public static int RPM_Max { get; set; } = 0;
public static double DiametroRoda { get; set; } = 0.3556;
public static int LogsManter { get; set; } = 60;
public static PinoutDataModel Pinout { get; set; }
public static List<FuncoesPinout> Funcoes { get; set; } = new List<FuncoesPinout>();
@ -58,7 +53,8 @@ namespace AgroBase.Models
Motores = new List<MovSensoriamentoMotor>()
{
new MovSensoriamentoMotor() {
Canal = 0,
Canal = 1,
Endereco = "0x01",
ID = "ET",
Descricao = "Esquerdo Trás",
ConfigSentidos = new ConfiguracaoSentidoMotor() {
@ -68,18 +64,12 @@ namespace AgroBase.Models
Tras = Sentido.Antihorario
},
Funcoes = new List<FuncoesPinout>() {
FuncoesPinout.PWM,
FuncoesPinout.DIR,
FuncoesPinout.BRK,
FuncoesPinout.STP,
FuncoesPinout.HallA,
FuncoesPinout.HallB,
FuncoesPinout.HallC,
FuncoesPinout.TMP,
}
},
new MovSensoriamentoMotor() {
Canal = 1,
Canal = 2,
Endereco = "0x02",
ID = "EF",
Descricao = "Esquerdo Frente",
ConfigSentidos = new ConfiguracaoSentidoMotor() {
@ -89,18 +79,12 @@ namespace AgroBase.Models
Tras = Sentido.Antihorario
},
Funcoes = new List<FuncoesPinout>() {
FuncoesPinout.PWM,
FuncoesPinout.DIR,
FuncoesPinout.BRK,
FuncoesPinout.STP,
FuncoesPinout.HallA,
FuncoesPinout.HallB,
FuncoesPinout.HallC,
FuncoesPinout.TMP,
}
},
new MovSensoriamentoMotor() {
Canal = 2,
Canal = 3,
Endereco = "0x03",
ID = "DT",
Descricao = "Direito Trás",
ConfigSentidos = new ConfiguracaoSentidoMotor() {
@ -110,18 +94,12 @@ namespace AgroBase.Models
Tras = Sentido.Antihorario
},
Funcoes = new List<FuncoesPinout>() {
FuncoesPinout.PWM,
FuncoesPinout.DIR,
FuncoesPinout.BRK,
FuncoesPinout.STP,
FuncoesPinout.HallA,
FuncoesPinout.HallB,
FuncoesPinout.HallC,
FuncoesPinout.TMP,
}
},
new MovSensoriamentoMotor() {
Canal = 3,
Canal = 4,
Endereco = "0x04",
ID = "DF",
Descricao = "Direito Frente",
ConfigSentidos = new ConfiguracaoSentidoMotor() {
@ -131,13 +109,6 @@ namespace AgroBase.Models
Tras = Sentido.Horario
},
Funcoes = new List<FuncoesPinout>() {
FuncoesPinout.PWM,
FuncoesPinout.DIR,
FuncoesPinout.BRK,
FuncoesPinout.STP,
FuncoesPinout.HallA,
FuncoesPinout.HallB,
FuncoesPinout.HallC,
FuncoesPinout.TMP,
}
}
@ -152,13 +123,7 @@ namespace AgroBase.Models
((int)F_Code.Cfg).ToString() + SerialService.SplitMessage +
"MD" + SerialService.SplitParams +
(Conectar ? "1" : "0") + SerialService.SplitParams +
_TaxaAmostragem.ToString() + SerialService.SplitParams +
RampaMin.ToString() + SerialService.SplitParams +
RampaMax.ToString() + SerialService.SplitParams +
PulsosPorRevolucao.ToString() + SerialService.SplitParams +
_DelayBalanceamento.ToString() + SerialService.SplitParams +
_MargemRPM.ToString() + SerialService.SplitParams +
_MaxOffsetRPM.ToString();
_TaxaAmostragem.ToString();
Config.Add(ProtocoloMOD);
return Config;
}
@ -186,24 +151,34 @@ namespace AgroBase.Models
{
switch (TipoSensor)
{
case S_Code.sRPM:
case S_Code.sBLD:
{
double rpm = 0;
double.TryParse(Dados[2].Replace(".", ","), out rpm);
Motor.RPM = rpm;
double potencia = 0;
double.TryParse(Dados[3].Replace(".", ","), out potencia);
Motor.Potencia = potencia;
int aceleracao = 0;
int.TryParse(Dados[4], out aceleracao);
Motor.Aceleracao = (StatusMotor)aceleracao;
double temperatura = 0;
double.TryParse(Dados[3].Replace(".", ","), out temperatura);
Motor.Temperatura = temperatura;
double tensao = 0;
double.TryParse(Dados[4].Replace(".", ","), out tensao);
Motor.Tensao = tensao;
double corrente_max = 0;
double.TryParse(Dados[5].Replace(".", ","), out corrente_max);
Motor.Corrente_Max = corrente_max;
bool ligado = Dados[6] == "1";
Motor.Ligado = ligado;
int sentido = 0;
int.TryParse(Dados[5], out sentido);
int.TryParse(Dados[7], out sentido);
Motor.Sentido = (Sentido)sentido;
Motor.Revertendo = Dados[6] == "1";
double rpm_offset = 0;
double.TryParse(Dados[7].Replace(".", ","), out rpm_offset);
Motor.RPM_Offset = rpm_offset;
bool freio = Dados[8] == "1";
Motor.Freio = freio;
int codAlarme = 0;
int.TryParse(Dados[9], out codAlarme);
Motor.CodigoAlarme = codAlarme;
double tempDriver = 0;
double.TryParse(Dados[10].Replace(".", ","), out tempDriver);
Motor.TemperaturaDriver = tempDriver;
AtualizaGrafico = true;
break;
}
@ -238,20 +213,6 @@ namespace AgroBase.Models
Motor.Inicializado = Dados[2] == "1";
break;
}
case S_Code.sTMP:
{
double t = 0;
double.TryParse(Dados[2].Replace(".", ","), out t);
Motor.Temperatura = t;
/*double u = 0;
double.TryParse(Dados[3].Replace(".", ","), out u);
Motor.Umidade = u;
long i = 0;
long.TryParse(Dados[4].Replace(".", ","), out i);
Motor.IndiceCalor = i;*/
AtualizaGrafico = true;
break;
}
}
}
@ -268,18 +229,11 @@ namespace AgroBase.Models
ComponenteID = Motor.ID,
RPM_SP = Motor.RPM_SP,
RPM = Motor.RPM,
RPM_Offset = Motor.RPM_Offset,
Periodo = Motor.Intervalo,
Potencia = Motor.Potencia,
PotenciaSP = Motor.Potencia_SP,
Kp = Kp,
Ki = Ki,
Kd = Kd,
Temperatura = Motor.Temperatura,
Umidade = Motor.Umidade,
IndiceCalor = Motor.IndiceCalor,
Sentido = Motor.Sentido,
Velocidade = Motor.VelocidadeInstantanea,
TemperaturaDriver = Motor.TemperaturaDriver,
Tensao = Motor.Tensao,
});
if (Motor.LogGrafico.Count() > LogsManter)
@ -287,11 +241,7 @@ namespace AgroBase.Models
Motor.LogGrafico.RemoveAt(0);
}
//frmInstancial.frmPlotMovimentacao.AtualizaGrafico();
/*if (frmPrincipal.Dispositivos.Any(x => x.Dispositivo == T_Code.Mov))
{
((frmMovPlot)(frmPrincipal.Dispositivos.First(x => x.Dispositivo == T_Code.Mov).frmPlot)).AtualizaGrafico();
}*/
frmInstancial.frmAcompanhamento.AtualizaGrafico();
}
}
@ -317,64 +267,6 @@ namespace AgroBase.Models
{
return Conectado;
}
public void PopulaGridSensoriamento()
{
frmInstancial.frmPrincipal.gridSenMotores.Rows.Clear();
frmInstancial.frmPrincipal.gridSenMotores.Columns.Clear();
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clMotor", "Motor");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clInicializado", "Inicializado");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clSentidoSP", "Sentido SP");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clSentido", "Sentido");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clStatus", "Status");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clPotencia", "Potencia");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clRPMOffset", "RPM Offset");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clRPM", "RPM");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clVelocidade", "Velocidade");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clTemperatura", "Temperatura");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clCorrente", "Corrente");
frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clTensao", "Tensão");
//frmInstancial.frmPrincipal.gridSenMotores.Columns.Add("clUmidade", "Umidade");
foreach (var Motor in Motores)
{
frmInstancial.frmPrincipal.gridSenMotores.Rows.Add(new string[]
{
Motor.Descricao,
Motor.Inicializado ? "Sim" : "Não",
Enum.GetName(typeof(Sentido), Motor.Sentido_SP),
Enum.GetName(typeof(Sentido), Motor.Sentido),
Enum.GetName(typeof(StatusMotor), Motor.Aceleracao),
Motor.Potencia.ToString("0.00"),
Motor.RPM_Offset.ToString("0.00"),
Motor.RPM.ToString("0.00"),
Motor.VelocidadeInstantanea.ToString("0.00"),
Motor.Temperatura.ToString("0.00"),
Motor.Corrente.ToString("0.00"),
Motor.Tensao.ToString("0.00"),
//Motor.Umidade.ToString(),
});
}
}
public void AtualizaGridSensoriamento()
{
foreach (var Motor in Motores)
{
Motor.VelocidadeInstantanea = CalculaVelocidadeRPM(Motor.RPM);
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[1].Value = Motor.Inicializado ? "Sim" : "Não";
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[2].Value = Enum.GetName(typeof(Sentido), Motor.Sentido_SP);
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[3].Value = Enum.GetName(typeof(Sentido), Motor.Sentido);
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[4].Value = Enum.GetName(typeof(StatusMotor), Motor.Aceleracao);
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[5].Value = Motor.Potencia.ToString("0.00");
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[6].Value = Motor.RPM_Offset.ToString("0.00");
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[7].Value = Motor.RPM.ToString("0.00");
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[8].Value = Motor.VelocidadeInstantanea.ToString("0.00");
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[9].Value = Motor.Temperatura.ToString("0.00");
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[10].Value = Motor.Corrente.ToString("0.00");
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[11].Value = Motor.Tensao.ToString("0.00");
//frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[10].Value = Motor.Umidade.ToString();
}
}
public void IniciarRegistrador()
{
@ -423,27 +315,37 @@ namespace AgroBase.Models
public int Canal { get; set; }
public string ID { get; set; }
public string Descricao { get; set; }
// SETs
public string Endereco { get; set; }
public bool Ligado { get; set; } = false;
public bool Freio { get; set; } = false;
public int CodigoAlarme { get; set; } = 0;
public int RPM_SP { get; set; } = 0;
public Sentido Sentido_SP { get; set; } = Sentido.Parado;
public int NumeroPolos { get; set; } = 2;
public int Rampa { get; set;} = 0;
public int RPM_Max { get; set; } = 800;
// GETs
public double RPM { get; set; } = 0;
public Sentido Sentido { get; set; } = Sentido.Parado;
public double Temperatura { get; set; } = 0;
public double TemperaturaDriver { get; set; } = 0;
public double Tensao { get; set; } = 0;
public double Corrente_Max { get; set; } = 0;
public bool Comandar { get; set; } = false;
public bool Alarme { get; set; } = false;
public bool Inicializado { get; set; } = false;
public bool Revertendo { get; set; } = false;
public int RPM_SP { get; set; } = 0;
public double Potencia { get; set; } = 0;
public double Potencia_SP { get; set; } = 0;
public Sentido Sentido_SP { get; set; } = Sentido.Parado;
public Sentido Sentido { get; set; } = Sentido.Parado;
public StatusMotor Aceleracao { get; set; } = StatusMotor.Estavel;
public double RPM { get; set; } = 0;
public double RPM_Offset { get; set; } = 0;
public long Intervalo { get; set; } = 0;
public double VelocidadeInstantanea { get; set; } = 0;
public double Temperatura { get; set; } = 0;
public double Umidade { get; set; } = 0;
public double IndiceCalor { get; set; } = 0;
public double Corrente { get; set; } = 0;
public double Tensao { get; set; } = 0;
public ConfiguracaoSentidoMotor ConfigSentidos { get; set; }
public bool Testando { get; set; } = false;
public double VelocidadeInstantanea { get; set; } = 0;
public double Corrente { get; set; } = 0;
public ConfiguracaoSentidoMotor ConfigSentidos { get; set; }
public List<AlarmeModel> Alarmes { get; set; } = new List<AlarmeModel>();
public List<SensoriamentoMotorTestes> LogTestes { get; set; } = new List<SensoriamentoMotorTestes>();
public List<MovSensorimanetoGrafico> LogGrafico { get; set; } = new List<MovSensorimanetoGrafico>();
@ -463,11 +365,10 @@ namespace AgroBase.Models
ID + SerialService.SplitParams +
(Conectar ? "1" : "0") + SerialService.SplitParams +
Canal.ToString() + SerialService.SplitParams +
(Alarme ? "1" : "0") + SerialService.SplitParams +
(Comandar ? "1" : "0") + SerialService.SplitParams +
MovimentacaoModel.Kp.ToString().Replace(",", ".") + SerialService.SplitParams +
MovimentacaoModel.Ki.ToString().Replace(",", ".") + SerialService.SplitParams +
MovimentacaoModel.Kd.ToString().Replace(",", ".") + SerialService.SplitParams +
Endereco + SerialService.SplitParams +
NumeroPolos + SerialService.SplitParams +
Rampa + SerialService.SplitParams +
RPM_Max + SerialService.SplitParams +
PinoutModel.PinoProtocolo(_pinout, Funcoes); // 29 ~ 51
return Protocolo;
@ -509,22 +410,12 @@ namespace AgroBase.Models
string ProtocoloMotor = "";
if (Revertendo && false)
{
return ProtocoloMotor;
}
ProtocoloMotor =
((int)F_Code.Cmd).ToString() + SerialService.SplitMessage +
ID + SerialService.SplitParams +
((int)Sentido_SP).ToString() + SerialService.SplitParams +
RPM_SP.ToString() + SerialService.SplitParams +
(Alarme ? "1" : "0");
if (Sentido_SP != Sentido.Parado)
{
Revertendo = true;
}
(Freio ? "1" : "0");
return ProtocoloMotor;
}
@ -620,18 +511,11 @@ namespace AgroBase.Models
public string ComponenteID { get; set; }
public int RPM_SP { get; set; }
public double RPM { get; set; }
public double RPM_Offset { get; set; }
public long Periodo { get; set; }
public double Potencia { get; set; }
public double PotenciaSP { get; set; }
public double Kp { get; set; }
public double Ki { get; set; }
public double Kd { get; set; }
public double Temperatura { get; set; }
public double Umidade { get; set; }
public double IndiceCalor { get; set; }
public double TemperaturaDriver { get; set; }
public Sentido Sentido { get; set; }
public double Velocidade { get; set; }
public double Tensao { get; set; }
}

View File

@ -210,8 +210,8 @@ namespace AgroBase.Models.Modules
new PinoutModel() { Controlador = TiposControladores.ESP32_WROVER, Barramento = TiposBarramentos.CONTROLADOR, Pino = 2, ComponenteID = "", Descricao = "30", Funcao = FuncoesPinout.NaoConectado, Habilitado = true },
new PinoutModel() { Controlador = TiposControladores.ESP32_WROVER, Barramento = TiposBarramentos.CONTROLADOR, Pino = 0, ComponenteID = "", Descricao = "31", Funcao = FuncoesPinout.NaoConectado, Habilitado = true },
new PinoutModel() { Controlador = TiposControladores.ESP32_WROVER, Barramento = TiposBarramentos.CONTROLADOR, Pino = 4, ComponenteID = "", Descricao = "32", Funcao = FuncoesPinout.NaoConectado, Habilitado = true },
new PinoutModel() { Controlador = TiposControladores.ESP32_WROVER, Barramento = TiposBarramentos.CONTROLADOR, Pino = 16, ComponenteID = "", Descricao = "33", Funcao = FuncoesPinout.NaoConectado, Habilitado = true },
new PinoutModel() { Controlador = TiposControladores.ESP32_WROVER, Barramento = TiposBarramentos.CONTROLADOR, Pino = 17, ComponenteID = "", Descricao = "34", Funcao = FuncoesPinout.NaoConectado, Habilitado = true },
new PinoutModel() { Controlador = TiposControladores.ESP32_WROVER, Barramento = TiposBarramentos.CONTROLADOR, Pino = 16, ComponenteID = "", Descricao = "33", Funcao = FuncoesPinout.RX, Habilitado = false },
new PinoutModel() { Controlador = TiposControladores.ESP32_WROVER, Barramento = TiposBarramentos.CONTROLADOR, Pino = 17, ComponenteID = "", Descricao = "34", Funcao = FuncoesPinout.TX, Habilitado = false },
new PinoutModel() { Controlador = TiposControladores.ESP32_WROVER, Barramento = TiposBarramentos.CONTROLADOR, Pino = 5, ComponenteID = "", Descricao = "35", Funcao = FuncoesPinout.NaoConectado, Habilitado = true },
new PinoutModel() { Controlador = TiposControladores.ESP32_WROVER, Barramento = TiposBarramentos.CONTROLADOR, Pino = 18, ComponenteID = "", Descricao = "36", Funcao = FuncoesPinout.NaoConectado, Habilitado = true },
new PinoutModel() { Controlador = TiposControladores.ESP32_WROVER, Barramento = TiposBarramentos.CONTROLADOR, Pino = 19, ComponenteID = "", Descricao = "37", Funcao = FuncoesPinout.NaoConectado, Habilitado = true },

View File

@ -720,45 +720,6 @@ namespace AgroBase.Models.Modules
return Conectado;
}
public void PopulaGridSensoriamento()
{
}
public void AtualizaGridSensoriamento()
{
foreach (var Sensor in Sensores.Where(x => x.ID.Contains("MV")).ToList())
{
try
{
MovSensoriamentoMotor Motor =
Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Mov) ?
((MovimentacaoModel)(Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == T_Code.Mov).Dados)).Motores.FirstOrDefault(x => Sensor.ID.Contains(x.ID)) :
null;
if (Motor != null)
{
switch (Sensor.Componente)
{
case S_Code.sTMP:
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[9].Value = Motor.Temperatura.ToString("0.00");
break;
case S_Code.sCOR:
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[10].Value = Motor.Corrente.ToString("0.00");
frmInstancial.frmPrincipal.gridSenMotores.Rows[Motor.Canal].Cells[11].Value = Motor.Tensao.ToString("0.00");
break;
}
}
}
catch
{
}
}
}
public void IniciarRegistrador()
{

View File

@ -694,12 +694,9 @@ namespace AgroBase.Models
ComponenteID = Motor.ID,
Inicializado = Motor.Inicializado,
Alarme = Motor.Alarme,
Aceleracao = Motor.Aceleracao,
RPM_SP = Motor.RPM_SP,
RPM = Motor.RPM,
Corrente = Motor.Corrente,
Potencia = Motor.Potencia,
RPM_Offset = Motor.RPM_Offset,
Temperatura = Motor.Temperatura,
Tensao = Motor.Tensao,
Sentido_SP = Motor.Sentido_SP,
@ -1151,12 +1148,9 @@ namespace AgroBase.Models
public double RPM_SP { get; set; }
public double RPM { get; set; }
public double Velocidade { get; set; }
public double Potencia { get; set; }
public double RPM_Offset { get; set; }
public Sentido Sentido_SP { get; set; }
public Sentido Sentido { get; set; }
public double Temperatura { get; set; }
public StatusMotor Aceleracao { get; set; } = StatusMotor.Estavel;
public double Corrente { get; set; }
public double Tensao { get; set; }
}

View File

@ -0,0 +1,525 @@
using AgroBase.Forms;
using AgroBase.Models;
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static AgroBase.Models.Enuns;
using System.Windows.Forms;
using Emgu.CV.Structure;
using static Emgu.CV.ML.KNearest;
namespace AgroBase.Services
{
public class BLD300RService
{
public static SerialPort PortaBLD = null;
public static bool Iniciado
{
get
{
if (PortaBLD != null && !PortaBLD.IsOpen)
{
try
{
PortaBLD.Open();
}
catch
{
PortaBLD = null;
}
}
return PortaBLD != null && PortaBLD.IsOpen;
}
}
public static BLD300RModel UltimaLeitura
{
get
{
// Função auxiliar para converter byte[] para int
int ConvertByteArrayToInt(byte[] bytes)
{
if (bytes == null) return 0;
int result = 0;
if (bytes.Length == 2)
{
string raw = "0x" + bytes[0].ToString("X") + bytes[1].ToString("X");
result = Convert.ToInt32(raw, 16);
}
else if (bytes.Length == 4)
{
string raw = "0x" + bytes[0].ToString("X") + bytes[1].ToString("X") + bytes[2].ToString("X") + bytes[3].ToString("X");
result = Convert.ToInt32(raw, 16);
}
return result;
}
// Função auxiliar para verificar a existência de uma chave e obter o valor correspondente
byte[] GetParametroValue(string chave)
{
return Parametros.FirstOrDefault(x => x.Chave == chave).Valor;
}
// Obtenção e conversão dos parâmetros
int versao = ConvertByteArrayToInt(GetParametroValue("Versao"));
int codigoAlarme = ConvertByteArrayToInt(GetParametroValue("AlarmeCode"));
int numeroPolos = ConvertByteArrayToInt(GetParametroValue("NumPolos"));
int rpmMax = ConvertByteArrayToInt(GetParametroValue("RPM_Max"));
int rampa = ConvertByteArrayToInt(GetParametroValue("Rampa"));
int rpmSp = Convert.ToInt32(ConvertByteArrayToInt(GetParametroValue("RPM_SP")) * Parametros.First(x => x.Chave == "RPM_SP").Escala);
int rpm = Convert.ToInt32(ConvertByteArrayToInt(GetParametroValue("RPM")) * Parametros.First(x => x.Chave == "RPM").Escala);
bool controleRS485 = ConvertByteArrayToInt(GetParametroValue("ControleRS485")) == 1;
bool ativado = ConvertByteArrayToInt(GetParametroValue("Enabled")) == 1;
bool freado = ConvertByteArrayToInt(GetParametroValue("Breaked")) == 1;
Sentido direcao = ConvertByteArrayToInt(GetParametroValue("Direction")) == 1 ? Sentido.Horario : Sentido.Antihorario;
var P_V = Parametros.First(x => x.Chave == "Tensao");
double tensao = ConvertByteArrayToInt(P_V.Valor) * P_V.Escala;
var P_T = Parametros.First(x => x.Chave == "Temperatura");
double temperatura = ConvertByteArrayToInt(P_T.Valor) * P_T.Escala;
var P_A = Parametros.First(x => x.Chave == "LimiteCorrente");
double corrente = ConvertByteArrayToInt(P_A.Valor) * P_A.Escala;
// Criação do modelo com os valores obtidos
BLD300RModel model = new BLD300RModel()
{
Versao = versao,
ControleRS485 = controleRS485,
CodigoAlarme = codigoAlarme,
NumeroPolos = numeroPolos,
RPM_Max = rpmMax,
Rampa = rampa,
RPM_SP = rpmSp,
RPM = rpm,
Ativado = ativado,
Freado = freado,
Direcao = direcao,
Tensao = tensao,
Temperatura = temperatura,
CorrenteMax = corrente
};
return model;
}
}
public static byte slaveAddress = 0x02;
public static List<ModbusParametrosModel> Parametros = new List<ModbusParametrosModel>()
{
new ModbusParametrosModel()
{
Chave = "Versao",
Descricao = "Verifica a versão do driver",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = true,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x00BB
},
new ModbusParametrosModel()
{
Chave = "ControleRS485",
Descricao = "Habilita/Desabilita controle através da interface RS485",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = false,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x00B6
},
new ModbusParametrosModel()
{
Chave = "AlarmeCode",
Descricao = "Verifica o código de alarme",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = true,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x0076
},
new ModbusParametrosModel()
{
Chave = "NumPolos",
Descricao = "Verifica/Define o número de polos do motor definido no driver",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = false,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x0086
},
new ModbusParametrosModel()
{
Chave = "RPM_Max",
Descricao = "Verifica/Define o RPM máximo do motor através do controle",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = false,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x0092
},
new ModbusParametrosModel()
{
Chave = "Rampa",
Descricao = "Verifica/Define o tempo de rampa de aceleração/desaceleração (x 100 ms)",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = false,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x008A
},
new ModbusParametrosModel()
{
Chave = "RPM_SP",
Descricao = "Verifica/Define o RPM de Set Point",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = false,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x0056
},
new ModbusParametrosModel()
{
Chave = "RPM",
Descricao = "Verifica o RPM atual do motor",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 0.27,
LeituraLoop = true,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x005F
},
new ModbusParametrosModel()
{
Chave = "Enabled",
Descricao = "Verifica/Define o status do motor",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = true,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x0066
},
new ModbusParametrosModel()
{
Chave = "Breaked",
Descricao = "Verifica/Define o status do freio do motor",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = true,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x006A
},
new ModbusParametrosModel()
{
Chave = "Direction",
Descricao = "Verifica/Define o sentido de giro do motor",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = true,
LeituraGeral = true,
N_Registros = 0x0001,
Registro = 0x006D
},
new ModbusParametrosModel()
{
Chave = "LimiteCorrente",
Descricao = "Verifica o limite de corrente definido",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 0.01,
LeituraLoop = false,
LeituraGeral = true,
N_Registros = 0x0002,
Registro = 0x0096
},
new ModbusParametrosModel()
{
Chave = "Tensao",
Descricao = "Verifica a tensão de alimentação no driver",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 0.01,
LeituraLoop = true,
LeituraGeral = true,
N_Registros = 0x0002,
Registro = 0x00C8
},
new ModbusParametrosModel()
{
Chave = "Temperatura",
Descricao = "Verifica a temperatura do driver",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 0.01,
LeituraLoop = true,
LeituraGeral = true,
N_Registros = 0x0002,
Registro = 0x00d2
},
new ModbusParametrosModel()
{
Chave = "Restaurar",
Descricao = "Restaura os parâmetros de fábrica",
FuncaoGet = 0x03,
FuncaoSet = 0x06,
Escala = 1,
LeituraLoop = false,
LeituraGeral = false,
N_Registros = 0x0001,
Registro = 0x00CC
},
};
public static async Task<bool> VerificaPortaBLD(SerialPort porta)
{
/*porta.BaudRate = 9600;
porta.StopBits = StopBits.Two;
porta.Parity = Parity.None;
porta.ReadTimeout = 1000;
porta.WriteTimeout = 1000;
var Parametro = Parametros.First(x => x.Chave == "Versao");
var comando = ModbusService.ComandoGetParametro(slaveAddress, Parametro);
EnviarComando(porta, comando);
await Task.Delay(200);
var resposta = SerialService.VerificarRespostaPortasDesconhecidas(porta);*/
RS485Service.Inicializar(porta.PortName);
var Parametro = Parametros.First(x => x.Chave == "Versao");
var comando = ModbusService.ComandoGetParametro(slaveAddress, Parametro);
var resposta = await RS485Service.SendRequestAsync(slaveAddress, comando);
if (resposta.Length >= 5 && resposta[1] == Parametro.FuncaoGet && DecifrarResposta(resposta) != null)
{
AtualizarPortaCOM(porta);
return Iniciado;
}
porta.Close();
return false;
}
public static void AtualizarPortaCOM(SerialPort Porta)
{
/*if (PortaBLD == null)
{
PortaBLD = new SerialPort()
{
Parity = Parity.None,
StopBits = StopBits.Two,
ReadTimeout = 1000,
WriteTimeout = 1000,
};
}
else if (Iniciado)
{
PortaBLD.Close();
}
PortaBLD.BaudRate = Porta.BaudRate;
PortaBLD.PortName = Porta.PortName;
PortaBLD.DataReceived -= PortaBLD_DataReceived;
PortaBLD.DataReceived += PortaBLD_DataReceived;*/
Porta.Close();
PortaBLD = RS485Service._serialPort;
if (Iniciado)
{
DefinirDispositivo();
AtualizarDadosDriver().ConfigureAwait(false);
ReceberDados().ConfigureAwait(false);
}
}
private static void DefinirDispositivo()
{
if (Iniciado)
{
SerialService.DispositivosMapeados.Add(new SerialService.DispositivoDetalhesModel()
{
PortaCOM = PortaBLD.PortName,
Dispositivo = T_Code.Bld,
Erro = !Iniciado,
Versao = 0
});
}
}
public static async Task EnviarComando(SerialPort _Porta, byte[] Comando, ModbusParametrosModel Parametro)
{
if (_Porta != null)
{
if (!_Porta.IsOpen)
{
_Porta.Open();
}
if (_Porta.IsOpen)
{
//_Porta.Write(Comando, 0, Comando.Length);
try
{
byte[] buffer = await RS485Service.SendRequestAsync(slaveAddress, Comando);
DecifrarResposta(buffer, Parametro);
}
catch (Exception ex)
{
Console.WriteLine("Erro ao receber resposta do endereço " + slaveAddress + " para o parâmetro SET " + Parametro.Chave);
}
}
}
}
public static void PortaBLD_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
if (PortaBLD.IsOpen)
{
byte[] buffer = SerialService.LerDadosDaPortaSerial(PortaBLD, 7);
DecifrarResposta(buffer);
}
}
private static async Task<bool> ReceberDados()
{
await Task.Delay(1000);
foreach (var Parametro in Parametros.Where(x => x.LeituraLoop))
{
//EnviarComando(PortaBLD, ModbusService.ComandoGetParametro(slaveAddress, Parametro));
//await Task.Delay(100);
//byte[] buffer = SerialService.VerificarRespostaPortasDesconhecidas(PortaBLD);
//byte[] buffer = SerialService.LerDadosDaPortaSerial(PortaBLD, 5);
//DecifrarResposta(buffer, Parametro);
try
{
byte[] buffer = await RS485Service.SendRequestAsync(slaveAddress, ModbusService.ComandoGetParametro(slaveAddress, Parametro));
DecifrarResposta(buffer, Parametro);
//Console.WriteLine("Resposta recebida com sucesso do endereço " + slaveAddress + " para o parâmetro " + Parametro.Chave + " com valor [" + string.Join(",", Parametro.Valor) + "]");
}
catch (Exception ex)
{
Console.WriteLine("Erro ao receber resposta do endereço " + slaveAddress + " para o parâmetro GET " + Parametro.Chave);
}
}
return await ReceberDados();
}
public static BLD300RModel DecifrarResposta(byte[] resposta, ModbusParametrosModel Parametro = null)
{
try
{
/*if (!VerificarCrc(resposta))
{
Console.Write("CRC inválido. A resposta pode estar corrompida.");
return null;
}*/
if (Parametro == null)
{
Parametro = Parametros.OrderBy(x => x.UltimaRequisicao).First();
}
if (resposta.Length > 3)
{
if (Parametros.Any(x => x.FuncaoGet == resposta[1]))
{
int num_registros = resposta[2];
byte[] bytes_resposta = resposta.Skip(3).Take(num_registros).ToArray();
Parametro.Valor = bytes_resposta;
Parametro.UltimaRequisicao = DateTime.MaxValue;
if (Parametro.Chave == "Versao" && SerialService.DispositivosMapeados.Any(x => x.Dispositivo == T_Code.Bld && x.Versao == 0))
{
SerialService.DispositivosMapeados.First(x => x.Dispositivo == T_Code.Bld).Versao = UltimaLeitura.Versao;
}
}
else if (Parametros.Any(x => x.FuncaoSet == resposta[1]))
{
string parametro_raw = "0x" + (resposta[2].ToString("X").Length == 1 ? "0" : "") + resposta[2].ToString("X") + (resposta[3].ToString("X").Length == 1 ? "0" : "") + resposta[3].ToString("X");
int parametro = Convert.ToInt32(parametro_raw, 16);
string valor_raw = "0x" + (resposta[4].ToString("X").Length == 1 ? "0" : "") + resposta[4].ToString("X") + (resposta[5].ToString("X").Length == 1 ? "0" : "") + resposta[5].ToString("X");
int valor = Convert.ToInt32(valor_raw, 16);
Parametros.First(x => x.Registro == parametro).Valor = resposta.Skip(4).Take(2).ToArray();
//MessageBox.Show("Parâmetro gravado com sucesso!");
}
else
{
Console.WriteLine("Resposta inválida ou código de função incorreto.");
}
}
return new BLD300RModel();
}
catch (Exception ex)
{
}
return null;
}
public static async Task AtualizarDadosDriver()
{
foreach (var Parametro in Parametros.Where(x => x.LeituraGeral))
{
//EnviarComando(PortaBLD, ModbusService.ComandoGetParametro(slaveAddress, Parametro));
//await Task.Delay(100);
//byte[] buffer = SerialService.VerificarRespostaPortasDesconhecidas(PortaBLD);
//DecifrarResposta(buffer, Parametro);
try
{
byte[] buffer = await RS485Service.SendRequestAsync(slaveAddress, ModbusService.ComandoGetParametro(slaveAddress, Parametro));
DecifrarResposta(buffer, Parametro);
}
catch (Exception ex)
{
Console.WriteLine("Erro ao receber resposta do endereço " + slaveAddress + " para o parâmetro GET " + Parametro.Chave);
}
}
}
}
}

View File

@ -260,11 +260,6 @@ namespace AgroBase.Comum
frmPin = new frmPinout(Dispositivo);
if (!EqualityComparer<T>.Default.Equals(Dados, default(T)))
{
Dados.PopulaGridSensoriamento();
}
_Porta.DataReceived -= _Porta_DataReceived;
_Porta.DataReceived += _Porta_DataReceived;
@ -774,7 +769,6 @@ namespace AgroBase.Comum
if (Recebido[0].ToString() == SerialService.BeginSensor && !EqualityComparer<T>.Default.Equals(Dados, default(T)))
{
Dados.RecebeProtocoloSerial(Recebido);
Dados.AtualizaGridSensoriamento();
}
}

View File

@ -0,0 +1,145 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Emgu.CV.ML.KNearest;
namespace AgroBase.Services
{
public class ModbusService
{
public static byte[] Crc16(byte[] data)
{
ushort crc = 0xFFFF;
foreach (byte pos in data)
{
crc ^= pos;
for (int i = 0; i < 8; i++)
{
if ((crc & 1) != 0)
{
crc >>= 1;
crc ^= 0xA001;
}
else
{
crc >>= 1;
}
}
}
return new byte[] { (byte)crc, (byte)(crc >> 8) };
}
public static bool VerifyChecksum(byte[] bytes)
{
if (bytes.Length < 2) return false;
// Extrai o CRC recebido dos últimos dois bytes da mensagem
byte[] receivedCrc = new byte[] { bytes[bytes.Length - 2], bytes[bytes.Length - 1] };
// Extrai os dados da mensagem sem o CRC
byte[] data = new byte[bytes.Length - 2];
Array.Copy(bytes, data, bytes.Length - 2);
// Calcula o CRC dos dados
byte[] computedCrc = Crc16(data);
// Verifica se o CRC calculado é igual ao CRC recebido
return receivedCrc[0] == computedCrc[0] && receivedCrc[1] == computedCrc[1];
}
public static byte[] HexStringToByteArray(string hex)
{
int NumberChars = hex.Length;
byte[] bytes = new byte[NumberChars / 2];
for (int i = 0; i < NumberChars; i += 2)
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
return bytes;
}
public static int ByteArrayToDecimal(byte[] bytes)
{
if (bytes == null)
{
throw new ArgumentNullException(nameof(bytes));
}
switch (bytes.Length)
{
case 2:
// Converter 2 bytes para short e depois para decimal
int shortValue = BitConverter.ToInt32(bytes, 0);
return shortValue;
case 4:
// Converter 4 bytes para int e depois para decimal
int intValue = BitConverter.ToInt32(bytes, 0);
return intValue;
default:
throw new ArgumentException("O array de bytes deve ter 2 ou 4 elementos.");
}
}
public static byte[] ComandoSetParametro(byte slaveAddress, ModbusParametrosModel Parametro, float valor)
{
Parametro.UltimaRequisicao = DateTime.Now;
// Convertendo o valor para o formato correto (LSB = 0.01)
int valorInt = (int)(valor * Parametro.Escala); // Convertendo para inteiro conforme a resolução
byte functionCode = Parametro.FuncaoSet;
ushort registerAddress = Parametro.Registro;
// Construindo o comando
List<byte> command = new List<byte>();
command.Add(slaveAddress);
command.Add(functionCode);
command.AddRange(BitConverter.GetBytes(registerAddress).Reverse()); // Little endian
command.AddRange(BitConverter.GetBytes((ushort)valorInt).Reverse()); // Little endian
byte[] crc = Crc16(command.ToArray()); // Supondo que você tenha a implementação do CRC16
command.AddRange(crc);
return command.ToArray();
}
public static byte[] ComandoGetParametro(byte slaveAddress, ModbusParametrosModel Parametro)
{
Parametro.UltimaRequisicao = DateTime.Now;
byte functionCode = Parametro.FuncaoGet;
ushort registerAddress = Parametro.Registro;
ushort numberOfRegisters = Parametro.N_Registros; // Lendo apenas um registro
// Construindo o comando
List<byte> command = new List<byte>();
command.Add(slaveAddress);
command.Add(functionCode);
command.AddRange(BitConverter.GetBytes(registerAddress).Reverse()); // Big endian
command.AddRange(BitConverter.GetBytes(numberOfRegisters).Reverse()); // Big endian
byte[] crc = Crc16(command.ToArray()); // Supondo que você tenha a implementação do CRC16
command.AddRange(crc);
return command.ToArray();
}
}
public class ModbusParametrosModel
{
public DateTime UltimaRequisicao { get; set; } = DateTime.MaxValue;
public string Descricao { get; set; }
public string Chave { get; set; }
public byte FuncaoGet { get; set; }
public byte FuncaoSet { get; set; }
public byte Registro { get; set; }
public byte N_Registros { get; set; }
public bool LeituraLoop { get; set; }
public bool LeituraGeral { get; set; }
public double Escala { get; set; }
public byte[] Valor { get; set; }
}
}

View File

@ -0,0 +1,87 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AgroBase.Services
{
public class RS485Service
{
public static SerialPort _serialPort;
private static ConcurrentDictionary<int, TaskCompletionSource<byte[]>> _pendingRequests;
private static List<byte> _receiveBuffer = new List<byte>();
public RS485Service(string portName)
{
}
public static void Inicializar(string portName)
{
_serialPort = new SerialPort(portName, 9600, Parity.None, 8, StopBits.Two);
_serialPort.DataReceived += OnDataReceived;
_serialPort.Open();
_pendingRequests = new ConcurrentDictionary<int, TaskCompletionSource<byte[]>>();
}
public static async Task<byte[]> SendRequestAsync(int address, byte[] request)
{
var tcs = new TaskCompletionSource<byte[]>();
_pendingRequests[address] = tcs;
_serialPort.Write(request, 0, request.Length);
// Timeout após 2 segundos
var timeoutTask = Task.Delay(2000).ContinueWith(t => tcs.TrySetCanceled());
var completedTask = await Task.WhenAny(tcs.Task, timeoutTask);
// Verifica se a tarefa concluída foi a de timeout
if (completedTask == timeoutTask)
{
_receiveBuffer.Clear();
throw new TimeoutException("O dispositivo não respondeu dentro do tempo esperado.");
}
// Retorna o resultado da tarefa que não foi de timeout
return await tcs.Task;
}
private static void OnDataReceived(object sender, SerialDataReceivedEventArgs e)
{
while (_serialPort.BytesToRead > 0)
{
byte[] buffer = new byte[_serialPort.BytesToRead];
int bytesRead = _serialPort.Read(buffer, 0, buffer.Length);
_receiveBuffer.AddRange(buffer);
if (_receiveBuffer.Count > 20)
{
_receiveBuffer.Clear();
_serialPort.DiscardInBuffer();
}
// Verifica se a mensagem completa foi recebida
else if (_receiveBuffer.Count >= 4) // Tamanho mínimo de uma mensagem MODBUS RTU (endereço + função + CRC)
{
// Verifica o CRC
if (ModbusService.VerifyChecksum(_receiveBuffer.ToArray()))
{
byte[] response = _receiveBuffer.ToArray();
_receiveBuffer.Clear();
// Processar a resposta e identificar o dispositivo
int address = 0x02;
if (_pendingRequests.TryRemove(address, out var tcs))
{
tcs.SetResult(response);
}
}
}
}
}
}
}

View File

@ -133,6 +133,10 @@ namespace AgroBase.Services
{
DispositivoConectado = WT901CService.Iniciado;
}
else if (Dispositivo == T_Code.Bld)
{
DispositivoConectado = BLD300RService.Iniciado;
}
else
{
IDispositivosService dispositivoService = Variaveis.DispositivosConectados.FirstOrDefault(x => x.Dispositivo == Dispositivo);
@ -270,6 +274,14 @@ namespace AgroBase.Services
return Encontrado;
}
}
if (!BLD300RService.Iniciado)
{
bool Encontrado = await BLD300RService.VerificaPortaBLD(porta);
if (Encontrado)
{
return Encontrado;
}
}
if (!WT901CService.Iniciado)
{
bool Encontrado = await WT901CService.VerificaPortaWT901C(porta);
@ -278,6 +290,7 @@ namespace AgroBase.Services
return Encontrado;
}
}
if (TentativasPortas.TryGetValue(porta.PortName, out int tentativas))
{

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

View File

@ -1 +1 @@
{"ExpansorGPIO":false,"EnderecoExpansor":"","Pinos":[{"Controlador":0,"Barramento":0,"Pino":99,"Descricao":"1","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":98,"Descricao":"2","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":97,"Descricao":"3","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":4,"Descricao":"4","Funcao":5,"Habilitado":true,"ComponenteID":"ET"},{"Controlador":0,"Barramento":0,"Pino":5,"Descricao":"5","Funcao":9,"Habilitado":true,"ComponenteID":"ET"},{"Controlador":0,"Barramento":0,"Pino":6,"Descricao":"6","Funcao":10,"Habilitado":true,"ComponenteID":"ET"},{"Controlador":0,"Barramento":0,"Pino":7,"Descricao":"7","Funcao":11,"Habilitado":true,"ComponenteID":"ET"},{"Controlador":0,"Barramento":0,"Pino":15,"Descricao":"8","Funcao":6,"Habilitado":true,"ComponenteID":"ET"},{"Controlador":0,"Barramento":0,"Pino":16,"Descricao":"9","Funcao":7,"Habilitado":true,"ComponenteID":"ET"},{"Controlador":0,"Barramento":0,"Pino":17,"Descricao":"10","Funcao":8,"Habilitado":true,"ComponenteID":"ET"},{"Controlador":0,"Barramento":0,"Pino":18,"Descricao":"11","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":8,"Descricao":"12","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":3,"Descricao":"13","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":46,"Descricao":"14","Funcao":8,"Habilitado":true,"ComponenteID":"DT"},{"Controlador":0,"Barramento":0,"Pino":9,"Descricao":"15","Funcao":7,"Habilitado":true,"ComponenteID":"DT"},{"Controlador":0,"Barramento":0,"Pino":10,"Descricao":"16","Funcao":6,"Habilitado":true,"ComponenteID":"DT"},{"Controlador":0,"Barramento":0,"Pino":11,"Descricao":"17","Funcao":11,"Habilitado":true,"ComponenteID":"DT"},{"Controlador":0,"Barramento":0,"Pino":12,"Descricao":"18","Funcao":10,"Habilitado":true,"ComponenteID":"DT"},{"Controlador":0,"Barramento":0,"Pino":13,"Descricao":"19","Funcao":9,"Habilitado":true,"ComponenteID":"DT"},{"Controlador":0,"Barramento":0,"Pino":14,"Descricao":"20","Funcao":5,"Habilitado":true,"ComponenteID":"DT"},{"Controlador":0,"Barramento":0,"Pino":96,"Descricao":"21","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":95,"Descricao":"22","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":94,"Descricao":"23","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":93,"Descricao":"24","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":19,"Descricao":"25","Funcao":5,"Habilitado":true,"ComponenteID":"DF"},{"Controlador":0,"Barramento":0,"Pino":20,"Descricao":"26","Funcao":9,"Habilitado":true,"ComponenteID":"DF"},{"Controlador":0,"Barramento":0,"Pino":21,"Descricao":"27","Funcao":11,"Habilitado":true,"ComponenteID":"DF"},{"Controlador":0,"Barramento":0,"Pino":47,"Descricao":"28","Funcao":10,"Habilitado":true,"ComponenteID":"DF"},{"Controlador":0,"Barramento":0,"Pino":48,"Descricao":"29","Funcao":6,"Habilitado":true,"ComponenteID":"DF"},{"Controlador":0,"Barramento":0,"Pino":45,"Descricao":"30","Funcao":7,"Habilitado":true,"ComponenteID":"DF"},{"Controlador":0,"Barramento":0,"Pino":0,"Descricao":"31","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":35,"Descricao":"32","Funcao":8,"Habilitado":true,"ComponenteID":"DF"},{"Controlador":0,"Barramento":0,"Pino":36,"Descricao":"33","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":37,"Descricao":"34","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":38,"Descricao":"35","Funcao":8,"Habilitado":true,"ComponenteID":"EF"},{"Controlador":0,"Barramento":0,"Pino":39,"Descricao":"36","Funcao":7,"Habilitado":true,"ComponenteID":"EF"},{"Controlador":0,"Barramento":0,"Pino":40,"Descricao":"37","Funcao":6,"Habilitado":true,"ComponenteID":"EF"},{"Controlador":0,"Barramento":0,"Pino":41,"Descricao":"38","Funcao":11,"Habilitado":true,"ComponenteID":"EF"},{"Controlador":0,"Barramento":0,"Pino":42,"Descricao":"39","Funcao":10,"Habilitado":true,"ComponenteID":"EF"},{"Controlador":0,"Barramento":0,"Pino":2,"Descricao":"40","Funcao":9,"Habilitado":true,"ComponenteID":"EF"},{"Controlador":0,"Barramento":0,"Pino":1,"Descricao":"41","Funcao":5,"Habilitado":true,"ComponenteID":"EF"},{"Controlador":0,"Barramento":0,"Pino":44,"Descricao":"42","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":43,"Descricao":"43","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":0,"Barramento":0,"Pino":92,"Descricao":"44","Funcao":0,"Habilitado":false,"ComponenteID":""}]}
{"ExpansorGPIO":false,"EnderecoExpansor":"","Pinos":[{"Controlador":1,"Barramento":0,"Pino":99,"Descricao":"1","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":98,"Descricao":"2","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":36,"Descricao":"3","Funcao":12,"Habilitado":true,"ComponenteID":"ET"},{"Controlador":1,"Barramento":0,"Pino":39,"Descricao":"4","Funcao":12,"Habilitado":true,"ComponenteID":"EF"},{"Controlador":1,"Barramento":0,"Pino":34,"Descricao":"5","Funcao":12,"Habilitado":true,"ComponenteID":"DT"},{"Controlador":1,"Barramento":0,"Pino":35,"Descricao":"6","Funcao":12,"Habilitado":true,"ComponenteID":"DF"},{"Controlador":1,"Barramento":0,"Pino":32,"Descricao":"7","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":33,"Descricao":"8","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":25,"Descricao":"9","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":26,"Descricao":"10","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":27,"Descricao":"11","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":14,"Descricao":"12","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":12,"Descricao":"13","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":97,"Descricao":"14","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":13,"Descricao":"15","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":9,"Descricao":"16","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":10,"Descricao":"17","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":11,"Descricao":"18","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":96,"Descricao":"19","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":6,"Descricao":"26","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":7,"Descricao":"27","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":8,"Descricao":"28","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":15,"Descricao":"29","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":2,"Descricao":"30","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":0,"Descricao":"31","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":4,"Descricao":"32","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":16,"Descricao":"33","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":17,"Descricao":"34","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":5,"Descricao":"35","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":18,"Descricao":"36","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":19,"Descricao":"37","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":95,"Descricao":"38","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":21,"Descricao":"39","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":3,"Descricao":"40","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":1,"Descricao":"41","Funcao":0,"Habilitado":false,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":22,"Descricao":"42","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":23,"Descricao":"43","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":94,"Descricao":"44","Funcao":0,"Habilitado":false,"ComponenteID":""}]}

View File

@ -1 +1 @@
002e82922157c4b8bf51d0aac2c5b49b17bb0fad25fc7718f8e99736d0574ac6
fd547cec450dd4e7cc70eb5c8487b1e9776deeb08c0f3d1efb1d416ed404d584

View File

@ -448,3 +448,4 @@ C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.Up2Date
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.exe
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.pdb
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Forms.frmWT901C.resources
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Forms.frmBLD.resources

View File

@ -36,6 +36,7 @@ enum S_Code {
sBMB = 325,
sLED = 445,
sSNR = 532,
sBLD = 544,
};
enum Sentido {

View File

@ -0,0 +1,115 @@
#ifndef ModbusService
#define ModbusService
HardwareSerial SerialDriver(1);
#define RXD1 16
#define TXD1 17
#define DE_RE_PIN 4 // Pino para DE e RE
bool Debug = false;
class ModbusGetResponse {
public:
byte _address;
byte _command_code;
byte _num_registers;
double _value;
ModbusGetResponse() : _address(0), _command_code(0), _num_registers(0), _value(0.0) {}
};
void InicializarModbus(bool _debug = false) {
SerialDriver.begin(9600, SERIAL_8N2, RXD1, TXD1);
Serial.println("Modbus Inicializado");
pinMode(DE_RE_PIN, OUTPUT);
digitalWrite(DE_RE_PIN, LOW); // Inicialmente em modo de recepção
Debug = _debug;
}
// Função para calcular CRC16
uint16_t calculateCRC(const uint8_t* data, uint8_t length) {
uint16_t crc = 0xFFFF;
for (uint8_t i = 0; i < length; i++) {
crc ^= data[i];
for (uint8_t j = 0; j < 8; j++) {
if (crc & 0x0001) {
crc >>= 1;
crc ^= 0xA001;
} else {
crc >>= 1;
}
}
}
return crc;
}
// Função para construir o comando Modbus
void sendModbusCommand(uint8_t slaveAddress, uint8_t functionCode, uint16_t registerAddress, int value, uint8_t* response, uint8_t& length) {
uint8_t command[8];
command[0] = slaveAddress;
command[1] = functionCode;
command[2] = (registerAddress >> 8) & 0xFF; // Big endian
command[3] = registerAddress & 0xFF;
// Converter o valor inteiro para o formato adequado
command[4] = (value >> 8) & 0xFF; // Big endian
command[5] = value & 0xFF;
uint16_t crc = calculateCRC(command, 6);
command[6] = crc & 0xFF;
command[7] = (crc >> 8) & 0xFF;
// Alternar para modo de transmissão
digitalWrite(DE_RE_PIN, HIGH);
vTaskDelay(1); // Pequeno atraso para garantir que o modo de transmissão esteja ativo
SerialDriver.write(command, 8);
if (Debug) {
// Imprimir o comando em formato hexadecimal
Serial.print("Comando enviado: ");
for (int i = 0; i < 8; i++) {
if (command[i] < 0x10) {
Serial.print("0"); // Adiciona um zero à esquerda para bytes menores que 0x10
}
Serial.print(command[i], HEX);
Serial.print(" ");
}
Serial.println();
}
// Alternar para modo de recepção
SerialDriver.flush(); // Garantir que todos os dados foram enviados
digitalWrite(DE_RE_PIN, LOW);
delay(1); // Pequeno atraso para garantir que o modo de recepção esteja ativo
// Aguardar a resposta
delay(100); // Ajuste o tempo de delay conforme necessário
// Ler a resposta
if (SerialDriver.available()) {
length = SerialDriver.readBytes(response, SerialDriver.available());
if (Debug) {
// Imprimir a resposta em formato hexadecimal
Serial.print("Resposta recebida: ");
for (int i = 0; i < length; i++) {
if (response[i] < 0x10) {
Serial.print("0"); // Adiciona um zero à esquerda para bytes menores que 0x10
}
Serial.print(response[i], HEX);
Serial.print(" ");
}
Serial.println();
}
} else {
length = 0;
}
}
#endif

View File

@ -298,4 +298,19 @@ String MontarDadosProtocoloSonarM(int distancias[36], int angulos[36], int posic
return Protocolo;
}
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)rpm + ";" +
(String)temperatura + ";" +
(String)tensao + ";" +
(String)corrente_max + ";" +
(ligado ? "1" : "0") + ";" +
(String)sentido + ";" +
(freio ? "1" : "0") + ";" +
(String)codigo_alarme + ";" +
(String)temp_driver;
return Protocolo;
}
#endif

View File

@ -0,0 +1,354 @@
// Dispositivo: Movimentação
// Versão Firmware: 19
// Ultima atualização: 03/06/2024
// Atualização: Drivers BLD-300R
#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 <HardwareSerial.h>
#include <SimpleKalmanFilter.h>
#define D_Code Mov
#define VERSION 19
#define _pinoLED RGB_BUILTIN
long _baudRate = 115200;
bool Conectado = false;
int _TaxaAmostragem = 500;
class Motor {
public:
// Construtor
Motor(String desc) {
_ID = desc;
}
// Definições
String _ID;
bool Iniciado = false;
bool Testando = false;
PinoModel _pinoTMP;
SimpleKalmanFilter* tempKalman;
int _canal;
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;
void Inicializar() {
if (Iniciado) {
EnviarDadosSerial(_ID + " ja inicializado");
EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
return;
}
if (_pinoTMP.Definido()) {
_pinoTMP.Conectar();
tempKalman = new SimpleKalmanFilter(2, 2, 0.01);
}
xTaskCreatePinnedToCore(&Motor::CheckTaskWrapper, "CheckTask", 5000, this, 21 - _canal + 4, &CheckTaskHandle, tskNO_AFFINITY);
EnviarDadosSerial(_ID + " Iniciado");
Iniciado = true;
EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
ConfigurarDriver();
AtualizarDadosControle(true);
}
void Desligar() {
if (!Iniciado) {
EnviarDadosSerial(_ID + " nao esta inicializado");
EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
return;
}
// Parar a execução das tarefas
vTaskDelete(CheckTaskHandle);
// Redefinir as configurações para os valores iniciais
_pinoTMP.Desconectar();
// Outras redefinições de variáveis de estado, se necessário
delete tempKalman;
EnviarDadosSerial(_ID + " Desligado");
Iniciado = false;
EnviarDadosSerial(MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
AtualizarDadosControle(true);
}
ModbusGetResponse EnviarComandoModbus(byte endereco, byte funcao, byte registro, int valor) {
uint8_t response[256];
uint8_t length = 0;
ModbusGetResponse resposta;
sendModbusCommand(endereco, funcao, registro, valor, response, length);
// GET
if (funcao == 0x03) {
if (length >= 5) { // Verifica se a resposta tem pelo menos 5 bytes (endereco, codigo_comando, numero_registros, 2 bytes de dados, 2 bytes de CRC)
resposta._address = response[0];
resposta._command_code = response[1];
resposta._num_registers = response[2];
if (resposta._num_registers == 2) { // Caso de 2 bytes (sem ponto flutuante)
uint16_t value = (response[3] << 8) | response[4]; // Combina os dois bytes
resposta._value = static_cast<double>(value); // Converte para double
} else if (resposta._num_registers == 4 && length >= 7) { // Caso de 4 bytes (com ponto flutuante)
uint16_t highBytes = (response[3] << 8) | response[4]; // Combina os dois primeiros bytes
uint16_t lowBytes = (response[5] << 8) | response[6]; // Combina os dois últimos bytes
// Converte para double
resposta._value = highBytes + (lowBytes / 10000.0); // Supondo que os valores após a vírgula são representados em 4 dígitos decimais
} else {
Serial.println("Numero de registros inesperado ou resposta incompleta.");
}
} else {
Serial.println("Resposta incompleta.");
}
}
// SET
else if (funcao == 0x06) {
resposta._address = response[0];
resposta._command_code = response[1];
resposta._num_registers = 0;
resposta._value = (response[4] << 8) | response[5];
}
return resposta;
}
void ConfigurarDriver() {
EnviarComandoModbus(_endereco, 0x06, 0x00B6, 1);
EnviarComandoModbus(_endereco, 0x06, 0x0086, _numPolos);
EnviarComandoModbus(_endereco, 0x06, 0x008A, _rampa);
EnviarComandoModbus(_endereco, 0x06, 0x0092, _rpmMax);
}
void AtualizarDadosControle(bool reset = false) {
if (reset) {
_Ligado = false;
_Freio = false;
_SentidoSP = Parado;
_RPM_SP = 0;
}
if (_RPM_SP != RPM_SP) {
RPM_SP = EnviarComandoModbus(_endereco, 0x06, 0x0056, _RPM_SP)._value;
}
if (_Freio != Freio) {
Freio = EnviarComandoModbus(_endereco, 0x06, 0x006A, _Freio ? 1 : 0)._value == 1;
}
if (_SentidoSP != _Sentido) {
int std = EnviarComandoModbus(_endereco, 0x06, 0x006D, _SentidoSP == Horario ? 1 : 0)._value;
_Sentido = !Ligado ? Parado : std == 0 ? Horario : Antihorario;
}
if (_Ligado != Ligado) {
Ligado = EnviarComandoModbus(_endereco, 0x06, 0x0066, _Ligado ? 1 : 0)._value == 1;
}
}
private:
TaskHandle_t CheckTaskHandle = NULL;
static void CheckTaskWrapper(void *pvParameters) {
Motor *motor = static_cast<Motor*>(pvParameters);
motor->CheckTask();
}
void CheckTask() {
unsigned long firstMilis = millis();
while (1)
{
if (!Conectado) {
// Caso não esteja conectado, aguarda 1 segundo até a próxima verificação, liberando uso de CPU
vTaskDelay(1000);
continue;
}
long intMillis = (millis() - firstMilis);
// A cada _TaxaAmostragem, enviar os dados para o software
if (intMillis >= _TaxaAmostragem) {
AferirTemperatura();
AferirDadosDriver();
EnviarDadosSerial(MontarProtocoloSensor(sBLD, _ID, MontarDadosProtocoloBLD(RPM, Temperatura, Tensao, CorrenteMax, Ligado, _Sentido, Freio, CodAlarme, TemperaturaDriver)));
firstMilis = millis();
}
// Aguarda metade do menor período possível entre leituras
vTaskDelay(1);
}
}
void AferirDadosDriver() {
RPM_SP = EnviarComandoModbus(_endereco, 0x03, 0x0056, 1)._value;
RPM = EnviarComandoModbus(_endereco, 0x03, 0x005F, 1)._value;
Ligado = EnviarComandoModbus(_endereco, 0x03, 0x0066, 1)._value == 1;
Freio = EnviarComandoModbus(_endereco, 0x03, 0x006A, 1)._value == 1;
_Sentido = EnviarComandoModbus(_endereco, 0x03, 0x006D, 1)._value == 1 ? Horario : Antihorario;
CodAlarme = EnviarComandoModbus(_endereco, 0x03, 0x0076, 1)._value;
Tensao = EnviarComandoModbus(_endereco, 0x03, 0x00C8, 1)._value;
CorrenteMax = EnviarComandoModbus(_endereco, 0x03, 0x0096, 1)._value;
TemperaturaDriver = EnviarComandoModbus(_endereco, 0x03, 0x00D2, 1)._value;
}
void AferirTemperatura() {
int leitura = _pinoTMP.get();
float leituraNormalizada = tempKalman->updateEstimate(leitura);
Temperatura = leituraNormalizada;
}
};
Motor M1("ET");
Motor M2("EF");
Motor M3("DT");
Motor M4("DF");
Motor* MotorPorID(String ID) {
Motor* _motor =
ID == "ET" ? &M1 :
ID == "EF" ? &M2 :
ID == "DT" ? &M3 :
ID == "DF" ? &M4 :
nullptr;
return _motor;
}
void setup() {
Serial.begin(_baudRate);
delay(10);
InicializarModbus();
}
void loop() {
std::vector<ProtocoloSerial> protocolos = LerBufferSerialFila();
for (int i = 0; i < protocolos.size(); i++) {
ProcessarProtocolo(protocolos[i].protocolo, protocolos[i].funcao, protocolos[i].idMensagem);
}
}
void ProcessarProtocolo(String Protocolo, F_Code _funcao, int idMensagem) {
if (_funcao == Chk) {
EnviarDadosSerial(MontarProtocoloVerificacao(D_Code, VERSION));
}
else if (_funcao == Cfg) {
std::vector<String> Partes = SplitString(Protocolo, (char*)",");
String ID = Partes[0];
bool Conectar = Partes[1] == "1";
if (ID == "MD") {
_TaxaAmostragem = Partes[2].toInt();
EnviarDadosSerial(MontarProtocoloSensor(sCFG, "MD", Conectar ? "1" : "0"));
vTaskDelay(pdMS_TO_TICKS(100));
Conectado = Conectar;
}
else {
int canal = Partes[2].toInt();
String addr = Partes[3];
int num_polos = Partes[4].toInt();
int rampa = Partes[5].toInt();
int rpm_max = Partes[6].toInt();
TiposBarramentos tmpB = (TiposBarramentos)Partes[7].toInt();
int tmp = Partes[8].toInt();
Motor* _motor = MotorPorID(ID);
if (Conectar) {
_motor->_canal = canal;
_motor->_endereco = stringToByte(addr);
_motor->_numPolos = num_polos;
_motor->_rampa = rampa;
_motor->_rpmMax = rpm_max;
_motor->_pinoTMP = PinoModel(tmp, tmpB, _INPUT, ANALOGICO);
_motor->Inicializar();
}
else {
_motor->Desligar();
}
vTaskDelay(pdMS_TO_TICKS(500));
}
}
else if (_funcao == Cmd) {
std::vector<String> Partes = SplitString(Protocolo, (char*)",");
String ID = Partes[0];
Motor* _motor = MotorPorID(ID);
_motor->_SentidoSP = (Sentido)Partes[1].toInt();
_motor->_Ligado = _motor->_SentidoSP != Parado;
_motor->_RPM_SP = Partes[2].toInt();
_motor->_Freio = Partes[3] == "1";
_motor->AtualizarDadosControle();
}
else if (_funcao == Tst) {
std::vector<String> Partes = SplitString(Protocolo, (char*)",");
String ID = Partes[0];
Motor* _motor = MotorPorID(ID);
bool EmTeste = _motor->Testando;
if (!EmTeste) {
//_motor->Testar();
}
}
EnviarDadosSerial(MontarProtocoloMensagemRecebida(idMensagem));
}

View File

@ -0,0 +1,205 @@
import serial
import struct
import time
import crcmod
# Configuração da porta serial
ser = serial.Serial(
port='COM3', # Substitua pelo seu porto serial
baudrate=9600,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_TWO,
timeout=1
)
slave_address = 0x02 # Endereço do escravo
CodigosFuncoes = {
"GetParametro": 0x03,
"SetParametro": 0x06,
}
Parametros = {
"RPM_SP": 0x0056,
"RPM": 0x005F,
"Enabled": 0x0066,
"Breaked": 0x006A,
"Direction": 0x006D,
"AlarmeCode": 0x0076,
"NumPolos": 0x0086,
"Rampa": 0x008A,
"VelocidadeMaxAnalog": 0x0092,
"Current": 0x0096,
"ControleRS485": 0x00B6,
"Versao": 0x00BB,
"Voltage": 0x00C8,
"Temperature": 0x00D2
}
Parametros2 = {
"RPM_SP": (0x0056, 2),
"RPM": (0x005F, 2),
"Enabled": (0x0066, 2),
"Breaked": (0x006A, 2),
"Direction": (0x006D, 2),
"AlarmeCode": (0x0076, 2),
"NumPolos": (0x0086, 2),
"Rampa": (0x008A, 2),
"VelocidadeMaxAnalog": (0x0092, 2),
"Current": (0x0096, 4),
"ControleRS485": (0x00B6, 2),
"Versao": (0x00BB, 2),
"Voltage": (0x00C8, 4), # Exemplo de parâmetro que retorna 4 bytes
"Temperature": (0x00D2, 4) # Exemplo de parâmetro que retorna 4 bytes
}
def crc16(data: bytes):
crc = 0xFFFF
for pos in data:
crc ^= pos
for i in range(8):
if (crc & 1) != 0:
crc >>= 1
crc ^= 0xA001
else:
crc >>= 1
return crc.to_bytes(2, byteorder='little')
def montar_comando(funcao, parametro, val):
function_code = CodigosFuncoes[funcao]
start_address = Parametros[parametro]
num_of_registers = val
command = bytearray([slave_address, function_code]) + start_address.to_bytes(2, byteorder='big') + num_of_registers.to_bytes(2, byteorder='big')
command += crc16(command)
return command
def enviar_comando(comando):
ser.write(comando)
time.sleep(0.1) # Pequena pausa para garantir o envio
resposta = ser.read(ser.inWaiting()) # Lê todos os dados disponíveis na porta
return resposta
def decifrar_resposta(resposta, funcao, parametro):
# Certifique-se de que a resposta é do tipo bytes
if isinstance(resposta, str):
resposta = bytes.fromhex(resposta)
resHex = resposta.hex()
#print(resposta)
#print(resposta.hex())
# Verifica o comprimento da resposta e o código da função
if len(resposta) >= 5 and resposta[1] == CodigosFuncoes[funcao]:
remetente = resposta[0]
# Extrai o número de bytes de dados
num_bytes = resposta[2]
# Verifica se o comprimento da resposta é consistente com o número de bytes de dados
if len(resposta) == 5 + num_bytes:
valor_raw = int.from_bytes(resposta[3:3 + num_bytes], byteorder='big')
valor = valor_raw # * 1 # Ajuste o fator de multiplicação conforme necessário
#print(f"Remetente: {remetente}, {parametro}: {valor}")
return (remetente, valor)
else:
print("Comprimento da resposta inconsistente com o número de bytes de dados.")
else:
print("Resposta inválida ou código de função incorreto.")
return (0, None)
def montar_comando_todos_parametros():
function_code = CodigosFuncoes["GetParametro"]
start_address = 0x0056
num_of_registers = 32
command = bytearray([slave_address, function_code]) + start_address.to_bytes(2, byteorder='big') + num_of_registers.to_bytes(2, byteorder='big')
command += crc16(command)
return command
def decifrar_resposta_todos_parametros(resposta):
# Certifique-se de que a resposta é do tipo bytes
if isinstance(resposta, str):
resposta = bytes.fromhex(resposta)
print(resposta.hex())
# Verifica o comprimento da resposta e o código da função
if len(resposta) >= 5 and resposta[1] == CodigosFuncoes["GetParametro"]:
remetente = resposta[0]
# Extrai o número de bytes de dados
num_bytes = resposta[2]
print(f"Remetente: {remetente}, num_Bytes: {num_bytes}")
# Verifica se o comprimento da resposta é consistente com o número de bytes de dados
if len(resposta) == 5 + num_bytes or True:
valores = {}
for parametro, (endereco, tamanho) in Parametros2.items():
offset = (endereco - 0x0056) * 2 + 3
if offset + tamanho <= len(resposta):
valor_raw = int.from_bytes(resposta[offset:offset + tamanho], byteorder='big')
valores[parametro] = valor_raw * 1 # Ajuste o fator de multiplicação conforme necessário
return (remetente, valores)
else:
print("Comprimento da resposta inconsistente com o número de bytes de dados.")
else:
print("Resposta inválida ou código de função incorreto.")
return (0, {})
try:
while True:
resultados = []
remetente = 0
res = enviar_comando(montar_comando("SetParametro", "ControleRS485", 1))
res = enviar_comando(montar_comando("SetParametro", "VelocidadeMaxAnalog", 500))
if (False):
for parametro in Parametros:
comando = montar_comando("GetParametro", parametro, 1)
res = enviar_comando(comando)
remetente, valor = decifrar_resposta(res, "GetParametro", parametro)
resultados.append((parametro, valor))
# Imprime todos os resultados em uma linha, separados por tabulações
linha_resultados = f"Remetente: {remetente}\t" + ("\t".join(f"{parametro}: {valor}" for parametro, valor in resultados))
print(linha_resultados)
d = 0
if (True):
if (d == 0):
d = 1
else:
d = 0
time.sleep(1)
res = enviar_comando(montar_comando("SetParametro", "Enabled", 1))
print(res.hex())
time.sleep(0.1)
res = enviar_comando(montar_comando("SetParametro", "Direction", d))
print(res)
time.sleep(0.1)
res = enviar_comando(montar_comando("SetParametro", "RPM_SP", 250))
print(res.hex())
time.sleep(5)
res = enviar_comando(montar_comando("SetParametro", "RPM_SP", 0))
print(res.hex())
time.sleep(1)
res = enviar_comando(montar_comando("SetParametro", "Enabled", 0))
print(res.hex())
time.sleep(1)
time.sleep(1)
except KeyboardInterrupt:
res = enviar_comando(montar_comando("SetParametro", "RPM_SP", 0))
print(res.hex())
time.sleep(0.1)
res = enviar_comando(montar_comando("SetParametro", "Enabled", 0))
print("Programa encerrado pelo usuário")
finally:
ser.close()

86
Python/bld300r/test.py Normal file
View File

@ -0,0 +1,86 @@
from pymodbus.client import ModbusSerialClient
from pymodbus.constants import Endian
from pymodbus.payload import BinaryPayloadDecoder, BinaryPayloadBuilder
import struct
# Configuração do cliente Modbus
client = ModbusSerialClient(
method='rtu',
port='COM3', # Substitua pelo seu porto serial
baudrate=9600,
stopbits=2,
bytesize=8,
parity='N',
timeout=1
)
# Função para calcular CRC-16
def calculate_crc(data):
crc = 0xFFFF
for pos in data:
crc ^= pos
for _ in range(8):
if (crc & 1) != 0:
crc >>= 1
crc ^= 0xA001
else:
crc >>= 1
return crc
# Função para ler um registro
def read_register(address, count=1):
response = client.read_holding_registers(address, count, unit=1)
if not response.isError():
decoder = BinaryPayloadDecoder.fromRegisters(response.registers, byteorder=Endian.BIG)
return decoder.decode_16bit_uint()
else:
print("Erro na leitura do registro")
return None
# Função para escrever em um registro
def write_register(address, value):
builder = BinaryPayloadBuilder(byteorder=Endian.BIG)
builder.add_16bit_uint(value)
payload = builder.to_registers()
response = client.write_registers(address, payload, unit=1)
if response.isError():
print("Erro na escrita do registro")
else:
print("Escrita bem-sucedida")
# Função para converter resposta em float
def get_float(data):
float_address = data[3:]
temp = struct.unpack('>f', bytes(float_address))[0]
return temp
# Conectar ao cliente Modbus
if client.connect():
print("Conectado ao driver BLD-300R")
# Exemplo de leitura de velocidade do motor
speed_address = 0x005F
speed = read_register(speed_address)
if speed is not None:
print(f"Velocidade do motor: {speed} rpm")
# Exemplo de leitura de código de alarme
alarm_address = 0x0076
alarm_code = read_register(alarm_address)
if alarm_code is not None:
print(f"Código de alarme: {alarm_code}")
# Exemplo de escrita de velocidade do motor
set_speed_address = 0x0056
set_speed_value = 1100 # Velocidade desejada em rpm
write_register(set_speed_address, set_speed_value)
# Exemplo de habilitação do controle RS485
enable_address = 0x00B6
enable_value = 1 # Habilitar
write_register(enable_address, enable_value)
# Desconectar do cliente Modbus
client.close()
else:
print("Falha na conexão com o driver BLD-300R")