public calcVar(AHRS sensor)
{
int i = 0;
InitializeComponent();
this.sensor = sensor;
// Add DataReceived event handler.
sensor.DataReceivedEvent += new DataReceivedDelegate(DataReceivedEventHandler);
data_collection_enabled = false;
next_data_index = 0;
accxdata = new double[SAMPLES];
accydata = new double[SAMPLES];
acczdata = new double[SAMPLES];
magxdata = new double[SAMPLES];
magydata = new double[SAMPLES];
magzdata = new double[SAMPLES];
gyroxdata = new double[SAMPLES];
gyroydata = new double[SAMPLES];
gyrozdata = new double[SAMPLES];
calMat = new double[3, 3];
calMat[0, 0] = 1.0;
calMat[1, 1] = 1.0;
calMat[2, 2] = 1.0;
for (i = 0; i < SAMPLES; i++)
{
accydata[i]=0;
acczdata[i] = 0;
magxdata[i] = 0;
magydata[i] = 0;
magzdata[i] = 0;
gyroxdata[i] = 0;
gyroydata[i] = 0;
gyrozdata[i] = 0;
}
}