Пример #1
0
        private string SetExtruderTemperature(string command)
        {
            try
            {
                // M104 S210 or M109 S[temp]
                var sIndex = command.IndexOf('S') + 1;
                ExtruderGoalTemperature = int.Parse(command.Substring(sIndex));
                ExtruderTemperatureChanged?.Invoke(this, null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return("ok\n");
        }
Пример #2
0
        private string SetExtruderTemperature(string command)
        {
            try
            {
                // M104 S210 or M109 S[temp]

                double index = 0;
                GetFirstNumberAfter("T", command, ref index);

                double temp = 0;
                GetFirstNumberAfter("S", command, ref temp);

                if (index > Extruders.Count - 1)
                {
                    // increase the number of extruders
                    var newList = new List <Heater>(Extruders.Count + 1);
                    foreach (var extruder in Extruders)
                    {
                        newList.Add(extruder);
                    }

                    for (int i = Extruders.Count + 1; i < index + 2; i++)
                    {
                        newList.Add(new Heater($"Hotend{i}")
                        {
                            CurrentTemperature = 27
                        });
                    }
                    Extruders = newList;
                }

                Extruders[(int)index].TargetTemperature = temp;
                ExtruderTemperatureChanged?.Invoke(this, null);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return("ok\n");
        }