增加功能
This commit is contained in:
parent
ba6cb6e03b
commit
56429cdf7d
1
.idea/.idea.Seyounth.Hyosung/.idea/.name
generated
Normal file
1
.idea/.idea.Seyounth.Hyosung/.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
Seyounth.Hyosung
|
7
.idea/.idea.Seyounth.Hyosung/.idea/MarsCodeWorkspaceAppSettings.xml
generated
Normal file
7
.idea/.idea.Seyounth.Hyosung/.idea/MarsCodeWorkspaceAppSettings.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="com.codeverse.userSettings.MarscodeWorkspaceAppSettingsState">
|
||||||
|
<option name="ckgOperationStatus" value="SUCCESS" />
|
||||||
|
<option name="progress" value="0.96511626" />
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/.idea.Seyounth.Hyosung/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.Seyounth.Hyosung/.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -4,6 +4,7 @@ namespace Seyounth.Hyosung.Data.Models;
|
|||||||
|
|
||||||
public class Variety
|
public class Variety
|
||||||
{
|
{
|
||||||
|
public string Name => $"{Id} - {Code} - {StackingLayers}";
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string Code { get; set; }
|
public string Code { get; set; }
|
||||||
@ -87,7 +88,7 @@ public class Variety
|
|||||||
NeedFilmCoating = entity.NeedFilmCoating,
|
NeedFilmCoating = entity.NeedFilmCoating,
|
||||||
MasterLabelCount = entity.MasterLabelCount,
|
MasterLabelCount = entity.MasterLabelCount,
|
||||||
SubLabelCount = entity.SubLabelCount,
|
SubLabelCount = entity.SubLabelCount,
|
||||||
MiddlePallet = Pallet.FromEntity( pallets.First(x => x.Id == entity.MiddlePalletId)),
|
MiddlePallet = Pallet.FromEntity(pallets.First(x => x.Id == entity.MiddlePalletId)),
|
||||||
TopAndBottomPallet = Pallet.FromEntity(pallets.First(x => x.Id == entity.TopAndBottomPalletId)),
|
TopAndBottomPallet = Pallet.FromEntity(pallets.First(x => x.Id == entity.TopAndBottomPalletId)),
|
||||||
Tray = Pallet.FromEntity(pallets.First(x => x.Id == entity.TrayId)),
|
Tray = Pallet.FromEntity(pallets.First(x => x.Id == entity.TrayId)),
|
||||||
HasBox = entity.HasBox
|
HasBox = entity.HasBox
|
||||||
|
@ -16,6 +16,7 @@ public static class ServiceExtensions
|
|||||||
var connectionString = configuration.GetConnectionString("DefaultConnection");
|
var connectionString = configuration.GetConnectionString("DefaultConnection");
|
||||||
services.AddSingleton<ISqlSugarClient>(s =>
|
services.AddSingleton<ISqlSugarClient>(s =>
|
||||||
{
|
{
|
||||||
|
#if RELEASE
|
||||||
SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
|
SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
|
||||||
{
|
{
|
||||||
DbType = DbType.SqlServer,
|
DbType = DbType.SqlServer,
|
||||||
@ -23,6 +24,16 @@ public static class ServiceExtensions
|
|||||||
IsAutoCloseConnection = true,
|
IsAutoCloseConnection = true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
#elif DEBUG
|
||||||
|
SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
DbType = DbType.Sqlite,
|
||||||
|
ConnectionString = "Data Source=hyosung.db",
|
||||||
|
IsAutoCloseConnection = true,
|
||||||
|
InitKeyType = InitKeyType.Attribute
|
||||||
|
}
|
||||||
|
);
|
||||||
|
#endif
|
||||||
return sqlSugar;
|
return sqlSugar;
|
||||||
});
|
});
|
||||||
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
@ -36,7 +38,10 @@ public partial class App : Application
|
|||||||
builder.Services.AddSingleton<MainWindowViewModel>();
|
builder.Services.AddSingleton<MainWindowViewModel>();
|
||||||
builder.Services.AddSingleton<VarietyPage>();
|
builder.Services.AddSingleton<VarietyPage>();
|
||||||
builder.Services.AddSingleton<VarietyViewModel>();
|
builder.Services.AddSingleton<VarietyViewModel>();
|
||||||
|
builder.Services.AddSingleton<HomeViewPage>();
|
||||||
|
builder.Services.AddSingleton<HomeViewModel>();
|
||||||
builder.Services.AddHyosung(builder.Configuration);
|
builder.Services.AddHyosung(builder.Configuration);
|
||||||
|
|
||||||
_host = builder.Build();
|
_host = builder.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,10 +64,10 @@ public partial class App : Application
|
|||||||
{
|
{
|
||||||
_host.Services.UseHyosung();
|
_host.Services.UseHyosung();
|
||||||
_host.StartAsync();
|
_host.StartAsync();
|
||||||
}catch(Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
19
Seyounth.Hyosung/Models/StackModel.cs
Normal file
19
Seyounth.Hyosung/Models/StackModel.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using Seyounth.Hyosung.Data.Models;
|
||||||
|
|
||||||
|
namespace Seyounth.Hyosung.Models;
|
||||||
|
|
||||||
|
public class StackModel
|
||||||
|
{
|
||||||
|
public string TrayCode { get; set; } = "NoData";
|
||||||
|
|
||||||
|
public string VarietyCode { get; set; } = "NoData";
|
||||||
|
|
||||||
|
public int Layers { get; set; }
|
||||||
|
|
||||||
|
public int TotalCount { get; set; }
|
||||||
|
|
||||||
|
public int CurrentCount { get; set; }
|
||||||
|
|
||||||
|
public ObservableCollection<Yarn> Yarns { get; set; } = new();
|
||||||
|
}
|
32
Seyounth.Hyosung/ViewModels/HomeViewModel.cs
Normal file
32
Seyounth.Hyosung/ViewModels/HomeViewModel.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using Seyounth.Hyosung.Data.Models;
|
||||||
|
using Seyounth.Hyosung.Data.Services;
|
||||||
|
using Seyounth.Hyosung.Models;
|
||||||
|
|
||||||
|
namespace Seyounth.Hyosung.ViewModels;
|
||||||
|
|
||||||
|
public partial class HomeViewModel : ObservableObject
|
||||||
|
{
|
||||||
|
[ObservableProperty] private StackModel _stack1;
|
||||||
|
|
||||||
|
[ObservableProperty] private StackModel _stack2;
|
||||||
|
|
||||||
|
[ObservableProperty] private ObservableCollection<Variety> _varieties;
|
||||||
|
|
||||||
|
[ObservableProperty] private List<string> _yarnCarTypes;
|
||||||
|
|
||||||
|
[ObservableProperty] private Variety _selectedVariety;
|
||||||
|
|
||||||
|
public HomeViewModel(IVarietyService varietyService)
|
||||||
|
{
|
||||||
|
_stack1 = new StackModel();
|
||||||
|
_stack2 = new StackModel();
|
||||||
|
_yarnCarTypes = new List<string>();
|
||||||
|
_yarnCarTypes.Add("A");
|
||||||
|
_yarnCarTypes.Add("B");
|
||||||
|
_yarnCarTypes.Add("C");
|
||||||
|
_yarnCarTypes.Add("D");
|
||||||
|
_varieties = new ObservableCollection<Variety>(varietyService.GetAll());
|
||||||
|
}
|
||||||
|
}
|
@ -11,18 +11,9 @@ public partial class MainWindowViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
[ObservableProperty] private string _applicationTitle = "Hyosung - Seyounth Auto";
|
[ObservableProperty] private string _applicationTitle = "Hyosung - Seyounth Auto";
|
||||||
|
|
||||||
[ObservableProperty] private List<Variety> varieties;
|
|
||||||
|
|
||||||
[ObservableProperty] private List<string> yarnCar=new();
|
|
||||||
|
|
||||||
|
|
||||||
public MainWindowViewModel(IVarietyService varietyService)
|
public MainWindowViewModel(IVarietyService varietyService)
|
||||||
{
|
{
|
||||||
Varieties = varietyService.GetAll();
|
|
||||||
YarnCar.Add("A");
|
|
||||||
YarnCar.Add("B");
|
|
||||||
YarnCar.Add("C");
|
|
||||||
YarnCar.Add("D");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
|
@ -69,14 +69,8 @@
|
|||||||
Text="仪表盘" />
|
Text="仪表盘" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TabItem.Header>
|
</TabItem.Header>
|
||||||
<Grid>
|
<Frame Padding="16" HorizontalAlignment="Stretch"
|
||||||
<StackPanel Orientation="Horizontal">
|
VerticalAlignment="Stretch" x:Name="HomeFrame" />
|
||||||
<ComboBox Margin="20" MinWidth="150" x:Name="VarietyCombox" ItemsSource="{Binding ViewModel.Varieties}" DisplayMemberPath="Code"/>
|
|
||||||
<ComboBox Margin="20" MinWidth="80" x:Name="YarnCarCombox" ItemsSource="{Binding ViewModel.YarnCar}"/>
|
|
||||||
<Button Margin="20" Content="发送" Click="Button_Click"/>
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem x:Name="VarietyTabItem">
|
<TabItem x:Name="VarietyTabItem">
|
||||||
<TabItem.Header>
|
<TabItem.Header>
|
||||||
|
@ -14,22 +14,15 @@ public partial class MainWindow
|
|||||||
{
|
{
|
||||||
public MainWindowViewModel ViewModel { get; }
|
public MainWindowViewModel ViewModel { get; }
|
||||||
|
|
||||||
private readonly IHyosungRuntime hyosungRuntime;
|
|
||||||
|
|
||||||
public MainWindow(MainWindowViewModel viewModel, VarietyPage varietyPage,IHyosungRuntime hyosung)
|
public MainWindow(MainWindowViewModel viewModel,
|
||||||
|
VarietyPage varietyPage,
|
||||||
|
HomeViewPage homeViewPage)
|
||||||
{
|
{
|
||||||
ViewModel = viewModel;
|
ViewModel = viewModel;
|
||||||
DataContext = this;
|
DataContext = this;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
VarietyFrame.Content = varietyPage;
|
VarietyFrame.Content = varietyPage;
|
||||||
hyosungRuntime = hyosung;
|
HomeFrame.Content = homeViewPage;
|
||||||
}
|
|
||||||
|
|
||||||
private async void Button_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
var variety = VarietyCombox.SelectedItem as Variety;
|
|
||||||
variety.YarnCarSide = 1;
|
|
||||||
variety.YarnCarType = YarnCarCombox.SelectedIndex + 1;
|
|
||||||
await hyosungRuntime.SendVarietyToPlcAsync(variety);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,189 @@
|
|||||||
<Page x:Class="Seyounth.Hyosung.Views.Pages.HomeViewPage"
|
<Page x:Class="Seyounth.Hyosung.Views.Pages.HomeViewPage"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:Seyounth.Hyosung.Views.Pages"
|
xmlns:local="clr-namespace:Seyounth.Hyosung.Views.Pages"
|
||||||
mc:Ignorable="d"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
mc:Ignorable="d"
|
||||||
Title="HomeViewPage">
|
d:DesignHeight="800" d:DesignWidth="1500"
|
||||||
|
d:DataContext="{d:DesignInstance local:HomeViewPage,
|
||||||
|
IsDesignTimeCreatable=True}">
|
||||||
|
|
||||||
<Grid>
|
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<materialDesign:Card Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="16">
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<materialDesign:Card VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="16"
|
||||||
|
materialDesign:ElevationAssist.Elevation="Dp4">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<materialDesign:ColorZone>
|
||||||
|
<TextBlock Margin="10" Text="码垛工位1" VerticalAlignment="Center" HorizontalAlignment="Center"
|
||||||
|
FontSize="22" />
|
||||||
|
</materialDesign:ColorZone>
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||||
|
<TextBlock Foreground="White" Margin="10" FontSize="20" Text="托盘号:" />
|
||||||
|
<TextBox Foreground="#76ff03" IsEnabled="False" FontSize="20"
|
||||||
|
Text="{Binding ViewModel.Stack1.TrayCode}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<TextBlock Foreground="White" Margin="10" FontSize="20" Text="品类编号:" />
|
||||||
|
<TextBox Foreground="#76ff03" IsEnabled="False" FontSize="20"
|
||||||
|
Text="{Binding ViewModel.Stack1.VarietyCode}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<TextBlock Foreground="White" Margin="10" FontSize="20" Text="码垛层数:" />
|
||||||
|
<TextBox Foreground="#76ff03" IsEnabled="False" FontSize="20"
|
||||||
|
Text="{Binding ViewModel.Stack1.Layers}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<TextBlock Foreground="White" Margin="10" FontSize="20" Text="总数:" />
|
||||||
|
<TextBox Foreground="#76ff03" IsEnabled="False" FontSize="20"
|
||||||
|
Text="{Binding ViewModel.Stack1.TotalCount}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<TextBlock Foreground="White" Margin="10" FontSize="20" Text="当前:" />
|
||||||
|
<TextBox Foreground="#76ff03" IsEnabled="False" FontSize="20"
|
||||||
|
Text="{Binding ViewModel.Stack1.CurrentCount}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</StackPanel>
|
||||||
|
<GroupBox Margin="16" FontSize="20" Grid.Row="2" Header="纱信息">
|
||||||
|
<ListView
|
||||||
|
ItemsSource="{Binding ViewModel.Stack1.Yarns}">
|
||||||
|
<ListView.View>
|
||||||
|
<GridView>
|
||||||
|
<GridViewColumn
|
||||||
|
DisplayMemberBinding="{Binding }"
|
||||||
|
Header="序号" />
|
||||||
|
<GridViewColumn
|
||||||
|
DisplayMemberBinding="{Binding QrCode}"
|
||||||
|
Header="二维码" />
|
||||||
|
<GridViewColumn
|
||||||
|
DisplayMemberBinding="{Binding Lot}"
|
||||||
|
Header="Lot" />
|
||||||
|
<GridViewColumn
|
||||||
|
DisplayMemberBinding="{Binding StackTime}"
|
||||||
|
Header="码垛时间" />
|
||||||
|
</GridView>
|
||||||
|
</ListView.View>
|
||||||
|
</ListView>
|
||||||
|
</GroupBox>
|
||||||
|
</Grid>
|
||||||
|
</materialDesign:Card>
|
||||||
|
|
||||||
|
<materialDesign:Card Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
|
||||||
|
Margin="16"
|
||||||
|
materialDesign:ElevationAssist.Elevation="Dp4">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<materialDesign:ColorZone>
|
||||||
|
<TextBlock Margin="10" Text="码垛工位2" VerticalAlignment="Center" HorizontalAlignment="Center"
|
||||||
|
FontSize="22" />
|
||||||
|
</materialDesign:ColorZone>
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||||
|
<TextBlock Foreground="White" Margin="10" FontSize="20" Text="托盘号:" />
|
||||||
|
<TextBox Foreground="#76ff03" IsEnabled="False" FontSize="20"
|
||||||
|
Text="{Binding ViewModel.Stack2.TrayCode}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<TextBlock Foreground="White" Margin="10" FontSize="20" Text="品类编号:" />
|
||||||
|
<TextBox Foreground="#76ff03" IsEnabled="False" FontSize="20"
|
||||||
|
Text="{Binding ViewModel.Stack2.VarietyCode}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<TextBlock Foreground="White" Margin="10" FontSize="20" Text="码垛层数:" />
|
||||||
|
<TextBox Foreground="#76ff03" IsEnabled="False" FontSize="20"
|
||||||
|
Text="{Binding ViewModel.Stack2.Layers}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<TextBlock Foreground="White" Margin="10" FontSize="20" Text="总数:" />
|
||||||
|
<TextBox Foreground="#76ff03" IsEnabled="False" FontSize="20"
|
||||||
|
Text="{Binding ViewModel.Stack2.TotalCount}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<TextBlock Foreground="White" Margin="10" FontSize="20" Text="当前:" />
|
||||||
|
<TextBox Foreground="#76ff03" IsEnabled="False" FontSize="20"
|
||||||
|
Text="{Binding ViewModel.Stack2.CurrentCount}"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
</StackPanel>
|
||||||
|
<GroupBox Margin="16" FontSize="20" Grid.Row="2" Header="纱信息">
|
||||||
|
<ListView
|
||||||
|
ItemsSource="{Binding ViewModel.Stack2.Yarns}">
|
||||||
|
<ListView.View>
|
||||||
|
<GridView>
|
||||||
|
<GridViewColumn
|
||||||
|
DisplayMemberBinding="{Binding }"
|
||||||
|
Header="序号" />
|
||||||
|
<GridViewColumn
|
||||||
|
DisplayMemberBinding="{Binding QrCode}"
|
||||||
|
Header="二维码" />
|
||||||
|
<GridViewColumn
|
||||||
|
DisplayMemberBinding="{Binding Lot}"
|
||||||
|
Header="Lot" />
|
||||||
|
<GridViewColumn
|
||||||
|
DisplayMemberBinding="{Binding StackTime}"
|
||||||
|
Header="码垛时间" />
|
||||||
|
</GridView>
|
||||||
|
</ListView.View>
|
||||||
|
</ListView>
|
||||||
|
</GroupBox>
|
||||||
|
</Grid>
|
||||||
|
</materialDesign:Card>
|
||||||
|
</Grid>
|
||||||
|
</materialDesign:Card>
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||||
|
<GroupBox
|
||||||
|
Width="300"
|
||||||
|
Margin="16"
|
||||||
|
FontSize="22"
|
||||||
|
materialDesign:ElevationAssist.Elevation="Dp6"
|
||||||
|
Header="上料区执行标准"
|
||||||
|
Style="{StaticResource MaterialDesignCardGroupBox}">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock VerticalAlignment="Center" Margin="10"
|
||||||
|
Foreground="White" Grid.Row="0" Text="品类:" />
|
||||||
|
<ComboBox x:Name="VarietyComboBox" Grid.Column="1" Margin="10" Grid.Row="0"
|
||||||
|
ItemsSource="{Binding ViewModel.Varieties}"
|
||||||
|
SelectedItem="{Binding ViewModel.SelectedVariety, Mode=TwoWay}"
|
||||||
|
DisplayMemberPath="Name" />
|
||||||
|
<TextBlock VerticalAlignment="Center" Margin="10"
|
||||||
|
Foreground="White" Grid.Row="1" Grid.Column="0" Text="纱车类型:" />
|
||||||
|
<ComboBox x:Name="YarnCarTypeComboBox" Grid.Column="1" Margin="10" Grid.Row="1" IsEnabled="False"
|
||||||
|
ItemsSource="{Binding ViewModel.YarnCarTypes}" />
|
||||||
|
<TextBlock VerticalAlignment="Center" Margin="10"
|
||||||
|
Foreground="White" Grid.Row="2" Grid.Column="0" Text="码垛层数:" />
|
||||||
|
<TextBox Grid.Column="1" Margin="10" Grid.Row="2" IsEnabled="False"
|
||||||
|
Text="{Binding ViewModel.SelectedVariety.StackingLayers}" />
|
||||||
|
<TextBlock VerticalAlignment="Center" Margin="10"
|
||||||
|
Foreground="White" Grid.Row="3" Grid.Column="0" Text="总数:" />
|
||||||
|
<TextBox Grid.Column="1" Margin="10" Grid.Row="3" IsEnabled="False"
|
||||||
|
Text="{Binding ViewModel.SelectedVariety.TotalCount}" />
|
||||||
|
<Button x:Name="ChangeVarietyButton"
|
||||||
|
materialDesign:ButtonProgressAssist.IsIndeterminate="True"
|
||||||
|
Click="ChangeVarietyButton_OnClick"
|
||||||
|
Margin="20" Grid.Column="1" Grid.Row="4" FontSize="20" Content="切换">
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
@ -1,17 +1,9 @@
|
|||||||
using System;
|
using System.Windows;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Data;
|
using MaterialDesignThemes.Wpf;
|
||||||
using System.Windows.Documents;
|
using Seyounth.Hyosung.Data.Models;
|
||||||
using System.Windows.Input;
|
using Seyounth.Hyosung.Runtime;
|
||||||
using System.Windows.Media;
|
using Seyounth.Hyosung.ViewModels;
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace Seyounth.Hyosung.Views.Pages
|
namespace Seyounth.Hyosung.Views.Pages
|
||||||
{
|
{
|
||||||
@ -20,9 +12,47 @@ namespace Seyounth.Hyosung.Views.Pages
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class HomeViewPage : Page
|
public partial class HomeViewPage : Page
|
||||||
{
|
{
|
||||||
public HomeViewPage()
|
public HomeViewModel ViewModel { get; set; }
|
||||||
|
|
||||||
|
private readonly IHyosungRuntime _runtime;
|
||||||
|
|
||||||
|
public HomeViewPage(HomeViewModel viewModel, IHyosungRuntime runtime)
|
||||||
{
|
{
|
||||||
|
_runtime = runtime;
|
||||||
|
ViewModel = viewModel;
|
||||||
|
DataContext = this;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ChangeVarietyButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
var variety = VarietyComboBox.SelectedItem as Variety;
|
||||||
|
if (variety == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请选择要切换的品种");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChangeVarietyButton.Content = "切换中";
|
||||||
|
ButtonProgressAssist.SetIsIndicatorVisible(ChangeVarietyButton, true);
|
||||||
|
ChangeVarietyButton.IsEnabled = false;
|
||||||
|
|
||||||
|
variety.YarnCarSide = 1;
|
||||||
|
variety.YarnCarType = YarnCarTypeComboBox.SelectedIndex + 1;
|
||||||
|
_runtime.SendVarietyToPlcAsync(variety)
|
||||||
|
.ContinueWith(task =>
|
||||||
|
{
|
||||||
|
if (task.IsCompletedSuccessfully)
|
||||||
|
{
|
||||||
|
ChangeVarietyButton.Content = "切换";
|
||||||
|
ButtonProgressAssist.SetIsIndicatorVisible(ChangeVarietyButton, false);
|
||||||
|
ChangeVarietyButton.IsEnabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show(task.Exception?.Message, "切换失败");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user