@@ -30,7 +30,7 @@ Module1=functions
30
30
NumberOfFiles=8
31
31
NumberOfLibraries=9
32
32
NumberOfModules=1
33
- Version=8.1
33
+ Version=8.5
34
34
@EndOfDesignText@
35
35
#Region Project Attributes
36
36
#MainFormWidth: 600
@@ -72,12 +72,13 @@ Sub Process_Globals
72
72
Dim FirstTime As Boolean = True
73
73
74
74
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)
76
76
Dim IP_Port = "8081" ' The printer web server port ' Not yet used
77
77
78
78
Private Timer1 As Timer
79
79
Dim elfin As Image
80
80
Dim layer_image As B4XBitmap
81
+ Dim lastslice As Int = -1
81
82
82
83
Private fx As JFX
83
84
Private MainForm As Form
@@ -105,6 +106,8 @@ Sub Process_Globals
105
106
Private Label_version As Label
106
107
Private Label_serialnb As Label
107
108
Private Label_fw As Label
109
+ Private Label_elapsed As Label
110
+
108
111
End Sub
109
112
110
113
Sub AppStart (Form1 As Form, Args() As String)
@@ -646,12 +649,25 @@ Sub Printer_IsPrinting()
646
649
Dim thickness As Double = colroot.Get("thickness")
647
650
Dim totalSlices As Int = colroot.Get("totalSlices")
648
651
Dim currentSlice As Int = colroot.Get("currentSlice")
652
+ Dim currentSliceTime As Int = colroot.Get("averageSliceTime")
649
653
Dim startTime As Int = colroot.Get("startTime")
650
654
Current_uuid = colroot.Get("id")
651
655
Dim zliftDistance As Double = colroot.Get("zliftDistance")
652
656
Dim elapsedTime As Int = colroot.Get("elapsedTime")
653
657
Dim status As String = colroot.Get("status")
654
658
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
+
655
671
Exit ' Break the loop
656
672
657
673
End If
@@ -664,106 +680,122 @@ End Sub
664
680
Sub Timer1_Tick
665
681
666
682
'Handle timed events
683
+
684
+ If Is_Printing = True Or Is_Paused Then
667
685
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
680
698
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
684
704
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
686
722
687
- If printInProgress Then Exit ' Found a print, exit the loop
723
+ Next
688
724
689
- Next
690
-
691
725
If printInProgress Then
692
726
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
722
754
End If
723
-
724
- End If
755
+
725
756
726
- Else
757
+ Else
727
758
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
734
765
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)"
746
778
747
- End If
779
+ End If
748
780
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
753
785
754
- j.Release
755
- End If
756
-
757
- Else
786
+ j.Release
787
+ End If
758
788
759
- xui.MsgboxAsync("The printer is already printing!" & CRLF & "Unable to start a new print." ,"Attention")
789
+ Else
760
790
761
- End If
762
-
791
+ xui.MsgboxAsync("The printer is already printing!" & CRLF & "Unable to start a new print." ,"Attention")
763
792
793
+ End If
764
794
End Sub
765
795
766
796
797
+
798
+
767
799
Sub GetLabel(RowIndex As Int, CellIndex As Int) As Label
768
800
Dim row() As Object = TableView_Files.Items.Get(RowIndex)
769
801
Return row(CellIndex)
@@ -813,7 +845,9 @@ Sub FitImageToView(bmp As B4XBitmap, ImageView As B4XView)
813
845
#if B4i
814
846
scale = GetDeviceLayoutValues.NonnormalizedScale
815
847
#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
817
851
End Sub
818
852
819
853
Sub FillImageToView(bmp As B4XBitmap, ImageView As B4XView)
@@ -833,5 +867,6 @@ Sub FillImageToView(bmp As B4XBitmap, ImageView As B4XView)
833
867
ImageView.SetBitmap(bmp.Resize(ImageView.Width * scale, ImageView.Height * scale, True))
834
868
End Sub
835
869
870
+
836
871
#End Region
837
872
0 commit comments