Example #1
0
        private void PrepareForPrinting(JobParams jobParams, FilamentSpool filament, FilamentProfile filamentProfile, bool bHomingRequired)
        {
            var stringList = new List <string>
            {
                string.Format("M106 S170"),
                string.Format("M109 S{0}", filament.filament_temperature),
                string.Format("M106 S255"),
                string.Format("M114"),
                string.Format("M117")
            };

            if (bHomingRequired)
            {
                stringList.Add(string.Format("G91"));
                stringList.Add(string.Format("G0 Z2"));
                stringList.Add(string.Format("G28"));
            }
            else
            {
                stringList.Add(string.Format("G92 X{0} Y{1}", m_fLocationX, m_fLocationY));
                stringList.Add(string.Format("M114"));
            }
            if (jobParams.options.use_heated_bed)
            {
                stringList.Add(string.Format("M190 S{0}", filamentProfile.preprocessor.initialPrint.BedTemperature));
            }

            if (bHomingRequired)
            {
                stringList.Add(string.Format("G91"));
                stringList.Add(string.Format("G0 Z-2"));
            }
            stringList.Add(string.Format("G90"));
            var num = (int)m_oFirmwareController.WriteManualCommands(stringList.ToArray());
        }
Example #2
0
        public override JobController.Result Resume(out List <string> resume_gcode, FilamentSpool spool)
        {
            resume_gcode = null;
            if (spool == null)
            {
                spool = InitialSpoolUsed;
            }

            if (spool == null)
            {
                return(JobController.Result.FAILED_NoFilament);
            }

            if (Status != JobStatus.Paused)
            {
                return(JobController.Result.FAILED_NotPaused);
            }

            if (!m_bSDOnly)
            {
                CurrentPrintJobExtrusion = ExtrusionAtPause;
                Status = JobStatus.Heating;
            }
            return(JobController.Result.Success);
        }
Example #3
0
        public void AssociateFilamentToPrinter(PrinterSerialNumber printer, FilamentSpool spool)
        {
            DisassociateFilamentFromPrinter(printer);
            if (!(spool != null))
            {
                return;
            }

            DisassociateFilamentFromPrinter(spool.filament_uid);
            if (spool.filament_uid == 0U)
            {
                return;
            }

            CurrentFilamentSettings.printerFilamentAssociations.Add(printer, spool.filament_uid);
            for (var index = 0; index < CurrentFilamentSettings.usedFilamentSpools.filament.Count; ++index)
            {
                FilamentSpool other = CurrentFilamentSettings.usedFilamentSpools.filament[index];
                if (spool.Matches(other) && (int)other.filament_uid != (int)spool.filament_uid && FindAssociatedPrinter(other.filament_uid) == PrinterSerialNumber.Undefined)
                {
                    CurrentFilamentSettings.usedFilamentSpools.filament.RemoveAt(index);
                    --index;
                }
            }
            UpdateUsedFilamentSpool(spool);
            SaveSettings();
        }
Example #4
0
        public void CheatCodeEnterCallBack(MultiBoxEditBoxWidget edit)
        {
            if (MainWindow.GetSelectedPrinter() == null)
            {
                return;
            }

            var filamentSpool = new FilamentSpool();

            CurrentDetails.user_filaments = settingsManager.FilamentDictionary.GetFromCheatCode(edit.Text.ToUpperInvariant());
            if (CurrentDetails.user_filaments == null || CurrentDetails.user_filaments.Count == 0)
            {
                messagebox.AddMessageToQueue("Please enter a valid cheat code", PopupMessageBox.MessageBoxButtons.OK);
            }
            else
            {
                FilamentSpool spool = CurrentDetails.user_filaments[0].ToSpool();
                spool.filament_location      = FilamentSpool.Location.External;
                CurrentDetails.current_spool = spool;
                if (CurrentDetails.user_filaments.Count == 1 && CurrentDetails.user_filaments[0].Color == FilamentConstants.ColorsEnum.Other || CurrentDetails.user_filaments.Count > 1)
                {
                    MainWindow.ActivateFrame(Manage3DInkMainWindow.PageID.Page7_FilamentColor, CurrentDetails);
                }
                else
                {
                    spool.filament_temperature = settingsManager.GetFilamentTemperature(spool.filament_type, CurrentDetails.user_filaments[0].Color);
                    if (CurrentDetails.mode == Manage3DInkMainWindow.Mode.AddFilament)
                    {
                        CurrentDetails.mode = Manage3DInkMainWindow.Mode.SetFilamentLocationInsertingNew;
                    }

                    MainWindow.ActivateFrame(Manage3DInkMainWindow.PageID.Page18_FilamentSpoolSize, CurrentDetails);
                }
            }
        }
Example #5
0
        public static void M576GetFilamentInformation(GCode gcode, FirmwareController connection)
        {
            connection.ProcessFilamentDataFromEEPROM();
            FilamentSpool currentFilament = connection.GetCurrentFilament();

            connection.WriteLog(string.Format(">> ok S:{0} P:{1} T:{2} E:{3} I:{4} UID:{5}", (int)currentFilament.filament_color_code, currentFilament.filament_type, currentFilament.filament_temperature - 100, currentFilament.estimated_filament_length_printed, currentFilament.filament_size, currentFilament.filament_uid), Logger.TextType.Read);
        }
Example #6
0
        public void MyButtonCallback(ButtonWidget button)
        {
            PrinterObject selectedPrinter = spooler_connection.SelectedPrinter;

            if (selectedPrinter == null || !selectedPrinter.IsConnected())
            {
                return;
            }

            switch (button.ID)
            {
            case 1000:
                var num1 = (int)selectedPrinter.SendEmergencyStop(null, null);
                break;

            case 1014:
                FilamentSpool currentFilament = selectedPrinter.GetCurrentFilament();
                if (currentFilament == null)
                {
                    messagebox.AddMessageToQueue("Sorry, but you must insert filament first.");
                    break;
                }
                var num2 = FilamentConstants.Temperature.BedDefault(currentFilament.filament_type);
                selectedPrinter.SendCommandAutoLockRelease(new AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, PrinterCompatibleString.Format("M190 S{0}", (object)num2));
                break;

            case 1015:
                selectedPrinter.SendCommandAutoLockRelease(new AsyncCallback(selectedPrinter.ShowLockError), selectedPrinter, "M140 S0");
                break;
            }
        }
Example #7
0
 public Mangage3DInkStageDetails(Manage3DInkMainWindow.Mode mode, FilamentSpool current_spool)
     : this(mode, Manage3DInkMainWindow.PageID.Page0_StartupPage)
 {
     this.mode          = mode;
     this.current_spool = current_spool;
     pageAfterWait      = Manage3DInkMainWindow.PageID.Page0_StartupPage;
 }
Example #8
0
        private void ShowCurrentDetails()
        {
            PrinterObject selectedPrinter = MainWindow.GetSelectedPrinter();

            if (ShowError(selectedPrinter))
            {
                return;
            }

            selectedPrinter.MarkedAsBusy = false;
            FilamentSpool filamentSpool = selectedPrinter.GetCurrentFilament();

            if (filamentSpool != null)
            {
                filamentSpool = new FilamentSpool(filamentSpool);
            }

            if (filamentSpool == null)
            {
                text_title.Text = "3D Ink Currently in use:";
                text_main.Text  = selectedPrinter.isBusy || selectedPrinter.Info.Status == PrinterStatus.Connecting ? (selectedPrinter.Info.current_job == null ? "Unable to read information from the printer because it is working." : "Unable to read information from the printer because it is printing.") : "Looks like your printer doesn't have 3D Ink loaded.";
                DisableAllControls();
                text_main.Visible = true;
            }
            else
            {
                ShowCurrentFilament(selectedPrinter, filamentSpool);
            }
        }
Example #9
0
        public static PrintOptions GetOptions(FilamentSpool info, bool allow_untethered, JobParams.Mode defaultmode)
        {
            var manualPrintOptions = new ManualPrintOptions();

            manualPrintOptions.SetUntetheredOptions(allow_untethered, defaultmode);
            if (info != null)
            {
                manualPrintOptions.SelectFilament(info.filament_type);
                manualPrintOptions.textBoxFilamentTemp.Text = info.filament_temperature.ToString();
            }
            else
            {
                manualPrintOptions.SelectFilament(FilamentSpool.TypeEnum.PLA);
            }

            manualPrintOptions.groupBox1.Enabled           = false;
            manualPrintOptions.textBoxFilamentTemp.Enabled = false;
            manualPrintOptions.groupBox3.Enabled           = false;
            var num = (int)manualPrintOptions.ShowDialog();

            if (!manualPrintOptions.ok)
            {
                PrintOptions options = manualPrintOptions.options;
                options.type = FilamentSpool.TypeEnum.OtherOrUnknown;
                manualPrintOptions.options = options;
            }
            return(manualPrintOptions.options);
        }
Example #10
0
 public override bool Pause(out List <string> pause_gcode, FilamentSpool spool)
 {
     pause_gcode              = null;
     Status                   = JobStatus.Paused;
     ExtrusionAtPause         = CurrentPrintJobExtrusion;
     CurrentPrintJobExtrusion = 0.0f;
     return(true);
 }
Example #11
0
 public override bool Pause(out List <string> pause_gcode, FilamentSpool spool)
 {
     Status      = JobStatus.Paused;
     pause_gcode = new List <string>()
     {
         "M25"
     };
     return(true);
 }
Example #12
0
        public override void MyButtonCallback(ButtonWidget button)
        {
            PrinterObject selectedPrinter = MainWindow.GetSelectedPrinter();

            if (selectedPrinter == null)
            {
                return;
            }

            FilamentSpool currentFilament = selectedPrinter.GetCurrentFilament();

            if (selectedPrinter.IsPausedorPausing && currentFilament != null && currentFilament.filament_location == FilamentSpool.Location.Internal)
            {
                messagebox.AddMessageToQueue("Sorry, but changes cannot be made to internal spools while paused.");
            }
            else
            {
                selectedPrinter.MarkedAsBusy = true;
                switch (button.ID)
                {
                case 19:
                    if (current_spool == null)
                    {
                        messagebox.AddMessageToQueue(new SpoolerMessage(MessageType.UserDefined, "Please insert filament"));
                        break;
                    }
                    if (settingsManager.CurrentAppearanceSettings.ShowAllWarnings)
                    {
                        messagebox.AddMessageToQueue(new SpoolerMessage(MessageType.UserDefined, "Warning. Changing these filament profiles can cause damage to your printer and are for advanced users only."));
                    }

                    MainWindow.ActivateFrame(Manage3DInkMainWindow.PageID.Page9_ChangeFilamentDetails, new Mangage3DInkStageDetails(Manage3DInkMainWindow.Mode.SetDetails, current_spool));
                    break;

                case 20:
                    MainWindow.LockPrinterAndGotoPage(selectedPrinter, Manage3DInkMainWindow.PageID.Page6_IsThereFilament, new Mangage3DInkStageDetails(Manage3DInkMainWindow.Mode.SetDetails));
                    break;

                case 21:
                    MainWindow.LockPrinterAndGotoPage(selectedPrinter, Manage3DInkMainWindow.PageID.Page11_CheatCodePage, new Mangage3DInkStageDetails(Manage3DInkMainWindow.Mode.AddFilament));
                    break;

                case 22:
                    if (!(currentFilament != null))
                    {
                        break;
                    }

                    MainWindow.previous_spool = currentFilament;
                    MainWindow.LockPrinterAndGotoPage(selectedPrinter, Manage3DInkMainWindow.PageID.Page12_RaisingExtruder, new Mangage3DInkStageDetails(Manage3DInkMainWindow.Mode.RemoveFilament, MainWindow.previous_spool));
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
        }
Example #13
0
 public override JobController.Result Resume(out List <string> resume_gcode, FilamentSpool spool)
 {
     Status       = JobStatus.Printing;
     resume_gcode = new List <string>()
     {
         "M24"
     };
     return(JobController.Result.Success);
 }
Example #14
0
        public CommandResult RecoveryPrintFromPowerFailure(bool bHomingRequired)
        {
            if (m_oPrinterPowerRecovery.PrintingStatus == PowerRecovery.PowerResetState.NotPrinting)
            {
                return(CommandResult.Failed_Exception);
            }

            PrinterInfo currentPrinterInfo = m_oFirmwareController.CurrentPrinterInfo;

            if (currentPrinterInfo.persistantData.SavedJobInformation == null || currentPrinterInfo.persistantData.SavedJobInformation.Params == null)
            {
                return(CommandResult.Failed_RequiredDataNotAvailable);
            }

            JobParams     jobParams = currentPrinterInfo.persistantData.SavedJobInformation.Params;
            FilamentSpool filament;

            if (jobParams.filament_temperature > 0 && jobParams.filament_type != FilamentSpool.TypeEnum.OtherOrUnknown && jobParams.filament_type != FilamentSpool.TypeEnum.NoFilament)
            {
                filament = new FilamentSpool(jobParams.filament_type, jobParams.filament_temperature);
            }
            else if (null != currentPrinterInfo.filament_info)
            {
                filament = new FilamentSpool(currentPrinterInfo.filament_info);
            }
            else
            {
                FilamentSpool.TypeEnum filamentTypeFromName = FirmwareSDPrintJob.GetFilamentTypeFromName(jobParams.gcodefile);
                switch (filamentTypeFromName)
                {
                case FilamentSpool.TypeEnum.NoFilament:
                case FilamentSpool.TypeEnum.OtherOrUnknown:
                    return(CommandResult.Failed_RequiredDataNotAvailable);

                default:
                    filament = new FilamentSpool(filamentTypeFromName, FilamentConstants.Temperature.Default(filamentTypeFromName));
                    break;
                }
            }
            var filamentProfile = FilamentProfile.CreateFilamentProfile(currentPrinterInfo.filament_info, m_oFirmwareController.MyPrinterProfile);

            PrepareForPrinting(jobParams, filament, filamentProfile, bHomingRequired || float.IsNaN(m_fLocationX) || float.IsNaN(m_fLocationY));
            CommandResult commandResult = PowerRecovery.PowerResetState.PowerFailureSDPrint != m_oPrinterPowerRecovery.PrintingStatus ? RecoverSpooledPrint(currentPrinterInfo.persistantData.SavedJobInformation) : RecoverSDPrint(jobParams);

            if (commandResult == CommandResult.Success)
            {
                var num = (int)ClearPowerRecoveryFault(true);
            }
            else
            {
                m_oFirmwareController.SendEmergencyStop();
            }

            return(commandResult);
        }
Example #15
0
File: Printer.cs Project: urish/M3D
        public SpoolerResult SetFilamentInfo(AsyncCallback callback, object state, FilamentSpool info)
        {
            if (info == null)
            {
                return(SetFilamentToNone(callback, state));
            }

            current_spool    = new FilamentSpool(info);
            spool_up_to_date = true;
            return(SendRPCToSpooler(callback, state, "SetFilamentInformation", (object)info));
        }
Example #16
0
        public CommandResult SetFilamentInformation(FilamentSpool filament)
        {
            FirmwareController firmwareController = GetFirmwareController();

            if (firmwareController == null)
            {
                return(CommandResult.Failed_NotInFirmware);
            }

            firmwareController.SetFilamentInformation(filament, true);
            return(CommandResult.Success);
        }
Example #17
0
        public override void OnUpdate()
        {
            if (Visible)
            {
                try
                {
                    PrinterObject selectedPrinter = MainWindow.GetSelectedPrinter();
                    DisableAllControls();
                    ShowCurrentDetails();
                    if (selectedPrinter == null)
                    {
                        return;
                    }

                    if (!IsPrinterInErrorState)
                    {
                        FilamentSpool currentFilament = selectedPrinter.GetCurrentFilament();
                        current_spool = !(currentFilament != null) || currentFilament.filament_type == FilamentSpool.TypeEnum.NoFilament ? null : new FilamentSpool(currentFilament);
                        if (!selectedPrinter.isBusy)
                        {
                            if (current_spool == null)
                            {
                                correct_button.Visible  = true;
                                correct_button.Enabled  = true;
                                add_button.Visible      = true;
                                add_button.Enabled      = true;
                                settings_button.Visible = true;
                                settings_button.Enabled = true;
                            }
                            else
                            {
                                correct_button.Visible  = true;
                                remove_button.Enabled   = true;
                                remove_button.Visible   = true;
                                settings_button.Enabled = true;
                                settings_button.Visible = true;
                            }
                        }
                        else
                        {
                            progress_busy.Visible = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
            base.OnUpdate();
        }
Example #18
0
        public bool Pause(out List <string> pause_gcode, FilamentSpool spool)
        {
            pause_gcode = null;
            AbstractJob jobImplementation = MyJobImplementation;

            if (jobImplementation == null || jobImplementation.Status == JobStatus.Paused || IsSavingToSD)
            {
                return(false);
            }

            job_timer.Stop();
            var flag = jobImplementation.Pause(out pause_gcode, spool);

            if (flag)
            {
                if (pause_gcode == null)
                {
                    pause_gcode = new List <string>();
                }

                var      num1 = 90f;
                var      num2 = 1800f;
                Vector2D cornerPositionBoxTop = m_oParentFirmwareController.MyPrinterProfile.PrinterSizeConstants.BackCornerPositionBoxTop;
                string   str;
                if (m_oParentFirmwareController.CurrentPrinterInfo.extruder.Temperature > 0.0)
                {
                    m_fRetractionAtPause = !(null != spool) || spool.filament_type == FilamentSpool.TypeEnum.NoFilament ? 10f : FilamentProfile.CreateFilamentProfile(spool, (PrinterProfile)m_oParentFirmwareController.MyPrinterProfile).preprocessor.initialPrint.PrimeAmount;
                    str = PrinterCompatibleString.Format("G0 Z{0} F{1} E-{2}", 8f, num1, m_fRetractionAtPause);
                }
                else
                {
                    m_fRetractionAtPause = 0.0f;
                    str = PrinterCompatibleString.Format("G0 Z{0} F{1}", 8f, num1);
                }
                pause_gcode.AddRange(new string[7]
                {
                    "G4 S0",
                    "M114",
                    "G91",
                    str,
                    "G90",
                    PrinterCompatibleString.Format("G0 X{0} Y{1} F{2}", (object)cornerPositionBoxTop.x, (object)cornerPositionBoxTop.y, (object)num2),
                    "M104 S0"
                });
                m_oParentFirmwareController.OnGotUpdatedPosition += new ScriptCallback(OnReceivedUpdatedPosition);
                m_bUpdatedDataReceivedAfterPause = false;
            }
            return(flag);
        }
Example #19
0
 public void GenerateSlicerSettings(PrinterObject printer, PrinterView printerview)
 {
     settings = new M3D.Slicer.General.PrintSettings();
     settings.SetPrintDefaults();
     if (printer != null)
     {
         FilamentSpool currentFilament = printer.GetCurrentFilament();
         settings.filament_info = currentFilament;
         if (currentFilament.filament_type == FilamentSpool.TypeEnum.HIPS)
         {
             settings.filament_info.filament_type = FilamentSpool.TypeEnum.ABS;
         }
     }
     settings.transformation = printerview.GetObjectSlicerTransformation();
 }
Example #20
0
 public AbstractJob(JobParams jobParams, string user, InternalPrinterProfile printerProfile)
 {
     MyPrinterProfile          = printerProfile;
     Status                    = JobStatus.Queued;
     PreviewImageFileName      = "null";
     jobDetails                = new JobDetails();
     Details.jobParams         = jobParams;
     Details.bounds            = new BoundingBox(float.MaxValue, float.MaxValue, float.MaxValue, float.MinValue, float.MinValue, float.MinValue);
     Details.ideal_temperature = 0;
     User             = user;
     job_begin_timer  = new Stopwatch();
     InitialSpoolUsed = new FilamentSpool
     {
         filament_temperature = jobParams.filament_temperature,
         filament_type        = jobParams.filament_type
     };
 }
Example #21
0
        private void EvaluateRemainingFilament()
        {
            var           num          = 0.75f * CurrentJobDetails.settings.filament_info.GetMaxFilamentBySpoolSize();
            FilamentSpool filamentInfo = CurrentJobDetails.settings.filament_info;

            if (settings_manager.CurrentFilamentSettings.TrackFilament && filamentInfo.estimated_filament_length_printed >= (double)num && CurrentJobDetails.Estimated_Filament < filamentInfo.GetMaxFilamentBySpoolSize() - (double)filamentInfo.estimated_filament_length_printed)
            {
                message_box.AddMessageToQueue(Locale.GlobalLocale.T("T_PrintDialog_LowFilament"), PopupMessageBox.MessageBoxButtons.YESNO, new PopupMessageBox.OnUserSelectionDel(OrderFilamentCallBack));
            }
            else if (settings_manager.CurrentFilamentSettings.TrackFilament && CurrentJobDetails.Estimated_Filament > filamentInfo.GetMaxFilamentBySpoolSize() - (double)filamentInfo.estimated_filament_length_printed)
            {
                message_box.AddMessageToQueue(Locale.GlobalLocale.T("T_PrintDialog_LowFilamentContinue"), PopupMessageBox.MessageBoxButtons.YESNO, new PopupMessageBox.OnUserSelectionDel(ContinuePrintCallBack));
            }
            else
            {
                PrepareToStartPrint();
            }
        }
Example #22
0
File: Printer.cs Project: urish/M3D
        public FilamentSpool GetCurrentFilament()
        {
            var filamentSpool = (FilamentSpool)null;

            lock (spool_lock)
            {
                if (current_spool != null)
                {
                    filamentSpool = new FilamentSpool(current_spool);
                }
            }
            if (filamentSpool != null && filamentSpool.filament_type == FilamentSpool.TypeEnum.NoFilament)
            {
                return(null);
            }

            return(filamentSpool);
        }
        public void TemperatureEditEnterCallback(EditBoxWidget edit)
        {
            PrinterObject selectedPrinter = MainWindow.GetSelectedPrinter();

            if (selectedPrinter == null)
            {
                return;
            }

            if (int.TryParse(custom_temperature_edit.Text.ToString(), out var result))
            {
                var min  = (int)FilamentConstants.Temperature.MaxMinForFilamentType(CurrentDetails.current_spool.filament_type).Min;
                var num1 = 260;
                if (result >= min && result <= num1)
                {
                    messagebox.AddMessageToQueue(string.Format("Changing the current temperature settings from {0} to {1}.", CurrentDetails.current_spool.filament_temperature, custom_temperature_edit.Text), PopupMessageBox.MessageBoxButtons.OK);
                    var filamentSpool = new FilamentSpool(CurrentDetails.current_spool)
                    {
                        filament_temperature = result
                    };
                    CurrentDetails.current_spool           = filamentSpool;
                    CurrentDetails.waitCondition           = new Mangage3DInkStageDetails.WaitCondition(WaitCondition);
                    CurrentDetails.pageAfterWait           = Manage3DInkMainWindow.PageID.Page0_StartupPage;
                    FilamentWaitingPage.CurrentWaitingText = "Please wait. The printer is busy perfoming the requested actions.";
                    settingsManager.FilamentDictionary.AddCustomTemperature(filamentSpool.filament_type, (FilamentConstants.ColorsEnum)Enum.ToObject(typeof(FilamentConstants.ColorsEnum), filamentSpool.filament_color_code), filamentSpool.filament_temperature);
                    MainWindow.ActivateFrame(Manage3DInkMainWindow.PageID.Page8_WaitingPage, CurrentDetails);
                    var num2 = (int)selectedPrinter.AcquireLock(new M3D.Spooling.Client.AsyncCallback(SetFilamentAfterLock), selectedPrinter);
                }
                else
                {
                    messagebox.AddMessageToQueue(new SpoolerMessage(MessageType.UserDefined, "Please enter a temperature from " + min + " to " + num1));
                }
            }
            else
            {
                messagebox.AddMessageToQueue(new SpoolerMessage(MessageType.UserDefined, "Please enter a valid temperature value"));
            }
        }
Example #24
0
        public void CheckUpdatedFilamentProfile(FilamentProfile.TypeColorKey key, FilamentProfile.CustomOptions new_data)
        {
            try
            {
                if (key.type == FilamentSpool.TypeEnum.NoFilament)
                {
                    return;
                }

                foreach (Printer printer in PrintSpoolerClient)
                {
                    FilamentSpool currentFilament = printer.GetCurrentFilament();
                    if (currentFilament != null && currentFilament.filament_type != FilamentSpool.TypeEnum.NoFilament && (currentFilament.filament_type == key.type && (FilamentConstants.ColorsEnum)currentFilament.filament_color_code == key.color))
                    {
                        currentFilament.filament_temperature = new_data.temperature;
                        var num = (int)printer.AcquireLock(new M3D.Spooling.Client.AsyncCallback(OnFilamentUpdateLock), new SpoolerConnection.UpdateFilamentData((IPrinter)printer, currentFilament));
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #25
0
        public void UpdateUsedFilamentSpool(FilamentSpool spool)
        {
            if (!(spool != null))
            {
                return;
            }

            FilamentSpool usedSpool = FindUsedSpool(spool.filament_uid);

            if (usedSpool == null)
            {
                CurrentFilamentSettings.usedFilamentSpools.filament.Add(spool);
            }
            else
            {
                if (spool.estimated_filament_length_printed <= (double)usedSpool.estimated_filament_length_printed)
                {
                    return;
                }

                usedSpool.estimated_filament_length_printed = spool.estimated_filament_length_printed;
            }
        }
Example #26
0
        private void ShowCurrentFilament(PrinterObject printer, FilamentSpool current_spool)
        {
            text_title.Text             = "3D Ink Currently in use:\n\n" + FilamentProfile.GenerateSpoolName(current_spool, true);
            text_temperature_value.Text = current_spool.filament_temperature.ToString() + " Degrees C";
            FilamentConstants.Branding brandingFrom = FilamentConstants.GetBrandingFrom(current_spool.filament_type, (FilamentConstants.ColorsEnum)current_spool.filament_color_code);
            text_material_value.Text       = brandingFrom == FilamentConstants.Branding.Other ? FilamentConstants.TypesToString(current_spool.filament_type) : FilamentConstants.TypesToString(current_spool.filament_type) + " " + FilamentConstants.BrandingToString(brandingFrom);
            text_color_value.Text          = FilamentConstants.ColorsToString((FilamentConstants.ColorsEnum)current_spool.filament_color_code);
            text_main.Text                 = "";
            text_3dInkAmount_value.Text    = current_spool.estimated_filament_length_printed.ToString("0.00");
            text_temperature_value.Visible = true;
            text_material_value.Visible    = true;
            text_color_value.Visible       = true;
            text_temperature.Visible       = true;
            text_material.Visible          = true;
            text_color.Visible             = true;
            if (!settingsManager.CurrentFilamentSettings.TrackFilament)
            {
                return;
            }

            text_3dInkAmount_value.Visible = true;
            text_3dInkAmount.Visible       = true;
        }
Example #27
0
        public JobController.Result Resume(out List <string> resume_gcode, FilamentSpool spool)
        {
            resume_gcode = null;
            AbstractJob jobImplementation = MyJobImplementation;

            if (jobImplementation == null)
            {
                return(JobController.Result.FAILED_Create);
            }

            JobController.Result result = jobImplementation.Resume(out List <string> resume_gcode1, spool);
            if (result == JobController.Result.Success)
            {
                var num1 = !(null != spool) || spool.filament_type == FilamentSpool.TypeEnum.NoFilament ? byte.MaxValue : FilamentProfile.CreateFilamentProfile(spool, m_oParentFirmwareController.MyPrinterProfile).preprocessor.initialPrint.StartingFanValue;
                var num2 = 90f;
                resume_gcode = new List <string>()
                {
                    PrinterCompatibleString.Format("M106 S{0}", (object)num1),
                    PrinterCompatibleString.Format("M109 S{0}", (object)spool.filament_temperature)
                };
                if (m_bUpdatedDataReceivedAfterPause)
                {
                    resume_gcode.Add("G90");
                    resume_gcode.Add(PrinterCompatibleString.Format("G0 X{0} Y{1} F{2}", m_v3DeExtruderLocationAtPause.pos.x, m_v3DeExtruderLocationAtPause.pos.y, num2));
                    resume_gcode.Add(PrinterCompatibleString.Format("G0 Z{0} F{1}", m_v3DeExtruderLocationAtPause.pos.z, num2));
                    resume_gcode.Add(PrinterCompatibleString.Format("G92 E{0}", (object)(float)(m_v3DeExtruderLocationAtPause.e - (double)m_fRetractionAtPause)));
                }
                if (resume_gcode1 != null && resume_gcode1.Count > 0)
                {
                    resume_gcode.AddRange(resume_gcode1);
                }

                job_timer.Start();
            }
            return(result);
        }
Example #28
0
        public bool FilamentSpoolLoaded(FilamentProfile.TypeColorKey key, FilamentProfile.CustomOptions new_data)
        {
            var flag = false;

            try
            {
                if (key.type != FilamentSpool.TypeEnum.NoFilament)
                {
                    foreach (Printer printer in PrintSpoolerClient)
                    {
                        FilamentSpool currentFilament = printer.GetCurrentFilament();
                        if (currentFilament != null && currentFilament.filament_type != FilamentSpool.TypeEnum.NoFilament && (currentFilament.filament_type == key.type && (FilamentConstants.ColorsEnum)currentFilament.filament_color_code == key.color))
                        {
                            flag = true;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(flag);
        }
Example #29
0
        public override void MyButtonCallback(ButtonWidget button)
        {
            if (MainWindow.GetSelectedPrinter() == null)
            {
                return;
            }

            if (button.ID == 9)
            {
                MainWindow.ResetToStartup();
            }
            else
            {
                CurrentDetails.current_spool.estimated_filament_length_printed = 0.0f;
                CurrentDetails.current_spool.filament_uid = FilamentSpool.GenerateUID();
                if (button.ID == 6)
                {
                    FilamentSpool filamentSpool = SearchForFilamentDuplicate();
                    if (filamentSpool != null)
                    {
                        if (filamentSpool.estimated_filament_length_printed > (double)CurrentDetails.current_spool.estimated_filament_length_printed)
                        {
                            CurrentDetails.current_spool.estimated_filament_length_printed = filamentSpool.estimated_filament_length_printed;
                        }

                        CurrentDetails.current_spool.filament_uid = filamentSpool.filament_uid;
                        infobox.AddMessageToQueue("Using saved 3D Ink history.");
                    }
                    else
                    {
                        infobox.AddMessageToQueue("Matching 3D Ink history not found. Treating as a new spool.");
                    }
                }
                MainWindow.ActivateFrame(Manage3DInkMainWindow.PageID.Page13_FilamentLocation, CurrentDetails);
            }
        }
Example #30
0
 public FilamentSpool FindMatchingUsedSpool(FilamentSpool spool)
 {
     return(CurrentFilamentSettings.usedFilamentSpools.filament.Find(x => x.Matches(spool)));
 }