Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hemei
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
hemei
Commits
80e25321
Commit
80e25321
authored
May 17, 2022
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 称重服务器寄存器原始地址查看
parent
3504da74
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
162 additions
and
8 deletions
+162
-8
AssemblyInfo.cs
...LY.Weight/FLY.Weight.UI.Server/Properties/AssemblyInfo.cs
+2
-2
WdDRList.xaml
Project.FLY.Weight/FLY.Weight.UI.Server/WdDRList.xaml
+35
-3
WdDRList.xaml.cs
Project.FLY.Weight/FLY.Weight.UI.Server/WdDRList.xaml.cs
+125
-3
No files found.
Project.FLY.Weight/FLY.Weight.UI.Server/Properties/AssemblyInfo.cs
View file @
80e25321
...
...
@@ -51,6 +51,6 @@ using System.Windows;
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.0.
1
.0")]
[assembly: AssemblyFileVersion("7.0.
1
.0")]
[assembly: AssemblyVersion("7.0.
2
.0")]
[assembly: AssemblyFileVersion("7.0.
2
.0")]
[assembly: Guid("AC4FFE57-FF42-4B4D-9E23-FF583D78187D")]
Project.FLY.Weight/FLY.Weight.UI.Server/WdDRList.xaml
View file @
80e25321
...
...
@@ -6,9 +6,41 @@
xmlns:local="clr-namespace:FLY.Weight.UI.Server"
mc:Ignorable="d"
Title="DRList" Height="450" Width="800">
<Window.Resources>
<Style TargetType="DataGridCell" x:Key="gridCellStyle">
<!--文字居中-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<!--被选中时,背景色改变-->
<Style.Triggers>
<Trigger Property="DataGridCell.IsSelected" Value="True">
<Setter Property="Background" Value="Gray" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<DataGrid x:Name="dataGrid" AutoGenerateColumns="True" IsReadOnly="True"/>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBox Text="{Binding SearchText}" MinWidth="200" Margin="2"/>
<Button Content="向下搜索" Padding="20,5" Margin="2" Click="btnSearchDownClick"/>
<Button Content="向上搜索" Padding="20,5" Margin="2" Click="btnSearchUpClick"/>
<TextBlock>
当前查找结果序号=<Run Text="{Binding SearchIndex,Mode=OneWay}"/>
</TextBlock>
</StackPanel>
<DataGrid Grid.Row="1" x:Name="dataGrid" AutoGenerateColumns="True" IsReadOnly="True"
AlternationCount ="5" AlternatingRowBackground="LightGray"
CellStyle="{StaticResource gridCellStyle}" CanUserSortColumns="False"/>
</Grid>
</Window>
Project.FLY.Weight/FLY.Weight.UI.Server/WdDRList.xaml.cs
View file @
80e25321
...
...
@@ -20,13 +20,17 @@ namespace FLY.Weight.UI.Server
/// <summary>
/// DRList.xaml 的交互逻辑
/// </summary>
public
partial
class
WdDRList
:
Window
public
partial
class
WdDRList
:
Window
,
INotifyPropertyChanged
{
ObservableCollection
<
DataToRegsView
>
dataToRegsViews
=
new
ObservableCollection
<
DataToRegsView
>();
Modbus
.
WithThread
.
ModbusMapper_Client
plc
;
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
WdDRList
()
{
InitializeComponent
();
}
public
void
Init
(
Modbus
.
WithThread
.
ModbusMapper_Client
plc
)
{
...
...
@@ -49,19 +53,23 @@ namespace FLY.Weight.UI.Server
dataToRegsViews
.
Add
(
new
DataToRegsView
()
{
Index
=
i
,
dr
=
dr
,
Addr
=
dr
.
addr
,
RegAddr
=
dr
.
regAddr
,
DataArea
=
dr
.
dataArea
,
OwnerName
=
dr
.
ownerName
,
IsNeedUpdate
=
dr
.
isNeedUpdate
,
PropertyName
=
dr
.
propertyName
,
Description
=
description
,
Value
=
dr
.
value
});
});
;
}
plc
.
PropertyChanged
+=
Plc_PropertyChanged
;
plc
.
NameDataChanged
+=
Plc_NameDataChanged
;
dataGrid
.
ItemsSource
=
dataToRegsViews
;
this
.
DataContext
=
this
;
}
private
void
Plc_NameDataChanged
(
object
sender
,
DataToRegs
dr
)
...
...
@@ -88,6 +96,113 @@ namespace FLY.Weight.UI.Server
}
}
}
public
int
SearchIndex
{
get
;
private
set
;
}
=
-
1
;
public
string
SearchText
{
get
;
set
;
}
private
void
btnSearchDownClick
(
object
sender
,
RoutedEventArgs
e
)
{
if
(
string
.
IsNullOrEmpty
(
SearchText
))
{
MessageBox
.
Show
(
"输入为空"
,
"异常"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Hand
);
return
;
}
int
newSearchIndex
=
-
1
;
for
(
int
i
=
SearchIndex
+
1
;
i
<
dataToRegsViews
.
Count
();
i
++)
{
if
(
dataToRegsViews
[
i
].
OwnerName
.
Contains
(
SearchText
))
{
//找到了
newSearchIndex
=
i
;
break
;
}
if
(
dataToRegsViews
[
i
].
PropertyName
.
Contains
(
SearchText
))
{
//找到了
newSearchIndex
=
i
;
break
;
}
if
(
dataToRegsViews
[
i
].
Description
.
Contains
(
SearchText
))
{
//找到了
newSearchIndex
=
i
;
break
;
}
if
(
dataToRegsViews
[
i
].
RegAddr
.
Contains
(
SearchText
))
{
//找到了
newSearchIndex
=
i
;
break
;
}
}
if
(
newSearchIndex
!=
-
1
)
{
SearchIndex
=
newSearchIndex
;
dataGrid
.
SelectedItem
=
dataToRegsViews
[
newSearchIndex
];
dataGrid
.
ScrollIntoView
(
dataGrid
.
SelectedItem
);
return
;
}
else
{
SearchIndex
=
-
1
;
MessageBox
.
Show
(
"不能找到更多"
,
"异常"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Hand
);
return
;
}
}
private
void
btnSearchUpClick
(
object
sender
,
RoutedEventArgs
e
)
{
if
(
string
.
IsNullOrEmpty
(
SearchText
))
{
MessageBox
.
Show
(
"输入为空"
,
"异常"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Hand
);
return
;
}
int
newSearchIndex
=
-
1
;
for
(
int
i
=
SearchIndex
-
1
;
i
>=
0
&&
i
<
dataToRegsViews
.
Count
();
i
--)
{
if
(
dataToRegsViews
[
i
].
OwnerName
.
Contains
(
SearchText
))
{
//找到了
newSearchIndex
=
i
;
break
;
}
if
(
dataToRegsViews
[
i
].
PropertyName
.
Contains
(
SearchText
))
{
//找到了
newSearchIndex
=
i
;
break
;
}
if
(
dataToRegsViews
[
i
].
Description
.
Contains
(
SearchText
))
{
//找到了
newSearchIndex
=
i
;
break
;
}
if
(
dataToRegsViews
[
i
].
RegAddr
.
Contains
(
SearchText
))
{
//找到了
newSearchIndex
=
i
;
break
;
}
}
if
(
newSearchIndex
!=
-
1
)
{
SearchIndex
=
newSearchIndex
;
dataGrid
.
SelectedItem
=
dataToRegsViews
[
newSearchIndex
];
return
;
}
else
{
SearchIndex
=
-
1
;
MessageBox
.
Show
(
"不能找到更多"
,
"异常"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Hand
);
return
;
}
}
}
/// <summary>
/// 数据映射的类;
...
...
@@ -96,6 +211,7 @@ namespace FLY.Weight.UI.Server
/// </summary>
public
class
DataToRegsView
:
INotifyPropertyChanged
{
public
int
Index
{
get
;
set
;
}
public
DataToRegs
dr
;
/// <summary>
/// 对应 PLC寄存器区 coil or register
...
...
@@ -103,10 +219,16 @@ namespace FLY.Weight.UI.Server
public
PLCAddressArea
DataArea
{
get
;
set
;
}
/// <summary>
/// PLC 首地址
/// PLC
寄存器
首地址
/// </summary>
public
int
Addr
{
get
;
set
;
}
/// <summary>
/// 寄存器 原始地址字符串
/// </summary>
public
string
RegAddr
{
get
;
set
;
}
public
string
OwnerName
{
get
;
set
;
}
/// <summary>
/// object 的 property 名称, 只能是 数字类型都是double, 剩下就是 bool
/// </summary>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment