1.新增触发动作

2.去掉功率部分
3.调整部分UI
master
zhangxy 2 weeks ago
parent f55f6d5e16
commit 6f52dd8a1d

@ -6,7 +6,7 @@
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:SocketExample"
mc:Ignorable="d"
Title="RFID读写器多终端监控软件v1.031" Height="450" Width="800">
Title="RFID读写器多终端监控软件v1.041" Height="450" Width="800">
<Window.Resources>
<Style x:Key="SocketButton" TargetType="Button" BasedOn="{StaticResource BaseButtonStyle}">
@ -50,11 +50,12 @@
</Setter>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<Border>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="10" Height="30">
<TextBlock Text="监控终端生成数量:" VerticalAlignment="Center" Margin="0,0,10,0"/>
@ -62,126 +63,136 @@
<Button Content="生成" Click="GenerateButton_Click" Width="50" Margin="10 0 0 0" Style="{StaticResource SocketButton}"/>
<Button Content="清空" Click="ClearButton_Click" Width="50" Margin="10 0 0 0" Style="{StaticResource SocketButton}"/>
</StackPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<ItemsControl x:Name="PanelContainer">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"></WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
<ItemsControl x:Name="PanelContainer">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"></WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderThickness="1" BorderBrush="Black" Margin="1">
<StackPanel Orientation="Vertical" Margin="5 5 5 5" Width="360" >
<Border Width="Auto" Background="LightSkyBlue" >
<TextBlock Width="Auto" Text="{Binding Text}"></TextBlock>
<TextBox Width="Auto" Foreground="Black" Background="LightSkyBlue" Text="{Binding Text}" FontSize="14"></TextBox>
</Border>
<StackPanel Orientation="Horizontal" Width="360">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="IP地址" Height="30" Margin="10 8 0 0"/>
<TextBox TextWrapping="Wrap" x:Name="IPtextbox" Text="{Binding IPtext}" Width="100" Height="20" Margin="5 8 0 0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="端口号" Height="30" Margin="10 8 0 0"/>
<TextBox TextWrapping="Wrap" Text="{Binding Porttext}" x:Name="Porttextbox" Width="45" Height="20" Margin="5 8 0 0"/>
<Button Content="读取" Height="20" Width="40" Margin="10 8 0 0" Command="{Binding _readcomn}" Style="{StaticResource SocketButton}"/>
<StackPanel Orientation="Horizontal" Width="360">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="IP地址" Height="30" Margin="10 8 0 0"/>
<TextBox TextWrapping="Wrap" x:Name="IPtextbox" Text="{Binding IPtext}" Width="100" Height="20" Margin="5 8 0 0"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="端口号" Height="30" Margin="10 8 0 0"/>
<TextBox TextWrapping="Wrap" Text="{Binding Porttext}" x:Name="Porttextbox" Width="45" Height="20" Margin="5 8 0 0"/>
<!-- <Button Content="读取" Height="20" Width="40" Margin="10 8 0 0" Command="{Binding _readcomn}" Style="{StaticResource SocketButton}"/>-->
</StackPanel>
</StackPanel>
<Ellipse Width="20" Height="20" Fill="{Binding StateColour}" Margin="8 8 0 0"/>
<Label Height="30" Content="{Binding LinkState}" Margin="2 8 0 0"></Label>
<Button Content="连接" Height="30" Margin="10 8 0 0" Command="{Binding _linkcomn}" Style="{StaticResource SocketButton}"/>
<Button Content="清空" Height="30" Margin="10 8 0 0" Command="{Binding _clearcomn}" Style="{StaticResource SocketButton}"/>
<Button Content="断开" Height="30" Margin="10 8 10 0" Command="{Binding _disconnectcomn}" Style="{StaticResource SocketButton}"/>
</StackPanel>
<Ellipse Width="20" Height="20" Fill="{Binding StateColour}" Margin="20 8 0 0"/>
<Label Height="30" Content="{Binding LinkState}" Margin="2 8 0 0"></Label>
<Button Content="连接" Height="30" Margin="10 8 0 0" Command="{Binding _linkcomn}" Style="{StaticResource SocketButton}"/>
<Button Content="清空" Height="30" Margin="10 8 0 0" Command="{Binding _clearcomn}" Style="{StaticResource SocketButton}"/>
<Button Content="断开" Height="30" Margin="10 8 10 0" Command="{Binding _disconnectcomn}" Style="{StaticResource SocketButton}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Width="370" Margin="0,5,0,5" Height="100">
<StackPanel Orientation="Horizontal" Width="370" Margin="0,1,0,5" Height="100">
<Border Height="Auto" Width="200" BorderBrush="Black" BorderThickness="1" Margin="5,5,10,0" >
<ScrollViewer x:Name="TextScrollViewer" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
<TextBox x:Name="InfoTextBlock_Client" TextWrapping="Wrap" BorderThickness="0" IsReadOnly="True" Text="{Binding Infotext}" Height="Auto" Width="Auto">
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction
Command="{Binding TextChangedCommand}"
CommandParameter="{Binding ElementName=TextScrollViewer}"
/>
</i:EventTrigger>
</i:Interaction.Triggers>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
</ScrollViewer>
</ScrollViewer>
</Border>
<StackPanel Orientation="Vertical" Margin="0,5,0,0" Width="130">
<TextBlock Text="请输入需要发送的内容:"></TextBlock>
<StackPanel Orientation="Horizontal">
<TextBox TextWrapping="Wrap" x:Name="MessageTextBox_Client" Text="{Binding MessageText}" Height="50" Width="110" Margin="0,0,0,5"/>
<ComboBox x:Name="TextComboBox" Width="20" Height="20" ItemsSource="{Binding SendTextComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SendTextChangedCommand}"
CommandParameter="{Binding ElementName=TextComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<TextBox TextWrapping="Wrap" x:Name="MessageTextBox_Client" Text="{Binding MessageText}" Height="50" Width="130" Margin="0,0,0,5"/>
<Button Content="发送" Width="40" Command="{Binding _sendcomn}" Style="{StaticResource SocketButton}"/>
</StackPanel>
<Button Content="发送" Width="50" HorizontalAlignment="Center" Command="{Binding _sendcomn}" Style="{StaticResource SocketButton}"/>
</StackPanel>
</StackPanel>
<Border BorderBrush="Black" BorderThickness="0.5">
<ScrollViewer VerticalScrollBarVisibility="Visible" Margin="0.5 0.1 0.5 0.1" Height="150">
<ItemsControl ItemsSource="{Binding TagItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"></WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" Margin="0.5 0 0.5 0">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Label Content="标签:"/>
<TextBlock Text="{Binding EPCinfo}" VerticalAlignment="Center"></TextBlock>
</StackPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Label Content="HEX:"/>
<TextBlock Text="{Binding EPCASC}" VerticalAlignment="Center"></TextBlock>
</StackPanel>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<Label Content="RSSI:"/>
<TextBlock Text="{Binding RSSIinfo}" VerticalAlignment="Center"/>
</StackPanel>
<Border BorderBrush="Black" BorderThickness="0.5">
<ScrollViewer VerticalScrollBarVisibility="Visible" Margin="0.5 0.1 0.5 0.1" Height="150">
<ItemsControl ItemsSource="{Binding TagItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"></WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" Margin="0.5 0 0.5 0">
<Grid Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Label Content="标签:"/>
<TextBlock Text="{Binding EPCinfo}" VerticalAlignment="Center"></TextBlock>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Label Content="Count:"/>
<TextBlock Text="{Binding Countinfo}" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Label Content="Time:"/>
<TextBlock Text="{Binding Timeinfo}" VerticalAlignment="Center"/>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Label Content="HEX:"/>
<TextBlock Text="{Binding EPCASC}" VerticalAlignment="Center"></TextBlock>
</StackPanel>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<Label Content="RSSI:"/>
<TextBlock Text="{Binding RSSIinfo}" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Label Content="Count:"/>
<TextBlock Text="{Binding Countinfo}" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Label Content="Time:"/>
<TextBlock Text="{Binding Timeinfo}" VerticalAlignment="Center"/>
</StackPanel>
</Grid>
</Grid>
</Grid>
</ScrollViewer>
</ScrollViewer>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
<!-- 功率部分,已备份,注释后不再生成该部分
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
<!--触发动作部分-->
<Border BorderBrush="Black" BorderThickness="0.5">
<StackPanel Orientation="Horizontal" Margin="1 2 1 2">
<Label Content="触发动作:" FontWeight="Bold" FontSize="13"/>
<TextBox Text="{Binding ActionType}" Width="70" TextAlignment="Center" FontSize="13"/>
<ComboBox x:Name="TextComboBox" Width="20" Height="20" ItemsSource="{Binding SendTextComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding SendTextChangedCommand}"
CommandParameter="{Binding ElementName=TextComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
<Label Content="时间段:" FontWeight="Bold" FontSize="13"/>
<TextBox Text="{Binding TimeOut}" Width="50" TextAlignment="Center" FontSize="13"/>
<Button Content="发送" Width="50" Margin="15 2 0 2" Command="{Binding _sendactioncomn}" Style="{StaticResource SocketButton}"/>
</StackPanel>
</Border>
<!-- 功率部分,已备份,注释后不再生成该部分
<Border BorderBrush="Black" BorderThickness="0.5">
<Grid Margin="0 0 0 0">
<Grid.RowDefinitions>
@ -306,151 +317,147 @@
</Grid>
</Border>
-->
<Border BorderBrush="Black" BorderThickness="0.5">
<Grid Margin="0 0 0 2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" HorizontalAlignment="Center" Content="GPIO状态" FontSize="14" FontWeight="Bold" FontStyle="Oblique"></Label>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<Label Content="GPO1" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO1}"></Label>
</Border>
<ComboBox x:Name="GPO1ComboBox" Width="20" Height="20" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
-->
<Border BorderBrush="Black" BorderThickness="0.5">
<Grid Margin="0 0 0 2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" HorizontalAlignment="Center" Content="GPIO状态" FontSize="14" FontWeight="Bold" FontStyle="Oblique"></Label>
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<Label Content="GPO1" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO1}"></Label>
</Border>
<ComboBox x:Name="GPO1ComboBox" Width="20" Height="20" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding GPOSelectionChangedCommand}"
CommandParameter="{Binding ElementName=GPO1ComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Label Content="GPO2" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO2}"></Label>
</Border>
<ComboBox x:Name="GPO2ComboBox" Width="20" Height="20" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Label Content="GPO2" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO2}"></Label>
</Border>
<ComboBox x:Name="GPO2ComboBox" Width="20" Height="20" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding GPOSelectionChangedCommand}"
CommandParameter="{Binding ElementName=GPO2ComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Label Content="GPO3" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO3}"></Label>
</Border>
<ComboBox x:Name="GPO3ComboBox" Width="20" Height="20" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Label Content="GPO3" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO3}"></Label>
</Border>
<ComboBox x:Name="GPO3ComboBox" Width="20" Height="20" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding GPOSelectionChangedCommand}"
CommandParameter="{Binding ElementName=GPO3ComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal">
<Label Content="GPO4" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO4}"></Label>
</Border>
<ComboBox x:Name="GPO4ComboBox" Width="20" Height="20" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal">
<Label Content="GPO4" HorizontalAlignment="Left"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPO4}"></Label>
</Border>
<ComboBox x:Name="GPO4ComboBox" Width="20" Height="20" ItemsSource="{Binding GPOComboBox,Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction
Command="{Binding GPOSelectionChangedCommand}"
CommandParameter="{Binding ElementName=GPO4ComboBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
</StackPanel>
</Grid>
<Grid Grid.Row="1" Margin="0 0 0 5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<Label Content="GPI1" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI1}"></Label>
</Border>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Label Content="GPI2" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI2}"></Label>
</Border>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Label Content="GPI3" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI3}"></Label>
</Border>
</StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal">
<Label Content="GPI4" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI4}"></Label>
</Border>
</StackPanel>
</Grid>
</Grid>
<Grid Grid.Row="1" Margin="0 0 0 5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<Label Content="GPI1" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI1}"></Label>
</Border>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Label Content="GPI2" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI2}"></Label>
</Border>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Label Content="GPI3" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI3}"></Label>
</Border>
</StackPanel>
<StackPanel Grid.Column="3" Orientation="Horizontal">
<Label Content="GPI4" HorizontalAlignment="Left" Margin="0 0 6 0"/>
<Border BorderBrush="Black" BorderThickness="0.5">
<Label Content="{Binding GPI4}"></Label>
</Border>
</StackPanel>
</Border>
<Border BorderBrush="Black" BorderThickness="0.5">
<Grid Margin="0 0 0 2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="版本信息" HorizontalAlignment="Center" FontSize="14" FontWeight="Bold" FontStyle="Oblique"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="模块型号:" HorizontalAlignment="Left" FontSize="14" />
<Label Grid.Column="1" Content="{Binding moduleInfo}"></Label>
<Label Grid.Column="2" Content="主板固件号:" HorizontalAlignment="Left" FontSize="14" />
<Label Grid.Column="3" Content="{Binding motherboardFirmware}"></Label>
</Grid>
</Grid>
</Grid>
</Border>
<Border BorderBrush="Black" BorderThickness="0.5">
<Grid Margin="0 0 0 2">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="版本信息" HorizontalAlignment="Center" FontSize="14" FontWeight="Bold" FontStyle="Oblique"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="模块型号:" HorizontalAlignment="Left" FontSize="14" />
<Label Grid.Column="1" Content="{Binding moduleInfo}"></Label>
<Label Grid.Column="2" Content="主板固件号:" HorizontalAlignment="Left" FontSize="14" />
<Label Grid.Column="3" Content="{Binding motherboardFirmware}"></Label>
</Grid>
</Grid>
</Border>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Border>
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Border>
</Window>

@ -12,6 +12,7 @@ using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -21,9 +22,11 @@ using System.Windows.Input;
using System.Windows.Markup;
using System.Xml;
using GalaSoft.MvvmLight.Command;
using Google.Protobuf.WellKnownTypes;
using K4os.Compression.LZ4.Streams.Abstractions;
using Mesnac.Log;
using Microsoft.Xaml.Behaviors.Core;
using Mysqlx.Crud;
using Org.BouncyCastle.Utilities.Encoders;
using TouchSocket.Core;
using TouchSocket.Sockets;
@ -70,6 +73,12 @@ namespace SocketExample
OnPropertyChanged(); // 通知 UI 更新
}
}
public string _actiontype;//触发动作
public string ActionType { get => _actiontype; set { _actiontype = value; OnPropertyChanged(); } }
public string _timeout;//时间段盘点
public string TimeOut { get => _timeout; set { _timeout = value; OnPropertyChanged(); } }
private string _rssiinfo;//RSSI强度
public string RSSIinfo { get => _rssiinfo; set { _rssiinfo = value; OnPropertyChanged(); } }
private string _countinfo;//count数值
@ -157,6 +166,10 @@ namespace SocketExample
public LinkCommand getpowercomn;//获取功率
public LinkCommand stopreadingcomn;//停止连续读取功能
public LinkCommand sendactioncomn;
public LinkCommand powerselectchanged;
Thread GPIOthread;
@ -168,7 +181,9 @@ namespace SocketExample
Text = $"客户端{index + 1}";
linkcomn = new LinkCommand(Button_Link);//绑定按钮的链接事件
readcomn = new LinkCommand(Button_Read);
stopreadingcomn = new LinkCommand(Button_StopReading);
sendcomn = new LinkCommand(Button_Click_Send);//绑定发送按钮的事件
sendactioncomn = new LinkCommand (Button_SendActionComn);
disconnectcomn = new LinkCommand(Button_disconnect);//绑定断连按钮的事件
clearcomn = new LinkCommand(Button_clear);//绑定清空按钮的事件
setpowercomn = new LinkCommand(Button_SetPower);
@ -181,7 +196,7 @@ namespace SocketExample
//页面初始化
int[] Powerdatasource = {5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33};
string[] GPOdatasource = {"高","低"};
string[] SendTextdatasource = { "读取"};
string[] SendTextdatasource = { "单次读取","时间段盘点"};
MessageText = string.Empty;
IPtext = "192.168.0.7";//默认IP
@ -211,6 +226,8 @@ namespace SocketExample
public LinkCommand _readcomn { get { return readcomn; } }
public LinkCommand _stopreadingcomn { get { return stopreadingcomn; } }
public LinkCommand _sendcomn { get { return sendcomn; } }
public LinkCommand _disconnectcomn { get { return disconnectcomn; } }
@ -218,6 +235,7 @@ namespace SocketExample
public LinkCommand _clearcomn { get { return clearcomn; } }
public LinkCommand _setpowercomn { get { return setpowercomn; } }
public LinkCommand _getpowercomn { get { return getpowercomn; } }
public LinkCommand _sendactioncomn { get { return sendactioncomn; } }
#endregion
#region socket事件
@ -250,12 +268,49 @@ namespace SocketExample
{
switch (commandState)
{
case "01":
try
{
byte[] newData = new byte[data.Length + 1];
Array.Copy(data, 0, newData, 0, 5); // 复制前半部分 // 插入新值
Array.Copy(data, 5, newData, 5, 4);
Array.Copy(data, 5, newData, 6, data.Length - 5);
Timeinfo = $"{currentTime} {time.Substring(0, 10)}";//获取时间
string NewDataString = BitConverter.ToString(newData).Replace("-", " ");
int startTemp = 33;
//Infotext += $"({currentTime})客户端接收到EPC信息\n{EPCASC}\n\n";
List<TagInfo> taglist = GetTagInfos(newData);
ObservableCollection<TagItem> items = new ObservableCollection<TagItem>();
for (int j = 0; j < taglist.Count; j++)
{
int TempLength = taglist[j].EPCstring.Length * 3 - 1;
EPCinfo = NewDataString.Substring(startTemp, TempLength);
items.Add(new TagItem(taglist[j].EPCstring, EPCinfo, taglist[j].RSSI.ToString(), taglist[j].Count.ToString(), Timeinfo));
startTemp += 16 + TempLength;
string year = DateTime.Now.ToString("yyyy-MM-dd");
EnsureFolderExists($"日志文件夹/{year}/{Text}");
path = $"日志文件夹/{year}/{Text}/" + path + Text + ".txt";
writeToTxt(path, $"EPC:{taglist[j].EPCstring}\nHEX:{EPCinfo}\nRSSI:{taglist[j].RSSI.ToString()} Count:{taglist[j].Count.ToString()} Time:{Timeinfo}\n____________________________");
path = "";
//LogService.Instance.Debug("");
}
TagItems = items;
}
catch (Exception ex)
{
Infotext += ex;
}
break;
case "02":
try
{
RSSIinfo = Convert.ToInt32(readStateString.Substring(14, 2), 16).ToString();//RSSI
Countinfo = Convert.ToInt32(readStateString.Substring(12, 2), 16).ToString();//Count
int TagNumber = Convert.ToInt32(readStateString.Substring(10,2),16);
Timeinfo = $"{currentTime} {time.Substring(0, 10)}";//获取时间
int startTemp = 33;
@ -425,6 +480,9 @@ namespace SocketExample
EPCASC = "###";
EPCinfo = "###";
Timeinfo = $" {currentTime}\n{time.Substring(0, 10)}";//获取时间
ObservableCollection<TagItem> items = new ObservableCollection<TagItem>();
items.Add(new TagItem(EPCASC, EPCinfo, RSSIinfo, Countinfo, Timeinfo));
TagItems = items;
break;
}
}
@ -469,7 +527,7 @@ namespace SocketExample
Thread.Sleep(500);
data = strToToHexByte("AA 55 02 02 03 E8 EB 0D");//获取1000ms内标签信息
data = strToToHexByte("AA 55 02 02 07 D0 D7 0D");//获取1000ms内标签信息
client.Send(data);
Thread.Sleep(1000);
@ -577,7 +635,7 @@ namespace SocketExample
{
try
{
byte[] data = strToToHexByte("AA 55 02 02 03 E8 EB 0D");//获取1000ms内标签信息
byte[] data = strToToHexByte("AA 55 02 02 07 D0 D7 0D");//获取2000ms内标签信息
client.Send(data);
}
catch (Exception ex) {
@ -586,6 +644,20 @@ namespace SocketExample
}
void Button_StopReading()
{
try
{
byte[] data = strToToHexByte("AA 55 02 12 00 00 10 0D");//停止连续盘点
client.Send(data);
}
catch (Exception ex)
{
Infotext += $"发送读取命令时出错: {ex.Message}\n";
}
}
void Button_SetPower()
{
@ -654,7 +726,51 @@ namespace SocketExample
Infotext += $"处理请求时出错: {ex.Message}\n";
}
}
void Button_SendActionComn()
{
try
{
string message = ActionType;
if (message == string.Empty || message == null)
{
MessageBox.Show("请选择触发动作!");
}
else
{
try
{
byte[] data = null;
switch (message)
{
case "单次读取":
ActionType = "单次读取";
data = strToToHexByte("AA 55 02 01 00 64 67 0D");//单次
break;
/*
case "连续读取":
ActionType = "连续读取";
data = strToToHexByte("AA 55 02 11 00 00 13 0D");//连续
break;
*/
case "时间段盘点":
ActionType = "时间段盘点";
data = strToToHexByte(CheckDuringTime());
break;
}
client.Send(data);
}
catch (Exception ex)
{
Infotext += ex.Message;
}
}
}
catch (Exception ex)
{
}
}
void Button_disconnect()
{
client.Close();//断开连接
@ -703,6 +819,7 @@ namespace SocketExample
break;
}
sender.SelectedItem = null;
}
catch(Exception ex)
{
@ -764,13 +881,26 @@ namespace SocketExample
string selcetion = sender.SelectedItem?.ToString();
try
{
//byte[] data = null;
switch (selcetion)
{
case "读取":
MessageText = "AA 55 02 02 03 E8 EB 0D";
case "单次读取":
ActionType = "单次读取";
//data = strToToHexByte("AA 55 02 01 00 64 67 0D");//单次
break;
/*
case "连续读取":
ActionType = "连续读取";
data = strToToHexByte("AA 55 02 11 00 00 13 0D");//连续
break;
*/
case "时间段盘点":
ActionType = "时间段盘点";
//data = strToToHexByte(CheckDuringTime());
break;
}
//client.Send(data);
sender.SelectedItem = null;
}
catch (Exception ex)
{
@ -778,6 +908,14 @@ namespace SocketExample
}
}
string CheckDuringTime()
{
string actionstring = "AA 55 02 02 ";
actionstring += Convert.ToInt32(TimeOut).ToString("X").PadLeft(4, '0').Insert(2, " ")+ " ";
actionstring += Convert.ToString(GetXor(strToToHexByte(actionstring), 2), 16) + " 0D";
return actionstring;
}
void SaveCommand()
{
byte[] confirmdata1 = strToToHexByte("AA 55 05 5F ");//保存命令

Loading…
Cancel
Save