You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.5 KiB
53 lines
1.5 KiB
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using MultiTerm.Protocols.Model;
|
|
using System.Text;
|
|
|
|
namespace MultiTerm.Core.ViewModel;
|
|
|
|
public partial class ByteDataViewModel : ObservableObject, IDataViewModel
|
|
{
|
|
/// <summary>
|
|
/// Object of data model.
|
|
/// </summary>
|
|
private readonly ExtendedByte data;
|
|
|
|
#region IDataViewModel Implementation
|
|
|
|
[ObservableProperty]
|
|
private int lineIdentifier;
|
|
|
|
[ObservableProperty]
|
|
private TimeOnly time;
|
|
|
|
[ObservableProperty]
|
|
private string displayStringChar = String.Empty;
|
|
|
|
[ObservableProperty]
|
|
private string displayStringHex = String.Empty;
|
|
|
|
[ObservableProperty]
|
|
private string displayStringBin = String.Empty;
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// Allows access to the low level data byte.
|
|
/// </summary>
|
|
public byte Byte => this.data.Byte;
|
|
|
|
/// <summary>
|
|
/// Instanciates new <see cref="ByteDataViewModel"/>.
|
|
/// Initializes internal variables with data according to <paramref name="extendedByte"/>.
|
|
/// </summary>
|
|
/// <param name="extendedByte">data</param>
|
|
/// <param name="lineIdentifier">identifies line in which this byte is located</param>
|
|
public ByteDataViewModel(ExtendedByte extendedByte, int lineIdentifier)
|
|
{
|
|
this.data = extendedByte;
|
|
this.lineIdentifier = lineIdentifier;
|
|
this.DisplayStringChar = extendedByte.ToCharacterString();
|
|
this.DisplayStringHex = extendedByte.ToHexString();
|
|
this.DisplayStringBin = extendedByte.ToBinaryString();
|
|
this.Time = extendedByte.Time;
|
|
}
|
|
}
|
|
|