public bool OpenProgram(string partProgramFile)
        {
            Debug.Assert(!string.IsNullOrEmpty(partProgramFile));
            Debug.Assert(_pcdPartPrograms != null);

            if (_pcdPartProgram != null && !string.IsNullOrEmpty(_pcdPartProgram.FullName))
            {
                if (string.Compare(_pcdPartProgram.FullName, partProgramFile, true) == 0)
                {
                    return(true);
                }
            }

            try
            {
                if (_pcdPartPrograms.Count > 0)
                {
                    bool ret = false;
                    for (int i = _pcdPartPrograms.Count; i > 0; i--)
                    {
                        ret = _pcdPartPrograms.Remove(i);
                    }
                    if (!ret)
                    {
                        return(ret);
                    }
                    if (_pcdPartProgram != null)
                    {
                        Marshal.FinalReleaseComObject(_pcdPartProgram);
                        _pcdPartProgram = null;
                    }
                    GC.Collect();
                    Thread.Sleep(1000);
                }
                Thread.Sleep(1000);
                _pcdPartProgram = null;
                _pcdPartProgram = _pcdPartPrograms.Add(partProgramFile, PCDLRN.UNITTYPE.MM, _pcdApplication.DefaultMachineName, _pcdApplication.DefaultProbeFile);
                if (_pcdPartProgram != null)
                {
                    _pcdPartProgram.ClearAllTADs();
                    _pcdPartProgram.ClearExecutionBlock();
                    _pcdPartProgram.ClearExecutionMarkedSet();
                    _pcdPartProgram.ClearVerifyFeaturesFlag();
                    _pcdPartProgram.RefreshPart();
                }
                Thread.Sleep(1000); // 等待PCDMIS打开程序
                //_isOpened = _pcdPartProgram != null;
            }
            catch (Exception e)
            {
                throw new PcdmisServiceException(e.Message);
            }
            if (_pcdPartProgram == null)
            {
                throw new PcdmisServiceException(messages[3]);
            }
            return(true);
        }
Exemple #2
0
        /// <summary>Display a screen showing the matching part program.
        /// </summary>
        /// <param name="program">The part program to display.</param>
        private void ShowOne(PartProgram program)
        {
            PartProgramPanel.Visible = true;
            NonePanel.Visible = false;
            MultiplePanel.Visible = false;
            LoadButton.Enabled = true;

            if (program == _currentPartProgram) return;
            _currentPartProgram = program;

            PartProgramPanel.Controls.Clear();
            PartProgramBox box = new PartProgramBox();

            PartProgramPanel.Controls.Add(box);
            box.Dock = DockStyle.Fill;
            box.PartProgram = program;

            if (AutoLoadCheckBox.Checked) LoadPartProgram(program);
        }
Exemple #3
0
 /// <summary>Display a screen showing a "multiple matches" screen.
 /// </summary>
 /// <param name="programs">An array of matching part programs.</param>
 /// <remarks>This could be extended in the future to display a list of part programs for the user to choose from.</remarks>
 private void ShowMultiple(PartProgram[] programs)
 {
     PartProgramPanel.Visible = false;
     NonePanel.Visible = false;
     MultiplePanel.Visible = true;
     LoadButton.Enabled = false;
 }
Exemple #4
0
        /// <summary>Saves the configured part programs back to the configuration file.
        /// </summary>
        /// <param name="programs">The programs to save to configuration .</param>
        private void SavePartPrograms(PartProgram[] programs)
        {
            XDocument document = new XDocument();
            document.Add(new XElement("PartPrograms"));

            foreach (PartProgram program in programs)
            {
                document.Root.Add(program.ToXElement());
            }

            File.WriteAllText("PartPrograms.xml", document.ToString());
        }
Exemple #5
0
        private void PromptSetup(PartProgram program)
        {
            if (program.SetupFilename != null)
            {
                string setupPath = Path.Combine(program.SetupPath ?? "", program.SetupFilename ?? "");

                if(PromptPlayRadio.Checked)
                {
                    if (MessageBox.Show(this, "Do you want to play the setup video for this part program?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            PlayVideo(setupPath);
                }
                else if(AutoPlayRadio.Checked)
                {
                    PlayVideo(setupPath);
                }
            }
        }
Exemple #6
0
        /// <summary>Populates the configuration list with part programs.
        /// </summary>
        /// <param name="programs"></param>
        private void LoadPartProgramsIntoList(PartProgram[] programs)
        {
            ConfigurationTable.RowCount = 0;
            ConfigurationTable.Controls.Clear();

            foreach (PartProgram program in programs)
            {
                PartProgramBox box = new PartProgramBox();
                box.PartProgram = program;
                box.Dock = DockStyle.Fill;

                Button delete = new Button();
                delete.Text = "Remove";
                delete.Dock = DockStyle.Fill;
                delete.Tag = program;
                delete.Click += PartProgramDeleteButton_Click;

                ConfigurationTable.RowCount += 1;
                ConfigurationTable.Controls.Add(box);
                ConfigurationTable.Controls.Add(delete);

            }

            ConfigurationTable.RowCount += 1;
        }
Exemple #7
0
        /// <summary>Loads the given part program and plays setup video based on configuration.
        /// </summary>
        /// <param name="program"></param>
        private void LoadPartProgram(PartProgram program)
        {
            try
            {
                string path = Path.Combine(program.ProgramPath ?? _program.DefaultPath, program.ProgramFilename ?? "");
                //FIXME: default to D:\MD1 (or default path from IProgram) if path not specified
                //FIXME: if file not in D:\MD1, copy with appropriate prompting or other configurable action
                if (program.ScheduleProgram)
                {
                    _program.SelectScheduleProgram(path);
                }
                else
                {
                    _program.SelectMainProgram(path);
                }

                PromptSetup(program);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Unable to load file \"" + program.ProgramFilename + "\". Error message: " + ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                BarcodeTextBox.Focus();
            }
        }
 public PartProgramForm()
 {
     InitializeComponent();
     _program = new PartProgram();
 }
        private void UpdateDisplay(PartProgram program)
        {
            this.BeginUpdateDisplay();

            BarcodeTextBox.Text = _program.Barcode;
            ProgramLabel.Text = _program.ProgramFilename;
            ThumbnailLabel.Text = _program.ThumbnailFilename;
            SetupLabel.Text = _program.SetupFilename;
            DescriptionTextBox.Text = _program.Description;
            ScheduleProgramCheckBox.Checked = _program.ScheduleProgram;

            this.EndUpdateDisplay();
        }