OmagVIEWPlus 2.2j1 :

-> correzione comunicazione,
-> verifica dei pezzi da prelevare.
This commit is contained in:
Nicola Pievani
2020-10-22 17:36:01 +00:00
parent d950fc1060
commit 9fa56cf5c1
11 changed files with 774 additions and 223 deletions
+5
View File
@@ -48,6 +48,11 @@ Module ConstIni
Public Const K_ANGRACK As String = "AngRack"
Public Const K_RULLERX As String = "RullerX"
Public Const K_RULLERY As String = "RullerY"
Public Const K_PIVOTCX As String = "PivotCX"
Public Const K_PIVOTCY As String = "PivotCY"
Public Const K_PIVOTBX As String = "PivotBX"
Public Const K_PIVOTBY As String = "PivotBY"
Public Const S_BOX As String = "Box"
Public Const K_MAX_HEIGHT As String = "MaxHeightPallet"
+44 -3
View File
@@ -321,7 +321,7 @@ Friend Module CamAuto
Dim rmData As New RawMoveData
Dim b3Part As New BBox3d
' verifico di posizionare le ventose correttamente
If MyPutVacuumCupsOnPart(nPartId, rmData, b3Part) Then
If MyPutVacuumCupsOnPart(nPartId, rmData, b3Part, VACUUM_HEAD) Then
SaveOneMoveInfo(nPartId, rmData)
Dim TmpPart As New Part(nPartId, nProjId)
' recupero le dimensioni del minimo rettangolo -> dal vettore che unisce il centro pezzo con il vertice in alto a sinistra
@@ -335,7 +335,34 @@ Friend Module CamAuto
' salvo il punto ptCent del pezzo
TmpPart.SetCenterPartTable(ptCenT)
'--------------------------- CONTROLLARE LA POSIZIONE DEL BARICENTRO -------------------------------------
' verifico in quale regione della tavola si trova il pezzo
'Dim ptMin, ptMax As Point3d
'EgtGetTableArea(1, ptMin, ptMax)
'Dim bRotated As Boolean = False
'If Not TmpPart.MoveTable1.m_sCups.Contains("V8") And
' ptCenT.x < (ptMax.x + ptMin.x) / 2 AndAlso ptCenT.y < (ptMax.y + ptMin.y) / 2 Then
' ' sono nel terzo quadrante uso semppre la V8
'ElseIf Not TmpPart.MoveTable1.m_sCups.Contains("V8") And
' ptCenT.x < (ptMax.x + ptMin.x) / 2 AndAlso ptCenT.y > (ptMax.y + ptMin.y) / 2 Then
' ' sono nel secondo quadrante
' Dim a As Boolean = True
'ElseIf Not TmpPart.MoveTable1.m_sCups.Contains("V8") And
' ptCenT.x > (ptMax.x + ptMin.x) / 2 AndAlso ptCenT.y < (ptMax.y + ptMin.y) / 2 Then
' ' sono nel primo quadrante
' Dim a As Boolean = True
'ElseIf Not TmpPart.MoveTable1.m_sCups.Contains("V8") And
' ptCenT.x > (ptMax.x + ptMin.x) / 2 AndAlso ptCenT.y > (ptMax.y + ptMin.y) / 2 Then
' ' sono nel quarto qudrante
' Dim a As Boolean = True
'End If
' se il centro del pezzo è a destra del centro tavola allora ruoto la testa delle ventose
'If ptCenT.y < (ptMax.y - ptMin.y) / 2 AndAlso (rmData.m_dAngRotDeg - 180) <= EPS_SMALL AndAlso (rmData.m_dAngRotDeg - 90) >= EPS_SMALL Then
' rmData.m_dAngRotDeg = -rmData.m_dAngRotDeg
' rmData.m_vtDelta.Rotate(Vector3d.Z_AX, rmData.m_dAngRotDeg)
' End If
' ruoto il pezzo e lo posziono in alto a sinistra
EgtRotate(nPartId, rmData.m_ptCenMinRect, Vector3d.Z_AX, TmpPart.DegAngOnTable, GDB_RT.GLOB)
' ruoto il versore Y del rettangolo
@@ -356,7 +383,16 @@ Friend Module CamAuto
' creo le variabili per il posizionamento delle ventose sul tavolo 2
Dim rmData2 As New RawMoveData
Dim b3Part2 As New BBox3d
If MyPutVacuumCupsOnPart(nPartId, rmData2, b3Part2) Then
If MyPutVacuumCupsOnPart(nPartId, rmData2, b3Part2, VACUUM_HEAD_PALLET) Then
' correggo il vettore vtDelta con il pivot
Dim PivotC As Vector3d = New Vector3d(Map.refUnloadingAreaVM.PivotCX, Map.refUnloadingAreaVM.PivotCY, 0)
PivotC.Rotate(Vector3d.Z_AX, rmData2.m_dAngRotDeg)
rmData2.m_vtDelta = rmData2.m_vtDelta + PivotC
' se il vettore vtDelta.x < 0 significa che la ventosa deve essere ruotata di 180°
If rmData2.m_vtDelta.x < 0 Then
rmData2.m_dAngRotDeg = 180
rmData2.m_vtDelta.Rotate(Vector3d.Z_AX, rmData2.m_dAngRotDeg)
End If
TmpPart.SetInfoTable2(rmData2)
Else
EgtOutLog("Error on UpdateVacuums in Part Table2" & nPartId.ToString())
@@ -434,12 +470,17 @@ Friend Module CamAuto
' Ripristino fase corrente originale
EgtSetCurrPhase(nOriPhase)
' restituisco l'elenco dei pezzi (prima gli automatici e poi quelli manuali)
Dim nActualPositionList As Integer = 0
If Not IsNothing(Map.refUnloadingAreaVM) Then
For Each ItemPart In PartsList
Map.refUnloadingAreaVM.ListPart.Add(ItemPart)
nActualPositionList = nActualPositionList + 1
PartWritePrivateProfileString(ItemPart.IdProject, "PartList", "IdPart" & nActualPositionList.ToString, ItemPart.IdPart.ToString)
Next
For Each ItemPartManual In PartsListManual
Map.refUnloadingAreaVM.ListPart.Add(ItemPartManual)
nActualPositionList = nActualPositionList + 1
PartWritePrivateProfileString(ItemPartManual.IdProject, "PartList", "IdPart" & nActualPositionList.ToString, ItemPartManual.IdPart.ToString)
Next
' notifico l'ultimo pezzo
Map.refUnloadingAreaVM.ListPart(Map.refUnloadingAreaVM.ListPart.Count - 1).SetIsLast(True)
+3 -1
View File
@@ -23,8 +23,10 @@ Module ConstMach
' Info altezza tavola addizionale nella tavola
Public Const KEY_ADD_TABLE As String = "AddTab"
' Nome testa con ventose per spostamento pezzi
' Nome testa con ventose scaricatore
Public Const VACUUM_HEAD As String = "H4"
' Nome testa con ventose pallettizzatore
Public Const VACUUM_HEAD_PALLET As String = "H104"
' Info tipo ventosa
Public Const KEY_VAC_TYPE As String = "VacType"
' Nome gruppo layout in testa con ventose
+177 -65
View File
@@ -22,17 +22,17 @@ Module VacuumCups
Return m_nVacId
End Function
Friend Function LoadVacuumCups() As Boolean
Friend Function LoadVacuumCups(ByVal Optional sNameHead As String = VACUUM_HEAD) As Boolean
' Leggo tipo manipolatore con ventosa
m_nVacType = 0
EgtGetInfo(EgtGetHeadId(VACUUM_HEAD), KEY_VAC_TYPE, m_nVacType)
EgtGetInfo(EgtGetHeadId(sNameHead), KEY_VAC_TYPE, m_nVacType)
' Cancello eventuali vecchie ventose
RemoveVacuumCups()
' Identificativo ventose nella macchina
Dim nLayId As Integer = EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), VACUUM_HEAD_LAYOUT)
Dim nLayId As Integer = EgtGetFirstNameInGroup(EgtGetHeadId(sNameHead), VACUUM_HEAD_LAYOUT)
If nLayId = GDB_ID.NULL Then Return False
' Identificativo riferimento della testa nella macchina
Dim nT1Id As Integer = EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), HEAD_FIRST_EXIT)
Dim nT1Id As Integer = EgtGetFirstNameInGroup(EgtGetHeadId(sNameHead), HEAD_FIRST_EXIT)
If nT1Id = GDB_ID.NULL Then Return False
' Creo gruppo temporaneo in cui copiarli
m_nTempId = EgtCreateGroup(GDB_ID.ROOT)
@@ -43,7 +43,7 @@ Module VacuumCups
m_nVacId = EgtCopyGlob(nLayId, m_nTempId)
If m_nVacId = GDB_ID.NULL Then Return False
' Angolo di rotazione preferito
EgtGetInfo( m_nVacId, KEY_VACLAY_PREFROT, m_dPreferredRot)
EgtGetInfo(m_nVacId, KEY_VACLAY_PREFROT, m_dPreferredRot)
' Direzione di riferimento per tagli Drip
'EgtGetInfo( m_nVacId, KEY_VACLAY_DRIPREFDIR, m_dDripRefAng)
' Nascondo il gruppo ma rendo visibili le curve di contorno delle ventose
@@ -51,10 +51,10 @@ Module VacuumCups
Dim nId As Integer = EgtGetFirstInGroup(m_nVacId)
While nId <> GDB_ID.NULL
Select Case EgtGetType(nId)
Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
EgtSetStatus(nId, GDB_ST.ON_)
Case Else
EgtSetStatus(nId, GDB_ST.OFF)
Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
EgtSetStatus(nId, GDB_ST.ON_)
Case Else
EgtSetStatus(nId, GDB_ST.OFF)
End Select
nId = EgtGetNext(nId)
End While
@@ -80,10 +80,10 @@ Module VacuumCups
Return True
End Function
Friend Function ResetVacuumCups() As Boolean
Friend Function ResetVacuumCups(Optional ByVal sNameHead As String = VACUUM_HEAD) As Boolean
' Ripristino posizione e rotazione originali
Dim frOriRef As New Frame3d
EgtFrame(EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), HEAD_FIRST_EXIT), GDB_ID.ROOT, frOriRef)
EgtFrame(EgtGetFirstNameInGroup(EgtGetHeadId(sNameHead), HEAD_FIRST_EXIT), GDB_ID.ROOT, frOriRef)
Dim frCurrRef As New Frame3d
EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef)
EgtMove(m_nVacId, frOriRef.Orig() - frCurrRef.Orig(), GDB_RT.GLOB)
@@ -95,10 +95,10 @@ Module VacuumCups
Dim nId As Integer = EgtGetFirstInGroup(m_nVacId)
While nId <> GDB_ID.NULL
Select Case EgtGetType(nId)
Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
EgtSetStatus(nId, GDB_ST.ON_)
Case Else
EgtSetStatus(nId, GDB_ST.OFF)
Case GDB_TY.CRV_LINE, GDB_TY.CRV_ARC, GDB_TY.CRV_BEZ, GDB_TY.CRV_COMPO
EgtSetStatus(nId, GDB_ST.ON_)
Case Else
EgtSetStatus(nId, GDB_ST.OFF)
End Select
nId = EgtGetNext(nId)
End While
@@ -222,9 +222,10 @@ Module VacuumCups
End Function
Friend Function MyPutVacuumCupsOnPart(nPartId As Integer,
ByRef rmData As RawMoveData, ByRef b3Part As BBox3d) As Boolean
ByRef rmData As RawMoveData, ByRef b3Part As BBox3d, ByVal sNameHead As String) As Boolean
LoadVacuumCups(sNameHead)
' Ripristino posizione originale ventose
ResetVacuumCups()
ResetVacuumCups(sNameHead)
' Verifico sia veramente un pezzo
If EgtGetRawPartFromPart(nPartId) = GDB_ID.NULL Then Return False
@@ -255,24 +256,28 @@ Module VacuumCups
' recupero la direzione ortogaonale al versore X
Dim vtOrtoDir As Vector3d = frFrame.VersY()
Dim vtDir As Vector3d = frFrame.VersX()
' verifico che la componente su X sia nel verso dello tappeto (vtDirX.x<0)
If vtDir.x > 0 Then
vtDir.x = vtDir.x * (-1)
End If
rmData.m_vtOrtoDirX = vtOrtoDir
Dim dMyLen, dMyAngV, dMyAngH As Double
vtDir.ToSpherical(dMyLen, dMyAngV, dMyAngH)
' recupero l'Id del lato più lungo
Dim MaxSideId As Integer = GetMaxSideId(nPartId)
' ruoto il segmento
EgtRotate(MaxSideId, ptCetMinRect, Vector3d.Z_AX, dMyAngH)
' recupero la direzione del lato più lungo
EgtMidVector(MaxSideId, vtDir)
rmData.m_vtDirX = vtDir
' fisso l'angolo di deposito del pezzo
' mi riconduco sempre agli angoli
If dMyAngH > 180 Then
dMyAngH = dMyAngH - 180
End If
m_dPreferredRot = dMyAngH
' controruoto il segmento
EgtRotate(MaxSideId, ptCetMinRect, Vector3d.Z_AX, -dMyAngH)
'' recupero l'Id del lato più lungo
'Dim MaxSideId As Integer = GetMaxSideId(nPartId)
'EgtRotate(MaxSideId, ptCetMinRect, Vector3d.Z_AX, dMyAngH)
'' recupero la direzione del lato più lungo
'EgtMidVector(MaxSideId, vtDir)
'rmData.m_vtDirX = vtDir
'' fisso l'angolo di prelievo del pezzo
'm_dPreferredRot = dMyAngH
'' controruoto il segmento
'EgtRotate(MaxSideId, ptCetMinRect, Vector3d.Z_AX, -dMyAngH)
' ottengo l'angolo orizzotale del vettore direzione (dAngH)
'Dim dLen, dAngV, dAngH As Double
@@ -295,7 +300,7 @@ Module VacuumCups
Dim nOutId As Integer = GetRegionOutLoop(nRegId, nGrpRegId)
If nOutId = GDB_ID.NULL Then Return False
' Eseguo ricerca
If FindVacuumCupsOnRaw(nPartId, ptPartCen, b3Part, ptPartCen, nOutId, nRegId, rmData) Then
If FindVacuumCupsOnRaw(nPartId, ptPartCen, b3Part, ptPartCen, nOutId, nRegId, rmData, sNameHead) Then
EgtErase(nOutId)
Return True
Else
@@ -322,7 +327,7 @@ Module VacuumCups
Private Function FindVacuumCupsOnRaw(nRawId As Integer, ptRawCen As Point3d,
b3Kerf As BBox3d, ptKerfCen As Point3d, nOutlineId As Integer, nRKerfId As Integer,
ByRef rmData As RawMoveData) As Boolean
ByRef rmData As RawMoveData, Optional sNameHead As String = VACUUM_HEAD) As Boolean
' Cerco migliore configurazione di ventose per prendere il grezzo
Const MAX_SEL As Integer = 20
For nI As Integer = 1 To MAX_SEL
@@ -336,17 +341,39 @@ Module VacuumCups
Dim dRotAngDeg As Double = 0
Dim vtMove2 As New Vector3d
Dim ptRotCen2 As New Point3d
Dim dRotAngDeg2 As Double = 0
Dim dRotAngDeg2 As Double = 90
' verifico con il primo elenco di ventose
Dim dDist = TestVacuumCupSelection(sCups, b3Kerf, ptKerfCen, nOutlineId, nRKerfId, vtMove, ptRotCen, dRotAngDeg)
Dim dDist2 = TestVacuumCupSelection(sCups2, b3Kerf, ptKerfCen, nOutlineId, nRKerfId, vtMove2, ptRotCen2, dRotAngDeg2)
If dDist > INFINITO - 1 And dDist2 > INFINITO - 1 Then Continue For
If dDist2 < dDist Then
sCups = sCups2
vtMove = vtMove2
ptRotCen = ptRotCen2
dRotAngDeg = dRotAngDeg2
Dim dDist As Double = INFINITO
If sNameHead = VACUUM_HEAD Then
' se tavola 1
Dim bFirstSelection As Boolean = MyVacuumTest(sCups, b3Kerf, ptKerfCen, nOutlineId, nRKerfId, vtMove, ptRotCen, dRotAngDeg, sNameHead)
Dim bSecondSelection As Boolean = False
If Not bFirstSelection Then
bSecondSelection = MyVacuumTest(sCups2, b3Kerf, ptKerfCen, nOutlineId, nRKerfId, vtMove2, ptRotCen2, dRotAngDeg2, sNameHead)
End If
If bSecondSelection Then
sCups = sCups2
vtMove = vtMove2
ptRotCen = ptRotCen2
dRotAngDeg = dRotAngDeg2
End If
If Not bFirstSelection And Not bSecondSelection Then Continue For
Else
' se pallettizzatore imposto come angolo privilegiato C180
m_dPreferredRot = 180
dDist = TestVacuumCupSelection(sCups, b3Kerf, ptKerfCen, nOutlineId, nRKerfId, vtMove, ptRotCen, dRotAngDeg)
If dDist > INFINITO - 1 Then Continue For
End If
'If dDist > INFINITO - 1 And dDist2 > INFINITO - 1 Then Continue For
'If dDist2 < dDist Then
' sCups = sCups2
' vtMove = vtMove2
' ptRotCen = ptRotCen2
' dRotAngDeg = dRotAngDeg2
'End If
' Eseguo il movimento
EgtMove(m_nVacId, vtMove, GDB_RT.GLOB)
EgtRotate(m_nVacId, ptRotCen, Vector3d.Z_AX(), dRotAngDeg, GDB_RT.GLOB)
@@ -384,6 +411,85 @@ Module VacuumCups
Return False
End Function
Private Function MyVacuumTest(sCups() As String, b3Raw As BBox3d, ptRawCen As Point3d, nOutlineId As Integer, nRawRegId As Integer,
ByRef vtMove As Vector3d, ByRef ptRotCen As Point3d, ByRef dRotAngDeg As Double, sNameHead As String) As Boolean
Dim dDist = TestVacuumCupSelection(sCups, b3Raw, ptRawCen, nOutlineId, nRawRegId, vtMove, ptRotCen, dRotAngDeg)
If dDist < INFINITO - 1 Then
Dim frCurrRefTemp As New Frame3d
EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRefTemp)
EgtMove(m_nVacId, vtMove, GDB_RT.GLOB)
frCurrRefTemp.Move(vtMove)
' calcolo l'offset dal centro del pezzo
Dim vtDeltaTest As Vector3d = frCurrRefTemp.Orig() - ptRawCen
' allineo l'offset e al ventosa
vtDeltaTest.Rotate(Vector3d.Z_AX, dRotAngDeg)
EgtRotate(m_nVacId, ptRawCen, Vector3d.Z_AX, dRotAngDeg)
' dimensioni tavola
Dim MinX, MaxY As Double
EgtGetInfo(EgtGetTableId(MAIN_TAB), "MaxTabY", MaxY)
EgtGetInfo(EgtGetTableId(MAIN_TAB), "MinTabX", MinX)
' calcolo la posizione di prelievo del pezzo
Dim ptUnload As New Point3d
ptUnload.x = ptRawCen.x + vtDeltaTest.x
ptUnload.y = ptRawCen.y + vtDeltaTest.y
' allineo il riferimeno della ventosa
frCurrRefTemp.Rotate(ptRawCen, Vector3d.Z_AX, dRotAngDeg)
' verifico che il punto sia all'interno delle corse
EgtSetCalcTool("", sNameHead, 1)
Dim nStat As Integer = 0
Dim bVerifyStroke As Boolean = EgtVerifyOutstroke(ptUnload.x, ptUnload.y, ptRawCen.z, dRotAngDeg, 0, nStat)
If nStat <> 0 Then bVerifyStroke = False
' verifico di no sbattere contro la macchina
If bVerifyStroke Then
Dim b3BoxVacuum As New BBox3d
EgtGetBBoxGlob(m_nVacId, GDB_BB.STANDARD, b3BoxVacuum)
If b3BoxVacuum.Min.x < MinX Then
bVerifyStroke = False
End If
If b3BoxVacuum.Max.y > MaxY Then
bVerifyStroke = False
End If
End If
If Not bVerifyStroke Then
frCurrRefTemp.Rotate(ptRawCen, Vector3d.Z_AX, -dRotAngDeg)
vtDeltaTest.Rotate(Vector3d.Z_AX, -dRotAngDeg)
EgtRotate(m_nVacId, ptRawCen, Vector3d.Z_AX, -dRotAngDeg)
' provo a ruotare di 180
If dRotAngDeg >= 90 Then
dRotAngDeg = dRotAngDeg - 180
Else
dRotAngDeg = dRotAngDeg + 180
End If
vtDeltaTest.Rotate(Vector3d.Z_AX, dRotAngDeg)
frCurrRefTemp.Rotate(ptRawCen, Vector3d.Z_AX, dRotAngDeg)
EgtRotate(m_nVacId, ptRawCen, Vector3d.Z_AX, dRotAngDeg)
ptUnload.x = ptRawCen.x + vtDeltaTest.x
ptUnload.y = ptRawCen.y + vtDeltaTest.y
bVerifyStroke = EgtVerifyOutstroke(ptUnload.x, ptUnload.y, ptRawCen.z, dRotAngDeg, 0, nStat)
If nStat <> 0 Then bVerifyStroke = False
' verifico di no sbattere contro la macchina
Dim b3BoxVacuum As New BBox3d
EgtGetBBoxGlob(m_nVacId, GDB_BB.STANDARD, b3BoxVacuum)
If b3BoxVacuum.Min.x < MinX Then
bVerifyStroke = False
End If
If b3BoxVacuum.Max.y > MaxY Then
bVerifyStroke = False
End If
vtDeltaTest.Rotate(Vector3d.Z_AX, -dRotAngDeg)
EgtRotate(m_nVacId, ptRawCen, Vector3d.Z_AX, -dRotAngDeg)
frCurrRefTemp.Rotate(ptRawCen, Vector3d.Z_AX, -dRotAngDeg)
End If
EgtMove(m_nVacId, -vtMove, GDB_RT.GLOB)
frCurrRefTemp.Move(-vtMove)
Return bVerifyStroke
End If
EgtMove(m_nVacId, -vtMove, GDB_RT.GLOB)
Return False
End Function
Private Function GetVacuumCupSelection(nInd As Integer, ByRef sCups() As String, ByRef sCups2() As String) As Boolean
' Recupero elenco ventose nella soluzione
Dim sSel As String = KEY_VACLAY_SEL & nInd.ToString()
@@ -414,9 +520,9 @@ Module VacuumCups
Return True
End Function
Private Function GetVacRotAxisSteps(ByRef vAngRot As List(Of Double)) As Boolean
Private Function GetVacRotAxisSteps(ByRef vAngRot As List(Of Double), ByRef Optional sNameHead As String = VACUUM_HEAD) As Boolean
' Recupero l'asse rotante della testa ventosa
Dim nRotAxId As Integer = EgtGetParent(EgtGetHeadId(VACUUM_HEAD))
Dim nRotAxId As Integer = EgtGetParent(EgtGetHeadId(sNameHead))
' Verifico se contiene info con STEPS
Dim sSteps As String = ""
If Not EgtGetInfo(nRotAxId, KEY_ROTVAC_STEPS, sSteps) Then Return False
@@ -453,6 +559,10 @@ Module VacuumCups
b3Vac.Move(vtMove)
' Determino la rotazione, allineando il lato lungo delle ventose con quello del grezzo
ptRotCen = b3Vac.Center()
' angolo preferenziale di afferraggio
dRotAngDeg = m_dPreferredRot + dRotAngDeg
'Dim frMinRect As New Frame3d
'If EgtCurveMinAreaRectangleXY(nOutlineId, GDB_ID.ROOT, frMinRect) Then
' Dim dLen, dAngVertDeg, dAngOrizzDeg As Double
@@ -474,34 +584,36 @@ Module VacuumCups
' End If
'End If
' la ventosa DEVE sempre essere allineata con il lato più lungo del pezzo
dRotAngDeg = m_dPreferredRot
' cosrtuisco un array con gli Identificativi delle ventose
Dim nCups(sCups.Length() - 1) As Integer
For nJ As Integer = 0 To sCups.Length() - 1
nCups(nJ) = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ))
Next
' Angoli di prova
Dim vAngRot As New List(Of Double)
' Se asse rotante ventosa a step
If GetVacRotAxisSteps(vAngRot) Then
' Ordino secondo distanza angolare crescente da direzione di allineamento (modulo 180 deg)
Dim dRotRefDeg As Double = dRotAngDeg
vAngRot.Sort(Function(P, Q)
Dim dDiffP = Math.Abs(P - dRotRefDeg)
If Math.Abs(dDiffP - 180) < 10 * EPS_ANG_SMALL Then dDiffP = 1
Dim dDiffQ = Math.Abs(Q - dRotRefDeg)
If Math.Abs(dDiffQ - 180) < 10 * EPS_ANG_SMALL Then dDiffQ = 1
Return CInt(dDiffP - dDiffQ)
End Function)
' Annullo la rotazione di allineamento
dRotAngDeg = 0
' altrimenti in continuo
Else
' Assegno più valori di ricerca e conservo angolo di allineamento
vAngRot.AddRange({0, +5, -5, +12.5, -12.5, +25, -25, +45, -45})
End If
'' Se asse rotante ventosa a step
'If GetVacRotAxisSteps(vAngRot) Then
' ' Ordino secondo distanza angolare crescente da direzione di allineamento (modulo 180 deg)
' Dim dRotRefDeg As Double = dRotAngDeg
' vAngRot.Sort(Function(P, Q)
' Dim dDiffP = Math.Abs(P - dRotRefDeg)
' If Math.Abs(dDiffP - 180) < 10 * EPS_ANG_SMALL Then dDiffP = 1
' Dim dDiffQ = Math.Abs(Q - dRotRefDeg)
' If Math.Abs(dDiffQ - 180) < 10 * EPS_ANG_SMALL Then dDiffQ = 1
' Return CInt(dDiffP - dDiffQ)
' End Function)
' ' Annullo la rotazione di allineamento
' dRotAngDeg = 0
' ' altrimenti in continuo
'Else
' ' Assegno più valori di ricerca e conservo angolo di allineamento
' vAngRot.AddRange({0, +5, -5, +12.5, -12.5, +25, -25, +45, -45})
'End If
' Assegno più valori di ricerca e conservo angolo di allineamento
vAngRot.AddRange({0, +5, -5, +12.5, -12.5, +25, -25, +45, -45})
' Eseguo verifica delle ventose rispetto al grezzo
Dim bVacOk As Boolean = False
+42 -1
View File
@@ -336,8 +336,49 @@ Public Class MainWindowM
If Not EgtSetCurrMachGroup(nMachGroupId) Then Return False
' Visualizzo solo la tavola della macchina
EgtShowOnlyTable(True)
' attivo la prima fase
EgtSetCurrPhase(1)
Dim b3FirstPhase As New BBox3d()
Dim nRawPartID As Integer = EgtGetFirstRawPart()
While nRawPartID <> GDB_ID.NULL
If EgtVerifyRawPartPhase(nRawPartID, 1) Then
Dim b3CurrRawPart As New BBox3d
EgtGetRawPartBBox(nRawPartID, b3CurrRawPart)
b3FirstPhase.Add(b3CurrRawPart)
End If
nRawPartID = EgtGetNextRawPart(nRawPartID)
End While
Dim nLastPhase = EgtGetPhaseCount()
' Attivo ultima fase di lavorazione
EgtSetCurrPhase(EgtGetPhaseCount())
EgtSetCurrPhase(nLastPhase)
Dim b3LastPhase As New BBox3d()
nRawPartID = EgtGetFirstRawPart()
While nRawPartID <> GDB_ID.NULL
If EgtVerifyRawPartPhase(nRawPartID, nLastPhase) Then
Dim b3CurrRawPart As New BBox3d
EgtGetRawPartBBox(nRawPartID, b3CurrRawPart)
b3LastPhase.Add(b3CurrRawPart)
End If
nRawPartID = EgtGetNextRawPart(nRawPartID)
End While
Dim vtRawOffset As New Vector3d
Dim ptTable1 As New Point3d
EgtGetTableRef(1, ptTable1)
vtRawOffset.x = ptTable1.x - b3LastPhase.Min().x
nRawPartID = EgtGetFirstRawPart()
While nRawPartID <> GDB_ID.NULL
EgtMoveRawPart(nRawPartID, vtRawOffset)
nRawPartID = EgtGetNextRawPart(nRawPartID)
End While
' salvo le modifiche nel nuov file
EgtSaveFile(m_sTempDir & "\" & CURR_PROJ_NAME, NGE.BIN)
' Nascondo lavorazioni
HideAllMachinings()
' Recupero elenco dei pezzi attivi nella fase
+53 -22
View File
@@ -254,12 +254,19 @@ Public Class Part
' quando calcolo le posizioni delle ventose devo recuperare queste info
Public Function GetloadingPosStrip() As Point3d
Dim ptUnLoad As New Point3d
' ruoto gli offset per allinearmi al tappeto di scarico
m_MoveTable1.m_vtDelta.Rotate(Vector3d.Z_AX, -m_MoveTable1.m_dAngRotDeg)
If m_MoveTable1.m_sCups.Contains("V8") Then
' controruoto e mi porto in posizione posizione di scarico
m_MoveTable1.m_vtDelta.Rotate(Vector3d.Z_AX, 180)
Else
' ruoto gli offset per allinearmi al tappeto di scarico
m_MoveTable1.m_vtDelta.Rotate(Vector3d.Z_AX, -m_MoveTable1.m_dAngRotDeg)
End If
Dim vtResult As Vector3d = m_MoveTable1.m_vtDelta - m_MoveTable1.m_vtRect
' se la distanza x è minore della larghezza della ventosa correggo
If vtResult.x + 1534 / 2 > 0 Then
If Not m_MoveTable1.m_sCups.Contains("V8") And vtResult.x + 1534 / 2 > 0 Then
ptUnLoad.x = -1534 / 2
Else
ptUnLoad.x = vtResult.x
@@ -289,6 +296,7 @@ Public Class Part
' restituisce la posizione di deposito sul pallet (riceve l'offset attuale del pellet in funzione dei pezzi già caricati)
Public Function GetUnloadingPosBox(vtCurrOffset As Vector3d) As Point3d
Dim ptUnload As New Point3d
'correggo il vettore Delta a causa di un pivot dell'asse di rotazione
Dim vtResult As Vector3d = m_MoveTable2.m_vtDelta + vtCurrOffset
ptUnload.x = vtResult.x
ptUnload.y = vtResult.y
@@ -296,6 +304,27 @@ Public Class Part
Return ptUnload
End Function
' restituisce la posizione di deposito sul pallet (riceve l'offset attuale del pellet in funzione dei pezzi già caricati)
Public Function GetUnloadingPosRack(vtCurrOffset As Vector3d) As Point3d
Dim ptUnload As New Point3d
m_MoveTable2.m_vtDelta.z = 0
'correggo il vettore Delta a causa di un pivot dell'asse di rotazione
m_MoveTable2.m_vtDelta = m_MoveTable2.m_vtDelta + New Vector3d(Map.refUnloadingAreaVM.PivotBX, Map.refUnloadingAreaVM.PivotBY, 0)
' cambio il sitema di riferimento per posizionarmi allineato alla piastrella
m_MoveTable2.m_vtDelta.Rotate(Vector3d.Z_AX, -90)
m_MoveTable2.m_vtDelta.Rotate(Vector3d.Y_AX, -90)
' salvo la coordinata x (punto di appoggio della piastrella)
Dim posX As Double = vtCurrOffset.x
Dim vtResult As Vector3d = m_MoveTable2.m_vtDelta + vtCurrOffset
' considero di traslare il vettore così ottenuto nel punto posX
vtResult.x = 0
vtResult.Rotate(Vector3d.Y_AX, 90 - Map.refUnloadingAreaVM.AngRack)
ptUnload.x = posX + vtResult.x
ptUnload.y = vtResult.y
ptUnload.z = vtResult.z
Return ptUnload
End Function
' restituisce se la ventosa deve essere attivata
Public Function GetVacuumLoadingStatus(sVacuum As String, Optional sTable As String = "Table1") As Integer
If sTable = "Table1" Then
@@ -312,21 +341,21 @@ Public Class Part
Public Function SavePart(nIdexPart As Integer) As Boolean
' scrivo l'elenco dei part presenti nel file
PartWritePrivateProfileString(m_IdProject, "PartList", "IdPart" & nIdexPart.ToString, m_IdPart.ToString)
'PartWritePrivateProfileString(m_IdProject, "PartList", "IdPart" & nIdexPart.ToString, m_IdPart.ToString)
' stato della piastrella
PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, ConstIni.K_STATUS, CInt(m_enStatus))
PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, ConstIni.K_PLACE, CInt(m_enPlace))
PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, ConstIni.K_UNLOADING, CInt(m_enUnloading))
' posizione della tavola
PartWritePrivateProfilePoint(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "Table1ref", m_ptTable1)
' posizione centro pezzo sulla tavola
PartWritePrivateProfilePoint(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "CenterPartTable1", m_CenterPartTable)
' altezza della piastrella
PartWritePrivateProfileDouble(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "Height", m_Height)
' IdWarehouse
PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "IdWarehouse", CInt(m_enWarehouse))
' IdBox
PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "IdBox", m_IdBox)
' altezza della piastrella
PartWritePrivateProfileDouble(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "Height", m_Height)
' posizione della tavola
PartWritePrivateProfilePoint(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "Table1ref", m_ptTable1)
' posizione centro pezzo sulla tavola
PartWritePrivateProfilePoint(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "CenterPartTable1", m_CenterPartTable)
' info Table 1
For nIndex = 1 To 2
Dim objRawMoveData As New RawMoveData
@@ -335,24 +364,24 @@ Public Class Part
Else
objRawMoveData = m_MoveTable2
End If
' RawMove
PartWritePrivateProfileVector(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "RawMove" & nIndex.ToString, objRawMoveData.m_vtRawMove)
' CenterMinRect
PartWritePrivateProfilePoint(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "CenterMinRect" & nIndex.ToString, objRawMoveData.m_ptCenMinRect)
' RotAngDeg
PartWritePrivateProfileDouble(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "RotAngDeg" & nIndex.ToString, objRawMoveData.m_dAngRotDeg)
' Delta
PartWritePrivateProfileVector(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "Delta" & nIndex.ToString, objRawMoveData.m_vtDelta)
' Cups
PartWritePrivateProfileString(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "Cups" & nIndex.ToString, objRawMoveData.m_sCups)
' Rect
PartWritePrivateProfileVector(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "Rect" & nIndex.ToString, objRawMoveData.m_vtRect)
' DirX
PartWritePrivateProfileVector(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "DirX" & nIndex.ToString, objRawMoveData.m_vtDirX)
' OrtoDirX
PartWritePrivateProfileVector(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "OrtoDirX" & nIndex.ToString, objRawMoveData.m_vtOrtoDirX)
' CenterMinRect
PartWritePrivateProfilePoint(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "CenterMinRect" & nIndex.ToString, objRawMoveData.m_ptCenMinRect)
' Cups
PartWritePrivateProfileString(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "Cups" & nIndex.ToString, objRawMoveData.m_sCups)
' RotAngDeg
PartWritePrivateProfileDouble(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "RotAngDeg" & nIndex.ToString, objRawMoveData.m_dAngRotDeg)
' RawAngRotDeg
PartWritePrivateProfileDouble(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "RawAngRotDeg" & nIndex.ToString, objRawMoveData.m_dRawAngRotDeg)
' RawMove
PartWritePrivateProfileVector(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "RawMove" & nIndex.ToString, objRawMoveData.m_vtRawMove)
Next
Return True
End Function
@@ -447,6 +476,8 @@ Public Class Part
PartGetPrivateProfileVector(nIdProj, ConstIni.S_PART & nIdPart.ToString, "Delta" & nIndex.ToString, objRawMoveData.m_vtDelta)
' Rect
PartGetPrivateProfileVector(nIdProj, ConstIni.S_PART & nIdPart.ToString, "Rect" & nIndex.ToString, objRawMoveData.m_vtRect)
LocalPart.MinRectX = objRawMoveData.m_vtRect.x * 2
LocalPart.MinRectY = objRawMoveData.m_vtRect.y * 2
' DirX
PartGetPrivateProfileVector(nIdProj, ConstIni.S_PART & nIdPart.ToString, "DirX" & nIndex.ToString, objRawMoveData.m_vtDirX)
' OrtoDirX
@@ -454,11 +485,11 @@ Public Class Part
' CenterMinRect
PartGetPrivateProfilePoint(nIdProj, ConstIni.S_PART & nIdPart.ToString, "CenterMinRect" & nIndex.ToString, objRawMoveData.m_ptCenMinRect)
' Cups
PartWritePrivateProfileString(nIdProj, ConstIni.S_PART & nIdPart.ToString, "Cups" & nIndex.ToString, objRawMoveData.m_sCups)
PartGetPrivateProfileString(nIdProj, ConstIni.S_PART & nIdPart.ToString, "Cups" & nIndex.ToString, "", objRawMoveData.m_sCups)
' RotAngDeg
PartWritePrivateProfileDouble(nIdProj, ConstIni.S_PART & nIdPart.ToString, "RotAngDeg" & nIndex.ToString, objRawMoveData.m_dAngRotDeg)
PartGetPrivateProfileDouble(nIdProj, ConstIni.S_PART & nIdPart.ToString, "RotAngDeg" & nIndex.ToString, objRawMoveData.m_dAngRotDeg)
' RawAngRotDeg
PartWritePrivateProfileDouble(nIdProj, ConstIni.S_PART & nIdPart.ToString, "RawAngRotDeg" & nIndex.ToString, objRawMoveData.m_dRawAngRotDeg)
PartGetPrivateProfileDouble(nIdProj, ConstIni.S_PART & nIdPart.ToString, "RawAngRotDeg" & nIndex.ToString, objRawMoveData.m_dRawAngRotDeg)
Next
Map.refUnloadingAreaVM.ListPart.Add(LocalPart)
@@ -474,7 +505,7 @@ Public Class Part
End If
Next
' verifico se almeno un pezzo del progetto è stato depositato nel magazzino
If LocalPart.enPlace <> Place.ON_MOTOR_RULLER Or LocalPart.enPlace <> Place.ON_TABLE Then
If LocalPart.enPlace <> Place.ON_MOTOR_RULLER AndAlso LocalPart.enPlace <> Place.ON_TABLE Then
bIsWorking = True
End If
Next
+365 -106
View File
@@ -25,6 +25,8 @@ Public Class NCCommunication
Private m_bFirst As Boolean = True
Private m_bWaitingManualUnloading As Boolean = False
' Timer
Private m_TimerIsBusy As Boolean = False
Private m_RefreshTimer As New DispatcherTimer
@@ -71,6 +73,16 @@ Public Class NCCommunication
End If
' eseguo la ricerca dei part
Part.GetListOfPart()
' carico il magazzino attivo (letto dalla configurazione)
For Each ItemWarehouse In Map.refUnloadingAreaVM.WarehouseList
If SetCurrStorage(ItemWarehouse) Then
If Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.LOADING Then
Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.WORKING
OutLogProcess("[0] Progetto pronto per pallettizzazione: " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString)
End If
Exit For
End If
Next
' Eseguo subito la prima lettura variabili
Refresh()
@@ -118,28 +130,48 @@ Public Class NCCommunication
' se la tavola è svuotata allora ricerco un nuovo progetto (solo se la rulliera non contiene pezzi con scarico manuale)
If Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE).Count = 0 Then
OutLogProcess("[0] Tavola di carico vuota")
' verifico se sono presenti pezzi manuali sulla rulliera
Dim bManualUnloading As Boolean = False
Dim nCounterManual As Integer = 0
Dim nCounterAutomatic As Integer = 0
' conto il numero di pezzi manuali presenti sulla rulliera
For Each ItemPart In Map.refUnloadingAreaVM.GetParts(Place.ON_MOTOR_RULLER)
If ItemPart.enUnloading = Unloading.MANUAL Then
' comunico alla macchina che deve iniziare lo scarico manuale
WriteInt("UnloadManual", 1)
bManualUnloading = True
' rendo visibile la freccia rossa sulla rulliera
Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Visible
OutLogProcess("[0] Pezzi manuali sulla rulliera")
Exit For
nCounterManual = nCounterManual + 1
Else
nCounterAutomatic = nCounterAutomatic + 1
End If
Next
' leggo dalla macchina se è terminato lo sacrico manuale
If ReadInt("UnloadManual", nValue) Then
bRaededVariable = True
If nValue = 0 Then bManualUnloading = False
' leggo se lo scarico manuale è terminato (nValue=0) solo quando sono terminati quello automatici
If m_bWaitingManualUnloading Then
If ReadInt("rUnloadManual", nValue) Then
bRaededVariable = True
If nValue = 0 Then
' svuoto la rulliera dai pezzi manuali
Map.refUnloadingAreaVM.UnloadedManualPart()
' comunico che lo scarico manuale è terminato
m_bWaitingManualUnloading = False
' ridefinisco subito il numero di pezzi manuali
nCounterManual = 0
End If
End If
End If
' verifico se sono presenti pezzi manuali sulla rulliera (se non ci son pezzi manuali -> bManualUnloading = False)
If nCounterManual > 0 AndAlso nCounterAutomatic = 0 Then
' comunico alla macchina che deve iniziare lo scarico manuale
WriteReal("UnloadManual", 1)
' attendo che sia comunicato il valore anche nella variabile di lettura (rUnloadManual)
'EgtUILib.WritePrivateProfileString("0", "81.10", "1", "c:\EgtData\OmagVIEWPlus\Config\NC_Debug.ini")
' comunico che attendo il termino dello scarico manuale
m_bWaitingManualUnloading = True
' rendo visibile la freccia rossa sulla rulliera
Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Visible
OutLogProcess("[0] Pezzi manuali sulla rulliera")
End If
' se lo scarico manuale è terminato procedo a caricare nuovo progetto
If Not bManualUnloading Then
' svuoto la rulliera dai paìezzi manuali
Map.refUnloadingAreaVM.UnloadedManualPart()
If nCounterManual = 0 Then
' nascondo la freccai rossa
Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Collapsed
' carico il nuovo progetto
@@ -152,6 +184,10 @@ Public Class NCCommunication
If Map.refMainWindowVM.StartUnloadingProject() Then
' Rinomino segnalazione nuovo in segnalazione blocco
My.Computer.FileSystem.MoveFile(sProjNew, sProjLock, True)
OutLogProcess("[0] Tutti i pezzi sono prelevabili")
Else
' Rinomino segnalazione nuovo in segnalazione blocco
OutLogProcess("[0] Impossibile caricare tutti i pezzi")
End If
End If
'' avendo caricato un nuovo progetto devo disporre il nuovo magazzino (se non ho altri progetti prima)
@@ -176,7 +212,7 @@ Public Class NCCommunication
' leggo lo stato SCARICATORE StatusMachine1
Dim StatusMachine1 As StatusMachine = StatusMachine.MOVING
If ReadInt("StatusMachine1", nValue) Then
If ReadInt("rStatusMachine1", nValue) Then
bRaededVariable = True
' converto in Enum
If nValue >= 0 OrElse nValue <= 4 Then
@@ -192,16 +228,9 @@ Public Class NCCommunication
If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable1) Then
' comunico che il pezzo è stato depositato sulla rulliera (aggiorno il file ini del progetto)
Map.refUnloadingAreaVM.CurrPartTable1.enPlace = Place.ON_MOTOR_RULLER
'EgtSetStatus(Map.refUnloadingAreaVM.CurrPartTable1.IdPart, GDB_ST.OFF)
EgtSetStatus(Map.refUnloadingAreaVM.CurrPartTable1.IdPart, GDB_ST.OFF)
EgtDraw()
OutLogProcess("[1] Pezzo depositato su rulliera: " & Map.refUnloadingAreaVM.CurrPartTable1.IdPart.ToString)
' se l'ultimo pezzo è stato scaricato
If Map.refUnloadingAreaVM.CurrPartTable1.IsLast Then
' genero i file .epl, .ppl
Map.refMainWindowVM.MainWindowM.SavePartStatus()
WriteInt("LastPartTable1", 1)
OutLogProcess("[1] Ultimo Pezzo prelevato dal tavolo: " & Map.refUnloadingAreaVM.CurrPartTable1.IdPart.ToString)
End If
End If
' passo al pezzo successivo, e lo rendo corrente
Map.refUnloadingAreaVM.CurrPartTable1 = UnLoadTable1()
@@ -209,18 +238,12 @@ Public Class NCCommunication
Case StatusMachine.CHANGE_POINT
OutLogProcess("[1] Stato macchina 1: 3")
' la macchina è ferma ed è pronta a ricevere le nuove coordinate
' se esisteva un pezzo corrente allora significa chè è stato scartato
If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable1) Then
' comunico che il pezzo è stato sacrtato (aggiorno il file ini del progetto)
Map.refUnloadingAreaVM.CurrPartTable1.enStatus = StatusPart.WASTE
OutLogProcess("[1] Pezzo scartato sul tavolo: " & Map.refUnloadingAreaVM.CurrPartTable1.IdPart.ToString)
' se l'ultimo pezzo è rovinato (ha tentato di caricarlo ma ha fallito)
If Map.refUnloadingAreaVM.CurrPartTable1.IsLast Then
' genero i file .epl, .ppl
Map.refMainWindowVM.MainWindowM.SavePartStatus()
WriteInt("LastPartTable1", 1)
OutLogProcess("[1] Ultimo Pezzo scartato sul tavolo: " & Map.refUnloadingAreaVM.CurrPartTable1.IdPart.ToString)
End If
End If
' passo al pezzo successivo, e lo rendo corrente
Map.refUnloadingAreaVM.CurrPartTable1 = UnLoadTable1()
@@ -247,25 +270,25 @@ Public Class NCCommunication
' se il progetto è prenotato allora rendo i magazzini non disponibili alla macchina e disattivi
If Map.refMainWindowVM.WaitingConfirmManualPart Then
OutLogProcess("[2] Nuova lastra prenotata")
OutLogProcess("[2] Nuova lastra prenotata")
' riabilito la scelta dei magazzini
Map.refUnloadingAreaVM.SetActiveWarehouse(0)
For Each ItemWarehouse In Map.refUnloadingAreaVM.WarehouseList
ItemWarehouse.SetState(States.NOT_AVAILABLE)
OutLogProcess("[2] Rendo disponibile il magazzino: " & ItemWarehouse.Id.ToString)
OutLogProcess("[2] Rendo disponibile il magazzino: " & ItemWarehouse.Id.ToString)
Next
Else
' ricerco il primo magazzino attivo
For Each ItemWarehouse In Map.refUnloadingAreaVM.WarehouseList
If ItemWarehouse.IsActive Then
OutLogProcess("[2] Trovato magazzino Attivo: " & ItemWarehouse.Id.ToString)
OutLogProcess("[2] Trovato magazzino Attivo: " & ItemWarehouse.Id.ToString)
' verifico se il magazzino è ancora disponibile per il nuovo progetto
Map.refUnloadingAreaVM.bOrganizeWarehouse = Not SetCurrStorage(ItemWarehouse)
End If
Next
' se non è stato trovato nessun magazzino attivo cerco il primo magazzino disponibile
If Map.refUnloadingAreaVM.bOrganizeWarehouse Then
OutLogProcess("[2] Nessun magazzino Attivo")
OutLogProcess("[2] Nessun magazzino Attivo")
For Each ItemWarehouse In Map.refUnloadingAreaVM.WarehouseList
If ItemWarehouse.State = States.AVAILABLE Then
Map.refUnloadingAreaVM.bOrganizeWarehouse = Not SetCurrStorage(ItemWarehouse)
@@ -282,14 +305,14 @@ Public Class NCCommunication
' inizio a lavorare sul progetto corrente
If Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.LOADING Then
Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.WORKING
OutLogProcess("[2] Progetto pronto per pallettizzazione: " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString)
OutLogProcess("[2] Progetto pronto per pallettizzazione: " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString)
End If
' comunico nuovo magazzino
SetActiveWarehouse(CurrWarehouse)
' leggo lo stao del pallettizzatore
Dim StatusMachine2 As StatusMachine = StatusMachine.MOVING
If ReadInt("StatusMachine2", nValue) Then
If ReadInt("rStatusMachine2", nValue) Then
bRaededVariable = True
' converto in Enum
If nValue >= 0 OrElse nValue <= 4 Then
@@ -353,41 +376,54 @@ Public Class NCCommunication
If Not IsNothing(Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE)) AndAlso
Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE).Count > 0 Then
LocalPart = Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE)(0)
WriteReal("X_Table1", LocalPart.GetUnloadingPosTable1.x)
WriteReal("Y_Table1", LocalPart.GetUnloadingPosTable1.y)
WriteReal("Z_Table1", LocalPart.GetUnloadingPosTable1.z)
Dim PosTable1 As Point3d = LocalPart.GetUnloadingPosTable1
WriteReal("X_Table1", PosTable1.x)
WriteReal("Y_Table1", PosTable1.y)
WriteReal("Z_Table1", PosTable1.z)
WriteReal("C_Table1", LocalPart.DegAngOnTable)
PartWritePrivateProfilePoint(LocalPart.IdProject, ConstIni.S_PART & LocalPart.IdPart.ToString, "PointTable1", PosTable1)
Dim nIdHead As Integer = EgtGetHeadId(VACUUM_HEAD)
EgtSetStatus(nIdHead, GDB_ST.ON_)
EgtDraw()
' salvo le informazioni del pezzo manipolatore per il deposito
WriteReal("X_MotorStrip", LocalPart.GetloadingPosStrip.x)
WriteReal("Y_MotorStrip", LocalPart.GetloadingPosStrip.y)
WriteReal("Z_MotorStrip", LocalPart.GetloadingPosStrip.z)
WriteReal("C_MotorStrip", -LocalPart.DegAngOnTable)
'' eseguo una simulazione di deposito: ruoto attorno al riferimento della ventosa
'Dim ptRot As New Point3d
'ptRot.x = (LocalPart.MoveTable1.m_vtDelta + Point3d.ORIG - LocalPart.MoveTable1.m_ptCenMinRect).x
'ptRot.y = (LocalPart.MoveTable1.m_vtDelta + Point3d.ORIG - LocalPart.MoveTable1.m_ptCenMinRect).y
'EgtRotate(LocalPart.IdPart, ptRot, Vector3d.Z_AX, -LocalPart.MoveTable1.m_dAngRotDeg, GDB_RT.GLOB)
'Dim vtStepMove As New Vector3d(LocalPart.GetloadingPosStrip.x, LocalPart.GetloadingPosStrip.y, LocalPart.GetloadingPosStrip.z + 1000)
'' Posiziono il pezzo nell'orogine della tavola
'EgtMove(LocalPart.IdPart, New Point3d(0, 0, 1000) - LocalPart.GetPointOnTable1(LocalPart.MoveTable1.m_ptCenMinRect) + vtStepMove)
'EgtSetStatus(LocalPart.IdPart, GDB_ST.ON_)
'EgtDraw()
'' salvo le modifiche nel nuov file
'EgtSaveFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\" & CURR_PROJ_NAME, NGE.BIN)
Dim C_Ang As Double = 0
If LocalPart.MoveTable1.m_sCups.Contains("V8") Then
C_Ang = -90
End If
Dim PosStrip As Point3d = LocalPart.GetloadingPosStrip
WriteReal("X_MotorStrip", PosStrip.x)
WriteReal("Y_MotorStrip", PosStrip.y)
WriteReal("Z_MotorStrip", PosStrip.z)
WriteReal("C_MotorStrip", C_Ang)
PartWritePrivateProfilePoint(LocalPart.IdProject, ConstIni.S_PART & LocalPart.IdPart.ToString, "PointStrip", PosStrip)
' restitusco la dimensione x del pezzo
WriteReal("Rect1DimX", LocalPart.MoveTable1.m_vtRect.x * 2)
' salvo le ventose che devono essere attivate
For IndexVacuum = 1 To 6
For IndexVacuum = 1 To 8
WriteInt("Tb1Vacuum" & IndexVacuum.ToString, LocalPart.GetVacuumLoadingStatus("V" & IndexVacuum.ToString))
Next
' comunico se è ultimo pezzo
If LocalPart.IsLast Then
WriteInt("LastPartTable1", 1)
OutLogProcess("UnLoadTable1() -> Ultimo Pezzo prelevato dal tavolo: " & LocalPart.IdPart.ToString)
Else
WriteInt("LastPartTable1", -1)
OutLogProcess("UnLoadTable1() -> Altri pezzi da prelevare dal tavolo")
End If
' modifico il colore per indicare quale è il pezzo in elaborazione
Dim nIdRegion As Integer = GetRegionFromPart(LocalPart.IdPart)
If nIdRegion > 0 Then
EgtSetColor(nIdRegion, New Color3d(225, 0, 0, 80))
EgtDraw()
End If
' comunico nuovo stato alla macchina-> 1
WriteInt("StatusMachine1", CInt(StatusMachine.LOADED_POINT))
' comunic se è ultimo pezzo
If LocalPart.IsLast Then
WriteInt("LastPartTable2", 1)
End If
'EgtUILib.WritePrivateProfileString("0", "81.140", "1", "c:\EgtData\OmagVIEWPlus\Config\NC_Debug.ini")
OutLogProcess("UnLoadTable1() -> Communico punto di prelievo pezzo: " & LocalPart.IdPart.ToString)
OutLogProcess("UnLoadTable1() -> Stato macchina 1: 1" & LocalPart.IdPart.ToString)
OutLogProcess("UnLoadTable1() -> Stato macchina 1: 1 - " & LocalPart.IdPart.ToString)
End If
Return LocalPart
End Function
@@ -397,6 +433,7 @@ Public Class NCCommunication
If IsNothing(Map.refUnloadingAreaVM.GetCurrentWarehouse) Then Return True
For Each ItemBox In Map.refUnloadingAreaVM.GetCurrentWarehouse.Boxes
If ItemBox.State = States.LOADING Then
OutLogProcess("EndedUnloading() -> Box G" & ItemBox.OrigDefCN.ToString & " index " & ItemBox.Id.ToString & " incompleto")
Return False
End If
Next
@@ -404,6 +441,23 @@ Public Class NCCommunication
Return True
End Function
' restituisce l'Id della regione del pezzo
Private Function GetRegionFromPart(IdPart As Integer) As Integer
Dim nRegId As Integer = EgtGetFirstNameInGroup(IdPart, ConstGen.NAME_REGION)
If nRegId = GDB_ID.NULL Then
Return -1
End If
' Cerco prima regione nel layer
Dim nId = EgtGetFirstInGroup(nRegId)
While nId <> GDB_ID.NULL
If EgtGetType(nId) = GDB_TY.SRF_FRGN Then
Return nId
End If
nId = EgtGetNext(nId)
End While
Return -1
End Function
' verifico lo stato del magazzino (se tutto occupato allora lo libero subito)
Private Function CurrWarehaouseIsAvailable(CurrWareouse As WarehouseVM) As Boolean
If IsNothing(CurrWareouse) Then Return True
@@ -428,17 +482,25 @@ Public Class NCCommunication
' salvo il magazzino attivo (solo se è differente da quello corrente)
Private Sub SetActiveWarehouse(CurrWarehouse As WarehouseVM)
Dim nValue As Integer = 0
If ReadInt("ActiveStorage", nValue) Then
Dim enIdStorage As Warehouses
If nValue >= 0 OrElse nValue <= 4 Then
enIdStorage = DirectCast(nValue, Warehouses)
End If
If enIdStorage <> CurrWarehouse.Id Then
WarehauseWritePrivateProfileString("Warehouse", "ActiveStorage", CurrWarehouse.Id.ToString)
WriteInt("ActiveStorage", CInt(CurrWarehouse.Id))
OutLogProcess("SetActiveWarehouse() -> Comunico il cambio di magazzino alla macchina: " & CurrWarehouse.Id.ToString)
End If
End If
Dim dValue As Double = 0
' comunico il magazzino attivo
WarehauseWritePrivateProfileString("Warehouse", "ActiveStorage", CurrWarehouse.Id.ToString)
'' lo stato del magazzino è reale (solo nel plc)
'If ReadReal("rActiveStorage", dValue) Then
' Dim enIdStorage As Warehouses
' nValue = CInt(dValue)
' If nValue >= 0 OrElse nValue <= 4 Then
' enIdStorage = DirectCast(nValue, Warehouses)
' End If
' If enIdStorage <> CurrWarehouse.Id Then
' WarehauseWritePrivateProfileString("Warehouse", "ActiveStorage", CurrWarehouse.Id.ToString)
' nValue = CInt(CurrWarehouse.Id)
' WriteReal("ActiveStorage", CDbl(nValue))
' EgtUILib.WritePrivateProfileString("0", "81.6", nValue.ToString, "c:\EgtData\OmagVIEWPlus\Config\NC_Debug.ini")
' OutLogProcess("SetActiveWarehouse() -> " & enIdStorage.ToString & " <> " & CurrWarehouse.Id.ToString)
' OutLogProcess("SetActiveWarehouse() -> Comunico il cambio di magazzino alla macchina: " & CurrWarehouse.Id.ToString)
' End If
'End If
End Sub
' verifico che il magazzino corrente possa accogliere i nuovi pezzi
@@ -485,47 +547,53 @@ Public Class NCCommunication
ItemBox.State = States.LOADING
Map.refUnloadingAreaVM.CurrBox = ItemBox
' comunico le coordinte di afferraggio pezzo (indipendenti dal tipo di Box)
WriteReal("X_Ruller", LocalPart.GetLoadingPosRuller.x)
WriteReal("Y_Ruller", LocalPart.GetLoadingPosRuller.y)
WriteReal("Z_Ruller", LocalPart.GetLoadingPosRuller.z)
WriteReal("C_Ruller", 0)
Dim PointRuller As Point3d = LocalPart.GetLoadingPosRuller
WriteReal("X_Ruller", PointRuller.x)
WriteReal("Y_Ruller", PointRuller.y)
WriteReal("Z_Ruller", PointRuller.z)
WriteReal("C_Ruller", LocalPart.MoveTable2.m_dAngRotDeg)
PartWritePrivateProfilePoint(LocalPart.IdProject, ConstIni.S_PART & LocalPart.IdPart.ToString, "PointRuller", PointRuller)
' restitusco la dimensione x del pezzo
WriteReal("Rect2DimX", LocalPart.MoveTable2.m_vtRect.x * 2)
' cumunico l'id del box ativo
WriteInt("ActiveBox", ItemBox.Id)
' riconosco il tipo di box
Dim C_Ang As Double = 90
Dim C_Ang As Double = 0
Dim B_Ang As Double = 0
If ItemBox.enConfigBox = ConfigBox.PALLET Then
ItemPart.MoveTable2.m_vtDelta.Rotate(Vector3d.Z_AX(), 90)
' deposito sempre com la ventosa 8 rivolta verso i cancelli
C_Ang = 180
Dim vtCurrOffset As New Vector3d(Map.refUnloadingAreaVM.OffsetPalletX, Map.refUnloadingAreaVM.OffsetPalletY, ItemBox.GetPalletOffsetZ())
WriteReal("X_Box", LocalPart.GetUnloadingPosBox(vtCurrOffset).x)
WriteReal("Y_Box", LocalPart.GetUnloadingPosBox(vtCurrOffset).y)
WriteReal("Z_Box", LocalPart.GetUnloadingPosBox(vtCurrOffset).z)
Dim PointPallet As Point3d = LocalPart.GetUnloadingPosBox(vtCurrOffset)
WriteReal("X_Box", PointPallet.x)
WriteReal("Y_Box", PointPallet.y)
WriteReal("Z_Box", PointPallet.z)
PartWritePrivateProfilePoint(LocalPart.IdProject, ConstIni.S_PART & LocalPart.IdPart.ToString, "PointPallet", PointPallet)
' se il pallet è vicino all'uscita del magazzino
WriteReal("C_Box", C_Ang)
WriteReal("B_Box", B_Ang)
'' eseguo una simulazione di deposito
'EgtRotate(ItemPart.IdPart, ItemPart.MoveTable2.m_ptCenMinRect, Vector3d.Z_AX, C_Ang, GDB_RT.GLOB)
'Dim vtStep As New Vector3d(LocalPart.GetUnloadingPosBox(vtCurrOffset).x - 2000, LocalPart.GetUnloadingPosBox(vtCurrOffset).y + 1000, LocalPart.GetUnloadingPosBox(vtCurrOffset).z + 1000)
'EgtMove(ItemPart.IdPart, vtStep)
'EgtSetStatus(ItemPart.IdPart, GDB_ST.ON_)
'EgtDraw()
Else
ItemPart.MoveTable2.m_vtDelta.Rotate(Vector3d.Z_AX(), 90)
C_Ang = 90
B_Ang = -Map.refUnloadingAreaVM.AngRack
Dim vtCurrOffset As New Vector3d(ItemBox.GetRackOffsetX(ItemPart.MinRectY), Map.refUnloadingAreaVM.OffsetPalletY, ItemBox.GetRackOffsetZ(ItemPart.MinRectY, ItemPart.Height))
WriteReal("X_Box", LocalPart.GetUnloadingPosBox(vtCurrOffset).x)
WriteReal("Y_Box", LocalPart.GetUnloadingPosBox(vtCurrOffset).y)
WriteReal("Z_Box", LocalPart.GetUnloadingPosBox(vtCurrOffset).z)
' ottengo il vettore del baricentro (con piastrella verticale
Dim vtCurrOffset As New Vector3d(ItemBox.GetRackOffsetX(), Map.refUnloadingAreaVM.OffsetRackY, ItemBox.GetRackOffsetZ(ItemPart.MoveTable1.m_vtRect.y))
Dim PointRacks As Point3d = LocalPart.GetUnloadingPosRack(vtCurrOffset)
WriteReal("X_Box", PointRacks.z)
WriteReal("Y_Box", PointRacks.y)
WriteReal("Z_Box", PointRacks.z)
PartWritePrivateProfilePoint(LocalPart.IdProject, ConstIni.S_PART & LocalPart.IdPart.ToString, "PointRack", PointRacks)
WriteReal("C_Box", C_Ang)
WriteReal("B_Box", B_Ang)
End If
' salvo le ventose che devono essere attivate
For IndexVacuum = 1 To 6
For IndexVacuum = 1 To 8
WriteInt("Tb2Vacuum" & IndexVacuum.ToString, LocalPart.GetVacuumLoadingStatus("V" & IndexVacuum.ToString, "Table2"))
Next
bFoundBox = True
WriteInt("StatusMachine2", CInt(StatusMachine.LOADED_POINT))
'EgtUILib.WritePrivateProfileString("0", "81.192", "1", "c:\EgtData\OmagVIEWPlus\Config\NC_Debug.ini")
OutLogProcess("UnLoadTable2() -> Communico punto di prelievo pezzo: " & LocalPart.IdPart.ToString)
OutLogProcess("UnLoadTable2() -> Stato macchina 2: 1")
Exit For
@@ -572,15 +640,75 @@ Public Class NCCommunication
End If
End If
End If
OutLogProcess("<< ERRORE nella converione dati: [" & S_VARIABLES & "] '" & sVarName & "' non presente >>")
Return False
End Function
Friend Function WriteInt(sVarName As String, nValue As Integer) As Boolean
' definito il nome della variabile recupero l'inidirzzo variabile PLC e restituisco il valore letto da PLC
Private Function ReadReal(sVarName As String, ByRef dValue As Double) As Boolean
Dim bok As Boolean = True
Dim sVar As String = String.Empty
' leggo da file OmagVIEWPlus l'indirizzo della variabile associata
If GetMainPrivateProfileString(S_VARIABLES, sVarName, "", sVar) > 0 Then
' Spezzatura nei componenti: sVar -> ActiveStorage=81,0,2
Dim sVarSplit() As String = sVar.Split(","c)
If sVarSplit.Length = 3 Then
' elimino spazi
For Each Var In sVarSplit
Var = Var.Trim
Next
Dim nType As Integer = 0
Dim Type As Types = 0
' l'ulitmo codice identifica il tipo di variabile
Integer.TryParse(sVarSplit(2), nType)
If nType >= 0 AndAlso nType <= 7 Then Type = DirectCast(nType, Types)
' se il tipo è reale
If Type = 5 Then
Dim DbNumber As Integer = 0
Dim Start As Integer = 0
Integer.TryParse(sVarSplit(0), DbNumber)
Integer.TryParse(sVarSplit(1), Start)
' leggo dalla macchina (file NC_Debug.ini) il valore della variabile associata
If m_NC.ReadReal(DbNumber, Start, dValue) Then
' scrivo in backup
Dim sBackupFolder As String = Map.refMainWindowVM.MainWindowM.sLogDir & "\" & Date.Today.Year & "-" &
If(Date.Today.Month < 10, "0", "") & Date.Today.Month & "-" & If(Date.Today.Day < 10, "0", "") & Date.Today.Day & ".ini"
WritePrivateProfileString(m_nTime.ToString, DbNumber & "." & Start, dValue.ToString, sBackupFolder)
EgtOutLog("DB." & DbNumber.ToString & "DBD" & Start.ToString & " -> " & dValue)
Return True
Else
OutLogProcess("<< ERRORE nella comunicazione: DB." & DbNumber.ToString & "DBD." & dValue.ToString & " non presente >>")
End If
End If
End If
End If
OutLogProcess("<< ERRORE nella conversione dati: [" & S_VARIABLES & "] '" & sVarName & "' non presente >>")
Return False
End Function
' scrivo le variabili RG[n], n: indice della variabile RG
Friend Function WriteInt_RG(sVarName As String, nValue As Integer) As Boolean
Dim bok As Boolean = True
Dim sVar As String = String.Empty
' lettura dell'inidrizzo di memoria per la scrittura del valore e dell'indice di R
Dim DBNumber As Integer = 81
Dim nWriteValue As Integer = 0
Dim nWriteIndex As Integer = 0
If GetMainPrivateProfileString(S_VARIABLES, "ConvertToRG", "", sVar) > 0 Then
Dim sItemSplit() As String = sVarName.Split(","c)
If sItemSplit.Count = 3 And IsNumeric(sItemSplit(0)) And IsNumeric(sItemSplit(1)) And IsNumeric(sItemSplit(2)) Then
DBNumber = CInt(sItemSplit(0))
nWriteIndex = CInt(sItemSplit(1))
nWriteValue = CInt(sItemSplit(2))
Else
Return False
End If
Else
Return False
End If
' Lettura variabile
If GetMainPrivateProfileString(S_VARIABLES, sVarName, "", sVar) > 0 Then
' Spezzatura nei componenti
Dim sVarSplit() As String = sVar.Split(","c)
If sVarSplit.Length = 2 Then
@@ -612,23 +740,41 @@ Public Class NCCommunication
EgtOutLog("Scrittura sempre occupata")
Return False
End If
If m_NC.WriteInt(81, 144, nValue) And m_NC.WriteInt(81, 140, RNumber) Then
If m_NC.WriteInt(DBNumber, nWriteValue, nValue) And m_NC.WriteInt(DBNumber, nWriteIndex, RNumber) Then
' scrivo in backup
Dim sBackupFolder As String = Map.refMainWindowVM.MainWindowM.sLogDir & "\" & Date.Today.Year & "-" &
If(Date.Today.Month < 10, "0", "") & Date.Today.Month & "-" & If(Date.Today.Day < 10, "0", "") & Date.Today.Day & ".ini"
WritePrivateProfileString(m_nTime.ToString, "81.140", RNumber.ToString, sBackupFolder)
WritePrivateProfileString(m_nTime.ToString, "81.144", nValue.ToString, sBackupFolder)
WritePrivateProfileString(m_nTime.ToString, DBNumber.ToString & "." & nWriteValue.ToString, RNumber.ToString, sBackupFolder)
WritePrivateProfileString(m_nTime.ToString, DBNumber.ToString & "." & nWriteIndex.ToString, nValue.ToString, sBackupFolder)
Return True
End If
End If
End If
End If
OutLogProcess("<< ERRORE nella converione dati: [" & S_VARIABLES & "] '" & sVarName & "' non presente >>")
Return False
End Function
Friend Function WriteReal(sVarName As String, dValue As Double) As Boolean
Friend Function WriteReal_RG(sVarName As String, dValue As Double) As Boolean
Dim bok As Boolean = True
Dim sVar As String = String.Empty
' lettura dell'inidrizzo di memoria per la scrittura del valore e dell'indice di R
Dim DBNumber As Integer = 81
Dim nWriteValue As Integer = 0
Dim nWriteIndex As Integer = 0
If GetMainPrivateProfileString(S_VARIABLES, "ConvertToRG", "", sVar) > 0 Then
Dim sItemSplit() As String = sVarName.Split(","c)
If sItemSplit.Count = 3 And IsNumeric(sItemSplit(0)) And IsNumeric(sItemSplit(1)) And IsNumeric(sItemSplit(2)) Then
DBNumber = CInt(sItemSplit(0))
nWriteIndex = CInt(sItemSplit(1))
nWriteValue = CInt(sItemSplit(2))
Else
Return False
End If
Else
Return False
End If
' Lettura variabile
If GetMainPrivateProfileString(S_VARIABLES, sVarName, "", sVar) > 0 Then
' Spezzatura nei componenti
@@ -662,17 +808,129 @@ Public Class NCCommunication
EgtOutLog("Scrittura sempre occupata")
Return False
End If
If m_NC.WriteReal(81, 144, dValue) And m_NC.WriteInt(81, 140, RNumber) Then
If m_NC.WriteReal(DBNumber, nWriteValue, dValue) And m_NC.WriteInt(DBNumber, nWriteIndex, RNumber) Then
' scrivo in backup
Dim sBackupFolder As String = Map.refMainWindowVM.MainWindowM.sLogDir & "\" & Date.Today.Year & "-" &
If(Date.Today.Month < 10, "0", "") & Date.Today.Month & "-" & If(Date.Today.Day < 10, "0", "") & Date.Today.Day & ".ini"
WritePrivateProfileString(m_nTime.ToString, DBNumber.ToString & "." & nWriteValue.ToString, RNumber.ToString, sBackupFolder)
WritePrivateProfileString(m_nTime.ToString, DBNumber.ToString & "." & nWriteIndex.ToString, dValue.ToString, sBackupFolder)
Return True
End If
End If
End If
End If
OutLogProcess("<< ERRORE nella converione dati: [" & S_VARIABLES & "] '" & sVarName & "' non presente >>")
Return False
End Function
Friend Function WriteInt(sVarName As String, nValue As Integer) As Boolean
Dim bok As Boolean = True
Dim sVar As String = String.Empty
' Lettura variabile
If GetMainPrivateProfileString(S_VARIABLES, sVarName, "", sVar) > 0 Then
' Spezzatura nei componenti
Dim sVarSplit() As String = sVar.Split(","c)
If sVarSplit.Length = 3 Then
' elimino spazi
For Each Var In sVarSplit
Var = Var.Trim
Next
Dim nType As Integer = 0
Dim Type As Types = 0
Integer.TryParse(sVarSplit(2), nType)
If nType >= 0 AndAlso nType <= 7 Then Type = DirectCast(nType, Types)
If Type = 2 Then
Dim DbNumber As Integer = 0
Dim Start As Integer = 0
Integer.TryParse(sVarSplit(0), DbNumber)
Integer.TryParse(sVarSplit(1), Start)
If nValue > 65000 Then
EgtOutLog("Trying to write an overflow integer")
Return False
End If
'' controllo che scrittura sia disponibile
'Dim WriteValue As Integer = 0
'For Index = 0 To 10
' m_NC.ReadInt(DbNumber, Start, WriteValue)
' If WriteValue = 2000 Then
' Exit For
' End If
' System.Threading.Thread.Sleep(10)
'Next
'If WriteValue <> 2000 Then
' EgtOutLog("Scrittura sempre occupata")
' Return False
'End If
If m_NC.WriteInt(DbNumber, Start, CShort(nValue)) Then
' scrivo in backup
Dim sBackupFolder As String = Map.refMainWindowVM.MainWindowM.sLogDir & "\" & Date.Today.Year & "-" &
If(Date.Today.Month < 10, "0", "") & Date.Today.Month & "-" & If(Date.Today.Day < 10, "0", "") & Date.Today.Day & ".ini"
WritePrivateProfileString(m_nTime.ToString, "81.144", nValue.ToString, sBackupFolder)
EgtOutLog("Write:" & DbNumber & "." & Start & " -> " & CShort(nValue))
Return True
Else
OutLogProcess("<< IMPOSSIBILE COMUNICARE INTERO >>")
End If
End If
End If
End If
OutLogProcess("<< ERRORE nella converione dati: [" & S_VARIABLES & "] '" & sVarName & "' non presente >>")
Return False
End Function
Friend Function WriteReal(sVarName As String, dValue As Double) As Boolean
Dim bok As Boolean = True
Dim sVar As String = String.Empty
' Lettura variabile
If GetMainPrivateProfileString(S_VARIABLES, sVarName, "", sVar) > 0 Then
' Spezzatura nei componenti
Dim sVarSplit() As String = sVar.Split(","c)
If sVarSplit.Length = 3 Then
' elimino spazi
For Each Var In sVarSplit
Var = Var.Trim
Next
Dim nType As Integer = 0
Dim Type As Types = 0
Integer.TryParse(sVarSplit(2), nType)
If nType >= 0 AndAlso nType <= 7 Then Type = DirectCast(nType, Types)
If Type = 5 Then
Dim DbNumber As Integer = 0
Dim Start As Integer = 0
Integer.TryParse(sVarSplit(0), DbNumber)
Integer.TryParse(sVarSplit(1), Start)
If dValue > 65000 Then
EgtOutLog("Trying to write an overflow integer")
Return False
End If
'' controllo che scrittura sia disponibile
'Dim WriteValue As Integer = 0
'For Index = 0 To 10
' m_NC.ReadInt(DbNumber, Start, WriteValue)
' If WriteValue = 2000 Then
' Exit For
' End If
' System.Threading.Thread.Sleep(10)
'Next
'If WriteValue <> 2000 Then
' EgtOutLog("Scrittura sempre occupata")
' Return False
'End If
If m_NC.WriteReal(DbNumber, Start, CSng(dValue)) Then
' scrivo in backup
Dim sBackupFolder As String = Map.refMainWindowVM.MainWindowM.sLogDir & "\" & Date.Today.Year & "-" &
If(Date.Today.Month < 10, "0", "") & Date.Today.Month & "-" & If(Date.Today.Day < 10, "0", "") & Date.Today.Day & ".ini"
WritePrivateProfileString(m_nTime.ToString, "81.140", RNumber.ToString, sBackupFolder)
WritePrivateProfileString(m_nTime.ToString, "81.144", dValue.ToString, sBackupFolder)
Return True
End If
End If
End If
End If
OutLogProcess("<< ERRORE nella converione dati: [" & S_VARIABLES & "] '" & sVarName & "' non presente >>")
Return False
End Function
@@ -707,6 +965,7 @@ Public Class NCCommunication
End If
End If
End If
OutLogProcess("<< ERRORE nella converione dati: [" & S_VARIABLES & "] '" & sVarName & "' non presente >>")
Return False
End Function
+3
View File
@@ -10,6 +10,9 @@
</Grid.RowDefinitions>
<DockPanel HorizontalAlignment="Right" Grid.Row="1">
<TextBlock Text="Select manual parts for unloading" VerticalAlignment="Center"
Visibility="{Binding VisibilityManulaPartCommand}"
Margin="0,0,50,0"/>
<Button Content="Confirm" Width="100"
Visibility="{Binding VisibilityManulaPartCommand}"
Command="{Binding ConfirmManualPart_Command}"/>
+5 -1
View File
@@ -43,10 +43,14 @@
<Image Source="{Binding RullerArrowImage}"
Grid.ColumnSpan="2" Stretch="Uniform"
VerticalAlignment="Center" Margin="-364,39,364.4,38.2" />
<TextBlock Text="{Binding TableDifference}"
Grid.ColumnSpan="2"
Style="{StaticResource CounterPercentageTextBlock}"/>
<Image Source="{Binding RullerArrowImage}"
Visibility="Collapsed"
Grid.ColumnSpan="2" Stretch="Uniform"
VerticalAlignment="Center" Margin="469,39,-468.8,38.2" />
<!--comandi per selezioni tavola-->
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" >
<ToggleButton VerticalAlignment="Top"
+68 -14
View File
@@ -16,7 +16,7 @@ Public Class UnloadingAreaVM
'-----------------------------------------------------------------------------------------
' definsice se deve ricalcolato la disposizione dei pezzi nel magazzino
Private m_bOrganizeWarehouse As Boolean = False
Private m_bOrganizeWarehouse As Boolean = True
Public Property bOrganizeWarehouse As Boolean
Get
Return m_bOrganizeWarehouse
@@ -188,6 +188,35 @@ Public Class UnloadingAreaVM
Return m_AngRack
End Get
End Property
Private m_PivotCX As Double
Public ReadOnly Property PivotCX As Double
Get
Return m_PivotCX
End Get
End Property
Private m_PivotCY As Double
Public ReadOnly Property PivotCY As Double
Get
Return m_PivotCY
End Get
End Property
Private m_PivotBX As Double
Public ReadOnly Property PivotBX As Double
Get
Return m_PivotBX
End Get
End Property
Private m_PivotBY As Double
Public ReadOnly Property PivotBY As Double
Get
Return m_PivotBY
End Get
End Property
' altezza massima sul pallet
Private m_MaxHeight As Double
Public ReadOnly Property MaxHeight As Double
@@ -333,8 +362,8 @@ Public Class UnloadingAreaVM
End Get
Set(value As Visibility)
m_RullerArrowVisibility = value
NotifyPropertyChanged("RullerArrowVisibility")
NotifyPropertyChanged("RullerArrowImage")
NotifyPropertyChanged("RullerArrowVisibility")
End Set
End Property
@@ -536,7 +565,11 @@ Public Class UnloadingAreaVM
SetOffset(K_RACKY, m_OffsetRackY) AndAlso
SetOffset(K_ANGRACK, m_AngRack) AndAlso
SetOffset(K_RULLERX, m_OffsetRullerX) AndAlso
SetOffset(K_RULLERY, m_OffsetRullerY)
SetOffset(K_RULLERY, m_OffsetRullerY) AndAlso
SetOffset(K_PIVOTCX, m_PivotCX) AndAlso
SetOffset(K_PIVOTCY, m_PivotCY) AndAlso
SetOffset(K_PIVOTBX, m_PivotBX) AndAlso
SetOffset(K_PIVOTBX, m_PivotBX)
Dim bSetMaxPallet As Boolean = SetMaxPallet(K_MAX_HEIGHT, m_MaxHeight) AndAlso
SetMaxPallet(K_MAX_LENGTH, m_MaxLength) AndAlso
SetMaxPallet(K_MAX_WIDTH, m_MaxWidth)
@@ -651,6 +684,8 @@ Public Class UnloadingAreaVM
Exit For
End If
Next
ElseIf m_IdProjTable2.enStatus = StatusProj.WORKING Then
Return True
ElseIf Map.refMainWindowVM.MainWindowM.ProjIndList.Count = 0 Then
' se non ci sono progetti esco
Return True
@@ -658,14 +693,16 @@ Public Class UnloadingAreaVM
m_IdProjTable2 = Map.refMainWindowVM.MainWindowM.ProjIndList(0)
End If
OutLogProcess("OrganaizeWarehouse() -> Nuovo progetto per scarico macchin 2: " & m_IdProjTable2.nProjInd.ToString)
' questa veriabile è comandata all'interno del Refresh
'If Not m_bOrganizeWarehouse Then Return True
' recupero il magazzino attivo
Dim CurrWarehause As WarehouseVM = GetCurrentWarehouse()
If Not IsNothing(Me_Warehouse) Then
CurrWarehause = Me_Warehouse
End If
If IsNothing(CurrWarehause) Then Return False
If IsNothing(CurrWarehause) Then
OutLogProcess("OrganaizeWarehouse() -> Nessun magazzino attivo")
Return False
End If
' lista dei box disponibili (pallet/rack)
Dim nPallet As Integer = 0
@@ -692,11 +729,14 @@ Public Class UnloadingAreaVM
Dim RackPartList As New List(Of Part)
Dim PalletPartList As New List(Of Part)
' tutti quelli già sul rullo
For Each ItemPart In GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER)
Dim ListMotorRuller As ObservableCollection(Of Part) = GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER)
OutLogProcess("OrganaizeWarehouse() -> Pezzi sulla rulliera: " & ListMotorRuller.Count)
For Each ItemPart In ListMotorRuller
If ItemPart.enUnloading = Unloading.AUTOMATIC Then
If ItemPart.MinRectX > m_MaxLength Or ItemPart.MinRectY > m_MaxWidth Then
RackPartList.Add(ItemPart)
nPartOnRack = nPartOnRack + 1
OutLogProcess("OrganaizeWarehouse() -> Pezzo fuori dalle dimensioni massime pallet: " & ItemPart.IdPart.ToString)
Else
PalletPartList.Add(ItemPart)
nPartOnPallet = nPartOnPallet + 1
@@ -704,22 +744,26 @@ Public Class UnloadingAreaVM
End If
Next
' tutti quelli ancora sul tavolo
For Each ItemPart In GetParts(m_IdProjTable2.nProjInd, Place.ON_TABLE)
Dim ListTable As ObservableCollection(Of Part) = GetParts(m_IdProjTable2.nProjInd, Place.ON_TABLE)
OutLogProcess("OrganaizeWarehouse() -> Pezzi sul tavolo: " & ListTable.Count)
For Each ItemPart In ListTable
If ItemPart.enUnloading = Unloading.AUTOMATIC Then
If ItemPart.MinRectX > m_MaxLength Or ItemPart.MinRectY > m_MaxWidth Then
RackPartList.Add(ItemPart)
nPartOnRack = nPartOnRack + 1
OutLogProcess("OrganaizeWarehouse() -> Pezzo fuori dalle dimensioni massime rack: " & ItemPart.IdPart.ToString)
Else
PalletPartList.Add(ItemPart)
nPartOnPallet = nPartOnPallet + 1
End If
End If
Next
' recupero l'altezza del primo pezzo, altrimenti esco
Dim dHeightTile As Double = 0
If PalletPartList.Count > 0 Then
dHeightTile = PalletPartList(0).Height
Else
ElseIf PalletPartList.Count = 0 And RackPartList.Count = 0 Then
EgtOutLog("Warning: no parts for unloading")
Return True
End If
@@ -742,6 +786,8 @@ Public Class UnloadingAreaVM
For IndexBox = 0 To nTemRack - 1
If IndexPart <= RackPartList.Count - 1 Then
RackPartList(IndexPart).IdBox = AvailableRackList(IndexBox).Id
' salvo l'informazione nel file PartList
PartWritePrivateProfileInt(PalletPartList(IndexPart).IdProject, ConstIni.S_PART & PalletPartList(IndexPart).IdPart.ToString, "IdBox", PalletPartList(IndexPart).IdBox)
RackPartList(IndexPart).enWarehouse = CurrWarehause.Id
AvailableRackList(IndexBox).MyListPart.Add(RackPartList(IndexPart))
IndexPart = IndexPart + 1
@@ -755,6 +801,8 @@ Public Class UnloadingAreaVM
For IndexBox = 0 To nTemPallet - 1
If IndexPart <= PalletPartList.Count - 1 Then
PalletPartList(IndexPart).IdBox = AvailablePalletList(IndexBox).Id
' salvo l'informazione nel file PartList
PartWritePrivateProfileInt(PalletPartList(IndexPart).IdProject, ConstIni.S_PART & PalletPartList(IndexPart).IdPart.ToString, "IdBox", PalletPartList(IndexPart).IdBox)
PalletPartList(IndexPart).enWarehouse = CurrWarehause.Id
AvailablePalletList(IndexBox).MyListPart.Add(PalletPartList(IndexPart))
IndexPart = IndexPart + 1
@@ -809,19 +857,25 @@ Public Class UnloadingAreaVM
' scarico tutti i pezzi manuali rimasti sulla rulliera
Public Sub UnloadedManualPart()
Dim bManualUnloaded As Boolean = False
For Each ItemPart In GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER, StatusPart.GOOD)
For Each ItemPart In GetParts(Place.ON_MOTOR_RULLER, StatusPart.GOOD)
If ItemPart.enUnloading = Unloading.MANUAL Then
ItemPart.enPlace = Place.ON_MANUAL_BOX
bManualUnloaded = True
End If
Next
' se non ci sono pezzi del progetto corrente sulla rulliera considero il progetto terminato
If GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER).Count > 0 Then Return
If bManualUnloaded Then m_IdProjTable2.enStatus = StatusProj.DONE
If GetParts(Place.ON_MOTOR_RULLER).Count > 0 Then Return
Dim nIdProj As Integer = -1
If m_IdProjTable2.nProjInd > 0 Then
If bManualUnloaded Then m_IdProjTable2.enStatus = StatusProj.DONE
nIdProj = m_IdProjTable2.nProjInd
Else
nIdProj = Map.refMainWindowVM.MainWindowM.nProjInd
End If
OutLogProcess("UnloadedManualPart() -> Pezzi manuali scaricati")
OutLogProcess("UnloadedManualPart() -> Progetto terimnato: " & m_IdProjTable2.nProjInd.ToString)
OutLogProcess("UnloadedManualPart() -> Progetto terimnato: " & nIdProj.ToString)
' elimino il file ini associato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString & ".ini"
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & nIdProj.ToString & ".ini"
If My.Computer.FileSystem.FileExists(sFile) Then
My.Computer.FileSystem.DeleteFile(sFile)
OutLogProcess("UnloadedManualPart() -> Eliminato file: " & sFile)
+9 -10
View File
@@ -257,9 +257,10 @@ Public Class Box
Return dHeight
End Function
' restituisce la coordinata Y in funzione delle dimensioni del pezzo da depositare
Public Function GetRackOffsetX(MinRectY As Double) As Double
Dim nCounter As Double = 0
' restituisce la coordinata X in funzione delle dimensioni del pezzo da depositare
Public Function GetRackOffsetX() As Double
' decido di lavorare nel piano della piastrella
Dim nCounter As Double = 1
Dim dHeight As Double = 1
' inizializzo l'altezza di deposito con lo spessore del pezzo
For Each ItemPart In MyListPart
@@ -273,17 +274,15 @@ Public Class Box
End If
Next
Dim RadAngRack As Double = Map.refUnloadingAreaVM.AngRack * Math.PI / 180
Dim Cotangq As Double = 1 / Math.Tan(RadAngRack) ^ 2
Dim OffsetX As Double = dHeight * (1 - Cotangq) ^ 0.5
Dim OffsetX = dHeight / Math.Sin(RadAngRack)
OffsetX = nCounter * OffsetX
Return OffsetX - MinRectY / 2 * Math.Cos(RadAngRack)
Return OffsetX
End Function
' restituisce la coordinata Z in funzione delle dimensioni del pezzo da depositare
Public Function GetRackOffsetZ(MinRectY As Double, Heigth As Double) As Double
Dim RadAngRack As Double = Map.refUnloadingAreaVM.AngRack * Math.PI / 180
Dim OffsetZ As Double = MinRectY * Math.Sin(RadAngRack) + Heigth * Math.Cos(RadAngRack)
Return OffsetZ
Public Function GetRackOffsetZ(MinRectY As Double) As Double
' ricevo la coordinata y del vettore che unisce il centro allo spigolo in altoa snistra
Return MinRectY
End Function
'--------------------------------------------------------------------------------------------------------------------