分别刷新和显示气缸 A/B 位输出状态
This commit is contained in:
parent
c55bff6c32
commit
634e11c325
@ -323,13 +323,13 @@ namespace PLCSharp.VVMs.Cylinders
|
||||
|
||||
private bool _StatusBOut;
|
||||
/// <summary>
|
||||
/// A位输出状态
|
||||
/// B位输出状态
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public bool StatusBOut
|
||||
{
|
||||
get { return _StatusBOut; }
|
||||
set { SetProperty(ref _StatusAOut, value); }
|
||||
set { SetProperty(ref _StatusBOut, value); }
|
||||
}
|
||||
|
||||
private string _FaultCode;
|
||||
|
||||
@ -82,6 +82,9 @@ namespace PLCSharp.VVMs.Cylinders
|
||||
list[i].DQB = controller.DQ.FirstOrDefault(d => d.Name == list[i].OutB);
|
||||
}
|
||||
|
||||
list[i].StatusAOut = !string.IsNullOrEmpty(list[i].OutA) && list[i].DQA?.Status == true;
|
||||
list[i].StatusBOut = !string.IsNullOrEmpty(list[i].OutB) && list[i].DQB?.Status == true;
|
||||
|
||||
//气缸功能块
|
||||
FB(list[i]);
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@
|
||||
FontSize="14" FontWeight="Bold"
|
||||
Content="B 位"
|
||||
Command="{Binding CylinderAction}"
|
||||
Background="{Binding SelectedCylinder.StatusAOut, Converter={StaticResource BoolToValueConverter}, ConverterParameter=Lime, FallbackValue=Gray}"
|
||||
Background="{Binding SelectedCylinder.StatusBOut, Converter={StaticResource BoolToValueConverter}, ConverterParameter=Lime, FallbackValue=Gray}"
|
||||
CommandParameter="B" />
|
||||
|
||||
</Grid>
|
||||
|
||||
28
Tests/PLCSharp.Tests/CylinderRegressionTests.cs
Normal file
28
Tests/PLCSharp.Tests/CylinderRegressionTests.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using PLCSharp.VVMs.Cylinders;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PLCSharp.Tests;
|
||||
|
||||
public class CylinderRegressionTests
|
||||
{
|
||||
[Fact]
|
||||
public void OutputStatesAndButtonBindingsAreIndependent()
|
||||
{
|
||||
var cylinder = new Cylinder { StatusBOut = true };
|
||||
Assert.True(cylinder.StatusBOut);
|
||||
Assert.False(cylinder.StatusAOut);
|
||||
cylinder.StatusAOut = true;
|
||||
cylinder.StatusBOut = false;
|
||||
Assert.True(cylinder.StatusAOut);
|
||||
Assert.False(cylinder.StatusBOut);
|
||||
|
||||
using var resource = typeof(CylinderRegressionTests).Assembly.GetManifestResourceStream("Cylinders.xaml");
|
||||
var view = XDocument.Load(resource!);
|
||||
foreach (var side in new[] { "A", "B" })
|
||||
{
|
||||
var button = view.Descendants(view.Root!.Name.Namespace + "Button")
|
||||
.Single(b => (string?)b.Attribute("CommandParameter") == side);
|
||||
Assert.Contains($"SelectedCylinder.Status{side}Out,", (string?)button.Attribute("Background"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\..\PLCSharpWpf\VVMs\Cylinders\Cylinders.xaml" LogicalName="Cylinders.xaml" />
|
||||
<ProjectReference Include="..\..\PLCSharpWpf\PLCSharp.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user