Sonntag, 5. September 2010

Um in diesem Forum zu schreiben, bitte registrieren oder anmelden (siehe Link oben rechts auf dieser Seite). Das Registrieren ist kostenlos und wird sofort wirksam.

Forum
 
  Forum  VersatileSerial...  Questions, Requ...  Counter counting words (2 bytes) instead of bytes
vorherige vorherige
 
Nächste deaktiviert
neuer Beitrag 11.05.2009 20:51
  Tom
2 Beiträge
keine Bewertung


Counter counting words (2 bytes) instead of bytes 

Hi,

I need a counter field that counts 2-byte units (words) instead of bytes. How can I accomplish this?

Thanx

Tom

 
neuer Beitrag 12.05.2009 16:37
  christian
16 Beiträge
keine Bewertung


Re: Counter counting words (2 bytes) instead of bytes 

Hi Tom,

you could do that by using the customization facilities, like this:

public class WordLength : VSCustomizableNumBase<ushort>
{
  protected override Int32 GetInt32()
  {
    return Convert.ToInt32(this.value * 2);
  }
  protected override void SetInt32(Int32 value)
  {
    this.value = (ushort)(value / 2);
  }
}

[VSSerializableContainer]
public class MyContainer
{
  [VSSerializableBinary(100, CounterMode = VSCounterMode.BytesStored, CounterMemberSpan = int.MaxValue)]
  private WordLength dgLen = new WordLength();

  [VSSerializableBinary(200)]
  private int someData;

  [VSSerializableBinary(300)]
  private int someMoreData;

}

 
vorherige vorherige
 
Nächste deaktiviert
  Forum  VersatileSerial...  Questions, Requ...  Counter counting words (2 bytes) instead of bytes
Datenschutzerklärung  |  Nutzungsbedingungen
Copyright 2009 by AIT Software GmbH