refactor: 将Framework库和RT、UI放在同一个解决方案中。
This commit is contained in:
+142
@@ -0,0 +1,142 @@
|
||||
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maitenances.CalibrationTable.CalibrationTableView"
|
||||
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:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<DataGrid Grid.Column="0" HorizontalAlignment="Left" CanUserAddRows="False" AutoGenerateColumns="False" RowHeaderWidth="0"
|
||||
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
SelectedItem="{Binding CurrentSelection}"
|
||||
ItemsSource="{Binding CalibrationItems}" Margin="0,5,0,0" >
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Header="Name" Width="280">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" >
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Canvas Grid.Row="0">
|
||||
<Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="1,1,1,1" Background="{DynamicResource Table_BG_Title}" Grid.Row="1" Padding="5,1" Height="40" Width="120">
|
||||
<TextBlock Text="Calibration Item" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
<Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="0,1,1,1" Background="{DynamicResource Table_BG_Content}" Grid.Row="1" Grid.Column="1" Padding="5,1" Canvas.Left="120" Height="40" Width="250">
|
||||
<TextBlock Text="{Binding CurrentSelection.DisplayName}" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
|
||||
<Button Content="Save" Grid.Column="1" Width="70" Height="30" Margin="0" Padding="0" Canvas.Left="385" Canvas.Top="4" >
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="Save">
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
|
||||
<Button Content="Cancel" Grid.Column="1" Width="70" Height="30" Margin="0" Padding="0" Canvas.Left="473" Canvas.Top="4" >
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="Cancel">
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</Canvas>
|
||||
|
||||
<Canvas Grid.Row="1" VerticalAlignment="Bottom">
|
||||
<TextBlock Text="Feedback Value:" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center" Canvas.Left="1" Canvas.Top="-21" />
|
||||
|
||||
<TextBlock Text="Calibration Value:" TextWrapping="Wrap" Foreground="{DynamicResource FG_Black}" FontSize="12" FontFamily="Arial" VerticalAlignment="Center" Canvas.Left="210" Canvas.Top="-21" />
|
||||
|
||||
</Canvas>
|
||||
|
||||
|
||||
<Canvas Grid.Row="2">
|
||||
<controls:TextBoxEx AllowBackgroundChange="False" Text="{Binding Path=FeedbackValue, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch" RenderTransformOrigin="3.857,1.5" Height="40" Width="160" Canvas.Left="1" />
|
||||
|
||||
<controls:TextBoxEx AllowBackgroundChange="False" Text="{Binding Path=CalibrationValue, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Stretch" RenderTransformOrigin="3.857,1.5" Canvas.Left="208" Height="40" Width="160" />
|
||||
|
||||
<Button Content="Add" Grid.Column="1" Width="70" Height="30" Margin="0" Padding="0" Canvas.Left="389" Canvas.Top="5" >
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="Add">
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</Canvas>
|
||||
|
||||
|
||||
<DataGrid Grid.Row="3" HorizontalAlignment="Left" CanUserAddRows="False" AutoGenerateColumns="False" RowHeaderWidth="0"
|
||||
VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
|
||||
ItemsSource="{Binding TableData}" Margin="0,5,0,0" >
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Header="Feedback Value" Width="280">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding FeedbackValue}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" >
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Header="Calibration Value" Width="280">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding CalibrationValue}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" >
|
||||
</TextBlock>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Header=" " Width="280">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Button Content="Delete" Width="100" Height="25" FontSize="14">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="DeleteItem">
|
||||
<micro:Parameter Value="{Binding }" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.CalibrationTable
|
||||
{
|
||||
/// <summary>
|
||||
/// CalibrationTableView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class CalibrationTableView : UserControl
|
||||
{
|
||||
public CalibrationTableView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+213
@@ -0,0 +1,213 @@
|
||||
using Aitex.Core.RT.Log;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Aitex.Core.RT.SCCore;
|
||||
using Aitex.Core.UI.MVVM;
|
||||
using Aitex.Core.Util;
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using MECF.Framework.Common.CommonData;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
using SciChart.Core.Extensions;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.CalibrationTable
|
||||
{
|
||||
|
||||
public interface ICalibrationTableViewModelParameter
|
||||
{
|
||||
List<CalibrationTableItem> Items { get; set; }
|
||||
}
|
||||
|
||||
public class CalibrationTableItem
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
public string ItemTableScName { get; set; }
|
||||
public string ItemEnableScName { get; set; }
|
||||
}
|
||||
|
||||
public class CalibrationTableViewModel : UiViewModelBase, ISupportMultipleSystem
|
||||
{
|
||||
public ICalibrationTableViewModelParameter CustomParameter { get; set; }
|
||||
|
||||
public class NotifiableCalibrationTableItem : NotifiableItem
|
||||
{
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
public float FeedbackValue { get; set; }
|
||||
|
||||
public float CalibrationValue { get; set; }
|
||||
}
|
||||
|
||||
public ObservableCollection<CalibrationTableItem> CalibrationItems { get; set; }
|
||||
|
||||
public ObservableCollection<NotifiableCalibrationTableItem> TableData { get; set; }
|
||||
|
||||
public string FeedbackValue { get; set; }
|
||||
|
||||
public string CalibrationValue { get; set; }
|
||||
|
||||
private CalibrationTableItem _currentSelection;
|
||||
|
||||
public CalibrationTableItem CurrentSelection
|
||||
{
|
||||
get { return _currentSelection; }
|
||||
set
|
||||
{
|
||||
_currentSelection = value;
|
||||
ChangeSelection(_currentSelection);
|
||||
|
||||
NotifyOfPropertyChange(nameof(CurrentSelection));
|
||||
}
|
||||
}
|
||||
|
||||
public CalibrationTableViewModel()
|
||||
{
|
||||
DisplayName = "Calibration Table ";
|
||||
|
||||
CalibrationItems = new ObservableCollection<CalibrationTableItem>();
|
||||
TableData = new ObservableCollection<NotifiableCalibrationTableItem>();
|
||||
}
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
|
||||
if (CustomParameter != null && CustomParameter.Items != null && CalibrationItems.IsEmpty())
|
||||
{
|
||||
foreach (var item in CustomParameter.Items)
|
||||
{
|
||||
CalibrationItems.Add(new CalibrationTableItem()
|
||||
{
|
||||
DisplayName = item.DisplayName,
|
||||
ItemEnableScName = item.ItemEnableScName,
|
||||
ItemTableScName = item.ItemTableScName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void ChangeSelection(CalibrationTableItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
TableData.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
var tableValues = QueryDataClient.Instance.Service.GetConfig(item.ItemTableScName);
|
||||
if (tableValues == null)
|
||||
return;
|
||||
|
||||
var scValue = (string) tableValues;
|
||||
|
||||
string[] items = scValue.Split(';');
|
||||
|
||||
|
||||
var tableData = new ObservableCollection<NotifiableCalibrationTableItem>();
|
||||
|
||||
for (int i = 0; i < items.Length; i++)
|
||||
{
|
||||
if (items.Length > i)
|
||||
{
|
||||
string itemValue = items[i];
|
||||
if (!string.IsNullOrEmpty(itemValue))
|
||||
{
|
||||
string[] pairValue = itemValue.Split('#');
|
||||
if (pairValue.Length == 2)
|
||||
{
|
||||
if (float.TryParse(pairValue[0], out float rangeItem1)
|
||||
&& float.TryParse(pairValue[1], out float rangeItem2))
|
||||
{
|
||||
tableData.Add(new NotifiableCalibrationTableItem()
|
||||
{
|
||||
FeedbackValue = rangeItem1,
|
||||
CalibrationValue = rangeItem2,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TableData = new ObservableCollection<NotifiableCalibrationTableItem>( tableData.OrderBy(x => x.FeedbackValue).ToList());
|
||||
|
||||
NotifyOfPropertyChange(nameof(TableData));
|
||||
}
|
||||
|
||||
|
||||
public void Save()
|
||||
{
|
||||
if (CurrentSelection == null)
|
||||
return;
|
||||
|
||||
string data = "";
|
||||
foreach (var item in TableData)
|
||||
{
|
||||
data += $"{item.FeedbackValue}#{item.CalibrationValue};";
|
||||
}
|
||||
|
||||
InvokeClient.Instance.Service.DoOperation("System.SetConfig", CurrentSelection.ItemTableScName, data);
|
||||
|
||||
Reload();
|
||||
}
|
||||
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
Reload();
|
||||
}
|
||||
|
||||
private void Reload()
|
||||
{
|
||||
ChangeSelection(CurrentSelection);
|
||||
}
|
||||
|
||||
public void Add()
|
||||
{
|
||||
if (string.IsNullOrEmpty(FeedbackValue) || string.IsNullOrEmpty(CalibrationValue))
|
||||
{
|
||||
MessageBox.Show("Input value is empty");
|
||||
return;
|
||||
}
|
||||
if (!float.TryParse(FeedbackValue, out float feedback) ||
|
||||
!float.TryParse(CalibrationValue, out float calibrationValue))
|
||||
{
|
||||
MessageBox.Show("Input value not valid");
|
||||
return;
|
||||
}
|
||||
|
||||
FeedbackValue = "";
|
||||
CalibrationValue = "";
|
||||
NotifyOfPropertyChange(nameof(FeedbackValue));
|
||||
NotifyOfPropertyChange(nameof(CalibrationValue));
|
||||
|
||||
TableData.Add(new NotifiableCalibrationTableItem()
|
||||
{
|
||||
DisplayName = CurrentSelection.DisplayName,
|
||||
FeedbackValue = feedback,
|
||||
CalibrationValue = calibrationValue,
|
||||
});
|
||||
}
|
||||
|
||||
public void DeleteItem(NotifiableCalibrationTableItem item)
|
||||
{
|
||||
TableData.Remove(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maitenances.Connections.ConnectionView"
|
||||
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:connections="clr-namespace:MECF.Framework.UI.Client.CenterViews.Maitenances.Connections"
|
||||
mc:Ignorable="d" >
|
||||
<UserControl.Resources>
|
||||
<connections:BoolBackgroundConverter x:Key="BoolBackgroundConverter"/>
|
||||
|
||||
<SolidColorBrush x:Key="DataGrid_Cell_BD" Color="Gray"/>
|
||||
|
||||
|
||||
<Style x:Key="Lamp-Button" TargetType="{x:Type connections:IoButton}">
|
||||
<Setter Property="Width" Value="16"/>
|
||||
<Setter Property="Height" Value="16"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type connections:IoButton}">
|
||||
<Grid>
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True" Content=""/>
|
||||
|
||||
<Ellipse Stroke="Gray" StrokeThickness="2"
|
||||
Fill="DarkGray" />
|
||||
<Ellipse x:Name="Highlight" Stroke="Gray" StrokeThickness="2"
|
||||
Fill="Lime" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="True">
|
||||
<Setter Property="Visibility" TargetName="Highlight" Value="Visible"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsChecked" Value="False">
|
||||
<Setter Property="Visibility" TargetName="Highlight" Value="Collapsed"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="False">
|
||||
<Setter Property="Opacity" TargetName="Highlight" Value="1"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="Sepcial_ListBoxItem" TargetType="{x:Type ListBoxItem}">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBoxItem}">
|
||||
<Border x:Name="Bd" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
|
||||
<Grid>
|
||||
<Border x:Name="Highlight" BorderBrush="Black" BorderThickness="0" Background="{DynamicResource Listview_BG_Highlight}" Opacity="0"/>
|
||||
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Cursor="Hand" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="true">
|
||||
<Setter Property="Opacity" TargetName="Highlight" Value="1"/>
|
||||
<Setter Property="BorderThickness" TargetName="Highlight" Value="1"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource FG_White}"/>
|
||||
<Setter Property="Margin" TargetName="Highlight" Value="0,0,1,1"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Opacity" TargetName="Highlight" Value="0.8"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="ListBox.AlternationIndex" Value="0">
|
||||
<Setter Property="Background" Value="{DynamicResource Listview_BG_First}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="ListBox.AlternationIndex" Value="1">
|
||||
<Setter Property="Background" Value="{DynamicResource Listview_BG_Second}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<DataTemplate x:Key="DOTemplate">
|
||||
<Grid Margin="-1,-1,0,0" Height="45" Background="{Binding IsChecked, ElementName=ckHold, Converter={StaticResource BoolBackgroundConverter}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
|
||||
<ColumnDefinition Width="200"></ColumnDefinition>
|
||||
<ColumnDefinition Width="200"></ColumnDefinition>
|
||||
<ColumnDefinition Width="45"></ColumnDefinition>
|
||||
<ColumnDefinition Width="100"></ColumnDefinition>
|
||||
<ColumnDefinition Width="100"></ColumnDefinition>
|
||||
<ColumnDefinition Width="15"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Column="0" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1" >
|
||||
<TextBlock Text= "{Binding Path=Name}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Column="1" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1" >
|
||||
<TextBlock Text= "{Binding Path=Address}" HorizontalAlignment="Left" VerticalAlignment="Center" ></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Column="2" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
|
||||
<connections:IoButton ON="{Binding Path=IsConnected}" Style="{StaticResource Lamp-Button}" IsChecked="{Binding IsConnected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="3" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
|
||||
<Button Content="Connect" Height="35" Command="{Binding RelativeSource={RelativeSource FindAncestor,
|
||||
AncestorType={x:Type ListBox}}, Path=DataContext.ConnectCommand}" CommandParameter="{Binding Path=Name}" />
|
||||
</Border>
|
||||
|
||||
|
||||
<Border Grid.Column="4" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
|
||||
<Button Content="Disconnect" Height="35" Command="{Binding RelativeSource={RelativeSource FindAncestor,
|
||||
AncestorType={x:Type ListBox}}, Path=DataContext.DisconnectCommand}" CommandParameter="{Binding Path=Name}" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<ListBox ItemContainerStyle="{DynamicResource Sepcial_ListBoxItem}" Width="1900" ItemsSource="{Binding ListConnections}" AlternationCount="2" ItemTemplate="{StaticResource DOTemplate}" ScrollViewer.VerticalScrollBarVisibility="Disabled" BorderThickness="0" Margin="5,0" HorizontalAlignment="Center">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel IsItemsHost="True" Orientation="Vertical" Margin="1,1,0,0"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
</ListBox>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.Connections
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for IOView.xaml
|
||||
/// </summary>
|
||||
public partial class ConnectionView : UserControl
|
||||
{
|
||||
public ConnectionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Input;
|
||||
using Aitex.Core.RT.DataCenter;
|
||||
using Aitex.Core.UI.MVVM;
|
||||
using MECF.Framework.Common.Communications;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using OpenSEMI.ClientBase;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.Connections
|
||||
{
|
||||
public class ConnectionViewModel : UiViewModelBase, ISupportMultipleSystem
|
||||
{
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
|
||||
}
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
base.OnDeactivate(close);
|
||||
}
|
||||
|
||||
|
||||
public ObservableCollection<NotifiableConnectionItem> ListConnections { get; set; }
|
||||
|
||||
public ICommand ConnectCommand { get; set; }
|
||||
public ICommand DisconnectCommand { get; set; }
|
||||
|
||||
public ConnectionViewModel()
|
||||
{
|
||||
ListConnections = new ObservableCollection<NotifiableConnectionItem>();
|
||||
|
||||
ConnectCommand = new DelegateCommand<string>(DoConnect);
|
||||
DisconnectCommand = new DelegateCommand<string>(DoDisconnect);
|
||||
}
|
||||
|
||||
private void DoConnect(string obj)
|
||||
{
|
||||
if (DialogBox.Confirm($"Are you sure you want to connect {obj}?"))
|
||||
{
|
||||
InvokeClient.Instance.Service.DoOperation($"Connection.Connect", obj);
|
||||
}
|
||||
}
|
||||
private void DoDisconnect(string obj)
|
||||
{
|
||||
if (DialogBox.Confirm($"Are you sure you want to disconnect {obj}?"))
|
||||
{
|
||||
InvokeClient.Instance.Service.DoOperation($"Connection.Disconnect", obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void Poll()
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
var connections = QueryDataClient.Instance.Service.GetData("Connection.List");
|
||||
if (connections == null)
|
||||
return;
|
||||
|
||||
List<NotifiableConnectionItem> items = connections as List<NotifiableConnectionItem>;
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
|
||||
if (ListConnections.Count == 0 || (ListConnections.FirstOrDefault(x => x.Name == item.Name) == null))
|
||||
{
|
||||
ListConnections.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
var find = ListConnections.First(x => x.Name == item.Name);
|
||||
find.IsConnected = find.IsConnected;
|
||||
find.InvokePropertyChanged("IsConnected");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//InvokePropertyChanged("ListConnections");
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class IoButton : ToggleButton
|
||||
{
|
||||
public static readonly DependencyProperty ONProperty;
|
||||
static IoButton()
|
||||
{
|
||||
ONProperty = DependencyProperty.Register("ON", typeof(bool), typeof(IoButton));
|
||||
}
|
||||
|
||||
public bool ON
|
||||
{
|
||||
get { return (bool)GetValue(ONProperty); }
|
||||
set { SetValue(ONProperty, value); }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class BoolBackgroundConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
bool? ret = (bool?)value;
|
||||
return ret.HasValue && ret.Value ? "LightBlue" : "Transparent";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maitenances.IO1.IO1View"
|
||||
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:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
mc:Ignorable="d" >
|
||||
<UserControl.Resources>
|
||||
<DataTemplate x:Key="DOTemplate">
|
||||
<Grid Margin="-1,-1,0,0" Height="23">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"></ColumnDefinition>
|
||||
<ColumnDefinition Width="200"></ColumnDefinition>
|
||||
<ColumnDefinition Width="50"></ColumnDefinition>
|
||||
<ColumnDefinition Width="45"></ColumnDefinition>
|
||||
<ColumnDefinition Width="45"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="1" Padding="5,1">
|
||||
<TextBlock Text= "{Binding Path=Index}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Column="1" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
|
||||
<TextBlock Text= "{Binding Path=Name}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Column="2" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
|
||||
<TextBlock Text= "{Binding Path=Address}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Column="3" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
|
||||
<controls:SwitchButton ON="{Binding Value}" Style="{StaticResource Lamp-Button}" HorizontalAlignment="Center" />
|
||||
</Border>
|
||||
<Border Grid.Column="4" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
|
||||
<controls:SwitchButton ON="{Binding Value}" Style="{StaticResource OperationButton}" HorizontalAlignment="Center">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="SetDO">
|
||||
<micro:Parameter Value="{Binding }" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</controls:SwitchButton>
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="DITemplate">
|
||||
<Grid Margin="-1,-1,0,0" Height="23">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"></ColumnDefinition>
|
||||
<ColumnDefinition Width="200"></ColumnDefinition>
|
||||
<ColumnDefinition Width="50"></ColumnDefinition>
|
||||
<ColumnDefinition Width="45"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="1" Padding="5,1">
|
||||
<TextBlock Text= "{Binding Path=Index}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Column="1" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
|
||||
<TextBlock Text= "{Binding Path=Name}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Column="2" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
|
||||
<TextBlock Text= "{Binding Path=Address}" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
|
||||
</Border>
|
||||
<Border Grid.Column="3" BorderBrush="{DynamicResource DataGrid_Cell_BD}" BorderThickness="0,1,1,1" Padding="5,1">
|
||||
<controls:SwitchButton ON="{Binding Value}" Style="{StaticResource Lamp-Button}" HorizontalAlignment="Center" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</UserControl.Resources>
|
||||
<Grid HorizontalAlignment="Left">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{Binding DIWidth}"></ColumnDefinition>
|
||||
<ColumnDefinition Width="{Binding DOWidth}"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TabControl>
|
||||
<TabItem Header="DI">
|
||||
<ListBox ItemsSource="{Binding DIs}"
|
||||
ItemContainerStyle="{DynamicResource Sepcial_ListBoxItem}"
|
||||
AlternationCount="2" ItemTemplate="{StaticResource DITemplate}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled"
|
||||
Width="{Binding DIWidth}"
|
||||
BorderThickness="0" Margin="5,0" HorizontalAlignment="Left" IsEnabled="{Binding IsPermission}">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel IsItemsHost="True" Orientation="Vertical" Margin="1,1,0,0"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
</ListBox>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
<TabControl Grid.Column="1" Margin="5,0,0,0">
|
||||
<TabItem Header="DO">
|
||||
<ListBox ItemContainerStyle="{DynamicResource Sepcial_ListBoxItem}" ItemsSource="{Binding DOs}" AlternationCount="2" ItemTemplate="{StaticResource DOTemplate}" IsEnabled="{Binding IsPermission}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Disabled" BorderThickness="0" Margin="5,0" HorizontalAlignment="Left">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel IsItemsHost="True" Orientation="Vertical" Margin="1,1,0,0"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.Style>
|
||||
<Style>
|
||||
<Setter Property="ListBox.Width" Value="850"></Setter>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding TwoColumnMode}" Value="False">
|
||||
<Setter Property="ListBox.Width" Value="450"></Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ListBox.Style>
|
||||
</ListBox>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.IO1
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for IOView.xaml
|
||||
/// </summary>
|
||||
public partial class IO1View : UserControl
|
||||
{
|
||||
public IO1View()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using Aitex.Core.RT.IOCore;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.Common.IOCore;
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
using MECF.Framework.RT.Core.IoProviders;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using OpenSEMI.ClientBase;
|
||||
using OpenSEMI.ClientBase.IO;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.IO1
|
||||
{
|
||||
public class IO1ViewModel : UiViewModelBase, ISupportMultipleSystem
|
||||
{
|
||||
public Visibility DIVisibility
|
||||
{
|
||||
get { return DIs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
public Visibility DOVisibility
|
||||
{
|
||||
get { return DOs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
public Visibility AIVisibility
|
||||
{
|
||||
get { return AIs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
public Visibility AOVisibility
|
||||
{
|
||||
get { return AOs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
|
||||
public int DIWidth
|
||||
{
|
||||
get { return (DIs.Count / 31 + 1) * 355; }
|
||||
}
|
||||
public int DOWidth
|
||||
{
|
||||
get { return (DOs.Count / 31 + 1) * 405; }
|
||||
}
|
||||
public int AIWidth
|
||||
{
|
||||
get { return (AIs.Count / 31 + 1) * 370; }
|
||||
}
|
||||
public int AOWidth
|
||||
{
|
||||
get { return (AOs.Count / 31 + 1) * 370; }
|
||||
}
|
||||
|
||||
public ObservableCollection<IOItem<short>> AIs { get; private set; }
|
||||
public ObservableCollection<AOItem> AOs { get; private set; }
|
||||
public ObservableCollection<IOItem<bool>> DIs { get; private set; }
|
||||
public ObservableCollection<IOItem<bool>> DOs { get; private set; }
|
||||
|
||||
private string _diKey;
|
||||
private string _doKey;
|
||||
private string _aiKey;
|
||||
private string _aoKey;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
|
||||
_diKey = $"{SystemName}.DIItemList";
|
||||
_doKey = $"{SystemName}.DOItemList";
|
||||
_aiKey = $"{SystemName}.AIItemList";
|
||||
_aoKey = $"{SystemName}.AOItemList";
|
||||
|
||||
this.AIs = InitIOData<short>(IOType.AI, _aiKey);
|
||||
this.AOs = InitIOData(IOType.AO, _aoKey);
|
||||
this.DIs = InitIOData<bool>(IOType.DI, _diKey);
|
||||
this.DOs = InitIOData<bool>(IOType.DO, _doKey);
|
||||
|
||||
|
||||
_diKey = $"{SystemName}.DIList";
|
||||
_doKey = $"{SystemName}.DOList";
|
||||
_aiKey = $"{SystemName}.AIList";
|
||||
_aoKey = $"{SystemName}.AOList";
|
||||
Subscribe(_aiKey);
|
||||
Subscribe(_aoKey);
|
||||
Subscribe(_diKey);
|
||||
Subscribe(_doKey);
|
||||
}
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
base.OnDeactivate(close);
|
||||
}
|
||||
|
||||
protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
|
||||
{
|
||||
base.InvokeAfterUpdateProperty(data);
|
||||
|
||||
if (data[_aiKey] != null)
|
||||
{
|
||||
List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_aiKey];
|
||||
Dictionary<string, short> dicValues = new Dictionary<string, short>();
|
||||
|
||||
for (int i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].ShortValue;
|
||||
}
|
||||
|
||||
foreach (IOItem<short> item in AIs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
if (data[_aoKey] != null)
|
||||
{
|
||||
List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_aoKey];
|
||||
Dictionary<string, short> dicValues = new Dictionary<string, short>();
|
||||
|
||||
for (int i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].ShortValue;
|
||||
}
|
||||
|
||||
foreach (IOItem<short> item in AOs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
|
||||
if (data[_diKey] != null)
|
||||
{
|
||||
List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_diKey];
|
||||
Dictionary<string, bool> dicValues = new Dictionary<string, bool>();
|
||||
|
||||
for (int i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].BoolValue;
|
||||
}
|
||||
|
||||
foreach (IOItem<bool> item in DIs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
if (data[_doKey] != null)
|
||||
{
|
||||
List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_doKey];
|
||||
Dictionary<string, bool> dicValues = new Dictionary<string, bool>();
|
||||
|
||||
for (int i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].BoolValue;
|
||||
}
|
||||
|
||||
foreach (IOItem<bool> item in DOs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDO(IOItem<bool> doItem)
|
||||
{
|
||||
if (MessageBox.Show(
|
||||
$"Please be attention, direct control DO is generally forbidden, Are you sure you want to do the operation?\r\n {doItem.Name} = {!doItem.Value}",
|
||||
"Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
|
||||
return;
|
||||
|
||||
InvokeClient.Instance.Service.DoOperation("System.SetDoValue", doItem.Name, !doItem.Value);
|
||||
}
|
||||
|
||||
public void SetAO(AOItem aoItem)
|
||||
{
|
||||
if (MessageBox.Show(
|
||||
$"Please be attention, direct control AO is generally forbidden, Are you sure you want to do the operation?\r\n {aoItem.Name} = {aoItem.NewValue}",
|
||||
"Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
|
||||
return;
|
||||
|
||||
InvokeClient.Instance.Service.DoOperation("System.SetAoValue", aoItem.Name, aoItem.NewValue);
|
||||
|
||||
aoItem.TextSaved = true;
|
||||
}
|
||||
|
||||
public ObservableCollection<IOItem<T>> InitIOData<T>(IOType type, string dataName)
|
||||
{
|
||||
//get the whole informations
|
||||
ObservableCollection<IOItem<T>> da = new ObservableCollection<IOItem<T>>();
|
||||
|
||||
if (type == IOType.DI)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
List<NotifiableIoItem> di = (List<NotifiableIoItem>)diList;
|
||||
for (int i = 0; i < di.Count; i++)
|
||||
{
|
||||
bool value = true;
|
||||
if (value is T)
|
||||
{
|
||||
da.Add(new IOItem<T>()
|
||||
{
|
||||
Index = di[i].Index,
|
||||
Name = di[i].Name ,
|
||||
Value = (T)(object)di[i].BoolValue,
|
||||
Address = di[i].Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == IOType.DO)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
|
||||
for (int i = 0; i < item.Count; i++)
|
||||
{
|
||||
bool value = true;
|
||||
if (value is T)
|
||||
{
|
||||
da.Add(new IOItem<T>()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name ,
|
||||
Value = (T)(object)item[i].BoolValue,
|
||||
Address = item[i].Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (type == IOType.AI)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
|
||||
for (int i = 0; i < item.Count; i++)
|
||||
{
|
||||
da.Add(new IOItem<T>()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name ,
|
||||
Value = (T)(object)item[i].ShortValue,
|
||||
Address = item[i].Address
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return da;
|
||||
}
|
||||
|
||||
public ObservableCollection<AOItem> InitIOData(IOType type, string dataName)
|
||||
{
|
||||
//get the whole informations
|
||||
ObservableCollection<AOItem> da = new ObservableCollection<AOItem>();
|
||||
|
||||
if (type == IOType.AO)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
|
||||
for (int i = 0; i < item.Count; i++)
|
||||
{
|
||||
{
|
||||
da.Add(new AOItem()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name ,
|
||||
Value = item[i].ShortValue,
|
||||
Address = item[i].Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return da;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maitenances.IO2.IO2View"
|
||||
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:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
xmlns:c="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Converter"
|
||||
mc:Ignorable="d" >
|
||||
<UserControl.Resources>
|
||||
<c:DisplayNameConverter x:Key="DisplayConverter" />
|
||||
</UserControl.Resources>
|
||||
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
|
||||
<Grid HorizontalAlignment="Left" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TabControl Grid.Column="0" Margin="20,0,0,0" Visibility="{Binding DIVisibility}">
|
||||
<TabItem Header="DI" >
|
||||
<ListView ItemsSource="{Binding Path=DIs}"
|
||||
Grid.Column="2" IsEnabled="{Binding IsPermission}"
|
||||
AlternationCount="2"
|
||||
VerticalAlignment="Top" MaxHeight="730"
|
||||
Name="DIListView">
|
||||
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="50"
|
||||
Header="Index"
|
||||
DisplayMemberBinding="{Binding Path=Index}" />
|
||||
|
||||
<GridViewColumn Width="200" Header="Name">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn Width="70"
|
||||
Header="Address"
|
||||
DisplayMemberBinding="{Binding Path=Address}" />
|
||||
|
||||
<GridViewColumn Width="50" Header="Status">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Width="35">
|
||||
<controls:SwitchButton HorizontalAlignment="Center"
|
||||
ON="{Binding Value}"
|
||||
Style="{StaticResource Lamp-Button}">
|
||||
</controls:SwitchButton>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<TabControl Grid.Column="1" Margin="20,0,0,0" Visibility="{Binding DOVisibility}">
|
||||
<TabItem Header="DO">
|
||||
<ListView ItemsSource="{Binding Path=DOs}" IsEnabled="{Binding IsPermission}"
|
||||
Grid.Column="3" MaxHeight="730"
|
||||
AlternationCount="2"
|
||||
VerticalAlignment="Top"
|
||||
Name="DOListView">
|
||||
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="50"
|
||||
Header="Index"
|
||||
DisplayMemberBinding="{Binding Path=Index}" />
|
||||
|
||||
<GridViewColumn Width="200" Header="Name">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn Width="70"
|
||||
Header="Address"
|
||||
DisplayMemberBinding="{Binding Path=Address}" />
|
||||
|
||||
<GridViewColumn Width="50" Header="Status">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate >
|
||||
<Grid Width="35">
|
||||
<controls:SwitchButton HorizontalAlignment="Center"
|
||||
ON="{Binding Value}"
|
||||
Style="{StaticResource Lamp-Button}">
|
||||
</controls:SwitchButton>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Width="75" Header="Operation">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate >
|
||||
<Grid Width="45">
|
||||
<controls:SwitchButton ON="{Binding Value}" Style="{StaticResource OperationButton}" HorizontalAlignment="Center">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="SetDO">
|
||||
<micro:Parameter Value="{Binding }" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</controls:SwitchButton>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
<TabControl Grid.Column="2" Margin="20,0,0,0" Visibility="{Binding AIVisibility}">
|
||||
<TabItem Header="AI">
|
||||
<ListView ItemsSource="{Binding Path=AIs}" IsEnabled="{Binding IsPermission}"
|
||||
AlternationCount="2" MaxHeight="730"
|
||||
Name="AIListView"
|
||||
VerticalAlignment="Top" >
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="50"
|
||||
Header="Index"
|
||||
DisplayMemberBinding="{Binding Path=Index}" />
|
||||
|
||||
<GridViewColumn Width="200" Header="Name">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn Width="70"
|
||||
Header="Address"
|
||||
DisplayMemberBinding="{Binding Path=Address}" />
|
||||
|
||||
<GridViewColumn Width="50"
|
||||
Header="Value"
|
||||
DisplayMemberBinding="{Binding Path=Value}" />
|
||||
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
|
||||
</TabControl>
|
||||
<TabControl Grid.Column="3" Margin="20,0,0,0" Visibility="{Binding AOVisibility}">
|
||||
<TabItem Header="AO">
|
||||
<ListView ItemsSource="{Binding Path=AOs}" IsEnabled="{Binding IsPermission}"
|
||||
Grid.Column="1"
|
||||
AlternationCount="2" MaxHeight="730"
|
||||
VerticalAlignment="Top"
|
||||
Name="AOListView">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="50"
|
||||
Header="Index"
|
||||
DisplayMemberBinding="{Binding Path=Index}" />
|
||||
|
||||
<GridViewColumn Width="200" Header="Name">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn Width="70"
|
||||
Header="Address"
|
||||
DisplayMemberBinding="{Binding Path=Address}" />
|
||||
|
||||
<GridViewColumn Width="50"
|
||||
Header="Value"
|
||||
DisplayMemberBinding="{Binding Path=Value}" />
|
||||
<GridViewColumn Width="80" Header="New Value">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate >
|
||||
<toolkit:IntegerUpDown Text="{Binding Path=NewValue}" Width="60"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn Width="75" Header="Operation">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate >
|
||||
<Button Content="Set" FontSize="12" Height="22" Width="45">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="SetAO">
|
||||
<micro:Parameter Value="{Binding }" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.IO2
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for IOView.xaml
|
||||
/// </summary>
|
||||
public partial class IO2View : UserControl
|
||||
{
|
||||
public IO2View()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using Aitex.Core.RT.IOCore;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.Common.IOCore;
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using OpenSEMI.ClientBase;
|
||||
using OpenSEMI.ClientBase.IO;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.IO2
|
||||
{
|
||||
/// <summary>
|
||||
/// 与IO2ViewModel的区别是,这个用Short类型的AI , AO
|
||||
/// </summary>
|
||||
public class IO2ViewModel : UiViewModelBase, ISupportMultipleSystem
|
||||
{
|
||||
public Visibility DIVisibility
|
||||
{
|
||||
get { return DIs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
public Visibility DOVisibility
|
||||
{
|
||||
get { return DOs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
public Visibility AIVisibility
|
||||
{
|
||||
get { return AIs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
public Visibility AOVisibility
|
||||
{
|
||||
get { return AOs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
|
||||
public int DIWidth
|
||||
{
|
||||
get { return (DIs.Count / 31 + 1) * 355; }
|
||||
}
|
||||
public int DOWidth
|
||||
{
|
||||
get { return (DOs.Count / 31 + 1) * 405; }
|
||||
}
|
||||
public int AIWidth
|
||||
{
|
||||
get { return (AIs.Count / 31 + 1) * 370; }
|
||||
}
|
||||
public int AOWidth
|
||||
{
|
||||
get { return (AOs.Count / 31 + 1) * 370; }
|
||||
}
|
||||
|
||||
public ObservableCollection<IOItem<short>> AIs { get; private set; }
|
||||
public ObservableCollection<AOItem> AOs { get; private set; }
|
||||
public ObservableCollection<IOItem<bool>> DIs { get; private set; }
|
||||
public ObservableCollection<IOItem<bool>> DOs { get; private set; }
|
||||
|
||||
private string _diKey;
|
||||
private string _doKey;
|
||||
private string _aiKey;
|
||||
private string _aoKey;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
|
||||
_diKey = $"{SystemName}.DIItemList";
|
||||
_doKey = $"{SystemName}.DOItemList";
|
||||
_aiKey = $"{SystemName}.AIItemList";
|
||||
_aoKey = $"{SystemName}.AOItemList";
|
||||
|
||||
this.AIs = InitIOData<short>(IOType.AI, _aiKey);
|
||||
this.AOs = InitIOData(IOType.AO, _aoKey);
|
||||
this.DIs = InitIOData<bool>(IOType.DI, _diKey);
|
||||
this.DOs = InitIOData<bool>(IOType.DO, _doKey);
|
||||
|
||||
|
||||
_diKey = $"{SystemName}.DIList";
|
||||
_doKey = $"{SystemName}.DOList";
|
||||
_aiKey = $"{SystemName}.AIList";
|
||||
_aoKey = $"{SystemName}.AOList";
|
||||
Subscribe(_aiKey);
|
||||
Subscribe(_aoKey);
|
||||
Subscribe(_diKey);
|
||||
Subscribe(_doKey);
|
||||
}
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
base.OnDeactivate(close);
|
||||
}
|
||||
|
||||
protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
|
||||
{
|
||||
base.InvokeAfterUpdateProperty(data);
|
||||
|
||||
if (data.ContainsKey(_aiKey) && data[_aiKey] != null)
|
||||
{
|
||||
List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_aiKey];
|
||||
Dictionary<string, short> dicValues = new Dictionary<string, short>();
|
||||
|
||||
for (int i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].ShortValue;
|
||||
}
|
||||
|
||||
foreach (IOItem<short> item in AIs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
if (data.ContainsKey(_aoKey) && data[_aoKey] != null)
|
||||
{
|
||||
List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_aoKey];
|
||||
Dictionary<string, short> dicValues = new Dictionary<string, short>();
|
||||
|
||||
for (int i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].ShortValue;
|
||||
}
|
||||
|
||||
foreach (IOItem<short> item in AOs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
|
||||
if (data.ContainsKey(_diKey) && data[_diKey] != null)
|
||||
{
|
||||
List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_diKey];
|
||||
Dictionary<string, bool> dicValues = new Dictionary<string, bool>();
|
||||
|
||||
for (int i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].BoolValue;
|
||||
}
|
||||
|
||||
foreach (IOItem<bool> item in DIs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
if (data.ContainsKey(_doKey) && data[_doKey] != null)
|
||||
{
|
||||
List<NotifiableIoItem> lstData = (List<NotifiableIoItem>)data[_doKey];
|
||||
Dictionary<string, bool> dicValues = new Dictionary<string, bool>();
|
||||
|
||||
for (int i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].BoolValue;
|
||||
}
|
||||
|
||||
foreach (IOItem<bool> item in DOs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDO(IOItem<bool> doItem)
|
||||
{
|
||||
if (MessageBox.Show(
|
||||
$"Please be attention, direct control DO is generally forbidden, Are you sure you want to do the operation?\r\n {doItem.Name} = {!doItem.Value}",
|
||||
"Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
|
||||
return;
|
||||
|
||||
InvokeClient.Instance.Service.DoOperation("System.SetDoValue", doItem.Name, !doItem.Value);
|
||||
}
|
||||
|
||||
public void SetAO(AOItem aoItem)
|
||||
{
|
||||
if (MessageBox.Show(
|
||||
$"Please be attention, direct control AO is generally forbidden, Are you sure you want to do the operation?\r\n {aoItem.Name} = {aoItem.NewValue}",
|
||||
"Warning", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
|
||||
return;
|
||||
|
||||
InvokeClient.Instance.Service.DoOperation("System.SetAoValue", aoItem.Name, aoItem.NewValue);
|
||||
|
||||
aoItem.TextSaved = true;
|
||||
}
|
||||
|
||||
public ObservableCollection<IOItem<T>> InitIOData<T>(IOType type, string dataName)
|
||||
{
|
||||
//get the whole informations
|
||||
ObservableCollection<IOItem<T>> da = new ObservableCollection<IOItem<T>>();
|
||||
|
||||
if (type == IOType.DI)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
|
||||
for (int i = 0; i < item.Count; i++)
|
||||
{
|
||||
bool value = true;
|
||||
if (value is T)
|
||||
{
|
||||
da.Add(new IOItem<T>()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name,
|
||||
DisplayName = item[i].Name.Substring(item[i].Name.IndexOf('.') + 1),
|
||||
Value = (T)(object)item[i].BoolValue,
|
||||
Address = item[i].Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == IOType.DO)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
|
||||
for (int i = 0; i < item.Count; i++)
|
||||
{
|
||||
bool value = true;
|
||||
if (value is T)
|
||||
{
|
||||
da.Add(new IOItem<T>()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name,
|
||||
DisplayName = item[i].Name.Substring(item[i].Name.IndexOf('.') + 1),
|
||||
Value = (T)(object)item[i].BoolValue,
|
||||
Address = item[i].Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (type == IOType.AI)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
|
||||
for (int i = 0; i < item.Count; i++)
|
||||
{
|
||||
da.Add(new IOItem<T>()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name,
|
||||
DisplayName = item[i].Name.Substring(item[i].Name.IndexOf('.') + 1),
|
||||
Value = (T)(object)item[i].ShortValue,
|
||||
Address = item[i].Address
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return da;
|
||||
}
|
||||
|
||||
public ObservableCollection<AOItem> InitIOData(IOType type, string dataName)
|
||||
{
|
||||
//get the whole informations
|
||||
ObservableCollection<AOItem> da = new ObservableCollection<AOItem>();
|
||||
|
||||
if (type == IOType.AO)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
List<NotifiableIoItem> item = (List<NotifiableIoItem>)diList;
|
||||
for (int i = 0; i < item.Count; i++)
|
||||
{
|
||||
{
|
||||
da.Add(new AOItem()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name,
|
||||
DisplayName = item[i].Name.Substring(item[i].Name.IndexOf('.')+1),
|
||||
Value = item[i].ShortValue,
|
||||
Address = item[i].Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return da;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
<UserControl x:Class="MECF.Framework.UI.Client.CenterViews.Maitenances.IO3.IO3View"
|
||||
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:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
xmlns:c="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Converter"
|
||||
xmlns:lex="http://wpflocalizeextension.codeplex.com"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="1000" d:DesignWidth="1900"
|
||||
lex:LocalizeDictionary.DesignCulture="en"
|
||||
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common">
|
||||
<UserControl.Resources>
|
||||
<c:DisplayNameConverter x:Key="DisplayConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid HorizontalAlignment="Left">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="40" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TabControl Grid.Column="0" Margin="20,0,0,0" Visibility="{Binding DIVisibility}" >
|
||||
<TabItem Header="DI">
|
||||
<ListView ItemsSource="{Binding Path=DIsFilter}" IsEnabled="{Binding IsPermission}"
|
||||
AlternationCount="2"
|
||||
Name="DIListView">
|
||||
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="50"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Header="{lex:Loc ID_TXT_Index}"
|
||||
DisplayMemberBinding="{Binding Path=Index}" />
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="200" Header="{lex:Loc ID_TXT_Name}">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" ToolTip="{Binding ToolTip}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="0"
|
||||
Header="{lex:Loc ID_TXT_Address}"
|
||||
DisplayMemberBinding="{Binding Path=Address}" />
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="50" Header="{lex:Loc ID_TXT_Status}">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Width="35">
|
||||
<controls:SwitchButton HorizontalAlignment="Center"
|
||||
ON="{Binding Value}"
|
||||
Style="{StaticResource Lamp-Button}">
|
||||
</controls:SwitchButton>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<TabControl Grid.Column="1" Margin="10,0,0,0" Visibility="{Binding DOVisibility}">
|
||||
<TabItem Header="DO">
|
||||
<ListView ItemsSource="{Binding Path=DOsFilter}" IsEnabled="{Binding IsPermission}"
|
||||
AlternationCount="2"
|
||||
Name="DOListView">
|
||||
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="50"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Header="{lex:Loc ID_TXT_Index}"
|
||||
DisplayMemberBinding="{Binding Path=Index}" />
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="200" Header="{lex:Loc ID_TXT_Name}">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" ToolTip="{Binding ToolTip}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="0"
|
||||
Header="{lex:Loc ID_TXT_Address}"
|
||||
DisplayMemberBinding="{Binding Path=Address}" />
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="50" Header="{lex:Loc ID_TXT_Status}">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate >
|
||||
<Grid Width="35">
|
||||
<controls:SwitchButton HorizontalAlignment="Center"
|
||||
ON="{Binding Value}"
|
||||
Style="{StaticResource Lamp-Button}">
|
||||
</controls:SwitchButton>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="75" Header="{lex:Loc ID_TXT_Operation}">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate >
|
||||
<Grid Width="45">
|
||||
<controls:SwitchButton ON="{Binding Value}" Style="{StaticResource OperationButton}" HorizontalAlignment="Center">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="SetDO">
|
||||
<micro:Parameter Value="{Binding }" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</controls:SwitchButton>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
<TabControl Grid.Column="2" Margin="10,0,0,0" Visibility="{Binding AIVisibility}">
|
||||
<TabItem Header="AI">
|
||||
<ListView ItemsSource="{Binding Path=AIsFilter}" IsEnabled="{Binding IsPermission}"
|
||||
AlternationCount="2"
|
||||
Name="AIListView">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="50"
|
||||
Header="{lex:Loc ID_TXT_Index}"
|
||||
DisplayMemberBinding="{Binding Path=Index}" />
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="200" Header="{lex:Loc ID_TXT_Name}">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" ToolTip="{Binding ToolTip}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="0"
|
||||
Header="{lex:Loc ID_TXT_Address}"
|
||||
DisplayMemberBinding="{Binding Path=Address}" />
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="90"
|
||||
Header="{lex:Loc ID_TXT_Value}"
|
||||
DisplayMemberBinding="{Binding Path=Value, StringFormat={}{0:F2}}" />
|
||||
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
|
||||
</TabControl>
|
||||
<TabControl Grid.Column="3" Margin="10,0,0,0" Visibility="{Binding AOVisibility}">
|
||||
<TabItem Header="AO">
|
||||
<ListView ItemsSource="{Binding Path=AOsFilter}" IsEnabled="{Binding IsPermission}"
|
||||
AlternationCount="2"
|
||||
Name="AOListView">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="50"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Header="{lex:Loc ID_TXT_Index}"
|
||||
DisplayMemberBinding="{Binding Path=Index}" />
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="200" Header="{lex:Loc ID_TXT_Name}">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding DisplayName, Converter={StaticResource DisplayConverter}}" ToolTip="{Binding ToolTip}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="0"
|
||||
Header="{lex:Loc ID_TXT_Address}"
|
||||
DisplayMemberBinding="{Binding Path=Address}" />
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="90"
|
||||
Header="{lex:Loc ID_TXT_Value}"
|
||||
DisplayMemberBinding="{Binding Path=Value, StringFormat={}{0:F2}}"/>
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="100" Header="{lex:Loc ID_TXT_NewValue}">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate >
|
||||
<controls:TextBoxEx Text="{Binding Path=NewValue}" Width="90"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="75" Header="{lex:Loc ID_TXT_Operation}">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate >
|
||||
<Button Content="{lex:Loc ID_BTN_Set_Content}" FontSize="12" Height="22" Width="45">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="SetAO">
|
||||
<micro:Parameter Value="{Binding }" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
<Label
|
||||
Grid.Row="1"
|
||||
Margin="15,0,10,0"
|
||||
VerticalAlignment="Center"
|
||||
Content="{lex:Loc ID_TXT_Filter}"
|
||||
FontSize="16" />
|
||||
<controls:TextBoxEx
|
||||
Grid.Row="1"
|
||||
Height="26"
|
||||
Margin="65,0,50,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
AllowBackgroundChange="False"
|
||||
Text="{Binding Path=CurrentCriteria, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
Width="30"
|
||||
Height="30"
|
||||
Margin="0,0,5,0"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center">
|
||||
<Button.Content>
|
||||
<Path
|
||||
Width="15"
|
||||
Height="15"
|
||||
Margin="0,3"
|
||||
Data="M5.5,0 L8.5,0 8.5,5.5 14,5.5 14,8.5 8.5,8.5 8.5,14 5.5,14 5.5,8.5 0,8.5 0,5.5 5.5,5.5 z"
|
||||
Fill="Black"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Stretch="Fill"
|
||||
StrokeThickness="3">
|
||||
</Path>
|
||||
</Button.Content>
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="ClearFilter" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.IO3
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for IOView.xaml
|
||||
/// </summary>
|
||||
public partial class IO3View : UserControl
|
||||
{
|
||||
public IO3View()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,406 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Aitex.Core.RT.IOCore;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.Common.IOCore;
|
||||
using MECF.Framework.Common.OperationCenter;
|
||||
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.OcrReaders.IOSS;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using OpenSEMI.ClientBase;
|
||||
using OpenSEMI.ClientBase.IO;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Maitenances.IO3
|
||||
{
|
||||
/// <summary>
|
||||
/// 与IO2ViewModel的区别是,这个用Float类型的AI , AO
|
||||
/// </summary>
|
||||
public class IO3ViewModel : UiViewModelBase, ISupportMultipleSystem
|
||||
{
|
||||
public Visibility DIVisibility
|
||||
{
|
||||
get { return DIs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
public Visibility DOVisibility
|
||||
{
|
||||
get { return DOs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
public Visibility AIVisibility
|
||||
{
|
||||
get { return AIs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
public Visibility AOVisibility
|
||||
{
|
||||
get { return AOs.Count > 0 ? Visibility.Visible : Visibility.Collapsed; }
|
||||
}
|
||||
|
||||
public int DIWidth
|
||||
{
|
||||
get { return (DIs.Count / 31 + 1) * 355; }
|
||||
}
|
||||
public int DOWidth
|
||||
{
|
||||
get { return (DOs.Count / 31 + 1) * 405; }
|
||||
}
|
||||
public int AIWidth
|
||||
{
|
||||
get { return (AIs.Count / 31 + 1) * 370; }
|
||||
}
|
||||
public int AOWidth
|
||||
{
|
||||
get { return (AOs.Count / 31 + 1) * 370; }
|
||||
}
|
||||
|
||||
public ObservableCollection<IOItem<float>> AIs { get; private set; }
|
||||
public ObservableCollection<AOItemFloat> AOs { get; private set; }
|
||||
public ObservableCollection<IOItem<bool>> DIs { get; private set; }
|
||||
public ObservableCollection<IOItem<bool>> DOs { get; private set; }
|
||||
|
||||
public ObservableCollection<IOItem<float>> AIsFilter { get; private set; }
|
||||
public ObservableCollection<AOItemFloat> AOsFilter { get; private set; }
|
||||
public ObservableCollection<IOItem<bool>> DIsFilter { get; private set; }
|
||||
public ObservableCollection<IOItem<bool>> DOsFilter { get; private set; }
|
||||
|
||||
private string _diKey;
|
||||
private string _doKey;
|
||||
private string _aiKey;
|
||||
private string _aoKey;
|
||||
|
||||
protected override void OnInitialize()
|
||||
{
|
||||
base.OnInitialize();
|
||||
|
||||
_diKey = $"{SystemName}.DIItemList";
|
||||
_doKey = $"{SystemName}.DOItemList";
|
||||
_aiKey = $"{SystemName}.AIItemList";
|
||||
_aoKey = $"{SystemName}.AOItemList";
|
||||
|
||||
AIs = InitIOData<float>(IOType.AI, _aiKey);
|
||||
AOs = InitIOData(IOType.AO, _aoKey);
|
||||
DIs = InitIOData<bool>(IOType.DI, _diKey);
|
||||
DOs = InitIOData<bool>(IOType.DO, _doKey);
|
||||
|
||||
AIsFilter = AIs;
|
||||
AOsFilter = AOs;
|
||||
DIsFilter = DIs;
|
||||
DOsFilter = DOs;
|
||||
|
||||
|
||||
_diKey = $"{SystemName}.DIList";
|
||||
_doKey = $"{SystemName}.DOList";
|
||||
_aiKey = $"{SystemName}.AIList";
|
||||
_aoKey = $"{SystemName}.AOList";
|
||||
Subscribe(_aiKey);
|
||||
Subscribe(_aoKey);
|
||||
Subscribe(_diKey);
|
||||
Subscribe(_doKey);
|
||||
}
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
base.OnDeactivate(close);
|
||||
}
|
||||
|
||||
protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
|
||||
{
|
||||
base.InvokeAfterUpdateProperty(data);
|
||||
|
||||
if (data.ContainsKey(_aiKey) && data[_aiKey] != null)
|
||||
{
|
||||
var lstData = (List<NotifiableIoItem>)data[_aiKey];
|
||||
var dicValues = new Dictionary<string, float>();
|
||||
|
||||
for (var i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].FloatValue;
|
||||
}
|
||||
|
||||
foreach (var item in AIs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
if (data.ContainsKey(_aoKey) && data[_aoKey] != null)
|
||||
{
|
||||
var lstData = (List<NotifiableIoItem>)data[_aoKey];
|
||||
var dicValues = new Dictionary<string, float>();
|
||||
|
||||
for (var i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].FloatValue;
|
||||
}
|
||||
|
||||
foreach (IOItem<float> item in AOs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
|
||||
if (data.ContainsKey(_diKey) && data[_diKey] != null)
|
||||
{
|
||||
var lstData = (List<NotifiableIoItem>)data[_diKey];
|
||||
var dicValues = new Dictionary<string, bool>();
|
||||
|
||||
for (var i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].BoolValue;
|
||||
}
|
||||
|
||||
foreach (var item in DIs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
if (data.ContainsKey(_doKey) && data[_doKey] != null)
|
||||
{
|
||||
var lstData = (List<NotifiableIoItem>)data[_doKey];
|
||||
var dicValues = new Dictionary<string, bool>();
|
||||
|
||||
for (var i = 0; i < lstData.Count; i++)
|
||||
{
|
||||
dicValues[lstData[i].Name] = lstData[i].BoolValue;
|
||||
}
|
||||
|
||||
foreach (var item in DOs)
|
||||
{
|
||||
if (dicValues.ContainsKey(item.Name))
|
||||
item.Value = dicValues[item.Name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDO(IOItem<bool> doItem)
|
||||
{
|
||||
if (!DialogBox.Confirm(
|
||||
$"Please be attention, direct control DO is generally forbidden, Are you sure you want to do the operation?\r\n {doItem.DisplayName} = {!doItem.Value}",
|
||||
"Warning"))
|
||||
return;
|
||||
|
||||
InvokeClient.Instance.Service.DoOperation("System.SetDoValue", doItem.Name, !doItem.Value);
|
||||
}
|
||||
|
||||
public void SetAO(AOItemFloat AOItemFloat)
|
||||
{
|
||||
if (!DialogBox.Confirm(
|
||||
$"Please be attention, direct control AO is generally forbidden, Are you sure you want to do the operation?\r\n {AOItemFloat.DisplayName} = {AOItemFloat.NewValue}",
|
||||
"Warning" ))
|
||||
return;
|
||||
|
||||
InvokeClient.Instance.Service.DoOperation("System.SetAoValueFloat", AOItemFloat.Name, AOItemFloat.NewValue);
|
||||
|
||||
AOItemFloat.TextSaved = true;
|
||||
}
|
||||
|
||||
private string GetDisplayName(NotifiableIoItem io)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(io.Display_Zh))
|
||||
{
|
||||
return (io.Display_Zh.Length <= 10 ? io.Display_Zh : $"{io.Display_Zh.Substring(0, 10)}...") +
|
||||
(string.IsNullOrEmpty(io.AltName) ? "" : $"({io.AltName})");
|
||||
}
|
||||
else
|
||||
{
|
||||
return (string.IsNullOrEmpty(io.Description) || io.Description.Length > 6)
|
||||
? io.Name.Substring(io.Name.IndexOf('.') + 1)
|
||||
: io
|
||||
.Name.Substring(io.Name.IndexOf('.') + 1) + " (" + io.Description + ")";
|
||||
}
|
||||
}
|
||||
|
||||
private string GetToolTip(NotifiableIoItem io)
|
||||
{
|
||||
return $"Name: {io.Name}\r\nAddr: {io.Address}\r\nDescription: {io.Description}";
|
||||
}
|
||||
|
||||
public ObservableCollection<IOItem<T>> InitIOData<T>(IOType type, string dataName)
|
||||
{
|
||||
//get the whole informations
|
||||
var da = new ObservableCollection<IOItem<T>>();
|
||||
|
||||
if (type == IOType.DI)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
var item = (List<NotifiableIoItem>)diList;
|
||||
for (var i = 0; i < item.Count; i++)
|
||||
{
|
||||
var value = true;
|
||||
if (value is T)
|
||||
{
|
||||
if(item[i].Visible)
|
||||
{
|
||||
da.Add(new IOItem<T>()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name,
|
||||
DisplayName = GetDisplayName(item[i]),
|
||||
ToolTip = GetToolTip(item[i]),
|
||||
Value = (T)(object)item[i].BoolValue,
|
||||
Address = item[i].Address
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == IOType.DO)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
var item = (List<NotifiableIoItem>)diList;
|
||||
for (var i = 0; i < item.Count; i++)
|
||||
{
|
||||
var value = true;
|
||||
if (value is T)
|
||||
{
|
||||
if (item[i].Visible)
|
||||
{
|
||||
da.Add(new IOItem<T>()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name,
|
||||
DisplayName = GetDisplayName(item[i]),
|
||||
ToolTip = GetToolTip(item[i]),
|
||||
Value = (T)(object)item[i].BoolValue,
|
||||
Address = item[i].Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (type == IOType.AI)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
var item = (List<NotifiableIoItem>)diList;
|
||||
for (var i = 0; i < item.Count; i++)
|
||||
{
|
||||
if (item[i].Visible)
|
||||
{
|
||||
da.Add(new IOItem<T>()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name,
|
||||
DisplayName = GetDisplayName(item[i]),
|
||||
ToolTip = GetToolTip(item[i]),
|
||||
Value = (T)(object)item[i].FloatValue,
|
||||
Address = item[i].Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return da;
|
||||
}
|
||||
|
||||
public ObservableCollection<AOItemFloat> InitIOData(IOType type, string dataName)
|
||||
{
|
||||
//get the whole informations
|
||||
var da = new ObservableCollection<AOItemFloat>();
|
||||
|
||||
if (type == IOType.AO)
|
||||
{
|
||||
var diList = QueryDataClient.Instance.Service.GetData(dataName);
|
||||
|
||||
if (diList != null)
|
||||
{
|
||||
var item = (List<NotifiableIoItem>)diList;
|
||||
for (var i = 0; i < item.Count; i++)
|
||||
{
|
||||
if (item[i].Visible)
|
||||
{
|
||||
da.Add(new AOItemFloat()
|
||||
{
|
||||
Index = item[i].Index,
|
||||
Name = item[i].Name,
|
||||
DisplayName = GetDisplayName(item[i]),
|
||||
ToolTip = GetToolTip(item[i]),
|
||||
Value = item[i].FloatValue,
|
||||
Address = item[i].Address
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return da;
|
||||
}
|
||||
|
||||
private string _currentCriteria = String.Empty;
|
||||
public string CurrentCriteria
|
||||
{
|
||||
get { return _currentCriteria; }
|
||||
set
|
||||
{
|
||||
if (value == _currentCriteria)
|
||||
return;
|
||||
|
||||
_currentCriteria = value;
|
||||
NotifyOfPropertyChange("CurrentCriteria");
|
||||
ApplyFilter();
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyFilter()
|
||||
{
|
||||
var index = 0;
|
||||
|
||||
if (int.TryParse(CurrentCriteria, out index))
|
||||
{
|
||||
DIsFilter = new ObservableCollection<IOItem<bool>>(
|
||||
DIs.Where(d => d.Index == index));
|
||||
|
||||
DOsFilter = new ObservableCollection<IOItem<bool>>(
|
||||
DOs.Where(d => d.Index == index));
|
||||
|
||||
AIsFilter = new ObservableCollection<IOItem<float>>(
|
||||
AIs.Where(d => d.Index == index));
|
||||
|
||||
AOsFilter = new ObservableCollection<AOItemFloat>(
|
||||
AOs.Where(d => d.Index == index));
|
||||
}
|
||||
else
|
||||
{
|
||||
DIsFilter = new ObservableCollection<IOItem<bool>>(
|
||||
DIs.Where(d => d.DisplayName.IndexOf(CurrentCriteria, StringComparison.OrdinalIgnoreCase) >= 0));
|
||||
|
||||
DOsFilter = new ObservableCollection<IOItem<bool>>(
|
||||
DOs.Where(d => d.DisplayName.IndexOf(CurrentCriteria, StringComparison.OrdinalIgnoreCase) >= 0));
|
||||
|
||||
AIsFilter = new ObservableCollection<IOItem<float>>(
|
||||
AIs.Where(d => d.DisplayName.IndexOf(CurrentCriteria, StringComparison.OrdinalIgnoreCase) >= 0));
|
||||
|
||||
AOsFilter = new ObservableCollection<AOItemFloat>(
|
||||
AOs.Where(d => d.DisplayName.IndexOf(CurrentCriteria, StringComparison.OrdinalIgnoreCase) >= 0));
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearFilter()
|
||||
{
|
||||
CurrentCriteria = "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user