datasheet window wip

This commit is contained in:
nikzori
2024-12-05 17:52:25 +03:00
parent ca806a5009
commit 5716811f6f
5 changed files with 55 additions and 25 deletions

16
Datasheet.Designer.cs generated
View File

@@ -29,13 +29,27 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Datasheet));
this.listView1 = new System.Windows.Forms.ListView();
this.SuspendLayout();
//
// listView1
//
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listView1.HideSelection = false;
this.listView1.Location = new System.Drawing.Point(12, 137);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(716, 301);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// Datasheet
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(740, 450);
this.Controls.Add(this.listView1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Datasheet";
this.Text = "Datasheet";
@@ -44,5 +58,7 @@
}
#endregion
private System.Windows.Forms.ListView listView1;
}
}

View File

@@ -13,24 +13,30 @@ namespace Gidrolock_Modbus_Scanner
public partial class Datasheet : Form
{
int pollDelay = 250; // delay between each entry poll, ms
List<EntryUI> entries = new List<EntryUI>();
Device device = App.device;
public Datasheet()
{
InitializeComponent();
}
}
InitializeComponent();
listView1.AllowColumnReorder = true;
listView1.CheckBoxes = true;
listView1.FullRowSelect = true;
listView1.GridLines = true;
public class EntryUI : GroupBox
{
public Label Label_Name;
public Label Label_Value;
public ToolTip ToolTip;
public EntryUI(string name, string description, int address, string registerType, string dataType)
{
Label_Name.Text = name;
ToolTip.SetToolTip(this, description);
listView1.Columns.Add("#", -2, HorizontalAlignment.Left);
listView1.Columns.Add("Name", -2, HorizontalAlignment.Left);
listView1.Columns.Add("Value", -2, HorizontalAlignment.Left);
listView1.Columns.Add("Address", -2, HorizontalAlignment.Left);
for (int i = 0; i < device.entries.Count; i++)
{
ListViewItem item = new ListViewItem(i.ToString());
item.SubItems.Add(device.entries[i].name);
item.SubItems.Add(" ");
item.SubItems.Add(device.entries[i].address.ToString());
listView1.Items.Add(item);
}
}
}
}

View File

@@ -68,20 +68,27 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="json.cs" />
<Compile Include="Modbus.cs" />
<Compile Include="Form1.cs">
<Compile Include="Datasheet.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
<Compile Include="Datasheet.Designer.cs">
<DependentUpon>Datasheet.cs</DependentUpon>
</Compile>
<Compile Include="Json.cs" />
<Compile Include="Modbus.cs" />
<Compile Include="Main.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Main.Designer.cs">
<DependentUpon>Main.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Timeout.cs" />
<Compile Include="Tools.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
<EmbeddedResource Include="Datasheet.resx">
<DependentUpon>Datasheet.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Main.resx">
<DependentUpon>Main.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>

View File

@@ -40,5 +40,5 @@ namespace Gidrolock_Modbus_Scanner
this.readOnce = readOnce;
}
}
public enum RegisterType { Coil, DiscreteInput, HoldingRegister, InputRegister }
public enum RegisterType { Coil, Discrete, Holding, Input }
}

View File

@@ -214,6 +214,7 @@ namespace Gidrolock_Modbus_Scanner
{
AddLog("Попытка подключиться к устройству " + device.name);
Datasheet datasheet = new Datasheet();
datasheet.Show();
/*
if (Radio_SerialPort.Checked)
await SendMessageAsync(FunctionCode.InputRegister, 200, 6);