Dreamine.PLC.Wpf 1.0.1
Dreamine.PLC.Wpf 산업 자동화 및 I/O 기능을 제공합니다.
로딩중...
검색중...
일치하는것 없음
PlcAddressViewItem.cs
이 파일의 문서화 페이지로 가기
1using System.ComponentModel;
2using System.Runtime.CompilerServices;
3using Dreamine.PLC.Abstractions.Devices;
4
6
15public sealed class PlcAddressViewItem : INotifyPropertyChanged
16{
25 private PlcDeviceType _deviceType;
34 private int _offset;
43 private int? _bitOffset;
52 private string _displayName = string.Empty;
53
62 public event PropertyChangedEventHandler? PropertyChanged;
63
72 public PlcDeviceType DeviceType
73 {
74 get => _deviceType;
75 set => SetField(ref _deviceType, value);
76 }
77
86 public int Offset
87 {
88 get => _offset;
89 set => SetField(ref _offset, value);
90 }
91
100 public int? BitOffset
101 {
102 get => _bitOffset;
103 set => SetField(ref _bitOffset, value);
104 }
105
114 public string DisplayName
115 {
116 get => _displayName;
117 set => SetField(ref _displayName, value);
118 }
119
136 public PlcAddress ToAddress()
137 {
138 return new PlcAddress(DeviceType, Offset, BitOffset);
139 }
140
189 private bool SetField<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
190 {
191 if (EqualityComparer<T>.Default.Equals(field, value))
192 {
193 return false;
194 }
195
196 field = value;
197 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
198 return true;
199 }
200}
bool SetField< T >(ref T field, T value, [CallerMemberName] string? propertyName=null)
PropertyChangedEventHandler? PropertyChanged