Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2260 | - | 1 | using System; |
2 | using System.Collections.Generic; |
||
3 | using System.Data; |
||
4 | using System.Linq; |
||
5 | using System.Text; |
||
6 | |||
7 | namespace MKLiveView |
||
8 | { |
||
9 | static class Waypoints |
||
10 | { |
||
11 | |||
12 | enum pointType |
||
13 | { |
||
14 | INVALID= 255, |
||
15 | WP = 0, |
||
16 | POI = 1 |
||
17 | } |
||
18 | |||
19 | enum status |
||
20 | { |
||
21 | INVALID= 255, |
||
22 | NEW = 0, |
||
23 | DONE = 1 |
||
24 | } |
||
25 | |||
26 | public static DataRow toDataRow(byte[]data, DataRow dr) |
||
27 | { |
||
28 | double longitude = 0, latitude = 0, altitude = 0; |
||
29 | 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; |
||
30 | string name = ""; |
||
31 | |||
32 | if (data.Length >= 28) |
||
33 | { |
||
34 | int i_32, iVal; |
||
35 | i_32 = data[5]; |
||
36 | iVal = i_32 << 24; |
||
37 | i_32 = data[4]; |
||
38 | iVal += i_32 << 16; |
||
39 | i_32 = data[3]; |
||
40 | iVal += i_32 << 8; |
||
41 | iVal += data[2]; |
||
42 | |||
43 | longitude = (double)iVal / Math.Pow(10, 7); |
||
44 | |||
45 | i_32 = data[9]; |
||
46 | iVal = i_32 << 24; |
||
47 | i_32 = data[8]; |
||
48 | iVal += i_32 << 16; |
||
49 | i_32 = data[7]; |
||
50 | iVal += i_32 << 8; |
||
51 | iVal += data[6]; |
||
52 | latitude = (double)iVal / Math.Pow(10, 7); |
||
53 | |||
54 | |||
55 | i_32 = data[13]; |
||
56 | iVal = i_32 << 24; |
||
57 | i_32 = data[12]; |
||
58 | iVal += i_32 << 16; |
||
59 | i_32 = data[11]; |
||
60 | iVal += i_32 << 8; |
||
61 | iVal += data[10]; |
||
62 | altitude = (double)iVal / Math.Pow(10, 7); |
||
63 | |||
64 | pstatus = data[14]; |
||
65 | |||
66 | i_32 = data[16]; |
||
67 | iVal = i_32 << 8; |
||
68 | iVal += data[15]; |
||
69 | |||
70 | heading = iVal; |
||
71 | tolRadius = data[17]; |
||
72 | holdTime = data[18]; |
||
73 | eventFlag = data[19]; |
||
74 | index = data[20]; |
||
75 | type = data[21]; |
||
76 | WPeventChanVal = data[22]; |
||
77 | altitudeRate = data[23]; |
||
78 | speed = data[24]; |
||
79 | camAngle = data[25]; |
||
80 | |||
81 | name = new string(ASCIIEncoding.ASCII.GetChars(data, 26, 4)).Trim('\0'); |
||
82 | |||
83 | autoTrigger = data[30]; |
||
84 | |||
85 | 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() }; |
||
86 | return dr; |
||
87 | |||
88 | } |
||
89 | return null; |
||
90 | |||
91 | |||
92 | } |
||
93 | |||
94 | |||
95 | } |
||
96 | } |