This commit is contained in:
xyy
2026-04-20 14:03:34 +08:00
parent 83c9d27c37
commit dc197701ab
5 changed files with 45 additions and 6 deletions

View File

@@ -114,7 +114,8 @@ namespace EmptyLoadTest
try try
{ {
string plcIp = "192.168.1.10"; //string plcIp = "192.168.1.10";
string plcIp = "127.0.0.1";
bool initSuccess = ModbusResourceManager.Instance.Init(plcIp, 502); bool initSuccess = ModbusResourceManager.Instance.Init(plcIp, 502);
if (!initSuccess) if (!initSuccess)
{ {

View File

@@ -219,6 +219,7 @@
<MenuItem Header="测试" Style="{StaticResource MenuItemStyle}"> <MenuItem Header="测试" Style="{StaticResource MenuItemStyle}">
<MenuItem Header="空载测试" Style="{StaticResource MenuItemStyle}"/> <MenuItem Header="空载测试" Style="{StaticResource MenuItemStyle}"/>
<MenuItem Header="负载测试" Style="{StaticResource MenuItemStyle}" Click="LoadTestMenuItem_Click"/> <MenuItem Header="负载测试" Style="{StaticResource MenuItemStyle}" Click="LoadTestMenuItem_Click"/>
<MenuItem Header="跳动测试" Style="{StaticResource MenuItemStyle}" Click="JumpingTest_Click"/>
<MenuItem Header="报表" Style="{StaticResource MenuItemStyle}" Click="ReportMenuItem_Click"/> <MenuItem Header="报表" Style="{StaticResource MenuItemStyle}" Click="ReportMenuItem_Click"/>
</MenuItem> </MenuItem>
@@ -341,7 +342,8 @@
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 按钮区域 --><!-- <!-- 按钮区域 -->
<!--
<StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1" <StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1"
HorizontalAlignment="Center" Margin="0,300,0,0" Cursor=""> HorizontalAlignment="Center" Margin="0,300,0,0" Cursor="">
<Button Content="开始" Style="{StaticResource StartButtonStyle}" Click="Button_Click_1"/> <Button Content="开始" Style="{StaticResource StartButtonStyle}" Click="Button_Click_1"/>

View File

@@ -1,4 +1,5 @@
using Modbus.Device; using Modbus.Device;
using P_RTU_TEST_WinForm;
using System.Configuration; using System.Configuration;
using System.Net.Http; using System.Net.Http;
using System.Net.Sockets; using System.Net.Sockets;
@@ -64,7 +65,8 @@ namespace EmptyLoadTest
try try
{ {
string plcIp = "192.168.1.10"; //string plcIp = "192.168.1.10";
string plcIp = "127.0.0.1";
bool initSuccess = ModbusResourceManager.Instance.Init(plcIp, 502); bool initSuccess = ModbusResourceManager.Instance.Init(plcIp, 502);
if (!initSuccess) if (!initSuccess)
{ {
@@ -468,5 +470,27 @@ namespace EmptyLoadTest
Close(); Close();
} }
private void JumpingTest_Click(object sender, RoutedEventArgs e)
{
// WPF 跳转到 WinForm 窗口
var mainWindow = MainForm.Instance;
// WinForm 用IsHandleCreated 替代 IsVisible
if (!mainWindow.IsHandleCreated)
{
// 关键WinForm 窗口必须用 Show() 不能用 ShowDialog()
mainWindow.Show();
}
else
{
mainWindow.Activate();
}
// this.Close();
}
} }
} }

View File

@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>False</GenerateTargetFrameworkAttribute>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
@@ -25,4 +27,8 @@
<PackageReference Include="System.IO.Ports" Version="10.0.1" /> <PackageReference Include="System.IO.Ports" Version="10.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="ModbusDemo4CS\ModbusDemo4CS.csproj" />
</ItemGroup>
</Project> </Project>

View File

@@ -1,10 +1,12 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 18
VisualStudioVersion = 17.14.36327.8 d17.14 VisualStudioVersion = 18.2.11408.102 d18.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "医用刨削器特征新版8", "医用刨削器特征新版8.csproj", "{B0C9D63D-2C43-43F4-8273-273BCC58C3AE}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "医用刨削器特征新版8", "医用刨削器特征新版8.csproj", "{B0C9D63D-2C43-43F4-8273-273BCC58C3AE}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModbusDemo4CS", "ModbusDemo4CS\ModbusDemo4CS.csproj", "{7401784B-5723-4579-B056-A6F23EC80C9A}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
{B0C9D63D-2C43-43F4-8273-273BCC58C3AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {B0C9D63D-2C43-43F4-8273-273BCC58C3AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0C9D63D-2C43-43F4-8273-273BCC58C3AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {B0C9D63D-2C43-43F4-8273-273BCC58C3AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0C9D63D-2C43-43F4-8273-273BCC58C3AE}.Release|Any CPU.Build.0 = Release|Any CPU {B0C9D63D-2C43-43F4-8273-273BCC58C3AE}.Release|Any CPU.Build.0 = Release|Any CPU
{7401784B-5723-4579-B056-A6F23EC80C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7401784B-5723-4579-B056-A6F23EC80C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7401784B-5723-4579-B056-A6F23EC80C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7401784B-5723-4579-B056-A6F23EC80C9A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE