Example #1
0
        // Configure to match Grbl settings (if loaded)
        public bool Config()
        {
            if (GrblSettings.Loaded)
            {
                double val;
                if (!(val = GrblSettings.GetDouble(GrblSetting.JogStepDistance)).Equals(double.NaN))
                {
                    jogDistance[(int)JogMode.Step] = val;
                }
                if (!(val = GrblSettings.GetDouble(GrblSetting.JogSlowDistance)).Equals(double.NaN))
                {
                    jogDistance[(int)JogMode.Slow] = val;
                }
                if (!(val = GrblSettings.GetDouble(GrblSetting.JogFastDistance)).Equals(double.NaN))
                {
                    jogDistance[(int)JogMode.Fast] = val;
                }
                if (!(val = GrblSettings.GetDouble(GrblSetting.JogStepSpeed)).Equals(double.NaN))
                {
                    jogSpeed[(int)JogMode.Step] = val;
                }
                if (!(val = GrblSettings.GetDouble(GrblSetting.JogSlowSpeed)).Equals(double.NaN))
                {
                    jogSpeed[(int)JogMode.Slow] = val;
                }
                if (!(val = GrblSettings.GetDouble(GrblSetting.JogFastSpeed)).Equals(double.NaN))
                {
                    jogSpeed[(int)JogMode.Fast] = val;
                }
            }

            return(GrblSettings.Loaded);
        }
Example #2
0
        public bool Update()
        {
            if (GrblSettings.Loaded)
            {
                xspeed  = GrblSettings.GetDouble(GrblSetting.AxisSetting_XMaxRate);
                xaccel  = GrblSettings.GetDouble(GrblSetting.AxisSetting_XAcceleration);
                zspeed  = GrblSettings.GetDouble(GrblSetting.AxisSetting_ZMaxRate);
                zaccel  = GrblSettings.GetDouble(GrblSetting.AxisSetting_ZAcceleration);
                rpm_min = GrblSettings.GetDouble(GrblSetting.RpmMin);
                rpm_max = GrblSettings.GetDouble(GrblSetting.RpmMax);

                GrblParserState.Get();

                metric = GrblParserState.IsActive("G21") != null;
                if (!xmodelock)
                {
                    xmode = GrblInfo.LatheXMode;
                }

                if (dialog != null)
                {
                    dialog.InitUI(); // use event instead?
                }
            }

            return(GrblSettings.Loaded);
        }
Example #3
0
 void btnSave_Click(object sender, EventArgs e)
 {
     if (curSetting != null)
     {
         curSetting.Assign();
     }
     GrblSettings.Save();
 }
Example #4
0
 void btnReload_Click(object sender, EventArgs e)
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         GrblSettings.Load();
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Example #5
0
 void btnBackup_Click(object sender, EventArgs e)
 {
     GrblSettings.Backup(string.Format("{0}\\settings.txt", Application.StartupPath));
 }
Example #6
0
 void btnReload_Click(object sender, EventArgs e)
 {
     GrblSettings.Load();
 }
Example #7
0
        public static void Load()
        {
            GrblSettings.data.Clear();

            Comms.com.DataReceived += new DataReceivedHandler(GrblSettings.Process);

            Comms.com.PurgeQueue();
            Comms.com.WriteCommand(GrblConstants.CMD_GETSETTINGS);

            while (Comms.com.CommandState != Comms.State.ACK)
            {
                Application.DoEvents();
            }

            Comms.com.DataReceived -= GrblSettings.Process;

            try
            {
                StreamReader file = new StreamReader(string.Format("{0}\\setting_codes_{1}.txt", Application.StartupPath, GrblLanguage.language));

                if (file != null)
                {
                    string line = file.ReadLine();

                    line = file.ReadLine(); // Skip header

                    while (line != null)
                    {
                        string[] columns = line.Split('\t');

                        if (columns.Length >= 6)
                        {
                            DataRow[] rows = GrblSettings.data.Select("Id=" + columns[0]);
                            if (rows.Count() == 1)
                            {
                                rows[0]["Name"]        = columns[1];
                                rows[0]["Unit"]        = columns[2];
                                rows[0]["DataType"]    = columns[3];
                                rows[0]["DataFormat"]  = columns[4];
                                rows[0]["Description"] = columns[5];
                                if (columns.Length >= 7)
                                {
                                    rows[0]["Min"] = parseDouble(columns[6]);
                                }
                                if (columns.Length >= 8)
                                {
                                    rows[0]["Max"] = parseDouble(columns[7]);
                                }
                                if ((string)rows[0]["DataType"] == "float")
                                {
                                    rows[0]["Value"] = GrblSettings.FormatFloat((string)rows[0]["Value"], (string)rows[0]["DataFormat"]);
                                }
                            }
                        }
                        line = file.ReadLine();
                    }
                }
                file.Close();
            }
            catch
            {
            }
            GrblSettings.data.AcceptChanges();
        }
Example #8
0
 public static double GetDouble(GrblSetting key)
 {
     return(GrblSettings.parseDouble(GrblSettings.GetString(key)));
 }