using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using IvyBus; using System.Xml.Serialization; using System.IO; namespace SimpleRadar { public partial class FormRadar : Form { static public int COMET_LENGTH = 5; public Dictionary> RadarPlots; public FormRadar() { InitializeComponent(); RadarPlots = new Dictionary>(); } private void FormRadar_Load(object sender, EventArgs e) { IvyBus.ivy.Start(ivyDomain.Domain); Bind(); } private void Bind() { // ajoute la nouvelle regex //TrackMovedEvent Flight=324 CallSign=LB114JQ Ssr=0452 Sector=SL Layers=F,I X=87.00 Y=-128.88 Vx=-197 Vy=265 Afl=195 Rate=2098 Heading=323 GroundSpeed=330 Tendency=1 Time=12:08:32 int regexp_id = IvyBus.ivy.BindMsg(@"^TrackMovedEvent Flight=([0-9]+) CallSign=([a-zA-Z0-9_-]+) Ssr=([0-9]*)[ ]+Sector=(.*) Layers=(.*) X=(.+) Y=(.+) Vx=(.+) Vy=(.+) Afl=([0-9]+) Rate=(-?[0-9]+) Heading=([-\.0-9]+) GroundSpeed=([0-9]+) Tendency=(-?[0-9]) Time=([0-9]+:[0-9]+:[0-9]+)", RecieveIvyMsgTrackMovedEvent, null); regexp_id = IvyBus.ivy.BindMsg(@"SelectionEvent acc=(.*) wp=(.*) role=(.*) Flight=([0-9]+)", SelectedAircraft, null); // TheIvyBus.SendMsg("SelectionEvent acc=bordeaux wp=WP1 role=TC Flight=" + strip.SSR); // int regexp_id1 = IvyBus.BindMsg(@"^ErasmusA Flight=(.*) Callsign=(.*) X=(.*) Y=(.*) Vx=(.*) Vy=(.*) Afl=(.*) Rate=(.*) Heading=(.*) GSpeed=(.*) EraGS=(.*) ManSta=(.*) Time=(.*)", RecieveIvyMsgErasmusSolve); } private void SelectedAircraft(object sender, IvyMessageEventArgs e) { userControlRadarView1.SelectedAircraft = e[3]; userControlRadarView1.Invalidate(); } private void RecieveIvyMsgTrackMovedEvent(object sender, IvyMessageEventArgs e) { //Create new aircraft and store it AircraftPosition pos = new AircraftPosition(); pos.Flight = e[0]; pos.CallSign = e[1]; pos.Ssr = e[2]; pos.Sector = e[3]; pos.Layers = e[4]; pos.X = double.Parse(e[5], IvyBus.Culture); pos.Y = double.Parse(e[6], IvyBus.Culture); pos.Vx = double.Parse(e[7], IvyBus.Culture); pos.Vy = double.Parse(e[8], IvyBus.Culture); pos.AFL = int.Parse(e[9], IvyBus.Culture); pos.Rate = int.Parse(e[10], IvyBus.Culture); pos.Heading = int.Parse(e[11], IvyBus.Culture); pos.GroundSpeed = double.Parse(e[12], IvyBus.Culture); pos.Tendency = int.Parse(e[13], IvyBus.Culture); //Parse the time string sTime = e[14]; string[] time = sTime.Split(':'); pos.Time_Of_Plot = Convert.ToInt32(time[2]) + Convert.ToInt32(time[1]) * 60 + Convert.ToInt32(time[0]) * 3600; AddAircraftPosition(pos); UpdateView(); } private void UpdateView() { userControlRadarView1.UpdateRadar(RadarPlots); } private void AddAircraftPosition(AircraftPosition pos) { if (!RadarPlots.ContainsKey(pos.CallSign)) { //New radar Track if (!RadarPlots.ContainsKey(pos.CallSign)) { RadarPlots[pos.CallSign] = new List(); } } //Test if no more than CometLength Item if (RadarPlots[pos.CallSign].Count > COMET_LENGTH) RadarPlots[pos.CallSign].RemoveAt(0); RadarPlots[pos.CallSign].Add(pos); } } }