From 92196b99e66cde39c721713aa3b7d0bf61157b49 Mon Sep 17 00:00:00 2001 From: Nicola Pievani Date: Mon, 28 Jul 2025 17:13:20 +0200 Subject: [PATCH] Gestione ventosa asse W e gestione foto per tutte le tavole --- CadCuts/VacuumCups.vb | 3 ++ Constants/ConstMachIni.vb | 5 +++ Machine/CurrentMachine.vb | 32 ++++++++++++++- MainWindow.xaml.vb | 4 ++ My Project/AssemblyInfo.vb | 4 +- RawPhoto/Camera.vb | 82 ++++++++++++++++++++++++++++++-------- 6 files changed, 109 insertions(+), 21 deletions(-) diff --git a/CadCuts/VacuumCups.vb b/CadCuts/VacuumCups.vb index 94e7420..b58f1ea 100644 --- a/CadCuts/VacuumCups.vb +++ b/CadCuts/VacuumCups.vb @@ -563,6 +563,9 @@ Module VacuumCups ' assegnate le posizioni del centro delle ventose e l'angolo di posizionamento orizzontale verifica che la posizione sia raggiungibile Public Function VerifyOutOfStrokes(ptRef As Point3d, dRotAngDeg As Double) As Integer + ' Se macchina con ventosa dietro (VacType=1) non eseguo nessun controllo + If GetVacuumType() = 1 Then Return 0 + ' Verifico se usare l'asse W per la gestione delle ventose Dim sAxisName As String = "C" ' verifico che il nome dell'asse impostato sia corretto If EgtGetAxisId(sAxisName) = GDB_ID.NULL Then diff --git a/Constants/ConstMachIni.vb b/Constants/ConstMachIni.vb index 9daed7b..081fbaf 100644 --- a/Constants/ConstMachIni.vb +++ b/Constants/ConstMachIni.vb @@ -179,10 +179,15 @@ Public Const K_CHANGETABWD As String = "ChangeTabWD" Public Const S_PHOTO As String = "Photo" + Public Const K_PHOTO_CAMERACOUNTER As String = "CameraCounter" Public Const K_PHOTO_OFFSETX As String = "OffsetX" Public Const K_PHOTO_OFFSETY As String = "OffsetY" Public Const K_PHOTO_TAB2_OFFSETX As String = "Tab2OffsetX" Public Const K_PHOTO_TAB2_OFFSETY As String = "Tab2OffsetY" + Public Const K_PHOTO_TAB3_OFFSETX As String = "Tab3OffsetX" + Public Const K_PHOTO_TAB3_OFFSETY As String = "Tab3OffsetY" + Public Const K_PHOTO_TAB4_OFFSETX As String = "Tab4OffsetX" + Public Const K_PHOTO_TAB4_OFFSETY As String = "Tab4OffsetY" Public Const K_PHOTO_HQ_OFFSETX As String = "HQOffsetX" Public Const K_PHOTO_HQ_OFFSETY As String = "HQOffsetY" Public Const K_CAMERA_DIRECT_CMD As String = "CameraDirectCmd" diff --git a/Machine/CurrentMachine.vb b/Machine/CurrentMachine.vb index ca38c94..36cdc72 100644 --- a/Machine/CurrentMachine.vb +++ b/Machine/CurrentMachine.vb @@ -142,8 +142,14 @@ Public Class CurrentMachine Private m_dPhotoOffsetY As Double = 0 Private m_dTab2PhotoOffsetX As Double = 0 Private m_dTab2PhotoOffsetY As Double = 0 + Private m_dTab3PhotoOffsetX As Double = 0 + Private m_dTab3PhotoOffsetY As Double = 0 + Private m_dTab4PhotoOffsetX As Double = 0 + Private m_dTab4PhotoOffsetY As Double = 0 Private m_dHQPhotoOffsetX As Double = 0 Private m_dHQPhotoOffsetY As Double = 0 + ' Numero di camere attive in macchina + Private m_nCamCounter As Integer = 0 ' Abilitazione scelta restart Private m_bEnableRestart As Boolean = False @@ -917,18 +923,30 @@ Public Class CurrentMachine Friend ReadOnly Property PhotoOffset As Vector3d Get Select Case GetCurrentTable() + Case 4 + Return New Vector3d(m_dTab4PhotoOffsetX, m_dTab4PhotoOffsetY, 0) + Case 3 + Return New Vector3d(m_dTab3PhotoOffsetX, m_dTab3PhotoOffsetY, 0) Case 2 Return New Vector3d(m_dTab2PhotoOffsetX, m_dTab2PhotoOffsetY, 0) - Case Else + Case 1 ' verifico quale delle due fotocamere è attualmente attiva If GetPrivateProfileInt(S_CAMERAHQ, K_CAMERAHQ_ACTIVATE, 0, m_MainWindow.GetMachIniFile()) = 1 Then Return New Vector3d(m_dHQPhotoOffsetX, m_dHQPhotoOffsetY, 0) End If Return New Vector3d(m_dPhotoOffsetX, m_dPhotoOffsetY, 0) + Case Else + Return New Vector3d(m_dPhotoOffsetX, m_dPhotoOffsetY, 0) End Select End Get End Property + Friend ReadOnly Property CameraCounter As Integer + Get + Return m_nCamCounter + End Get + End Property + Friend ReadOnly Property bEnableRestart As Boolean Get Return m_bEnableRestart @@ -1428,11 +1446,21 @@ Public Class CurrentMachine ' Leggo centratura del pezzo in X sulla tavola (per macchine con nastro) m_bCenterRawOnX = (GetPrivateProfileInt(S_TABLE, K_CENTER_RAW_ONX, 0, sMachIniFile) <> 0) - ' Leggo offset aggiuntivo a fotografia + ' Leggo il numero di camere installate a bordo macchina + m_nCamCounter = GetPrivateProfileInt(S_PHOTO, K_PHOTO_CAMERACOUNTER, -1, sMachIniFile) + ' Leggo offset aggiuntivo a fotografia (Tab1 oppure Tab di carico) m_dPhotoOffsetX = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_OFFSETX, 0, sMachIniFile) m_dPhotoOffsetY = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_OFFSETY, 0, sMachIniFile) + ' Tab2 m_dTab2PhotoOffsetX = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_TAB2_OFFSETX, 0, sMachIniFile) m_dTab2PhotoOffsetY = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_TAB2_OFFSETY, 0, sMachIniFile) + ' Tab3 + m_dTab3PhotoOffsetX = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_TAB3_OFFSETX, 0, sMachIniFile) + m_dTab3PhotoOffsetY = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_TAB3_OFFSETY, 0, sMachIniFile) + ' Tab4 + m_dTab4PhotoOffsetX = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_TAB4_OFFSETX, 0, sMachIniFile) + m_dTab4PhotoOffsetY = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_TAB4_OFFSETY, 0, sMachIniFile) + ' Tab1 Hq m_dHQPhotoOffsetX = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_HQ_OFFSETX, 0, sMachIniFile) m_dHQPhotoOffsetY = GetPrivateProfileDouble(S_PHOTO, K_PHOTO_HQ_OFFSETY, 0, sMachIniFile) diff --git a/MainWindow.xaml.vb b/MainWindow.xaml.vb index ddafd55..e1a8f90 100644 --- a/MainWindow.xaml.vb +++ b/MainWindow.xaml.vb @@ -274,6 +274,10 @@ Class MainWindow Return m_bIsSiemensPc End Function + Public Function GetDebug() As Integer + Return m_nDebug + End Function + Private Sub MainWindow_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized ' Verifico sia l'unica istanza ManageSingleIstance() diff --git a/My Project/AssemblyInfo.vb b/My Project/AssemblyInfo.vb index 9390afe..c941882 100644 --- a/My Project/AssemblyInfo.vb +++ b/My Project/AssemblyInfo.vb @@ -62,5 +62,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/RawPhoto/Camera.vb b/RawPhoto/Camera.vb index 9711941..391fcdf 100644 --- a/RawPhoto/Camera.vb +++ b/RawPhoto/Camera.vb @@ -73,6 +73,8 @@ Public Class Camera Private m_bStartProspCorrect As Boolean = False Private m_dStartProspCorrect As Double = 20 + Private DeltaCameraTab As Integer = 0 + ' Flag per foto in esecuzione Friend m_bBusy As Boolean = False @@ -155,33 +157,77 @@ Public Class Camera ' OK: Restituisce la tavola a cui è associato il processo Private Function GetCurrentTableFromCameraProcess(nIndProc As Integer) As Integer - ' La cameraHq è sempre associata all'ultimo processo e sempre alla prima tavola - If nIndProc > GetTableCount() Then - Return 1 - End If - Return nIndProc + Dim nIndTab As Integer = 1 + Select Case DeltaCameraTab + Case 0 + nIndTab = nIndProc + Case 1 + ' La cameraHq è sempre associata all'ultimo processo e sempre alla prima tavola + nIndTab = 1 + Case -1 + nIndTab = GetCurrentTable() + End Select + + Return nIndTab End Function ' OK: Restituisce il processo a cui è associata la tavola Private Function GetProcessFromCurrentTable(nIndTab As Integer) As Integer - ' Alla tavola 1 possono essre associati 2 processi (solo se camera Hq abilitata e attiva) - If nIndTab = 1 And - (GetPrivateProfileInt(S_CAMERAHQ, K_CAMERAHQ_ENABLE, 0, m_MainWindow.GetMachIniFile()) <> 0) AndAlso - (GetPrivateProfileInt(S_CAMERAHQ, K_CAMERAHQ_ACTIVATE, 0, m_MainWindow.GetMachIniFile()) <> 0) Then - ' forzo l'utilizzo della seconda Hq (sopra alla tavola 1 di lavoro) - Return nIndTab + 1 - End If - Return nIndTab + Dim nIndProc As Integer = 1 + Select Case DeltaCameraTab + Case 0 + ' Indice di processo uguale all'indice della tavola + nIndProc = nIndTab + Case 1 + ' Alla tavola 1 possono essre associati 2 processi (solo se camera Hq abilitata e attiva) + If nIndTab = 1 And + (GetPrivateProfileInt(S_CAMERAHQ, K_CAMERAHQ_ENABLE, 0, m_MainWindow.GetMachIniFile()) <> 0) AndAlso + (GetPrivateProfileInt(S_CAMERAHQ, K_CAMERAHQ_ACTIVATE, 0, m_MainWindow.GetMachIniFile()) <> 0) Then + ' forzo l'utilizzo della seconda Hq (sopra alla tavola 1 di lavoro) + nIndProc = nIndTab + 1 + Else + nIndProc = 1 + End If + Case -1 + nIndProc = 1 + End Select + + Return nIndProc End Function ' OK: Avvio un processo per ogni tavola presente in macchina Public Function CamerasHide() As Boolean ' Lancio il programma in cieco, se già attivo lo nascondo m_nCameraCount = GetTableCount() - ' Aggiungo un altro processo se camera Hq abilitata (non esite una vera tavola associata) - If GetPrivateProfileInt(S_CAMERAHQ, K_CAMERAHQ_ENABLE, 0, m_MainWindow.GetMachIniFile()) = 1 Then - m_nCameraCount = m_nCameraCount + 1 + + ' Se esiste una configurazione, ne verifico la sua valità + If m_MainWindow.m_CurrentMachine.CameraCounter > -1 Then + DeltaCameraTab = m_MainWindow.m_CurrentMachine.CameraCounter - GetTableCount() + Select Case DeltaCameraTab + Case 0 + ' ad ogni tavola associo una camera/configurazione + Case 1 + ' Gestisco correttamente solo il caso: 1 tavola e 2 camere + If GetPrivateProfileInt(S_CAMERAHQ, K_CAMERAHQ_ENABLE, 0, m_MainWindow.GetMachIniFile()) = 1 Then + m_nCameraCount = m_nCameraCount + 1 + End If + Case -1 + ' Gestisco correttamente solo il caso: 2 tavole e 1 camera + m_nCameraCount = m_nCameraCount - 1 + Case Else + EgtOutLog(" 🚨 CAUTION : Differenza tra numero di camere e numero di tavole: " & DeltaCameraTab.ToString & + ", sarà attivata solo la prima camera.") + DeltaCameraTab = 0 + End Select + Else + EgtOutLog(" 🚨 CAUTION : In file *.ini machine '[Photo]' there is not param 'CameraCounter'.") + ' Aggiungo un altro processo se camera Hq abilitata (non esite una vera tavola associata) + If GetPrivateProfileInt(S_CAMERAHQ, K_CAMERAHQ_ENABLE, 0, m_MainWindow.GetMachIniFile()) = 1 Then + m_nCameraCount = m_nCameraCount + 1 + DeltaCameraTab = 1 + End If End If + Try For Index As Integer = 1 To m_nCameraCount Dim m_ProcessCmg As New Process() @@ -266,7 +312,9 @@ Public Class Camera Case "BACKIMAGE PRONTA" m_bSavedBackImage = True End Select - EgtOutLog(" § " & sMsg(0) & " Process_" & sMsg(1)) + If m_MainWindow.GetDebug > 3 Then + EgtOutLog(" § " & sMsg(0) & " Process_" & sMsg(1)) + End If End If End If End Sub