阀门优化

This commit is contained in:
艾竹
2021-08-02 22:04:58 +08:00
parent 831256336f
commit d11a3ef2fd
4 changed files with 66 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reactive.Linq;
using System.Text;
using Util.DiagramDesigner;
@@ -8,6 +9,7 @@ namespace AIStudio.Wpf.SFC.ViewModels
{
public class Simulate_SolenoidViewModel : SFCNode
{
private IDisposable diChangedSubscription;
public Simulate_SolenoidViewModel() : base(SFCNodeKinds.Simulate_Solenoid)
{
ItemWidth = 32;
@@ -21,6 +23,17 @@ namespace AIStudio.Wpf.SFC.ViewModels
{
}
protected override void Init()
{
base.Init();
if (diChangedSubscription != null)
{
diChangedSubscription.Dispose();
}
Random random = new Random();
diChangedSubscription = WhenPropertyChanged.Where(o => o.ToString() == "Value").Throttle(TimeSpan.FromSeconds(random.Next(1,10))).Subscribe(OnValueChanged);//Sample
}
private bool _showText;
public override bool ShowText
{
@@ -64,11 +77,19 @@ namespace AIStudio.Wpf.SFC.ViewModels
{
if (DOLinkPoint != null)
{
DOLinkPoint.Value = DILinkPoint.Value;
Value = DILinkPoint.Value;
}
}
}
private void OnValueChanged(string propertyName)
{
if (DOLinkPoint != null)
{
DOLinkPoint.Value = Value;
}
}
/// <summary>
/// 反馈
/// </summary>