コード例 #1
0
        /// <summary>
        ///     Invokes when initialization process is over
        ///     вызывается когда процесс инициализации закончен
        /// </summary>
        public void OnInitialized()
        {
            _settings.Load();

            (new LoggerServiceBase()).LogMessage(" Переход в режим реального времени", LogManager.GetLogger(LogMessageTypes.COMMEN_MESSAGE), LogMessageTypes.COMMEN_MESSAGE);
            if (this.Devices.Count != 0)
            {
                foreach (var runtimelogicaldevice in _devices)
                {
                    (runtimelogicaldevice.Model as IRuntimeDevice).SetUpdatingMode(false);
                }
                return;
            }
            ;
            this._interactionService
            .Interact(ApplicationInteractionProviders.QuestionMessageBoxInteractionProvider,
                      onInitialized: dialog =>
            {
                dialog.Title   = "Перейти в режим конфигурации?";
                dialog.Message = "Программа не сконфигурирована. Перейти в режим конфигурации?";
            },
                      onUninitialized: dialog =>
            {
                if (dialog.Result == MessageBoxResult.YES)
                {
                    SendKeys.SendWait("^{F5}");
                }
            });
        }
コード例 #2
0
 private void OnNavigateToExtraSettingsCommand()
 {
     _settings.Load();
     _interactionService.Interact(ApplicationInteractionProviders.ExtraSettingsInteractionProvider, viewModel =>
     {
         viewModel.Title = "Дополнительные настройки";
         viewModel.AcknowledgeEnabled            = _settings.AcknowledgeEnabled;
         viewModel.FullTimeout                   = _settings.FullTimeoutPeriod;
         viewModel.PartialTimeout                = _settings.PartialTimeoutPeriod;
         viewModel.QueryTimeout                  = _settings.QueryTimeoutPeriod;
         viewModel.MinuteRepeatInterval          = _settings.MillisecondRepeatInterval / (60 * 1000);
         viewModel.NumberOfLightingCommandRepeat = _settings.NumberOfLightingCommandRepeat;
     }, viewModel =>
     {
         if (viewModel.Result == MessageBoxResult.OK)
         {
             _settings.AcknowledgeEnabled            = viewModel.AcknowledgeEnabled;
             _settings.FullTimeoutPeriod             = viewModel.FullTimeout;
             _settings.PartialTimeoutPeriod          = viewModel.PartialTimeout;
             _settings.QueryTimeoutPeriod            = viewModel.QueryTimeout;
             _settings.NumberOfLightingCommandRepeat = viewModel.NumberOfLightingCommandRepeat;
             _settings.MillisecondRepeatInterval     = viewModel.MinuteRepeatInterval * 60 * 1000;
             _settings.Save();
         }
     });
 }
コード例 #3
0
        public MasterViewModel(
            IComService comService,
            IGrblStatus grblStatus,
            ICommandSender commandSender,
            IGrblDispatcher grblDispatcher,
            IApplicationSettingsService applicationSettingsService,
            IGCodeFileService gCodeFileService)
        {
            _grblDispatcher             = grblDispatcher;
            _applicationSettingsService = applicationSettingsService;
            _applicationSettingsService.Upgrade();
            _applicationSettingsService.Load();

            ComConnectionViewModel = new COMConnectionViewModel(comService, applicationSettingsService);
            _comService            = comService;
            _grblStatus            = grblStatus;
            _commandSender         = commandSender;
            _gCodeFileService      = gCodeFileService;

            _grblStatus.GrblStatusModel.MachineStateChanged += GrblStatusModelMachineStateChanged;
            _grblStatus.GrblStatusModel.PropertyChanged     += GrblStatusModelPropertyChanged;
            _comService.ConnectionStateChanged       += ComServiceConnectionStateChanged;
            _commandSender.CommunicationLogUpdated   += CommandSenderCommunicationLogUpdated;
            _commandSender.CommandQueueLengthChanged += CommandSenderCommandQueueLengthChanged;

            _commandSender.FileCommands.CommandList.CollectionChanged += (sender, args) =>
            {
                NotifyOfPropertyChange(() => FileLinesProcessed);
            };

            StartNotifications();
        }
コード例 #4
0
ファイル: StorageService.cs プロジェクト: yinyefeng/Afluistic
        public Notification Save(Statement statement)
        {
            var settingsResult = _applicationSettingsService.Load();

            if (settingsResult.HasErrors)
            {
                return(settingsResult);
            }

            ApplicationSettings settings = settingsResult;
            var path = settings.StatementPath;

            if (path.IsNullOrEmpty())
            {
                return(Notification.ErrorFor(InitializationErrorMessageText, typeof(Statement).GetSingularUIDescription()));
            }
            var result = _serializationService.SerializeToFile(statement, path);

            if (result.HasErrors)
            {
                return(Notification.ErrorFor(SerializationErrorMessageText, typeof(Statement).GetSingularUIDescription(), path, Environment.NewLine, result.Errors));
            }
            return(result);
        }
コード例 #5
0
        private Notification Handle(string[] args)
        {
            if (args.Length == 0)
            {
                _commandHandler.WriteUsage(_systemService.StandardOut);
                return(Notification.Empty);
            }

            var command = _commandHandler.GetMatchingCommand(args);

            if (command == null)
            {
                return(Notification.ErrorFor(DontKnowHowToHandleMessageText, String.Join(" ", args)));
            }
            var executionArguments = new ExecutionArguments
            {
                Args = args.Skip(command.GetCommandWords().Length).ToArray(),
                ApplicationSettings = _applicationSettingsService.Load(),
                Statement           = _storageService.Load()
            };

            var result = _commandHandler.Handle(command, executionArguments);

            if (result.HasErrors)
            {
                return(result);
            }

            if (command.ChangesTheApplicationSettings())
            {
                var saveResult = _applicationSettingsService.Save(executionArguments.ApplicationSettings);
                if (saveResult.HasErrors)
                {
                    return(saveResult);
                }
            }

            if (command.ChangesTheStatement())
            {
                var saveResult = _storageService.Save(executionArguments.Statement);
                if (saveResult.HasErrors)
                {
                    return(saveResult);
                }
            }
            return(result);
        }
コード例 #6
0
ファイル: RuntimeDeviceBase.cs プロジェクト: tomyqg/ULA
        private async void InitializeDriver()
        {
            var driver = await _runtimeModeDriversService
                         .GetDriverById(Guid.Parse(this.DeviceMomento.State.RelatedDriverId));

            _applicationSettingsService.Load();
            DriverMomento = driver.CreateMomento();
            InitFormatters();
            _tcpDeviceConnection = _applicationConnectionService.CreateTcpDeviceConnection(
                DriverMomento.State.GetTcpAddress(), DriverMomento.State.GetTcpPort(),
                _applicationSettingsService.QueryTimeoutPeriod * 1000);
            _tcpDeviceConnection.ConnectionRestoredAction += async() =>
            {
                try
                {
                    _isOnline = true;
                    if (_isConnectionWasOnline)
                    {
                        _connectionLogger.ConnectionResroted(_logger);
                    }
                    _isConnectionWasOnline = true;
                }
                catch
                {
                }
            };

            _tcpDeviceConnection.ConnectionLostAction += () =>
            {
                if (_isOnline)
                {
                    _isDeviceInitialized = false;
                    _connectionLogger.ConnectionLost(_logger);
                    _isOnline = false;
                }
            };
        }