Exemple #1
0
        public PlotViewModel(Models.PlotModel plotModel)
        {
            _uiVisualizerService = ServiceLocator.Default.ResolveType <IUIVisualizerService>();
            _logService          = ServiceLocator.Default.ResolveType <ILoggingService>();
            _kserv       = ServiceLocator.Default.ResolveType <IKmotionService>();
            _plotService = ServiceLocator.Default.ResolveType <IAvailablePlotsService>();
            Messages     = new List <string[]>(1024);
            _dataLog     = new List <string[]>(20000);

            OxyPlotModel = new OxyPlot.PlotModel();
            PlotModel    = plotModel;

            StartStopCommand = new TaskCommand <bool>(OnStartStopCommandExecuteAsync, OnStartStopCommandCanExecute);
            Clear            = new TaskCommand(OnClearExecute);
            ZeroCommand      = new TaskCommand(OnZeroCommandExecuteAsync, OnZeroCommandCanExecute);
            SaveCommand      = new TaskCommand(OnSaveCommandExecuteAsync, OnSaveCommandCanExecute);
            LoadCommand      = new TaskCommand(OnLoadCommandExecuteAsync, OnLoadCommandCanExecute);
            ConfigCommand    = new TaskCommand(OnConfigCommandExecuteAsync, OnConfigCommandCanExecute);
            ExportPngCommand = new TaskCommand(OnExportPngCommandExecute);

            // this instance is created on the UI thread
            //_context = SynchronizationContext.Current;

            _userInterfaceDispatcher = Dispatcher.CurrentDispatcher;
            _cancelSource            = new CancellationTokenSource();

            //syncing plots
            _plotService.AvailablePlots.Add(OxyPlotModel);

            //messages strings or hex dump of memory
            FromHex = false;
        }
Exemple #2
0
        public MainWindowViewModel(IKmotionService kserv, IAvailablePlotsService plotserver, ILoggingService loggingService)
        {
            _kserv          = kserv;
            _plotService    = plotserver;
            _loggingService = loggingService;
            ThreadIDs       = new ObservableCollection <int?>();
            ThreadIDs.Add(null);
            ThreadIDs.Add(1);
            ThreadIDs.Add(2);
            ThreadIDs.Add(3);
            ThreadIDs.Add(4);
            ThreadIDs.Add(5);
            ThreadIDs.Add(6);
            ThreadIDs.Add(7);
            WindowModel = new MainWindowModel();
            FreeThreads = CollectionViewSource.GetDefaultView(ThreadIDs);

            SelectedCProgram = null;

            AddCFile        = new TaskCommand(OnAddCFileExecuteAsync);
            SaveCFile       = new TaskCommand(OnSaveCFileExecuteAsync, OnSaveCFileCanExecute);
            RemoveCFile     = new TaskCommand(OnRemoveCFileExecuteAsync, OnRemoveCFileCanExecute);
            Download        = new TaskCommand(OnDownloadExecuteAsync, OnDownloadCanExecute);
            Execute         = new TaskCommand(OnExecuteExecuteAsync, OnExecuteCanExecute);
            Hault           = new TaskCommand(OnHaultExecuteAsync, OnHaultCanExecute);
            HaultAllCommand = new TaskCommand(OnHaultAllCommandExecuteAsync, OnHaultAllCommandCanExecute);

            SetThreadIDCommand = new Command <int?>(OnSetThreadIDCommandExecuteAsync, OnSetThreadIDCommandCanExecute);

            SaveConfigCommand = new TaskCommand(OnSaveConfigCommandExecuteAsync);
            NewPlotCommand    = new TaskCommand(OnNewPlotCommandExecuteAsync);
            OpenConfigCommand = new TaskCommand(OnOpenConfigCommandExecuteAsync);
            StopStartCommand  = new TaskCommand <bool>(OnStopStartCommandExecuteAsync, OnStopStartCommandCanExecute);
            AboutCommand      = new TaskCommand(OnAboutCommandExecuteAsync);

            _stopwatch = new Stopwatch();
            _stopwatch.Start();
            _statusTimer          = new DispatcherTimer();
            _statusTimer.Interval = TimeSpan.FromMilliseconds(500);
            _statusTimer.Tick    += this.OnMainStatusTick;
            _statusTimer.Start();

            SyncPlotsOnX   = true;
            SaveConfigPath = "";
            //get saved settings, (syncx,y,last saved config..)
            Services.Tracker.Configure(this).Apply();
            if (!string.IsNullOrEmpty(SaveConfigPath))
            {
                try
                {
                    OpenConfiguration(SaveConfigPath);
                }
                catch (Exception ex)
                {
                    LogTo.Error(ex, "Error openeing previous configuration, ignoring.");
                }
            }
        }
Exemple #3
0
 public LoggingService(IKmotionService kserv)
 {
     _kMotionService = kserv;
     _msgQueues      = new List <MessageQueue>();
 }