Wednesday, February 08, 2012

Please register or login (see links at the top-right corner of this page) to post in this Forum. Registration is free and becomes valid immediately.

Forum
 
  Forum  VersatileSerial...  Questions, Requ...  Counter counting words (2 bytes) instead of bytes
Previous Previous
 
Next Disabled
New Post 5/11/2009 9:51 PM
  Tom
2 posts
No Ranking


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

 
New Post 5/12/2009 5:37 PM
  christian
18 posts
No Ranking


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;

}

 
Previous Previous
 
Next Disabled
  Forum  VersatileSerial...  Questions, Requ...  Counter counting words (2 bytes) instead of bytes
Privacy Statement  |  Terms Of Use
Copyright 2011 by AIT Software GmbH