9.5: FgfsDataHelper


#region Usings

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.Threading;

#endregion

namespace FgfsSharp
{
//TODO: Documentation
class FgfsDataHelper
{
#region Privates

private FgfsDataObject _dataObject;

#endregion

#region Properties

public FgfsDataObject DataObject
{
get { return _dataObject;}
private set {_dataObject = value;}
}

#endregion

#region Constructor

public FgfsDataHelper(FgfsDataObject dataObject)
{
Console.WriteLine("Constructor: FgfsDataHelper");
this.DataObject = dataObject;
}

#endregion

#region Interface Methods

public void UpdateDataObject(StreamReader streamReader)
{
string incoming = streamReader.ReadLine();

//think about using a propery!
string[] plainData = incoming.Split(new char[] { '|' });

lock (DataObject)
{
DataObject.Speed = Convert.ToInt32(plainData[0]);
DataObject.Altitude = Convert.ToInt32(plainData[1]);
DataObject.Roll = Convert.ToInt32(plainData[2]);
DataObject.Pitch = Convert.ToInt32(plainData[3]);
DataObject.HeadingMagN = Convert.ToInt32(plainData[4]);
}
Thread.Sleep(1);
DataObject.NotifyObservers();
}

#endregion

#region Public Method (obsolete)

public void PrintObject()
{
Console.WriteLine("Speed: {0}, Alt: {1}", DataObject.Speed, DataObject.Altitude);
}

#endregion
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: