首次上传
This commit is contained in:
@@ -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