Example #1
0
        public Anomaly(int timeStep, string description)
        {
            this.TimeStep = timeStep;
            Time          = TimeManagerModel.TimeFormat(timeStep / 10);
            var f = description.Split(',');

            if (f.Length == 2)
            {
                this.feature1 = f[0];
                this.feature2 = f[1];
            }
        }
Example #2
0
        public MainWindow()
        {
            InitializeComponent();
            SetJoystick();
            SetRudder();
            SetThrottle();
            SetPluginsDir();

            // vm = new FlightSimulatorViewModel(new FlightSimulatorModel());

            // create vm's

            MainModel  mainModel = new MainModel();
            GraphModel gModel    = new GraphModel(mainModel);

            graphVM = new GraphViewModel(gModel);
            FlightDataModel fdModel = new FlightDataModel(mainModel);

            flightDataVM = new FlightDataViewModel(fdModel);
            TimeManagerModel tmModel = new TimeManagerModel(mainModel);

            timeManagerVM = new TimeManagerViewModel(tmModel);
            mainVM        = new MainViewModel(mainModel);
            mainModel.SetFlightDataModel(fdModel);
            mainModel.SetGraphModel(gModel);
            mainModel.SetTimeManagerModel(tmModel);

            // data contexts
            tbTime.DataContext     = timeManagerVM;
            sldrTime.DataContext   = mainVM;
            tbHeight.DataContext   = flightDataVM;
            tbAirSpeed.DataContext = flightDataVM;

            CurrCategoryPlot.DataContext           = gModel;
            CurrCorrelatedCategoryPlot.DataContext = gModel;
            CorrelatedAsFuncOfCurrent.DataContext  = gModel;
            AnomaliesTable.DataContext             = gModel;

            File.Copy(PLUGINS_DIR + "/LinearRegression.dll", LibraryManager.LIBRARY_PATH, true);
            File.Copy(PLUGINS_DIR + "/LinearRegression.dll", LibraryManager.LINEAR_LIBRARY_PATH, true);
            File.Copy(PLUGINS_DIR + "/StringWrapper.dll", StringWrapper.STRING_LIBRARY_PATH, true);

            CompositionTarget.Rendering += CompositionTarget_Rendering;

            timeManagerVM.notifyPropertyChanged += (object sender, EventArgs e) =>
            {
                if (e as TimeChangedEventArgs != null)
                {
                    TimeChangedEventArgs args = e as TimeChangedEventArgs;
                    if (args.Info == PropertyChangedEventArgs.InfoVal.TimeChanged)
                    {
                        this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
                        {
                            sldrTime.Value = args.Seconds;
                            tbTime.Text    = args.NewTime;
                        });
                    }
                }
            };

            flightDataVM.notifyPropertyChanged += (object sender, EventArgs e) =>
            {
                if (e as InformationChangedEventArgs != null)
                {
                    InformationChangedEventArgs args = e as InformationChangedEventArgs;
                    if (args.Info == PropertyChangedEventArgs.InfoVal.InfoChanged)
                    {
                        this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
                        {
                            // the last 2 in every formula can be changed to JOYSTICK_RATIO in order to get the sensitivity fit the size of the joystick
                            int leftJoystick = (int)(Canvas.GetLeft(Joystick) + (Joystick.Width - JoystickHandle.Width) / 2 + (Joystick.Width - JoystickHandle.Width) * (args.Aileron) / 2),
                            topJoystick      = (int)(Canvas.GetTop(Joystick) + (Joystick.Height - JoystickHandle.Height) / 2 + (Joystick.Height - JoystickHandle.Height) * (args.Elevator) / 2);
                            Canvas.SetLeft(JoystickHandle, leftJoystick);
                            Canvas.SetTop(JoystickHandle, topJoystick);
                            int leftRudder = (int)(Canvas.GetLeft(RudderLayout) + (RudderLayout.Width - RudderTracker.Width) / 2 + (RudderLayout.Width - RudderTracker.Width) * (args.Rudder) / 2);
                            Canvas.SetLeft(RudderTracker, leftRudder);
                            int topThrottle = (int)(Canvas.GetTop(ThrottleLayout) + (ThrottleLayout.Height - ThrottleTracker.Height) / 2 - (ThrottleLayout.Height - ThrottleTracker.Height) * (args.Throttle) / 2);
                            Canvas.SetTop(ThrottleTracker, topThrottle);

                            tbHeight.Text      = args.Altimeter.ToString();
                            tbAirSpeed.Text    = args.AirSpeed.ToString();
                            angleOfRoll.Angle  = args.Roll;
                            angleOfPitch.Angle = args.Pitch;
                            angleOfYaw.Angle   = args.Yaw;
                            orientation.Angle  = args.Orientation;
                        });
                    }
                }
            };

            mainVM.notifyPropertyChanged += (object sender, EventArgs e) =>
            {
                if (e as XMLFileUploadEventArgs != null)
                {
                    XMLFileUploadEventArgs args = e as XMLFileUploadEventArgs;
                    if (args.Info == PropertyChangedEventArgs.InfoVal.FileUpdated)
                    {
                        foreach (string c in args.Categories)
                        {
                            MenuItem item = new MenuItem
                            {
                                Header = c
                            };
                            item.Click += MenuItem_Click;
                            // mainVM.CategoriesMenu.Add(item);
                            Props.Items.Add(item);
                        }
                    }
                }
                if (e as CSVAnomaliesFileUploadEventArgs != null)
                {
                    CSVAnomaliesFileUploadEventArgs args = e as CSVAnomaliesFileUploadEventArgs;
                    if (args.Info == PropertyChangedEventArgs.InfoVal.FileUpdated)
                    {
                        sldrTime.Maximum = args.Length;
                    }
                }
                // more....
            };
            MessageBox.Show("Welcome to our Flight Tracker\nTo start open flightgear (Make sure you already put your xml inside" +
                            " the protocols folder in the flightgear folder) now click on fly\nNow in the window that will open after you press ok upload all the three files - click on settings" +
                            " and then choose the files to upload (one by one to their category) then click on upload and you are good to go!", "Welcome!");
        }