2019-07-19 23:59:32 +01:00
|
|
|
|
namespace Fuse
|
|
|
|
|
{
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
public class TestEvent
|
|
|
|
|
{
|
2019-07-20 20:20:25 +01:00
|
|
|
|
private int cycles;
|
|
|
|
|
|
2019-07-19 23:59:32 +01:00
|
|
|
|
public bool Valid { get; private set; } = false;
|
|
|
|
|
|
2019-07-20 20:20:25 +01:00
|
|
|
|
public int Cycles => this.cycles;
|
2019-07-19 23:59:32 +01:00
|
|
|
|
|
|
|
|
|
public string Specifier { get; private set; }
|
|
|
|
|
|
|
|
|
|
public ushort Address { get; private set; } = (ushort)EightBit.Mask.Mask16;
|
|
|
|
|
|
2019-07-20 19:17:08 +01:00
|
|
|
|
public byte Value { get; private set; } = (byte)EightBit.Mask.Mask8;
|
2019-07-19 23:59:32 +01:00
|
|
|
|
|
2019-07-20 19:17:08 +01:00
|
|
|
|
public void Parse(Lines lines)
|
2019-07-19 23:59:32 +01:00
|
|
|
|
{
|
2019-07-20 19:17:08 +01:00
|
|
|
|
this.ParseLine(lines.ReadLine());
|
2019-07-19 23:59:32 +01:00
|
|
|
|
if (!this.Valid)
|
|
|
|
|
{
|
2019-07-20 19:17:08 +01:00
|
|
|
|
lines.UnreadLine();
|
2019-07-19 23:59:32 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ParseLine(string line)
|
|
|
|
|
{
|
|
|
|
|
var split = line.Split(new char[] { ' ', '\t' });
|
|
|
|
|
this.ParseLine(split);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ParseLine(string[] tokens)
|
|
|
|
|
{
|
2019-07-20 20:20:25 +01:00
|
|
|
|
this.Valid = int.TryParse(tokens[0], out this.cycles);
|
|
|
|
|
if (!this.Valid)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-19 23:59:32 +01:00
|
|
|
|
this.Specifier = tokens[1];
|
|
|
|
|
|
|
|
|
|
this.Valid = true;
|
|
|
|
|
switch (this.Specifier)
|
|
|
|
|
{
|
|
|
|
|
case "MR":
|
|
|
|
|
case "MW":
|
|
|
|
|
this.Address = Convert.ToUInt16(tokens[2], 16);
|
|
|
|
|
this.Value = Convert.ToByte(tokens[3], 16);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "MC":
|
|
|
|
|
case "PC":
|
|
|
|
|
this.Address = Convert.ToUInt16(tokens[2], 16);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "PR":
|
|
|
|
|
case "PW":
|
|
|
|
|
this.Address = Convert.ToUInt16(tokens[2], 16);
|
|
|
|
|
this.Value = Convert.ToByte(tokens[3], 16);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
this.Valid = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|