adicionado mks057d, atualizado sensoriamento e atuador
This commit is contained in:
parent
44d88cc81e
commit
453acec2ab
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -235,6 +235,12 @@
|
|||
<Compile Include="Forms\frmMapa.Designer.cs">
|
||||
<DependentUpon>frmMapa.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\frmMKS.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\frmMKS.Designer.cs">
|
||||
<DependentUpon>frmMKS.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\frmMvdConfig.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
@ -359,6 +365,7 @@
|
|||
<Compile Include="Models\LoRaModel.cs" />
|
||||
<Compile Include="Models\MapasModel.cs" />
|
||||
<Compile Include="Models\MensagemFilaModel.cs" />
|
||||
<Compile Include="Models\MKS057DModel.cs" />
|
||||
<Compile Include="Models\Modules\AtuadorModel.cs" />
|
||||
<Compile Include="Models\Modules\DirecionalModel.cs" />
|
||||
<Compile Include="Models\Modules\DispositivoBaseModel.cs" />
|
||||
|
|
@ -397,6 +404,7 @@
|
|||
<Compile Include="Services\LoRaSerializer.cs" />
|
||||
<Compile Include="Services\LoRaService.cs" />
|
||||
<Compile Include="Services\MapasService.cs" />
|
||||
<Compile Include="Services\MKS057DService.cs" />
|
||||
<Compile Include="Services\ModbusService.cs" />
|
||||
<Compile Include="Services\MqttService.cs" />
|
||||
<Compile Include="Services\PythonService.cs" />
|
||||
|
|
@ -592,6 +600,9 @@
|
|||
<EmbeddedResource Include="Forms\frmMapa.resx">
|
||||
<DependentUpon>frmMapa.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\frmMKS.resx">
|
||||
<DependentUpon>frmMKS.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\frmMvdConfig.resx">
|
||||
<DependentUpon>frmMvdConfig.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ namespace AgroBase.Forms.Movimentacao
|
|||
|
||||
TextBox txtEndereco = FuncoesGlobais.FindControlRecursive<TextBox>(gpbSentido, "txt" + Modulo.Modulo_ID + "Endereco");
|
||||
Modulo.MovMotor.Endereco = txtEndereco.Text;
|
||||
Modulo.DirMotor.Endereco = txtEndereco.Text;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -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>
|
||||
|
|
@ -93,6 +93,7 @@ namespace AgroBase
|
|||
this.btnIniciarOperacao = new System.Windows.Forms.Button();
|
||||
this.lblModoOperacao = new System.Windows.Forms.Label();
|
||||
this.cmbModoOperacao = new System.Windows.Forms.ComboBox();
|
||||
this.btnMKS = new System.Windows.Forms.Button();
|
||||
this.gpbAcoes.SuspendLayout();
|
||||
this.erroStrip.SuspendLayout();
|
||||
this.pnlLateral.SuspendLayout();
|
||||
|
|
@ -117,9 +118,9 @@ namespace AgroBase
|
|||
this.gpbAcoes.Controls.Add(this.pnlLateral);
|
||||
this.gpbAcoes.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.gpbAcoes.Location = new System.Drawing.Point(470, 0);
|
||||
this.gpbAcoes.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbAcoes.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.gpbAcoes.Name = "gpbAcoes";
|
||||
this.gpbAcoes.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbAcoes.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.gpbAcoes.Size = new System.Drawing.Size(558, 609);
|
||||
this.gpbAcoes.TabIndex = 0;
|
||||
this.gpbAcoes.TabStop = false;
|
||||
|
|
@ -155,7 +156,7 @@ namespace AgroBase
|
|||
this.pnlLateral.Controls.Add(this.btnNovoDispositivo);
|
||||
this.pnlLateral.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pnlLateral.Location = new System.Drawing.Point(2, 15);
|
||||
this.pnlLateral.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.pnlLateral.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.pnlLateral.Name = "pnlLateral";
|
||||
this.pnlLateral.Size = new System.Drawing.Size(554, 592);
|
||||
this.pnlLateral.TabIndex = 0;
|
||||
|
|
@ -174,9 +175,9 @@ namespace AgroBase
|
|||
//
|
||||
this.gpbDispositivos.Controls.Add(this.lstDisponiveis);
|
||||
this.gpbDispositivos.Location = new System.Drawing.Point(161, 78);
|
||||
this.gpbDispositivos.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbDispositivos.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.gpbDispositivos.Name = "gpbDispositivos";
|
||||
this.gpbDispositivos.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbDispositivos.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.gpbDispositivos.Size = new System.Drawing.Size(386, 133);
|
||||
this.gpbDispositivos.TabIndex = 3;
|
||||
this.gpbDispositivos.TabStop = false;
|
||||
|
|
@ -186,7 +187,7 @@ namespace AgroBase
|
|||
//
|
||||
this.lstDisponiveis.HideSelection = false;
|
||||
this.lstDisponiveis.Location = new System.Drawing.Point(11, 20);
|
||||
this.lstDisponiveis.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.lstDisponiveis.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.lstDisponiveis.Name = "lstDisponiveis";
|
||||
this.lstDisponiveis.Size = new System.Drawing.Size(252, 102);
|
||||
this.lstDisponiveis.TabIndex = 0;
|
||||
|
|
@ -196,7 +197,7 @@ namespace AgroBase
|
|||
// btnRemover
|
||||
//
|
||||
this.btnRemover.Location = new System.Drawing.Point(87, 50);
|
||||
this.btnRemover.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnRemover.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnRemover.Name = "btnRemover";
|
||||
this.btnRemover.Size = new System.Drawing.Size(62, 23);
|
||||
this.btnRemover.TabIndex = 12;
|
||||
|
|
@ -219,7 +220,7 @@ namespace AgroBase
|
|||
this.cmbDispositivos.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbDispositivos.FormattingEnabled = true;
|
||||
this.cmbDispositivos.Location = new System.Drawing.Point(22, 26);
|
||||
this.cmbDispositivos.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.cmbDispositivos.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbDispositivos.Name = "cmbDispositivos";
|
||||
this.cmbDispositivos.Size = new System.Drawing.Size(128, 21);
|
||||
this.cmbDispositivos.TabIndex = 10;
|
||||
|
|
@ -234,9 +235,9 @@ namespace AgroBase
|
|||
this.gpbNovoDispositivo.Controls.Add(this.lblTipo);
|
||||
this.gpbNovoDispositivo.Enabled = false;
|
||||
this.gpbNovoDispositivo.Location = new System.Drawing.Point(16, 78);
|
||||
this.gpbNovoDispositivo.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbNovoDispositivo.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.gpbNovoDispositivo.Name = "gpbNovoDispositivo";
|
||||
this.gpbNovoDispositivo.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbNovoDispositivo.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.gpbNovoDispositivo.Size = new System.Drawing.Size(141, 133);
|
||||
this.gpbNovoDispositivo.TabIndex = 9;
|
||||
this.gpbNovoDispositivo.TabStop = false;
|
||||
|
|
@ -247,7 +248,7 @@ namespace AgroBase
|
|||
this.cmbTipos.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbTipos.FormattingEnabled = true;
|
||||
this.cmbTipos.Location = new System.Drawing.Point(7, 37);
|
||||
this.cmbTipos.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.cmbTipos.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbTipos.Name = "cmbTipos";
|
||||
this.cmbTipos.Size = new System.Drawing.Size(128, 21);
|
||||
this.cmbTipos.TabIndex = 2;
|
||||
|
|
@ -255,7 +256,7 @@ namespace AgroBase
|
|||
// btnSalvar
|
||||
//
|
||||
this.btnSalvar.Location = new System.Drawing.Point(7, 101);
|
||||
this.btnSalvar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnSalvar.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnSalvar.Name = "btnSalvar";
|
||||
this.btnSalvar.Size = new System.Drawing.Size(127, 20);
|
||||
this.btnSalvar.TabIndex = 9;
|
||||
|
|
@ -266,7 +267,7 @@ namespace AgroBase
|
|||
// txtDescricao
|
||||
//
|
||||
this.txtDescricao.Location = new System.Drawing.Point(7, 76);
|
||||
this.txtDescricao.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.txtDescricao.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.txtDescricao.Name = "txtDescricao";
|
||||
this.txtDescricao.Size = new System.Drawing.Size(128, 20);
|
||||
this.txtDescricao.TabIndex = 3;
|
||||
|
|
@ -294,7 +295,7 @@ namespace AgroBase
|
|||
// btnNovoDispositivo
|
||||
//
|
||||
this.btnNovoDispositivo.Location = new System.Drawing.Point(22, 50);
|
||||
this.btnNovoDispositivo.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnNovoDispositivo.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnNovoDispositivo.Name = "btnNovoDispositivo";
|
||||
this.btnNovoDispositivo.Size = new System.Drawing.Size(60, 23);
|
||||
this.btnNovoDispositivo.TabIndex = 8;
|
||||
|
|
@ -355,9 +356,9 @@ namespace AgroBase
|
|||
this.gpbMovimentacao.Controls.Add(this.trkRPM);
|
||||
this.gpbMovimentacao.Controls.Add(this.lblRPM);
|
||||
this.gpbMovimentacao.Location = new System.Drawing.Point(9, 63);
|
||||
this.gpbMovimentacao.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbMovimentacao.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.gpbMovimentacao.Name = "gpbMovimentacao";
|
||||
this.gpbMovimentacao.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbMovimentacao.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.gpbMovimentacao.Size = new System.Drawing.Size(330, 85);
|
||||
this.gpbMovimentacao.TabIndex = 2;
|
||||
this.gpbMovimentacao.TabStop = false;
|
||||
|
|
@ -376,7 +377,7 @@ namespace AgroBase
|
|||
// trkKmh
|
||||
//
|
||||
this.trkKmh.Location = new System.Drawing.Point(168, 37);
|
||||
this.trkKmh.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.trkKmh.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.trkKmh.Maximum = 34;
|
||||
this.trkKmh.Name = "trkKmh";
|
||||
this.trkKmh.Size = new System.Drawing.Size(158, 45);
|
||||
|
|
@ -388,7 +389,7 @@ namespace AgroBase
|
|||
// trkRPM
|
||||
//
|
||||
this.trkRPM.Location = new System.Drawing.Point(4, 37);
|
||||
this.trkRPM.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.trkRPM.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.trkRPM.Maximum = 500;
|
||||
this.trkRPM.Minimum = 5;
|
||||
this.trkRPM.Name = "trkRPM";
|
||||
|
|
@ -411,7 +412,7 @@ namespace AgroBase
|
|||
// tkbAngulo
|
||||
//
|
||||
this.tkbAngulo.Location = new System.Drawing.Point(4, 95);
|
||||
this.tkbAngulo.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.tkbAngulo.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.tkbAngulo.Maximum = 180;
|
||||
this.tkbAngulo.Name = "tkbAngulo";
|
||||
this.tkbAngulo.Size = new System.Drawing.Size(314, 45);
|
||||
|
|
@ -442,7 +443,7 @@ namespace AgroBase
|
|||
// tkbVelocidade
|
||||
//
|
||||
this.tkbVelocidade.Location = new System.Drawing.Point(4, 35);
|
||||
this.tkbVelocidade.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.tkbVelocidade.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.tkbVelocidade.Maximum = 100;
|
||||
this.tkbVelocidade.Minimum = 1;
|
||||
this.tkbVelocidade.Name = "tkbVelocidade";
|
||||
|
|
@ -455,7 +456,7 @@ namespace AgroBase
|
|||
// btnVer
|
||||
//
|
||||
this.btnVer.Location = new System.Drawing.Point(256, 20);
|
||||
this.btnVer.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnVer.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnVer.Name = "btnVer";
|
||||
this.btnVer.Size = new System.Drawing.Size(63, 20);
|
||||
this.btnVer.TabIndex = 13;
|
||||
|
|
@ -466,7 +467,7 @@ namespace AgroBase
|
|||
// btnJoyAtt
|
||||
//
|
||||
this.btnJoyAtt.Location = new System.Drawing.Point(121, 20);
|
||||
this.btnJoyAtt.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnJoyAtt.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnJoyAtt.Name = "btnJoyAtt";
|
||||
this.btnJoyAtt.Size = new System.Drawing.Size(63, 20);
|
||||
this.btnJoyAtt.TabIndex = 12;
|
||||
|
|
@ -477,7 +478,7 @@ namespace AgroBase
|
|||
// btnJoyEdt
|
||||
//
|
||||
this.btnJoyEdt.Location = new System.Drawing.Point(188, 20);
|
||||
this.btnJoyEdt.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnJoyEdt.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnJoyEdt.Name = "btnJoyEdt";
|
||||
this.btnJoyEdt.Size = new System.Drawing.Size(63, 20);
|
||||
this.btnJoyEdt.TabIndex = 11;
|
||||
|
|
@ -490,7 +491,7 @@ namespace AgroBase
|
|||
this.cmbJoysticks.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbJoysticks.FormattingEnabled = true;
|
||||
this.cmbJoysticks.Location = new System.Drawing.Point(4, 21);
|
||||
this.cmbJoysticks.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.cmbJoysticks.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbJoysticks.Name = "cmbJoysticks";
|
||||
this.cmbJoysticks.Size = new System.Drawing.Size(112, 21);
|
||||
this.cmbJoysticks.TabIndex = 3;
|
||||
|
|
@ -503,7 +504,7 @@ namespace AgroBase
|
|||
// btnDiagnosticos
|
||||
//
|
||||
this.btnDiagnosticos.Location = new System.Drawing.Point(5, 6);
|
||||
this.btnDiagnosticos.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnDiagnosticos.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnDiagnosticos.Name = "btnDiagnosticos";
|
||||
this.btnDiagnosticos.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnDiagnosticos.TabIndex = 14;
|
||||
|
|
@ -514,7 +515,7 @@ namespace AgroBase
|
|||
// btnAcompanhamento
|
||||
//
|
||||
this.btnAcompanhamento.Location = new System.Drawing.Point(5, 32);
|
||||
this.btnAcompanhamento.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnAcompanhamento.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnAcompanhamento.Name = "btnAcompanhamento";
|
||||
this.btnAcompanhamento.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnAcompanhamento.TabIndex = 15;
|
||||
|
|
@ -525,7 +526,7 @@ namespace AgroBase
|
|||
// btnAtuCamera
|
||||
//
|
||||
this.btnAtuCamera.Location = new System.Drawing.Point(5, 56);
|
||||
this.btnAtuCamera.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnAtuCamera.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnAtuCamera.Name = "btnAtuCamera";
|
||||
this.btnAtuCamera.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnAtuCamera.TabIndex = 16;
|
||||
|
|
@ -536,7 +537,7 @@ namespace AgroBase
|
|||
// btnMapas
|
||||
//
|
||||
this.btnMapas.Location = new System.Drawing.Point(5, 107);
|
||||
this.btnMapas.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnMapas.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnMapas.Name = "btnMapas";
|
||||
this.btnMapas.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnMapas.TabIndex = 17;
|
||||
|
|
@ -547,7 +548,7 @@ namespace AgroBase
|
|||
// btnSenCamera
|
||||
//
|
||||
this.btnSenCamera.Location = new System.Drawing.Point(5, 82);
|
||||
this.btnSenCamera.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnSenCamera.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnSenCamera.Name = "btnSenCamera";
|
||||
this.btnSenCamera.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnSenCamera.TabIndex = 18;
|
||||
|
|
@ -562,9 +563,9 @@ namespace AgroBase
|
|||
this.gpbJoystick.Controls.Add(this.btnJoyAtt);
|
||||
this.gpbJoystick.Controls.Add(this.btnVer);
|
||||
this.gpbJoystick.Location = new System.Drawing.Point(9, 10);
|
||||
this.gpbJoystick.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbJoystick.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.gpbJoystick.Name = "gpbJoystick";
|
||||
this.gpbJoystick.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbJoystick.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.gpbJoystick.Size = new System.Drawing.Size(330, 49);
|
||||
this.gpbJoystick.TabIndex = 18;
|
||||
this.gpbJoystick.TabStop = false;
|
||||
|
|
@ -577,9 +578,9 @@ namespace AgroBase
|
|||
this.gpbControleDirecional.Controls.Add(this.lblAngulo);
|
||||
this.gpbControleDirecional.Controls.Add(this.lblVelocidade);
|
||||
this.gpbControleDirecional.Location = new System.Drawing.Point(9, 154);
|
||||
this.gpbControleDirecional.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbControleDirecional.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.gpbControleDirecional.Name = "gpbControleDirecional";
|
||||
this.gpbControleDirecional.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbControleDirecional.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.gpbControleDirecional.Size = new System.Drawing.Size(330, 159);
|
||||
this.gpbControleDirecional.TabIndex = 19;
|
||||
this.gpbControleDirecional.TabStop = false;
|
||||
|
|
@ -589,9 +590,9 @@ namespace AgroBase
|
|||
//
|
||||
this.gpbAtalhos.Controls.Add(this.pnlAtalhos);
|
||||
this.gpbAtalhos.Location = new System.Drawing.Point(344, 10);
|
||||
this.gpbAtalhos.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbAtalhos.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.gpbAtalhos.Name = "gpbAtalhos";
|
||||
this.gpbAtalhos.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbAtalhos.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.gpbAtalhos.Size = new System.Drawing.Size(122, 304);
|
||||
this.gpbAtalhos.TabIndex = 20;
|
||||
this.gpbAtalhos.TabStop = false;
|
||||
|
|
@ -600,6 +601,7 @@ namespace AgroBase
|
|||
// pnlAtalhos
|
||||
//
|
||||
this.pnlAtalhos.AutoScroll = true;
|
||||
this.pnlAtalhos.Controls.Add(this.btnMKS);
|
||||
this.pnlAtalhos.Controls.Add(this.btnBLD300R);
|
||||
this.pnlAtalhos.Controls.Add(this.btnWT901C);
|
||||
this.pnlAtalhos.Controls.Add(this.btnLoRaConfig);
|
||||
|
|
@ -616,7 +618,7 @@ namespace AgroBase
|
|||
this.pnlAtalhos.Controls.Add(this.btnContornos);
|
||||
this.pnlAtalhos.Controls.Add(this.btnAtuCalibragem);
|
||||
this.pnlAtalhos.Location = new System.Drawing.Point(4, 14);
|
||||
this.pnlAtalhos.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.pnlAtalhos.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.pnlAtalhos.Name = "pnlAtalhos";
|
||||
this.pnlAtalhos.Size = new System.Drawing.Size(112, 286);
|
||||
this.pnlAtalhos.TabIndex = 0;
|
||||
|
|
@ -624,7 +626,7 @@ namespace AgroBase
|
|||
// btnBLD300R
|
||||
//
|
||||
this.btnBLD300R.Location = new System.Drawing.Point(5, 343);
|
||||
this.btnBLD300R.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnBLD300R.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnBLD300R.Name = "btnBLD300R";
|
||||
this.btnBLD300R.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnBLD300R.TabIndex = 28;
|
||||
|
|
@ -635,7 +637,7 @@ namespace AgroBase
|
|||
// btnWT901C
|
||||
//
|
||||
this.btnWT901C.Location = new System.Drawing.Point(5, 319);
|
||||
this.btnWT901C.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnWT901C.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnWT901C.Name = "btnWT901C";
|
||||
this.btnWT901C.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnWT901C.TabIndex = 27;
|
||||
|
|
@ -646,7 +648,7 @@ namespace AgroBase
|
|||
// btnLoRaConfig
|
||||
//
|
||||
this.btnLoRaConfig.Location = new System.Drawing.Point(5, 296);
|
||||
this.btnLoRaConfig.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnLoRaConfig.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnLoRaConfig.Name = "btnLoRaConfig";
|
||||
this.btnLoRaConfig.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnLoRaConfig.TabIndex = 26;
|
||||
|
|
@ -657,7 +659,7 @@ namespace AgroBase
|
|||
// btnResultados
|
||||
//
|
||||
this.btnResultados.Location = new System.Drawing.Point(5, 272);
|
||||
this.btnResultados.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnResultados.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnResultados.Name = "btnResultados";
|
||||
this.btnResultados.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnResultados.TabIndex = 25;
|
||||
|
|
@ -668,7 +670,7 @@ namespace AgroBase
|
|||
// btnKinect
|
||||
//
|
||||
this.btnKinect.Location = new System.Drawing.Point(5, 249);
|
||||
this.btnKinect.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnKinect.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnKinect.Name = "btnKinect";
|
||||
this.btnKinect.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnKinect.TabIndex = 24;
|
||||
|
|
@ -679,7 +681,7 @@ namespace AgroBase
|
|||
// btnSimulador
|
||||
//
|
||||
this.btnSimulador.Location = new System.Drawing.Point(5, 225);
|
||||
this.btnSimulador.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnSimulador.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnSimulador.Name = "btnSimulador";
|
||||
this.btnSimulador.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnSimulador.TabIndex = 23;
|
||||
|
|
@ -690,7 +692,7 @@ namespace AgroBase
|
|||
// btnGPS
|
||||
//
|
||||
this.btnGPS.Location = new System.Drawing.Point(5, 132);
|
||||
this.btnGPS.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnGPS.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnGPS.Name = "btnGPS";
|
||||
this.btnGPS.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnGPS.TabIndex = 19;
|
||||
|
|
@ -701,7 +703,7 @@ namespace AgroBase
|
|||
// btnSonar
|
||||
//
|
||||
this.btnSonar.Location = new System.Drawing.Point(5, 202);
|
||||
this.btnSonar.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnSonar.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnSonar.Name = "btnSonar";
|
||||
this.btnSonar.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnSonar.TabIndex = 22;
|
||||
|
|
@ -712,7 +714,7 @@ namespace AgroBase
|
|||
// btnContornos
|
||||
//
|
||||
this.btnContornos.Location = new System.Drawing.Point(5, 155);
|
||||
this.btnContornos.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnContornos.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnContornos.Name = "btnContornos";
|
||||
this.btnContornos.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnContornos.TabIndex = 20;
|
||||
|
|
@ -723,7 +725,7 @@ namespace AgroBase
|
|||
// btnAtuCalibragem
|
||||
//
|
||||
this.btnAtuCalibragem.Location = new System.Drawing.Point(5, 179);
|
||||
this.btnAtuCalibragem.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnAtuCalibragem.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnAtuCalibragem.Name = "btnAtuCalibragem";
|
||||
this.btnAtuCalibragem.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnAtuCalibragem.TabIndex = 21;
|
||||
|
|
@ -740,9 +742,9 @@ namespace AgroBase
|
|||
this.gpbOperacao.Controls.Add(this.lblModoOperacao);
|
||||
this.gpbOperacao.Controls.Add(this.cmbModoOperacao);
|
||||
this.gpbOperacao.Location = new System.Drawing.Point(9, 315);
|
||||
this.gpbOperacao.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbOperacao.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.gpbOperacao.Name = "gpbOperacao";
|
||||
this.gpbOperacao.Padding = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.gpbOperacao.Padding = new System.Windows.Forms.Padding(2);
|
||||
this.gpbOperacao.Size = new System.Drawing.Size(457, 97);
|
||||
this.gpbOperacao.TabIndex = 21;
|
||||
this.gpbOperacao.TabStop = false;
|
||||
|
|
@ -751,7 +753,7 @@ namespace AgroBase
|
|||
// btnIHM
|
||||
//
|
||||
this.btnIHM.Location = new System.Drawing.Point(296, 58);
|
||||
this.btnIHM.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnIHM.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnIHM.Name = "btnIHM";
|
||||
this.btnIHM.Size = new System.Drawing.Size(122, 33);
|
||||
this.btnIHM.TabIndex = 16;
|
||||
|
|
@ -762,7 +764,7 @@ namespace AgroBase
|
|||
// btnConfigurarOperacao
|
||||
//
|
||||
this.btnConfigurarOperacao.Location = new System.Drawing.Point(121, 58);
|
||||
this.btnConfigurarOperacao.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnConfigurarOperacao.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnConfigurarOperacao.Name = "btnConfigurarOperacao";
|
||||
this.btnConfigurarOperacao.Size = new System.Drawing.Size(122, 33);
|
||||
this.btnConfigurarOperacao.TabIndex = 15;
|
||||
|
|
@ -774,7 +776,7 @@ namespace AgroBase
|
|||
//
|
||||
this.chbDebugMode.AutoSize = true;
|
||||
this.chbDebugMode.Location = new System.Drawing.Point(134, 35);
|
||||
this.chbDebugMode.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.chbDebugMode.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.chbDebugMode.Name = "chbDebugMode";
|
||||
this.chbDebugMode.Size = new System.Drawing.Size(109, 17);
|
||||
this.chbDebugMode.TabIndex = 14;
|
||||
|
|
@ -784,7 +786,7 @@ namespace AgroBase
|
|||
// btnIniciarOperacao
|
||||
//
|
||||
this.btnIniciarOperacao.Location = new System.Drawing.Point(7, 58);
|
||||
this.btnIniciarOperacao.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.btnIniciarOperacao.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnIniciarOperacao.Name = "btnIniciarOperacao";
|
||||
this.btnIniciarOperacao.Size = new System.Drawing.Size(109, 33);
|
||||
this.btnIniciarOperacao.TabIndex = 13;
|
||||
|
|
@ -807,12 +809,23 @@ namespace AgroBase
|
|||
this.cmbModoOperacao.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbModoOperacao.FormattingEnabled = true;
|
||||
this.cmbModoOperacao.Location = new System.Drawing.Point(7, 33);
|
||||
this.cmbModoOperacao.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.cmbModoOperacao.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.cmbModoOperacao.Name = "cmbModoOperacao";
|
||||
this.cmbModoOperacao.Size = new System.Drawing.Size(110, 21);
|
||||
this.cmbModoOperacao.TabIndex = 13;
|
||||
this.cmbModoOperacao.SelectedIndexChanged += new System.EventHandler(this.cmbModoOperacao_SelectedIndexChanged);
|
||||
//
|
||||
// btnMKS
|
||||
//
|
||||
this.btnMKS.Location = new System.Drawing.Point(5, 367);
|
||||
this.btnMKS.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.btnMKS.Name = "btnMKS";
|
||||
this.btnMKS.Size = new System.Drawing.Size(84, 20);
|
||||
this.btnMKS.TabIndex = 29;
|
||||
this.btnMKS.Text = "MKS 057D";
|
||||
this.btnMKS.UseVisualStyleBackColor = true;
|
||||
this.btnMKS.Click += new System.EventHandler(this.btnMKS_Click);
|
||||
//
|
||||
// frmPrincipal
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
|
@ -825,7 +838,7 @@ namespace AgroBase
|
|||
this.Controls.Add(this.gpbMovimentacao);
|
||||
this.Controls.Add(this.generalStrip);
|
||||
this.Controls.Add(this.gpbAcoes);
|
||||
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.Name = "frmPrincipal";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Agro Base";
|
||||
|
|
@ -926,6 +939,7 @@ namespace AgroBase
|
|||
private System.Windows.Forms.Button btnLoRaConfig;
|
||||
private System.Windows.Forms.Button btnWT901C;
|
||||
private System.Windows.Forms.Button btnBLD300R;
|
||||
private System.Windows.Forms.Button btnMKS;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ namespace AgroBase
|
|||
{
|
||||
Variaveis.DispositivosConectados.Where(x => x.Dados.GetStatusConexao()).ToList().ForEach(x => x.AcaoDesconectar());
|
||||
}
|
||||
SerialService.RealizarVarreduraPortasUSB().ConfigureAwait(false);
|
||||
//SerialService.RealizarVarreduraPortasUSB().ConfigureAwait(false);
|
||||
|
||||
if (
|
||||
Variaveis.OperacaoEmAndamento.DispAtu == null && Variaveis.DispositivosConectados.Any(x => x.Dispositivo == T_Code.Atu) ||
|
||||
|
|
@ -437,5 +437,11 @@ namespace AgroBase
|
|||
MessageBox.Show("Driver BLD-300R não está conectado!");
|
||||
}*/
|
||||
}
|
||||
|
||||
private void btnMKS_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmMKS frm = new frmMKS();
|
||||
frm.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,9 +120,6 @@
|
|||
<metadata name="erroStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>11, 10</value>
|
||||
</metadata>
|
||||
<metadata name="erroStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>11, 10</value>
|
||||
</metadata>
|
||||
<metadata name="generalStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>133, 16</value>
|
||||
</metadata>
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ namespace AgroBase.Forms
|
|||
}
|
||||
|
||||
pnlOrientacaoTrajeto.Invalidate();
|
||||
pnlAnguloControle.Invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ namespace AgroBase.Models
|
|||
Bld = 108,
|
||||
Mvd = 109,
|
||||
Mbs = 110,
|
||||
Mks = 111,
|
||||
}
|
||||
|
||||
public enum F_Code
|
||||
|
|
@ -94,6 +95,7 @@ namespace AgroBase.Models
|
|||
sBLD = 544,
|
||||
sCMD = 878,
|
||||
sMVD = 477,
|
||||
sATU = 478,
|
||||
}
|
||||
|
||||
public enum BotoesJoystick
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ namespace AgroBase
|
|||
|
||||
public static void EnviaComandoMotor(Keys Tecla, T_Code? Disp = null)
|
||||
{
|
||||
if ((DispCon.Count == 0 || Variaveis.OperacaoEmAndamento.Modo != ModoOperacao.Manual || !Variaveis.OperacaoEmAndamento.Iniciado))
|
||||
if ((Variaveis.OperacaoEmAndamento.Modo != ModoOperacao.Manual || !Variaveis.OperacaoEmAndamento.Iniciado))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
using AgroBase.Services;
|
||||
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 MKS057DModel
|
||||
{
|
||||
public bool Iniciado { get; set; }
|
||||
public double ErroCarregado { get; set; }
|
||||
public string ErroCarregado_Hex { get; set; }
|
||||
public double ErroAcumulado { get; set; }
|
||||
public string ErroAcumulado_Hex { get; set; }
|
||||
public double RPM { get; set; }
|
||||
public string RPM_Hex { get; set; }
|
||||
public int NumeroPulsos { get; set; }
|
||||
public string NumeroPulsos_Hex { get; set; }
|
||||
public double ErroAngulo { get; set; }
|
||||
public string ErroAngulo_Hex { get; set; }
|
||||
public Estado StatusDriver { get; set; }
|
||||
public StatusComando StatusModoLimiteZero { get; set; }
|
||||
public Estado StatusTravaMotor { get; set; }
|
||||
public StatusComando StatusBloqueioMotor { get; set; }
|
||||
public StatusComando StatusMovimentoMotor { get; set; }
|
||||
public Sentido Direcao { get; set; }
|
||||
public double Velocidade { get; set; }
|
||||
public double Aceleracao { get; set; }
|
||||
public string Mensagem { get; set; }
|
||||
}
|
||||
|
||||
public class MKS057ComandoModel
|
||||
{
|
||||
public byte Comando { get; set; }
|
||||
public string Endereco { get; set; }
|
||||
public double Angulo { get; set; }
|
||||
public double Velocidade { get; set; }
|
||||
public ModosControle ModoControle { get; set; } = ModosControle.AnguloAbsoluto;
|
||||
public Sentido _Sentido { get; set; } = Sentido.Parado;
|
||||
public bool AguardaResposta { get; set; } = false;
|
||||
public int TimeoutResposta { get; set; } = 1000;
|
||||
}
|
||||
|
||||
public enum ModosOperacao
|
||||
{
|
||||
CR_OPEN = 1,
|
||||
CR_CLOSE = 2,
|
||||
CR_vFOC = 3,
|
||||
SR_OPEN = 4,
|
||||
SR_CLOSE = 5,
|
||||
SR_vFOC = 6,
|
||||
}
|
||||
|
||||
public enum ModosControle
|
||||
{
|
||||
Pulsos = 1,
|
||||
AnguloRelativo = 2,
|
||||
AnguloAbsoluto = 3,
|
||||
}
|
||||
|
||||
public enum ModosRetornoOrigem
|
||||
{
|
||||
Desativado = 0,
|
||||
ModoDirecao = 1,
|
||||
ModoAproximacao = 2,
|
||||
}
|
||||
|
||||
public enum StatusComando
|
||||
{
|
||||
Falha = 0,
|
||||
Sucesso = 1,
|
||||
Erro = 2,
|
||||
Retornando = 3,
|
||||
Completo = 4,
|
||||
Movendo = 5,
|
||||
Parando = 6,
|
||||
Calibrando = 7,
|
||||
}
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ namespace AgroBase.Models
|
|||
DirecaoCarroRua direcaoCaminho = DirecaoCarroRua.Parado;
|
||||
if (TrajetoriaDinamica.Any())
|
||||
{
|
||||
GPSModel PontoMaisProximo = GPSService.PontoMaisProximoRuaProjetada(TrajetoriaDinamica, TrajetoriaTipo.Dinamica);
|
||||
(GPSModel PontoMaisProximo, bool aproximando) = GPSService.PontoMaisProximoRuaProjetada(TrajetoriaDinamica, TrajetoriaTipo.Dinamica);
|
||||
int idxPontoMaisProximo = TrajetoriaDinamica.IndexOf(PontoMaisProximo);
|
||||
direcaoCaminho = TrajetoriaDinamica[idxPontoMaisProximo].DirecaoTrecho;
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
PontosRua.Reverse();
|
||||
}
|
||||
GPSModel PontoMaisProximo = GPSService.PontoMaisProximoRuaProjetada(PontosRua, TrajetoriaTipo.Rua);
|
||||
(GPSModel PontoMaisProximo, bool aproximando) = GPSService.PontoMaisProximoRuaProjetada(PontosRua, TrajetoriaTipo.Rua);
|
||||
int idx = PontosRua.IndexOf(PontoMaisProximo);
|
||||
foreach (var Ponto in PontosRua)
|
||||
{
|
||||
|
|
@ -95,7 +95,7 @@ namespace AgroBase.Models
|
|||
}
|
||||
}
|
||||
double distTrecho = GPSService.DistanciaDoTrecho(Trecho);
|
||||
dentro = distTrecho > 0 && distTrecho < Rua.properties.Length;
|
||||
dentro = (distTrecho > 0 && distTrecho < Rua.properties.Length) || (idx == 0 && !aproximando);
|
||||
|
||||
return dentro;
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
get
|
||||
{
|
||||
if (Trajetoria.Any(x => x.Any()))
|
||||
if (Trajetoria.Any(x => x.Any()) && Trajetoria.Count() > IdxRuaAtual)
|
||||
{
|
||||
var primeiroPontoRua = Trajetoria.Skip(IdxRuaAtual).First().First();
|
||||
return primeiroPontoRua;
|
||||
|
|
@ -135,7 +135,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
get
|
||||
{
|
||||
if (Trajetoria.Any(x => x.Any()))
|
||||
if (Trajetoria.Any(x => x.Any()) && Trajetoria.Count() > IdxRuaAtual)
|
||||
{
|
||||
var ultimoPontoRua = Trajetoria.Skip(IdxRuaAtual).First().Last();
|
||||
return ultimoPontoRua;
|
||||
|
|
@ -166,7 +166,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
if (TrajetoriaDinamica.Any())
|
||||
{
|
||||
GPSModel PontoMaisProximo = GPSService.PontoMaisProximoRuaProjetada(TrajetoriaDinamica, TrajetoriaTipo.Dinamica);
|
||||
(GPSModel PontoMaisProximo, bool aproximando) = GPSService.PontoMaisProximoRuaProjetada(TrajetoriaDinamica, TrajetoriaTipo.Dinamica);
|
||||
int idx = TrajetoriaDinamica.IndexOf(PontoMaisProximo);
|
||||
|
||||
if ((idx + 1) >= TrajetoriaDinamica.Count())
|
||||
|
|
@ -215,7 +215,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
if (IdxRuaAtual > 0)
|
||||
{
|
||||
GPSModel pontoMaisProximo = GPSService.PontoMaisProximoRuaProjetada(Trajetoria[IdxRuaAtual - 1], TrajetoriaTipo.Geral);
|
||||
(GPSModel pontoMaisProximo, bool aproximando) = GPSService.PontoMaisProximoRuaProjetada(Trajetoria[IdxRuaAtual - 1], TrajetoriaTipo.Geral);
|
||||
double distanciaP0 = GPSService.DistanciaEntrePontos(GPSService.UltimaLeitura, pontoMaisProximo);
|
||||
if (distanciaP0 < Variaveis.OperacaoEmAndamento.OpMapaGPS.ReferencialRuaGPS.MargemLimiteEntradaRua)
|
||||
{
|
||||
|
|
@ -261,7 +261,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
if (IdxRuaAtual > 0)
|
||||
{
|
||||
GPSModel pontoMaisProximo = GPSService.PontoMaisProximoRuaProjetada(Trajetoria[IdxRuaAtual - 1], TrajetoriaTipo.Geral);
|
||||
(GPSModel pontoMaisProximo, bool aproximando) = GPSService.PontoMaisProximoRuaProjetada(Trajetoria[IdxRuaAtual - 1], TrajetoriaTipo.Geral);
|
||||
double distanciaP0 = GPSService.DistanciaEntrePontos(GPSService.UltimaLeitura, pontoMaisProximo);
|
||||
if (distanciaP0 < Variaveis.OperacaoEmAndamento.OpMapaGPS.ReferencialRuaGPS.MargemLimiteEntradaRua)
|
||||
{
|
||||
|
|
@ -467,7 +467,7 @@ namespace AgroBase.Models
|
|||
{
|
||||
GPSModel pontoAtual = GPSService.UltimaLeitura;
|
||||
|
||||
GPSModel P0 = GPSService.PontoMaisProximoRuaProjetada(Rua, TrajetoriaTipo.Geral);
|
||||
(GPSModel P0, bool aproximando) = GPSService.PontoMaisProximoRuaProjetada(Rua, TrajetoriaTipo.Geral);
|
||||
int idxP0 = Rua.IndexOf(P0);
|
||||
bool PontoProximo = idxP0 < Rua.Count() - 1;
|
||||
bool PontoAnterior = idxP0 > 0;
|
||||
|
|
@ -496,8 +496,6 @@ namespace AgroBase.Models
|
|||
{
|
||||
List<GPSModel> RuaAtual = Trajetoria.Skip(i).First();
|
||||
|
||||
bool dentroRua = Variaveis.OperacaoEmAndamento.OpMapaGPS.ReferencialRuaGPS.DentroDaRua;
|
||||
|
||||
double anguloProjetar = GPSService.CalcularOrientacao(RuaAtual.First(), RuaAtual.Skip(1).First()) + 90;
|
||||
|
||||
List<GPSModel> RuaProjetada = ProjetarRua(RuaAtual, distanciaEntreRuas, anguloProjetar);
|
||||
|
|
@ -525,13 +523,13 @@ namespace AgroBase.Models
|
|||
|
||||
if (!Caminho.Any())
|
||||
{
|
||||
GPSModel PontoMaisProximo = GPSService.PontoMaisProximoRuaProjetada(RuaProjetada, TrajetoriaTipo.Rua);
|
||||
(GPSModel PontoMaisProximo, bool aproximando) = GPSService.PontoMaisProximoRuaProjetada(RuaProjetada, TrajetoriaTipo.Rua);
|
||||
int idxPontoMaisProximo = RuaProjetada.IndexOf(PontoMaisProximo);
|
||||
|
||||
GPSModel inicio = GPSService.UltimaLeitura;
|
||||
|
||||
List<GPSModel> _caminho = new List<GPSModel>();
|
||||
if (idxPontoMaisProximo == 0)
|
||||
if (idxPontoMaisProximo == 0 && aproximando)
|
||||
{
|
||||
//_caminho.Add(PrimeiroPonto);
|
||||
List<GPSModel> _pontos = GPSService.InterpolarPontos(inicio, PrimeiroPonto, 1.0);
|
||||
|
|
@ -540,9 +538,12 @@ namespace AgroBase.Models
|
|||
_caminho.AddRange(_pontos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//bool dentroRua = Variaveis.OperacaoEmAndamento.OpMapaGPS.ReferencialRuaGPS.DentroDaRua;
|
||||
bool dentroRua = Variaveis.OperacaoEmAndamento.Mapa.DentroDaRua;
|
||||
|
||||
// Se estiver manobrando e a manobra ainda não tiver sido concluída, OU, o ponto mais próximo é o ultimo ponto da rua, e já esta fora da rua
|
||||
if (!Variaveis.OperacaoEmAndamento.OpMapaGPS.ReferencialRuaGPS.ManobraConcluida || (idxPontoMaisProximo == (RuaProjetada.Count() - 1) && !dentroRua))
|
||||
if (!Variaveis.OperacaoEmAndamento.OpMapaGPS.ReferencialRuaGPS.ManobraConcluida || ((idxPontoMaisProximo == (RuaProjetada.Count() - 1)) && !dentroRua))
|
||||
{
|
||||
_caminho.Add(inicio);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using AgroBase.Services;
|
||||
using Emgu.CV.Ocl;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -13,7 +14,7 @@ namespace AgroBase.Models.Modules
|
|||
public class AtuadorModel : DispositivoBaseModel
|
||||
{
|
||||
public string Modulo_ID { get; set; } = T_Code.Atu.ToString();
|
||||
|
||||
public bool RequisitarDados { get; set; } = false;
|
||||
private bool _MensagemConexaoRecebida { get; set; } = false;
|
||||
public bool MensagemConexaoRecebida(bool Reset = false)
|
||||
{
|
||||
|
|
@ -244,19 +245,22 @@ namespace AgroBase.Models.Modules
|
|||
public Dictionary<string, List<string>> ProtocoloConfiguracao(bool Conectar)
|
||||
{
|
||||
// Inicializar o dicionário
|
||||
var configDictionary = new Dictionary<string, List<string>>();
|
||||
var configDictionary = new Dictionary<string, List<string>>() { { Modulo_ID, new List<string>() } };
|
||||
|
||||
// Adicionar configurações dos Bicos Pulverizadores
|
||||
var bicosConfig = BicosPulverizadores.Select(x => x.ProtocoloConfiguracaoBico(Conectar)).ToList();
|
||||
configDictionary.Add(Modulo_ID, bicosConfig);
|
||||
var bicosConfig = BicosPulverizadores.Where(x => x.Comandar).Select(x => x.ProtocoloConfiguracaoBico(Conectar)).ToList();
|
||||
configDictionary[Modulo_ID].AddRange(bicosConfig);
|
||||
|
||||
// Adicionar configuração da Bomba Pressurizadora
|
||||
var bombaConfig = new List<string> { BombaPressurizadora.ProtocoloConfiguracaoBomba(Conectar) };
|
||||
configDictionary.Add(Modulo_ID, bombaConfig);
|
||||
if (BombaPressurizadora.Comandar)
|
||||
{
|
||||
string bombaConfig = BombaPressurizadora.ProtocoloConfiguracaoBomba(Conectar);
|
||||
configDictionary[Modulo_ID].Add(bombaConfig);
|
||||
}
|
||||
|
||||
// Adicionar configurações dos Sensores
|
||||
var sensoresConfig = Sensores.Select(x => x.ProtocoloConfiguracaoSensor(Pinout, Conectar)).ToList();
|
||||
configDictionary.Add(Modulo_ID, sensoresConfig);
|
||||
var sensoresConfig = Sensores.Where(x => x.Aferir).Select(x => x.ProtocoloConfiguracaoSensor(Pinout, Conectar)).ToList();
|
||||
configDictionary[Modulo_ID].AddRange(sensoresConfig);
|
||||
|
||||
// Adicionar configuração do ProtocoloMOD
|
||||
string protocoloMOD =
|
||||
|
|
@ -264,22 +268,50 @@ namespace AgroBase.Models.Modules
|
|||
"MD" + SerialService.SplitParams +
|
||||
(Conectar ? "1" : "0") + SerialService.SplitParams +
|
||||
_TaxaAmostragem.ToString() + SerialService.SplitParams +
|
||||
(AtuacaoNivelAlto ? "1" : "0");
|
||||
var protocoloMODConfig = new List<string> { protocoloMOD };
|
||||
configDictionary.Add(Modulo_ID, protocoloMODConfig);
|
||||
(AtuacaoNivelAlto ? "1" : "0") + SerialService.SplitParams +
|
||||
(RequisitarDados ? "1" : "0");
|
||||
|
||||
configDictionary[Modulo_ID].Add(protocoloMOD);
|
||||
|
||||
configDictionary[Modulo_ID].Add(ProtocoloVerificacao(false));
|
||||
|
||||
return configDictionary;
|
||||
}
|
||||
|
||||
public string ProtocoloVerificacao(bool Completo)
|
||||
{
|
||||
if (Completo)
|
||||
{
|
||||
string ProtocoloCheck =
|
||||
SerialService.BeginLine +
|
||||
0 + SerialService.SplitMessage +
|
||||
Modulo_ID + SerialService.SplitMessage +
|
||||
((int)F_Code.Chk).ToString() + SerialService.SplitMessage +
|
||||
"check" +
|
||||
SerialService.EndLine;
|
||||
|
||||
return ProtocoloCheck;
|
||||
}
|
||||
else
|
||||
{
|
||||
string ProtocoloCheck =
|
||||
((int)F_Code.Chk).ToString() + SerialService.SplitMessage +
|
||||
"check";
|
||||
|
||||
return ProtocoloCheck;
|
||||
}
|
||||
}
|
||||
|
||||
public void RecebeProtocoloSerial(string Protocolo)
|
||||
{
|
||||
// #ET;00000;00000;00000;000
|
||||
if (!string.IsNullOrEmpty(Protocolo) && Protocolo[0].ToString() == SerialService.BeginSensor)
|
||||
string Mod_ID = Protocolo.Split(SerialService.SplitMessage[0])[0];
|
||||
string mensagem = Protocolo.Substring(Mod_ID.Length + 1, Protocolo.Length - Mod_ID.Length - 1);
|
||||
if (!string.IsNullOrEmpty(Protocolo) && mensagem[0].ToString() == SerialService.BeginSensor)
|
||||
{
|
||||
string[] Dados = Protocolo.Replace(SerialService.BeginSensor, "").Split(SerialService.EndLine[0])[0].Split(';');
|
||||
string[] Dados = mensagem.Replace(SerialService.BeginSensor, "").Split(SerialService.EndLine[0])[0].Split(';');
|
||||
string _id = Dados[1].Trim();
|
||||
S_Code TipoSensor = (S_Code)(int.Parse(Dados[0]));
|
||||
AtuadorBicoModel Bico = BicosPulverizadores.FirstOrDefault(x => x.ID.Trim() == _id);
|
||||
/*AtuadorBicoModel Bico = BicosPulverizadores.FirstOrDefault(x => x.ID.Trim() == _id);
|
||||
SensorModel Sensor = Sensores.FirstOrDefault(x => x.ID.Trim() == _id);
|
||||
AtuadorBombaModel Bomba = _id == BombaPressurizadora.ID.Trim() ? BombaPressurizadora : null;
|
||||
if (Bico == null && Sensor == null && Bomba == null)
|
||||
|
|
@ -290,12 +322,12 @@ namespace AgroBase.Models.Modules
|
|||
_MensagemConexaoRecebida = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
try
|
||||
{
|
||||
switch (TipoSensor)
|
||||
{
|
||||
case S_Code.sCFG:
|
||||
/*case S_Code.sCFG:
|
||||
{
|
||||
bool Inicializado = Dados[2] == "1";
|
||||
if (Bico != null)
|
||||
|
|
@ -400,19 +432,120 @@ namespace AgroBase.Models.Modules
|
|||
Bomba.Potencia = potencia;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
case S_Code.sATU:
|
||||
{
|
||||
#region BICOS
|
||||
|
||||
BicosPulverizadores.FirstOrDefault(x => x.ID.Contains("1")).Inicializado = Dados[2] == "1";
|
||||
BicosPulverizadores.FirstOrDefault(x => x.ID.Contains("1")).StatusBico = Dados[3] == "1";
|
||||
|
||||
BicosPulverizadores.FirstOrDefault(x => x.ID.Contains("2")).Inicializado = Dados[4] == "1";
|
||||
BicosPulverizadores.FirstOrDefault(x => x.ID.Contains("2")).StatusBico = Dados[5] == "1";
|
||||
|
||||
BicosPulverizadores.FirstOrDefault(x => x.ID.Contains("3")).Inicializado = Dados[6] == "1";
|
||||
BicosPulverizadores.FirstOrDefault(x => x.ID.Contains("3")).StatusBico = Dados[7] == "1";
|
||||
|
||||
BicosPulverizadores.FirstOrDefault(x => x.ID.Contains("4")).Inicializado = Dados[8] == "1";
|
||||
BicosPulverizadores.FirstOrDefault(x => x.ID.Contains("4")).StatusBico = Dados[9] == "1";
|
||||
|
||||
#endregion
|
||||
|
||||
#region BOMBA
|
||||
|
||||
BombaPressurizadora.Inicializado = Dados[10] == "1";
|
||||
BombaPressurizadora.Ligado = Dados[11] == "1";
|
||||
double.TryParse(Dados[12], out double p);
|
||||
BombaPressurizadora.Potencia = p;
|
||||
|
||||
#endregion
|
||||
|
||||
#region FLUXO
|
||||
|
||||
var SenFlx = Sensores.FirstOrDefault(x => x.Componente == S_Code.sFLX);
|
||||
if (SenFlx != null)
|
||||
{
|
||||
SenFlx.Inicializado = Dados[13] == "1";
|
||||
int.TryParse(Dados[14].Replace(".", ","), out int pulsos);
|
||||
int.TryParse(Dados[15].Replace(".", ","), out int tempo);
|
||||
_LeituraPulsos = pulsos;
|
||||
_LeituraPeriodo = tempo;
|
||||
|
||||
if (VazaoFluxoMLpS > 0)
|
||||
{
|
||||
foreach (var bico in BicosPulverizadores.Where(x => x.Atuado))
|
||||
{
|
||||
bico.MediaNivelFluxo = VazaoFluxoMLpS / BicosPulverizadores.Count(y => y.Atuado);
|
||||
};
|
||||
|
||||
double periodoAtual = SenFlx.Leituras.Any() ? (double)_LeituraPeriodo - SenFlx.Leituras[1] : (double)_LeituraPeriodo;
|
||||
VolumeVazaoML += (VazaoFluxoMLpS) * (periodoAtual / 1000);
|
||||
|
||||
Variaveis.OperacaoEmAndamento.OpMapaGPS.Sensoriamento.HerbicidaConsumido = (VolumeVazaoML / 1000);
|
||||
}
|
||||
SenFlx.Leituras = new List<double>()
|
||||
{
|
||||
pulsos,
|
||||
tempo
|
||||
};
|
||||
|
||||
DefineLimitesSensor(SenFlx);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MASSA
|
||||
|
||||
var SenMas = Sensores.FirstOrDefault(x => x.Componente == S_Code.sMAS);
|
||||
if (SenMas != null)
|
||||
{
|
||||
SenMas.Inicializado = Dados[16] == "1";
|
||||
double.TryParse(Dados[17].Replace(".", ","), out double massa);
|
||||
_MassaLeitura = massa;
|
||||
|
||||
SenMas.Leituras = new List<double>()
|
||||
{
|
||||
massa
|
||||
};
|
||||
}
|
||||
|
||||
DefineLimitesSensor(SenMas);
|
||||
|
||||
#endregion
|
||||
|
||||
#region PRSSAO
|
||||
|
||||
var SenPrs = Sensores.FirstOrDefault(x => x.Componente == S_Code.sPRS);
|
||||
if (SenPrs != null)
|
||||
{
|
||||
SenPrs.Inicializado = Dados[18] == "1";
|
||||
double.TryParse(Dados[19].Replace(".", ","), out double pressao);
|
||||
double.TryParse(Dados[20].Replace(".", ","), out double leitura);
|
||||
|
||||
PressaoLinha = pressao;
|
||||
_LeituraPressao = leitura;
|
||||
|
||||
BombaPressurizadora.Pressao = PressaoLinha;
|
||||
|
||||
SenPrs.Leituras = new List<double>()
|
||||
{
|
||||
pressao,
|
||||
};
|
||||
|
||||
DefineLimitesSensor(SenPrs);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Sensor != null)
|
||||
/*if (Sensor != null)
|
||||
{
|
||||
if (Sensor.Leituras[0] > Sensor.ValorMaximo)
|
||||
{
|
||||
Sensor.ValorMaximo = Sensor.Leituras[0];
|
||||
}
|
||||
else if (Sensor.Leituras[0] < Sensor.ValorMinimo)
|
||||
{
|
||||
Sensor.ValorMinimo = Sensor.Leituras[0];
|
||||
}
|
||||
}
|
||||
DefineLimitesSensor(Sensor);
|
||||
}*/
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -421,6 +554,18 @@ namespace AgroBase.Models.Modules
|
|||
}
|
||||
}
|
||||
|
||||
private void DefineLimitesSensor(SensorModel Sensor)
|
||||
{
|
||||
if (Sensor.Leituras[0] > Sensor.ValorMaximo)
|
||||
{
|
||||
Sensor.ValorMaximo = Sensor.Leituras[0];
|
||||
}
|
||||
else if (Sensor.Leituras[0] < Sensor.ValorMinimo)
|
||||
{
|
||||
Sensor.ValorMinimo = Sensor.Leituras[0];
|
||||
}
|
||||
}
|
||||
|
||||
public void DefineStatusConexao(string Mod_ID, bool conecatdo)
|
||||
{
|
||||
if (Mod_ID == Modulo_ID)
|
||||
|
|
|
|||
|
|
@ -47,25 +47,25 @@ namespace AgroBase.Models.Modules
|
|||
{
|
||||
Modulo_ID = "ET",
|
||||
MovMotor = MvdMotorBLDC.CarregarParametrosIniciais("ET", "0x01"),
|
||||
DirMotor = MvdMotorPasso.CarregarParametrosIniciais("ET"),
|
||||
DirMotor = MvdMotorPasso.CarregarParametrosIniciais("ET", "0x01"),
|
||||
},
|
||||
new ModuloMvdModel()
|
||||
{
|
||||
Modulo_ID = "EF",
|
||||
MovMotor = MvdMotorBLDC.CarregarParametrosIniciais("EF", "0x02"),
|
||||
DirMotor = MvdMotorPasso.CarregarParametrosIniciais("EF")
|
||||
DirMotor = MvdMotorPasso.CarregarParametrosIniciais("EF", "0x02")
|
||||
},
|
||||
new ModuloMvdModel()
|
||||
{
|
||||
Modulo_ID = "DT",
|
||||
MovMotor = MvdMotorBLDC.CarregarParametrosIniciais("DT", "0x03"),
|
||||
DirMotor = MvdMotorPasso.CarregarParametrosIniciais("DT")
|
||||
DirMotor = MvdMotorPasso.CarregarParametrosIniciais("DT", "0x03")
|
||||
},
|
||||
new ModuloMvdModel()
|
||||
{
|
||||
Modulo_ID = "DF",
|
||||
MovMotor = MvdMotorBLDC.CarregarParametrosIniciais("DF", "0x04"),
|
||||
DirMotor = MvdMotorPasso.CarregarParametrosIniciais("DF")
|
||||
DirMotor = MvdMotorPasso.CarregarParametrosIniciais("DF", "0x04")
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
@ -645,6 +645,7 @@ namespace AgroBase.Models.Modules
|
|||
public string ID { get; set; } = T_Code.Dir.ToString();
|
||||
|
||||
// SETs
|
||||
public string Endereco { get; set; } = "0x01";
|
||||
public Sentido Sentido_SP { get; set; } = Sentido.Parado;
|
||||
public double Angulo_SP { get; set; } = 0;
|
||||
public int Velocidade { get; set; } = 50;
|
||||
|
|
@ -665,12 +666,15 @@ namespace AgroBase.Models.Modules
|
|||
public ConfiguracaoSentidoMotor ConfigSentidos { get; set; }
|
||||
public List<FuncoesPinout> Funcoes { get; set; }
|
||||
|
||||
public MKS057DModel DadosDriver { get; set; } = new MKS057DModel();
|
||||
|
||||
public static MvdMotorPasso CarregarParametrosIniciais(string Mod_ID)
|
||||
|
||||
public static MvdMotorPasso CarregarParametrosIniciais(string Mod_ID, string _Endereco)
|
||||
{
|
||||
return new MvdMotorPasso()
|
||||
{
|
||||
ID = T_Code.Dir.ToString(),
|
||||
Endereco = _Endereco,
|
||||
ConfigSentidos = new ConfiguracaoSentidoMotor()
|
||||
{
|
||||
Direita = Mod_ID.Contains("F") ? Sentido.Horario : Sentido.Antihorario,
|
||||
|
|
@ -684,7 +688,7 @@ namespace AgroBase.Models.Modules
|
|||
FuncoesPinout.DIR,
|
||||
FuncoesPinout.ENA,
|
||||
FuncoesPinout.EncoderAbsoluto
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -712,7 +716,7 @@ namespace AgroBase.Models.Modules
|
|||
|
||||
public string ProtocoloComando(Direcao Direcao)
|
||||
{
|
||||
if (Inicializado && Comandar && (Controlar))
|
||||
if ((Inicializado || (MKS057DService.Iniciado && DadosDriver.Iniciado)) && Comandar && (Controlar))
|
||||
{
|
||||
Sentido_SP =
|
||||
Direcao == Direcao.Cima ? ConfigSentidos.Direita :
|
||||
|
|
@ -730,6 +734,25 @@ namespace AgroBase.Models.Modules
|
|||
((int)Sentido_SP).ToString() + SerialService.SplitParams +
|
||||
Angulo_SP.ToString() + SerialService.SplitParams +
|
||||
Velocidade.ToString();
|
||||
|
||||
if (MKS057DService.Iniciado && DadosDriver.Iniciado)
|
||||
{
|
||||
int mx = Sentido_SP == Sentido.Antihorario ? -1 : 1;
|
||||
|
||||
MKS057DService.EnviarComandoControle(new MKS057ComandoModel()
|
||||
{
|
||||
Comando = Convert.ToByte("13"),
|
||||
Endereco = Endereco,
|
||||
Angulo = Angulo_SP * mx,
|
||||
Velocidade = Velocidade,
|
||||
_Sentido = Sentido_SP,
|
||||
ModoControle = ModosControle.AnguloAbsoluto,
|
||||
AguardaResposta = false,
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
ProtocoloMotor = "";
|
||||
}
|
||||
|
||||
return ProtocoloMotor;
|
||||
}
|
||||
return "";
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace AgroBase.Models.Modules
|
|||
public class SensoriamentoModel : DispositivoBaseModel
|
||||
{
|
||||
public string Modulo_ID { get; set; } = T_Code.Sen.ToString();
|
||||
|
||||
public bool RequisitarDados { get; set; } = false;
|
||||
private bool _MensagemConexaoRecebida { get; set; } = false;
|
||||
public bool MensagemConexaoRecebida(bool Reset = false)
|
||||
{
|
||||
|
|
@ -364,20 +364,20 @@ namespace AgroBase.Models.Modules
|
|||
public Dictionary<string, List<string>> ProtocoloConfiguracao(bool Conectar)
|
||||
{
|
||||
// Inicializar o dicionário
|
||||
var configDictionary = new Dictionary<string, List<string>>();
|
||||
var configDictionary = new Dictionary<string, List<string>>() { { Modulo_ID, new List<string>() } };
|
||||
|
||||
// Adicionar configurações dos Sensores que devem ser aferidos
|
||||
var sensoresConfig = Sensores
|
||||
.Where(x => x.Aferir)
|
||||
.Select(x => x.ProtocoloConfiguracaoSensor(Pinout, Conectar))
|
||||
.ToList();
|
||||
configDictionary.Add(Modulo_ID, sensoresConfig);
|
||||
configDictionary[Modulo_ID].AddRange(sensoresConfig);
|
||||
|
||||
// Adicionar configurações dos Sinaleiros
|
||||
var sinaleirosConfig = Sinaleiros
|
||||
.Select(x => x.ProtocoloConfiguracaoSinaleiro(Pinout, Conectar))
|
||||
.ToList();
|
||||
configDictionary.Add(Modulo_ID, sinaleirosConfig);
|
||||
configDictionary[Modulo_ID].AddRange(sinaleirosConfig);
|
||||
|
||||
// Adicionar configuração do ProtocoloMOD
|
||||
string protocoloMOD =
|
||||
|
|
@ -385,19 +385,45 @@ namespace AgroBase.Models.Modules
|
|||
"MD" + SerialService.SplitParams +
|
||||
(Conectar ? "1" : "0") + SerialService.SplitParams +
|
||||
_TaxaAmostragem.ToString() + SerialService.SplitParams +
|
||||
(RequisitarDados ? "1" : "0") + SerialService.SplitParams +
|
||||
PinoutModel.PinoProtocolo(Pinout, Funcoes);
|
||||
var protocoloMODConfig = new List<string> { protocoloMOD };
|
||||
configDictionary.Add(Modulo_ID, protocoloMODConfig);
|
||||
configDictionary[Modulo_ID].Add(protocoloMOD);
|
||||
|
||||
return configDictionary;
|
||||
}
|
||||
|
||||
public string ProtocoloVerificacao(bool Completo)
|
||||
{
|
||||
if (Completo)
|
||||
{
|
||||
string ProtocoloCheck =
|
||||
SerialService.BeginLine +
|
||||
0 + SerialService.SplitMessage +
|
||||
Modulo_ID + SerialService.SplitMessage +
|
||||
((int)F_Code.Chk).ToString() + SerialService.SplitMessage +
|
||||
"check" +
|
||||
SerialService.EndLine;
|
||||
|
||||
return ProtocoloCheck;
|
||||
}
|
||||
else
|
||||
{
|
||||
string ProtocoloCheck =
|
||||
((int)F_Code.Chk).ToString() + SerialService.SplitMessage +
|
||||
"check";
|
||||
|
||||
return ProtocoloCheck;
|
||||
}
|
||||
}
|
||||
|
||||
public void RecebeProtocoloSerial(string Protocolo)
|
||||
{
|
||||
// #ET;00000;00000;00000;000
|
||||
if (!string.IsNullOrEmpty(Protocolo) && Protocolo[0].ToString() == SerialService.BeginSensor)
|
||||
string Mod_ID = Protocolo.Split(SerialService.SplitMessage[0])[0];
|
||||
string mensagem = Protocolo.Substring(Mod_ID.Length + 1, Protocolo.Length - Mod_ID.Length - 1);
|
||||
if (!string.IsNullOrEmpty(Protocolo) && mensagem[0].ToString() == SerialService.BeginSensor)
|
||||
{
|
||||
string[] Dados = Protocolo.Replace(SerialService.BeginSensor, "").Split(SerialService.EndLine[0])[0].Split(';');
|
||||
string[] Dados = mensagem.Replace(SerialService.BeginSensor, "").Split(SerialService.EndLine[0])[0].Split(';');
|
||||
|
||||
int cod = 0;
|
||||
int.TryParse(Dados[0], out cod);
|
||||
if (cod == 0)
|
||||
|
|
|
|||
|
|
@ -467,12 +467,12 @@ namespace AgroBase.Models.Operacoes
|
|||
// Se a etapa anterior não for CaminhandoRua, então significa que ele já iniciou a etapa de sair da rua
|
||||
else
|
||||
{
|
||||
/*// Ainda tem ruas a serem percorridas, logo, o robô precisa realizar a manobra para seguir para a próxima rua
|
||||
// Ainda tem ruas a serem percorridas, logo, o robô precisa realizar a manobra para seguir para a próxima rua
|
||||
if (!Variaveis.OperacaoEmAndamento.OpMapaGPS.Concluido)
|
||||
{
|
||||
etapaAtual = StatusCarroMapa.Manobrando;
|
||||
ManobraConcluida = false;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -710,7 +710,7 @@ namespace AgroBase.Models.Operacoes
|
|||
if (Variaveis.OperacaoEmAndamento.Mapa.IdxRuaAtual % 2 != 0)
|
||||
{
|
||||
PontosRua.Reverse();
|
||||
idx = idx != (PontosRua.Count - 1) ? (PontosRua.Count - 1) - idx : idx;
|
||||
idx = (PontosRua.Count - 1) - idx;
|
||||
}
|
||||
for (int i = 0; i <= idx; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -623,7 +623,7 @@ namespace AgroBase.Models
|
|||
ProgressoRua = Sensoriamento.ProgressoRua,
|
||||
Direcao = OpMapaGPS.ReferencialRuaGPS.Direcao,
|
||||
AnguloRua = Mapa.AnguloCaminho,
|
||||
DentroDaRua = OpMapaGPS.ReferencialRuaGPS.DentroDaRua,
|
||||
DentroDaRua = Mapa.DentroDaRua,
|
||||
IdxPontoAproximadoRua = OpMapaGPS.ReferencialRuaGPS.IdxPontoAproximadoRua,
|
||||
IdxRuaAtual = Mapa.IdxRuaAtual,
|
||||
AnguloDif = Sensoriamento.AnguloDif,
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ namespace AgroBase.Services
|
|||
PortaCOM = ModbusService._PortaModbus.PortName,
|
||||
Dispositivo = T_Code.Bld,
|
||||
Erro = !Iniciado,
|
||||
Versao = 1,
|
||||
Versao = UltimaLeitura.Versao.ToString(),
|
||||
Mod_ID = Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos.FirstOrDefault(x => Convert.ToByte(x.MovMotor.Endereco.Replace("0x", ""), 16) == slaveAddress).Modulo_ID,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace AgroBase.Services
|
|||
PortaCOM = PortaGPS.PortName,
|
||||
Dispositivo = T_Code.Gps,
|
||||
Erro = !Iniciado,
|
||||
Versao = 1
|
||||
Versao = "1",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -281,7 +281,7 @@ namespace AgroBase.Services
|
|||
return diferenca;
|
||||
}
|
||||
|
||||
public static GPSModel PontoMaisProximoRuaProjetada(List<GPSModel> RuaProjetada, TrajetoriaTipo trajetoriaTipo)
|
||||
public static (GPSModel, bool) PontoMaisProximoRuaProjetada(List<GPSModel> RuaProjetada, TrajetoriaTipo trajetoriaTipo)
|
||||
{
|
||||
int idxUltimoPonto =
|
||||
trajetoriaTipo == TrajetoriaTipo.Rua ? Variaveis.OperacaoEmAndamento.Mapa.IdxUltimoPontoTrajetoria :
|
||||
|
|
@ -291,7 +291,7 @@ namespace AgroBase.Services
|
|||
// Verifica se a lista está vazia
|
||||
if (RuaProjetada == null || RuaProjetada.Count == 0)
|
||||
{
|
||||
return null;
|
||||
return (null, false);
|
||||
}
|
||||
|
||||
// Inicializa variáveis
|
||||
|
|
@ -334,6 +334,7 @@ namespace AgroBase.Services
|
|||
|
||||
if (seAproximando && !seAproximandoAnterior)
|
||||
{
|
||||
seAproximandoAnterior = seAproximando;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -366,7 +367,7 @@ namespace AgroBase.Services
|
|||
break;
|
||||
}
|
||||
|
||||
return pontoMaisProximo;
|
||||
return (pontoMaisProximo, seAproximandoAnterior);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ namespace AgroBase.Services
|
|||
PortaCOM = PortaLoRa.PortName,
|
||||
Dispositivo = T_Code.Lra,
|
||||
Erro = !Iniciado,
|
||||
Versao = 220
|
||||
Versao = "220"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -44,6 +44,13 @@ namespace AgroBase.Services
|
|||
}
|
||||
|
||||
FilaEmEspera = false;
|
||||
|
||||
if (frmPrincipal.Fechando)
|
||||
{
|
||||
EnvioLiberado = true;
|
||||
return;
|
||||
}
|
||||
|
||||
EnvioLiberado = false;
|
||||
|
||||
if (Iniciado)
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ namespace AgroBase.Services
|
|||
PortaCOM = ModbusService._PortaModbus.PortName,
|
||||
Dispositivo = T_Code.Pzm,
|
||||
Erro = !Iniciado,
|
||||
Versao = 17
|
||||
Versao = "17"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -136,6 +136,12 @@ namespace AgroBase.Services
|
|||
|
||||
private static async Task<bool> ReceberDados()
|
||||
{
|
||||
if (!ModbusService.Iniciado)
|
||||
{
|
||||
Iniciado = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
PenultimaLeitura = new PZEMModel()
|
||||
{
|
||||
AlarmeTensaoMax = UltimaLeitura.AlarmeTensaoMax,
|
||||
|
|
@ -163,7 +169,7 @@ namespace AgroBase.Services
|
|||
|
||||
|
||||
await Task.Delay(TaxaAmostragem);
|
||||
|
||||
|
||||
return await ReceberDados();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace AgroBase.Services
|
|||
public string PortaCOM { get; set; }
|
||||
public T_Code Dispositivo { get; set; }
|
||||
public bool Erro { get; set; }
|
||||
public int Versao { get; set; }
|
||||
public string Versao { get; set; }
|
||||
public string Mod_ID { get; set; }
|
||||
}
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ namespace AgroBase.Services
|
|||
|
||||
public static async Task RealizarVarreduraPortasUSB()
|
||||
{
|
||||
if (VarreduraEmAndamento)
|
||||
if (VarreduraEmAndamento || frmPrincipal.Fechando)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ namespace AgroBase.Services
|
|||
|
||||
if (Variaveis.OperacaoEmAndamento.DispMvd == null)
|
||||
{
|
||||
await TentarIdentificarDispositivo(_Porta);
|
||||
//await TentarIdentificarDispositivo(_Porta);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -70,6 +70,7 @@ namespace AgroBase.Services
|
|||
{
|
||||
_Porta.Open();
|
||||
|
||||
bool DispositivoMvd = false;
|
||||
foreach (var Modulo in Variaveis.OperacaoEmAndamento.DispMvd.Dados.Modulos)
|
||||
{
|
||||
string ProtocoloCheck = Modulo.ProtocoloVerificacao(true);
|
||||
|
|
@ -79,11 +80,43 @@ namespace AgroBase.Services
|
|||
await AguardaRespostaPorta(_Porta, 1000);
|
||||
|
||||
bool respondeu = ProcessarRespostaDispositivo(_Porta);
|
||||
if (!PortaDispositivoProprio)
|
||||
if (!DispositivoMvd)
|
||||
{
|
||||
PortaDispositivoProprio = respondeu;
|
||||
DispositivoMvd = respondeu;
|
||||
}
|
||||
};
|
||||
bool DispositivoAtu = false;
|
||||
if (!DispositivoMvd)
|
||||
{
|
||||
string ProtocoloCheck = Variaveis.OperacaoEmAndamento.DispAtu.Dados.ProtocoloVerificacao(true);
|
||||
|
||||
_Porta.Write(ProtocoloCheck);
|
||||
|
||||
await AguardaRespostaPorta(_Porta, 1000);
|
||||
|
||||
bool respondeu = ProcessarRespostaDispositivo(_Porta);
|
||||
if (!DispositivoAtu)
|
||||
{
|
||||
DispositivoAtu = respondeu;
|
||||
}
|
||||
}
|
||||
bool DispositivoSen = false;
|
||||
if (!DispositivoMvd && !DispositivoAtu)
|
||||
{
|
||||
string ProtocoloCheck = Variaveis.OperacaoEmAndamento.DispSen.Dados.ProtocoloVerificacao(true);
|
||||
|
||||
_Porta.Write(ProtocoloCheck);
|
||||
|
||||
await AguardaRespostaPorta(_Porta, 1000);
|
||||
|
||||
bool respondeu = ProcessarRespostaDispositivo(_Porta);
|
||||
if (!DispositivoSen)
|
||||
{
|
||||
DispositivoSen = respondeu;
|
||||
}
|
||||
}
|
||||
|
||||
PortaDispositivoProprio = DispositivoMvd || DispositivoAtu || DispositivoSen;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -140,7 +173,7 @@ namespace AgroBase.Services
|
|||
|
||||
T_Code Dispositivo = T_Code.Vzo;
|
||||
F_Code Verificacao = F_Code.Nda;
|
||||
int Versao = 0;
|
||||
string Versao = "0";
|
||||
|
||||
var Dados = Recebido.Split(SplitMessage[0]);
|
||||
|
||||
|
|
@ -156,8 +189,7 @@ namespace AgroBase.Services
|
|||
|
||||
Dispositivo = (T_Code)(int.Parse(Dados[2]));
|
||||
|
||||
int.TryParse(Dados[3], out int versao);
|
||||
Versao = versao;
|
||||
Versao = Dados[3];
|
||||
|
||||
if (Dispositivo != T_Code.Vzo && !DispositivosMapeados.Any(x => x.Dispositivo == Dispositivo && x.Mod_ID == Mod_ID))
|
||||
{
|
||||
|
|
@ -219,6 +251,14 @@ namespace AgroBase.Services
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!MKS057DService.Iniciado)
|
||||
{
|
||||
bool Encontrado = await MKS057DService.VerificaPortaMKS(porta);
|
||||
if (Encontrado)
|
||||
{
|
||||
return Encontrado;
|
||||
}
|
||||
}
|
||||
if (!LoRaService.Iniciado)
|
||||
{
|
||||
bool Encontrado = await LoRaService.VerificaPortaLoRa(porta);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.IO.Ports;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static AgroBase.Models.Enuns;
|
||||
|
||||
namespace AgroBase.Services
|
||||
|
|
@ -85,6 +86,12 @@ namespace AgroBase.Services
|
|||
|
||||
private static async Task<bool> ReceberDados()
|
||||
{
|
||||
if (!ModbusService.Iniciado)
|
||||
{
|
||||
Iniciado = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
await ModbusService.EnviarComando(ComandoAquisicao);
|
||||
|
||||
byte[] resposta = SerialService.LerDadosDaPortaSerial(ModbusService._PortaModbus, 101);
|
||||
|
|
@ -117,7 +124,7 @@ namespace AgroBase.Services
|
|||
PortaCOM = ModbusService._PortaModbus.PortName,
|
||||
Dispositivo = T_Code.Wit,
|
||||
Erro = !Iniciado,
|
||||
Versao = 1
|
||||
Versao = DadosLeitura.Versao,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-06-24T15:05:14.6831673-03:00","Protocolo":"@1;Atu;258;B01,1,1,1,0,19$","Enviado":true},{"Momento":"2024-06-24T15:05:14.6901692-03:00","Protocolo":"Atu;#211;B01;1$\r","Enviado":false},{"Momento":"2024-06-24T15:05:15.2019129-03:00","Protocolo":"Atu;655;1;$\r","Enviado":false},{"Momento":"2024-06-24T15:05:15.2129154-03:00","Protocolo":"@2;Atu;258;B02,1,1,2,0,20$","Enviado":true},{"Momento":"2024-06-24T15:05:15.2199184-03:00","Protocolo":"Atu;#211;B02;1$\r","Enviado":false},{"Momento":"2024-06-24T15:05:15.7302546-03:00","Protocolo":"Atu;655;2;$\r","Enviado":false},{"Momento":"2024-06-24T15:05:15.7412559-03:00","Protocolo":"@3;Atu;258;B03,1,1,3,0,21$","Enviado":true},{"Momento":"2024-06-24T15:05:15.7462551-03:00","Protocolo":"Atu;#211;B03;1$\r","Enviado":false},{"Momento":"2024-06-24T15:05:16.2575212-03:00","Protocolo":"Atu;655;3;$\r","Enviado":false},{"Momento":"2024-06-24T15:05:16.2725209-03:00","Protocolo":"@4;Atu;258;B04,1,1,4,0,47$","Enviado":true},{"Momento":"2024-06-24T15:05:16.2785223-03:00","Protocolo":"Atu;#211;B04;1$\r","Enviado":false},{"Momento":"2024-06-24T15:05:16.7894288-03:00","Protocolo":"Atu;655;4;$\r","Enviado":false},{"Momento":"2024-06-24T15:05:16.7974315-03:00","Protocolo":"@5;Atu;258;B05,1,0,5,0,-1$","Enviado":true},{"Momento":"2024-06-24T15:05:16.8034325-03:00","Protocolo":"Atu;655;5;$\r","Enviado":false},{"Momento":"2024-06-24T15:05:16.8134336-03:00","Protocolo":"@6;Atu;258;B06,1,0,6,0,-1$","Enviado":true},{"Momento":"2024-06-24T15:05:16.8194324-03:00","Protocolo":"Atu;655;6;$\r","Enviado":false},{"Momento":"2024-06-24T15:05:16.8274341-03:00","Protocolo":"@7;Atu;258;B07,1,0,7,0,-1$","Enviado":true},{"Momento":"2024-06-24T15:05:16.8334325-03:00","Protocolo":"Atu;655;7;$\r","Enviado":false},{"Momento":"2024-06-24T15:05:16.8434297-03:00","Protocolo":"@8;Atu;258;B08,1,0,8,0,-1$","Enviado":true},{"Momento":"2024-06-24T15:05:16.8484333-03:00","Protocolo":"Atu;655;8;$\r","Enviado":false},{"Momento":"2024-06-24T15:05:16.859433-03:00","Protocolo":"@9;Atu;258;B09,1,0,9,0,-1$","Enviado":true},{"Momento":"2024-06-24T15:05:16.8644346-03:00","Protocolo":"Atu;655;9;$\r","Enviado":false},{"Momento":"2024-06-24T15:05:16.875431-03:00","Protocolo":"@10;Atu;258;B10,1,0,10,0,-1$","Enviado":true},{"Momento":"2024-06-24T15:05:16.8814334-03:00","Protocolo":"Atu;655;10;$\r","Enviado":false},{"Momento":"2024-06-24T15:05:16.891431-03:00","Protocolo":"@11;Atu;258;BOMBA,1,1,085,0,40,0,36,0,38,0,37,0,39$","Enviado":true},{"Momento":"2024-06-24T15:05:16.9004326-03:00","Protocolo":"Atu;#211;BOMBA;1$\r","Enviado":false}
|
||||
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-06-24T15:14:43.6222906-03:00","Protocolo":"@1;Atu;258;BOMBA,1,1,085,0,40,0,36,0,38,0,37,0,39$","Enviado":true},{"Momento":"2024-06-24T15:14:43.6292876-03:00","Protocolo":"Atu;#211;BOMBA;1$\r","Enviado":false},{"Momento":"2024-06-24T15:14:44.1402257-03:00","Protocolo":"Atu;655;1;$\r","Enviado":false},{"Momento":"2024-06-24T15:14:44.144226-03:00","Protocolo":"@2;Atu;258;MD,1,500,1$","Enviado":true},{"Momento":"2024-06-24T15:14:44.1522249-03:00","Protocolo":"Atu;#211;MD;1$\r","Enviado":false},{"Momento":"2024-06-24T15:14:44.2642252-03:00","Protocolo":"Atu;655;2;$\r","Enviado":false},{"Momento":"2024-06-24T15:14:44.3002245-03:00","Protocolo":"Atu;#422;B04;0$\r","Enviado":false},{"Momento":"2024-06-24T15:14:44.712216-03:00","Protocolo":"Atu;#422;B01;0$\r","Enviado":false},{"Momento":"2024-06-24T15:14:44.7692136-03:00","Protocolo":"Atu;#422;B03;0$\r","Enviado":false},{"Momento":"2024-06-24T15:14:44.8012164-03:00","Protocolo":"Atu;#422;B04;0$\r","Enviado":false}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1 @@
|
|||
[{"Momento":"2024-06-28T16:32:39.1989717-03:00","Protocolo":"@1;Sen;258;AB3V,1,322,1,500,10,0,-1,0x44,219$","Enviado":true},{"Momento":"2024-06-28T16:32:39.2209886-03:00","Protocolo":"????????????????????????????????????????????????????????????????Sen;655;1;$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.6831022-03:00","Protocolo":"@8;Sen;258;AB3V,1,322,1,500,10,0,-1,0x44,219$","Enviado":true},{"Momento":"2024-06-28T16:32:48.6901016-03:00","Protocolo":"Sen;#211;AB3V;0$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.7061022-03:00","Protocolo":"Sen;655;8;$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.7181026-03:00","Protocolo":"@9;Sen;258;AB5V,1,322,1,500,10,0,-1,0x41,219$","Enviado":true},{"Momento":"2024-06-28T16:32:48.7261021-03:00","Protocolo":"Sen;#211;AB5V;0$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.737102-03:00","Protocolo":"Sen;655;9;$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.7531027-03:00","Protocolo":"@10;Sen;258;AB7V2,1,322,1,500,10,0,-1,0x40,219$","Enviado":true},{"Momento":"2024-06-28T16:32:48.7621029-03:00","Protocolo":"Sen;#211;AB7V2;0$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.7721024-03:00","Protocolo":"Sen;655;10;$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.7821037-03:00","Protocolo":"@11;Sen;258;LEDMN,1,0,12$","Enviado":true},{"Momento":"2024-06-28T16:32:48.7881058-03:00","Protocolo":"Sen;#211;LEDMN;1$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.7981028-03:00","Protocolo":"Sen;655;11;$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.8121042-03:00","Protocolo":"@12;Sen;258;LEDAT,1,0,14$","Enviado":true},{"Momento":"2024-06-28T16:32:48.8181052-03:00","Protocolo":"Sen;#211;LEDAT;1$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.8281056-03:00","Protocolo":"Sen;655;12;$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.8431059-03:00","Protocolo":"@13;Sen;258;LEDOP,1,0,27$","Enviado":true},{"Momento":"2024-06-28T16:32:48.8491066-03:00","Protocolo":"Sen;#211;LEDOP;1$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.8591046-03:00","Protocolo":"Sen;655;13;$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.8751048-03:00","Protocolo":"@14;Sen;258;MD,1,500,0,0,-1,0,-1,0,23$","Enviado":true},{"Momento":"2024-06-28T16:32:48.8821024-03:00","Protocolo":"Sen;#211;MD;1$\r","Enviado":false},{"Momento":"2024-06-28T16:32:48.9931038-03:00","Protocolo":"Sen;655;14;$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.8497202-03:00","Protocolo":"@15;Sen;258;AB3V,1,322,1,500,10,0,-1,0x44,219$","Enviado":true},{"Momento":"2024-06-28T16:33:04.8557191-03:00","Protocolo":"Sen;#211;AB3V;0$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.8667177-03:00","Protocolo":"Sen;655;15;$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.8677214-03:00","Protocolo":"@16;Sen;258;AB5V,1,322,1,500,10,0,-1,0x41,219$","Enviado":true},{"Momento":"2024-06-28T16:33:04.8807183-03:00","Protocolo":"Sen;#211;AB5V;0$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.8917177-03:00","Protocolo":"Sen;655;16;$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.8987188-03:00","Protocolo":"@17;Sen;258;AB7V2,1,322,1,500,10,0,-1,0x40,219$","Enviado":true},{"Momento":"2024-06-28T16:33:04.9077198-03:00","Protocolo":"Sen;#211;AB7V2;0$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.9187185-03:00","Protocolo":"Sen;655;17;$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.9287201-03:00","Protocolo":"@18;Sen;258;LEDMN,1,0,12$","Enviado":true},{"Momento":"2024-06-28T16:33:04.9337187-03:00","Protocolo":"Sen;#211;LEDMN;1$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.9447186-03:00","Protocolo":"Sen;655;18;$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.9597203-03:00","Protocolo":"@19;Sen;258;LEDAT,1,0,14$","Enviado":true},{"Momento":"2024-06-28T16:33:04.9647185-03:00","Protocolo":"Sen;#211;LEDAT;1$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.9757207-03:00","Protocolo":"Sen;655;19;$\r","Enviado":false},{"Momento":"2024-06-28T16:33:04.9917201-03:00","Protocolo":"@20;Sen;258;LEDOP,1,0,27$","Enviado":true},{"Momento":"2024-06-28T16:33:04.9977243-03:00","Protocolo":"Sen;#211;LEDOP;1$\r","Enviado":false},{"Momento":"2024-06-28T16:33:05.0087212-03:00","Protocolo":"Sen;655;20;$\r","Enviado":false},{"Momento":"2024-06-28T16:33:05.0217219-03:00","Protocolo":"@21;Sen;258;MD,1,500,0,0,-1,0,-1,0,23$","Enviado":true},{"Momento":"2024-06-28T16:33:05.0287189-03:00","Protocolo":"Sen;#211;MD;1$\r","Enviado":false},{"Momento":"2024-06-28T16:33:05.1400439-03:00","Protocolo":"Sen;655;21;$\r","Enviado":false}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
{"Modulo_ID":"Atu","Conectado":false,"QuantidadeBicos":4,"DensidadeHerbicida":1.05,"CapacidadeReservatorio":30.0,"AtuacaoNivelAlto":true,"BicosPulverizadores":[{"ID":"B01","Posicao":1,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":34.42987713140743},{"ID":"B02","Posicao":2,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":14.876485059544191},{"ID":"B03","Posicao":3,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":18.103588945512129},{"ID":"B04","Posicao":4,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":18.437319738098896},{"ID":"B05","Posicao":5,"Atuado":false,"Comandar":false,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":0.0},{"ID":"B06","Posicao":6,"Atuado":false,"Comandar":false,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":0.0},{"ID":"B07","Posicao":7,"Atuado":false,"Comandar":false,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":0.0},{"ID":"B08","Posicao":8,"Atuado":false,"Comandar":false,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":0.0},{"ID":"B09","Posicao":9,"Atuado":false,"Comandar":false,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":0.0},{"ID":"B10","Posicao":10,"Atuado":false,"Comandar":false,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":0.0}],"BombaPressurizadora":{"ID":"BOMBA","BombaAtuada":false,"Ligado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[14,35,36,37,5],"PressaoSP":85.0,"Pressao":82.01,"Potencia":0.0},"Sensores":[{"LogGrafico":[],"ID":"FLXLN","Prioridade":23,"Descricao":"Fluxo na linha principal","Componente":198,"Aferir":true,"DelayAmostragem":300,"Inicializado":false,"Testando":false,"Funcoes":[25],"Parametros":[],"UnidadeMedida":"mL/s","Leituras":[0.0,0.0],"ValorMinimo":0.0,"ValorMaximo":25222.0,"LimiteMaximo":0.0,"LimiteMinimo":0.0},{"LogGrafico":[],"ID":"MASRS","Prioridade":3,"Descricao":"Massa do reservatório de herbicida","Componente":532,"Aferir":true,"DelayAmostragem":1000,"Inicializado":false,"Testando":false,"Funcoes":[22,23],"Parametros":[],"UnidadeMedida":"Kg","Leituras":[1117263.12],"ValorMinimo":-1.281631101976581E+32,"ValorMaximo":2.8836731440342142E+24,"LimiteMaximo":50.0,"LimiteMinimo":5.0},{"LogGrafico":[],"ID":"PRSLN","Prioridade":3,"Descricao":"Pressão na linha principal","Componente":333,"Aferir":true,"DelayAmostragem":1000,"Inicializado":false,"Testando":false,"Funcoes":[24],"Parametros":[["Vmin","000.00"],["Vmax","004.50"],["Pmax","174.04"]],"UnidadeMedida":"psi","Leituras":[82.01],"ValorMinimo":0.0,"ValorMaximo":127.63,"LimiteMaximo":120.0,"LimiteMinimo":60.0}],"PercentualInicioPulverizacao":0.3,"ScriptDeteccaoErvas":"weed-detector-v7.py","_MassaRef":0.8,"_MassaLeituraRef":40876.37,"_MassaLeituraExtra":1895800.0,"_MassaLeitura":1117263.12,"MassaReservatorio":15.236908365395459,"VolumeReservatorio":14.511341300376627,"PercentualReservatorio":48.371137667922085,"VolumeVazaoAferido":102.0,"_FluxoMlRef":102.0,"_FluxoPulsoRef":80.0,"_LeituraPulsos":0,"_LeituraPeriodo":0,"VazaoFluxoMLpS":0.0,"VolumeVazaoML":0.0,"_PressaoVmin":0.0,"_PressaoVmax":4.5,"_PressaoMax":174.045,"_LeituraPressao":2631.0,"PressaoLinha":82.01,"PressaoLinhaCalc":82.0030336996337}
|
||||
{"Modulo_ID":"Atu","RequisitarDados":false,"Conectado":false,"QuantidadeBicos":4,"DensidadeHerbicida":1.05,"CapacidadeReservatorio":30.0,"AtuacaoNivelAlto":true,"BicosPulverizadores":[{"ID":"B01","Posicao":1,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":17.1964398137526},{"ID":"B02","Posicao":2,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":14.876485059544191},{"ID":"B03","Posicao":3,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":18.103588945512129},{"ID":"B04","Posicao":4,"Atuado":false,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[21],"StatusBico":false,"MediaNivelFluxo":18.437319738098896}],"BombaPressurizadora":{"ID":"BOMBA","BombaAtuada":true,"Ligado":true,"Comandar":true,"Inicializado":false,"Testando":false,"Funcoes":[14,35,36,37,5],"PressaoSP":85.0,"Pressao":103.82,"Potencia":0.0},"Sensores":[{"LogGrafico":[],"ID":"FLXLN","Prioridade":23,"Descricao":"Fluxo na linha principal","Componente":198,"Aferir":true,"DelayAmostragem":300,"Inicializado":false,"Testando":false,"Funcoes":[25],"Parametros":[],"UnidadeMedida":"mL/s","Leituras":[0.0,0.0],"ValorMinimo":0.0,"ValorMaximo":25222.0,"LimiteMaximo":0.0,"LimiteMinimo":0.0},{"LogGrafico":[],"ID":"MASRS","Prioridade":3,"Descricao":"Massa do reservatório de herbicida","Componente":532,"Aferir":true,"DelayAmostragem":1000,"Inicializado":false,"Testando":false,"Funcoes":[22,23],"Parametros":[],"UnidadeMedida":"Kg","Leituras":[1188069.0],"ValorMinimo":-1.281631101976581E+32,"ValorMaximo":2.8836731440342142E+24,"LimiteMaximo":50.0,"LimiteMinimo":5.0},{"LogGrafico":[],"ID":"PRSLN","Prioridade":3,"Descricao":"Pressão na linha principal","Componente":333,"Aferir":true,"DelayAmostragem":1000,"Inicializado":false,"Testando":false,"Funcoes":[24],"Parametros":[["Vmin","000.00"],["Vmax","004.50"],["Pmax","174.04"]],"UnidadeMedida":"psi","Leituras":[103.82],"ValorMinimo":0.0,"ValorMaximo":127.63,"LimiteMaximo":120.0,"LimiteMinimo":60.0}],"PercentualInicioPulverizacao":0.3,"ScriptDeteccaoErvas":"weed-detector-v7.py","_MassaRef":0.8,"_MassaLeituraRef":40876.37,"_MassaLeituraExtra":1895800.0,"_MassaLeitura":1188069.0,"MassaReservatorio":13.851151655589771,"VolumeReservatorio":13.191573005323591,"PercentualReservatorio":43.9719100177453,"VolumeVazaoAferido":102.0,"_FluxoMlRef":102.0,"_FluxoPulsoRef":80.0,"_LeituraPulsos":0,"_LeituraPeriodo":0,"VazaoFluxoMLpS":0.0,"VolumeVazaoML":880.33879833854928,"_PressaoVmin":0.0,"_PressaoVmax":4.5,"_PressaoMax":174.045,"_LeituraPressao":3331.0,"PressaoLinha":103.82,"PressaoLinhaCalc":103.82064053724054}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
{"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":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":39,"Descricao":"4","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":34,"Descricao":"5","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":35,"Descricao":"6","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":32,"Descricao":"7","Funcao":12,"Habilitado":true,"ComponenteID":"TMVET"},{"Controlador":1,"Barramento":0,"Pino":33,"Descricao":"8","Funcao":12,"Habilitado":true,"ComponenteID":"TMVEF"},{"Controlador":1,"Barramento":0,"Pino":25,"Descricao":"9","Funcao":12,"Habilitado":true,"ComponenteID":"TMVDT"},{"Controlador":1,"Barramento":0,"Pino":26,"Descricao":"10","Funcao":12,"Habilitado":true,"ComponenteID":"TMVDF"},{"Controlador":1,"Barramento":0,"Pino":27,"Descricao":"11","Funcao":38,"Habilitado":true,"ComponenteID":"LEDOP"},{"Controlador":1,"Barramento":0,"Pino":14,"Descricao":"12","Funcao":38,"Habilitado":true,"ComponenteID":"LEDAT"},{"Controlador":1,"Barramento":0,"Pino":12,"Descricao":"13","Funcao":38,"Habilitado":true,"ComponenteID":"LEDMN"},{"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":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":17,"Descricao":"34","Funcao":0,"Habilitado":true,"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":33,"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":34,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":23,"Descricao":"43","Funcao":4,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":94,"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":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":39,"Descricao":"4","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":34,"Descricao":"5","Funcao":0,"Habilitado":true,"ComponenteID":""},{"Controlador":1,"Barramento":0,"Pino":35,"Descricao":"6","Funcao":0,"Habilitado":true,"ComponenteID":""},{"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":38,"Habilitado":true,"ComponenteID":"LEDMN"},{"Controlador":1,"Barramento":0,"Pino":16,"Descricao":"33","Funcao":38,"Habilitado":true,"ComponenteID":"LEDAT"},{"Controlador":1,"Barramento":0,"Pino":17,"Descricao":"34","Funcao":38,"Habilitado":true,"ComponenteID":"LEDOP"},{"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":""}]}
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
<meta name="viewport" content="width=device-width,
|
||||
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<style>
|
||||
#map_93a956b1c1fdd376be8bf764a75a26b3 {
|
||||
#map_487150d07168e27859c014539a529f87 {
|
||||
position: relative;
|
||||
width: 100.0%;
|
||||
height: 100.0%;
|
||||
|
|
@ -39,14 +39,14 @@
|
|||
<body>
|
||||
|
||||
|
||||
<div class="folium-map" id="map_93a956b1c1fdd376be8bf764a75a26b3" ></div>
|
||||
<div class="folium-map" id="map_487150d07168e27859c014539a529f87" ></div>
|
||||
|
||||
</body>
|
||||
<script>
|
||||
|
||||
|
||||
var map_93a956b1c1fdd376be8bf764a75a26b3 = L.map(
|
||||
"map_93a956b1c1fdd376be8bf764a75a26b3",
|
||||
var map_487150d07168e27859c014539a529f87 = L.map(
|
||||
"map_487150d07168e27859c014539a529f87",
|
||||
{
|
||||
center: [0.0, 0.0],
|
||||
crs: L.CRS.EPSG3857,
|
||||
|
|
@ -60,13 +60,13 @@
|
|||
|
||||
|
||||
|
||||
var tile_layer_d3ba4051be3f4c8192516ab966d40d3c = L.tileLayer(
|
||||
var tile_layer_ce5a855eda901aed36e6d1496051253f = L.tileLayer(
|
||||
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||
{"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
|
||||
);
|
||||
|
||||
|
||||
tile_layer_d3ba4051be3f4c8192516ab966d40d3c.addTo(map_93a956b1c1fdd376be8bf764a75a26b3);
|
||||
tile_layer_ce5a855eda901aed36e6d1496051253f.addTo(map_487150d07168e27859c014539a529f87);
|
||||
|
||||
</script>
|
||||
|
||||
|
|
@ -87,7 +87,7 @@
|
|||
}
|
||||
trajeto_json_add({"features": []});
|
||||
|
||||
trajeto_json.addTo(map_93a956b1c1fdd376be8bf764a75a26b3);
|
||||
trajeto_json.addTo(map_487150d07168e27859c014539a529f87);
|
||||
|
||||
function adicionarGeometria(novaGeometria) {
|
||||
trajeto_json.addData(novaGeometria);
|
||||
|
|
@ -145,7 +145,7 @@
|
|||
|
||||
var marcadorDinamico = L.marker([0, 0], {
|
||||
icon: customIcon
|
||||
}).addTo(map_93a956b1c1fdd376be8bf764a75a26b3);
|
||||
}).addTo(map_487150d07168e27859c014539a529f87);
|
||||
|
||||
// Conectar ao broker MQTT
|
||||
const client = mqtt.connect('ws://localhost:9001'); // Use wss para conexão segura
|
||||
|
|
@ -183,7 +183,7 @@
|
|||
marcadorDinamico.setRotationAngle(angulo);
|
||||
|
||||
adicionarCoordenada("Tj", [novaLongitude, novaLatitude]);
|
||||
map_93a956b1c1fdd376be8bf764a75a26b3.setView(novaPosicao, map_93a956b1c1fdd376be8bf764a75a26b3.getZoom());
|
||||
map_487150d07168e27859c014539a529f87.setView(novaPosicao, map_487150d07168e27859c014539a529f87.getZoom());
|
||||
});
|
||||
|
||||
function calcularOrientacao(P1latitude, P1longitude, P2latitude, P2longitude) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
9faeab0bdecfc33b7cf3e0470094fa6c7b88c27d5b616945d7acd772168707f2
|
||||
58884735b1d4182bf9da87e3d317e8cb10ba3ade748bdea766548bfee2967a8e
|
||||
|
|
|
|||
|
|
@ -449,3 +449,4 @@ C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Forms.frmWT901C.
|
|||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Forms.frmBLD.resources
|
||||
C:\ZendionINC\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Forms.frmMvdConfig.resources
|
||||
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.csproj.CopyComplete
|
||||
C:\ZendionInc\agrobot_base\AgroBase\AgroBase\obj\Debug\AgroBase.Forms.frmMKS.resources
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,906 @@
|
|||
// Dispositivo: Atuador
|
||||
// Versão Firmware: 7
|
||||
// Ultima atualização: 24/06/2024
|
||||
// Atualização: Atualizado protocolo de comunicação padrão
|
||||
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\Utils.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\Pinout.h"
|
||||
#include "HX711.h"
|
||||
#include <PID_v1.h>
|
||||
#include <SimpleKalmanFilter.h>
|
||||
#define D_Code Atu
|
||||
#define VERSION 7
|
||||
|
||||
const String Mod_ID = "Atu";
|
||||
|
||||
#define _pinoLED RGB_BUILTIN
|
||||
|
||||
long _baudRate = 115200;
|
||||
|
||||
bool Conectado = false;
|
||||
|
||||
int _TaxaAmostragem = 500;
|
||||
volatile bool RequisitarDados = false;
|
||||
bool AtuacaoNivelAlto = true;
|
||||
|
||||
static double _PressaoAtual = 0.0;
|
||||
|
||||
class BicoPulverizador {
|
||||
public:
|
||||
// Construtor
|
||||
BicoPulverizador(String desc) {
|
||||
_ID = desc;
|
||||
}
|
||||
|
||||
// Definições
|
||||
String _ID;
|
||||
int _posicao;
|
||||
PinoModel _pinoSolenoide;
|
||||
|
||||
bool Iniciado = false;
|
||||
bool Testando = false;
|
||||
|
||||
// Consumo
|
||||
bool StatusBico;
|
||||
|
||||
// Entrada de dados
|
||||
bool _BicoAtuado = !AtuacaoNivelAlto;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
//EnviarDadosSerial(Mod_ID, _ID + " ja inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
_BicoAtuado = !AtuacaoNivelAlto;
|
||||
_pinoSolenoide.Conectar(_BicoAtuado);
|
||||
StatusBico = _pinoSolenoide.get() == (AtuacaoNivelAlto ? 1 : 0);
|
||||
|
||||
//EnviarDadosSerial(_ID + " Iniciado");
|
||||
|
||||
Iniciado = true;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
//EnviarDadosSerial(_ID + " nao esta inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Redefinir as configurações para os valores iniciais
|
||||
_pinoSolenoide.Desconectar();
|
||||
|
||||
//EnviarDadosSerial(_ID + " Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void AlterarStatusBico() {
|
||||
_pinoSolenoide.set(_BicoAtuado);
|
||||
StatusBico = _pinoSolenoide.get() == (AtuacaoNivelAlto ? 1 : 0);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class BombaPressurizadora {
|
||||
public:
|
||||
// Construtor
|
||||
BombaPressurizadora(String desc) {
|
||||
_ID = desc;
|
||||
}
|
||||
|
||||
// Definições
|
||||
String _ID;
|
||||
PinoModel _pinoEN;
|
||||
PinoModel _pinoCS;
|
||||
PinoModel _pinoINA;
|
||||
PinoModel _pinoINB;
|
||||
PinoModel _pinoPWM;
|
||||
|
||||
double _Kp = 3.0;
|
||||
double _Ki = 2.2;
|
||||
double _Kd = 0.5;
|
||||
PID* _PID = nullptr;
|
||||
|
||||
int ZeroRampa = 0;
|
||||
int RampaMax = 1023;
|
||||
|
||||
bool Iniciado = false;
|
||||
bool Testando = false;
|
||||
int _canal = 0;
|
||||
|
||||
// Consumo
|
||||
bool Ligado;
|
||||
double PotenciaAtual = 0;
|
||||
|
||||
// Entrada de dados
|
||||
double _PressaoSP = 0;
|
||||
bool _BombaAtuada = false;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
//EnviarDadosSerial(_ID + " ja inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
_BombaAtuada = false;
|
||||
_pinoEN.Conectar(_BombaAtuada);
|
||||
Ligado = _pinoEN.get() == 1;
|
||||
_pinoCS.Conectar();
|
||||
_pinoINA.Conectar(false);
|
||||
_pinoINB.Conectar(true);
|
||||
if (_pinoPWM.Definido()) {
|
||||
ledcSetup(_canal, 1000, 10);
|
||||
ledcAttachPin(_pinoPWM.num, _canal);
|
||||
PotenciaAtual = 0;
|
||||
_PressaoSP = 0;
|
||||
ledcWrite(_canal, PotenciaAtual);
|
||||
}
|
||||
|
||||
_PID = new PID(&_PressaoAtual, &PotenciaAtual, &_PressaoSP, _Kp, _Ki, _Kd, DIRECT);
|
||||
_PID->SetOutputLimits(ZeroRampa, RampaMax);
|
||||
_PID->SetMode(AUTOMATIC);
|
||||
|
||||
xTaskCreatePinnedToCore(&BombaPressurizadora::SensorTaskWrapper, "SensorTask", 15000, this, 25, &SensorTaskHandle, tskNO_AFFINITY);
|
||||
|
||||
//EnviarDadosSerial(_ID + " Iniciado");
|
||||
|
||||
Iniciado = true;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
//EnviarDadosSerial(_ID + " nao esta inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Parar a execução das tarefas
|
||||
vTaskDelete(SensorTaskHandle);
|
||||
|
||||
// Redefinir as configurações para os valores iniciais
|
||||
_pinoPWM.Desconectar();
|
||||
_pinoEN.Desconectar();
|
||||
_pinoCS.Desconectar();
|
||||
_pinoINA.Desconectar();
|
||||
_pinoINB.Desconectar();
|
||||
_pinoPWM.Desconectar();
|
||||
|
||||
// Outras redefinições de variáveis de estado, se necessário
|
||||
delete _PID;
|
||||
|
||||
//EnviarDadosSerial(_ID + " Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void AlterarStatusBomba() {
|
||||
_pinoEN.set(_BombaAtuada);
|
||||
Ligado = _pinoEN.get() == 1;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
TaskHandle_t SensorTaskHandle = NULL;
|
||||
static void SensorTaskWrapper(void *pvParameters) {
|
||||
BombaPressurizadora *bomba = static_cast<BombaPressurizadora*>(pvParameters);
|
||||
bomba->SensorTask();
|
||||
}
|
||||
|
||||
void SensorTask() {
|
||||
unsigned long previousMillisLeitura = millis();
|
||||
const int histerese = -5; // Valor de histerese em unidades de pressão
|
||||
bool bombaDesligadaPorPressao = false;
|
||||
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;
|
||||
}
|
||||
|
||||
// Supondo que PressaoAtual seja atualizado em AtualizarStatusSensor()
|
||||
if (_PressaoAtual >= (_PressaoSP + histerese)) {
|
||||
// Desliga a bomba se a pressão estiver acima do set point + histerese
|
||||
bombaDesligadaPorPressao = true;
|
||||
} else if (_PressaoAtual <= (_PressaoSP - histerese) && bombaDesligadaPorPressao) {
|
||||
// Permite que o PID atue novamente se a pressão cair abaixo do set point - histerese
|
||||
bombaDesligadaPorPressao = false;
|
||||
}
|
||||
|
||||
if (!_BombaAtuada || bombaDesligadaPorPressao) {
|
||||
PotenciaAtual = ZeroRampa;
|
||||
} else {
|
||||
_PID->Compute();
|
||||
// Ajusta PotenciaAtual com base no PID
|
||||
}
|
||||
|
||||
ledcWrite(_canal, PotenciaAtual);
|
||||
|
||||
unsigned long currentMillis = millis();
|
||||
if ((currentMillis - previousMillisLeitura) >= _TaxaAmostragem) {
|
||||
previousMillisLeitura = currentMillis;
|
||||
|
||||
AtualizarStatusSensor();
|
||||
}
|
||||
|
||||
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void AtualizarStatusSensor() {
|
||||
Ligado = _pinoEN.get() == 1;
|
||||
|
||||
float PercentualPotencia = (PotenciaAtual / RampaMax) * 100;
|
||||
|
||||
//EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sBMB, _ID, MontarDadosProtocoloBombaPressurizadora(Ligado, PercentualPotencia)));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class SensorFluxo {
|
||||
public:
|
||||
SensorFluxo(String desc) {
|
||||
_ID = desc;
|
||||
}
|
||||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sFLX;
|
||||
PinoModel _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
float _calibragem;
|
||||
|
||||
bool Iniciado = false;
|
||||
|
||||
// Consumo
|
||||
volatile int ultimaLeitura = 0;
|
||||
volatile unsigned int tempoAnterior = 0;
|
||||
volatile int pulsos = 0;
|
||||
volatile float periodoTotal = 0;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
//EnviarDadosSerial(_ID + " ja inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
_pino.Conectar();
|
||||
ultimaLeitura = _pino.get();
|
||||
tempoAnterior = 0;
|
||||
|
||||
xTaskCreatePinnedToCore(&SensorFluxo::SFTaskWrapper, "SFTask", 10000, this, _prioridade, &SFTaskHandle, tskNO_AFFINITY);
|
||||
|
||||
//EnviarDadosSerial(_ID + " Iniciado");
|
||||
|
||||
Iniciado = true;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
//EnviarDadosSerial(_ID + " nao esta inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Parar a execução das tarefas
|
||||
vTaskDelete(SFTaskHandle);
|
||||
|
||||
// Redefinir as configurações para os valores iniciais
|
||||
_pino.Desconectar();
|
||||
|
||||
//EnviarDadosSerial(_ID + " Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
private:
|
||||
TaskHandle_t SFTaskHandle = NULL;
|
||||
static void SFTaskWrapper(void *pvParameters) {
|
||||
SensorFluxo *sensor = static_cast<SensorFluxo*>(pvParameters);
|
||||
sensor->SFTask();
|
||||
}
|
||||
|
||||
void SFTask() {
|
||||
unsigned long firstMilis = millis();
|
||||
volatile int pulsosA = 0;
|
||||
volatile float periodo = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool Leitura = _pino.get() == 1;
|
||||
if (Leitura != ultimaLeitura) {
|
||||
ultimaLeitura = Leitura;
|
||||
pulsos++;
|
||||
|
||||
// Calcular o período em microssegundos
|
||||
unsigned long tempoAtual = micros();
|
||||
unsigned long periodoUs = pulsos == 1 ? 0 : (tempoAtual - tempoAnterior);
|
||||
periodo = periodoUs / 1000.0; // Converte de us para ms (2300 us para 2,3 ms)
|
||||
periodoTotal += periodo;
|
||||
|
||||
//CalcularFluxo(periodo);
|
||||
|
||||
tempoAnterior = tempoAtual;
|
||||
}
|
||||
|
||||
long intMillis = (millis() - firstMilis);
|
||||
|
||||
int Tempo = _TaxaAmostragem + _delayAmostragem;
|
||||
// A cada _TaxaAmostragem, enviar os dados para o software
|
||||
if (intMillis >= Tempo) {
|
||||
if (pulsos == pulsosA) {
|
||||
periodoTotal = 0;
|
||||
pulsos = 0;
|
||||
}
|
||||
|
||||
//EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sFLX, _ID, MontarDadosProtocoloFluxo(pulsos, periodoTotal)));
|
||||
|
||||
pulsosA = pulsos;
|
||||
firstMilis = millis();
|
||||
}
|
||||
|
||||
// Aguarda metade do menor período possível entre leituras
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class SensorMassa {
|
||||
public:
|
||||
SensorMassa(String desc) {
|
||||
_ID = desc;
|
||||
}
|
||||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sMAS;
|
||||
PinoModel _pinoDT;
|
||||
PinoModel _pinoSCK;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
||||
HX711* balanca = nullptr;
|
||||
SimpleKalmanFilter* filtro = nullptr;
|
||||
|
||||
volatile double leituraMassa;
|
||||
|
||||
bool Iniciado = false;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
//EnviarDadosSerial(_ID + " ja inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pinoDT.Definido() && _pinoSCK.Definido()) {
|
||||
balanca = new HX711();
|
||||
filtro = new SimpleKalmanFilter(2, 2, 0.01);
|
||||
balanca->begin(_pinoDT.num, _pinoSCK.num);
|
||||
balanca->set_scale();
|
||||
//balanca->tare();
|
||||
}
|
||||
|
||||
xTaskCreatePinnedToCore(&SensorMassa::SMTaskWrapper, "SMTask", 5000, this, _prioridade, &SMTaskHandle, tskNO_AFFINITY);
|
||||
|
||||
//EnviarDadosSerial(_ID + " Iniciado");
|
||||
|
||||
Iniciado = true;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
//EnviarDadosSerial(_ID + " nao esta inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
delete balanca;
|
||||
delete filtro;
|
||||
|
||||
// Parar a execução das tarefas
|
||||
vTaskDelete(SMTaskHandle);
|
||||
|
||||
// Redefinir as configurações para os valores iniciais
|
||||
_pinoDT.Desconectar();
|
||||
_pinoSCK.Desconectar();
|
||||
|
||||
//EnviarDadosSerial(_ID + " Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
private:
|
||||
TaskHandle_t SMTaskHandle = NULL;
|
||||
static void SMTaskWrapper(void *pvParameters) {
|
||||
SensorMassa *sensor = static_cast<SensorMassa*>(pvParameters);
|
||||
sensor->SMTask();
|
||||
}
|
||||
|
||||
void SMTask() {
|
||||
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 + _delayAmostragem)) {
|
||||
AferirMassa();
|
||||
|
||||
firstMilis = millis();
|
||||
}
|
||||
|
||||
// Aguarda metade do menor período possível entre leituras
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void AferirMassa() {
|
||||
float leitura = balanca->get_units(5);
|
||||
leituraMassa = filtro->updateEstimate(leitura);
|
||||
//EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sMAS, _ID, MontarDadosProtocoloMassa(leituraMassa)));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class SensorPressao {
|
||||
public:
|
||||
SensorPressao(String desc) {
|
||||
_ID = desc;
|
||||
}
|
||||
|
||||
// Definições
|
||||
String _ID;
|
||||
S_Code _componente = sPRS;
|
||||
PinoModel _pino;
|
||||
int _delayAmostragem;
|
||||
int _prioridade;
|
||||
|
||||
double _Vmin = 0.0;
|
||||
double _Vmax = 4.5;
|
||||
double _Pmax = 174.045;
|
||||
|
||||
volatile double leituraPressao;
|
||||
|
||||
SimpleKalmanFilter* filtro = nullptr;
|
||||
|
||||
bool Iniciado = false;
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
//EnviarDadosSerial(_ID + " ja inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
_pino.Conectar();
|
||||
filtro = new SimpleKalmanFilter(2, 2, 0.01);
|
||||
|
||||
xTaskCreatePinnedToCore(&SensorPressao::SPTaskWrapper, "SPTask", 5000, this, _prioridade, &SPTaskHandle, tskNO_AFFINITY);
|
||||
|
||||
//EnviarDadosSerial(_ID + " Iniciado");
|
||||
|
||||
Iniciado = true;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
//EnviarDadosSerial(_ID + " nao esta inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
delete filtro;
|
||||
|
||||
// Parar a execução das tarefas
|
||||
vTaskDelete(SPTaskHandle);
|
||||
|
||||
// Redefinir as configurações para os valores iniciais
|
||||
_pino.Desconectar();
|
||||
|
||||
//EnviarDadosSerial(_ID + " Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
private:
|
||||
double leituraNormalizada = 0.0;
|
||||
|
||||
TaskHandle_t SPTaskHandle = NULL;
|
||||
static void SPTaskWrapper(void *pvParameters) {
|
||||
SensorPressao *sensor = static_cast<SensorPressao*>(pvParameters);
|
||||
sensor->SPTask();
|
||||
}
|
||||
|
||||
void SPTask() {
|
||||
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;
|
||||
}
|
||||
|
||||
AferirPressao();
|
||||
|
||||
// Aguarda metade do menor período possível entre leituras
|
||||
vTaskDelay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void AferirPressao() {
|
||||
int leitura = _pino.get();
|
||||
leituraPressao = filtro->updateEstimate(leitura);
|
||||
|
||||
double tensao = fmap(leituraPressao, 0.0, 4095.0, 0.0, 3300.0) / 1000.0;
|
||||
_PressaoAtual = fmap(tensao, _Vmin, _Vmax, 0.0, _Pmax);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
BicoPulverizador B_01("B01");
|
||||
BicoPulverizador B_02("B02");
|
||||
BicoPulverizador B_03("B03");
|
||||
BicoPulverizador B_04("B04");
|
||||
BombaPressurizadora BOMBA("BOMBA");
|
||||
SensorFluxo SenFlx("FLXLN");
|
||||
SensorMassa SenMas("MASRS");
|
||||
SensorPressao SenPrs("PRSLN");
|
||||
|
||||
BicoPulverizador* BicoPorID(String ID) {
|
||||
BicoPulverizador* _bico =
|
||||
ID == "B01" ? &B_01 :
|
||||
ID == "B02" ? &B_02 :
|
||||
ID == "B03" ? &B_03 :
|
||||
ID == "B04" ? &B_04 :
|
||||
nullptr;
|
||||
return _bico;
|
||||
}
|
||||
|
||||
BombaPressurizadora* BombaPorID(String ID) {
|
||||
BombaPressurizadora* _bomba =
|
||||
ID == "BOMBA" ? &BOMBA :
|
||||
nullptr;
|
||||
return _bomba;
|
||||
}
|
||||
|
||||
SensorFluxo* SFPorID(String ID) {
|
||||
SensorFluxo* _sensor =
|
||||
ID == "FLXLN" ? &SenFlx :
|
||||
nullptr;
|
||||
return _sensor;
|
||||
}
|
||||
|
||||
SensorMassa* SMPorID(String ID) {
|
||||
SensorMassa* _sensor =
|
||||
ID == "MASRS" ? &SenMas :
|
||||
nullptr;
|
||||
return _sensor;
|
||||
}
|
||||
|
||||
SensorPressao* SPPorID(String ID) {
|
||||
SensorPressao* _sensor =
|
||||
ID == "PRSLN" ? &SenPrs :
|
||||
nullptr;
|
||||
return _sensor;
|
||||
}
|
||||
|
||||
void ZerarPinos() {
|
||||
//const int gpios[] = {2, 4, 5, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 32, 33};
|
||||
const int gpios[] = {4, 5, 6, 7, 15, 16, 17, 18, 8, 3, 46, 9, 10, 11, 12, 13, 14, 19, 20, 21, 47, 48, 45, 0, 35, 36, 37, 38, 39, 40, 41, 42, 2, 1};
|
||||
|
||||
for (int i = 0; i < sizeof(gpios) / sizeof(gpios[0]); i++) {
|
||||
pinMode(gpios[i], OUTPUT);
|
||||
digitalWrite(gpios[i], !AtuacaoNivelAlto);
|
||||
}
|
||||
}
|
||||
|
||||
void SensoriamentoTask(void *pvParameters);
|
||||
TaskHandle_t SensoriamentoTaskHandle = NULL;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(_baudRate);
|
||||
|
||||
ZerarPinos();
|
||||
|
||||
delay(10);
|
||||
|
||||
if (xTaskCreatePinnedToCore(SensoriamentoTask, "SensoriamentoTask", 8000, NULL, 5, &SensoriamentoTaskHandle, tskNO_AFFINITY) != pdPASS) {
|
||||
Serial.println("Erro ao criar tarefa SensoriamentoTask");
|
||||
}
|
||||
}
|
||||
|
||||
void SensoriamentoTask(void *pvParameters) {
|
||||
while (1)
|
||||
{
|
||||
if (!RequisitarDados && Conectado) {
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sATU, Mod_ID, MontarDadosProtocoloAtuador(
|
||||
B_01.Iniciado,
|
||||
B_01.StatusBico,
|
||||
B_02.Iniciado,
|
||||
B_02.StatusBico,
|
||||
B_03.Iniciado,
|
||||
B_03.StatusBico,
|
||||
B_04.Iniciado,
|
||||
B_04.StatusBico,
|
||||
BOMBA.Iniciado,
|
||||
BOMBA.Ligado,
|
||||
BOMBA.PotenciaAtual,
|
||||
SenFlx.Iniciado,
|
||||
SenFlx.pulsos,
|
||||
SenFlx.periodoTotal,
|
||||
SenMas.Iniciado,
|
||||
SenMas.leituraMassa,
|
||||
SenPrs.Iniciado,
|
||||
_PressaoAtual,
|
||||
SenPrs.leituraPressao
|
||||
)));
|
||||
}
|
||||
vTaskDelay(_TaxaAmostragem);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
std::vector<ProtocoloSerial> protocolos = LerBufferSerialFila(Mod_ID);
|
||||
|
||||
for (int i = 0; i < protocolos.size(); i++) {
|
||||
ProcessarProtocolo(protocolos[i]);
|
||||
}
|
||||
|
||||
delay(1);
|
||||
}
|
||||
|
||||
void ProcessarProtocolo(ProtocoloSerial Mensagem) {
|
||||
switch (Mensagem.funcao) {
|
||||
case Chk:
|
||||
ProcessarChk(Mensagem);
|
||||
break;
|
||||
case Cfg:
|
||||
ProcessarCfg(Mensagem);
|
||||
break;
|
||||
case Cmd:
|
||||
ProcessarCmd(Mensagem);
|
||||
break;
|
||||
case Req:
|
||||
ProcessarReq(Mensagem);
|
||||
break;
|
||||
}
|
||||
|
||||
if (Mensagem.idMensagem > 0) {
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloMensagemRecebida(Mensagem.idMensagem));
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarChk(ProtocoloSerial Mensagem) {
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloVerificacao(D_Code, VERSION, Conectado));
|
||||
}
|
||||
|
||||
void ProcessarCfg(ProtocoloSerial Mensagem) {
|
||||
std::vector<String> Partes = SplitString(Mensagem.protocolo, (char*)",");
|
||||
|
||||
String ID = Partes[0];
|
||||
bool Conectar = Partes[1] == "1";
|
||||
if (ID == "MD") {
|
||||
_TaxaAmostragem = Partes[2].toInt();
|
||||
bool _AtuaNivelAlto = Partes[3] == "1";
|
||||
bool _reqDados = Partes[4] == "1";
|
||||
|
||||
AtuacaoNivelAlto = _AtuaNivelAlto;
|
||||
RequisitarDados = _reqDados;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, "MD", Conectar ? "1" : "0"));
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
Conectado = Conectar;
|
||||
}
|
||||
else {
|
||||
BicoPulverizador* _bico = BicoPorID(ID);
|
||||
BombaPressurizadora* _bomba = BombaPorID(ID);
|
||||
|
||||
if (_bico != nullptr) {
|
||||
bool bico_ativado = Partes[2] == "1";
|
||||
int posicao = Partes[3].toInt();
|
||||
TiposBarramentos solenoideB = (TiposBarramentos)Partes[4].toInt();
|
||||
int solenoide = Partes[5].toInt();
|
||||
if (bico_ativado) {
|
||||
if (Conectar) {
|
||||
_bico->_posicao = posicao;
|
||||
_bico->_pinoSolenoide = PinoModel(solenoide, solenoideB, _OUTPUT);
|
||||
|
||||
_bico->Inicializar();
|
||||
}
|
||||
else {
|
||||
_bico->Desligar();
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(500));
|
||||
}
|
||||
}
|
||||
else if (_bomba != nullptr) {
|
||||
bool bomba_ativada = Partes[2] == "1";
|
||||
double pressaoSP = Partes[3].toDouble();
|
||||
TiposBarramentos enB = (TiposBarramentos)Partes[4].toInt();
|
||||
int pinoEN = Partes[5].toInt();
|
||||
TiposBarramentos csB = (TiposBarramentos)Partes[6].toInt();
|
||||
int pinoCS = Partes[7].toInt();
|
||||
TiposBarramentos inaB = (TiposBarramentos)Partes[8].toInt();
|
||||
int pinoINA = Partes[9].toInt();
|
||||
TiposBarramentos inbB = (TiposBarramentos)Partes[10].toInt();
|
||||
int pinoINB = Partes[11].toInt();
|
||||
TiposBarramentos pwmB = (TiposBarramentos)Partes[12].toInt();
|
||||
int pinoPWM = Partes[13].toInt();
|
||||
if (bomba_ativada) {
|
||||
if (Conectar) {
|
||||
_bomba->_PressaoSP = pressaoSP;
|
||||
_bomba->_pinoEN = PinoModel(pinoEN, enB, _OUTPUT);
|
||||
_bomba->_pinoCS = PinoModel(pinoCS, csB, _INPUT, DIGITAL);
|
||||
_bomba->_pinoINA = PinoModel(pinoINA, inaB, _OUTPUT);
|
||||
_bomba->_pinoINB = PinoModel(pinoINB, inbB, _OUTPUT);
|
||||
_bomba->_pinoPWM = PinoModel(pinoPWM, pwmB, _PWM);
|
||||
|
||||
_bomba->Inicializar();
|
||||
}
|
||||
else {
|
||||
_bomba->Desligar();
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(500));
|
||||
}
|
||||
}
|
||||
else {
|
||||
S_Code componente = (S_Code)Partes[2].toInt();
|
||||
bool sensor_ativado = Partes[3] == "1";
|
||||
int delayAmostragem = Partes[4].toInt();
|
||||
int prioridade = Partes[5].toInt();
|
||||
TiposBarramentos pinoB = (TiposBarramentos)Partes[6].toInt();
|
||||
int pino = Partes[7].toInt();
|
||||
|
||||
switch (componente) {
|
||||
case sFLX: {
|
||||
SensorFluxo* _sensor = SFPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
if (Conectar) {
|
||||
_sensor->_pino = PinoModel(pino, pinoB, _INPUT, DIGITAL);
|
||||
_sensor->_prioridade = prioridade;
|
||||
_sensor->_delayAmostragem = delayAmostragem;
|
||||
|
||||
_sensor->Inicializar();
|
||||
}
|
||||
else {
|
||||
_sensor->Desligar();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case sMAS: {
|
||||
SensorMassa* _sensor = SMPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
TiposBarramentos pino2B = (TiposBarramentos)Partes[8].toInt();
|
||||
int pino2 = Partes[9].toInt();
|
||||
|
||||
if (Conectar) {
|
||||
_sensor->_pinoDT = PinoModel(pino, pinoB, _INPUT, DIGITAL);
|
||||
_sensor->_pinoSCK = PinoModel(pino2, pino2B, _INPUT, DIGITAL);
|
||||
_sensor->_prioridade = prioridade;
|
||||
_sensor->_delayAmostragem = delayAmostragem;
|
||||
|
||||
_sensor->Inicializar();
|
||||
}
|
||||
else {
|
||||
_sensor->Desligar();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case sPRS: {
|
||||
SensorPressao* _sensor = SPPorID(ID);
|
||||
if (sensor_ativado) {
|
||||
double Vmin = Partes[8].toDouble();
|
||||
double Vmax = Partes[9].toDouble();
|
||||
double Pmax = Partes[10].toDouble();
|
||||
if (Conectar) {
|
||||
_sensor->_Vmin = Vmin;
|
||||
_sensor->_Vmax = Vmax;
|
||||
_sensor->_Pmax = Pmax;
|
||||
|
||||
_sensor->_pino = PinoModel(pino, pinoB, _INPUT, ANALOGICO);
|
||||
_sensor->_prioridade = prioridade;
|
||||
_sensor->_delayAmostragem = delayAmostragem;
|
||||
|
||||
_sensor->Inicializar();
|
||||
}
|
||||
else {
|
||||
_sensor->Desligar();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarCmd(ProtocoloSerial Mensagem) {
|
||||
std::vector<String> Partes = SplitString(Mensagem.protocolo, (char*)",");
|
||||
|
||||
String ID = Partes[0];
|
||||
|
||||
BicoPulverizador* _bico = BicoPorID(ID);
|
||||
BombaPressurizadora* _bomba = BombaPorID(ID);
|
||||
|
||||
if (_bico != nullptr) {
|
||||
_bico->_BicoAtuado = Partes[1] == (AtuacaoNivelAlto ? "1" : "0");
|
||||
_bico->AlterarStatusBico();
|
||||
}
|
||||
else if (_bomba != nullptr) {
|
||||
_bomba->_BombaAtuada = Partes[1] == "1";
|
||||
_bomba->_PressaoSP = Partes[2].toDouble();
|
||||
_bomba->AlterarStatusBomba();
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarReq(ProtocoloSerial Mensagem) {
|
||||
//std::vector<String> Partes = SplitString(Mensagem.protocolo, SplitParams);
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sATU, Mod_ID, MontarDadosProtocoloAtuador(
|
||||
B_01.Iniciado,
|
||||
B_01.StatusBico,
|
||||
B_02.Iniciado,
|
||||
B_02.StatusBico,
|
||||
B_03.Iniciado,
|
||||
B_03.StatusBico,
|
||||
B_04.Iniciado,
|
||||
B_04.StatusBico,
|
||||
BOMBA.Iniciado,
|
||||
BOMBA.Ligado,
|
||||
BOMBA.PotenciaAtual,
|
||||
SenFlx.Iniciado,
|
||||
SenFlx.pulsos,
|
||||
SenFlx.periodoTotal,
|
||||
SenMas.Iniciado,
|
||||
SenMas.leituraMassa,
|
||||
SenPrs.Iniciado,
|
||||
_PressaoAtual,
|
||||
SenPrs.leituraPressao
|
||||
)));
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +46,7 @@ enum S_Code {
|
|||
sBLD = 544,
|
||||
sCMD = 878,
|
||||
sMVD = 477,
|
||||
sATU = 478,
|
||||
};
|
||||
|
||||
enum Sentido {
|
||||
|
|
|
|||
|
|
@ -320,4 +320,28 @@ String MontarDadosProtocoloMVD(bool movIniciado, double temperatura, bool dirIni
|
|||
return Protocolo;
|
||||
}
|
||||
|
||||
String MontarDadosProtocoloAtuador(bool b1Iniciado, bool b1, bool b2Iniciado, bool b2, bool b3Iniciado, bool b3, bool b4Iniciado, bool b4, bool bombaIniciada, bool bomba_ligado, double bomba_potencia, bool fluxoIniciado, int fluxo_pulsos, int fluxo_periodo, bool massaIniciado, double massa_leitura, bool pressaoIniciado, double pressao, double pressao_leitura) {
|
||||
String Protocolo = (String)"" +
|
||||
(b1Iniciado ? "1" : "0") + SplitMessage +
|
||||
(b1 ? "1" : "0") + SplitMessage +
|
||||
(b2Iniciado ? "1" : "0") + SplitMessage +
|
||||
(b2 ? "1" : "0") + SplitMessage +
|
||||
(b3Iniciado ? "1" : "0") + SplitMessage +
|
||||
(b3 ? "1" : "0") + SplitMessage +
|
||||
(b4Iniciado ? "1" : "0") + SplitMessage +
|
||||
(b4 ? "1" : "0") + SplitMessage +
|
||||
(bombaIniciada ? "1" : "0") + SplitMessage +
|
||||
(bomba_ligado ? "1" : "0") + SplitMessage +
|
||||
(String)bomba_potencia + SplitMessage +
|
||||
(fluxoIniciado ? "1" : "0") + SplitMessage +
|
||||
(String)fluxo_pulsos + SplitMessage +
|
||||
(String)fluxo_periodo + SplitMessage +
|
||||
(massaIniciado ? "1" : "0") + SplitMessage +
|
||||
(String)massa_leitura + SplitMessage +
|
||||
(pressaoIniciado ? "1" : "0") + SplitMessage +
|
||||
(String)pressao + SplitMessage +
|
||||
(String)pressao_leitura;
|
||||
return Protocolo;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,879 @@
|
|||
// Dispositivo: Movimentação e Direcional Unificados
|
||||
// Versão Firmware: 5
|
||||
// Ultima atualização: 24/06/2024
|
||||
// Atualização: Adicionado driver motor de passo RS485
|
||||
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\SerialService.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\ModbusService.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\utils.h"
|
||||
#include "C:\ZendionInc\agrobot_base\Firmware\Modulos\Pinout.h"
|
||||
#include <SimpleKalmanFilter.h>
|
||||
|
||||
#define D_Code Mvd
|
||||
#define VERSION 5
|
||||
String Mod_ID = "";
|
||||
|
||||
#define _pinoAddr0 36
|
||||
#define _pinoAddr1 39
|
||||
|
||||
int _pinModbusRX = 16;
|
||||
int _pinModbusTX = 17;
|
||||
int _pinModbusMD = 4;
|
||||
|
||||
void AtualizarEnderecoModulo() {
|
||||
bool A0 = digitalRead(_pinoAddr0) == 1;
|
||||
bool A1 = digitalRead(_pinoAddr1) == 1;
|
||||
|
||||
if (!A0 && !A1) {
|
||||
Mod_ID = "ET";
|
||||
}
|
||||
else if (A0 && !A1) {
|
||||
Mod_ID = "EF";
|
||||
}
|
||||
else if (!A0 && A1) {
|
||||
Mod_ID = "DT";
|
||||
}
|
||||
else if (A0 && A1) {
|
||||
Mod_ID = "DF";
|
||||
}
|
||||
}
|
||||
|
||||
long _baudRate = 115200;
|
||||
volatile bool Conectado = false;
|
||||
volatile int _TaxaAmostragem = 500;
|
||||
volatile bool RequisitarDados = false;
|
||||
|
||||
|
||||
class MotorBLDC {
|
||||
public:
|
||||
String _ID = "Mov";
|
||||
int _canal = 4;
|
||||
|
||||
volatile bool Iniciado = false;
|
||||
bool Testando = false;
|
||||
|
||||
PinoModel _pinoEN;
|
||||
PinoModel _pinoFR;
|
||||
PinoModel _pinoSV;
|
||||
PinoModel _pinoBK;
|
||||
|
||||
PinoModel _pinoTMP;
|
||||
SimpleKalmanFilter tempKalman = SimpleKalmanFilter(2, 2, 0.01);
|
||||
|
||||
byte _endereco;
|
||||
int _numPolos;
|
||||
int _rampa;
|
||||
int _rpmMax;
|
||||
|
||||
// Consumo
|
||||
double RPM;
|
||||
double RPM_SP;
|
||||
double Temperatura;
|
||||
double TemperaturaDriver;
|
||||
double Tensao;
|
||||
double CorrenteMax;
|
||||
bool Ligado;
|
||||
bool Freio;
|
||||
Sentido _Sentido = Parado;
|
||||
int CodAlarme;
|
||||
|
||||
// Entrada de dados
|
||||
double _RPM_SP;
|
||||
bool _Ligado = false;
|
||||
bool _Freio = false;
|
||||
Sentido _SentidoSP = Parado;
|
||||
|
||||
volatile bool ComandoEnviado = false;
|
||||
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
Iniciado = ConfigurarDriver();
|
||||
|
||||
if (_pinoEN.Definido()) {
|
||||
_pinoEN.Conectar(true);
|
||||
}
|
||||
if (_pinoFR.Definido()) {
|
||||
_pinoFR.Conectar();
|
||||
}
|
||||
if (_pinoBK.Definido()) {
|
||||
_pinoBK.Conectar(true);
|
||||
}
|
||||
if (_pinoSV.Definido()) {
|
||||
AtualizarPWM();
|
||||
}
|
||||
|
||||
if (_pinoTMP.Definido()) {
|
||||
_pinoTMP.Conectar();
|
||||
}
|
||||
|
||||
if (Iniciado) {
|
||||
AtualizarDadosControle(true);
|
||||
}
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
//EnviarDadosSerial(Mod_ID, _ID + " nao esta inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Parar a execução das tarefas
|
||||
//vTaskDelete(MovTaskHandle);
|
||||
|
||||
// Redefinir as configurações para os valores iniciais
|
||||
_pinoEN.Desconectar();
|
||||
_pinoFR.Desconectar();
|
||||
_pinoSV.Desconectar();
|
||||
_pinoBK.Desconectar();
|
||||
_pinoTMP.Desconectar();
|
||||
|
||||
//EnviarDadosSerial(Mod_ID, _ID + " Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
|
||||
AtualizarDadosControle(true);
|
||||
}
|
||||
|
||||
void AtualizarDadosControle(bool reset = false) {
|
||||
if (!Iniciado) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (reset) {
|
||||
_Ligado = false;
|
||||
_Freio = false;
|
||||
_SentidoSP = Parado;
|
||||
_RPM_SP = 0;
|
||||
}
|
||||
|
||||
int val = map(_RPM_SP, 0, _rpmMax, 0, 1023);
|
||||
ledcWrite(_canal, val);
|
||||
_pinoFR.set(_SentidoSP == Horario ? false : true);
|
||||
_pinoBK.set(!_Freio);
|
||||
_pinoEN.set(!_Ligado);
|
||||
|
||||
|
||||
/*ComandoEnviado = true;
|
||||
EnviarComandoModbus(_endereco, 0x06, 0x006D, _SentidoSP == Horario ? 1 : 0, false);
|
||||
EnviarComandoModbus(_endereco, 0x06, 0x0056, _RPM_SP, false);
|
||||
EnviarComandoModbus(_endereco, 0x06, 0x006A, _Freio ? 1 : 0, false);
|
||||
EnviarComandoModbus(_endereco, 0x06, 0x0066, _Ligado ? 1 : 0, false);
|
||||
vTaskDelay(100);
|
||||
ComandoEnviado = false;*/
|
||||
}
|
||||
|
||||
void RequisitarDados() {
|
||||
AferirDadosDriver();
|
||||
AferirTemperatura();
|
||||
|
||||
//EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sBLD, _ID, MontarDadosProtocoloBLD(RPM, Temperatura, Tensao, CorrenteMax, Ligado, _Sentido, Freio, CodAlarme, TemperaturaDriver)));
|
||||
}
|
||||
|
||||
private:
|
||||
ModbusGetResponse EnviarComandoModbus(byte endereco, byte funcao, byte registro, int valor, bool aguardarResposta = true) {
|
||||
const int maxTentativas = 2;
|
||||
int tentativas = 0;
|
||||
bool sucesso = false;
|
||||
ModbusGetResponse resposta;
|
||||
|
||||
while (tentativas < maxTentativas && !sucesso) {
|
||||
uint8_t response[256];
|
||||
uint8_t length = 0;
|
||||
|
||||
sendModbusCommand(endereco, funcao, registro, valor, response, length, aguardarResposta);
|
||||
|
||||
if (aguardarResposta) {
|
||||
if (funcao == 0x03) {
|
||||
if (length >= 5) {
|
||||
resposta._success = true;
|
||||
resposta._address = response[0];
|
||||
resposta._command_code = response[1];
|
||||
resposta._num_registers = response[2];
|
||||
|
||||
if (resposta._num_registers == 2) {
|
||||
uint16_t value = (response[3] << 8) | response[4];
|
||||
resposta._value = static_cast<double>(value);
|
||||
sucesso = true;
|
||||
} else if (resposta._num_registers == 4 && length >= 7) {
|
||||
uint16_t highBytes = (response[3] << 8) | response[4];
|
||||
uint16_t lowBytes = (response[5] << 8) | response[6];
|
||||
|
||||
// Combinar os bytes de alta e baixa ordem em um valor de 32 bits
|
||||
uint32_t combined = (static_cast<uint32_t>(highBytes) << 16) | lowBytes;
|
||||
|
||||
// Reinterpretar o valor combinado como um float
|
||||
float floatValue;
|
||||
memcpy(&floatValue, &combined, sizeof(floatValue));
|
||||
|
||||
resposta._value = static_cast<double>(floatValue);
|
||||
|
||||
sucesso = true;
|
||||
} else {
|
||||
resposta._success = false;
|
||||
}
|
||||
} else {
|
||||
resposta._success = false;
|
||||
}
|
||||
} else if (funcao == 0x06) {
|
||||
if (length >= 8) {
|
||||
resposta._success = true;
|
||||
resposta._address = response[0];
|
||||
resposta._command_code = response[1];
|
||||
resposta._num_registers = 0;
|
||||
resposta._value = (response[4] << 8) | response[5];
|
||||
sucesso = true;
|
||||
} else {
|
||||
Serial.println("Erro ao enviar comando");
|
||||
resposta._success = false;
|
||||
}
|
||||
}
|
||||
|
||||
tentativas++;
|
||||
} else {
|
||||
sucesso = true;
|
||||
resposta._success = sucesso;
|
||||
}
|
||||
}
|
||||
|
||||
return resposta;
|
||||
}
|
||||
|
||||
bool ConfigurarDriver() {
|
||||
ModbusGetResponse a = EnviarComandoModbus(_endereco, 0x06, 0x00B6, 1);
|
||||
if (a._success) {
|
||||
ModbusGetResponse b = EnviarComandoModbus(_endereco, 0x06, 0x0076, 0);
|
||||
if (b._success) {
|
||||
ModbusGetResponse c = EnviarComandoModbus(_endereco, 0x06, 0x0086, _numPolos);
|
||||
if (c._success) {
|
||||
ModbusGetResponse d = EnviarComandoModbus(_endereco, 0x06, 0x008A, _rampa);
|
||||
if (d._success) {
|
||||
ModbusGetResponse e = EnviarComandoModbus(_endereco, 0x06, 0x0092, _rpmMax);
|
||||
if (e._success) {
|
||||
ModbusGetResponse f = EnviarComandoModbus(_endereco, 0x06, 0x00B6, 0);
|
||||
return f._success;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AferirDadosDriver() {
|
||||
AguardaEnvioComando();
|
||||
RPM_SP = EnviarComandoModbus(_endereco, 0x03, 0x0056, 1)._value;
|
||||
AguardaEnvioComando();
|
||||
RPM = EnviarComandoModbus(_endereco, 0x03, 0x005F, 1)._value;
|
||||
AguardaEnvioComando();
|
||||
Ligado = EnviarComandoModbus(_endereco, 0x03, 0x0066, 1)._value == 1;
|
||||
AguardaEnvioComando();
|
||||
Freio = EnviarComandoModbus(_endereco, 0x03, 0x006A, 1)._value == 1;
|
||||
AguardaEnvioComando();
|
||||
_Sentido = Ligado ? EnviarComandoModbus(_endereco, 0x03, 0x006D, 1)._value == 1 ? Horario : Antihorario : Parado;
|
||||
AguardaEnvioComando();
|
||||
CodAlarme = EnviarComandoModbus(_endereco, 0x03, 0x0076, 1)._value;
|
||||
AguardaEnvioComando();
|
||||
Tensao = EnviarComandoModbus(_endereco, 0x03, 0x00C8, 2)._value;
|
||||
AguardaEnvioComando();
|
||||
CorrenteMax = EnviarComandoModbus(_endereco, 0x03, 0x0096, 2)._value;
|
||||
AguardaEnvioComando();
|
||||
TemperaturaDriver = EnviarComandoModbus(_endereco, 0x03, 0x00D2, 2)._value;
|
||||
}
|
||||
|
||||
void AferirTemperatura() {
|
||||
int leitura = _pinoTMP.get();
|
||||
float leituraNormalizada = tempKalman.updateEstimate(leitura);
|
||||
Temperatura = leituraNormalizada;
|
||||
}
|
||||
|
||||
void AguardaEnvioComando() {
|
||||
while (ComandoEnviado) {
|
||||
vTaskDelay(50);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class MotorPasso {
|
||||
public:
|
||||
String _ID = "Dir";
|
||||
int _canal = 0;
|
||||
|
||||
volatile bool Iniciado = false;
|
||||
bool Testando = false;
|
||||
|
||||
// Definições
|
||||
byte _endereco = 0x01;
|
||||
PinoModel _pinoENA;
|
||||
PinoModel _pinoDIR;
|
||||
PinoModel _pinoPUL;
|
||||
PinoModel _pinoEncoder;
|
||||
|
||||
SimpleKalmanFilter encoderKalman = SimpleKalmanFilter(1, 2, 0.01);
|
||||
|
||||
// Consumo
|
||||
double _Angulo;
|
||||
Sentido _Sentido;
|
||||
|
||||
// Entrada de dados
|
||||
double _Angulo_SP;
|
||||
int _Angulo_Offset = 0;
|
||||
Sentido _Sentido_SP = Parado;
|
||||
bool _MotorLigado = false;
|
||||
bool _Estabilizar = true;
|
||||
double _frequencia = 4000;
|
||||
|
||||
int FrequenciaMaxima = 10000;
|
||||
int dutyCycle = 512;
|
||||
|
||||
|
||||
void Inicializar() {
|
||||
if (Iniciado) {
|
||||
//EnviarDadosSerial(Mod_ID, _ID + " ja inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
Iniciado = true;
|
||||
|
||||
if (_pinoPUL.Definido()) {
|
||||
AtualizarPWM();
|
||||
}
|
||||
_pinoENA.Conectar(true);
|
||||
_pinoDIR.Conectar(false);
|
||||
_pinoEncoder.Conectar();
|
||||
|
||||
_Angulo_SP = 0;
|
||||
_MotorLigado = false;
|
||||
VerificarAnguloSPparado(true);
|
||||
|
||||
xTaskCreatePinnedToCore(&MotorPasso::DirTaskWrapper, "DirTask", 5000, this, 18, &DirTaskHandle, tskNO_AFFINITY);
|
||||
|
||||
//EnviarDadosSerial(Mod_ID, _ID + " Iniciado");
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void Desligar() {
|
||||
if (!Iniciado) {
|
||||
//EnviarDadosSerial(Mod_ID, _ID + " nao esta inicializado");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Parar a execução das tarefas
|
||||
vTaskDelete(DirTaskHandle);
|
||||
|
||||
// Redefinir as configurações para os valores iniciais
|
||||
_pinoENA.Desconectar();
|
||||
_pinoDIR.Desconectar();
|
||||
_pinoPUL.Desconectar();
|
||||
_pinoEncoder.Desconectar();
|
||||
|
||||
|
||||
//EnviarDadosSerial(Mod_ID, _ID + " Desligado");
|
||||
|
||||
Iniciado = false;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sCFG, _ID, Iniciado ? "1" : "0"));
|
||||
}
|
||||
|
||||
void RequisitarDados() {
|
||||
_Angulo = EnviarComandoModbus(_endereco, 0x31, 0)._value;
|
||||
//EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sENC, _ID, MontarDadosProtocoloEncoderAbsoluto(_Sentido, _Angulo)));
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void sendModbusCommandStepper(ModbusMessage& message) {
|
||||
uint8_t command[5];
|
||||
|
||||
command[0] = 0xFA;
|
||||
command[1] = message.slaveAddress;
|
||||
command[2] = message.functionCode;
|
||||
|
||||
uint16_t crc = calculateCRC(command, 3);
|
||||
command[3] = crc & 0xFF;
|
||||
command[4] = (crc >> 8) & 0xFF;
|
||||
|
||||
// Alternar para modo de transmissão
|
||||
digitalWrite(DE_RE_PIN, HIGH);
|
||||
vTaskDelay(pdMS_TO_TICKS(1)); // Pequeno atraso para garantir que o modo de transmissão esteja ativo
|
||||
|
||||
SerialDriver.write(command, 5);
|
||||
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);
|
||||
vTaskDelay(pdMS_TO_TICKS(1)); // Pequeno atraso para garantir que o modo de recepção esteja ativo
|
||||
|
||||
*message.length = 0;
|
||||
|
||||
if (message.waitCallback) {
|
||||
// Aguardar a resposta
|
||||
unsigned long startTime = millis();
|
||||
unsigned long timeout = 1000;
|
||||
while (SerialDriver.available() < 5 && (millis() - startTime) < timeout) {
|
||||
vTaskDelay(pdMS_TO_TICKS(50));
|
||||
}
|
||||
|
||||
// Ler a resposta
|
||||
if (SerialDriver.available()) {
|
||||
*message.length = SerialDriver.readBytes(message.response, SerialDriver.available());
|
||||
|
||||
if (Debug) {
|
||||
// Imprimir a resposta em formato hexadecimal
|
||||
Serial.print("Resposta recebida: ");
|
||||
for (int i = 0; i < *message.length; i++) {
|
||||
if (message.response[i] < 0x10) {
|
||||
Serial.print("0"); // Adiciona um zero à esquerda para bytes menores que 0x10
|
||||
}
|
||||
Serial.print(message.response[i], HEX);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
} else {
|
||||
Serial.println("Timeout ao aguardar resposta Modbus");
|
||||
}
|
||||
} else {
|
||||
vTaskDelay(pdMS_TO_TICKS(50));
|
||||
}
|
||||
|
||||
// Sinalizar que a resposta está disponível
|
||||
xSemaphoreGive(message.responseSemaphore);
|
||||
}
|
||||
|
||||
ModbusGetResponse EnviarComandoModbus(byte endereco, byte funcao, int valor, bool aguardarResposta = true) {
|
||||
const int maxTentativas = 2;
|
||||
int tentativas = 0;
|
||||
bool sucesso = false;
|
||||
ModbusGetResponse resposta;
|
||||
|
||||
while (tentativas < maxTentativas && !sucesso) {
|
||||
uint8_t response[256];
|
||||
uint8_t length = 0;
|
||||
|
||||
ModbusMessage message;
|
||||
message.slaveAddress = endereco;
|
||||
message.functionCode = funcao;
|
||||
message.value = valor;
|
||||
message.response = response;
|
||||
message.length = &length;
|
||||
message.priority = PRIORITY_HIGH;
|
||||
message.waitCallback = aguardarResposta;
|
||||
message.responseSemaphore = xSemaphoreCreateBinary();
|
||||
|
||||
sendModbusCommandStepper(message);
|
||||
|
||||
if (aguardarResposta) {
|
||||
if (length >= 5) {
|
||||
resposta._success = true;
|
||||
resposta._address = response[1];
|
||||
resposta._command_code = response[2];
|
||||
|
||||
if (length <= 7) {
|
||||
uint16_t value = (response[3] << 8) | response[4];
|
||||
resposta._value = static_cast<double>(value);
|
||||
sucesso = true;
|
||||
} else if (length > 7) {
|
||||
uint16_t highBytes = (response[3] << 8) | response[4];
|
||||
uint16_t lowBytes = (response[5] << 8) | response[6];
|
||||
|
||||
// Combinar os bytes de alta e baixa ordem em um valor de 32 bits
|
||||
uint32_t combined = (static_cast<uint32_t>(highBytes) << 16) | lowBytes;
|
||||
|
||||
// Reinterpretar o valor combinado como um float
|
||||
float floatValue;
|
||||
memcpy(&floatValue, &combined, sizeof(floatValue));
|
||||
|
||||
resposta._value = static_cast<double>(floatValue);
|
||||
|
||||
sucesso = true;
|
||||
} else {
|
||||
resposta._success = false;
|
||||
}
|
||||
} else {
|
||||
resposta._success = false;
|
||||
}
|
||||
|
||||
tentativas++;
|
||||
} else {
|
||||
sucesso = true;
|
||||
resposta._success = sucesso;
|
||||
}
|
||||
}
|
||||
|
||||
return resposta;
|
||||
}
|
||||
|
||||
double _Margem = 0.5;
|
||||
double _AgMin = 95;
|
||||
double _AgMax = 855;
|
||||
int RefMin = -90;
|
||||
int RefMax = 90;
|
||||
|
||||
double _anguloAnterior = 0;
|
||||
double _anguloAtual = 0;
|
||||
double _taxaMudancaAngulo = 0;
|
||||
|
||||
TaskHandle_t DirTaskHandle = NULL;
|
||||
static void DirTaskWrapper(void *pvParameters) {
|
||||
MotorPasso* motor = static_cast<MotorPasso*>(pvParameters);
|
||||
motor->DirTask();
|
||||
}
|
||||
|
||||
void DirTask() {
|
||||
unsigned long previousMillisRampa = millis();
|
||||
|
||||
while (true) {
|
||||
if (!Conectado) {
|
||||
vTaskDelay(1000);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*AferirPosicao();
|
||||
DefinirSentidoDeGiro();
|
||||
VerificarAnguloSP();
|
||||
Atualizar();*/
|
||||
|
||||
/*if (millis() - previousMillisRampa >= _TaxaAmostragem) {
|
||||
previousMillisRampa = millis();
|
||||
|
||||
RequisitarDados();
|
||||
}*/
|
||||
|
||||
vTaskDelay(100);
|
||||
}
|
||||
}
|
||||
|
||||
void AferirPosicao() {
|
||||
if (_pinoEncoder.Definido()) {
|
||||
int leitura = _pinoEncoder.get();
|
||||
float leituraNormalizada = encoderKalman.updateEstimate(leitura);
|
||||
double _angulo = fmap(leituraNormalizada, _AgMin, _AgMax, RefMin, RefMax);
|
||||
|
||||
double angulo_com_offset = _angulo - _Angulo_Offset;
|
||||
|
||||
// Normaliza o ângulo para o intervalo de -90 a 90 graus
|
||||
while (angulo_com_offset > RefMax) angulo_com_offset -= 180;
|
||||
while (angulo_com_offset < RefMin) angulo_com_offset += 180;
|
||||
|
||||
_Angulo = angulo_com_offset;
|
||||
}
|
||||
}
|
||||
|
||||
void DefinirSentidoDeGiro() {
|
||||
_anguloAtual = _Angulo;
|
||||
|
||||
// Calcular a taxa de mudança do ângulo
|
||||
_taxaMudancaAngulo = (_anguloAtual - _anguloAnterior) / (1.0 / 1000.0); // Supondo que a leitura é feita a cada 1 ms
|
||||
|
||||
if (_MotorLigado) {
|
||||
if (_taxaMudancaAngulo > 0) {
|
||||
_Sentido = Horario;
|
||||
} else if (_taxaMudancaAngulo < 0) {
|
||||
_Sentido = Antihorario;
|
||||
} else {
|
||||
_Sentido = Parado;
|
||||
}
|
||||
} else {
|
||||
_Sentido = Parado;
|
||||
}
|
||||
|
||||
_anguloAnterior = _anguloAtual;
|
||||
}
|
||||
|
||||
unsigned long previousMillisCorrecao = millis();
|
||||
void VerificarAnguloSP() {
|
||||
bool ModoSP = (_Angulo_SP > -1);
|
||||
if (_MotorLigado) {
|
||||
double AnguloComparar = ModoSP ? _Angulo_SP : RefMax;
|
||||
if (_Sentido_SP == Horario && _Angulo >= AnguloComparar) {
|
||||
_MotorLigado = false;
|
||||
}
|
||||
else if (_Sentido_SP == Antihorario && _Angulo <= (AnguloComparar * -1)) {
|
||||
_MotorLigado = false;
|
||||
}
|
||||
}
|
||||
else if (ModoSP) {
|
||||
if (millis() - previousMillisCorrecao >= _TaxaAmostragem) {
|
||||
previousMillisCorrecao = millis();
|
||||
|
||||
VerificarAnguloSPparado(_Estabilizar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VerificarAnguloSPparado(bool _estabilizar) {
|
||||
bool NoRangeZero = (_Angulo >= -_Margem && _Angulo <= _Margem);
|
||||
bool NoRangeSP = (_Angulo >= (_Angulo_SP - _Margem) && _Angulo <= (_Angulo_SP + _Margem));
|
||||
if (_Angulo_SP == 0) {
|
||||
if (!NoRangeZero && _estabilizar) {
|
||||
_Sentido_SP = _Angulo > 0 ? Antihorario : Horario;
|
||||
_MotorLigado = true;
|
||||
}
|
||||
}
|
||||
else if (!NoRangeSP) {
|
||||
_MotorLigado = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Atualizar() {
|
||||
_pinoENA.set(!_MotorLigado);
|
||||
_pinoDIR.set(_Sentido_SP != Antihorario);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
MotorBLDC MotorMOV;
|
||||
MotorPasso MotorDIR;
|
||||
|
||||
void AtualizarPWM() {
|
||||
if (MotorDIR.Iniciado && MotorDIR._pinoPUL.Definido()) {
|
||||
ledcSetup(MotorDIR._canal, MotorDIR._frequencia, 10);
|
||||
ledcAttachPin(MotorDIR._pinoPUL.num, MotorDIR._canal);
|
||||
ledcWrite(MotorDIR._canal, MotorDIR.dutyCycle);
|
||||
}
|
||||
if (MotorMOV.Iniciado && MotorMOV._pinoSV.Definido()) {
|
||||
ledcSetup(MotorMOV._canal, 1000, 10);
|
||||
ledcAttachPin(MotorMOV._pinoSV.num, MotorMOV._canal);
|
||||
ledcWrite(MotorMOV._canal, MotorMOV._RPM_SP);
|
||||
}
|
||||
}
|
||||
|
||||
void SensoriamentoTask(void *pvParameters);
|
||||
TaskHandle_t SensoriamentoTaskHandle = NULL;
|
||||
|
||||
void setup() {
|
||||
pinMode(_pinoAddr0, INPUT);
|
||||
pinMode(_pinoAddr1, INPUT);
|
||||
|
||||
AtualizarEnderecoModulo();
|
||||
|
||||
Serial.begin(_baudRate, SERIAL_8N1, 1, 3);
|
||||
|
||||
analogReadResolution(10);
|
||||
|
||||
delay(10);
|
||||
|
||||
ConfigurarModbus(true, _pinModbusRX, _pinModbusTX, _pinModbusMD, 9600, true);
|
||||
|
||||
delay(10);
|
||||
|
||||
if (xTaskCreatePinnedToCore(SensoriamentoTask, "SensoriamentoTask", 8000, NULL, 5, &SensoriamentoTaskHandle, tskNO_AFFINITY) != pdPASS) {
|
||||
Serial.println("Erro ao criar tarefa SensoriamentoTask");
|
||||
}
|
||||
}
|
||||
|
||||
void SensoriamentoTask(void *pvParameters) {
|
||||
while (1)
|
||||
{
|
||||
Conectado = MotorMOV.Iniciado || MotorDIR.Iniciado;
|
||||
|
||||
if (!RequisitarDados && Conectado) {
|
||||
|
||||
if (MotorMOV.Iniciado) {
|
||||
MotorMOV.RequisitarDados();
|
||||
}
|
||||
if (MotorDIR.Iniciado) {
|
||||
MotorDIR.RequisitarDados();
|
||||
}
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sMVD, Mod_ID, MontarDadosProtocoloMVD(
|
||||
MotorMOV.Iniciado,
|
||||
MotorMOV.RPM,
|
||||
MotorMOV.Temperatura,
|
||||
MotorMOV.Tensao,
|
||||
MotorMOV.CorrenteMax,
|
||||
MotorMOV.Ligado,
|
||||
MotorMOV._Sentido,
|
||||
MotorMOV.Freio,
|
||||
MotorMOV.CodAlarme,
|
||||
MotorMOV.TemperaturaDriver,
|
||||
MotorDIR.Iniciado,
|
||||
MotorDIR._Sentido,
|
||||
MotorDIR._Angulo
|
||||
)));
|
||||
}
|
||||
vTaskDelay(_TaxaAmostragem);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
std::vector<ProtocoloSerial> protocolos = LerBufferSerialFila(Mod_ID);
|
||||
|
||||
for (int i = 0; i < protocolos.size(); i++) {
|
||||
ProcessarProtocolo(protocolos[i]);
|
||||
}
|
||||
|
||||
delay(1);
|
||||
}
|
||||
|
||||
void ProcessarProtocolo(ProtocoloSerial Mensagem) {
|
||||
switch (Mensagem.funcao) {
|
||||
case Chk:
|
||||
ProcessarChk(Mensagem);
|
||||
break;
|
||||
case Cfg:
|
||||
ProcessarCfg(Mensagem);
|
||||
break;
|
||||
case Cmd:
|
||||
ProcessarCmd(Mensagem);
|
||||
break;
|
||||
case Req:
|
||||
ProcessarReq(Mensagem);
|
||||
break;
|
||||
}
|
||||
|
||||
if (Mensagem.idMensagem > 0) {
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloMensagemRecebida(Mensagem.idMensagem));
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarChk(ProtocoloSerial Mensagem) {
|
||||
Conectado = MotorMOV.Iniciado || MotorDIR.Iniciado;
|
||||
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloVerificacao(D_Code, VERSION, Conectado));
|
||||
}
|
||||
|
||||
void ProcessarCfg(ProtocoloSerial Mensagem) {
|
||||
std::vector<String> Partes = SplitString(Mensagem.protocolo, SplitParams);
|
||||
|
||||
String ID = Partes[0];
|
||||
bool Conectar = Partes[1] == "1";
|
||||
|
||||
if (ID == Mod_ID) {
|
||||
_TaxaAmostragem = Partes[2].toInt();
|
||||
RequisitarDados = Partes[3].toInt();
|
||||
TiposBarramentos txB = (TiposBarramentos)Partes[4].toInt();
|
||||
int txP = Partes[5].toInt();
|
||||
TiposBarramentos rxB = (TiposBarramentos)Partes[6].toInt();
|
||||
int rxP = Partes[7].toInt();
|
||||
TiposBarramentos MtxB = (TiposBarramentos)Partes[8].toInt();
|
||||
int MtxP = Partes[9].toInt();
|
||||
TiposBarramentos MrxB = (TiposBarramentos)Partes[10].toInt();
|
||||
int MrxP = Partes[11].toInt();
|
||||
TiposBarramentos MmdB = (TiposBarramentos)Partes[12].toInt();
|
||||
int MmdP = Partes[13].toInt();
|
||||
_pinModbusMD = MmdP;
|
||||
_pinModbusRX = MrxP;
|
||||
_pinModbusTX = MtxP;
|
||||
|
||||
//ConfigurarModbus(Conectar, _pinModbusRX, _pinModbusTX, _pinModbusMD);
|
||||
}
|
||||
else if (ID == MotorMOV._ID) {
|
||||
if (Conectar) {
|
||||
MotorMOV._endereco = stringToByte(Partes[2]);
|
||||
MotorMOV._numPolos = Partes[3].toInt();
|
||||
MotorMOV._rampa = Partes[4].toInt();
|
||||
MotorMOV._rpmMax = Partes[5].toInt();
|
||||
MotorMOV._pinoTMP = PinoModel(Partes[7].toInt(), (TiposBarramentos)Partes[6].toInt(), _INPUT, ANALOGICO);
|
||||
MotorMOV._pinoEN = PinoModel(Partes[9].toInt(), (TiposBarramentos)Partes[8].toInt(), _OUTPUT);
|
||||
MotorMOV._pinoFR = PinoModel(Partes[11].toInt(), (TiposBarramentos)Partes[10].toInt(), _OUTPUT);
|
||||
MotorMOV._pinoSV = PinoModel(Partes[13].toInt(), (TiposBarramentos)Partes[12].toInt(), _PWM);
|
||||
MotorMOV._pinoBK = PinoModel(Partes[15].toInt(), (TiposBarramentos)Partes[14].toInt(), _OUTPUT);
|
||||
|
||||
MotorMOV.Inicializar();
|
||||
}
|
||||
else {
|
||||
MotorMOV.Desligar();
|
||||
}
|
||||
}
|
||||
else if (ID == MotorDIR._ID) {
|
||||
if (Conectar) {
|
||||
MotorDIR._Estabilizar = Partes[2] == "1";
|
||||
MotorDIR._Angulo_Offset = Partes[3].toInt();
|
||||
MotorDIR._pinoPUL = PinoModel(Partes[5].toInt(), (TiposBarramentos)Partes[4].toInt(), _PWM);
|
||||
MotorDIR._pinoDIR = PinoModel(Partes[7].toInt(), (TiposBarramentos)Partes[6].toInt(), _OUTPUT);
|
||||
MotorDIR._pinoENA = PinoModel(Partes[9].toInt(), (TiposBarramentos)Partes[8].toInt(), _OUTPUT);
|
||||
MotorDIR._pinoEncoder = PinoModel(Partes[11].toInt(), (TiposBarramentos)Partes[10].toInt(), _INPUT, ANALOGICO);
|
||||
|
||||
MotorDIR.Inicializar();
|
||||
}
|
||||
else {
|
||||
MotorDIR.Desligar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarCmd(ProtocoloSerial Mensagem) {
|
||||
std::vector<String> Partes = SplitString(Mensagem.protocolo, SplitParams);
|
||||
|
||||
String ID = Partes[0];
|
||||
|
||||
if (ID == MotorMOV._ID && MotorMOV.Iniciado) {
|
||||
MotorMOV._SentidoSP = (Sentido)Partes[1].toInt();
|
||||
MotorMOV._Ligado = MotorMOV._SentidoSP != Parado;
|
||||
MotorMOV._RPM_SP = Partes[2].toInt();
|
||||
MotorMOV._Freio = Partes[3] == "1";
|
||||
|
||||
MotorMOV.AtualizarDadosControle();
|
||||
}
|
||||
else if (ID == MotorDIR._ID && MotorDIR.Iniciado) {
|
||||
MotorDIR._Sentido_SP = (Sentido)Partes[1].toInt();
|
||||
MotorDIR._Angulo_SP = Partes[2].toInt();
|
||||
MotorDIR._frequencia = (Partes[3].toInt() / 100.0) * MotorDIR.FrequenciaMaxima;
|
||||
|
||||
AtualizarPWM();
|
||||
|
||||
MotorDIR._MotorLigado = MotorDIR._Sentido_SP != Parado;
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessarReq(ProtocoloSerial Mensagem) {
|
||||
//std::vector<String> Partes = SplitString(Mensagem.protocolo, SplitParams);
|
||||
//Serial.println("Processando req...");
|
||||
if (MotorMOV.Iniciado) {
|
||||
MotorMOV.RequisitarDados();
|
||||
}
|
||||
if (MotorDIR.Iniciado) {
|
||||
MotorDIR.RequisitarDados();
|
||||
}
|
||||
|
||||
if (MotorMOV.Iniciado || MotorDIR.Iniciado) {
|
||||
//Serial.println("Enviando dados...");
|
||||
EnviarDadosSerial(Mod_ID, MontarProtocoloSensor(sMVD, Mod_ID, MontarDadosProtocoloMVD(
|
||||
MotorMOV.Iniciado,
|
||||
MotorMOV.RPM,
|
||||
MotorMOV.Temperatura,
|
||||
MotorMOV.Tensao,
|
||||
MotorMOV.CorrenteMax,
|
||||
MotorMOV.Ligado,
|
||||
MotorMOV._Sentido,
|
||||
MotorMOV.Freio,
|
||||
MotorMOV.CodAlarme,
|
||||
MotorMOV.TemperaturaDriver,
|
||||
MotorDIR.Iniciado,
|
||||
MotorDIR._Sentido,
|
||||
MotorDIR._Angulo
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,106 @@
|
|||
import serial
|
||||
import time
|
||||
|
||||
# Configuração da porta serial
|
||||
ser = serial.Serial(
|
||||
port='COM19', # Substitua pelo seu porto serial
|
||||
baudrate=38400,
|
||||
timeout=1
|
||||
)
|
||||
|
||||
slave_address = 0x01 # Endereço do escravo
|
||||
|
||||
Parametros = {
|
||||
"EncoderCarry": 0x30,
|
||||
"EncoderAddition": 0x31,
|
||||
"RPM": 0x32,
|
||||
"PulsesReceived": 0x33,
|
||||
"ErrorShaftAngle": 0x39,
|
||||
"EnPinStatus": 0x3A,
|
||||
"GoBackZeroStatus": 0x3B,
|
||||
"ProtectionRotorLockedStatus": 0x3D,
|
||||
"ProtectionShaftStatus": 0x3E,
|
||||
"Calibrate": 0x80,
|
||||
"Mode": 0x82,
|
||||
"MaxCurrent": 0x83,
|
||||
"Subdivision": 0x84,
|
||||
"EnPin": 0x85,
|
||||
"Direction": 0x86,
|
||||
"MotorProtection": 0x88,
|
||||
"SubdivisionInterpolation": 0x89,
|
||||
"BaudRate": 0x8A,
|
||||
"SlaveAddress": 0x8B,
|
||||
"SlaveRespond": 0x8C,
|
||||
"GoHomeParameters": 0x90,
|
||||
"GoHome": 0x91,
|
||||
"Default": 0x3F,
|
||||
}
|
||||
|
||||
|
||||
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 comando_get(parametro):
|
||||
function_code = 0xFA
|
||||
register = Parametros[parametro]
|
||||
command = bytearray([function_code, slave_address, register])
|
||||
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):
|
||||
# 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[0] == 0xFB:
|
||||
remetente = resposta[1]
|
||||
# Extrai o número de bytes de dados
|
||||
num_bytes = 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}, Valor: {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)
|
||||
|
||||
|
||||
try:
|
||||
#res = enviar_comando(comando_get("EncoderCarry"))
|
||||
com = [0xFA, 0x01, 0x30, 0x2B]
|
||||
com1 = [0xFA, 0x01, 0xFF, 0xC8]
|
||||
res = enviar_comando(com1)
|
||||
time.sleep(1)
|
||||
decifrar_resposta(res)
|
||||
except KeyboardInterrupt:
|
||||
print("Programa encerrado pelo usuário")
|
||||
finally:
|
||||
ser.close()
|
||||
Loading…
Reference in New Issue