Save an IRCode state

Supporting Visual Studio on Windows
nek974

Save an IRCode state

Postby nek974 » Sat Apr 16, 2011 1:32 am

Hi everybody, i want to know if its possible to save an IRCode ?
Firstly i've try to save all parameters...I have test something like :

IRCode myCode;
myCode.BitCount = 45;

But VS say me that this parameter is ReadOnly, so I don't know how to save this (for exemple in a file). I've test Serialization too but the IRCode class isn't Serializable.

Someone have an idea?

Thanks!

User avatar
Patrick
Lead Developer
Posts: 3078
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Save an IRCode state

Postby Patrick » Mon Apr 18, 2011 9:17 am

If you want to construct a new IRCode, you need to use one of the constructors - you can't change bit count or code data after the fact.

Code: Select all

IRCode myCode = new IRCode("123456", 45);

-Patrick

bemel
Fresh meat
Posts: 1
Joined: Mon Oct 18, 2010 7:21 pm
Contact:

Re: Save an IRCode state

Postby bemel » Sat Apr 30, 2011 8:22 pm

I tackled this problem a few months ago. The ircode object isn't serializable, as you said. My solution was to make a wrapper class that held the IRCode and IRCodeInfo. I copied each property of IRCode and IRCodeInfo into a custom made serializable class. When my application starts up, the serialized data is loaded and constructs the IRCode and IRCodeInfo from the saved strings and ints.

Variables in my irmapping class should help get you started:

private string _mapName;
private int _mapID;
[NonSerialized]
private IRCode _code;
private DateTime _lastXmit;
[NonSerialized]
private IRCodeInfo _info;
private bool _repeat;
private int _cBitCount;
private byte[] _cData;
private int _iBitCount;
private int _iCarrierFrequency;
private int _iDutyCycle;
private string _iEncoding; // enum type
private int _iGap;
private int[] _iHeader;
private string _iLength; // enum type
private int _iMinRepeat;
private int[] _iOne;
private int[] _iRepeat;
private int _iToggleMaskBitCount;
private byte[] _iToggleMaskData;
private int _iTrail;
private int[] _iZero;

I've been able to map and save IR codes from every type of remote I can find. Don't give up, it is possible to serialize IRCode & IRCodeInfo

Brad


Return to “C#.NET”

Who is online

Users browsing this forum: No registered users and 1 guest