Commit 7df48248 authored by 潘栩锋's avatar 潘栩锋 🚴

添加 根据AD盒V3,V2 版本号, 显示IO口的编号, V3是从X0~X15, V2是i1~i12

parent 42531211
...@@ -14,13 +14,14 @@ ...@@ -14,13 +14,14 @@
<ResourceDictionary Source="CtMicroGageStyle.xaml"/> <ResourceDictionary Source="CtMicroGageStyle.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<local:IO2BitColorConverter x:Key="io2bitcolorconv"/> <local:IO2BitColorConverter x:Key="io2bitcolorconv"/>
<local:IONumberConverter x:Key="ioNumberConv"/>
<local:CtMircoGageVmUt x:Key="viewModel" <local:CtMircoGageVmUt x:Key="viewModel"
Thick="300.3" AD="12000" ADMax="65535" Position="5001" PosLength="8900" PosMm="500.1" Velocity="5.1" ControllerState="定点" Thick="300.3" AD="12000" ADMax="65535" Position="5001" PosLength="8900" PosMm="500.1" Velocity="5.1" ControllerState="定点"
OStatus="0x0005" OStatus="0x0005"
IStatus="0xff7f" IStatus="0xff7f"
IsError="False" IsError="False"
ErrMsg="枫莱尔控制器连接断开" ErrMsg="枫莱尔控制器连接断开"
IsIOShowNo ="False"
/> />
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
...@@ -130,7 +131,7 @@ ...@@ -130,7 +131,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=13}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=13}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=12}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=12}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="13" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=12}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -139,7 +140,7 @@ ...@@ -139,7 +140,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=9}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=9}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=8}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=8}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="9" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=8}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -148,7 +149,7 @@ ...@@ -148,7 +149,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="5" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=4}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -157,7 +158,7 @@ ...@@ -157,7 +158,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="1" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=0}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
...@@ -176,7 +177,7 @@ ...@@ -176,7 +177,7 @@
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="5" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=4}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -185,7 +186,7 @@ ...@@ -185,7 +186,7 @@
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="1" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=0}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
......
...@@ -4,6 +4,7 @@ using FLY.Thick.Base.Common; ...@@ -4,6 +4,7 @@ using FLY.Thick.Base.Common;
using FLY.Thick.Base.IService; using FLY.Thick.Base.IService;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -88,4 +89,36 @@ namespace FLY.Thick.Base.UI ...@@ -88,4 +89,36 @@ namespace FLY.Thick.Base.UI
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }
public class IONumberConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool isIOShowNo = true;
int idx = 0;
if (value is bool)
{
isIOShowNo = (bool)value;
}
if (!(parameter is string))
{
return null;
}
if (!int.TryParse((string)parameter, out idx))
{
return null;
}
if (isIOShowNo)
{
return (idx + 1).ToString();
}
else {
return (idx).ToString();
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
} }
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<Setter Property="Foreground" Value="{StaticResource MahApps.Brushes.Accent}" /> <Setter Property="Foreground" Value="{StaticResource MahApps.Brushes.Accent}" />
<Setter Property="HorizontalAlignment" Value="Center" /> <Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" /> <Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontSize" Value="10"/> <Setter Property="FontSize" Value="8"/>
</Style> </Style>
<Style x:Key="IconStyle" TargetType="{x:Type Control}" > <Style x:Key="IconStyle" TargetType="{x:Type Control}" >
<Setter Property="Margin" Value="6"/> <Setter Property="Margin" Value="6"/>
......
...@@ -28,6 +28,7 @@ namespace FLY.Thick.Base.UI ...@@ -28,6 +28,7 @@ namespace FLY.Thick.Base.UI
public double Thick { get; set; } public double Thick { get; set; }
public int AD { get; set; } public int AD { get; set; }
public int ADMax { get; set; } public int ADMax { get; set; }
public bool IsIOShowNo { get; set; } = true;
public int Position { get; set; } public int Position { get; set; }
public int PosLength { get; set; } public int PosLength { get; set; }
...@@ -113,6 +114,7 @@ namespace FLY.Thick.Base.UI ...@@ -113,6 +114,7 @@ namespace FLY.Thick.Base.UI
}); });
Misc.BindingOperations.SetBinding(this.initParam, nameof(CtMicroGageVm.initParam.PosLength), this, nameof(PosLength)); Misc.BindingOperations.SetBinding(this.initParam, nameof(CtMicroGageVm.initParam.PosLength), this, nameof(PosLength));
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IsIOShowNo), this, nameof(IsIOShowNo));
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.OStatus), this, nameof(OStatus)); Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.OStatus), this, nameof(OStatus));
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IStatus), this, nameof(IStatus)); Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IStatus), this, nameof(IStatus));
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
</Style> </Style>
<Style x:Key="IOTextStyle" TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldContent}"> <Style x:Key="IOTextStyle" TargetType="TextBlock" BasedOn="{StaticResource Styles.Text.FieldContent}">
<Setter Property="FontSize" Value="20"/> <Setter Property="FontSize" Value="20"/>
<Setter Property="Width" Value="30" /> <Setter Property="Width" Value="40" />
<Setter Property="Margin" Value="3" /> <Setter Property="Margin" Value="3" />
</Style> </Style>
<local:WdIoTipVmUt x:Key="viewModel"/> <local:WdIoTipVmUt x:Key="viewModel"/>
......
...@@ -59,34 +59,13 @@ namespace FLY.Thick.Base.UI ...@@ -59,34 +59,13 @@ namespace FLY.Thick.Base.UI
this.dynArea = dynArea; this.dynArea = dynArea;
this.iODefineService = iODefineService; this.iODefineService = iODefineService;
for (int i = 0; i < 12; i++) {
IStatus.Add(new FlyAdIoStatus()
{
Number = $"i{i+1}"
});
};
for (int i = 0; i < 4; i++)
{
OStatus.Add(new FlyAdIoStatus()
{
Number = $"o{i+1}"
});
};
if (this.iODefineService is FObjBase.FObjServiceClient) if (this.iODefineService is FObjBase.FObjServiceClient)
{ {
var client = this.iODefineService as FObjBase.FObjServiceClient; var client = this.iODefineService as FObjBase.FObjServiceClient;
if (client.IsConnected)
{
update();
}
client.PropertyChanged += Client_PropertyChanged; client.PropertyChanged += Client_PropertyChanged;
} }
else
{
update();
}
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IsIOShowNo), update);
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IStatus), updateIsOn_In); Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.IStatus), updateIsOn_In);
Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.OStatus), updateIsOn_Out); Misc.BindingOperations.SetBinding(dynArea, nameof(dynArea.OStatus), updateIsOn_Out);
...@@ -122,16 +101,16 @@ namespace FLY.Thick.Base.UI ...@@ -122,16 +101,16 @@ namespace FLY.Thick.Base.UI
{ {
iODefineService.GetIODefine((asyncContext, retData) => { iODefineService.GetIODefine((asyncContext, retData) => {
var reponse = retData as IODefineCollection; var response = retData as IODefineCollection;
if (reponse == null) { if (response == null) {
return; return;
} }
var list = reponse.List; var list = response.List;
if (list == null || list.Count() == 0) if (list == null || list.Count() == 0)
return; return;
update(IODefine.IOTYPE.Input, IStatus, reponse.InCount, list); update(IODefine.IOTYPE.Input, IStatus, dynArea.IsIOShowNo, response.InCount, list);
update(IODefine.IOTYPE.Output, OStatus, reponse.OutCount, list); update(IODefine.IOTYPE.Output, OStatus, dynArea.IsIOShowNo, response.OutCount, list);
updateIsOn_In(); updateIsOn_In();
updateIsOn_Out(); updateIsOn_Out();
...@@ -141,25 +120,39 @@ namespace FLY.Thick.Base.UI ...@@ -141,25 +120,39 @@ namespace FLY.Thick.Base.UI
void update( void update(
IODefine.IOTYPE ioType, IODefine.IOTYPE ioType,
ObservableCollection<FlyAdIoStatus> ioStatus, ObservableCollection<FlyAdIoStatus> ioStatus,
bool isShowNo,
int ioCnt, int ioCnt,
List<IODefine> list) List<IODefine> list)
{ {
//补够数量 ioStatus.Clear();
if (ioStatus.Count() != ioCnt && ioCnt > 0) for (int i = 0; i < ioCnt; i++) {
string number;
if (isShowNo)
{
if (ioType == IODefine.IOTYPE.Input)
{
number = $"i{i + 1}";
}
else
{ {
while (ioStatus.Count() > ioCnt) number = $"o{i + 1}";
}
}
else {
if (ioType == IODefine.IOTYPE.Input)
{ {
ioStatus.RemoveAt(ioStatus.Count() - 1); number = $"X{i}";
} }
while (ioStatus.Count() < ioCnt) else
{ {
int i = ioStatus.Count(); number = $"Y{i}";
}
}
ioStatus.Add(new FlyAdIoStatus() ioStatus.Add(new FlyAdIoStatus()
{ {
Number = $"i{i + 1}" Number = number
}); });
} }
}
//获取中文 //获取中文
string[] iostatus_desps = new string[ioCnt]; string[] iostatus_desps = new string[ioCnt];
...@@ -216,18 +209,18 @@ namespace FLY.Thick.Base.UI ...@@ -216,18 +209,18 @@ namespace FLY.Thick.Base.UI
public WdIoTipVmUt() public WdIoTipVmUt()
{ {
for (int i = 0; i < 12; i++) for (int i = 0; i < 16; i++)
{ {
IStatus.Add(new FlyAdIoStatus() IStatus.Add(new FlyAdIoStatus()
{ {
Number = $"i{i + 1}" Number = $"X{i}"
}); });
}; };
for (int i = 0; i < 4; i++) for (int i = 0; i < 8; i++)
{ {
OStatus.Add(new FlyAdIoStatus() OStatus.Add(new FlyAdIoStatus()
{ {
Number = $"o{i + 1}" Number = $"Y{i}"
}); });
}; };
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
</Style> </Style>
<local:DynAreaIOVmUt x:Key="ioVm" /> <local:DynAreaIOVmUt x:Key="ioVm" />
<local:DynAreaErrorVm x:Key="errorVm" IsError="True" ErrMsg="枫莱尔控制器连接断开 枫莱尔控制器连接断开"/> <local:DynAreaErrorVm x:Key="errorVm" IsError="False" ErrMsg="枫莱尔控制器连接断开 枫莱尔控制器连接断开"/>
<local:IONumberConverter x:Key="ioNumberConv"/>
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Grid Height="100" > <Grid Height="100" >
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=13}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=13}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=12}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=12}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="13" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=12}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=9}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=9}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=8}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=8}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="9" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=8}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="5" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=4}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="1" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=0}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="5" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=4}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="1" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=0}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
......
...@@ -24,6 +24,7 @@ using MultiLayout; ...@@ -24,6 +24,7 @@ using MultiLayout;
using FLY.OBJComponents.IService; using FLY.OBJComponents.IService;
using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Command;
using FObjBase.Reflect; using FObjBase.Reflect;
using System.Globalization;
namespace FLY.Thick.Base.UI.UiModule namespace FLY.Thick.Base.UI.UiModule
{ {
...@@ -65,6 +66,7 @@ namespace FLY.Thick.Base.UI.UiModule ...@@ -65,6 +66,7 @@ namespace FLY.Thick.Base.UI.UiModule
public UInt16 IStatus { get; set; } = 0xffff; public UInt16 IStatus { get; set; } = 0xffff;
public UInt16 OStatus { get; set; } = 0x000f; public UInt16 OStatus { get; set; } = 0x000f;
public bool IsIOShowNo { get; set; } = true;
public int Hrs { get; set; } = 3; public int Hrs { get; set; } = 3;
/// <summary> /// <summary>
...@@ -94,7 +96,9 @@ namespace FLY.Thick.Base.UI.UiModule ...@@ -94,7 +96,9 @@ namespace FLY.Thick.Base.UI.UiModule
Misc.BindingOperations.SetBinding(this.dynArea, nameof(this.dynArea.IStatus), this, nameof(IStatus)); Misc.BindingOperations.SetBinding(this.dynArea, nameof(this.dynArea.IStatus), this, nameof(IStatus));
Misc.BindingOperations.SetBinding(this.dynArea, nameof(this.dynArea.OStatus), this, nameof(OStatus)); Misc.BindingOperations.SetBinding(this.dynArea, nameof(this.dynArea.OStatus), this, nameof(OStatus));
Misc.BindingOperations.SetBinding(this.dynArea, nameof(this.dynArea.IsIOShowNo), this, nameof(IsIOShowNo));
Misc.BindingOperations.SetBinding(this.dynArea, nameof(this.dynArea.Hrs), this, nameof(Hrs)); Misc.BindingOperations.SetBinding(this.dynArea, nameof(this.dynArea.Hrs), this, nameof(Hrs));
UpdateIsForever(); UpdateIsForever();
this.dynArea.PropertyChanged += (s, e) => this.dynArea.PropertyChanged += (s, e) =>
...@@ -400,4 +404,38 @@ namespace FLY.Thick.Base.UI.UiModule ...@@ -400,4 +404,38 @@ namespace FLY.Thick.Base.UI.UiModule
} }
} }
public class IONumberConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool isIOShowNo = true;
int idx = 0;
if (value is bool)
{
isIOShowNo = (bool)value;
}
if (!(parameter is string))
{
return null;
}
if (!int.TryParse((string)parameter, out idx))
{
return null;
}
if (isIOShowNo)
{
return (idx + 1).ToString();
}
else
{
return (idx).ToString();
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
} }
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
</Style> </Style>
<local:DynAreaIOVm x:Key="ioVm" IStatus = "0xff7f" OStatus = "0x0005" Hrs = "2000" IsForever="False"/> <local:DynAreaIOVm x:Key="ioVm" IStatus = "0xff7f" OStatus = "0x0005" Hrs = "2000" IsForever="False"/>
<local:IONumberConverter x:Key="ioNumberConv"/>
</ResourceDictionary> </ResourceDictionary>
</UserControl.Resources> </UserControl.Resources>
<Button Style="{StaticResource Styles.Button.Empty}" d:DataContext="{StaticResource ioVm}" Command="{Binding OpenIoTipCmd}"> <Button Style="{StaticResource Styles.Button.Empty}" d:DataContext="{StaticResource ioVm}" Command="{Binding OpenIoTipCmd}">
...@@ -40,7 +41,7 @@ ...@@ -40,7 +41,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=13}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=13}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=12}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=12}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="13" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=12}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -49,7 +50,7 @@ ...@@ -49,7 +50,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=9}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=9}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=8}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=8}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="9" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=8}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -58,7 +59,7 @@ ...@@ -58,7 +59,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="5" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=4}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -67,7 +68,7 @@ ...@@ -67,7 +68,7 @@
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding IStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="1" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=0}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
...@@ -84,7 +85,7 @@ ...@@ -84,7 +85,7 @@
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=5}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=4}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="5" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=4}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="4,0"> <StackPanel Orientation="Horizontal" Margin="4,0">
...@@ -93,7 +94,7 @@ ...@@ -93,7 +94,7 @@
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=1}" Style="{StaticResource IOStyle}"/>
<Grid> <Grid>
<Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/> <Rectangle Fill="{Binding OStatus,Converter={StaticResource io2bitcolorconv},ConverterParameter=0}" Style="{StaticResource IOStyle}"/>
<TextBlock Text="1" Style="{StaticResource IOTextStyle}"/> <TextBlock Text="{Binding IsIOShowNo,Converter={StaticResource ioNumberConv},ConverterParameter=0}" Style="{StaticResource IOTextStyle}"/>
</Grid> </Grid>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
......
...@@ -107,6 +107,10 @@ namespace FLY.Thick.Base.Common ...@@ -107,6 +107,10 @@ namespace FLY.Thick.Base.Common
public UInt16 OStatus { get; set; } = 0xffff; public UInt16 OStatus { get; set; } = 0xffff;
/// <summary>
/// I/O 显示编号1~16
/// </summary>
public bool IsIOShowNo { get; set; } = true;
#endregion #endregion
#region 系统 #region 系统
......
using FLY.Thick.Base.IService; using FLY.Thick.Base.IService;
using FlyADBase;
using FObjBase; using FObjBase;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -33,6 +34,13 @@ namespace FLY.Thick.Base.Common ...@@ -33,6 +34,13 @@ namespace FLY.Thick.Base.Common
public static FlyADIODefine Instance => instance; public static FlyADIODefine Instance => instance;
#region 输入口 #region 输入口
/// <summary>
/// 扫描按钮信号
/// </summary>
[Description("扫描按钮信号")]
public int InNo_Scan { get; protected set; } = 1 - 1;
/// <summary> /// <summary>
/// 归零信号 /// 归零信号
/// </summary> /// </summary>
...@@ -95,6 +103,13 @@ namespace FLY.Thick.Base.Common ...@@ -95,6 +103,13 @@ namespace FLY.Thick.Base.Common
#endregion #endregion
#region 输出口 #region 输出口
/// <summary>
/// 扫描动作中
/// </summary>
[Description("扫描动作中")]
public int OutNo_Scan { get; protected set; } = 1 - 1;
/// <summary> /// <summary>
/// 变频器反转 VF0 是松下的变频器牌子 /// 变频器反转 VF0 是松下的变频器牌子
/// </summary> /// </summary>
...@@ -132,23 +147,13 @@ namespace FLY.Thick.Base.Common ...@@ -132,23 +147,13 @@ namespace FLY.Thick.Base.Common
#endregion #endregion
private int version = 2; IFlyAD flyAD;
/// <summary> public virtual void SetFlyAD(IFlyAD _flyAD)
/// 根据AD盒的版本,设置
/// </summary>
/// <param name="version"></param>
public virtual void SerVersion(int version)
{ {
this.version = version; this.flyAD = _flyAD;
if (this.version == 3) Misc.BindingOperations.SetBinding(flyAD, nameof(flyAD.HardwareVersion), () =>
{ {
InNo_Org = 13 - 1; if (this.flyAD.HardwareVersion < 3)
InNo_Limit_Forw = 14 - 1;
InNo_Limit_Backw = 16 - 1;
InNo_Roll = 15 - 1;
}
else
{ {
InNo_Org = 2 - 1; InNo_Org = 2 - 1;
InNo_Limit_Forw = 3 - 1; InNo_Limit_Forw = 3 - 1;
...@@ -156,6 +161,15 @@ namespace FLY.Thick.Base.Common ...@@ -156,6 +161,15 @@ namespace FLY.Thick.Base.Common
InNo_Roll = 11 - 1; InNo_Roll = 11 - 1;
} }
else
{
InNo_Org = 13 - 1;
InNo_Limit_Forw = 14 - 1;
InNo_Limit_Backw = 16 - 1;
InNo_Roll = 15 - 1;
}
});
} }
/// <summary> /// <summary>
...@@ -201,23 +215,37 @@ namespace FLY.Thick.Base.Common ...@@ -201,23 +215,37 @@ namespace FLY.Thick.Base.Common
public void GetIODefine(AsyncCBHandler asyncDelegate, object asyncContext) public void GetIODefine(AsyncCBHandler asyncDelegate, object asyncContext)
{ {
//获取全部带 Description 的属性,且名字 InNo_XXX 或 OutNo_XXX //获取全部带 Description 的属性,且名字 InNo_XXX 或 OutNo_XXX
IODefineCollection reponse = new IODefineCollection(); IODefineCollection response = new IODefineCollection();
List<IODefine> list = new List<IODefine>(); List<IODefine> list = new List<IODefine>();
reponse.List = list; response.List = list;
if (version == 3) if (flyAD.HardwareVersion < 3)
{ {
reponse.InCount = 16; response.InCount = 12;
reponse.OutCount = 8; response.OutCount = 4;
} }
else { else {
reponse.InCount = 12; response.InCount = 16;
reponse.OutCount = 4; response.OutCount = 8;
} }
var inputPropertyNames = GetInputPropertyNames(); var inputPropertyNames = GetInputPropertyNames();
var outputPropertyNames = GetOutputPropertyNames(); var outputPropertyNames = GetOutputPropertyNames();
if (flyAD.MotorType != FlyADBase.MOTORTYPE.VF0)
{
//把 变频器 接口删除
outputPropertyNames.Remove(nameof(OutNo_VF0_Forw));
outputPropertyNames.Remove(nameof(OutNo_VF0_Backw));
outputPropertyNames.Remove(nameof(OutNo_VF0_Slow));
}
if (flyAD.MotorType == FlyADBase.MOTORTYPE.VF0)
{
//变频器 模式 没有扫描状态灯
outputPropertyNames.Remove(nameof(OutNo_Scan));
}
Type t = this.GetType(); Type t = this.GetType();
foreach (var propertyName in inputPropertyNames) foreach (var propertyName in inputPropertyNames)
...@@ -240,6 +268,7 @@ namespace FLY.Thick.Base.Common ...@@ -240,6 +268,7 @@ namespace FLY.Thick.Base.Common
Index = index, Index = index,
Description = desp Description = desp
}; };
list.Add(iodefine); list.Add(iodefine);
} }
...@@ -266,7 +295,7 @@ namespace FLY.Thick.Base.Common ...@@ -266,7 +295,7 @@ namespace FLY.Thick.Base.Common
list.Add(iodefine); list.Add(iodefine);
} }
asyncDelegate?.Invoke(asyncContext, reponse); asyncDelegate?.Invoke(asyncContext, response);
} }
} }
} }
...@@ -32,7 +32,6 @@ namespace FLY.Thick.Base.IService ...@@ -32,7 +32,6 @@ namespace FLY.Thick.Base.IService
/// 输出口数量 /// 输出口数量
/// </summary> /// </summary>
public int OutCount; public int OutCount;
/// <summary> /// <summary>
/// 列表 /// 列表
/// </summary> /// </summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment