Пример #1
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (dialogSaveModel.ShowDialog() == DialogResult.OK)
            {
                int filterIndex = dialogSaveModel.FilterIndex;
                try
                {
                    switch (filterIndex)
                    {
                    // OPT model
                    case 2:
                        Model optModel = ModelsConverter.ConvertToOptimization(ModelStorage.Instance.Model);
                        XmlModelProvider.Save(optModel, dialogSaveModel.FileName);
                        break;

                    // OPT.ID model
                    case 1:
                    default:
                        XmlIdentificationModelProvider.Save(ModelStorage.Instance.Model, dialogSaveModel.FileName);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBoxHelper.ShowError(ex.Message);
                }

                dialogSaveModel.FileName = string.Empty;
            }
        }
Пример #2
0
        private void WriteExchangeFile(string exchangeFilePath)
        {
            XmlIdentificationModelProvider.Save(ModelStorage.Instance.Model, exchangeFilePath);

            while (!File.Exists(exchangeFilePath))
            {
                Thread.Sleep(500);
            }
        }
Пример #3
0
        public void Save()
        {
            if (model == null)
            {
                throw new InvalidOperationException("Model is null");
            }

            XmlIdentificationModelProvider.Save(model, modelFile);
        }
Пример #4
0
        public void ProcessModel(object data)
        {
            CancellationToken cancellationToken;

            if (data == null)
            {
                cancellationToken = new CancellationToken(false);
            }
            else
            {
                cancellationToken = (CancellationToken)data;
            }

            if (cancellationToken.IsCancellationRequested)
            {
                OnProcessingComplete(new EventArgs());
                return;
            }

            model = XmlIdentificationModelProvider.Open(optFile);
            if (cancellationToken.IsCancellationRequested)
            {
                OnProcessingComplete(new EventArgs());
                return;
            }

            int maxProgress = model.IdentificationExperiments.Count;

            OnProgressChanged(new ProgressChangedEventArgs(0, maxProgress, 0, "Initialized"));

            int exp = 0;

            foreach (IdentificationExperiment experiment in model.IdentificationExperiments.Values)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }

                ProcessExperiment(experiment);
                OnProgressChanged(new ProgressChangedEventArgs(0, maxProgress, ++exp, "Processed experiment #" + experiment.Number.ToString()));
            }

            if (cancellationToken.IsCancellationRequested)
            {
                OnProcessingComplete(new EventArgs());
                return;
            }

            XmlIdentificationModelProvider.Save(model, optFile);

            OnProcessingComplete(new EventArgs());
        }
Пример #5
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if (dialogSaveModel.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    XmlIdentificationModelProvider.Save(ModelStorage.Instance.Model, dialogSaveModel.FileName);
                }
                catch (Exception ex)
                {
                    MessageBoxHelper.ShowError(ex.Message);
                }

                dialogSaveModel.FileName = string.Empty;
            }
        }