/// <summary> /// Initializes a new instance of the <see cref="WordWatch"/> class /// </summary> /// <param name="domain"><see cref="MemoryDomain"/> where you want to track</param> /// <param name="address">The address you want to track</param> /// <param name="type">How you you want to display the value See <see cref="WatchDisplayType"/></param> /// <param name="bigEndian">Specify the endianess. true for big endian</param> /// <param name="note">A custom note about the <see cref="Watch"/></param> /// <param name="value">Current value</param> /// <param name="previous">Previous value</param> /// <param name="changeCount">How many times value has changed</param> /// <exception cref="ArgumentException">Occurs when a <see cref="WatchDisplayType"/> is incompatible with <see cref="WatchSize.Word"/></exception> internal WordWatch(MemoryDomain domain, long address, WatchDisplayType type, bool bigEndian, string note, ushort value, ushort previous, int changeCount) : base(domain, address, WatchSize.Word, type, bigEndian, note) { _value = value == 0 ? GetWord() : value; _previous = previous; ChangeCount = changeCount; }
/// <summary> /// Initializes a new instance of the <see cref="ByteWatch"/> class. /// </summary> /// <param name="domain"><see cref="MemoryDomain"/> where you want to track</param> /// <param name="address">The address you want to track</param> /// <param name="type">How you you want to display the value See <see cref="WatchDisplayType"/></param> /// <param name="bigEndian">Specify the endianess. true for big endian</param> /// <param name="note">A custom note about the <see cref="Watch"/></param> /// <param name="value">Current value</param> /// <param name="previous">Previous value</param> /// <param name="changeCount">How many times value has changed</param> /// <exception cref="ArgumentException">Occurs when a <see cref="WatchDisplayType"/> is incompatible with <see cref="WatchSize.Byte"/></exception> internal ByteWatch(MemoryDomain domain, long address, WatchDisplayType type, bool bigEndian, string note, byte value, byte previous, int changeCount) : base(domain, address, WatchSize.Byte, type, bigEndian, note) { _value = value == 0 ? GetByte() : value; _previous = previous; ChangeCount = changeCount; }
/// <summary> /// Generate sa <see cref="Watch"/> from a given string /// String is tab separate /// </summary> /// <param name="line">Entire string, tab separated for each value Order is: /// <list type="number"> /// <item> /// <term>0x00</term> /// <description>Address in hexadecimal</description> /// </item> /// <item> /// <term>b,w or d</term> /// <description>The <see cref="WatchSize"/>, byte, word or double word</description> /// <term>s, u, h, b, 1, 2, 3, f</term> /// <description>The <see cref="WatchDisplayType"/> signed, unsigned,etc...</description> /// </item> /// <item> /// <term>0 or 1</term> /// <description>Big endian or not</description> /// </item> /// <item> /// <term>RDRAM,ROM,...</term> /// <description>The <see cref="IMemoryDomains"/></description> /// </item> /// <item> /// <term>Plain text</term> /// <description>Notes</description> /// </item> /// </list> /// </param> /// <param name="domains"><see cref="Watch"/>'s memory domain</param> /// <returns>A brand new <see cref="Watch"/></returns> public static Watch FromString(string line, IMemoryDomains domains) { string[] parts = line.Split(new[] { '\t' }, 6); if (parts.Length < 6) { if (parts.Length >= 3 && parts[2] == "_") { return(SeparatorWatch.Instance); } return(null); } if (long.TryParse(parts[0], NumberStyles.HexNumber, CultureInfo.CurrentCulture, out var address)) { WatchSize size = SizeFromChar(parts[1][0]); WatchDisplayType type = DisplayTypeFromChar(parts[2][0]); bool bigEndian = parts[3] != "0"; MemoryDomain domain = domains[parts[4]]; string notes = parts[5].Trim('\r', '\n'); return(GenerateWatch( domain, address, size, type, bigEndian, notes)); } return(null); }
private void SetTypeSelected(WatchDisplayType type) { foreach (var item in DisplayTypeDropDown.Items) { if (item.ToString() == Watch.DisplayTypeToString(type)) { DisplayTypeDropDown.SelectedItem = item; return; } } }
/// <summary> /// Initializes a new instance of the <see cref="Watch"/> class /// </summary> /// <param name="domain"><see cref="MemoryDomain"/> where you want to track</param> /// <param name="address">The address you want to track</param> /// <param name="size">A <see cref="WatchSize"/> (byte, word, double word)</param> /// <param name="type">How you you want to display the value See <see cref="WatchDisplayType"/></param> /// <param name="bigEndian">Specify the endianess. true for big endian</param> /// <param name="note">A custom note about the <see cref="Watch"/></param> /// <exception cref="ArgumentException">Occurs when a <see cref="WatchDisplayType"/> is incompatible with the <see cref="WatchSize"/></exception> protected Watch(MemoryDomain domain, long address, WatchSize size, WatchDisplayType type, bool bigEndian, string note) { if (IsDisplayTypeAvailable(type)) { _domain = domain; Address = address; Size = size; _type = type; BigEndian = bigEndian; Notes = note; } else { throw new ArgumentException($"{nameof(WatchDisplayType)} {type} is invalid for this type of {nameof(Watch)}", nameof(type)); } }
/// <summary> /// Generates a new <see cref="Watch"/> instance /// Can be either <see cref="ByteWatch"/>, <see cref="WordWatch"/>, <see cref="DWordWatch"/> or <see cref="SeparatorWatch"/> /// </summary> /// <param name="domain">The <see cref="MemoryDomain"/> where you want to watch</param> /// <param name="address">The address into the <see cref="MemoryDomain"/></param> /// <param name="size">The size</param> /// <param name="type">How the watch will be displayed</param> /// <param name="bigEndian">Endianess (true for big endian)</param> /// <param name="note">A custom note about the <see cref="Watch"/></param> /// <param name="value">The current watch value</param> /// <param name="prev">Previous value</param> /// <param name="changeCount">Number of changes occurs in current <see cref="Watch"/></param> /// <returns>New <see cref="Watch"/> instance. True type is depending of size parameter</returns> public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, WatchDisplayType type, bool bigEndian, string note = "", long value = 0, long prev = 0, int changeCount = 0) { return(size switch { WatchSize.Separator => SeparatorWatch.NewSeparatorWatch(note), WatchSize.Byte => new ByteWatch(domain, address, type, bigEndian, note, (byte)value, (byte)prev, changeCount), WatchSize.Word => new WordWatch(domain, address, type, bigEndian, note, (ushort)value, (ushort)prev, changeCount), WatchSize.DWord => new DWordWatch(domain, address, type, bigEndian, note, (uint)value, (uint)prev, changeCount), _ => SeparatorWatch.NewSeparatorWatch(note) });