using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace MKLiveView
{
static class Waypoints
{
enum pointType
{
INVALID
= 255,
WP
= 0,
POI
= 1
}
enum status
{
INVALID
= 255,
NEW = 0,
DONE
= 1
}
public static DataRow toDataRow
(byte[]data, DataRow dr
)
{
double longitude
= 0, latitude
= 0, altitude
= 0;
int pstatus
= 0, heading
= 0, tolRadius
= 0, holdTime
= 0, eventFlag
= 0, index
= 0, type
= 0, WPeventChanVal
= 0, altitudeRate
= 0, speed
= 0, camAngle
= 0, autoTrigger
=0;
string name
= "";
if (data
.Length >= 28)
{
int i_32, iVal
;
i_32
= data
[5];
iVal
= i_32
<< 24;
i_32
= data
[4];
iVal
+= i_32
<< 16;
i_32
= data
[3];
iVal
+= i_32
<< 8;
iVal
+= data
[2];
longitude
= (double)iVal
/ Math
.Pow(10,
7);
i_32
= data
[9];
iVal
= i_32
<< 24;
i_32
= data
[8];
iVal
+= i_32
<< 16;
i_32
= data
[7];
iVal
+= i_32
<< 8;
iVal
+= data
[6];
latitude
= (double)iVal
/ Math
.Pow(10,
7);
i_32
= data
[13];
iVal
= i_32
<< 24;
i_32
= data
[12];
iVal
+= i_32
<< 16;
i_32
= data
[11];
iVal
+= i_32
<< 8;
iVal
+= data
[10];
altitude
= (double)iVal
/ Math
.Pow(10,
7);
pstatus
= data
[14];
i_32
= data
[16];
iVal
= i_32
<< 8;
iVal
+= data
[15];
heading
= iVal
;
tolRadius
= data
[17];
holdTime
= data
[18];
eventFlag
= data
[19];
index
= data
[20];
type
= data
[21];
WPeventChanVal
= data
[22];
altitudeRate
= data
[23];
speed
= data
[24];
camAngle
= data
[25];
name
= new string(ASCIIEncoding
.ASCII.GetChars(data,
26,
4)).Trim('\0');
autoTrigger
= data
[30];
dr
.ItemArray = new object[] {data
[1],
((pointType
)type
).ToString(),name,longitude,latitude,altitude,heading,speed,altitudeRate,tolRadius,holdTime,autoTrigger,camAngle,eventFlag,WPeventChanVal,
((status
)pstatus
).ToString() };
return dr
;
}
return null;
}
}
}