1.增加手动自检功能,主页增加状态显示
This commit is contained in:
@ -14,6 +14,8 @@ using HandyControl.Tools.Extension;
|
||||
using 货架标准上位机.Views.Controls;
|
||||
using 货架标准上位机.Api;
|
||||
using WCS.Model;
|
||||
using System.Diagnostics;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace 货架标准上位机.ViewModel
|
||||
{
|
||||
@ -21,6 +23,23 @@ namespace 货架标准上位机.ViewModel
|
||||
{
|
||||
WarnInfoContainer WarnInfo = new WarnInfoContainer();//警告、错误等信息
|
||||
|
||||
public bool IsThisPageVisible = true;
|
||||
|
||||
public HomeViewModel()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (IsThisPageVisible)
|
||||
{
|
||||
RefreshUserControl();
|
||||
}
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#region 绑定
|
||||
private string textErr;
|
||||
/// <summary>
|
||||
@ -44,40 +63,43 @@ namespace 货架标准上位机.ViewModel
|
||||
WarnInfo.RemoveAll(WarnInfoType.AlwayWarn);
|
||||
}
|
||||
|
||||
public ICommand AddUserControlCommand { get => new DelegateCommand(AddUserControl); }
|
||||
public ICommand AddUserControlCommand { get => new DelegateCommand(RefreshUserControl); }
|
||||
public WrapPanel wrapPanel;
|
||||
public async void AddUserControl()
|
||||
public async void RefreshUserControl()
|
||||
{
|
||||
//var dia = Dialog.Show(new TextDialog());
|
||||
//try
|
||||
//{
|
||||
// var body = new GetShelfStatusRequest()
|
||||
// {
|
||||
// UserName = "xxx",
|
||||
// DeviceType = "WCS前端",
|
||||
// GroupNames = LocalFile.Config.GroupName,
|
||||
try
|
||||
{
|
||||
var body = new GetShelfStatusRequest()
|
||||
{
|
||||
UserName = "xxx",
|
||||
DeviceType = "WCS前端",
|
||||
GroupNames = LocalFile.Config.GroupName,
|
||||
};
|
||||
var Result = await ApiHelp.Post<GetShelfStatusResponse>([LocalFile.Config.ApiIpHost, "home/getShelfStatus"], body);
|
||||
if (Result != null && Result.Data?.Count > 0)
|
||||
{
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
wrapPanel.Children.Clear();
|
||||
Result.Data
|
||||
.ForEach(t =>
|
||||
{
|
||||
var shelf = new ShelfStatusControl(t.ShelfCode, t.CurentMode, "");
|
||||
wrapPanel.Children.Add(shelf);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
// };
|
||||
// var Result = await ApiHelp.Post<GetShelfStatusResponse>([LocalFile.Config.ApiIpHost, "home/getShelfStatus"], body);
|
||||
// if (Result != null && Result.Data?.Count > 0)
|
||||
// {
|
||||
// wrapPanel.Children.Clear();
|
||||
// Result.Data.ForEach(t =>
|
||||
// {
|
||||
// var shelf = new ShelfStatusControl(t.ShelfCode, t.CurentMode, t.GroupName);
|
||||
// wrapPanel.Children.Add(shelf);
|
||||
// });
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
// //dia.Close();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 页面加载时任务
|
||||
|
@ -8,10 +8,10 @@
|
||||
d:DesignHeight="200" d:DesignWidth="150">
|
||||
|
||||
<Border Name="border" Grid.Column="0" Margin="5" BorderThickness="1" Background="LightSkyBlue" BorderBrush="Black" CornerRadius="3">
|
||||
<StackPanel Margin="3">
|
||||
<TextBlock Name="txtShelfCode" HorizontalAlignment="Center"></TextBlock>
|
||||
<TextBlock Name="txtCurrentMode" HorizontalAlignment="Center"></TextBlock>
|
||||
<TextBlock Name="txtGroupName" HorizontalAlignment="Center"></TextBlock>
|
||||
<StackPanel Margin="25">
|
||||
<TextBlock Name="txtShelfCode" FontSize="20" HorizontalAlignment="Center"></TextBlock>
|
||||
<TextBlock Name="txtCurrentMode" FontSize="15" HorizontalAlignment="Center"></TextBlock>
|
||||
<TextBlock Name="txtOrderNumber" FontSize="15" HorizontalAlignment="Center"></TextBlock>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
@ -22,11 +22,11 @@ namespace 货架标准上位机.Views.Controls
|
||||
public partial class ShelfStatusControl : UserControl
|
||||
{
|
||||
|
||||
public ShelfStatusControl(string shelfCode, int currentMode, string groupName)
|
||||
public ShelfStatusControl(string shelfCode, int currentMode, string orderNumber)
|
||||
{
|
||||
InitializeComponent();
|
||||
txtShelfCode.Text = shelfCode;
|
||||
txtGroupName.Text = groupName;
|
||||
txtOrderNumber.Text = orderNumber;
|
||||
//待机模式 = 0,
|
||||
//入库模式 = 1,
|
||||
//出库模式 = 2,
|
||||
|
@ -8,13 +8,13 @@
|
||||
mc:Ignorable="d"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:pi="https://github.com/ping9719/wpfex"
|
||||
d:DesignHeight="737" d:DesignWidth="1192" LoadedVisibleFirst="loadFir">
|
||||
d:DesignHeight="737" d:DesignWidth="1192" LoadedVisibleFirst="loadFir" IsVisibleChanged="vis">
|
||||
<Border Margin="0" Background="AliceBlue" CornerRadius="3" Padding="0">
|
||||
<Grid>
|
||||
<Grid Height="737" VerticalAlignment="Top">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="7*"/>
|
||||
<RowDefinition Height="3*"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="4*"/>
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
<!--内容区-->
|
||||
<!--<Grid Grid.Row="0" Margin="5,5,5,0">-->
|
||||
@ -22,7 +22,6 @@
|
||||
<Border Grid.Row="0" Margin="5,5,5,0" BorderThickness="1" Background="White" BorderBrush="DodgerBlue" CornerRadius="3">
|
||||
<hc:ScrollViewer IsInertiaEnabled="True" hc:ScrollViewerAttach.AutoHide="False">
|
||||
<WrapPanel Name="shelfsWrapPanel">
|
||||
|
||||
</WrapPanel>
|
||||
</hc:ScrollViewer>
|
||||
</Border>
|
||||
@ -31,10 +30,10 @@
|
||||
<Border Grid.Row="1" Margin="5,5,5,5" BorderThickness="1" Background="White" BorderBrush="DodgerBlue" CornerRadius="3">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="4*"/>
|
||||
<!--<ColumnDefinition Width="4*"/>-->
|
||||
<ColumnDefinition Width="6*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!--报警-->
|
||||
<!--报警--><!--
|
||||
<GroupBox Grid.Column="0" Background="White" Padding="0" Style="{StaticResource GroupBoxTab}" Margin="5,5,5,5">
|
||||
<GroupBox.Header>
|
||||
<Grid Width="{Binding ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type GroupBox}}}">
|
||||
@ -43,20 +42,21 @@
|
||||
</Grid>
|
||||
</GroupBox.Header>
|
||||
<TextBox Style="{StaticResource TextBoxExtend.Multi}" IsReadOnly="True" Margin="-1" Text="{Binding TextErr}" Foreground="Tomato" hc:InfoElement.Placeholder="没有报警信息"></TextBox>
|
||||
</GroupBox>
|
||||
</GroupBox>-->
|
||||
<!--日志-->
|
||||
<GroupBox Grid.Column="1" Background="White" Padding="0" Style="{StaticResource GroupBoxTab}" Margin="0,5,5,5" >
|
||||
<GroupBox Grid.Column="1" Background="White" Padding="0" Style="{StaticResource GroupBoxTab}" >
|
||||
<GroupBox.Header>
|
||||
<Grid Width="{Binding ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type GroupBox}}}">
|
||||
<TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center">日志</TextBlock>
|
||||
<Button Grid.Row="2" Command="{Binding AddUserControlCommand}" Background="AliceBlue" Content="手动自检"></Button>
|
||||
<Button HorizontalAlignment="Right" Height="25" Margin="10,0" Padding="10,0" FontFamily="{StaticResource IconFont}" Command="{Binding ClearTextInfoCommand}"> 清空</Button>
|
||||
</Grid>
|
||||
</GroupBox.Header>
|
||||
<pi:TextBoxLog Token="123" Style="{StaticResource TextBoxExtend.Multi}" Margin="-1" hc:InfoElement.Placeholder="没有日志信息" Foreground="CornflowerBlue"></pi:TextBoxLog>
|
||||
<pi:TextBoxLog Token="selfCheck" Style="{StaticResource TextBoxExtend.Multi}" Margin="-1" hc:InfoElement.Placeholder="没有日志信息" Foreground="CornflowerBlue"></pi:TextBoxLog>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</Border>
|
||||
<Button Grid.Row="2" Command="{Binding AddUserControlCommand}" Content="点击添加控件"></Button>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</pi:UserControlBase>
|
||||
|
@ -24,7 +24,7 @@ namespace 货架标准上位机
|
||||
/// </summary>
|
||||
public partial class HomeView : UserControlBase
|
||||
{
|
||||
HomeViewModel viewModel = new HomeViewModel();
|
||||
public static HomeViewModel viewModel = new HomeViewModel();
|
||||
|
||||
public HomeView()
|
||||
{
|
||||
@ -40,5 +40,12 @@ namespace 货架标准上位机
|
||||
|
||||
viewModel.LoadTask();
|
||||
}
|
||||
private void vis(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (IsInDesignMode)
|
||||
return;
|
||||
|
||||
viewModel.IsThisPageVisible = (bool)e.NewValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,10 @@
|
||||
<!--<Button Grid.Column="1" Visibility="{Binding IsClose,Converter={StaticResource Boolean2VisibilityHiddenConverter}}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource CloseGeometry}" Click="closeClick"/>-->
|
||||
</Grid>
|
||||
<TextBlock Margin="5,0" Grid.Row="1" Text="{Binding Content, FallbackValue=我是内容}" Foreground="Red" FontSize="18" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<hc:UniformSpacingPanel x:Name="spacingPanel" Grid.Row="2" Margin="5,0,5,10" Spacing="10" Width="auto" ChildWrapping="Wrap" HorizontalAlignment="Center">
|
||||
<Button Content="确认"/>
|
||||
<Button Content="忽略"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<StackPanel Orientation="Horizontal" x:Name="spacingPanel" Grid.Row="2" Margin="5,0,5,10" Width="auto" HorizontalAlignment="Center">
|
||||
<Button Margin="10 0 10 0" Content="确认"/>
|
||||
<Button Margin="10 0 10 0" Content="忽略"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</hc:Window>
|
||||
|
@ -66,18 +66,6 @@ namespace 货架标准上位机
|
||||
return Show(content, title, new string[] { "确认", "忽略" }, _warning, isVisCloseBut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="buttons">按钮内容</param>
|
||||
/// <param name="isVisCloseBut">界面右上角是否显示关闭按钮</param>
|
||||
/// <returns>点击的按钮文本</returns>
|
||||
public static WarningWindow Show(string content, IEnumerable<string> buttons, WebSocketMessageModel _warning, bool isVisCloseBut = true, Window owner = null)
|
||||
{
|
||||
return Show(content, string.Empty, buttons, _warning, isVisCloseBut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框
|
||||
/// </summary>
|
||||
@ -103,6 +91,7 @@ namespace 货架标准上位机
|
||||
{
|
||||
Content = item,
|
||||
};
|
||||
button.Margin = new Thickness(10, 0, 10, 0);
|
||||
button.Click += (s, e) =>
|
||||
{
|
||||
clikename = ((Button)s).Content.ToString();
|
||||
|
@ -141,6 +141,10 @@ namespace 货架标准上位机
|
||||
scanner.ScannerDisplayControl.RefreshValues(string.Empty, string.Empty);
|
||||
}
|
||||
break;
|
||||
case WarningTypeEnum.通知自检进度:
|
||||
TextBoxLog.AddLog(warning.WarningMessage, "selfCheck", DateTime.Now);
|
||||
client.Send(e.DataFrame.ToText());
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
return;
|
||||
|
Reference in New Issue
Block a user