Fixes in ReadFromSerialPort ---- UpdateUI
parent
ddfd4b4591
commit
98cddf6586
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.vs/AVS/v16/.suo
BIN
.vs/AVS/v16/.suo
Binary file not shown.
Binary file not shown.
BIN
.vs/AVS/v17/.suo
BIN
.vs/AVS/v17/.suo
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -275,7 +275,7 @@ namespace AVS
|
|||
this.btn_reset_port.TabIndex = 57;
|
||||
this.btn_reset_port.Text = "RESET PORT";
|
||||
this.btn_reset_port.UseVisualStyleBackColor = false;
|
||||
this.btn_reset_port.Visible = false;
|
||||
this.btn_reset_port.Visible = true;
|
||||
this.btn_reset_port.Click += new System.EventHandler(this.btn_reset_port_Click);
|
||||
//
|
||||
// openFileDialog1
|
||||
|
|
58
MainForm.cs
58
MainForm.cs
|
@ -51,6 +51,9 @@ namespace AVS
|
|||
[DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern bool SetupDiCallClassInstaller(uint InstallFunction, IntPtr deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData);
|
||||
|
||||
[DllImport("setupapi.dll")]
|
||||
static extern bool SetupDiDestroyDeviceInfoList(IntPtr deviceInfoSet);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class SP_DEVINFO_DATA
|
||||
{
|
||||
|
@ -1739,6 +1742,35 @@ namespace AVS
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pb_red.Visible = false; // Hide red indicator
|
||||
pb_blue.Visible = true; // Show blue indicator for data received
|
||||
|
||||
// Match weight pattern in message (e.g., "123.45 kg")
|
||||
Match match = Regex.Match(message, @"(\d+(\.\d+)?) kg");
|
||||
|
||||
if (match.Success && double.TryParse(match.Groups[1].Value, out double weight))
|
||||
{
|
||||
// Only update weight display if it has changed
|
||||
if (weight != PreviousWeight)
|
||||
{
|
||||
PreviousWeight = weight; // Update the previous weight
|
||||
txt_weight.Text = weight.ToString("0.000"); // Display the current weight
|
||||
}
|
||||
|
||||
// Update hold weight if above threshold
|
||||
if (weight > 0.020)
|
||||
{
|
||||
lbl_hold_weight.Text = weight.ToString("0.000"); // Display the hold weight
|
||||
}
|
||||
|
||||
message = "Machine connected";
|
||||
lbl_msg.ForeColor = Color.Green;
|
||||
lbl_msg.Text = message;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1763,6 +1795,7 @@ namespace AVS
|
|||
}
|
||||
}
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
private void HandleException(Exception ex)
|
||||
|
@ -1923,27 +1956,40 @@ namespace AVS
|
|||
}
|
||||
|
||||
// Disable a device by Instance ID
|
||||
|
||||
public static void DisableDevice(string deviceInstanceId)
|
||||
{
|
||||
|
||||
|
||||
IntPtr deviceInfoSet = SetupDiGetClassDevs(IntPtr.Zero, deviceInstanceId, IntPtr.Zero, DIGCF_PRESENT);
|
||||
if (deviceInfoSet == IntPtr.Zero)
|
||||
{
|
||||
Console.WriteLine("Error getting device info set.");
|
||||
return;
|
||||
throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to get device info set");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SP_DEVINFO_DATA deviceInfoData = new SP_DEVINFO_DATA();
|
||||
deviceInfoData.cbSize = (uint)Marshal.SizeOf(typeof(SP_DEVINFO_DATA));
|
||||
|
||||
uint index = 0;
|
||||
while (SetupDiEnumDeviceInfo(deviceInfoSet, index, ref deviceInfoData))
|
||||
for (uint index = 0; SetupDiEnumDeviceInfo(deviceInfoSet, index, ref deviceInfoData); index++)
|
||||
{
|
||||
Console.WriteLine($"Found device: {deviceInfoData.DevInst}");
|
||||
SetupDiCallClassInstaller(DIF_DISABLE, deviceInfoSet, ref deviceInfoData);
|
||||
if (!SetupDiCallClassInstaller(DIF_DISABLE, deviceInfoSet, ref deviceInfoData))
|
||||
{
|
||||
Console.WriteLine("Device disabled.");
|
||||
break; // Stop after disabling the first matching device
|
||||
}
|
||||
Console.WriteLine("No matching device found.");
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Failed to disable device.");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
SetupDiDestroyDeviceInfoList(deviceInfoSet);
|
||||
}
|
||||
}
|
||||
public static string GetDeviceInstanceIdFromCOMPort(string portName)
|
||||
{
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -94,7 +94,8 @@
|
|||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48"
|
||||
"net48",
|
||||
"net481"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
|
@ -106,7 +107,7 @@
|
|||
"privateAssets": "none"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.416\\RuntimeIdentifierGraph.json"
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.403\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,13 @@
|
|||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\muhammad.faique\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files (x86)\Microsoft\Xamarin\NuGet\</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.11.6</NuGetToolVersion>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.7.0</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="C:\Users\muhammad.faique\.nuget\packages\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
|
||||
<SourceRoot Include="C:\Program Files (x86)\Microsoft\Xamarin\NuGet\" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<Import Project="$(NuGetPackageRoot)entityframework\6.4.4\buildTransitive\netcoreapp3.0\EntityFramework.props" Condition="Exists('$(NuGetPackageRoot)entityframework\6.4.4\buildTransitive\netcoreapp3.0\EntityFramework.props')" />
|
||||
</ImportGroup>
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
||||
</PropertyGroup>
|
||||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<Import Project="$(NuGetPackageRoot)system.text.encodings.web\7.0.0\buildTransitive\netcoreapp2.0\System.Text.Encodings.Web.targets" Condition="Exists('$(NuGetPackageRoot)system.text.encodings.web\7.0.0\buildTransitive\netcoreapp2.0\System.Text.Encodings.Web.targets')" />
|
||||
<Import Project="$(NuGetPackageRoot)system.text.json\7.0.1\buildTransitive\netcoreapp2.0\System.Text.Json.targets" Condition="Exists('$(NuGetPackageRoot)system.text.json\7.0.1\buildTransitive\netcoreapp2.0\System.Text.Json.targets')" />
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
is_global = true
|
||||
build_property.ApplicationManifest =
|
||||
build_property.StartupObject =
|
||||
build_property.ApplicationDefaultFont =
|
||||
build_property.ApplicationHighDpiMode =
|
||||
build_property.ApplicationUseCompatibleTextRendering =
|
||||
build_property.ApplicationVisualStyles =
|
||||
build_property.RootNamespace = AVS
|
||||
build_property.ProjectDir = D:\Projects\AVS\
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "ruBmURm9Q/B7dlNWTusRQQ/R+5RZgbQgksj//5+Zk8qcXJ14BCeK0BmvogYuoAuZoYXCQn3liiFiW6YFILdXUg==",
|
||||
"dgSpecHash": "QNbNTGu+h1/KOiKWOwagV0AD91N3ZDiiXBDwzgQZ492TlU57m4gvbddfIzuVmuKTrrxSf/B1N8DKBvqOKZCKaA==",
|
||||
"success": true,
|
||||
"projectFilePath": "D:\\Projects\\AVS\\AVS.csproj",
|
||||
"expectedPackageFiles": [
|
||||
|
@ -146,7 +146,7 @@
|
|||
"code": "NU1701",
|
||||
"level": "Warning",
|
||||
"warningLevel": 1,
|
||||
"message": "Package 'MaterialSkin 0.2.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.",
|
||||
"message": "Package 'MaterialSkin 0.2.1' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.",
|
||||
"libraryId": "MaterialSkin",
|
||||
"targetGraphs": [
|
||||
".NETCoreApp,Version=v3.1"
|
||||
|
|
Loading…
Reference in New Issue