Exemplo n.º 1
0
        /// <summary>
        /// Initialize the view model.
        /// </summary>
        public ScanAdcpViewModel()
            : base("Scan ADCP")
        {
            // Initialize values
            _events         = IoC.Get <IEventAggregator>();
            _pm             = IoC.Get <PulseManager>();
            _adcpConnection = IoC.Get <AdcpConnection>();

            // Serial Number Generator view model
            SerialNumberGeneratorVM              = IoC.Get <SerialNumberGeneratorViewModel>();
            SerialNumberGeneratorVM.UpdateEvent += SerialNumberGeneratorVM_UpdateEvent;

            // Next command
            NextCommand = ReactiveCommand.Create(this.WhenAny(x => x.IsScanning, x => !x.Value));
            NextCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ModeView)));

            // Back coommand
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Exit coommand
            ExitCommand = ReactiveCommand.Create();
            ExitCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Scan ADCP command
            ScanAdcpCommand = ReactiveCommand.CreateAsyncTask(_ => ScanAdcp());

            InitializeValue();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Intialize the view model.
        /// </summary>
        public CommunicationViewModel()
            : base("Communications")
        {
            // Set Event Aggregator
            _events = IoC.Get <IEventAggregator>();
            _pm     = IoC.Get <PulseManager>();

            // Get the singleton ADCP connection
            _adcpConnection = IoC.Get <AdcpConnection>();

            // Initialize the values
            InitValues();

            // Set the list
            CommPortList = SerialOptions.PortOptions;
            BaudRateList = SerialOptions.BaudRateOptions;

            // Next command
            NextCommand = ReactiveCommand.Create();
            NextCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ScanAdcpView)));

            // Back coommand
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Exit coommand
            ExitCommand = ReactiveCommand.Create();
            ExitCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Scan for ADCP command
            ScanAdcpCommand = ReactiveCommand.Create();
            ScanAdcpCommand.Subscribe(_ => ScanForAdcp());
        }
        /// <summary>
        /// Initialize the view model.
        /// </summary>
        public ZeroPressureSensorViewModel()
            : base("Zero Pressure Sensor")
        {
            // Initialize values
            _events         = IoC.Get <IEventAggregator>();
            _pm             = IoC.Get <PulseManager>();
            _adcpConnection = IoC.Get <AdcpConnection>();

            // Next command
            NextCommand = ReactiveCommand.Create();
            NextCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DeployAdcpView)));

            // Back coommand
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Exit coommand
            ExitCommand = ReactiveCommand.Create();
            ExitCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Zero Pressure sensor command
            ZeroPressureSensorCommand = ReactiveCommand.Create();
            ZeroPressureSensorCommand.Subscribe(_ => ZeroPressureSensor());

            InitializeValue();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initialize the view model.
        /// </summary>
        public VesselMountViewModel()
            : base("Vessel Mount ViewModel")
        {
            // Initialize values
            _events = IoC.Get <IEventAggregator>();
            _events.Subscribe(this);
            _pm = IoC.Get <PulseManager>();

            // Get the singleton ADCP connection
            _adcpConnection = IoC.Get <AdcpConnection>();

            // Get Options
            GetOptions();

            // Set the list
            CommPortList = SerialOptions.PortOptions;
            BaudRateList = SerialOptions.BaudRateOptions;

            // Next command
            NextCommand = ReactiveCommand.Create();
            NextCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.AveragingView)));

            // Back coommand
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Exit coommand
            ExitCommand = ReactiveCommand.Create();
            ExitCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Set the lists
            InitLists();
            InitValues();
        }
        /// <summary>
        /// Initialize the view model.
        /// </summary>
        public AdcpConfigurationViewModel()
            : base("Adcp Configuration")
        {
            // Initialize values
            _events         = IoC.Get <IEventAggregator>();
            _pm             = IoC.Get <PulseManager>();
            _adcpConnection = IoC.Get <AdcpConnection>();

            SubsystemConfigList = new ReactiveList <AdcpSubsystemConfigurationViewModel>();
            BatteryTypeList     = DeploymentOptions.GetBatteryList();

            // Initialize the values
            InitializeValues();

            // Scan ADCP command
            ScanAdcpCommand = ReactiveCommand.CreateAsyncTask(_ => ScanConfiguration());

            // Add Subsystem Configuration
            AddSubsystemCommand = ReactiveCommand.Create();
            AddSubsystemCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.FrequencyView)));

            // Next command
            NextCommand = ReactiveCommand.Create(this.WhenAny(x => x.IsScanning, x => !x.Value));
            NextCommand.Subscribe(_ => NextPage());

            // Back coommand
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Exit coommand
            ExitCommand = ReactiveCommand.Create();
            ExitCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Compass Cal coommand
            CompassCalCommand = ReactiveCommand.Create();
            CompassCalCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.CompassCalView)));

            // Edit the configuration command
            EditCommand = ReactiveCommand.Create();
            EditCommand.Subscribe(param => OnEditCommand(param));

            // Save the commands to a text file
            SaveCmdsCommand = ReactiveCommand.CreateAsyncTask(_ => SaveCommandsToFile());

            // Get the configuration from the project
            GetConfiguation();

            // Update the deployment duration to include all the new configurations
            // The duration needs to be divided amoung all the configuration
            UpdateDeploymentDuration();

            // Update the properites
            UpdateProperties();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initialize values.
        /// </summary>
        public ViewDataBaseViewModel()
        {
            // Project Manager
            _pm     = IoC.Get <PulseManager>();
            _events = IoC.Get <IEventAggregator>();
            _events.Subscribe(this);
            _adcpConn = IoC.Get <AdcpConnection>();

            // Initialize for warning when not recording live data
            IsDisplayRecordingWarning = false;

            // Warning timer
            _warningRecordTimer           = new System.Timers.Timer();
            _warningRecordTimer.Interval  = 5000;               // 5 seconds.
            _warningRecordTimer.Elapsed  += _warningRecordTimer_Elapsed;
            _warningRecordTimer.AutoReset = true;

            // Command to view the ViewData page
            HomeViewCommand = ReactiveCommand.Create();
            HomeViewCommand.Subscribe(_ => IoC.Get <IEventAggregator>().PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Command to view Graphical data
            GraphicalViewCommand = ReactiveCommand.Create();
            GraphicalViewCommand.Subscribe(_ => ActivateItem(IoC.Get <ViewDataBaseGraphicalViewModel>()));

            // Command to view Graphical data
            TextViewCommand = ReactiveCommand.Create();
            TextViewCommand.Subscribe(_ => ActivateItem(IoC.Get <ViewDataBaseTextViewModel>()));

            // Command to view DVL data
            DvlViewCommand = ReactiveCommand.Create();
            DvlViewCommand.Subscribe(_ => ActivateItem(IoC.Get <ViewDataBaseDvlViewModel>()));

            // Command to view Backscatter data
            BackscatterViewCommand = ReactiveCommand.Create();
            BackscatterViewCommand.Subscribe(_ => ActivateItem(IoC.Get <ViewDataBaseBackscatterViewModel>()));

            // Command to view 3D Profile data
            Profile3DViewCommand = ReactiveCommand.Create();
            Profile3DViewCommand.Subscribe(_ => ActivateItem(IoC.Get <ViewDataBaseProfile3DViewModel>()));

            // Command to view Diagnotics data
            DiagnosticViewCommand = ReactiveCommand.Create();
            DiagnosticViewCommand.Subscribe(_ => ActivateItem(IoC.Get <DiagnosticsBaseViewModel>()));

            // Command to view Diagnotics data
            ShipTrackViewCommand = ReactiveCommand.Create();
            ShipTrackViewCommand.Subscribe(_ => ActivateItem(IoC.Get <ValidationTestBaseViewModel>()));

            // Display Graphical view by default
            ActivateItem(IoC.Get <ViewDataBaseGraphicalViewModel>());
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initialize values.
        /// </summary>
        public DownloadDataViewModel()
            : base("DownloadDataViewModel")
        {
            // Update the display
            _displayTimer           = new System.Timers.Timer(500);
            _displayTimer.Elapsed  += _displayTimer_Elapsed;
            _displayTimer.AutoReset = true;
            _displayTimer.Enabled   = true;

            // Initialize values
            _adcpConn = IoC.Get <AdcpConnection>();
            _adcpConn.ReceiveDataEvent += new AdcpConnection.ReceiveDataEventHandler(_adcpConnection_ReceiveDataEvent);
            _pm = IoC.Get <PulseManager>();
            _eventAggregator = IoC.Get <IEventAggregator>();
            _eventAggregator.Subscribe(this);

            // Download values
            _isDownloadingData = false;
            DownloadTimeout    = DOWNLOAD_TIMEMOUT;
            DownloadTotalSpace = "";
            DownloadUsedSpace  = "";
            //DownloadDirectory = Pulse.Commons.GetProjectDefaultFolderPath();
            SetDownloadDirectory();
            _selectAllFiles        = true;
            OverwriteDownloadFiles = true;
            ParseDownloadedData    = false;
            DownloadFileList       = new ObservableCollectionEx <DownloadFile>();
            _downloadFailList      = new List <string>();
            _cancelDownload        = false;

            // Subscribe to recevie download events from the serial port and ethernet
            SubscribeDownloadEvents();

            // Create a wait handle to wait between each download
            _eventWaitDownload = new EventWaitHandle(false, EventResetMode.AutoReset);

            // Create a command to Download the data from the ADCP
            DownloadDataCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.CanDownloadData, x => x.Value),
                                                                  _ => Task.Run(() => DownloadData()));

            // Create a command to cancel the download process
            CancelDownloadCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.CanCancelDownload, x => x.Value),
                                                                    _ => Task.Run(() => CancelDownload()));

            // Create a command to populate the download list
            PopulateDownloadListCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.CanPopulateDownloadList, x => x.Value),
                                                                          _ => Task.Run(() => OnPopulateDownloadList()));

            // Create a command to format the SD card
            FormatSdCardCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.CanFormatSdCard, x => x.Value),
                                                                  _ => Task.Run(() => OnFormatSdCard()));
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initialize the object.
        /// </summary>
        public TerminalNavViewModel(AdcpConnection adcpConn)
            : base("Navigation Terminal")
        {
            // GPS 1
            TerminalGps1VM = new TerminalNmeaViewModel(TerminalNmeaViewModel.TerminalNavType.GPS1, "GPS 1 Serial Port", adcpConn);

            // GPS 2
            TerminalGps2VM = new TerminalNmeaViewModel(TerminalNmeaViewModel.TerminalNavType.GPS2, "GPS 2 Serial Port", adcpConn);

            // NMEA 1
            TerminalNmea1VM = new TerminalNmeaViewModel(TerminalNmeaViewModel.TerminalNavType.NMEA1, "NMEA 1 Serial Port", adcpConn);

            // NMEA 2
            TerminalNmea2VM = new TerminalNmeaViewModel(TerminalNmeaViewModel.TerminalNavType.NMEA2, "NMEA 2 Serial Port", adcpConn);
        }
Exemplo n.º 9
0
            /// <summary>
            /// Initialize
            /// </summary>
            public Adcps()
            {
                // ADCP Connection
                _adcpConn = IoC.Get <AdcpConnection>();;

                Baud         = "";
                Port         = "";
                SerialNumber = "";
                Firmware     = "";
                Hardware     = "";

                // Find ADCP command
                ConnectCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(_ => _._adcpConn,                                                     // Pass the AdcpConnection
                                                                              x => x.Value.IsOpen()),                                               // Verify the Serial port is open
                                                                 _ => Task.Run(() => Connect()));                                                   // Start pinging
            }
Exemplo n.º 10
0
        /// <summary>
        /// Initialize the view model.
        /// </summary>
        public LoadProjectsViewModel()
            : base("Load Projects")
        {
            // Set Event Aggregator
            _events = IoC.Get <IEventAggregator>();
            _pm     = IoC.Get <PulseManager>();

            // Get the singleton ADCP connection
            _adcpConnection = IoC.Get <AdcpConnection>();

            // Wait for decoding to be complete
            _eventWaitImport = new EventWaitHandle(false, EventResetMode.AutoReset);

            // Intialize values
            InitValues();

            // Next command
            NextCommand = ReactiveCommand.Create(this.WhenAny(x => x.SelectedProjectVM, x => x.Value != null));
            NextCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.AdcpConfigurationView)));

            // Back coommand
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Exit coommand
            ExitCommand = ReactiveCommand.Create();
            ExitCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Dialog to import data
            ImportDataCommand = ReactiveCommand.Create(this.WhenAny(x => x.IsProjectLoading, x => !x.Value));
            ImportDataCommand.Subscribe(_ => ImportData());

            // Dialog to import RTB data
            ImportRtbDataCommand = ReactiveCommand.Create(this.WhenAny(x => x.IsProjectLoading, x => !x.Value));
            ImportRtbDataCommand.Subscribe(_ => ImportRTB());

            // Scan for the projects
            Task.Run(() => ScanProjectAsync());
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initialize the view model.
        /// </summary>
        public StorageViewModel()
            : base("Storage")
        {
            // Set Event Aggregator
            _events = IoC.Get <IEventAggregator>();
            _pm     = IoC.Get <PulseManager>();

            // Get the singleton ADCP connection
            _adcpConnection = IoC.Get <AdcpConnection>();

            // Initialize values
            IsLoading = false;

            // Next command
            NextCommand = ReactiveCommand.Create(this.WhenAny(x => x.IsNextAvail, x => x.Value));                           // Check if available
            NextCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.SalinityView)));

            // Back coommand
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Exit coommand
            ExitCommand = ReactiveCommand.Create();
            ExitCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Browse Project Folder command
            BrowseProjectFolderCommand = ReactiveCommand.Create();
            BrowseProjectFolderCommand.Subscribe(param => BrowseProjectFolder(param));

            // Refresh Internal ADCP storage coommand
            RefreshAdcpInternalStorageCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => CheckMemoryCard()));

            // Format SD Card
            FormatInternalStorageCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => FormatInternalStorage()));

            // Initialize values
            InitializeValues();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initialize the view model.
        /// </summary>
        public SimpleCompassCalViewModel()
            : base("Simple Compass Cal")
        {
            // Initialize values
            _eventAggregator     = IoC.Get <IEventAggregator>();
            _adcpConn            = IoC.Get <AdcpConnection>();
            _compassCodec        = new RTI.PniPrimeCompassBinaryCodec();
            _compassDataResponse = new PniPrimeCompassBinaryCodec.PniDataResponse();
            IsAdmin               = Pulse.Commons.IsAdmin();                                        // Set if the user is an admin
            ResultTextFile        = RTI.Pulse.Commons.GetAppStorageDir() + @"\" + DEFAULT_RESULT_TXT;
            _statusBarEvent       = new StatusEvent("");
            _adcpConfig           = new AdcpConfiguration();
            CompassCalButtonLabel = "Start";

            // Start or stop compass calibration
            CompassCalCommand = ReactiveCommand.CreateAsyncTask(_ => _workerCompassCal_DoWork());

            // Create a command to take a sample
            TakeCompassCalSampleCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.CanTakeCompassCalSample, x => x.Value), _ => OnTakeCompassCalSample());

            // Setup the serial port to receive serial port events
            SetupAdcpEvents();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initialize the values.
        /// </summary>
        public DiagnosticsBaseViewModel()
            : base("Diagnostics Model")
        {
            // Initialize the values
            _pm = IoC.Get <PulseManager>();
            _pm.RegisterDisplayVM(this);
            _adcpConn = IoC.Get <AdcpConnection>();
            _events   = IoC.Get <IEventAggregator>();
            _events.Subscribe(this);

            // Initialize the dict
            _diagVMDict = new ConcurrentDictionary <SubsystemDataConfig, DiagnosticsViewModel>();

            // Create the ViewModels based off the AdcpConfiguration
            AddConfigurations();

            Init();

            // Find ADCP command
            FindAdcpCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(_ => _._adcpConn,                                                     // Pass the AdcpConnection
                                                                           x => x.Value != null),                                                // Verify the Serial port is open
                                                              _ => Task.Run(() => FindAdcp()));                                                  // Start pinging
        }
Exemplo n.º 14
0
        /// <summary>
        /// Initialize the view.
        /// </summary>
        public DeployAdcpViewModel()
            : base("Deploy ADCP")
        {
            // Initialize values
            _events            = IoC.Get <IEventAggregator>();
            _pm                = IoC.Get <PulseManager>();
            _adcpConnection    = IoC.Get <AdcpConnection>();
            AdditionalCommands = "";
            IsLoading          = false;

            // Next command
            NextCommand = ReactiveCommand.Create(this.WhenAny(x => x.IsLoading, x => !x.Value));
            NextCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ViewDataView)));

            // Back command
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Exit command
            ExitCommand = ReactiveCommand.Create();
            ExitCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Command to send commands to ADCP
            SendCommandsCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => ConfigureAdcp()));

            // Command to view all the commands
            ViewCommandsCommand = ReactiveCommand.Create();
            ViewCommandsCommand.Subscribe(_ => ShowCommands());

            // Command to zero pressure sensor
            ZeroPressureCommand = ReactiveCommand.Create();
            ZeroPressureCommand.Subscribe(_ => ZeroPressureSensor());

            // Save the commands to a text file
            SaveCmdsCommand = ReactiveCommand.Create();
            SaveCmdsCommand.Subscribe(_ => SaveCommandsToFile());
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initialize values.
        /// </summary>
        public UpdateFirmwareViewModel()
            : base("UpdateFirmwareViewModel")
        {
            // Update the display
            _displayTimer           = new System.Timers.Timer(500);
            _displayTimer.Elapsed  += _displayTimer_Elapsed;
            _displayTimer.AutoReset = true;
            _displayTimer.Enabled   = true;

            // Initialize values
            _adcpConn = IoC.Get <AdcpConnection>();
            _adcpConn.ReceiveDataEvent += new AdcpConnection.ReceiveDataEventHandler(_adcpConnection_ReceiveDataEvent);
            _eventAggregator            = IoC.Get <IEventAggregator>();
            _eventAggregator.Subscribe(this);

            // Subscribe to receive upload events
            SubscribeUploadEvents();

            // Command to get the file to update
            UpdateFirmwareCommand = ReactiveCommand.CreateAsyncTask(_ => OnUpdateFirmware());

            // Create a command to cancel updating the firmware
            CancelUpdateFirmwareCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => OnCancelUpdateFirmware()));
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initalize values.
        /// </summary>
        public NavBarViewModel()
            : base("Nav")
        {
            _pm          = IoC.Get <PulseManager>();
            _events      = IoC.Get <IEventAggregator>();
            _adcpConn    = IoC.Get <AdcpConnection>();
            _IsRecording = false;
            this.NotifyOfPropertyChange(() => this.IsRecording);

            // Set the record image
            SetRecorderImage();

            // Warning timer
            _recorderTimer           = new System.Timers.Timer();
            _recorderTimer.Interval  = 2000;               // 2 seconds.
            _recorderTimer.Elapsed  += _recorderTimer_Elapsed;
            _recorderTimer.AutoReset = true;
            _recorderTimer.Start();

            // Command to go back a view
            BackCommand = ReactiveCommand.Create();
            BackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.Back)));

            // Command to go to Home View
            HomeCommand = ReactiveCommand.Create();
            HomeCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.HomeView)));

            // Command to go to SmartPage View
            ConfigureCommand = ReactiveCommand.Create();
            ConfigureCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.SmartPageView)));

            // Command to go to ViewData View
            ViewDataCommand = ReactiveCommand.Create();
            ViewDataCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ViewDataView)));

            //// Command to go to Playback data
            //PlaybackCommand = ReactiveCommand.Create();
            //PlaybackCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.SelectPlaybackView)));

            // Select a file to playback
            PlaybackCommand = ReactiveCommand.Create();
            PlaybackCommand.Subscribe(_ => PlaybackFile());

            // Command to go to ScreenData View
            ScreenDataCommand = ReactiveCommand.Create();
            ScreenDataCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ScreenDataView)));

            // Command to go to Project View
            ProjectCommand = ReactiveCommand.Create();
            ProjectCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ProjectView)));

            // Command to go to VesselMount Options View
            VmOptionsCommand = ReactiveCommand.Create();
            VmOptionsCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.VesselMountOptionsView)));

            // Command to go to Data Format View
            DataFormatCommand = ReactiveCommand.Create();
            DataFormatCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DataFormatView)));

            // Command to go to VesselMount Options View
            AveragingCommand = ReactiveCommand.Create();
            AveragingCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.AveragingView)));

            // Set the Clock time to Local System time on the ADCP
            StartTestingCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.IsTesting, x => !x.Value),
                                                                  _ => Task.Run(() => On_StartTesting()));

            // Create a command to stop testing
            StopTestingCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.IsTesting, x => x.Value),
                                                                 _ => Task.Run(() => On_StopTesting()));
        }
        /// <summary>
        /// Create a base view for all the ScreenData Views.
        /// </summary>
        public ValidationTestBaseViewModel()
            : base("ValidationTestBaseViewModel")
        {
            // Project Manager
            _pm = IoC.Get <PulseManager>();
            _pm.RegisterDisplayVM(this);
            _events = IoC.Get <IEventAggregator>();
            _events.Subscribe(this);
            _adcpConn = IoC.Get <AdcpConnection>();

            // Set if the user is an admin
            IsAdmin = Pulse.Commons.IsAdmin();
            //LakeTestDirectory = RTI.Pulse.Commons.GetProjectDefaultFolderPath() + @"\LakeTest";
            ValidationTestDirectory = Pulse.Commons.DEFAULT_RECORD_DIR;

            // Initialize the list
            _validationTestVMDict = new ConcurrentDictionary <SubsystemDataConfig, ValidationTestViewModel>();

            IsTesting     = _adcpConn.IsValidationTestRecording;
            IsTankTesting = false;

            // Setup Admin values
            SetupAdminValues();

            // Initialize for warning when not recording live data
            IsDisplayRecordingWarning = false;

            // Warning timer
            _warningRecordTimer           = new System.Timers.Timer();
            _warningRecordTimer.Interval  = 5000;               // 5 seconds.
            _warningRecordTimer.Elapsed  += _warningRecordTimer_Elapsed;
            _warningRecordTimer.AutoReset = true;

            // Set the Clock time to Local System time on the ADCP
            StartTestingCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.IsTesting, x => !x.Value),
                                                                  _ => Task.Run(() => On_StartTesting()));

            // Create a command to stop testing
            StopTestingCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(x => x.IsTesting, x => x.Value),
                                                                 _ => Task.Run(() => On_StopTesting()));

            // Create a command to configure the ADCP for Fresh Water Lake Test
            ConfigureAdcpFreshCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => On_ConfigureAdcpFresh()));

            // Create a command to configure the ADCP for Salt Water Ocean Test
            ConfigureAdcpSaltCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => On_ConfigureAdcpSalt()));

            // Create a command to configure the ADCP for Tank Test
            ConfigureAdcpTankCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => On_ConfigureAdcpTank()));

            // Create a command to configure the ADCP for Ringing Test in tank
            ConfigureAdcpRingingTankCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => On_ConfigureAdcpRingingTank()));

            // Create a command to Start Pinging
            StartPingingCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => StartPingingCommandExec()));

            // Create a command to Stop Pinging
            StopPingingCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => StopPingingCommandExec()));

            // Import commands
            ImportAdcpScriptCommand = ReactiveCommand.CreateAsyncTask(this.WhenAny(_ => _._adcpConn,                                                // Pass the AdcpConnection
                                                                                   x => x.Value != null),                                           // Ensure the connection exist
                                                                      _ => ImportAdcpScript());                                                     // Import the ADCP Script


            // Create the ViewModels based off the AdcpConfiguration
            AddConfigurations();
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initialize the object.
        /// </summary>
        public PlaybackViewModel()
            : base("PlaybackViewModel")
        {
            // Get Project Manager
            _pm     = IoC.Get <PulseManager>();
            _events = IoC.Get <IEventAggregator>();
            _events.Subscribe(this);
            _adcpConn = IoC.Get <AdcpConnection>();

            _buffer = new ConcurrentQueue <PlaybackArgs>();

            IsAdmin = Pulse.Commons.IsAdmin();

            // Get ScreenData VM
            _screenDataVM = IoC.Get <ScreenDataBaseViewModel>();

            // Get Averaging VM
            _averagingVM = IoC.Get <AveragingBaseViewModel>();

            // Set the record image
            SetRecorderImage();

            // Initialize the total number of ensembles
            CurrentFileSize = MathHelper.MemorySizeString(0);

            PlaybackSpeed = DEFAULT_PLAYBACK_SPEED;
            PlaybackIndex = DEFAULT_PLAYBACK_INDEX;
            SetPlaybackSpeedIndicatorImage();

            // Timer to move the slider
            _timer              = new Timer();
            _timer.AutoReset    = true;
            _timer.Interval     = _PlaybackSpeed;
            _timer.Elapsed     += new ElapsedEventHandler(On_TimerElapsed);
            IsLooping           = false;
            IsLoading           = false;
            _isProcessingBuffer = false;

            // Recorder Timer
            _recorderTimer           = new Timer();
            _recorderTimer.AutoReset = true;
            _recorderTimer.Interval  = 2000;
            _recorderTimer.Elapsed  += new ElapsedEventHandler(On_recorderTimerElapsed);
            _recorderTimer.Start();

            // Command to set recording on or off
            RecordCommand = ReactiveCommand.Create();
            RecordCommand.Subscribe(_ => { IsRecordEnabled = !IsRecordEnabled; });

            // Command to begin playing back data
            PlayCommand = ReactiveCommand.Create();                          // Start the playback
            PlayCommand.Subscribe(_ => PlaybackCommandExecute());

            // Command to move the ensemble forward
            StepEnsembleFowardCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => StepEnsembleForward()));

            // Command to move the ensemble backward
            StepEnsembleBackwardCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => StepEnsembleBackward()));

            // Command to increase playback speed
            // Reduce the timer interval
            IncreaseSpeedCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => IncreasePlaybackSpeedCommandExec()));

            // Command to decrease playback speed
            // Reduce the timer interval
            DecreaseSpeedCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => DecreasePlaybackSpeedCommandExec()));

            // Blink Record image in background
            BlinkRecordImageCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => BlinkRecordImage()));

            // Command to display all the data in the project
            DisplayAllDataCommand = ReactiveCommand.CreateAsyncTask(_ => Task.Run(() => DisplayAllData()));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Shutdown the view model.
        /// </summary>
        /// <param name="close"></param>
        void IDeactivate.Deactivate(bool close)
        {
            // Shutdown the pulse manager
            PulseManager pm = IoC.Get <PulseManager>();

            if (pm != null)
            {
                pm.Dispose();
            }

            // Shutdown the singleton HomeViewModels
            HomeViewModel homeVM = IoC.Get <HomeViewModel>();

            if (homeVM != null)
            {
                homeVM.Dispose();
            }

            // Shutdown the singleton ViewDataBaseViewModel
            ViewDataBaseViewModel viewDataVM = IoC.Get <ViewDataBaseViewModel>();

            if (viewDataVM != null)
            {
                viewDataVM.Dispose();
            }

            // Shutdown the singleton PlaybackViewModel
            PlaybackViewModel playbackVM = IoC.Get <PlaybackViewModel>();

            if (playbackVM != null)
            {
                playbackVM.Dispose();
            }

            // Shutdown the singleton ValidationTestViewModel
            ValidationTestViewModel vtVM = IoC.Get <ValidationTestViewModel>();

            if (vtVM != null)
            {
                vtVM.Dispose();
            }

            // Shutdown the singleton CompassCalViewModel
            CompassCalViewModel ccVM = IoC.Get <CompassCalViewModel>();

            if (ccVM != null)
            {
                ccVM.Dispose();
            }

            // Shutdown the singleton ViewDataBaseGraphicalViewModel
            ViewDataBaseGraphicalViewModel vdGraph = IoC.Get <ViewDataBaseGraphicalViewModel>();

            if (vdGraph != null)
            {
                vdGraph.Dispose();
            }

            // Shutdown the singleton ViewDataBaseTextViewModel
            ViewDataBaseTextViewModel vdText = IoC.Get <ViewDataBaseTextViewModel>();

            if (vdText != null)
            {
                vdText.Dispose();
            }

            // Shutdown the singleton ScreenDataBaseViewModel
            ScreenDataBaseViewModel sdVM = IoC.Get <ScreenDataBaseViewModel>();

            if (sdVM != null)
            {
                sdVM.Dispose();
            }

            // Shutdown the singleton AveragingBaseViewModel
            AveragingBaseViewModel abVM = IoC.Get <AveragingBaseViewModel>();

            if (abVM != null)
            {
                abVM.Dispose();
            }

            // Shutdown the singleton ValidationTestBaseViewModel
            ValidationTestBaseViewModel vtbVM = IoC.Get <ValidationTestBaseViewModel>();

            if (vtbVM != null)
            {
                vtbVM.Dispose();
            }

            // Shutdown the singleton DownloadDataViewModel
            DownloadDataViewModel ddVM = IoC.Get <DownloadDataViewModel>();

            if (ddVM != null)
            {
                ddVM.Dispose();
            }

            // Shutdown the singleton UpdateFirmwareViewModel
            UpdateFirmwareViewModel ufVM = IoC.Get <UpdateFirmwareViewModel>();

            if (ufVM != null)
            {
                ufVM.Dispose();
            }

            // Shutdown the singleton CompassUtilityViewModel
            CompassUtilityViewModel cuVM = IoC.Get <CompassUtilityViewModel>();

            if (cuVM != null)
            {
                cuVM.Dispose();
            }

            // Shutdown the singleton RtiCompassCalViewModel
            RtiCompassCalViewModel rtiCcVM = IoC.Get <RtiCompassCalViewModel>();

            if (rtiCcVM != null)
            {
                rtiCcVM.Dispose();
            }

            //// Shutdown the singleton TerminalViewModel
            //TerminalViewModel termVM = IoC.Get<TerminalViewModel>();
            //if (termVM != null)
            //{
            //    termVM.Dispose();
            //}

            //// Shutdown the singleton TerminalAdcpViewModel
            //TerminalAdcpViewModel tadcpVM = IoC.Get<TerminalAdcpViewModel>();
            //if (tadcpVM != null)
            //{
            //    tadcpVM.Dispose();
            //}

            //// Shutdown the singleton TerminalNavViewModel
            //TerminalNavViewModel tnavVM = IoC.Get<TerminalNavViewModel>();
            //if (tnavVM != null)
            //{
            //    tnavVM.Dispose();
            //}

            // Shutdown the singleton AboutViewModel
            AboutViewModel aboutVM = IoC.Get <AboutViewModel>();

            if (aboutVM != null)
            {
                aboutVM.Dispose();
            }

            // Shutdown the singleton VesselMountViewModel
            VesselMountViewModel vmVM = IoC.Get <VesselMountViewModel>();

            if (vmVM != null)
            {
                vmVM.Dispose();
            }

            // Shutdown the singleton VesselMountViewModel
            DataOutputViewModel vmDO = IoC.Get <DataOutputViewModel>();

            if (vmDO != null)
            {
                vmDO.Dispose();
            }

            // Shutdown the singleton VesselMountViewModel
            WpMagDirOutputViewModel vmWMD = IoC.Get <WpMagDirOutputViewModel>();

            if (vmWMD != null)
            {
                vmWMD.Dispose();
            }

            // Shutdown the last active item
            DeactivateItem(ActiveItem, true);

            // MAKE THIS THE LAST THING TO SHUTDOWN
            // Shutdown the ADCP connection
            AdcpConnection adcp = IoC.Get <AdcpConnection>();

            if (adcp != null)
            {
                adcp.Dispose();
            }

            // Shutdown the applicaton and all the threads
            Environment.Exit(Environment.ExitCode);
        }