public void AddWatchEntry(WatchEntry Watch)
        {
            ListViewItem item = new ListViewItem();

            item.Text = Watch.Name;
            if (Watch.IndexedX)
            {
                item.Text += ",x";
            }
            if (Watch.IndexedY)
            {
                item.Text += ",y";
            }
            item.SubItems.Add(TypeToString(Watch));
            if (Watch.DisplayMemory)
            {
                item.SubItems.Add("(unread)");
                m_WatchEntries.Add(Watch);
            }
            else if (!Watch.DisplayMemory)
            {
                if (Watch.SizeInBytes == 1)
                {
                    GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(Watch.Address.ToString("x02"));
                    Watch.CurrentValue = data;
                    item.SubItems.Add(data.ToString());
                }
                else if (Watch.SizeInBytes == 2)
                {
                    GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer(Watch.Address.ToString("x04"));
                    Watch.CurrentValue = data;
                    item.SubItems.Add(data.ToString());
                }
                else
                {
                    item.SubItems.Add("(unread)");
                }
            }
            else
            {
                item.SubItems.Add("(unread)");
                m_WatchEntries.Add(Watch);
            }
            item.Tag = Watch;

            listWatch.Items.Add(item);
        }
Beispiel #2
0
    public void UpdateValues()
    {
      if ( InvokeRequired )
      {
        Invoke( new MainForm.ParameterLessCallback( UpdateValues ) );
        return;
      }

      foreach ( var watchEntry in m_WatchEntries )
      {
        ListViewItem itemToModify = null;
        foreach ( ListViewItem item in listWatch.Items )
        {
          WatchEntry oldWatchEntry = (WatchEntry)item.Tag;

          if ( oldWatchEntry == watchEntry )
          {
            itemToModify = item;
            break;
          }
        }
        if ( itemToModify == null )
        {
          itemToModify = new ListViewItem();

          itemToModify.Text = watchEntry.Name;
          if ( watchEntry.IndexedX )
          {
            itemToModify.Text += ",x";
          }
          if ( watchEntry.IndexedY )
          {
            itemToModify.Text += ",y";
          }
          itemToModify.SubItems.Add( TypeToString( watchEntry ) );
          if ( watchEntry.DisplayMemory )
          {
            itemToModify.SubItems.Add( "(unread)" );
          }
          else if ( !watchEntry.DisplayMemory )
          {
            if ( watchEntry.SizeInBytes == 1 )
            {
              GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer( watchEntry.Address.ToString( "x02" ) );
              watchEntry.CurrentValue = data;
              itemToModify.SubItems.Add( data.ToString() );
            }
            else if ( watchEntry.SizeInBytes == 2 )
            {
              GR.Memory.ByteBuffer data = new GR.Memory.ByteBuffer( watchEntry.Address.ToString( "x04" ) );
              watchEntry.CurrentValue = data;
              itemToModify.SubItems.Add( data.ToString() );
            }
          }
          else
          {
            itemToModify.SubItems.Add( "(unread)" );
          }
          itemToModify.Tag = watchEntry;
          listWatch.Items.Add( itemToModify );
        }

        if ( !watchEntry.DisplayMemory )
        {
          switch ( watchEntry.Type )
          {
            case WatchEntry.DisplayType.HEX:
              itemToModify.SubItems[2].Text = "$" + watchEntry.Address.ToString( "x4" );
              break;
            case WatchEntry.DisplayType.DEZ:
              itemToModify.SubItems[2].Text = watchEntry.Address.ToString();
              break;
            case WatchEntry.DisplayType.BINARY:
              itemToModify.SubItems[2].Text = "%" + Convert.ToString( watchEntry.Address, 2 );
              break;
            default:
              itemToModify.SubItems[2].Text = watchEntry.Address.ToString( "x4" );
              break;
          }
        }
      }
    }
Beispiel #3
0
    public void UpdateValue( string WatchVar, bool IndexedX, bool IndexedY, GR.Memory.ByteBuffer Data )
    {
      foreach ( ListViewItem item in listWatch.Items )
      {
        WatchEntry watchEntry = (WatchEntry)item.Tag;

        if ( ( watchEntry.Name == WatchVar )
        &&   ( watchEntry.IndexedX == IndexedX )
        &&   ( watchEntry.IndexedY == IndexedY ) )
        {
          watchEntry.CurrentValue = Data;

          if ( watchEntry.SizeInBytes != watchEntry.CurrentValue.Length )
          {
            Debug.Log( "Watch entry received different size than expected!" );
          }

          if ( watchEntry.CurrentValue.Length == 0 )
          {
            item.SubItems[2].Text = "(unread)";
            continue;
          }

          switch ( watchEntry.Type )
          {
            case WatchEntry.DisplayType.HEX:
              if ( watchEntry.DisplayMemory )
              {
                StringBuilder sb = new StringBuilder();

                sb.Append( "$" );
                if ( watchEntry.BigEndian )
                {
                  for ( int i = 0; i < Data.Length; ++i )
                  {
                    sb.Append( Data.ByteAt( i ).ToString( "x2" ) );
                    if ( i + 1 < Data.Length )
                    {
                      sb.Append( " " );
                    }
                  }
                }
                else
                {
                  for ( int i = 0; i < Data.Length; ++i )
                  {
                    sb.Append( Data.ByteAt( (int)Data.Length - 1 - i ).ToString( "x2" ) );
                    if ( i + 1 < Data.Length )
                    {
                      sb.Append( " " );
                    }
                  }
                }
                item.SubItems[2].Text = sb.ToString();
              }
              else
              {
                item.SubItems[2].Text = "$" + watchEntry.Address.ToString( "x4" );
              }
              break;
            case WatchEntry.DisplayType.DEZ:
              if ( !watchEntry.DisplayMemory )
              {
                item.SubItems[2].Text = watchEntry.Address.ToString();
              }
              else if ( watchEntry.SizeInBytes == 1 )
              {
                item.SubItems[2].Text = Data.ByteAt( 0 ).ToString();
              }
              else if ( watchEntry.BigEndian )
              {
                string totalText = "";
                for ( uint i = 0; i < Data.Length; ++i )
                {
                  totalText += Data.ByteAt( (int)i ).ToString( "d" ) + " ";
                }
                item.SubItems[2].Text = totalText;
              }
              else
              {
                string totalText = "";
                for ( uint i = 0; i < Data.Length; ++i )
                {
                  totalText += Data.ByteAt( (int)Data.Length - 1 - (int)i ).ToString( "d" ) + " ";
                }
                item.SubItems[2].Text = totalText;
              }
              break;
            case WatchEntry.DisplayType.BINARY:
              if ( !watchEntry.DisplayMemory )
              {
                item.SubItems[2].Text = "%" + Convert.ToString( watchEntry.Address, 2 );
              }
              else if ( watchEntry.SizeInBytes == 1 )
              {
                item.SubItems[2].Text = "%" + Convert.ToString( Data.ByteAt( 0 ), 2 );
              }
              else if ( watchEntry.SizeInBytes == 2 )
              {
                item.SubItems[2].Text = "%" + Convert.ToString( Data.UInt16At( 0 ), 2 );
              }
              else
              {
                item.SubItems[2].Text = Data.ToString();
              }
              break;
            default:
              if ( watchEntry.DisplayMemory )
              {
                item.SubItems[2].Text = Data.ByteAt( 0 ).ToString();
              }
              else
              {
                item.SubItems[2].Text = watchEntry.Address.ToString( "x4" );
              }
              break;
          }
        }
      }
    }
Beispiel #4
0
 public static System.UInt32 BCDToNumber(GR.Memory.ByteBuffer bbBuffer)
 {
     return(System.Convert.ToUInt32(bbBuffer.ToString()));
 }
Beispiel #5
0
        private void btnToHex_Click(object sender, EventArgs e)
        {
            GR.Memory.ByteBuffer data = DataFromHex();

            textBinaryData.Text = data.ToString();
        }