2022-12-12 22:33:17 +08:00
|
|
|
|
using System;
|
2023-04-29 18:36:50 +08:00
|
|
|
|
using System.Collections.Generic;
|
2021-07-29 13:55:18 +08:00
|
|
|
|
using System.Collections.ObjectModel;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Windows.Media;
|
2022-10-28 22:45:39 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner;
|
2023-01-25 11:11:27 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Models;
|
2022-12-12 22:33:17 +08:00
|
|
|
|
using AIStudio.Wpf.DiagramDesigner.Services;
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2021-07-29 13:55:18 +08:00
|
|
|
|
namespace AIStudio.Wpf.Logical.ViewModels
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public abstract class LogicalGateItemViewModel : LogicalGateItemViewModelBase
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
protected IUIVisualizerService visualiserService;
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LogicalGateItemViewModel(LogicalType logicalType) : this(null, logicalType)
|
|
|
|
|
|
{
|
2023-04-22 21:06:52 +08:00
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public LogicalGateItemViewModel(IDiagramViewModel root, LogicalType logicalType) : base(root, logicalType)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-04-22 21:06:52 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public LogicalGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public LogicalGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public override SelectableItemBase GetSerializableObject()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new LogicalGateDesignerItemBase(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-25 11:59:31 +08:00
|
|
|
|
protected override void Init(IDiagramViewModel root, bool initNew)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-03-25 11:59:31 +08:00
|
|
|
|
base.Init(root, initNew);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
visualiserService = ApplicationServicesProvider.Instance.Provider.VisualizerService;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-25 11:59:31 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
2023-04-19 22:26:04 +08:00
|
|
|
|
|
|
|
|
|
|
ColorViewModel.FillColor.Color = Colors.Orange;
|
2023-03-25 11:59:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
base.LoadDesignerItemViewModel(designerbase);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
if (designerbase is LogicalGateDesignerItemBase designer)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Value = designer.Value;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void ExecuteEditCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LogicalType == LogicalType.Constant)
|
|
|
|
|
|
{
|
|
|
|
|
|
ValueDesignerItemData data = new ValueDesignerItemData(Value);
|
|
|
|
|
|
if (visualiserService.ShowDialog(data) == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Value = data.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
LogicalGateItemData data = new LogicalGateItemData(Input.Values);
|
|
|
|
|
|
if (visualiserService.ShowDialog(data) == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class AddGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public AddGateItemViewModel() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public AddGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.ADD)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 16:20:39 +08:00
|
|
|
|
public AddGateItemViewModel(IDiagramViewModel root, LogicalGateDesignerItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public AddGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
}
|
2023-04-22 21:06:52 +08:00
|
|
|
|
|
|
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
2022-12-08 20:54:45 +08:00
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
public override bool EnableAddInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = true;
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EnableAddOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = false;
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Input.Values.Select(p => p.ConnectorValue).Sum();
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class SubtractGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SubtractGateItemViewModel() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public SubtractGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.SUB)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public SubtractGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public SubtractGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override bool EnableAddInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = true;
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EnableAddOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = false;
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
var first = Input.Values.Select(p => p.ConnectorValue).FirstOrDefault();
|
|
|
|
|
|
var second = Input.Values.Where((value, index) => index != 0).Select(p => p.ConnectorValue).Sum();
|
|
|
|
|
|
output.Value.ConnectorValue = first - second;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class MultiplyGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public MultiplyGateItemViewModel() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public MultiplyGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.MUL)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public MultiplyGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public MultiplyGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EnableAddInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = true;
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EnableAddOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = false;
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
2023-04-29 18:36:50 +08:00
|
|
|
|
double result = 1;
|
2023-04-15 23:32:29 +08:00
|
|
|
|
foreach (var input in Input.Values)
|
|
|
|
|
|
{
|
|
|
|
|
|
result *= input.ConnectorValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
output.Value.ConnectorValue = result;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class DivideGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public DivideGateItemViewModel() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DivideGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.DIV)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public DivideGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public DivideGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EnableAddInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = true;
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EnableAddOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = false;
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
double result = Input.Values.Select(p => p.ConnectorValue).FirstOrDefault();
|
|
|
|
|
|
foreach (var input in Input.Values.Where((value, index) => index != 0))
|
|
|
|
|
|
{
|
|
|
|
|
|
result /= input.ConnectorValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
output.Value.ConnectorValue = result;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class AverageGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public AverageGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public AverageGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.AVE)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public AverageGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public AverageGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EnableAddInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = true;
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EnableAddOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = false;
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Input.Values.Select(p => p.ConnectorValue).Average();
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class MODGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public MODGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public MODGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.MOD)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public MODGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public MODGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Input[0].ConnectorValue % Input[1].ConnectorValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ANDGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ANDGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ANDGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.AND)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public ANDGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public ANDGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Convert.ToInt32(Input[0].ConnectorValue) & Convert.ToInt32(Input[1].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ORGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ORGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ORGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.OR)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public ORGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public ORGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Convert.ToInt32(Input[0].ConnectorValue) | Convert.ToInt32(Input[1].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class XORGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public XORGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public XORGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.XOR)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public XORGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public XORGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Convert.ToInt32(Convert.ToInt32(Input[0].ConnectorValue) ^ Convert.ToInt32(Input[1].ConnectorValue));
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class NOTGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public NOTGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public NOTGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.NOT)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public NOTGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public NOTGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
2023-04-24 20:10:17 +08:00
|
|
|
|
if (Input[0].ConnectorValueType == DiagramDesigner.ConnectorValueType.Bool)
|
2023-04-15 23:32:29 +08:00
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Convert.ToInt32(!Convert.ToBoolean(Input[0].ConnectorValue));
|
2023-04-24 20:10:17 +08:00
|
|
|
|
output.Value.ConnectorValueType = DiagramDesigner.ConnectorValueType.Bool;
|
2023-04-15 23:32:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = ~Convert.ToInt32(Input[0].ConnectorValue);
|
2023-04-24 20:10:17 +08:00
|
|
|
|
output.Value.ConnectorValueType = DiagramDesigner.ConnectorValueType.Int;
|
2023-04-15 23:32:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class SHLGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SHLGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SHLGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.SHL)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public SHLGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public SHLGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Convert.ToInt32(Input[0].ConnectorValue) << Convert.ToInt32(Input[1].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class SHRGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SHRGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SHRGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.SHR)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public SHRGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public SHRGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Convert.ToInt32(Input[0].ConnectorValue) >> Convert.ToInt32(Input[1].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ROLGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ROLGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ROLGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.ROL)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public ROLGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public ROLGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = (Convert.ToInt32(Input[0].ConnectorValue) << Convert.ToInt32(Input[1].ConnectorValue)) | (Convert.ToInt32(Input[0].ConnectorValue) >> 32 - Convert.ToInt32(Input[1].ConnectorValue));
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class RORGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public RORGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public RORGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.ROR)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public RORGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public RORGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Int };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = (Convert.ToInt32(Input[0].ConnectorValue) >> Convert.ToInt32(Input[1].ConnectorValue)) | (Convert.ToInt32(Input[0].ConnectorValue) << 32 - Convert.ToInt32(Input[1].ConnectorValue));
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class SELGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SELGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-24 17:53:04 +08:00
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SELGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.SEL)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public SELGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public SELGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null, 0);
|
|
|
|
|
|
ExecuteAddInput(null, 1);
|
|
|
|
|
|
ExecuteAddInput(null, 2);
|
|
|
|
|
|
ExecuteAddOutput(null, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Bool, ConnectorValueType.Real, ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = (Input[0].ConnectorValue == output.Key) ? Input[1].ConnectorValue : Input[2].ConnectorValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class MAXGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public MAXGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public MAXGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.MAX)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public MAXGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public MAXGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override bool EnableAddInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = true;
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EnableAddOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = false;
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Input.Values.Select(p => p.ConnectorValue).Max();
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class MINGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public MINGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public MINGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.MIN)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public MINGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public MINGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override bool EnableAddInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = true;
|
|
|
|
|
|
|
|
|
|
|
|
public override bool EnableAddOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get;
|
|
|
|
|
|
} = false;
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Input.Values.Select(p => p.ConnectorValue).Min();
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class LIMITGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LIMITGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LIMITGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.LIMIT)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public LIMITGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public LIMITGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = (Input[0].ConnectorValue > Input[1].ConnectorValue) ? Input[1].ConnectorValue : Input[0].ConnectorValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class GTGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public GTGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public GTGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.GT)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public GTGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public GTGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
2023-04-15 23:32:29 +08:00
|
|
|
|
{
|
2023-04-29 18:36:50 +08:00
|
|
|
|
get
|
2023-04-15 23:32:29 +08:00
|
|
|
|
{
|
2023-04-29 18:36:50 +08:00
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Bool };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = (Input[0].ConnectorValue > Input[1].ConnectorValue) ? 1 : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class LTGateItemViewModel : LogicalGateItemViewModel
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LTGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LTGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.LT)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public LTGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public LTGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Bool };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = (Input[0].ConnectorValue < Input[1].ConnectorValue) ? 1 : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class GEGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public GEGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public GEGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.GE)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public GEGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public GEGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Bool };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = (Input[0].ConnectorValue >= Input[1].ConnectorValue) ? 1 : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class LEGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LEGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LEGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.LE)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public LEGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public LEGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Bool };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = (Input[0].ConnectorValue <= Input[1].ConnectorValue) ? 1 : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class EQGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public EQGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public EQGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.EQ)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public EQGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public EQGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Bool };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = (Input[0].ConnectorValue == Input[1].ConnectorValue) ? 1 : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class NEGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public NEGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public NEGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.NE)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public NEGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public NEGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Bool };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = (Input[0].ConnectorValue != Input[1].ConnectorValue) ? 1 : 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ABSGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ABSGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ABSGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.ABS)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public ABSGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public ABSGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Abs(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class SQRTGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SQRTGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SQRTGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.SQRT)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public SQRTGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public SQRTGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Sqrt(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class LNGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LNGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LNGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.LN)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public LNGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public LNGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Log10(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class LOGGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LOGGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public LOGGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.LOG)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public LOGGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public LOGGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Log(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class EXPGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public EXPGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public EXPGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.EXP)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public EXPGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public EXPGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Exp(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class SINGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SINGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public SINGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.SIN)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public SINGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public SINGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Sin(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class COSGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public COSGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public COSGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.COS)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public COSGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public COSGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Cos(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class TANGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public TANGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public TANGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.TAN)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public TANGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public TANGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Tan(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ASINGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ASINGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ASINGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.ASIN)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public ASINGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public ASINGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Asin(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ACOSGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ACOSGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ACOSGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.ACOS)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public ACOSGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public ACOSGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Acos(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ATANGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ATANGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ATANGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.ATAN)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public ATANGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public ATANGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Atan(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class EXPTGateItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public EXPTGateItemViewModel() : this(null)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public EXPTGateItemViewModel(IDiagramViewModel root) : base(root, LogicalType.EXPT)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public EXPTGateItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2022-12-08 20:54:45 +08:00
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public EXPTGateItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Math.Exp(Input[0].ConnectorValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ConstantDesignerItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public ConstantDesignerItemViewModel() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ConstantDesignerItemViewModel(IDiagramViewModel root) : base(root, LogicalType.Constant)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
ItemHeight = 28;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public ConstantDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public ConstantDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2023-04-15 23:32:29 +08:00
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void GetInput()
|
|
|
|
|
|
{
|
2023-04-22 21:06:52 +08:00
|
|
|
|
//无输入
|
2023-04-15 23:32:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class InputItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public InputItemViewModel() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public InputItemViewModel(IDiagramViewModel root) : base(root, LogicalType.Input)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
ItemHeight = 28;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public InputItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public InputItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
base.LoadDesignerItemViewModel(designerbase);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
if (designerbase is LogicalGateDesignerItemBase designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-24 17:53:04 +08:00
|
|
|
|
this.Value = designer.Value;
|
|
|
|
|
|
LinkPoint = LogicalService.LinkPoint.FirstOrDefault(p => p.Id.ToString() == designer.Icon); //不想新增字段了,就用这个Icon保存自定义测点的Id吧。
|
|
|
|
|
|
if (LinkPoint != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
LinkPoint.Value = designer.Value;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private LinkPoint _linkPoint;
|
|
|
|
|
|
public LinkPoint LinkPoint
|
|
|
|
|
|
{
|
2023-01-24 17:53:04 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _linkPoint;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SetProperty(ref _linkPoint, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
Icon = _linkPoint?.Id.ToString();//不想新增字段了,就用这个Icon保存自定义测点的Id吧。
|
|
|
|
|
|
Text = _linkPoint?.Name;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddOutput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void GetInput()
|
|
|
|
|
|
{
|
|
|
|
|
|
//无输入
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (LinkPoint != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var output in Output)
|
|
|
|
|
|
{
|
|
|
|
|
|
output.Value.ConnectorValue = LinkPoint.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
protected override void ExecuteEditCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
LinkPointDesignerItemData data = new LinkPointDesignerItemData(LinkPoint);
|
|
|
|
|
|
if (visualiserService.ShowDialog(data) == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LinkPoint = data.LinkPoint;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class OutputItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public OutputItemViewModel() : this(null)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public OutputItemViewModel(IDiagramViewModel root) : base(root, LogicalType.Output)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
ItemHeight = 28;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public OutputItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public OutputItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
base.LoadDesignerItemViewModel(designerbase);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
if (designerbase is LogicalGateDesignerItemBase designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-24 17:53:04 +08:00
|
|
|
|
|
|
|
|
|
|
this.Value = designer.Value;
|
|
|
|
|
|
LinkPoint = LogicalService.LinkPoint.FirstOrDefault(p => p.Id.ToString() == designer.Icon); //不想新增字段了,就用这个Icon保存自定义测点的Id吧。
|
|
|
|
|
|
if (LinkPoint != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
LinkPoint.Value = designer.Value;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private LinkPoint _linkPoint;
|
|
|
|
|
|
public LinkPoint LinkPoint
|
|
|
|
|
|
{
|
2023-01-24 17:53:04 +08:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return _linkPoint;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (SetProperty(ref _linkPoint, value))
|
|
|
|
|
|
{
|
|
|
|
|
|
Icon = _linkPoint?.Id.ToString();//不想新增字段了,就用这个Icon保存自定义测点的Id吧。
|
|
|
|
|
|
Text = _linkPoint?.Name;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-22 21:06:52 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
|
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddInput(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-15 23:32:29 +08:00
|
|
|
|
public override void CalculateOutput()
|
|
|
|
|
|
{
|
|
|
|
|
|
var first = Input.Values.FirstOrDefault();
|
|
|
|
|
|
Value = first.ConnectorValue;
|
|
|
|
|
|
LinkPoint.Value = first.ConnectorValue;
|
|
|
|
|
|
foreach (var output in Output)
|
2023-04-22 21:06:52 +08:00
|
|
|
|
{
|
2023-04-15 23:32:29 +08:00
|
|
|
|
output.Value.ConnectorValue = first.ConnectorValue;
|
2023-04-24 20:10:17 +08:00
|
|
|
|
output.Value.ConnectorValueType = first.ConnectorValueType;
|
2023-04-15 23:32:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
base.CalculateOutput();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
protected override void ExecuteEditCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
LinkPointDesignerItemData data = new LinkPointDesignerItemData(LinkPoint);
|
|
|
|
|
|
if (visualiserService.ShowDialog(data) == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LinkPoint = data.LinkPoint;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class TimerDesignerItemViewModel : LogicalGateItemViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
private System.Timers.Timer readDataTimer = new System.Timers.Timer();
|
|
|
|
|
|
public Action Do;
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
public TimerDesignerItemViewModel() : this(null)
|
|
|
|
|
|
{
|
2023-04-22 21:06:52 +08:00
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TimerDesignerItemViewModel(IDiagramViewModel root) : base(root, LogicalType.Time)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
ItemHeight = 32;
|
|
|
|
|
|
ItemWidth = 32;
|
|
|
|
|
|
Value = 1;
|
|
|
|
|
|
Start();
|
|
|
|
|
|
BuildMenuOptions();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public TimerDesignerItemViewModel(IDiagramViewModel root, SelectableItemBase designer) : base(root, designer)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
|
|
|
|
|
BuildMenuOptions();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-25 11:11:27 +08:00
|
|
|
|
public TimerDesignerItemViewModel(IDiagramViewModel root, SerializableItem serializableItem, string serializableType) : base(root, serializableItem, serializableType)
|
2022-12-08 20:54:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
BuildMenuOptions();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-25 11:59:31 +08:00
|
|
|
|
protected override void Init(IDiagramViewModel root, bool initNew)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Init(root, initNew);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
MenuItemCommand = new SimpleCommand(Command_Enable, ExecuteMenuItemCommand);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
readDataTimer.Elapsed += timeCycle;
|
|
|
|
|
|
readDataTimer.Interval = 1000;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-25 11:59:31 +08:00
|
|
|
|
protected override void InitNew()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitNew();
|
2023-04-22 21:06:52 +08:00
|
|
|
|
|
|
|
|
|
|
ClearConnectors();
|
|
|
|
|
|
ExecuteAddOutput(null);
|
2023-03-25 11:59:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-27 14:54:03 +08:00
|
|
|
|
protected override void LoadDesignerItemViewModel(SelectableItemBase designerbase)
|
2021-07-23 09:42:22 +08:00
|
|
|
|
{
|
2023-01-27 14:54:03 +08:00
|
|
|
|
base.LoadDesignerItemViewModel(designerbase);
|
2021-07-23 09:42:22 +08:00
|
|
|
|
|
|
|
|
|
|
if (IsEnabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Stop();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-29 18:36:50 +08:00
|
|
|
|
public override List<ConnectorValueType> ValueTypeInput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override List<ConnectorValueType> ValueTypeOutput
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
return new List<ConnectorValueType>() { ConnectorValueType.Real };
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
IsEnabled = true;
|
|
|
|
|
|
Output[0].ColorViewModel.FillColor.Color = Colors.Green;
|
|
|
|
|
|
readDataTimer.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Stop()
|
|
|
|
|
|
{
|
|
|
|
|
|
IsEnabled = false;
|
|
|
|
|
|
Output[0].ColorViewModel.FillColor.Color = Colors.Red;
|
|
|
|
|
|
readDataTimer.Stop();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ExecuteMenuItemCommand(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((obj as CinchMenuItem).IsChecked == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Stop();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-01-24 17:53:04 +08:00
|
|
|
|
public SimpleCommand MenuItemCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
get; private set;
|
|
|
|
|
|
}
|
2021-07-23 09:42:22 +08:00
|
|
|
|
private void BuildMenuOptions()
|
|
|
|
|
|
{
|
|
|
|
|
|
menuOptions = new ObservableCollection<CinchMenuItem>();
|
|
|
|
|
|
CinchMenuItem menuItem = new CinchMenuItem();
|
|
|
|
|
|
menuItem.Text = "启动";
|
|
|
|
|
|
menuItem.IsCheckable = true;
|
|
|
|
|
|
menuItem.IsChecked = IsEnabled;
|
|
|
|
|
|
menuItem.Command = MenuItemCommand;
|
|
|
|
|
|
menuItem.CommandParameter = menuItem;
|
|
|
|
|
|
menuOptions.Add(menuItem);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void ExecuteEditCommand(object parameter)
|
|
|
|
|
|
{
|
|
|
|
|
|
ValueDesignerItemData data = new ValueDesignerItemData(Value);
|
|
|
|
|
|
if (visualiserService.ShowDialog(data) == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Value = data.Value;
|
|
|
|
|
|
readDataTimer.Interval = this.Value * 1000;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void timeCycle(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
Output.FirstOrDefault().Value.ConnectorValue += Value;
|
|
|
|
|
|
if (Do != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Do();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Dispose();
|
2021-08-02 18:08:43 +08:00
|
|
|
|
readDataTimer.Stop();
|
2021-07-23 09:42:22 +08:00
|
|
|
|
readDataTimer.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|