Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void incoming(Byte[] pack)
- {
- /////////////////////////////////////////////////
- /// Receive incoming waypoints/control status
- /////////////////////////////////////////////////
- int count;
- Byte[] opCode = new Byte[2];
- Byte[] latitude = new Byte[8];
- Byte[] longitude = new Byte[8];
- Byte[] altitude = new Byte[8];
- Byte[] status = new Byte[2];
- Byte[] duration = new Byte[2];
- Int16 val;
- double lat;
- double lon;
- double alt;
- Int16 sta;
- Int16 dur;
- opCode[0] = pack[0];
- opCode[1] = pack[1];
- val = BitConverter.ToInt16(opCode, 0);
- switch (val)
- {
- case GNC:
- UpdateContRec("ONLINE");
- break;
- case REQ:
- if(MessageBox.Show("Do you want to relinquish control?",
- "Cockpit Client", MessageBoxButtons.YesNo)== DialogResult.Yes)
- {
- UpdateContRel("OFFLINE");
- response = serverSend.sendPacket(packet.buildPacket(REL));
- }
- break;
- case ADD:
- count = waypointManager.Rows.Count;
- for (int i = 0; i < (count - 1); i++)
- {
- UpdateRemWP(0);
- UpdateRemCombo(0);
- }
- for (int i = 0; val == (Int16)2; i++)
- {
- opCode[0] = pack[0 + (32 * (i+1))];
- opCode[1] = pack[1 + (32 * (i+1))];
- latitude[0] = pack[4 + (32 * i)];
- latitude[1] = pack[5 + (32 * i)];
- latitude[2] = pack[6 + (32 * i)];
- latitude[3] = pack[7 + (32 * i)];
- latitude[4] = pack[8 + (32 * i)];
- latitude[5] = pack[9 + (32 * i)];
- latitude[6] = pack[10 + (32 * i)];
- latitude[7] = pack[11 + (32 * i)];
- longitude[0] = pack[12 + (32 * i)];
- longitude[1] = pack[13 + (32 * i)];
- longitude[2] = pack[14 + (32 * i)];
- longitude[3] = pack[15 + (32 * i)];
- longitude[4] = pack[16 + (32 * i)];
- longitude[5] = pack[17 + (32 * i)];
- longitude[6] = pack[18 + (32 * i)];
- longitude[7] = pack[19 + (32 * i)];
- altitude[0] = pack[20 + (32 * i)];
- altitude[1] = pack[21 + (32 * i)];
- altitude[2] = pack[22 + (32 * i)];
- altitude[3] = pack[23 + (32 * i)];
- altitude[4] = pack[24 + (32 * i)];
- altitude[5] = pack[25 + (32 * i)];
- altitude[6] = pack[26 + (32 * i)];
- altitude[7] = pack[27 + (32 * i)];
- status[0] = pack[28 + (32 * i)];
- status[1] = pack[29 + (32 * i)];
- duration[0] = pack[30 + (32 * i)];
- duration[1] = pack[31 + (32 * i)];
- val = BitConverter.ToInt16(opCode, 0);
- lat = BitConverter.ToDouble(latitude, 0);
- lon = BitConverter.ToDouble(longitude, 0);
- alt = BitConverter.ToDouble(altitude, 0);
- sta = BitConverter.ToInt16(status, 0);
- dur = BitConverter.ToInt16(duration, 0);
- if (alt != 0)
- {
- UpdateCombo(Convert.ToString(i));
- DataGridViewRow row = new DataGridViewRow();
- row.CreateCells(waypointManager);
- row.Cells[0].Value = Convert.ToString(i);
- row.Cells[1].Value = lat + " : " + lon;
- row.Cells[2].Value = Convert.ToString(alt);
- if (sta == 1)
- {
- row.Cells[3].Value = "Hover";
- row.Cells[4].Value = Convert.ToString(dur);
- }
- else if (sta == 0)
- {
- row.Cells[3].Value = "Flyby";
- row.Cells[4].Value = "N/A";
- }
- UpdateWP(row);
- }
- }
- break;
- case REM:
- count = waypointManager.Rows.Count;
- for (int i = 0; i < (count - 1); i++)
- {
- UpdateRemWP(0);
- UpdateRemCombo(0);
- }
- for (int i = 0; val == (Int16)2; i++)
- {
- opCode[0] = pack[0 + (32 * (i + 1))];
- opCode[1] = pack[1 + (32 * (i + 1))];
- latitude[0] = pack[4 + (32 * i)];
- latitude[1] = pack[5 + (32 * i)];
- latitude[2] = pack[6 + (32 * i)];
- latitude[3] = pack[7 + (32 * i)];
- latitude[4] = pack[8 + (32 * i)];
- latitude[5] = pack[9 + (32 * i)];
- latitude[6] = pack[10 + (32 * i)];
- latitude[7] = pack[11 + (32 * i)];
- longitude[0] = pack[12 + (32 * i)];
- longitude[1] = pack[13 + (32 * i)];
- longitude[2] = pack[14 + (32 * i)];
- longitude[3] = pack[15 + (32 * i)];
- longitude[4] = pack[16 + (32 * i)];
- longitude[5] = pack[17 + (32 * i)];
- longitude[6] = pack[18 + (32 * i)];
- longitude[7] = pack[19 + (32 * i)];
- altitude[0] = pack[20 + (32 * i)];
- altitude[1] = pack[21 + (32 * i)];
- altitude[2] = pack[22 + (32 * i)];
- altitude[3] = pack[23 + (32 * i)];
- altitude[4] = pack[24 + (32 * i)];
- altitude[5] = pack[25 + (32 * i)];
- altitude[6] = pack[26 + (32 * i)];
- altitude[7] = pack[27 + (32 * i)];
- status[0] = pack[28 + (32 * i)];
- status[1] = pack[29 + (32 * i)];
- duration[0] = pack[30 + (32 * i)];
- duration[1] = pack[31 + (32 * i)];
- val = BitConverter.ToInt16(opCode, 0);
- lat = BitConverter.ToDouble(latitude, 0);
- lon = BitConverter.ToDouble(longitude, 0);
- alt = BitConverter.ToDouble(altitude, 0);
- sta = BitConverter.ToInt16(status, 0);
- dur = BitConverter.ToInt16(duration, 0);
- if (alt != 0)
- {
- UpdateCombo(Convert.ToString(i));
- DataGridViewRow row = new DataGridViewRow();
- row.CreateCells(waypointManager);
- row.Cells[0].Value = Convert.ToString(i);
- row.Cells[1].Value = lat + " : " + lon;
- row.Cells[2].Value = Convert.ToString(alt);
- if (sta == 1)
- {
- row.Cells[3].Value = "Hover";
- row.Cells[4].Value = Convert.ToString(dur);
- }
- else if (sta == 0)
- {
- row.Cells[3].Value = "Flyby";
- row.Cells[4].Value = "N/A";
- }
- UpdateWP(row);
- }
- }
- break;
- default:
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement