Skip to content

Commit 22d275a

Browse files
authored
Add files via upload
*ALL TESTING WAS DONE WITH THE 3.5.0 FIRMWARE for the Elfin 1 / 2* - Corrected error showing in log, due to preview image taking to long to download - Added dynamic size for image preview (scale ration 2531 x 1410 from 2k screen) - Added current print time / ETA estimate
1 parent 2b2512a commit 22d275a

File tree

3 files changed

+118
-83
lines changed

3 files changed

+118
-83
lines changed

Files/tab_printer.bjl

1.2 KB
Binary file not shown.

Nova3D File Manager.b4j

+118-83
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Module1=functions
3030
NumberOfFiles=8
3131
NumberOfLibraries=9
3232
NumberOfModules=1
33-
Version=8.1
33+
Version=8.5
3434
@EndOfDesignText@
3535
#Region Project Attributes
3636
#MainFormWidth: 600
@@ -72,12 +72,13 @@ Sub Process_Globals
7272
Dim FirstTime As Boolean = True
7373

7474
Dim Title As String ="Nova3D File Manager"
75-
Dim Version As String = "1.0.2004060" ' Version: MAJOR.MINOR.YEAR2 MONTH2 DAY2 DAILYREVISION1 (YYMMDDR)
75+
Dim Version As String = "1.0.2101240" ' Version: MAJOR.MINOR.YEAR2 MONTH2 DAY2 DAILYREVISION1 (YYMMDDR)
7676
Dim IP_Port = "8081" ' The printer web server port ' Not yet used
7777

7878
Private Timer1 As Timer
7979
Dim elfin As Image
8080
Dim layer_image As B4XBitmap
81+
Dim lastslice As Int = -1
8182

8283
Private fx As JFX
8384
Private MainForm As Form
@@ -105,6 +106,8 @@ Sub Process_Globals
105106
Private Label_version As Label
106107
Private Label_serialnb As Label
107108
Private Label_fw As Label
109+
Private Label_elapsed As Label
110+
108111
End Sub
109112

110113
Sub AppStart (Form1 As Form, Args() As String)
@@ -646,12 +649,25 @@ Sub Printer_IsPrinting()
646649
Dim thickness As Double = colroot.Get("thickness")
647650
Dim totalSlices As Int = colroot.Get("totalSlices")
648651
Dim currentSlice As Int = colroot.Get("currentSlice")
652+
Dim currentSliceTime As Int = colroot.Get("averageSliceTime")
649653
Dim startTime As Int = colroot.Get("startTime")
650654
Current_uuid = colroot.Get("id")
651655
Dim zliftDistance As Double = colroot.Get("zliftDistance")
652656
Dim elapsedTime As Int = colroot.Get("elapsedTime")
653657
Dim status As String = colroot.Get("status")
654658

659+
Label_FileName.Text = jobName
660+
Label_LayerHeight.Text = thickness & " mm"
661+
Label_Layers.Text = currentSlice & " / " & totalSlices
662+
Dim progress As Double = (100 * currentSlice) / totalSlices
663+
ProgressBar_print.Progress = progress / 100
664+
MainForm.Title = $"$1.1{progress}% - ${Title}"$
665+
Label_elapsed.Text = $"$2{DateTime.Gethour(elapsedTime-DateTime.TicksPerHour*1)}:$2{DateTime.Getminute(elapsedTime)}:$2{DateTime.GetSecond(elapsedTime)} / $2{DateTime.Gethour(currentSliceTime*totalSlices-DateTime.TicksPerHour*1)}:$2{DateTime.Getminute(currentSliceTime*totalSlices)}:$2{DateTime.Getsecond(currentSliceTime*totalSlices)} (${DateTime.Getsecond(currentSliceTime)}s)"$
666+
'Label_layertime.Text = $"$2.2{DateTime.GetSecond(currentSliceTime)}s"$
667+
Label_printstatus.Text = "Print in progress..."
668+
669+
670+
655671
Exit ' Break the loop
656672

657673
End If
@@ -664,106 +680,122 @@ End Sub
664680
Sub Timer1_Tick
665681

666682
'Handle timed events
683+
684+
If Is_Printing = True Or Is_Paused Then
667685

668-
If Is_Printing = True Or Is_Paused Then
669-
670-
Label_status.TextColor = fx.Colors.Black
671-
Dim j As HttpJob
672-
j.Initialize("", Me)
673-
j.Download("http://" & functions.SettingsMap.Get("IP") & ":8081" & "/job/list/")
674-
Wait For (j) JobDone(j As HttpJob)
675-
If j.Success Then
676-
Dim parser As JSONParser
677-
parser.Initialize(j.GetString)
678-
Dim root As List = parser.NextArray
679-
For Each colroot As Map In root
686+
Label_status.TextColor = fx.Colors.Black
687+
Dim j As HttpJob
688+
j.Initialize("", Me)
689+
j.Download("http://" & functions.SettingsMap.Get("IP") & ":8081" & "/job/list/")
690+
'Log("---- JOB LIST ----")
691+
Wait For (j) JobDone(j As HttpJob)
692+
If j.Success Then
693+
Dim parser As JSONParser
694+
parser.Initialize(j.GetString)
695+
'Log(j.GetString)
696+
Dim root As List = parser.NextArray
697+
For Each colroot As Map In root
680698

681-
Dim printInProgress As Boolean = colroot.Get("printInProgress")
682-
Dim printPaused As Boolean = colroot.Get("printPaused")
683-
'Log(printInProgress)
699+
Dim printInProgress As Boolean = colroot.Get("printInProgress")
700+
Dim printPaused As Boolean = colroot.Get("printPaused")
701+
'Dim printPaused As Boolean = colroot.Get("status")
702+
703+
Is_Paused = printPaused
684704

685-
Is_Paused = printPaused
705+
If printInProgress Then
706+
Current_uuid = colroot.Get("id")
707+
'Log(Current_uuid)
708+
709+
Dim jobName As String = colroot.Get("jobName")
710+
Dim thickness As Double = colroot.Get("thickness")
711+
Dim totalSlices As Int = colroot.Get("totalSlices")
712+
Dim currentSlice As Int = colroot.Get("currentSlice")
713+
Dim startTime As Int = colroot.Get("startTime")
714+
Dim currentSliceTime As Int = colroot.Get("lastNAverageSliceTime")
715+
716+
Dim zliftDistance As Double = colroot.Get("zliftDistance")
717+
Dim elapsedTime As Int = colroot.Get("elapsedTime")
718+
Dim status As String = colroot.Get("status")
719+
'Log(status)
720+
Exit ' Found a print, exit this loop
721+
End If
686722

687-
If printInProgress Then Exit ' Found a print, exit the loop
723+
Next
688724

689-
Next
690-
691725
If printInProgress Then
692726

693-
Dim jobName As String = colroot.Get("jobName")
694-
Dim thickness As Double = colroot.Get("thickness")
695-
Dim totalSlices As Int = colroot.Get("totalSlices")
696-
Dim currentSlice As Int = colroot.Get("currentSlice")
697-
Dim startTime As Int = colroot.Get("startTime")
698-
Current_uuid = colroot.Get("id")
699-
Dim zliftDistance As Double = colroot.Get("zliftDistance")
700-
Dim elapsedTime As Int = colroot.Get("elapsedTime")
701-
Dim status As String = colroot.Get("status")
702-
703-
'Log(elapsedTime)
704-
Log (DateTime.Gethour(elapsedTime) & ":" & DateTime.Getminute(elapsedTime) & ":" & DateTime.GetSecond(elapsedTime))
705-
706-
Label_FileName.Text = jobName
707-
Label_LayerHeight.Text = thickness & " mm"
708-
Label_Layers.Text = currentSlice & " / " & totalSlices
709-
Dim progress As Double = (100 * currentSlice) / totalSlices
710-
ProgressBar_print.Progress = progress / 100
711-
MainForm.Title = NumberFormat2(progress,1,0,0,False) & "% - " & Title
712-
Label_printstatus.Text = "Print in progress..."
713-
714-
' Get the current layer picture
715-
j.Download("http://" & functions.SettingsMap.Get("IP") & ":8081" & "/job/getImg/" & Current_uuid)
716-
Wait For (j) JobDone(j As HttpJob)
717-
If j.Success Then
718-
719-
If j.GetBitmap.Height > 0 Then
720-
layer_image = j.GetBitmap
721-
FitImageToView(layer_image.Rotate(270), ImageView_Layer)' show current layer image :)
727+
Label_FileName.Text = jobName
728+
Label_LayerHeight.Text = thickness & " mm"
729+
Label_Layers.Text = currentSlice & " / " & totalSlices
730+
Dim progress As Double = (100 * currentSlice) / totalSlices
731+
ProgressBar_print.Progress = progress / 100
732+
MainForm.Title = $"$1.1{progress}% - ${Title}"$
733+
Label_elapsed.Text = $"$2{DateTime.Gethour(elapsedTime-DateTime.TicksPerHour*1)}:$2{DateTime.Getminute(elapsedTime)}:$2{DateTime.GetSecond(elapsedTime)} / $2{DateTime.Gethour(currentSliceTime*totalSlices-DateTime.TicksPerHour*1)}:$2{DateTime.Getminute(currentSliceTime*totalSlices)}:$2{DateTime.Getsecond(currentSliceTime*totalSlices)} (${DateTime.Getsecond(currentSliceTime)}s)"$
734+
Label_printstatus.Text = "Print in progress..."
735+
736+
If currentSlice > lastslice+1 Or currentSlice=totalSlices Then
737+
lastslice = currentSlice
738+
' Get the current layer picture
739+
j.Release
740+
j.Download("http://" & functions.SettingsMap.Get("IP") & ":8081" & "/job/getImg/" & Current_uuid)
741+
'Log("---- IMAGE ----")
742+
Wait For (j) JobDone(j As HttpJob)
743+
If j.Success Then
744+
745+
If j.GetBitmap.Height > 0 Then
746+
layer_image = j.GetBitmap
747+
'FillImageToView(layer_image.Rotate(270), ImageView_Layer)' show current layer image :)
748+
FitImageToView(layer_image.Rotate(270), ImageView_Layer)' show current layer image :)
749+
End If
750+
Else
751+
Log(j.ErrorMessage)
752+
End If
753+
j.Release
722754
End If
723-
724-
End If
755+
725756

726-
Else
757+
Else
727758

728-
' Clean up to default
729-
Is_Paused = False
730-
Button_Pause.Visible = True
731-
Button_Pause.Enabled = True
732-
Button_Resume.Visible = False
733-
Button_Resume.Enabled = False
759+
' Clean up to default
760+
Is_Paused = False
761+
Button_Pause.Visible = True
762+
Button_Pause.Enabled = True
763+
Button_Resume.Visible = False
764+
Button_Resume.Enabled = False
734765

735-
ProgressBar_print.Progress = 0
736-
ImageView_Layer.SetImage(elfin) ' Pretty printer
737-
functions.enableAllTabs(TabPane1,TabPane1.Tabs.Get(1))
738-
Printer_GetFileList(functions.SettingsMap.Get("IP"))
739-
Is_Printing = False
740-
Timer1.Enabled = False
741-
Label_printstatus.Text = "Stand by"
742-
MainForm.Title = Title
743-
Label_FileName.Text = ""
744-
Label_LayerHeight.Text = "0.00 mm"
745-
Label_Layers.Text = "0 / 0"
766+
ProgressBar_print.Progress = 0
767+
ImageView_Layer.SetImage(elfin) ' Pretty printer
768+
functions.enableAllTabs(TabPane1,TabPane1.Tabs.Get(1))
769+
Printer_GetFileList(functions.SettingsMap.Get("IP"))
770+
Is_Printing = False
771+
Timer1.Enabled = False
772+
Label_printstatus.Text = "Stand by"
773+
MainForm.Title = Title
774+
Label_FileName.Text = ""
775+
Label_LayerHeight.Text = "0.00 mm"
776+
Label_Layers.Text = "0 / 0"
777+
Label_elapsed.Text = "--:--:-- / --:--:-- (--s)"
746778

747-
End If
779+
End If
748780

749-
If Is_Paused Then
750-
Label_printstatus.Text = "Print is paused!"
751-
Is_Paused = True
752-
End If
781+
If Is_Paused Then
782+
Label_printstatus.Text = "Print is paused!"
783+
Is_Paused = True
784+
End If
753785

754-
j.Release
755-
End If
756-
757-
Else
786+
j.Release
787+
End If
758788

759-
xui.MsgboxAsync("The printer is already printing!" & CRLF & "Unable to start a new print." ,"Attention")
789+
Else
760790

761-
End If
762-
791+
xui.MsgboxAsync("The printer is already printing!" & CRLF & "Unable to start a new print." ,"Attention")
763792

793+
End If
764794
End Sub
765795

766796

797+
798+
767799
Sub GetLabel(RowIndex As Int, CellIndex As Int) As Label
768800
Dim row() As Object = TableView_Files.Items.Get(RowIndex)
769801
Return row(CellIndex)
@@ -813,7 +845,9 @@ Sub FitImageToView(bmp As B4XBitmap, ImageView As B4XView)
813845
#if B4i
814846
scale = GetDeviceLayoutValues.NonnormalizedScale
815847
#End If
816-
ImageView.SetBitmap(bmp.Resize(ImageView.Width * scale, ImageView.Height * scale, True))
848+
If (ImageView.Width * scale > 0) And (ImageView.Height * scale > 0) Then
849+
ImageView.SetBitmap(bmp.Resize(ImageView.Width * scale, ImageView.Height * scale, True))
850+
End If
817851
End Sub
818852

819853
Sub FillImageToView(bmp As B4XBitmap, ImageView As B4XView)
@@ -833,5 +867,6 @@ Sub FillImageToView(bmp As B4XBitmap, ImageView As B4XView)
833867
ImageView.SetBitmap(bmp.Resize(ImageView.Width * scale, ImageView.Height * scale, True))
834868
End Sub
835869

870+
836871
#End Region
837872

Nova3D File Manager.jar

7.86 KB
Binary file not shown.

0 commit comments

Comments
 (0)