-gestione progressbar e caricamento foto
This commit is contained in:
+71
-8
@@ -43,10 +43,18 @@ Public Class Camera
|
||||
Private m_sImageDir As String = String.Empty
|
||||
|
||||
Private Const CAMERAMNG As String = "CameraMng"
|
||||
Private Const N_LOOP As Integer = 5
|
||||
|
||||
'Public m_ProcessCmg As New Process()
|
||||
|
||||
' Lista dei processi Cmg associati ad igni tavola
|
||||
Public m_ProcessCmgList As New List(Of Process)
|
||||
' restituisce lo stato che il processo associato alla tavola corrente (PrepareCamera)
|
||||
Private m_bIsRunnigProc As Boolean = False
|
||||
' restituisce l'esito dello scatto di una foto
|
||||
Private m_ClickOk As Boolean = False
|
||||
' restituisce l'esito dello scatto di una foto
|
||||
Private m_CorrectedImgOk As Boolean = False
|
||||
|
||||
' Flag per foto in esecuzione
|
||||
Friend m_bBusy As Boolean = False
|
||||
@@ -193,6 +201,10 @@ Public Class Camera
|
||||
If sMsg.Length > 1 Then
|
||||
If sMsg(0).Contains("PROCESSO ATTIVO") Then
|
||||
m_bIsRunnigProc = True
|
||||
ElseIf sMsg(0).Contains("CLICKED") Then
|
||||
m_ClickOk = True
|
||||
ElseIf sMsg(0).Contains("CORRECTED") Then
|
||||
m_CorrectedImgOk = True
|
||||
End If
|
||||
EgtOutLog(" § " & sMsg(0) & " Process_" & sMsg(1))
|
||||
End If
|
||||
@@ -260,6 +272,8 @@ Public Class Camera
|
||||
' Ottengo l'indice del processo associato alla tavola e la configurazione del processo
|
||||
Private Function PrepareCamera() As Integer
|
||||
m_bIsRunnigProc = False
|
||||
m_ClickOk = False
|
||||
m_CorrectedImgOk = False
|
||||
Dim sArgs As String = "7"
|
||||
Dim nInd As Integer = GetCurrentTable()
|
||||
' Invio richiesta al processo per vedere se la comunicazione è aperta
|
||||
@@ -268,8 +282,8 @@ Public Class Camera
|
||||
Catch ex As Exception
|
||||
EgtOutLog(ex.Message())
|
||||
End Try
|
||||
' Attendo massimo 5 secondi per avere una risposta dal programma (la risposta arriva al metodo Thread_OutputDataReceived)
|
||||
For i As Integer = 0 To 5
|
||||
' Attendo massimo N_LOOP secondi per avere una risposta dal programma (la risposta arriva al metodo Thread_OutputDataReceived)
|
||||
For i As Integer = 0 To N_LOOP
|
||||
Thread.Sleep(1000)
|
||||
If m_bIsRunnigProc Then Exit For
|
||||
Next
|
||||
@@ -277,7 +291,7 @@ Public Class Camera
|
||||
If Not m_bIsRunnigProc Then
|
||||
EgtOutLog(" ~ PROCESSO NON RISPONDE: Process_" & (nInd - 1).ToString())
|
||||
ReloadCameraHide(nInd - 1)
|
||||
For i As Integer = 0 To 5
|
||||
For i As Integer = 0 To N_LOOP
|
||||
Thread.Sleep(1000)
|
||||
' Invio richiesta al processo per vedere se la comunicazione è aperta
|
||||
m_ProcessCmgList(nInd - 1).StandardInput.WriteLine(sArgs)
|
||||
@@ -364,7 +378,9 @@ Public Class Camera
|
||||
' Visualizzo progressbar
|
||||
m_bBusy = True
|
||||
m_MainWindow.m_CurrentProjectPageUC.PhotoProgress.Visibility = Visibility.Visible
|
||||
m_MainWindow.m_CurrentProjectPageUC.PhotoProgress.Value = 1
|
||||
m_MainWindow.m_CurrentProjectPageUC.PhotoProgress.Value = 0
|
||||
' Costringo ad aggiornare UI
|
||||
UpdateUI()
|
||||
' Cancellazione eventuali vecchi file rimasti
|
||||
Try
|
||||
If My.Computer.FileSystem.FileExists(m_sResult) Then
|
||||
@@ -416,15 +432,15 @@ Public Class Camera
|
||||
If Not GoHomeForPhoto() Then
|
||||
EgtOutLog("Error in positioning")
|
||||
End If
|
||||
|
||||
' ------------------------------------ mando la testa in home ------------------------------------
|
||||
|
||||
' Scatto una foto con eventuale riconoscimento del contorno (il programma deve essere già attivo)
|
||||
Dim bOk As Boolean = False
|
||||
Dim sArgs As String = "2 0"
|
||||
Dim sArgs As String = "2"
|
||||
If m_bCalcContour Then sArgs = " 5 0 " & m_nThreshold.ToString() & " 0"
|
||||
Try
|
||||
m_ProcessCmgList(nInd - 1).StandardInput.WriteLine("2")
|
||||
' invio la richiesta di scattare una foto
|
||||
m_ProcessCmgList(nInd - 1).StandardInput.WriteLine(sArgs)
|
||||
bOk = WaitPhoto_0(nInd)
|
||||
Catch ex As Exception
|
||||
EgtOutLog(ex.Message())
|
||||
@@ -497,7 +513,54 @@ Public Class Camera
|
||||
End Function
|
||||
|
||||
Private Function WaitPhoto_0(nInd As Integer) As Boolean
|
||||
'MessageBox.Show("Ho ricevuto PIZZA")
|
||||
' verifico che abbia scattato la foto (dalla lettura degli eventi restituiti dal processo)
|
||||
For i As Integer = 0 To N_LOOP
|
||||
Thread.Sleep(1000)
|
||||
If m_ClickOk Then
|
||||
m_MainWindow.m_CurrentProjectPageUC.PhotoProgress.Value = 30
|
||||
' Costringo ad aggiornare UI
|
||||
UpdateUI()
|
||||
Exit For
|
||||
End If
|
||||
m_MainWindow.m_CurrentProjectPageUC.PhotoProgress.Value = 30 / N_LOOP * (i + 1)
|
||||
' Costringo ad aggiornare UI
|
||||
UpdateUI()
|
||||
Next
|
||||
' verifico che il processo di correzione della foto sia terminato correttamente
|
||||
For i As Integer = 0 To N_LOOP * 2
|
||||
Thread.Sleep(1000)
|
||||
If m_CorrectedImgOk Then
|
||||
m_MainWindow.m_CurrentProjectPageUC.PhotoProgress.Value = 80
|
||||
' Costringo ad aggiornare UI
|
||||
UpdateUI()
|
||||
Exit For
|
||||
End If
|
||||
m_MainWindow.m_CurrentProjectPageUC.PhotoProgress.Value = 30 + 50 / N_LOOP * (i + 1)
|
||||
' Costringo ad aggiornare UI
|
||||
UpdateUI()
|
||||
Next
|
||||
|
||||
' Copio i file
|
||||
Dim sImageDest As String = m_sImageDir & "\" & Path.GetFileName(m_sImage)
|
||||
Dim sInfoDest As String = Path.ChangeExtension(sImageDest, "txt")
|
||||
File.Copy(m_sImage, sImageDest, True)
|
||||
File.Copy(m_sInfo, sInfoDest, True)
|
||||
' Se richiesto il riconoscimento del contorno
|
||||
Dim sContourDest As String = String.Empty
|
||||
If m_bCalcContour Then
|
||||
sContourDest = Path.ChangeExtension(sImageDest, "dxf")
|
||||
File.Copy(m_sContour, sContourDest, True)
|
||||
' altrimenti cancello eventuale contorno presente
|
||||
Else
|
||||
m_MainWindow.m_CurrentProjectPageUC.RemoveContour()
|
||||
End If
|
||||
m_MainWindow.m_CurrentProjectPageUC.PhotoProgress.Value = 95
|
||||
' Costringo ad aggiornare UI
|
||||
UpdateUI()
|
||||
' Lancio caricamento della foto e del contorno
|
||||
m_MainWindow.m_CadCutPageUC.PostPhoto(sImageDest, sContourDest)
|
||||
Return True
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
|
||||
Reference in New Issue
Block a user