Ejemplo n.º 1
0
        private void bt_storeSetting_Click(object sender, EventArgs e)
        {
            cardSetting cs = new cardSetting();

            cs.corrFilePatch      = dg.Rows[(int)prm.lCorrect].Cells[1].Value.ToString();
            cs.power              = UInt16.Parse(dg.Rows[(int)prm.lPower].Cells[1].Value.ToString());
            cs.scale              = float.Parse(tb_scale.Text, System.Globalization.NumberStyles.Float, CultureInfo.InvariantCulture); //UInt16.Parse(tb_scale.Text);
            cs.num                = Int16.Parse(tb_devn.Text);
            cs.scriptPath         = dg.Rows[(int)prm.lScript].Cells[1].Value.ToString();                                               //tb_script.Text;
            cs.debug              = cb_printDebug.Checked;
            cs.ignoreLocalSetting = cb_ignoreListSetting.Checked;

            dg.Rows[(int)prm.lJampSize].Cells[1].Value = dg.Rows[(int)prm.lJampSize].Cells[1].Value.ToString().Replace('.', ',');
            dg.Rows[(int)prm.lJampSize].Cells[2].Value = dg.Rows[(int)prm.lJampSize].Cells[2].Value.ToString().Replace('.', ',');
            dg.Rows[(int)prm.lJampSize].Cells[3].Value = dg.Rows[(int)prm.lJampSize].Cells[3].Value.ToString().Replace('.', ',');
            dg.Rows[(int)prm.lMarkSize].Cells[1].Value = dg.Rows[(int)prm.lMarkSize].Cells[1].Value.ToString().Replace('.', ',');
            dg.Rows[(int)prm.lMarkSize].Cells[2].Value = dg.Rows[(int)prm.lMarkSize].Cells[2].Value.ToString().Replace('.', ',');
            dg.Rows[(int)prm.lMarkSize].Cells[3].Value = dg.Rows[(int)prm.lMarkSize].Cells[3].Value.ToString().Replace('.', ',');

            int i = 1;

            cs.style1.lStep      = long.Parse(dg.Rows[(int)prm.lStep].Cells[i].Value.ToString());
            cs.style1.lLaserOn   = long.Parse(dg.Rows[(int)prm.lLaserOn].Cells[i].Value.ToString());
            cs.style1.lLaserOff  = long.Parse(dg.Rows[(int)prm.lLaserOff].Cells[i].Value.ToString());
            cs.style1.lPolygon   = long.Parse(dg.Rows[(int)prm.lPolygon].Cells[i].Value.ToString());
            cs.style1.lMarkDelay = long.Parse(dg.Rows[(int)prm.lMarkDelay].Cells[i].Value.ToString());
            cs.style1.lJampDelay = long.Parse(dg.Rows[(int)prm.lJampDelay].Cells[i].Value.ToString());
            cs.style1.lFps       = long.Parse(dg.Rows[(int)prm.lFps].Cells[i].Value.ToString());
            cs.style1.lQt1       = long.Parse(dg.Rows[(int)prm.lQt1].Cells[i].Value.ToString());
            cs.style1.lQt2       = long.Parse(dg.Rows[(int)prm.lQt2].Cells[i].Value.ToString());
            cs.style1.lJampSize  = (UInt16)float.Parse(dg.Rows[(int)prm.lJampSize].Cells[i].Value.ToString(), System.Globalization.NumberStyles.Float);
            cs.style1.lMarkSize  = (UInt16)float.Parse(dg.Rows[(int)prm.lMarkSize].Cells[i].Value.ToString(), System.Globalization.NumberStyles.Float);
            cs.style1.lPower     = procentToPower(long.Parse(dg.Rows[(int)prm.lPower].Cells[i].Value.ToString()));

            SaveFileDialog openFileDialog1 = new SaveFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter           = "setting (*.ini)|*.ini|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 1;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if ((openFileDialog1.FileName) != null)
                {
                    //tb_script.Text = openFileDialog1.FileName;
                    using (Stream writer = new FileStream(openFileDialog1.FileName, FileMode.Create))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(cardSetting));
                        serializer.Serialize(writer, cs);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void bt_loadSetting_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog openFileDialog1 = new OpenFileDialog();

                openFileDialog1.InitialDirectory = "c:\\";
                openFileDialog1.Filter           = "setting (*.ini)|*.ini|All files (*.*)|*.*";
                openFileDialog1.FilterIndex      = 1;
                openFileDialog1.RestoreDirectory = true;

                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    if ((openFileDialog1.FileName) != null)
                    {
                        //tb_script.Text = openFileDialog1.FileName;
                        using (Stream stream = new FileStream(openFileDialog1.FileName, FileMode.Open))
                        {
                            XmlSerializer serializer = new XmlSerializer(typeof(cardSetting));
                            cardSetting   cs         = (cardSetting)serializer.Deserialize(stream);

                            dg.Rows[(int)prm.lStep].Cells[1].Value      = cs.style1.lStep.ToString();
                            dg.Rows[(int)prm.lLaserOn].Cells[1].Value   = cs.style1.lLaserOn.ToString();
                            dg.Rows[(int)prm.lLaserOff].Cells[1].Value  = cs.style1.lLaserOff.ToString();
                            dg.Rows[(int)prm.lPolygon].Cells[1].Value   = cs.style1.lPolygon.ToString();
                            dg.Rows[(int)prm.lMarkDelay].Cells[1].Value = cs.style1.lMarkDelay.ToString();
                            dg.Rows[(int)prm.lJampDelay].Cells[1].Value = cs.style1.lJampDelay.ToString();
                            dg.Rows[(int)prm.lFps].Cells[1].Value       = cs.style1.lFps.ToString();
                            dg.Rows[(int)prm.lQt1].Cells[1].Value       = cs.style1.lQt1.ToString();
                            dg.Rows[(int)prm.lQt2].Cells[1].Value       = cs.style1.lQt2.ToString();
                            dg.Rows[(int)prm.lJampSize].Cells[1].Value  = cs.style1.lJampSize.ToString();
                            dg.Rows[(int)prm.lMarkSize].Cells[1].Value  = cs.style1.lMarkSize.ToString();
                            dg.Rows[(int)prm.lPower].Cells[1].Value     = cs.style1.lPower.ToString();
                        }
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 3
0
        private void bt_initialise_Click(object sender, System.EventArgs e)
        {
            //check values
            tb_korr_x.Text = tb_korr_x.Text.Replace('.', ',');
            tb_korr_y.Text = tb_korr_y.Text.Replace('.', ',');
            double korr_x, korr_y;

            if (!double.TryParse(tb_korr_x.Text, out korr_x))
            {
                MessageBox.Show("Некорректное значение для поля Корр по X", "",
                                MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000);
                return;
            }
            if (!double.TryParse(tb_korr_y.Text, out korr_y))
            {
                MessageBox.Show("Некорректное значение для поля Корр по Y", "",
                                MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0x40000);
                return;
            }
            /// check value
            ///

            solveMode();
            UInt16      usmode = solveMode();
            cardSetting cs     = new cardSetting();

            cs.mode               = usmode;
            cs.corrFilePatch      = dg.Rows[(int)prm.lCorrect].Cells[1].Value.ToString();
            cs.power              = (UInt16)procentToPower(long.Parse(dg.Rows[(int)prm.lPower].Cells[1].Value.ToString()));
            cs.scale              = float.Parse(tb_scale.Text, System.Globalization.NumberStyles.Float, CultureInfo.InvariantCulture); //UInt16.Parse(tb_scale.Text);
            cs.num                = Int16.Parse(tb_devn.Text);
            cs.scriptPath         = dg.Rows[(int)prm.lScript].Cells[1].Value.ToString();                                               //tb_script.Text;
            cs.debug              = cb_printDebug.Checked;
            cs.ignoreLocalSetting = cb_ignoreListSetting.Checked;
            cs.startLayer         = UInt64.Parse(tb_startLayer.Text);
            cs.gainX              = korr_x;
            cs.gainY              = korr_y;

            dg.Rows[(int)prm.lJampSize].Cells[1].Value = dg.Rows[(int)prm.lJampSize].Cells[1].Value.ToString().Replace('.', ',');
            dg.Rows[(int)prm.lMarkSize].Cells[1].Value = dg.Rows[(int)prm.lMarkSize].Cells[1].Value.ToString().Replace('.', ',');


            int i = 1;

            cs.style1.lStep      = long.Parse(dg.Rows[(int)prm.lStep].Cells[i].Value.ToString());
            cs.style1.lLaserOn   = long.Parse(dg.Rows[(int)prm.lLaserOn].Cells[i].Value.ToString());
            cs.style1.lLaserOff  = long.Parse(dg.Rows[(int)prm.lLaserOff].Cells[i].Value.ToString());
            cs.style1.lPolygon   = long.Parse(dg.Rows[(int)prm.lPolygon].Cells[i].Value.ToString());
            cs.style1.lMarkDelay = long.Parse(dg.Rows[(int)prm.lMarkDelay].Cells[i].Value.ToString());
            cs.style1.lJampDelay = long.Parse(dg.Rows[(int)prm.lJampDelay].Cells[i].Value.ToString());
            cs.style1.lFps       = long.Parse(dg.Rows[(int)prm.lFps].Cells[i].Value.ToString());
            cs.style1.lQt1       = long.Parse(dg.Rows[(int)prm.lQt1].Cells[i].Value.ToString());
            cs.style1.lQt2       = long.Parse(dg.Rows[(int)prm.lQt2].Cells[i].Value.ToString());
            cs.style1.lJampSize  = helpers.speedToJampPeriod(cs.style1.lStep, float.Parse(dg.Rows[(int)prm.lJampSize].Cells[i].Value.ToString(), System.Globalization.NumberStyles.Float), cs.scale);
            cs.style1.lMarkSize  = helpers.speedToJampPeriod(cs.style1.lStep, float.Parse(dg.Rows[(int)prm.lMarkSize].Cells[i].Value.ToString(), System.Globalization.NumberStyles.Float), cs.scale);
            cs.style1.lPower     = procentToPower(long.Parse(dg.Rows[(int)prm.lPower].Cells[i].Value.ToString()));

            cs.workSpacePath = dg.Rows[(int)prm.lWorkSpace].Cells[1].Value.ToString();

            CardEventArgs arg = new CardEventArgs();

            arg.cs = cs;

            cardSetting(this, arg);
            if (SpIceController.isIntiialize)
            {
                Properties.Settings.Default.correctionFile = dg.Rows[(int)prm.lCorrect].Cells[1].Value.ToString();
                Properties.Settings.Default.scriptFile     = dg.Rows[(int)prm.lScript].Cells[1].Value.ToString();;//tb_script.Text;
                Properties.Settings.Default.printDebug     = cb_printDebug.Checked;

                i = 1;
                Properties.Settings.Default.s1Step         = long.Parse(dg.Rows[(int)prm.lStep].Cells[i].Value.ToString());
                Properties.Settings.Default.s1LaserOn      = long.Parse(dg.Rows[(int)prm.lLaserOn].Cells[i].Value.ToString());
                Properties.Settings.Default.s1LaserOff     = long.Parse(dg.Rows[(int)prm.lLaserOff].Cells[i].Value.ToString());
                Properties.Settings.Default.s1PolygonDelay = long.Parse(dg.Rows[(int)prm.lPolygon].Cells[i].Value.ToString());
                Properties.Settings.Default.s1MarkDelay    = long.Parse(dg.Rows[(int)prm.lMarkDelay].Cells[i].Value.ToString());
                Properties.Settings.Default.s1JampDelay    = long.Parse(dg.Rows[(int)prm.lJampDelay].Cells[i].Value.ToString());
                Properties.Settings.Default.s1Fps          = long.Parse(dg.Rows[(int)prm.lFps].Cells[i].Value.ToString());
                Properties.Settings.Default.s1Q1           = long.Parse(dg.Rows[(int)prm.lQt1].Cells[i].Value.ToString());
                Properties.Settings.Default.s1Q2           = long.Parse(dg.Rows[(int)prm.lQt2].Cells[i].Value.ToString());
                Properties.Settings.Default.s1JampSize     = float.Parse(dg.Rows[(int)prm.lJampSize].Cells[i].Value.ToString(), System.Globalization.NumberStyles.Float);
                Properties.Settings.Default.s1MarkSize     = float.Parse(dg.Rows[(int)prm.lMarkSize].Cells[i].Value.ToString(), System.Globalization.NumberStyles.Float);
                Properties.Settings.Default.s1Power        = long.Parse(dg.Rows[(int)prm.lPower].Cells[i].Value.ToString());
                Properties.Settings.Default.gainX          = korr_x;
                Properties.Settings.Default.gainY          = korr_y;
                Properties.Settings.Default.debugOutput    = dg.Rows[(int)prm.lWorkSpace].Cells[i].Value.ToString();
                Properties.Settings.Default.Save();
            }
        }