首次上传
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user