Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement
This commit is contained in:
commit
1a0b10015c
10 files changed
+552
-6
No files matched your search
@@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
namespace SunlightCentralizedControlManagement_SCCM_.ConvertMoels
|
||||||
|
{
|
||||||
|
internal class BoolRBConvert : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
bool G =(Boolean) value;
|
||||||
|
// bool G = (bool)value;
|
||||||
|
if (!G)//判断单元格值是否为零
|
||||||
|
{
|
||||||
|
return "";//零返回
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "red";//非零返回红色
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
|
|
||||||
namespace DyeingComputer.ConvertMoels
|
namespace SunlightCentralizedControlManagement_SCCM_.ConvertMoels
|
||||||
{
|
{
|
||||||
internal class IORBConvert : IValueConverter
|
internal class IORBConvert : IValueConverter
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -91,7 +91,7 @@
|
|||||||
<TextBlock Text="{x:Static lang:Resources.Curve}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
<TextBlock Text="{x:Static lang:Resources.Curve}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ListViewItem>
|
</ListViewItem>
|
||||||
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_MouseLeftButtonUp">
|
<ListViewItem Height="60" MouseLeftButtonUp="ListViewItem_Machine">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<materialDesign:PackIcon Kind="Settings" Width="25" Height="25" Margin="10" VerticalAlignment="Center"/>
|
<materialDesign:PackIcon Kind="Settings" Width="25" Height="25" Margin="10" VerticalAlignment="Center"/>
|
||||||
<TextBlock Text="{x:Static lang:Resources.Machine}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
<TextBlock Text="{x:Static lang:Resources.Machine}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ namespace SunlightCentralizedControlManagement_SCCM_
|
|||||||
{
|
{
|
||||||
Picture.Content = new View.MonitorView();
|
Picture.Content = new View.MonitorView();
|
||||||
}
|
}
|
||||||
|
private void ListViewItem_Machine(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
Picture.Content = new View.MachinesView();
|
||||||
|
}
|
||||||
private void ListViewItem_Curve(object sender, MouseButtonEventArgs e)
|
private void ListViewItem_Curve(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
Picture.Content = new View.CurveView();
|
Picture.Content = new View.CurveView();
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="ConvertMoels\BoolRBConvert.cs" />
|
||||||
<Compile Include="UserClass\AsyncTcpClient.cs" />
|
<Compile Include="UserClass\AsyncTcpClient.cs" />
|
||||||
<Compile Include="UserClass\ClsLock.cs" />
|
<Compile Include="UserClass\ClsLock.cs" />
|
||||||
<Compile Include="UserClass\CRCcheck16.cs" />
|
<Compile Include="UserClass\CRCcheck16.cs" />
|
||||||
@@ -103,6 +104,9 @@
|
|||||||
<Compile Include="View\CurveDiagram.xaml.cs">
|
<Compile Include="View\CurveDiagram.xaml.cs">
|
||||||
<DependentUpon>CurveDiagram.xaml</DependentUpon>
|
<DependentUpon>CurveDiagram.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="View\MachinesView.xaml.cs">
|
||||||
|
<DependentUpon>MachinesView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="View\SYSSetView.xaml.cs">
|
<Compile Include="View\SYSSetView.xaml.cs">
|
||||||
<DependentUpon>SYSSetView.xaml</DependentUpon>
|
<DependentUpon>SYSSetView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -164,6 +168,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="View\MachinesView.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
<Page Include="View\SYSSetView.xaml">
|
<Page Include="View\SYSSetView.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
|||||||
@@ -171,8 +171,20 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
|
|||||||
else if (SYSAPI == "SC851")
|
else if (SYSAPI == "SC851")
|
||||||
{
|
{
|
||||||
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||||
DataTable obj = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
MainWindowViewModel.dt_d = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
||||||
}//数字开关表
|
}//数字开关表
|
||||||
|
else if (SYSAPI == "SC852")
|
||||||
|
{
|
||||||
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||||
|
MainWindowViewModel.dt_a = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
||||||
|
}//寄存器表
|
||||||
|
else if (SYSAPI == "SC853")
|
||||||
|
{
|
||||||
|
DAT = DAT.Substring(DAT.IndexOf("]") + 1);
|
||||||
|
MainWindowViewModel.dt_m = JsonConvert.DeserializeObject<DataTable>(DAT);//反序列化
|
||||||
|
}//缓存表
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return EasyTask.CompletedTask;
|
return EasyTask.CompletedTask;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,295 @@
|
|||||||
|
<UserControl x:Class="SunlightCentralizedControlManagement_SCCM_.View.MachinesView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
|
||||||
|
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
|
||||||
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
|
xmlns:ConvertMoels="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ConvertMoels"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Loaded="UserControl_Loaded"
|
||||||
|
d:DesignHeight="900" d:DesignWidth="1200">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<ConvertMoels:StateToColorConvert x:Key="StateToColorConvert"/>
|
||||||
|
<ConvertMoels:BoolRBConvert x:Key="BoolRBConvert"/>
|
||||||
|
<ConvertMoels:IORBConvert x:Key="IORBConvert"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="60"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<DataGrid Grid.Row="0" x:Name="Griddata" AlternationCount="2" IsReadOnly="True" d:ItemsSource="{d:SampleData ItemCount=999}"
|
||||||
|
Background="White"
|
||||||
|
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" FontSize="15"
|
||||||
|
Grid.ColumnSpan="2" CanUserResizeRows="False" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||||
|
CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility ="Column" SelectionMode="Single"
|
||||||
|
HorizontalAlignment="Left" Width="280" MouseDoubleClick="Griddata_MouseDoubleClick">
|
||||||
|
<DataGrid.RowStyle >
|
||||||
|
<Style TargetType="{x:Type DataGridRow}">
|
||||||
|
<Setter Property="Height" Value="30" />
|
||||||
|
<Setter Property="FontSize" Value="25" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
|
||||||
|
<Setter Property="Background" Value="#FFFFFFFF" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||||
|
<Setter Property="Background" Value="#FFF0F0F0" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsMouseOver" Value="False"/>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.RowStyle>
|
||||||
|
<DataGrid.CellStyle>
|
||||||
|
<Style TargetType="DataGridCell">
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="MinWidth" Value="20"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Background" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.CellStyle>
|
||||||
|
<DataGrid.Resources>
|
||||||
|
<Style x:Key="CellStyle" TargetType="{x:Type DataGridCell}">
|
||||||
|
<Setter Property="Focusable" Value="False"/>
|
||||||
|
<Setter Property="Background" Value="#FFFFFFFF"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#FFFFFFFF"/>
|
||||||
|
<Setter Property="Foreground" Value="#000000"/>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.Resources>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<!--列信息绑定-->
|
||||||
|
<DataGridTemplateColumn Width="70" Header="{x:Static lang:Resources.State}">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<materialDesign:PackIcon Kind="StateMachine" Width="25" Height="30" VerticalAlignment="Center" HorizontalAlignment="Center"
|
||||||
|
Foreground="{Binding Path=State,Converter={StaticResource StateToColorConvert}}"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Machine}" Binding="{Binding Name}" Width="210" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="{x:Static lang:Resources.Group}" Binding="{Binding Groups}" Width="0" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Binding="{Binding IP}" Width="0" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Binding="{Binding PORT}" Width="0" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Binding="{Binding Serial}" Width="0" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Binding="{Binding Baud}" Width="0" IsReadOnly="True"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
<Grid Grid.Row="0" Margin="280,0,0,0">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="5"/>
|
||||||
|
<RowDefinition/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<GridSplitter Grid.Row="1" Height="5" HorizontalAlignment="Stretch" Background="#FF00204E"/>
|
||||||
|
<Grid Grid.Row="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<DataGrid x:Name="Grid_D" AlternationCount="2" SelectionChanged="Grid_D_SelectionChanged"
|
||||||
|
CellEditEnding="Grid_D_CellEditEnding" BeginningEdit="Grid_D_BeginningEdit" d:ItemsSource="{d:SampleData ItemCount=512}"
|
||||||
|
Margin="0,0,0,0" ItemsSource="{Binding Path=SYSData_D,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||||
|
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
|
||||||
|
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" AllowDrop="False"
|
||||||
|
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||||
|
CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility ="Column" Grid.Column="0"
|
||||||
|
Background="White" SelectionMode="Single" FontSize="15" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
|
||||||
|
<DataGrid.RowStyle >
|
||||||
|
<Style TargetType="{x:Type DataGridRow}">
|
||||||
|
<Setter Property="Height" Value="30" />
|
||||||
|
<Setter Property="FontSize" Value="25" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
|
||||||
|
<Setter Property="Background" Value="#FFFFFFFF" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||||
|
<Setter Property="Background" Value="#FFF0F0F0" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsMouseOver" Value="False"/>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.RowStyle>
|
||||||
|
<DataGrid.CellStyle>
|
||||||
|
<Style TargetType="DataGridCell">
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="MinWidth" Value="20"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Background" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.CellStyle>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<!--列信息绑定-->
|
||||||
|
<DataGridTextColumn Header="DIO" Width="100" Binding="{Binding ID}" IsReadOnly="True">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="{x:Type TextBlock}">
|
||||||
|
<Setter Property="Foreground" Value="{Binding Path=type,Converter={StaticResource IORBConvert}}"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn Header="PLC" Width="100" Binding="{Binding PLC}">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="{x:Type TextBlock}">
|
||||||
|
<Setter Property="Foreground" Value="{Binding Path=type,Converter={StaticResource IORBConvert}}"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn Header="NAME" Width="*" Binding="{Binding IOName}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="info" Width="100" Binding="{Binding DIO}" IsReadOnly="True">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="{x:Type TextBlock}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding Path= DIO}" Value="False">
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding Path= DIO}" Value="True">
|
||||||
|
<Setter Property="Foreground" Value="Red"></Setter>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
<DataGrid x:Name="Grid_A" AlternationCount="2" SelectionChanged="Grid_A_SelectionChanged"
|
||||||
|
CellEditEnding="Grid_A_CellEditEnding" BeginningEdit="Grid_A_BeginningEdit" d:ItemsSource="{d:SampleData ItemCount=256}"
|
||||||
|
Margin="0,0,0,0" ItemsSource="{Binding Path=SYSData_A,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||||
|
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
|
||||||
|
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" AllowDrop="False"
|
||||||
|
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||||
|
CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility ="Column" Grid.Column="1"
|
||||||
|
Background="White" SelectionMode="Single" FontSize="15" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
|
||||||
|
<DataGrid.RowStyle >
|
||||||
|
<Style TargetType="{x:Type DataGridRow}">
|
||||||
|
<Setter Property="Height" Value="30" />
|
||||||
|
<Setter Property="FontSize" Value="25" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
|
||||||
|
<Setter Property="Background" Value="#FFFFFFFF" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||||
|
<Setter Property="Background" Value="#FFF0F0F0" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsMouseOver" Value="False"/>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.RowStyle>
|
||||||
|
<DataGrid.CellStyle>
|
||||||
|
<Style TargetType="DataGridCell">
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="MinWidth" Value="20"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Background" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.CellStyle>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<!--列信息绑定-->
|
||||||
|
<DataGridTextColumn Header="AIO" Width="100" Binding="{Binding ID}" IsReadOnly="True">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="{x:Type TextBlock}">
|
||||||
|
<Setter Property="Foreground" Value="{Binding Path=type,Converter={StaticResource IORBConvert}}"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn Header="PLC" Width="100" Binding="{Binding PLC}">
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="{x:Type TextBlock}">
|
||||||
|
<Setter Property="Foreground" Value="{Binding Path=type,Converter={StaticResource IORBConvert}}"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn Header="NAME" Width="*" Binding="{Binding IOName}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="info" Width="100" Binding="{Binding AIO}" IsReadOnly="True"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
<DataGrid x:Name="Grid_M" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_M_SelectionChanged" d:ItemsSource="{d:SampleData ItemCount=200}"
|
||||||
|
Margin="0,0,0,0" ItemsSource="{Binding Path=SYSData_M,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||||
|
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
|
||||||
|
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" AllowDrop="False"
|
||||||
|
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||||
|
CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility ="Column" Grid.Column="3"
|
||||||
|
Background="White" SelectionMode="Single" FontSize="15" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
|
||||||
|
<DataGrid.RowStyle >
|
||||||
|
<Style TargetType="{x:Type DataGridRow}">
|
||||||
|
<Setter Property="Height" Value="30" />
|
||||||
|
<Setter Property="FontSize" Value="25" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
|
||||||
|
<Setter Property="Background" Value="#FFFFFFFF" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||||
|
<Setter Property="Background" Value="#FFF0F0F0" />
|
||||||
|
</Trigger>
|
||||||
|
<Trigger Property="IsMouseOver" Value="False"/>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.RowStyle>
|
||||||
|
<DataGrid.CellStyle>
|
||||||
|
<Style TargetType="DataGridCell">
|
||||||
|
<Setter Property="BorderThickness" Value="0"/>
|
||||||
|
<Setter Property="MinWidth" Value="20"/>
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Background" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
|
||||||
|
<Setter Property="Foreground" Value="Black"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</DataGrid.CellStyle>
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<!--列信息绑定-->
|
||||||
|
<DataGridTextColumn Header="ID" Width="100" Binding="{Binding ID}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="NAME" Width="*" Binding="{Binding IOName}" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Header="info" Width="100" Binding="{Binding Value}" IsReadOnly="True"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
<StackPanel Grid.Row="2" x:Name="mt" VerticalAlignment="Bottom" Height="60" Background="#FF00204E" Orientation="Horizontal" Margin="0,0,0,0" >
|
||||||
|
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
|
||||||
|
<ListViewItem Width="150" MouseLeftButtonUp="ListViewItem_MouseLeftButtonUp">
|
||||||
|
<StackPanel Orientation="Horizontal" >
|
||||||
|
<materialDesign:PackIcon Kind="CoffeeMachine" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
|
||||||
|
<TextBlock Text="{x:Static lang:Resources.DyeingMachine}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListViewItem>
|
||||||
|
</ListView>
|
||||||
|
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
|
||||||
|
<ListViewItem Width="150" >
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<materialDesign:PackIcon Kind="Pipe" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
|
||||||
|
<TextBlock Text="{x:Static lang:Resources.Conveyor}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListViewItem>
|
||||||
|
</ListView>
|
||||||
|
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Foreground="#FF1368BD">
|
||||||
|
<ListViewItem Width="150" >
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<materialDesign:PackIcon Kind="ReceiptText" Width="40" Height="30" Margin="10" VerticalAlignment="Center" Foreground="#FF1368BD"/>
|
||||||
|
<TextBlock Text="{x:Static lang:Resources.Receipt}" VerticalAlignment="Center" Margin="20 10" Foreground="White"/>
|
||||||
|
</StackPanel>
|
||||||
|
</ListViewItem>
|
||||||
|
</ListView>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
using SkiaSharp;
|
||||||
|
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
||||||
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||||
|
|
||||||
|
namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// MachinesSet.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class MachinesView : UserControl
|
||||||
|
{
|
||||||
|
public MachinesView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
CountDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
||||||
|
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
|
||||||
|
private string SYS_machines = null;
|
||||||
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
|
||||||
|
}
|
||||||
|
string machine;
|
||||||
|
private void Griddata_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
int rownum = Griddata.SelectedIndex;//获取鼠标选中行并定义变量
|
||||||
|
if (rownum != -1)//判断鼠标定位是否有效
|
||||||
|
{
|
||||||
|
machine = (Griddata.Columns[1].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第1列,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ListViewItem_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
private void Grid_D_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Grid_A_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Grid_M_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void Grid_D_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
||||||
|
{
|
||||||
|
string ID;
|
||||||
|
string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息
|
||||||
|
|
||||||
|
int rownum = Grid_D.SelectedIndex;//获取鼠标选中行并定义变量
|
||||||
|
if (rownum != -1)//判断鼠标定位是否有效
|
||||||
|
{
|
||||||
|
ID = (Grid_D.Columns[0].GetCellContent(Grid_D.Items[rownum]) as TextBlock).Text;//定位第0列,
|
||||||
|
|
||||||
|
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
|
||||||
|
datagrid_v.Add("PLC", newValue);
|
||||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
SQLiteHelpers.Update("IOName", datagrid_v, "ID ='" + ID + "'", null);//更新
|
||||||
|
SQLiteHelpers.Close();//关闭数据库
|
||||||
|
}
|
||||||
|
IO_data();//重新获得io表
|
||||||
|
MainWindowViewModel.D_view = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Grid_D_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
||||||
|
{
|
||||||
|
MainWindowViewModel.D_view = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Grid_A_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
|
||||||
|
{
|
||||||
|
string ID;
|
||||||
|
string newValue = (e.EditingElement as TextBox).Text;//获得输入单元格信息
|
||||||
|
|
||||||
|
int rownum = Grid_A.SelectedIndex;//获取鼠标选中行并定义变量
|
||||||
|
if (rownum != -1)//判断鼠标定位是否有效
|
||||||
|
{
|
||||||
|
ID = (Grid_A.Columns[0].GetCellContent(Grid_A.Items[rownum]) as TextBlock).Text;//定位第0列,
|
||||||
|
|
||||||
|
Dictionary<string, object> datagrid_v = new Dictionary<string, object>();//缓存函数
|
||||||
|
datagrid_v.Add("PLC", newValue);
|
||||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
SQLiteHelpers.Update("IOName", datagrid_v, "ID ='" + ID + "'", null);//更新
|
||||||
|
SQLiteHelpers.Close();//关闭数据库
|
||||||
|
}
|
||||||
|
IO_data();//重新获得io表
|
||||||
|
MainWindowViewModel.A_view = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Grid_A_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
|
||||||
|
{
|
||||||
|
MainWindowViewModel.A_view = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void IO_data()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(machine))
|
||||||
|
{
|
||||||
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
|
int State_ = Convert.ToInt16(drEmployee.Field<object>("State"));
|
||||||
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
if ((State_ == 101) || (State_ == 201) || (State_ == 202) || (State_ == 309))//获得细节信息
|
||||||
|
{
|
||||||
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC851" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index)
|
||||||
|
});
|
||||||
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC852" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index)
|
||||||
|
});
|
||||||
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
||||||
|
{
|
||||||
|
ID = index,
|
||||||
|
DAT = "SC853" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CountDown()
|
||||||
|
{
|
||||||
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||||
|
{
|
||||||
|
Interval = TimeSpan.FromSeconds(1.5)//秒
|
||||||
|
};
|
||||||
|
timer1s.Tick += Tick_Event_1S;
|
||||||
|
timer1s.Start();
|
||||||
|
}//时间周期初始化
|
||||||
|
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
||||||
|
{ IO_data(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,8 +24,7 @@
|
|||||||
<DataGrid Grid.Row="0" Grid.Column="0" x:Name="Griddata" AlternationCount="2" IsReadOnly="True" SelectionChanged="Griddata_SelectionChanged"
|
<DataGrid Grid.Row="0" Grid.Column="0" x:Name="Griddata" AlternationCount="2" IsReadOnly="True" SelectionChanged="Griddata_SelectionChanged"
|
||||||
d:ItemsSource="{d:SampleData ItemCount=999}" AutoGenerateColumns="False" MinColumnWidth="30"
|
d:ItemsSource="{d:SampleData ItemCount=999}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||||
ItemsSource="{Binding Path=TechnologicalMachine_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
|
ItemsSource="{Binding Path=TechnologicalMachine_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
|
||||||
Background="White"
|
Background="White" GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right"
|
||||||
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right"
|
|
||||||
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||||
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" >
|
CanUserDeleteRows="False" SelectionMode="Single" FontSize="15" Focusable="True" >
|
||||||
<DataGrid.RowStyle >
|
<DataGrid.RowStyle >
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
|
|
||||||
DispatcherTimer dis50ms = new DispatcherTimer
|
DispatcherTimer dis50ms = new DispatcherTimer
|
||||||
{
|
{
|
||||||
Interval = TimeSpan.FromMilliseconds(50) //毫秒
|
Interval = TimeSpan.FromMilliseconds(100) //毫秒
|
||||||
};
|
};
|
||||||
dis50ms.Tick += new EventHandler(DisTimer_50MS);//每一秒执行的方法
|
dis50ms.Tick += new EventHandler(DisTimer_50MS);//每一秒执行的方法
|
||||||
dis50ms.Start();//计时开始
|
dis50ms.Start();//计时开始
|
||||||
@@ -276,10 +276,37 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
public static DataTable dt_TM = new DataTable();
|
public static DataTable dt_TM = new DataTable();
|
||||||
public static DataTable dt_TP = new DataTable();
|
public static DataTable dt_TP = new DataTable();
|
||||||
public static bool TechnologicalProcess_bool =true;
|
public static bool TechnologicalProcess_bool =true;
|
||||||
|
public static bool A_view =true;
|
||||||
|
public static bool D_view =true;
|
||||||
|
public static bool IO_view;
|
||||||
private async void DATA_view()//IO显示
|
private async void DATA_view()//IO显示
|
||||||
{
|
{
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (dt_m.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
SYSData_M = ToObservableCollection<DATA_M>(dt_m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ) { }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (dt_a.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
if ((bool)A_view) SYSData_A = ToObservableCollection<DATA_A>(dt_a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ) { }
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (dt_d.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
if ((bool)D_view) SYSData_D = ToObservableCollection<DATA_D>(dt_d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TechnologicalMachine_View = ToObservableCollection<TechnologicalM>(Machines);
|
TechnologicalMachine_View = ToObservableCollection<TechnologicalM>(Machines);
|
||||||
|
|||||||
Reference in new issue
Block a user