OmagVIEWPlus 2.2j1:

-> nuova definizione dei pezzi (classe Part)
-> nuova gestione dei magazzini
-> aggiunta pagina per la selezione dei pezzi manuali
-> nuova configurazione delle variabili.
This commit is contained in:
Nicola Pievani
2020-10-09 08:13:48 +00:00
parent acb2c2b751
commit d950fc1060
51 changed files with 12255 additions and 412 deletions
+39
View File
@@ -50,5 +50,44 @@ Module ConstGen
Public Const TEMP_DIR As String = "Temp"
' Sottodirettorio backup
Public Const LOG_DIR As String = "Log"
' Sottodirettorio di default per le macchine
Public Const MACHINES_DFL_DIR As String = "Machines"
' Sottodirettorio di default per toolmakers
Public Const TOOLMAKERS_DFL_DIR As String = "ToolMakers"
' Nome file corrente
Public Const CURR_PROJ_NAME As String = "CurrProj.nge"
Public Const CURR_PROJ_NEW As String = "CurrProj.new"
Public Const CURR_PROJ_LOCK As String = "CurrProj.lck"
Public Const CURR_PROJ_EPL As String = "CurrProj.epl"
Public Const CURR_PROJ_PPL As String = "CurrProj.ppl"
Public Const CURR_PROJ_CHANGE As String = "CurrProj.chg"
' Nome della superficie del grezzo
Public Const NAME_RAW_SOLID As String = "RawSolid"
' Nome della regione fuori kerf nel grezzo
Public Const NAME_OUTKERF_REG As String = "SheetOut"
' Nome della regione di riferimento nel grezzo
Public Const NAME_REF_REG As String = "RefReg"
' Contrassegno di progetto OmagCut
Public Const NAME_PROJMARK As String = "OmagCut"
' Info per indice progetto
Public Const INFO_PROJINDEX As String = "ProjIndex"
' Info per materiale progetto
Public Const INFO_PROJMAT As String = "ProjMat"
' Info con path carico progetto
Public Const INFO_LOADPATH As String = "LoadPath"
' Info per stato scarico progetto salvato
Public Const INFO_UNLOADSAVED As String = "UnloadSaved"
' Nome layer delle regioni
Public Const NAME_REGION As String = "Region"
' Nome layer preview
Public Const NAME_PREVIEW As String = "PV"
' Info per stato pezzo
Public Const INFO_PARTOK As String = "POK"
' Info in pezzo con suo nome in Csv
Public Const INFO_CSV_PART As String = "CsvPart"
End Module
+29
View File
@@ -26,6 +26,7 @@ Module ConstIni
Public Const K_MESSAGES As String = "Messages"
Public Const K_WINPLACE As String = "WinPlace"
Public Const K_SUPPORT As String = "Support"
Public Const K_PROJDIR As String = "ProjDir"
Public Const S_LANGUAGES As String = "Languages"
Public Const K_LANGUAGE As String = "Language"
@@ -37,8 +38,36 @@ Module ConstIni
Public Const K_SLOT As String = "Slot"
Public Const K_TIMERINTERVAL As String = "TimerInterval"
Public Const S_OFFSET As String = "Offset"
Public Const K_PALLETX As String = "PalletX"
Public Const K_PALLETY As String = "PalletY"
Public Const K_PALLETZ As String = "PalletZ"
Public Const K_RACKX As String = "RackX"
Public Const K_RACKZ As String = "RackZ"
Public Const K_RACKY As String = "RackY"
Public Const K_ANGRACK As String = "AngRack"
Public Const K_RULLERX As String = "RullerX"
Public Const K_RULLERY As String = "RullerY"
Public Const S_BOX As String = "Box"
Public Const K_MAX_HEIGHT As String = "MaxHeightPallet"
Public Const K_MAX_LENGTH As String = "MaxLengthPallet"
Public Const K_MAX_WIDTH As String = "MaxWidthPallet"
Public Const K_MAX_TILE As String = "MaxTileRack"
Public Const S_WAREHOUSE As String = "Warehouse"
Public Const K_ACTIVESTORAGE As String = "ActiveStorage"
Public Const K_STORAGE As String = "Storage"
Public Const K_BOX As String = "Box"
Public Const S_VARIABLES As String = "Variables"
Public Const K_ACTIVEWAREHOUSE As String = "ActiveWarehouse"
Public Const S_PART As String = "Part"
Public Const K_IDPART As String = "IdPart"
Public Const K_IDPROJ As String = "IdProj"
Public Const K_STATUS As String = "Status"
Public Const K_PLACE As String = "Place"
Public Const K_UNLOADING As String = "Unloading"
End Module
File diff suppressed because it is too large Load Diff
+319
View File
@@ -0,0 +1,319 @@
'----------------------------------------------------------------------------
' EgalTech 2015-2017
'----------------------------------------------------------------------------
' File : ConstMach.vb Data : 10.04.17 Versione : 1.8d1
' Contenuto : Modulo costanti per lavorazioni/macchina.
'
'
'
' Modifiche : 10.04.17 DS Creazione modulo.
'
'
'----------------------------------------------------------------------------
Imports EgtUILib
Module ConstMach
' Delta Z sovratavola per evitare problemi di visualizzazione texture
Public Const DELTAZ_ADDTAB As Double = 0.1
' Nome gruppo dei sottopezzi
Public Const MACH_FIXT_GROUP As String = "Fixt"
' Nome tavola addizionale nel gruppo dei sottopezzi
Public Const MACH_ADD_TABLE As String = "AddTab"
' Info altezza tavola addizionale nella tavola
Public Const KEY_ADD_TABLE As String = "AddTab"
' Nome testa con ventose per spostamento pezzi
Public Const VACUUM_HEAD As String = "H4"
' Info tipo ventosa
Public Const KEY_VAC_TYPE As String = "VacType"
' Nome gruppo layout in testa con ventose
Public Const VACUUM_HEAD_LAYOUT As String = "LAYOUT"
' Base di info in gruppo layout per selezioni di ventose da verificare
Public Const KEY_VACLAY_SEL As String = "Sel"
' Info in gruppo layout per angolo di rotazione preferito
Public Const KEY_VACLAY_PREFROT As String = "PreferredRot"
' Info in gruppo layout per direzione di riferimento ventose per tagli da sotto
Public Const KEY_VACLAY_DRIPREFDIR As String = "DripRefDir"
' Info in asse rotante ventosa per step discreti
Public Const KEY_ROTVAC_STEPS As String = "STEPS"
' Nome oggetto frame prima uscita di una testa
Public Const HEAD_FIRST_EXIT As String = "_T1"
' Nomi tavole principale, seconda e terza
Public Const MAIN_TAB As String = "MainTab"
Public Const SECOND_TAB As String = "2ndTab"
Public Const THIRD_TAB As String = "3rdTab"
' Nome tavola ausiliaria per spostamento finale pezzi
Public Const AUX_TAB As String = "AuxTab"
' Costanti per lavorazioni
Public Const MACH_GROUP As String = "Mach01"
Public Const PHOTO_GRP As String = "Photos"
Public Const PHOTO_NAME As String = "Raw"
Public Const BASE_MACH_GROUP As String = "Mach_"
' Nome gruppo dei grezzi
Public Const MACH_RAWS_GROUP As String = "Raws"
' Nome della superficie del grezzo
Public Const NAME_RAW_SOLID As String = "RawSolid"
' Nome del centro del grezzo
Public Const NAME_RAW_CENTER As String = "RawCenter"
' Nome del contorno di kerf nel grezzo
Public Const NAME_KERF As String = "Kerf"
' Chiave per info di kerf nel grezzo
Public Const KEY_KERF As String = "Kerf"
' Nome del contorno del grezzo
Public Const NAME_RAW_OUTLINE As String = "RawOutline"
' Nome della regione del grezzo
Public Const NAME_RAW_REGION As String = "RawRegion"
' Nome della regione del kerf grezzo
Public Const NAME_KERF_REGION As String = "KerfRegion"
' Nome della regione fuori kerf nel grezzo
Public Const NAME_OUTKERF_REG As String = "SheetOut"
' Nome della regione di riferimento nel grezzo
Public Const NAME_REF_REG As String = "RefReg"
' Chiave per disabilitare la regione di riferimento
Public Const KEY_REF_REG_OFF As String = "Off"
' Chiave per definizione del grezzo per punti
Public Const KEY_RAWBYPOINTS As String = "Rbp"
' Nome del contorno di un'area rovinata
Public Const NAME_DAMAGED As String = "Damaged"
' Nome della regione di un'area rovinata
Public Const NAME_DAMAGED_REG As String = "DmgReg"
' Nome gruppo contorno grezzo da fotografia
Public Const NAME_RAW_PHOTO_OUTLINE As String = "RawPhotoOutline"
' Nome testo per Barcode
Public Const NAME_BARCODE As String = "BarCode"
' Info per identificativo blocco
Public Const INFO_RAW_BLOCK = "Block"
' Info per numero lastra nel blocco
Public Const INFO_RAW_SLABNBR = "SlabNbr"
' Contrassegno di progetto OmagCut
Public Const NAME_PROJMARK As String = "OmagCut"
' Info per stato flag taglio ridotto
Public Const INFO_REDUCEDCUT = "ReducedCut"
' Info per tastatura tagli con angolo di fianco
Public Const INFO_SACPROBE As String = "SacProbe"
' Info per lavaggio prima di spostamento pezzi con ventosa
Public Const INFO_WASHING As String = "Washing"
' Info per lavorazioni già ordinate
Public Const INFO_MACHORDER As String = "MachOrder"
' Info per indice progetto
Public Const INFO_PROJINDEX As String = "ProjIndex"
' Info per materiale progetto
Public Const INFO_PROJMAT As String = "ProjMat"
' Info per materiale foto
Public Const INFO_PHOTOMAT As String = "PhotoMat"
' Info per nome lastra
Public Const INFO_SLABNAME As String = "SlabName"
' Info per spessore lastra
Public Const INFO_SLABHEIGHT As String = "SlabHeight"
' Info per taglio di lama corrente
Public Const INFO_CURRSAWING As String = "CurrSawing"
' Info per fresatura corrente
Public Const INFO_CURRMILLING As String = "CurrMilling"
' Info per foratura corrente
Public Const INFO_CURRDRILLING As String = "CurrDrilling"
' Info per svuotatura corrente
Public Const INFO_CURRPOCKETING As String = "CurrPocketing"
' Info per getto d'acqua corrente
Public Const INFO_CURRWATERJETTING As String = "CurrWaterjetting"
' Info per programma di linea inviato
Public Const INFO_NCPROGSENT As String = "NcProgSent"
' Info per ingombro pezzi con gocciolatoio
Public Const INFO_DRIPBBOX As String = "DripBBox"
' Nome layer delle regioni
Public Const NAME_REGION As String = "Region"
' Nome solido derivato da regione del pezzo per taglio da sotto
Public Const NAME_DRIP_SOLID As String = "DripSolid"
' Delta Z regioni di pezzi per evitare problemi di visualizzazione con grezzi
Public Const DELTAZ_REG As Double = 0.1
' Nome layer contorni esterni
Public Const NAME_OUTLOOP As String = "OutLoop"
' Nome layer contorni interni
Public Const NAME_INLOOP As String = "InLoop"
' Nome layer percorsi sul pezzo
Public Const NAME_ONPATH As String = "OnPath"
' Nome layer percorsi di taglio da sotto (gocciolatoio)
Public Const NAME_DRIPCUT As String = "Drip"
' Nome layer percorsi di foratura da sotto
Public Const NAME_UNDERDRILL As String = "UnderDrill"
' Nome layer preview
Public Const NAME_PREVIEW As String = "PV"
' Info in entità da tagliare per affondamento
Public Const INFO_DEPTH As String = "Depth"
Public Const INFO_DEPTH2 As String = "Depth2"
' Info in entità da tagliare per taglio ristretto
Public Const INFO_STRICT As String = "Strict"
' Info in entità da tagliare per angolo di lato e tallone
Public Const INFO_SIDE_ANGLE As String = "SideAng"
Public Const INFO_OFFSET As String = "Offset"
Public Const INFO_SIDE_ANGLE2 As String = "SideAng2"
Public Const INFO_OFFSET2 As String = "Offset2"
Public Const INFO_HEEL As String = "Heel"
Public Const INFO_ORIG_SIDE_ANGLE As String = "OrigSideAng"
Public const INFO_SIDE_FIXED As String = "SideFixed"
' Info in entità da tagliare per gocciolatoio
Public Const INFO_HAVE_DRIP As String = "HaveDrip"
' Info in entità da tagliare per direzione che varia a seconda del tipo (una via o zigzag)
Public Const INFO_DIR As String = "Dir"
' Info in entità da tagliare per abilitare possibilità di inversione
Public Const INFO_ENABLE_INVERT As String = "EnInv"
' Info in entità da tagliare per angolo con entità precedente e successiva
Public Const INFO_PREVANG As String = "PrevAng"
Public Const INFO_NEXTANG As String = "NextAng"
' Info in entità da tagliare per lunghezza libera prima dell'inizio
Public Const INFO_START_FREELEN As String = "SFL"
' Info in entità da tagliare per lunghezza libera dopo la fine
Public Const INFO_END_FREELEN As String = "EFL"
' Angolo esterno minimo per calcolare la direzione libera sull'arco
Public Const FL_ARC_ANG_MIN As Double = 30
' Info in preview lavorazione con identificativo layer preview spostato nel pezzo
Public Const INFO_PV_ONPART_ID As String = "PvId"
' Info in lavorazione con identificativo lavorazioni inglobate
Public Const INFO_MCH_OTHMID As String = "OthMIds"
' Info in lavorazione con nome layer di provenieneza della geometria lavorata
Public Const INFO_MCH_LAYER As String = "Lay"
' Info lavorazione disabilitata dall'utente
Public Const INFO_MCH_USER_OFF As String = "UserOff"
' Info lavorazione disabilitata perchè lavorata in doppio con altra
Public Const INFO_MCH_DUPLED As String = "Dupled"
' Info lavorazione per pausa alla fine
Public Const INFO_MCH_PAUSE As String = "Pause"
' Info allungamento iniziale lavorazione imposto dall'utente
Public Const INFO_MCH_USER_SAL As String = "Usal"
' Info allungamento finale lavorazione imposto dall'utente
Public Const INFO_MCH_USER_EAL As String = "Ueal"
' Nome contorno taglio
Public Const NAME_PV_CUT As String = "CUT"
' Nome contorno pre-taglio
Public Const NAME_PV_PRECUT As String = "PRC"
' Nome contorno post-taglio
Public Const NAME_PV_POSTCUT As String = "POC"
' Nome contorno in basso taglio
Public Const NAME_PV_DOWN_CUT As String = "DCUT"
' Nome contorno in basso pre-taglio
Public Const NAME_PV_DOWN_PRECUT As String = "DPRC"
' Nome contorno in basso post-taglio
Public Const NAME_PV_DOWN_POSTCUT As String = "DPOC"
' Nome regione taglio
Public Const NAME_PV_RCUT As String = "RCUT"
' Nome regione pre-taglio (attacco)
Public Const NAME_PV_RLICUT As String = "RLICUT"
' Nome regione post-taglio (uscita)
Public Const NAME_PV_RLOCUT As String = "RLOCUT"
' Info in lavorazione taglio per attacco originale
Public Const INFO_MCH_ORILEADIN As String = "OriLI"
' Info in lavorazione taglio per uscita originale
Public Const INFO_MCH_ORILEADOUT As String = "OriLO"
' Info in pezzo con path di provenienza
Public Const INFO_SOU_PATH As String = "SouPath"
' Info in pezzo con path di Csv di provenienza
Public Const INFO_CSV_PATH As String = "CsvPath"
' Info in pezzo con suo nome in Csv
Public Const INFO_CSV_PART As String = "CsvPart"
' Info in pezzo con suo ordine in Csv
Public Const INFO_CSV_ORD As String = "CsvOrd"
' Info in pezzo con sua distinta in Csv
Public Const INFO_CSV_DIST As String = "CsvDist"
' Info in pezzo con suo materiale in Csv
Public Const INFO_CSV_MAT As String = "CsvMat"
' Info in pezzo con dimensione X in Csv
Public Const INFO_CSV_V1 As String = "V1"
' Info in pezzo con dimensione Y in Csv
Public Const INFO_CSV_V2 As String = "V2"
' Nome layer per valori angoli di inclinazione dei lati
Public Const SIDE_ANGLE_LAYER As String = "SideAngle"
' Nome layer per regioni selezione percorsi interni
Public Const SELECT_REGION_LAYER As String = "SelectRegion"
' Info in pezzo per stato rotazione
Public Const INFO_PARTROT As String = "ROT"
' Nome di pezzo che è una cornice
Public Const NAME_FRAME As String = "Frame"
' Nome del layer con la sezione della cornice
Public Const NAME_SECT As String = "Sect"
' Nome del layer con la linea guida della cornice
Public Const NAME_GUIDE As String = "Guide"
' Nome del layer con la superficie della cornice
Public Const NAME_SURF As String = "Surf"
' Nome del layer con la superficie facet della cornice
Public Const NAME_FACET As String = "Facet"
' Info con direzione della cornice (0=lungoX,1=lungoY,2=arca,3=guida)
Public Const INFO_FRAME_DIR As String = "Dir"
' Info con raggio della cornice ad arco
Public Const INFO_FRAME_ARCRAD As String = "ArcRad"
' Info con angolo della cornice ad arco
Public Const INFO_FRAME_ARCANG As String = "ArcAng"
' Nome della lavorazione di sgrossatura cornici
Public Const NAME_FRAME_SAWROU As String = "FrameSawRou"
' Nome della lavorazione di finitura cornici
Public Const NAME_FRAME_SAWFIN As String = "FrameSawFin"
' Nome della lavorazione di spatolatura cornici
Public Const NAME_FRAME_SAWSIDEFIN As String = "FrameSawSideFin"
' Nome della lavorazione di taglio singolo cornici
Public Const NAME_FRAME_SAWSINGLE As String = "FrameSawSingle"
' Info in pezzo per ultima superficie selezionata
Public Const INFO_FRAME_SURF As String = "Surf"
' Info in pezzo per facet di ultima superficie selezionata
Public Const INFO_FRAME_FACET As String = "Facet"
' Nome di pezzo per tagli diretti
Public Const NAME_DIRECTCUT As String = "DirectCut"
' Nome di pezzo temporaneo che serve per copia dime
Public Const NAME_COPYTEMPLATE As String = "CopyTemplate"
' Chiave per Id originale del pezzo per VeinMatch
Public Const KEY_ORI_ID As String = "OriId"
' Costante per flag di BBox
Public Const BBFLAG As Integer = GDB_BB.ONLY_VISIBLE + GDB_BB.IGNORE_TEXT + GDB_BB.IGNORE_DIM
' Lunghezza libera infinita
Public Const FREELEN_INF = 9999
' Colori per lavorazioni
Public Function COL_MCH_CUT() As Color3d
Return New Color3d(0, 255, 0)
End Function
Public Function COL_MCH_CUT_ANG() As Color3d
Return New Color3d(255, 0, 255)
End Function
Public Function COL_MCH_FREE() As Color3d
Return New Color3d(0, 0, 255)
End Function
Public Function COL_MCH_ONCUT() As Color3d
Return New Color3d(255, 165, 0)
End Function
Public Function COL_MCH_ONFREE() As Color3d
Return New Color3d(192, 128, 0)
End Function
Public Function COL_MCH_DRIPCUT() As Color3d
Return New Color3d(255, 0, 165)
End Function
Public Function COL_MCH_DRIPFREE() As Color3d
Return New Color3d(192, 0, 128)
End Function
Public Function COL_MCH_INTERF() As Color3d
Return New Color3d(255, 0, 0)
End Function
Public Function COL_MCH_DISABLED() As Color3d
Return New Color3d(96, 96, 96)
End Function
Public Function COL_MCH_DIS_NUMBER() As Color3d
Return New Color3d(32, 32, 128)
End Function
Public Function COL_MCH_DIS_INTERF() As Color3d
Return New Color3d(224, 64, 64)
End Function
' Colore superficie di cornice
Public Function COL_FRAME() As Color3d
Return New Color3d(128, 192, 96)
End Function
End Module
+263
View File
@@ -0,0 +1,263 @@
Module ConstMachIni
Public Const S_NUMERICALCONTROL As String = "NumericalControl"
Public Const K_TYPE As String = "Type"
Public Const S_PARTPROGRAM As String = "PartProgram"
Public Const K_EXTENSION As String = "Extension"
Public Const S_AXES As String = "Axes"
Public Const K_AXESNUM As String = "AxesNum"
Public Const K_SIMULATIONAXESNUM As String = "SimulationAxesNum"
Public Const K_L1NAME As String = "L1Name"
Public Const K_L1ID As String = "L1Id"
Public Const K_L2NAME As String = "L2Name"
Public Const K_L2ID As String = "L2Id"
Public Const K_L3NAME As String = "L3Name"
Public Const K_L3ID As String = "L3Id"
Public Const K_R1NAME As String = "R1Name"
Public Const K_R1ID As String = "R1Id"
Public Const K_R2NAME As String = "R2Name"
Public Const K_R2ID As String = "R2Id"
Public Const K_A6NAME As String = "A6Name"
Public Const K_A6ID As String = "A6Id"
Public Const K_A7NAME As String = "A7Name"
Public Const K_A7ID As String = "A7Id"
Public Const K_A8NAME As String = "A8Name"
Public Const K_A8ID As String = "A8Id"
Public Const K_A9NAME As String = "A9Name"
Public Const K_A9ID As String = "A9Id"
Public Const K_A10NAME As String = "A10Name"
Public Const K_A10ID As String = "A10Id"
Public Const K_DELTA_C As String = "DeltaC"
Public Const K_ININCHES As String = "InInches"
Public Const S_NCSIEMENS As String = "NcSiemens"
Public Const K_COMM_NAME As String = "CommName"
Public Const K_PATH_HMI As String = "PathHmi"
Public Const S_NCNUM As String = "NcNUM"
Public Const K_RESETSENDDELAY As String = "ResetSendDelay"
Public Const S_NCDATA As String = "NcData"
Public Const K_COMM As String = "Comm"
Public Const K_REFRESH As String = "Refresh"
Public Const K_MODE As String = "Mode"
Public Const K_JOGINCR As String = "JogIncr"
Public Const K_FEED As String = "Feed"
Public Const K_FEEDOVR As String = "FeedOvr"
Public Const K_SPEED As String = "Speed"
Public Const K_SPEEDOVR As String = "SpeedOvr"
Public Const K_POWER As String = "Power"
Public Const K_SPINDLE As String = "Spindle"
Public Const K_LASER As String = "Laser"
Public Const K_LASERTRAC As String = "LaserTrac"
Public Const K_COOLANT As String = "Coolant"
Public Const K_INTERNALCOOLANT As String = "InternalCoolant"
Public Const K_EXTERNCOOLANT As String = "ExternCoolant"
Public Const K_CAXES As String = "CAxes"
Public Const K_BAXES As String = "BAxes"
Public Const K_THREEAXES As String = "ThreeAxes"
Public Const K_FIVEAXES As String = "FiveAxes"
Public Const K_AIRBLOW As String = "AirBlow"
Public Const K_HOME As String = "Home"
Public Const K_TABLEUP As String = "TableUp"
Public Const K_TABLEDOWN As String = "TableDown"
Public Const K_MANUAL As String = "Manual"
Public Const K_DOORCLOSED As String = "DoorClosed"
Public Const K_LIMITZ As String = "LimitZ"
Public Const K_POWEROVR As String = "PowerOvr"
Public Const K_VACUUMUP As String = "VacuumUp"
Public Const K_VACUUMDOWN As String = "VacuumDown"
Public Const K_VACUUM2UP As String = "Vacuum2Up"
Public Const K_VACUUM2DOWN As String = "Vacuum2Down"
Public Const K_VACUUM0 As String = "Vacuum0"
Public Const K_VACUUM90 As String = "Vacuum90"
Public Const K_VACUUM1STATE As String = "Vacuum1State"
Public Const K_VACUUM2STATE As String = "Vacuum2State"
Public Const K_VACUUM3STATE As String = "Vacuum3State"
Public Const K_VACUUM4STATE As String = "Vacuum4State"
Public Const K_VACUUM5STATE As String = "Vacuum5State"
Public Const K_VACUUM6STATE As String = "Vacuum6State"
Public Const K_VACUUM135STATE As String = "Vacuum135State"
Public Const K_VACUUM246STATE As String = "Vacuum246State"
Public Const K_OPENALLSTATE As String = "OpenAllState"
Public Const K_CLOSEALLSTATE As String = "CloseAllState"
Public Const K_OPEN123STATE As String = "Open123State"
Public Const K_OPEN456STATE As String = "Open456State"
Public Const K_CLOSE123STATE As String = "Close123State"
Public Const K_CLOSE456STATE As String = "Close456State"
Public Const K_BLOWSTATE As String = "BlowState"
Public Const K_VACUUMSTATE As String = "VacuumState"
Public Const K_VACUUMON As String = "VacuumOn"
Public Const K_VACUUMOFF As String = "VacuumOff"
Public Const K_BYPASSTATE As String = "BypassState"
Public Const S_PRODUCTIONLINE As String = "ProductionLine"
Public Const K_ACTIVE As String = "Active"
Public Const K_NAMEPROG1 As String = "NameProg1"
Public Const K_VARPROG1 As String = "VarProg1"
Public Const K_NAMEPROG2 As String = "NameProg2"
Public Const K_VARPROG2 As String = "VarProg2"
Public Const K_LINEDATADIR As String = "DataDir"
Public Const K_VARPROJCOPY As String = "VarProjCopy"
Public Const K_SPECIALUNLOAD As String = "SpecialUnload"
Public Const K_SAVEPRODUCED As String = "SaveProduced"
Public Const K_VARPROGTWINS As String = "VarProgTwins"
Public Const K_ASKNEWONRESEND As String = "AskNewOnResend"
Public Const K_PRODLIENABLESAWPROBE As String = "EnableSawProbe"
Public Const K_PRODLIPROBINGSTATEVAR As String = "ProbingStateVar"
Public Const K_PRODLIPROBINGTCPOSVAR As String = "ProbingTcPosVar"
Public Const K_PRODLISAWDIAMETERVAR As String = "SawDiameterVar"
Public Const K_PRODLIPROBINGSTATE2VAR As String = "ProbingState2Var"
Public Const K_PRODLIPROBINGTCPOS2VAR As String = "ProbingTcPos2Var"
Public Const K_PRODLISAWDIAMETER2VAR As String = "SawDiameter2Var"
Public Const S_STATISTICS As String = "Stats"
Public Const K_DATADIR As String = "DataDir"
Public Const K_SHOWAREAS As String = "ShowAreas"
Public Const S_TABLE As String = "Table"
Public Const K_ADDITIONALTABLE As String = "AdditionalTable"
Public Const K_TAB2_ADDITIONALTABLE As String = "Tab2AdditionalTable"
Public Const K_TAB3_ADDITIONALTABLE As String = "Tab3AdditionalTable"
Public Const K_CENTER_RAW_ONX As String = "CenterRawOnX"
Public Const S_PHOTO As String = "Photo"
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 S_TOOLS As String = "Tools"
Public Const K_DRILLBIT As String = "Drillbit"
Public Const K_SAWBLADE As String = "Sawblade"
Public Const K_MILL As String = "Mill"
Public Const K_CUPWHEEL As String = "CupWheel"
Public Const K_POLISHINGWHEEL As String = "PolishingWheel"
Public Const K_WATERJET As String = "WaterJet"
Public Const K_SHOWTOOLCHANGER As String = "ShowToolChanger"
Public Const K_SHOWHEADEXIT As String = "ShowHeadExit"
Public Const K_SHOWUSERNOTES As String = "ShowUserNotes"
Public Const K_SHOWSPECIALS As String = "ShowSpecials"
Public Const K_DRILLHOLDER As String = "DrillHolder"
Public Const K_SAWBLADEHOLDER As String = "SawBladeHolder"
Public Const K_MILLHOLDER As String = "MillHolder"
Public Const K_DRILLMAKER As String = "DrillMaker"
Public Const K_SAWBLADEMAKER As String = "SawBladeMaker"
Public Const K_MILLMAKER As String = "MillMaker"
Public Const K_MOUNTEDTOOLCONFIG As String = "MountedToolConfig"
Public Const K_MAXSAWDIAMFORVAC As String = "MaxSawDiamForVac"
Public Const K_MAXSAWDIAMFORPROBE As String = "MaxSawDiamForProbe"
Public Const S_MACHININGS As String = "Machinings"
Public Const K_SAWING As String = "Sawing"
Public Const K_DRILLING As String = "Drilling"
Public Const K_MILLING As String = "Milling"
Public Const K_POCKETING As String = "Pocketing"
Public Const K_POLISHING As String = "Polishing"
Public Const K_SAWROUGHING As String = "SawRoughing"
Public Const K_SAWFINISHING As String = "SawFinishing"
Public Const K_WATERJETTING As String = "WaterJetting"
Public Const K_SAWINGSPECIALLEADIN As String = "SawingSpecialLeadIn"
Public Const S_MACH_NEST As String = "Nest"
Public Const K_MACH_HOLES_OFFSET As String = "HolesOffset"
Public Const K_MACH_HOLES_OVERLAP As String = "HolesOverlap"
Public Const K_MACH_HOLES_DIAMTOLER As String = "HolesDiamToler"
Public Const K_MACH_ONEHOLE_INTCORNER As String = "OneHoleOnIntCorner"
Public Const K_MACH_SAFE_LEN_CUT As String = "SafeLenOnCut"
Public Const K_MACH_SAFE_LEN_INTCORNER As String = "SafeLenOnIntCorner"
Public Const K_MACH_REDUCEDCUT As String = "ReducedCut"
Public Const K_MACH_REDUCEDDEPTH As String = "ReducedDepth"
Public Const K_MACH_EXTARCMINRAD As String = "ExtArcMinRad"
Public Const K_MACH_INTARCMAXSIDEANG As String = "IntArcMaxSideAng"
Public Const K_MACH_MILLING_ON_CORNERS As String = "MillingOnCorners"
Public Const K_MACH_MILLING_ON_SINKS As String = "MillingOnSinks"
Public Const K_MACH_MILLING_SHORTENING As String = "MillingShortening"
Public Const K_MACH_ENGRAVING_WITHMILL As String = "EngravingWithMill"
Public Const K_MACH_ENGRAVING_DEPTH As String = "EngravingDepth"
Public Const K_MACH_ENGRAVING_WIDTH As String = "EngravingWidth"
Public Const K_MACH_NEST_ALIGNED As String = "Aligned"
Public Const K_MACH_NEST_AUTOMATIC As String = "Automatic"
Public Const K_MACH_WASHING As String = "Washing"
Public Const K_MACH_SACPROBE As String = "SacProbe"
Public Const K_MACH_ENABLERESTART As String = "EnableRestart"
Public Const K_MACH_ENABLEPAUSE As String = "EnablePause"
Public Const K_MACH_CUTFSEVENABLE As String = "CutFsevEnable"
Public Const K_MACH_CUTFSEVLEN As String = "CutFsevLen"
Public Const K_MACH_CUTFSEVPERC As String = "CutFsevPerc"
' DrillMillC90
' CutLongDxSx
' AngRotMultiCut
' MinDistHeadsMultiCut
' MinSawRbHeight
Public Const S_MACH_RAWMOVE As String = "RawMove"
Public Const K_MACH_RM_ROTATE As String = "Rotate"
Public Const K_MACH_RM_FINALMOVE As String = "FinalMove"
Public Const S_MACH_REG As String = "Reg"
Public Const K_MACH_MAX_ROT_ANG As String = "MaxRotAng"
Public Const S_TOOLCHANGER As String = "ToolChanger"
Public Const K_NUMBER As String = "Number"
Public Const K_POS As String = "Pos"
Public Const K_NAME As String = "Name"
Public Const K_MANUALNUMBER As String = "ManualNumber"
Public Const K_MANUALPOS As String = "ManualPos"
Public Const K_MANUALNAME As String = "ManualName"
Public Const S_MACH_DIRECTCUTS As String = "DirectCuts"
Public Const K_FINALHOME As String = "FinalHome"
Public Const K_ADDSAWTHTO5AXMOVE As String = "AddSawThTo5AxMove"
Public Const S_MACHBUTTONS As String = "MachButtons"
Public Const S_CONTROLMACHBUTTONS As String = "ControlMachButtons"
Public Const S_VACUUMMACHBUTTONS As String = "VacuumMachButtons"
Public Const K_BUTTON As String = "Button"
Public Const S_MACH_INPROGRESS As String = "InProgress"
Public Const K_PHASEVAR As String = "PhaseVar"
Public Const S_MACH_PROBING As String = "Probing"
Public Const K_PROBINGSTATEVAR As String = "ProbingStateVar"
Public Const K_SAWDIAMETER As String = "SawDiameter"
Public Const K_RAWTHICKNESS As String = "RawThickness"
Public Const K_ENABLERAWPROBE As String = "EnableRawProbe"
Public Const S_MACH_BARCODEREADER As String = "BarcodeReader"
Public Const K_ENABLEBCR As String = "EnableBCR"
Public Const S_MACH_ESTIMATIONS As String = "Estimations"
Public Const K_ENABLEEST As String = "Enable"
Public Const S_MACH_MACH As String = "Mach"
Public Const K_CURRSAW As String = "CurrSaw"
Public Const K_CURRDRILL As String = "CurrDrill"
Public Const K_CURRMILL As String = "CurrMill"
Public Const K_CURRMILLNOTIP As String = "CurrMillNoTip"
Public Const K_CURRDRIPSAW As String = "CurrDripSaw"
Public Const K_CURRDRIPDRILL As String = "CurrDripDrill"
Public Const K_CURRWATERJET As String = "CurrWaterJet"
Public Const K_CURRSAWING As String = "CurrSawing"
Public Const K_CURRDRILLING As String = "CurrDrilling"
Public Const K_CURRMILLING As String = "CurrMilling"
Public Const K_CURRPOCKETING As String = "CurrPocketing"
Public Const K_CURRSAWROUGHING As String = "CurrSawRoughing"
Public Const K_CURRSAWFINISHING As String = "CurrSawFinishing"
Public Const K_CURRSAWSIDEFINISHING As String = "CurrSawSideFinishing"
Public Const K_CURRSAWSINGLE As String = "CurrSawSingle"
Public Const K_CURRDRIPSAWING As String = "CurrDripSawing"
Public Const K_CURRDRIPDRILLING As String = "CurrDripDrilling"
Public Const K_CURRWATERJETTING As String = "CurrWaterJetting"
Public Const S_MATERIALS As String = "Materials"
Public Const K_CURRMATERIAL As String = "CurrMaterial"
Public Const K_CURROFFICEMATERIAL As String = "CurrOfficeMaterial"
Public Const K_MATERIAL As String = "Material"
Public Const S_SETUP As String = "SetUp"
Public Const K_DEFAULT As String = "Default"
End Module
+528
View File
@@ -0,0 +1,528 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Module CsvM
' Dati lista
Private m_sCsvPath As String = String.Empty
Public ReadOnly Property CsvPath As String
Get
Return m_sCsvPath
End Get
End Property
Private m_CsvPartList As New List(Of CsvPart)
Public ReadOnly Property CsvPartList As List(Of CsvPart)
Get
Return m_CsvPartList
End Get
End Property
Private m_bCsvPartListModified As Boolean = False
Private m_sCompoDir As String = String.Empty
#Region "METHODS"
Public Sub InitCsvM()
' Leggo direttorio componenti
GetMainPrivateProfileString(S_COMPO, K_COMPODIR, "", m_sCompoDir)
' Leggo lista pezzi corrente
Dim sCsvFile As String = String.Empty
GetMainPrivateProfileString(S_CSV, K_CSVLASTFILE, "", sCsvFile)
If Not String.IsNullOrEmpty(sCsvFile) Then
LoadCsvPartList(sCsvFile)
End If
End Sub
Public Sub NewCmd()
' Salvo lista dei pezzi attuale (se modificata)
If Not SaveCsvPartList() Then
' Errore nel salvataggio del file CSV, vuoi continuare lo stesso ? - Errore
If MessageBox.Show(EgtMsg(MSG_CSVPAGEUC + 5), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.YesNo, MessageBoxImage.Error) <> MessageBoxResult.Yes Then
Return
End If
End If
' Pulisco path e lista dei pezzi Csv
m_sCsvPath = String.Empty
m_CsvPartList.Clear()
m_bCsvPartListModified = False
' Registro in ini nessuna path
WriteMainPrivateProfileString(S_CSV, K_CSVLASTFILE, "")
End Sub
Public Sub Open()
' Salvo lista dei pezzi attuale (se modificata)
If Not SaveCsvPartList() Then
' Errore nel salvataggio del file CSV, vuoi continuare lo stesso ? - Errore
If MessageBox.Show(EgtMsg(MSG_CSVPAGEUC + 5), EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.YesNo, MessageBoxImage.Error) <> MessageBoxResult.Yes Then
Return
End If
End If
' Leggo direttorio corrente dei file CSV
Dim sCurrDir As String = ""
GetMainPrivateProfileString(S_CSV, K_CSVCURRDIR, "C:\", sCurrDir)
' Apro dialogo scelta file
Dim CsvFileDlg As New Microsoft.Win32.OpenFileDialog()
If Directory.Exists(sCurrDir) Then CsvFileDlg.InitialDirectory = sCurrDir
CsvFileDlg.Filter = "Csv file|*.Csv|Epl file|*.Epl"
If Not CsvFileDlg.ShowDialog() Then Return
' Salvo direttorio corrente
WriteMainPrivateProfileString(S_CSV, K_CSVCURRDIR, Path.GetDirectoryName(CsvFileDlg.FileName))
' Apertura file
Dim sPath = CsvFileDlg.FileName
If String.Compare(Path.GetExtension(sPath), ".CSV", True) = 0 Then
LoadCsvFile(sPath)
Else
LoadCsvPartList(sPath)
End If
End Sub
Public Sub Insert()
' Recupero lo spessore della lastra corrente
Dim dRawHeight As Double = EstCalc.GetRawHeight()
If dRawHeight < EPS_SMALL Then Return
' Recupero il materiale della lastra corrente
Dim sCurrMat As String = String.Empty
If Not IsNothing(CurrentMachine.CurrMat) Then
sCurrMat = CurrentMachine.CurrMat.sName
End If
' Creo la lista dei pezzi inseribili nella lastra corrente
Dim InsPartList As New List(Of CsvPart)
For i As Integer = 1 To m_CsvPartList.Count()
Dim CurrPart As CsvPart = m_CsvPartList(i - 1)
If CurrPart.m_bActive And
Math.Abs(CurrPart.m_dTh - dRawHeight) < 100 * EPS_SMALL And
(String.IsNullOrWhiteSpace(CurrPart.m_sMaterial) Or
String.IsNullOrWhiteSpace(sCurrMat) Or
sCurrMat = "***" Or
String.Compare(CurrPart.m_sMaterial, sCurrMat, True) = 0) Then
InsPartList.Add(CurrPart)
End If
Next
' Lancio l'inserimento dei pezzi
ExecInsert(InsPartList)
' Dichiaro lista modificata
m_bCsvPartListModified = True
' Aggiorno visualizzazione
EgtDraw()
End Sub
Private Function ExecInsert(InsPartList As List(Of CsvPart)) As Boolean
Dim bMaxDimOnX As Boolean = (GetMainPrivateProfileInt(S_CSV, K_MAXDIMONX, 1) <> 0)
If bMaxDimOnX Then
' Ordino la lista dei pezzi secondo la dimensione minima decrescente (va su Y)
InsPartList.Sort(Function(P, Q)
Dim dPMin As Double = Math.Min(P.m_dDimX, P.m_dDimY)
Dim dQMin As Double = Math.Min(Q.m_dDimX, Q.m_dDimY)
If Math.Abs(dPMin - dQMin) < EPS_SMALL Then
Return (P.m_nOriInd - Q.m_nOriInd)
Else
Return CInt(Math.Ceiling(dQMin - dPMin))
End If
End Function)
Else
' Ordino la lista dei pezzi secondo le Y decrescenti
InsPartList.Sort(Function(P, Q)
If Math.Abs(P.m_dDimY - Q.m_dDimY) < EPS_SMALL Then
Return (P.m_nOriInd - Q.m_nOriInd)
Else
Return CInt(Math.Ceiling(Q.m_dDimY - P.m_dDimY))
End If
End Function)
End If
' Creo o svuoto gruppo temporaneo per i pezzi
Dim nIpGrp As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, "CSV")
If nIpGrp = GDB_ID.NULL Then
nIpGrp = EgtCreateGroup(GDB_ID.ROOT)
If nIpGrp = GDB_ID.NULL Then Return False
EgtSetName(nIpGrp, "CSV")
Else
EgtEmptyGroup(nIpGrp)
End If
EgtSetLevel(nIpGrp, GDB_LV.TEMP)
EgtSetStatus(nIpGrp, GDB_ST.OFF)
' Carico lua per creare rettangoli
Dim sLuaPath = m_sCompoDir & "\Rettangolo.lua"
If Not EgtLuaExecFile(sLuaPath) Then Return False
' Inserisco nel gruppo un nuovo componente per ogni pezzo da inserire
For i As Integer = 1 To InsPartList.Count()
Dim CurrPart As CsvPart = InsPartList(i - 1)
' Definizione variabili
Dim dDimX = CurrPart.m_dDimX
Dim dDimY = CurrPart.m_dDimY
If bMaxDimOnX And dDimY > dDimX Then
Dim dTemp As Double = dDimX
dDimX = dDimY
dDimY = dTemp
End If
EgtLuaSetGlobNumVar("CMP.V1", dDimX)
EgtLuaSetGlobNumVar("CMP.V2", dDimY)
EgtLuaSetGlobStringVar("CMP.INFO", CurrPart.m_sName)
' Esecuzione componente
If Not EgtLuaExecLine("CMP_Draw(false)") Then Return False
' Recupero Id del nuovo componente
Dim nId As Integer = EgtGetLastPart()
If nId = GDB_ID.NULL Then Return False
CurrPart.m_nId = nId
' Muovo la regione in Z per evitare problemi in visualizzazione
Dim nRegId = EgtGetFirstNameInGroup(nId, NAME_REGION)
EgtMove(nRegId, New Vector3d(0, 0, DELTAZ_REG), GDB_RT.GLOB)
' Eventuale testo per indicare il sopra
If Not bMaxDimOnX Then
Dim dH As Double = Math.Min(0.1 * dDimY, 30)
Dim nText As Integer = EgtCreateTextAdv(nRegId, New Point3d(dDimX / 2, dDimY - 0.6 * dH, 0), 0, "*TOP*", "", 500, False, dH, 1, 0, INS_POS.MC)
EgtSetColor(nText, New Color3d( 0, 0, 0))
End If
' Aggiusto per lavorazioni
AdjustFlatPart(nId)
' Aggiungo info su CSV di origine
EgtSetInfo(nId, INFO_CSV_PATH, m_sCsvPath)
EgtSetInfo(nId, INFO_CSV_PART, CurrPart.m_sName)
EgtSetInfo(nId, INFO_CSV_ORD, CurrPart.m_sOrd)
EgtSetInfo(nId, INFO_CSV_DIST, CurrPart.m_sDist)
EgtSetInfo(nId, INFO_CSV_MAT, CurrPart.m_sMaterial)
' Imposto colore testi
EstCalc.SetTextColor( nRegId)
' Lo sposto nel gruppo speciale
EgtRelocate(nId, nIpGrp)
Next
EgtLuaResetGlobVar("CMP")
EgtLuaResetGlobVar("CMP_Draw")
' Provo ad inserire i pezzi
Dim bDirect As Boolean = (GetMainPrivateProfileInt(S_CSV, K_CSVDIRECT, 1) <> 0)
For i As Integer = 1 To InsPartList.Count()
Dim CurrPart As CsvPart = InsPartList(i - 1)
While CurrPart.m_nToNest > 0
If PackOnePart(CurrPart.m_nId, bDirect) Then
CurrPart.m_nToNest -= 1
Else
Exit While
End If
End While
Next
Return True
End Function
Private Function PackOnePart(nId As Integer, bDirect As Boolean) As Boolean
' Creo una copia del pezzo nella radice
Dim nId2 As Integer = EgtCopyGlob(nId, GDB_ID.ROOT)
If nId2 = GDB_ID.NULL Then Return False
' Lo inserisco direttamente
If bDirect Then
' Aggiungo riferimento e lo inserisco in VeinMatching
VeinMatching.SetRefOnPart(nId2)
VeinMatching.AddPart(nId2, True)
' Provo inserimento in lastra
If EstCalc.InsertOnePart(nId2, CurrentMachine.bAligned, CurrentMachine.bReducedCut) Then
' Eventuale notifica al VeinMatching
VeinMatching.OnInsertPartInRaw(nId2)
Return True
Else
' Eventuale cancellazione per VM
VeinMatching.OnRemovePart(nId2)
' Cancellazione del pezzo
EraseMachinings(nId2)
EgtRemovePartFromRawPart(nId2)
EgtErase(nId2)
Return False
End If
' altrimenti lo metto in parcheggio
Else
' Aggiungo riferimento e lo inserisco in VeinMatching
VeinMatching.SetRefOnPart(nId2)
VeinMatching.AddPart(nId2, True)
' Inserisco in parcheggio
EstCalc.StoreOnePart(nId2, True)
Return True
End If
End Function
Public Sub Remove(ByRef bOther As Boolean, ByRef sOtherCsv As String)
' Rimuovo i pezzi selezionati della lista CSV corrente e ne aggiorno i contatori
Dim nId As Integer = EgtGetFirstSelectedObj()
While nId <> GDB_ID.NULL
Dim nNextId As Integer = EgtGetNextSelectedObj()
If Not RemoveOnePart(nId) Then
bOther = True
Dim sCsvPath As String = String.Empty
If EgtGetInfo(nId, INFO_CSV_PATH, sCsvPath) Then
Dim sCsvName As String = Path.GetFileNameWithoutExtension(sCsvPath)
If sOtherCsv.IndexOf(sCsvName) = -1 Then
sOtherCsv = sOtherCsv & sCsvName & ", "
End If
End If
End If
nId = nNextId
End While
' Dichiaro lista modificata
m_bCsvPartListModified = True
' Aggiorno visualizzazione
EgtDraw()
End Sub
Private Function RemoveOnePart(nId As Integer) As Boolean
' Recupero identificativi da Info
Dim sCsvPath As String = String.Empty
EgtGetInfo(nId, INFO_CSV_PATH, sCsvPath)
Dim sName As String = String.Empty
EgtGetInfo(nId, INFO_CSV_PART, sName)
' Verifico che il pezzo appartenga a questo Csv
If String.Compare(sCsvPath, m_sCsvPath, True) = 0 Then
' Cerco il pezzo nella lista dei pezzi
For i = 1 To m_CsvPartList.Count()
Dim CurrPart As CsvPart = m_CsvPartList(i - 1)
If String.Compare(sName, CurrPart.m_sName, True) = 0 Then
' Se era nel grezzo
If EgtGetParent(nId) = EstCalc.GetRawId() Then
' Rimuovo le lavorazioni
EraseMachinings(nId)
' Rimuovo dal grezzo
EgtRemovePartFromRawPart(nId)
End If
' Eventuale cancellazione per VM
VeinMatching.OnRemovePart(nId)
' Cancello il pezzo
EgtErase(nId)
' Aggiorno il contatore
CurrPart.m_nToNest += 1
' Esco
Return True
End If
Next
End If
' Pezzo non appartenente al Csv corrente
Return False
End Function
Private Function LoadCsvFile(sCsvPath As String) As Boolean
' Pulisco path e lista dei pezzi Csv
m_sCsvPath = String.Empty
m_CsvPartList.Clear()
' Definizione variabili
EgtLuaCreateGlobTable("CSV")
EgtLuaSetGlobStringVar("CSV.FILE", sCsvPath)
' Esecuzione
Dim nErr As Integer = 999
Dim sReader As String = String.Empty
GetMainPrivateProfileString(S_CSV, K_READER, "CsvRead.lua", sReader)
If EgtLuaExecFile(OmagOFFICEMap.refMainWindowVM.MainWindowM.sCsvAutoDir & "\" & sReader) AndAlso
EgtLuaCallFunction("CSV.Read") Then
' Verifica stato di errore
EgtLuaGetGlobIntVar("CSV.ERR", nErr)
End If
If nErr <> 0 Then
EgtOutLog("Error in CsvRead : " & nErr.ToString())
Return False
End If
' Assegno path
m_sCsvPath = sCsvPath
' Preparo lista dei pezzi
Dim nNbr As Integer = 0
EgtLuaGetGlobIntVar("CSV.NBR", nNbr)
For i As Integer = 1 To nNbr
Dim OnePart As New CsvPart
Dim sN As String = i.ToString()
EgtLuaGetGlobStringVar("CSV.NAME" & sN, OnePart.m_sName)
OnePart.m_bActive = True
EgtLuaGetGlobStringVar("CSV.ORD" & sN, OnePart.m_sOrd)
EgtLuaGetGlobStringVar("CSV.DIST" & sN, OnePart.m_sDist)
EgtLuaGetGlobStringVar("CSV.MAT" & sN, OnePart.m_sMaterial)
EgtLuaGetGlobIntVar("CSV.COUNT" & sN, OnePart.m_nCount)
OnePart.m_nToNest = OnePart.m_nCount
EgtLuaGetGlobBoolVar("CSV.RECT" & sN, OnePart.m_bIsRect)
EgtLuaGetGlobNumVar("CSV.DIMX" & sN, OnePart.m_dDimX)
EgtLuaGetGlobNumVar("CSV.DIMY" & sN, OnePart.m_dDimY)
EgtLuaGetGlobNumVar("CSV.TH" & sN, OnePart.m_dTh)
OnePart.m_nOriInd = i
' inserisco in lista
m_CsvPartList.Add(OnePart)
Next
EgtLuaResetGlobVar("CSV")
' Ordinamento lista dei pezzi (ordine crescente su materiale e spessore)
m_CsvPartList.Sort(Function(x, y)
Dim nComp As Integer = String.Compare(x.m_sMaterial, y.m_sMaterial, True)
If nComp = 0 Then
If Math.Abs(x.m_dTh - y.m_dTh) < EPS_SMALL Then
Return (x.m_nOriInd - y.m_nOriInd)
Else
Return CInt(Math.Ceiling(x.m_dTh - y.m_dTh))
End If
Else
Return nComp
End If
End Function)
' Salvo come epl
m_bCsvPartListModified = True
SaveCsvPartList()
' Rinomino file originale
Dim sBakPath As String = sCsvPath & ".bak"
Dim sBakName As String = Path.GetFileName(sBakPath)
' cancello eventuale vecchio backup
If My.Computer.FileSystem.FileExists(sBakPath) Then
My.Computer.FileSystem.DeleteFile(sBakPath)
End If
' eseguo rinomina
My.Computer.FileSystem.RenameFile(sCsvPath, sBakName)
Return True
End Function
Public Function SaveCsvPartList() As Boolean
' Se non c'è nulla di attivo, non faccio alcunché
If String.IsNullOrEmpty(m_sCsvPath) Then
EgtOutLog("CSV List Save Skipped : missing")
Return True
End If
' Se lista non modificata, non faccio alcunchhé
If Not m_bCsvPartListModified Then
EgtOutLog("CSV List Save Skipped : not modified")
Return True
End If
' Path del file
Dim sFile As String = Path.ChangeExtension(m_sCsvPath, ".epl")
' Gestione file
Try
' Apro file
Dim Writer As New IO.StreamWriter(sFile, False)
' Intestazione
Writer.WriteLine("[General]")
Writer.WriteLine("Path=" & m_sCsvPath)
' Ciclo sui pezzi
For i As Integer = 1 To m_CsvPartList.Count()
Dim CurrPart As CsvPart = m_CsvPartList(i - 1)
Writer.WriteLine("[P" & i.ToString() & "]")
Writer.WriteLine("Nam=" & CurrPart.m_sName)
Writer.WriteLine("Ord=" & CurrPart.m_sOrd)
Writer.WriteLine("Dist=" & CurrPart.m_sDist)
Writer.WriteLine("Mat=" & CurrPart.m_sMaterial)
Writer.WriteLine("Act=" & If(CurrPart.m_bActive, "1", "0"))
Writer.WriteLine("Cnt=" & CurrPart.m_nCount.ToString())
Writer.WriteLine("Add=" & CurrPart.m_nAdd.ToString())
Writer.WriteLine("ToN=" & CurrPart.m_nToNest.ToString())
Writer.WriteLine("Rct=" & If(CurrPart.m_bIsRect, "1", "0"))
Writer.WriteLine("DX=" & DoubleToString(CurrPart.m_dDimX, 4))
Writer.WriteLine("DY=" & DoubleToString(CurrPart.m_dDimY, 4))
Writer.WriteLine("Th=" & DoubleToString(CurrPart.m_dTh, 4))
Writer.WriteLine("OIn=" & CurrPart.m_nOriInd.ToString())
Next
' Terminatore
Writer.WriteLine("[END]")
' Chiudo file
Writer.Close()
' Dichiaro lista non più modificata
m_bCsvPartListModified = False
' Registro in ini path
WriteMainPrivateProfileString(S_CSV, K_CSVLASTFILE, sFile)
Return True
' Errore
Catch ex As Exception
EgtOutLog("CSV List error writing " & sFile)
Return False
End Try
End Function
Private Function LoadCsvPartList(sFile As String) As Boolean
' Pulisco path e lista dei pezzi Csv
m_sCsvPath = String.Empty
m_CsvPartList.Clear()
' Gestione file
Try
' Apro file
Dim Reader As New IO.StreamReader(sFile, False)
' Lettura intestazione
Dim sLine As String = Reader.ReadLine()
While sLine <> Nothing
If sLine = "[General]" Then
' non devo fare alcunché
ElseIf sLine.Length() >= 5 AndAlso sLine.Substring(0, 5) = "Path=" Then
Dim sItems() As String = sLine.Split("=".ToCharArray)
If sItems.Count() >= 2 Then
m_sCsvPath = sItems(1)
End If
Else
Exit While
End If
sLine = Reader.ReadLine()
End While
' Ciclo di lettura dei pezzi
Dim nI As Integer = 1
Dim sPart As String = "[P" & nI.ToString() & "]"
Dim OnePart As New CsvPart
While sLine <> Nothing
' Inizio pezzo o fine del file
If sLine = sPart Or sLine = "[END]" Then
' se esiste pezzo precedente, lo salvo
If nI > 1 Then
' inserisco in lista
m_CsvPartList.Add(OnePart)
End If
' predisposizioni per prossimo pezzo
nI += 1
sPart = "[P" & nI.ToString() & "]"
OnePart = New CsvPart
' Dato
Else
Dim sItems() As String = sLine.Split("=".ToCharArray)
If sItems.Count() >= 2 Then
If sItems(0) = "Nam" Then
OnePart.m_sName = sItems(1)
ElseIf sItems(0) = "Ord" Then
OnePart.m_sOrd = sItems(1)
ElseIf sItems(0) = "Dist" Then
OnePart.m_sDist = sItems(1)
ElseIf sItems(0) = "Mat" Then
OnePart.m_sMaterial = sItems(1)
ElseIf sItems(0) = "Act" Then
OnePart.m_bActive = If(sItems(1) = "0", False, True)
ElseIf sItems(0) = "Cnt" Then
StringToInt(sItems(1), OnePart.m_nCount)
ElseIf sItems(0) = "Add" Then
StringToInt(sItems(1), OnePart.m_nAdd)
ElseIf sItems(0) = "ToN" Then
StringToInt(sItems(1), OnePart.m_nToNest)
ElseIf sItems(0) = "Rct" Then
OnePart.m_bIsRect = If(sItems(1) = "0", False, True)
ElseIf sItems(0) = "DX" Then
StringToDouble(sItems(1), OnePart.m_dDimX)
ElseIf sItems(0) = "DY" Then
StringToDouble(sItems(1), OnePart.m_dDimY)
ElseIf sItems(0) = "Th" Then
StringToDouble(sItems(1), OnePart.m_dTh)
ElseIf sItems(0) = "OIn" Then
StringToInt(sItems(1), OnePart.m_nOriInd)
End If
End If
End If
sLine = Reader.ReadLine()
End While
' Chiudo il file
Reader.Close()
' Dichiaro lista non modificata
m_bCsvPartListModified = False
Return True
' Errore
Catch ex As Exception
EgtOutLog("Error reading " & sFile)
Return False
End Try
End Function
#End Region ' METHODS
End Module
Public Class CsvPart
Public m_sName As String = String.Empty
Public m_sOrd As String = String.Empty
Public m_sDist As String = String.Empty
Public m_sMaterial As String = String.Empty
Public m_bActive As Boolean = True
Public m_nCount As Integer = 0
Public m_nAdd As Integer = 0
Public m_nToNest As Integer = 0
Public m_bIsRect As Boolean = True
Public m_dDimX As Double = 0
Public m_dDimY As Double = 0
Public m_dTh As Double = 0
Public m_nOriInd As Integer = 0
Public m_nId As Integer = GDB_ID.NULL
End Class
File diff suppressed because it is too large Load Diff
+789
View File
@@ -0,0 +1,789 @@
Imports System.Globalization
Imports EgtUILib
Imports EgtWPFLib5
Module EstCalc
'--------------------------------------------------------------------------------------------------
Friend Function DoubleToString(ByVal dVal As Double, ByVal nNumDec As Integer) As String
Dim sFormat As String = "F" + Math.Abs(nNumDec).ToString()
Dim sVal As String = dVal.ToString(sFormat, CultureInfo.InvariantCulture)
If nNumDec > 0 Then
Return sVal.TrimEnd("0".ToCharArray()).TrimEnd(".".ToCharArray)
Else
Return sVal
End If
End Function
Friend Function StringToDouble(ByVal sVal As String, ByRef dVal As Double) As Boolean
If String.IsNullOrEmpty(sVal) Then Return False
Return EgtLuaEvalNumExpr(sVal, dVal)
End Function
Friend Function StringToInt(sVal As String, ByRef nVal As Integer) As Boolean
Dim dVal As Double = 0
If Not StringToDouble(sVal, dVal) Then Return False
nVal = CInt(Math.Round(dVal))
Return True
End Function
Friend Function LenToString(ByVal dVal As Double, ByVal nNumDec As Integer) As String
Return DoubleToString(EgtToUiUnits(dVal), nNumDec)
End Function
Friend Function StringToLen(ByVal sVal As String, ByRef dVal As Double) As Boolean
If String.IsNullOrEmpty(sVal) Then Return False
If EgtLuaEvalNumExpr(sVal, dVal) Then
dVal = EgtFromUiUnits(dVal)
Return True
Else
Return False
End If
End Function
'--------------------------------------------------------------------------------------------------
Private m_nRawId As Integer = GDB_ID.NULL
Public Function GetRawId() As Integer
Return m_nRawId
End Function
Private m_b3Raw As New BBox3d
Public Function GetRawPtMin() As Point3d
If m_b3Raw.IsEmpty() Then Return Point3d.ORIG()
Return m_b3Raw.Min()
End Function
Public Function GetRawPtMax() As Point3d
If m_b3Raw.IsEmpty() Then Return Point3d.ORIG()
Return m_b3Raw.Max()
End Function
Public Function GetRawLength() As Double
Return m_b3Raw.DimX()
End Function
Public Function GetRawWidth() As Double
Return m_b3Raw.DimY()
End Function
Public Function GetRawHeight() As Double
Return m_b3Raw.DimZ()
End Function
Public Function UpdateRawPart() As Boolean
' determino il grezzo (è il primo con fase 1)
m_nRawId = CamAuto.GetCurrentRaw()
If Not EgtGetRawPartBBox(m_nRawId, m_b3Raw) Then
m_nRawId = GDB_ID.NULL
m_b3Raw.Setup()
End If
Return (m_nRawId <> GDB_ID.NULL)
End Function
''--------------------------------------------------------------------------------------------------
'Public Function SetMaterialName() As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' If Not IsNothing(CurrentMachine.CurrMat) Then
' Return EgtSetInfo(nMGrpId, INFO_PROJMAT, CurrentMachine.CurrMat.sName)
' Else
' Return EgtSetInfo(nMGrpId, INFO_PROJMAT, "")
' End If
'End Function
'Public Function SetMaterialPhoto(sMatDB As String) As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' ' insesrisco il nome del materiale letto dal DB
' If Not String.IsNullOrEmpty(sMatDB) Then
' Return EgtSetInfo(nMGrpId, INFO_PHOTOMAT, sMatDB)
' Else
' Return False
' End If
'End Function
'Friend Function GetMaterialName() As String
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Dim sName As String = String.Empty
' EgtGetInfo(nMGrpId, INFO_PROJMAT, sName)
' Return sName
'End Function
'Friend Function GetMaterialPhoto() As String
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Dim sName As String = String.Empty
' If EgtGetInfo(nMGrpId, INFO_PHOTOMAT, sName) Then
' Return sName
' Else
' Return String.Empty
' End If
'End Function
''--------------------------------------------------------------------------------------------------
'Public Function SetSlabName(sSlabName As String) As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Return EgtSetInfo(nMGrpId, INFO_SLABNAME, sSlabName)
'End Function
'Friend Function GetSlabName() As String
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Dim sSlabName As String = ""
' EgtGetInfo(nMGrpId, INFO_SLABNAME, sSlabName)
' Return sSlabName
'End Function
'Public Function SetBlockCode(sBlockCode As String) As Boolean
' Dim nRawId As Integer = EstCalc.GetRawId()
' Return EgtSetInfo(nRawId, INFO_RAW_BLOCK, sBlockCode)
'End Function
'Public Function SetSlabCode(sSlabCode As String) As Boolean
' Dim nRawId As Integer = EstCalc.GetRawId()
' Return EgtSetInfo(nRawId, INFO_RAW_SLABNBR, sSlabCode)
'End Function
''--------------------------------------------------------------------------------------------------
'Public Function SetSlabHeight(dSlabHeight As Double) As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Return EgtSetInfo(nMGrpId, INFO_SLABHEIGHT, dSlabHeight)
'End Function
'Friend Function GetSlabHeight() As Double
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Dim dSlabHeight As Double = 0
' EgtGetInfo(nMGrpId, INFO_SLABHEIGHT, dSlabHeight)
' Return dSlabHeight
'End Function
''--------------------------------------------------------------------------------------------------
'Friend Function SetCurrSawing(sCurrSawing As String) As Boolean
' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers")
' If nOperId = GDB_ID.NULL Then Return False
' Return EgtSetInfo(nOperId, INFO_CURRSAWING, sCurrSawing)
'End Function
'Friend Function GetCurrSawing() As String
' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers")
' If nOperId = GDB_ID.NULL Then Return ""
' Dim sCurrSawing As String = String.Empty
' EgtGetInfo(nOperId, INFO_CURRSAWING, sCurrSawing)
' Return sCurrSawing
'End Function
'Friend Function SetCurrMilling(sCurrMilling As String) As Boolean
' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers")
' If nOperId = GDB_ID.NULL Then Return False
' Return EgtSetInfo(nOperId, INFO_CURRMILLING, sCurrMilling)
'End Function
'Friend Function GetCurrMilling() As String
' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers")
' If nOperId = GDB_ID.NULL Then Return ""
' Dim sCurrMilling As String = String.Empty
' EgtGetInfo(nOperId, INFO_CURRMILLING, sCurrMilling)
' Return sCurrMilling
'End Function
'Friend Function SetCurrDrilling(sCurrDrilling As String) As Boolean
' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers")
' If nOperId = GDB_ID.NULL Then Return False
' Return EgtSetInfo(nOperId, INFO_CURRDRILLING, sCurrDrilling)
'End Function
'Friend Function GetCurrDrilling() As String
' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers")
' If nOperId = GDB_ID.NULL Then Return ""
' Dim sCurrDrilling As String = String.Empty
' EgtGetInfo(nOperId, INFO_CURRDRILLING, sCurrDrilling)
' Return sCurrDrilling
'End Function
'Friend Function SetCurrPocketing(sCurrMilling As String) As Boolean
' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers")
' If nOperId = GDB_ID.NULL Then Return False
' Return EgtSetInfo(nOperId, INFO_CURRPOCKETING, sCurrMilling)
'End Function
'Friend Function GetCurrPocketing() As String
' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers")
' If nOperId = GDB_ID.NULL Then Return ""
' Dim sCurrPocketing As String = String.Empty
' EgtGetInfo(nOperId, INFO_CURRPOCKETING, sCurrPocketing)
' Return sCurrPocketing
'End Function
'Friend Function SetCurrWaterjetting(sCurrMilling As String) As Boolean
' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers")
' If nOperId = GDB_ID.NULL Then Return False
' Return EgtSetInfo(nOperId, INFO_CURRWATERJETTING, sCurrMilling)
'End Function
'Friend Function GetCurrWaterjetting() As String
' Dim nOperId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), "Opers")
' If nOperId = GDB_ID.NULL Then Return ""
' Dim sCurrWaterjetting As String = String.Empty
' EgtGetInfo(nOperId, INFO_CURRWATERJETTING, sCurrWaterjetting)
' Return sCurrWaterjetting
'End Function
''--------------------------------------------------------------------------------------------------
'Public Function SetOrderMachiningFlag() As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Return EgtSetInfo(nMGrpId, INFO_MACHORDER, 1)
'End Function
'Friend Function ResetOrderMachiningFlag() As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Return EgtRemoveInfo(nMGrpId, INFO_MACHORDER)
'End Function
'Friend Function GetOrderMachiningFlag() As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Dim nFlag As Integer = 0
' EgtGetInfo(nMGrpId, INFO_MACHORDER, nFlag)
' Return (nFlag <> 0)
'End Function
'Public Function AdjustAdditionalTable() As Boolean
' ' Recupero altezza sottotavola corrente
' Dim nFixtId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), MACH_FIXT_GROUP)
' Dim nAddTabId As Integer = EgtGetFirstNameInGroup(nFixtId, MACH_ADD_TABLE)
' Dim dCurrAddTab As Double = 0
' If nAddTabId <> GDB_ID.NULL And Not EgtGetInfo(nAddTabId, KEY_ADD_TABLE, dCurrAddTab) Then
' Dim b3AddTab As New BBox3d
' EgtGetBBoxGlob(nAddTabId, GDB_BB.STANDARD, b3AddTab)
' dCurrAddTab = b3AddTab.DimZ()
' End If
' ' Se valore cambiato, aggiorno...
' Dim dDeltaZ As Double = dAdditionalTable - dCurrAddTab
' If Math.Abs(dDeltaZ) > EPS_SMALL Then
' AddAdditionalTable()
' UpdateAllRawsZ(dDeltaZ)
' ' !!! FOTO DA GESTIRE !!!
' 'If GetPhoto() <> GDB_ID.NULL Then
' ' UpdatePhoto()
' ' UpdateContour()
' ' If EgtGetRawPartCount() > 0 Then
' ' ShowPhoto(False)
' ' End If
' 'End If
' End If
' Return True
'End Function
'Public Function AddAdditionalTable() As Boolean
' ' Gruppo dei sottopezzi
' Dim nFixtId As Integer = EgtGetFirstNameInGroup(EgtGetCurrMachGroup(), MACH_FIXT_GROUP)
' ' Elimino eventuale vecchia tavola dal gruppo dei bloccaggi
' EgtErase(EgtGetFirstNameInGroup(nFixtId, MACH_ADD_TABLE))
' ' Altezza eventuale tavola aggiuntiva
' Dim dAddTable As Double = dAdditionalTable
' ' Se non esiste sovratavola, esco subito
' If dAddTable < 10 * EPS_SMALL Then Return True
' ' Recupero box tavola
' Dim ptMin, ptMax As Point3d
' EgtGetTableArea(1, ptMin, ptMax)
' ' Aggiungo sovratavola nel gruppo dei bloccaggi
' ptMax.z -= DELTAZ_ADDTAB
' ptMin.z = ptMax.z
' ptMax.z += dAddTable
' Dim nAddTabId As Integer = EgtCreateSurfTmBBox(nFixtId, ptMin, ptMax, GDB_RT.GLOB)
' If nAddTabId = GDB_ID.NULL Then Return False
' EgtSetName(nAddTabId, MACH_ADD_TABLE)
' EgtSetColor(nAddTabId, New Color3d(150, 75, 0, 100), True)
' EgtSetInfo(nAddTabId, KEY_ADD_TABLE, dAddTable)
' Return True
'End Function
'Public Function SetWashingFlag(bWash As Boolean) As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Return EgtSetInfo(nMGrpId, INFO_WASHING, bWash)
'End Function
'Public Function GetWashingFlag() As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Dim bFlag As Boolean = True
' EgtGetInfo(nMGrpId, INFO_WASHING, bFlag)
' Return bFlag
'End Function
'Public Function UpdateWashingFlag() As Boolean
' Dim bCurrWash As Boolean = ( CurrentMachine.nWashing <> 0)
' Dim bProjWash As Boolean = GetWashingFlag()
' If bCurrWash <> bProjWash Then Return SetWashingFlag(bCurrWash)
' Return True
'End Function
'Public Function SetSideAngCutProbeFlag(bSacProbe As Boolean) As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' If bSacProbe Then
' Return EgtSetInfo(nMGrpId, INFO_SACPROBE, True)
' Else
' Return EgtRemoveInfo(nMGrpId, INFO_SACPROBE)
' End If
'End Function
'Public Function GetSideAngCutProbeFlag() As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Dim bFlag As Boolean = False
' EgtGetInfo(nMGrpId, INFO_SACPROBE, bFlag)
' Return bFlag
'End Function
'Public Function UpdateSideAngCutProbeFlag() As Boolean
' Dim bCurrSacProbe As Boolean = ( CurrentMachine.nSacProbe > 0)
' Dim bProjSacProbe As Boolean = GetSideAngCutProbeFlag()
' If bCurrSacProbe <> bProjSacProbe Then Return SetSideAngCutProbeFlag(bCurrSacProbe)
' Return True
'End Function
'Public Function SetReducedCut(bReduced As Boolean) As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Return EgtSetInfo(nMGrpId, INFO_REDUCEDCUT, bReduced)
'End Function
'Public Function GetReducedCut() As Boolean
' Dim nMGrpId As Integer = EgtGetCurrMachGroup()
' Dim bFlag As Boolean = False
' EgtGetInfo(nMGrpId, INFO_REDUCEDCUT, bFlag)
' Return bFlag
'End Function
''--------------------------------------------------------------------------------------------------
'Public Function PartIsFree(nId As Integer) As Boolean
' ' Deve essere un pezzo
' If Not EgtIsPart(nId) Then Return False
' ' Non deve essere inserito in grezzi della prima fase di qualche gruppo di lavoro
' Dim sList As String = String.Empty
' If Not EgtGetInfo(nId, "!LST", sList) Then Return True
' Dim sItems() As String = sList.Split(",".ToCharArray)
' If sItems.Count() = 0 Then Return True
' For Each sLstId In sItems
' Dim nLstId As Integer = GDB_ID.NULL
' StringToInt(sLstId, nLstId)
' Dim nRawId = EgtGetParent(nLstId)
' Dim nPhase As Integer = 1
' EgtGetInfo(nRawId, "Ph", nPhase)
' If nPhase = 1 Then
' Dim sName As String = String.Empty
' If EgtGetName(EgtGetParent(nRawId), sName) AndAlso sName = MACH_RAWS_GROUP Then Return False
' End If
' Next
' Return True
'End Function
'Public Function GetPartMachGroup(nId As Integer) As Integer
' ' Identificativo di ricerca nel grezzo
' Dim nFindId As Integer = GDB_ID.NULL
' ' Se pezzo non assegnato a gruppo
' If EgtIsPart(nId) Then
' ' Cerco associazione a gruppo in grezzo della prima fase di qualche gruppo di lavoro
' Dim sList As String = String.Empty
' If Not EgtGetInfo(nId, "!LST", sList) Then Return GDB_ID.NULL
' Dim sItems() As String = sList.Split(",".ToCharArray)
' If sItems.Count() = 0 Then Return GDB_ID.NULL
' For Each sLstId In sItems
' Dim nLstId As Integer = GDB_ID.NULL
' StringToInt(sLstId, nLstId)
' Dim nRawId = EgtGetParent(nLstId)
' Dim nPhase As Integer = 1
' EgtGetInfo(nRawId, "Ph", nPhase)
' If nPhase = 1 Then
' Dim sRawsName As String = String.Empty
' If EgtGetName(EgtGetParent(nRawId), sRawsName) AndAlso sRawsName = MACH_RAWS_GROUP Then
' nFindId = nLstId
' Exit For
' End If
' End If
' Next
' Else
' nFindId = nId
' End If
' ' Verifico identificativo di ricerca
' If nFindId = GDB_ID.NULL Then Return GDB_ID.NULL
' ' Il padre del padre deve essere il gruppo dei grezzi
' Dim nRawsId As Integer = EgtGetParent(EgtGetParent(nFindId))
' Dim sName As String = String.Empty
' If Not EgtGetName(nRawsId, sName) OrElse sName <> MACH_RAWS_GROUP Then Return GDB_ID.NULL
' ' Il padre del gruppo dei grezzi deve essere il gruppo di lavoro
' Dim nMachGrpId As Integer = EgtGetParent(nRawsId)
' Dim sMachGrpName As String = String.Empty
' If Not EgtGetMachGroupName(nMachGrpId, sMachGrpName) Then Return GDB_ID.NULL
' Return nMachGrpId
'End Function
''--------------------------------------------------------------------------------------------------
'Public Sub HideParkedParts(Optional bDisableModified As Boolean = True)
' ' Se richiesto, disabilito impostazione modificato
' Dim bOldEnMod As Boolean = False
' If bDisableModified Then
' bOldEnMod = EgtGetEnableModified()
' If bOldEnMod Then EgtDisableModified()
' End If
' ' Nascondo pezzi parcheggiati
' Dim nPartId As Integer = EgtGetFirstPart()
' While nPartId <> GDB_ID.NULL
' EgtSetStatus(nPartId, GDB_ST.OFF)
' nPartId = EgtGetNextPart(nPartId)
' End While
' ' Se necessario, ripristino precedente impostazione modificato
' If bOldEnMod Then EgtEnableModified()
'End Sub
'Public Sub ShowParkedParts(Optional bDisableModified As Boolean = True)
' ' Se richiesto, disabilito impostazione modificato
' Dim bOldEnMod As Boolean = False
' If bDisableModified Then
' bOldEnMod = EgtGetEnableModified()
' If bOldEnMod Then EgtDisableModified()
' End If
' ' Visualizzo pezzi parcheggiati che non appartengano a grezzi di altri gruppi
' Dim nPartId As Integer = EgtGetFirstPart()
' While nPartId <> GDB_ID.NULL
' If PartIsFree(nPartId) Then
' EgtSetStatus(nPartId, GDB_ST.ON_)
' Else
' EgtSetStatus(nPartId, GDB_ST.OFF)
' End If
' nPartId = EgtGetNextPart(nPartId)
' End While
' ' Se necessario, ripristino precedente impostazione modificato
' If bOldEnMod Then EgtEnableModified()
'End Sub
'Public Function AdjustFlatPart(nPartId As Integer) As Boolean
' ' Ciclo sui layer
' Dim nLayerId As Integer = EgtGetFirstLayer(nPartId)
' While nLayerId <> GDB_ID.NULL
' ' Recupero il layer successivo
' Dim nNextLayerId As Integer = EgtGetNextLayer(nLayerId)
' ' Recupero il nome del layer
' Dim sLayName As String = String.Empty
' If EgtGetName(nLayerId, sLayName) Then
' ' Se layer OutLoop o InLoop
' If String.Compare(sLayName, NAME_OUTLOOP, True) = 0 Or
' String.Compare(sLayName, NAME_INLOOP, True) = 0 Then
' ' Sistemo i layer per applicare facilmente le lavorazioni
' EgtAdjustFlatPartLayer(nLayerId)
' End If
' ' Se senza nome, lo elimino
' Else
' EgtErase(nLayerId)
' End If
' ' Passo al layer successivo
' nLayerId = nNextLayerId
' End While
' Return True
'End Function
'Friend Function SetTextColor( nGroup As Integer) As Boolean
' ' Recupero il colore da assegnare ai testi
' Dim colText As New Color3d( 0, 0, 0)
' Dim sTextColor As String = " "
' If GetMainPrivateProfileString(S_NEST, K_TEXTCOLOR, " ", sTextColor) <> 0 Then
' Dim sTextColorArray() As String = sTextColor.Split(","c)
' Dim nRed As Integer = 0 : Integer.TryParse( sTextColorArray(0), nRed)
' Dim nGreen As Integer = 0 : Integer.TryParse( sTextColorArray(1), nGreen)
' Dim nBlue As Integer = 0 : Integer.TryParse( sTextColorArray(2), nBlue)
' colText.Setup( nRed, nGreen, nBlue)
' End If
' ' Assegno questo colore ai testi del layer indicato
' Dim nId As Integer = EgtGetFirstInGroup( nGroup)
' While nId <> GDB_ID.NULL
' If EgtGetType(nId) = GDB_TY.EXT_TEXT Then
' EgtSetColor(nId, colText)
' End If
' nId = EgtGetNext(nId)
' End While
' Return True
'End Function
''--------------------------------------------------------------------------------------------------
'Public Function VerifyTrfData(nId As Integer) As Boolean
' ' Verifico se pezzo da Trf
' If Not EgtExistsInfo(nId, "OC") Then Return True
' ' Recupero e verifico lo spessore del pezzo
' Dim dTh As Double = 0
' EgtGetInfo(nId, "T", dTh)
' dim dTrfThickTolerance As double = GetMainPrivateProfileDouble(S_NEST, K_TRFTHICKTOLERANCE, 0.1)
' If Math.Abs(dTh - m_b3Raw.DimZ()) > dTrfThickTolerance Then Return False
' ' Recupero il materiale e la finitura superficiale del pezzo
' Dim sMat As String = ""
' EgtGetInfo(nId, "MT", sMat)
' Dim sSurf As String = ""
' EgtGetInfo(nId, "SRF", sSurf)
' ' Recupero materiale e finitura superficiale di pezzo già inserito (come dati di riferimento)
' Dim sRefMat As String = ""
' Dim sRefSurf As String = ""
' Dim nPartId As Integer = EgtGetFirstPartInRawPart(m_nRawId)
' While nPartId <> GDB_ID.NULL
' If EgtGetInfo(nPartId, "MT", sRefMat) And EgtGetInfo(nPartId, "SRF", sRefSurf) Then Exit While
' nPartId = EgtGetNextPartInRawPart(nPartId)
' End While
' If String.IsNullOrWhiteSpace(sRefMat) And String.IsNullOrWhiteSpace(sRefSurf) Then Return True
' ' Verifico materiale e finitura superficiale
' If sMat <> sRefMat Or sSurf <> sRefSurf Then Return False
' Return True
'End Function
'Public Function PreInsertOnePart(nId As Integer) As Boolean
' ' Se non esiste grezzo o pezzo non in parcheggio, esco
' If m_nRawId = GDB_ID.NULL OrElse Not EgtIsPart(nId) Then Return False
' ' Sistemazioni per eventuali lati inclinati con tallone
' AdjustPartSideAngleHeel(nId, m_b3Raw.DimZ())
' ' Sistemazioni per eventuali lati esterni inclinati e/o offsettati
' EgtCalcFlatPartUpRegion(nId, True)
' EgtCalcFlatPartDownRegion(nId, m_b3Raw.DimZ())
' ' Dimensioni del pezzo
' Dim b3Part As New BBox3d
' If Not EgtGetBBoxGlob(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, b3Part) Then Return False
' ' Centro del grezzo
' Dim ptRawCenter As Point3d
' If Not EgtGetRawPartCenter(m_nRawId, ptRawCenter) Then Return False
' Dim dRawCenX = ptRawCenter.x - m_b3Raw.Min().x
' Dim dRawCenY = ptRawCenter.y - m_b3Raw.Min().y
' ' Inserisco il pezzo nel grezzo, in centro in XY e in alto in Z
' Dim ptP As New Point3d(dRawCenX - 0.5 * b3Part.DimX(), dRawCenY - 0.5 * b3Part.DimY(), m_b3Raw.DimZ())
' If Not EgtAddPartToRawPart(nId, ptP, m_nRawId) Then Return False
' ' Aggiungo le lavorazioni standard
' Dim nWarn As Integer = 0
' AddMachinings(nId, nWarn)
' ' Lama troppo grande per utilizzo ventosa
' If nWarn = 1 Then OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_SPLITPAGEUC + 11), 3, MSG_TYPE.WARNING)
' Return true
'End Function
'Public Function PreRemoveOnePart(nId As Integer) As Boolean
' ' Se non esiste il pezzo, esco
' If nId = GDB_ID.NULL Then Return false
' ' Rimuovo le lavorazioni
' EraseMachinings(nId)
' ' Elimino eventuali modifiche per lati esterni inclinati e/o offsettati
' EgtCalcFlatPartUpRegion(nId, False)
' EgtCalcFlatPartDownRegion(nId, 0)
' ' Eventuale cancellazione solido per taglio da sotto
' EraseSolidForDrip(nId)
' ' Parcheggio
' EgtRemovePartFromRawPart(nId)
' EgtSetStatus(nId, GDB_ST.ON_)
' Return true
'End Function
'Public Function InsertOnePart(nId As Integer, bAligned As Boolean, bReducedCut As Boolean) As Boolean
' ' Se il pezzo non è in parcheggio, non si può inserire
' If Not EgtIsPart(nId) Then Return False
' ' Metto pezzo in centro grezzo con lavorazioni e sistemazioni varie
' Dim bFit As Boolean = False
' If PreInsertOnePart( nId) Then
' ' Eseguo nesting
' If UpdateNestRegions() Then
' EnableReferenceRegion(bAligned)
' If Not EgtExistsInfo(m_nRawId, KEY_RAWBYPOINTS) Then
' bFit = EgtPackPartInRectangle(nId, bReducedCut, True)
' End If
' If Not bFit Then
' bFit = EgtPackPart(nId, bReducedCut, True)
' End If
' End If
' End If
' ' Gestione risultato nesting
' If bFit Then
' ' Eventuale aggiunta solido per taglio da sotto
' UpdateSolidForDrip(nId)
' Return True
' Else
' ' Ripristino lo stato originale
' PreRemoveOnePart( nId)
' Return False
' End If
'End Function
'Private Function AdjustPartSideAngleHeel(nPartId As Integer, dTh As Double) As Boolean
' ' Recupero entità del layer esterno e di quelli interni
' Dim vEnt As New List(Of Integer)
' Dim nEntId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(nPartId, NAME_OUTLOOP))
' While nEntId <> GDB_ID.NULL
' vEnt.Add(nEntId)
' nEntId = EgtGetNext(nEntId)
' End While
' Dim nLayId As Integer = EgtGetFirstNameInGroup(nPartId, NAME_INLOOP)
' While nLayId <> GDB_ID.NULL
' nEntId = EgtGetFirstInGroup(nLayId)
' While nEntId <> GDB_ID.NULL
' vEnt.Add(nEntId)
' nEntId = EgtGetNext(nEntId)
' End While
' nLayId = EgtGetNextName(nLayId, NAME_INLOOP)
' End While
' ' Aggiorno le entità con tallone e quelle con angolo esterno
' Const AGG_DEPTH As Double = 2.0
' For Each nEnt As Integer In vEnt
' ' Se aggiornamento vietato, vado oltre
' If EgtExistsInfo( nEnt, INFO_SIDE_FIXED) Then continue for
' ' Recupero eventuali tallone ed angolo originale
' Dim dHeel As Double = 0
' Dim dSideAng As Double = 0
' EgtGetInfo(nEnt, INFO_HEEL, dHeel)
' EgtGetInfo(nEnt, INFO_ORIG_SIDE_ANGLE, dSideAng)
' If Math.Abs(dSideAng) > EPS_ANG_SMALL And dHeel > 10 * EPS_SMALL Then
' ' Angolo esterno
' If dSideAng > 0 Then
' ' Se tallone inferiore a spessore
' If dHeel < dTh - 10 * EPS_SMALL Then
' EgtSetInfo(nEnt, INFO_SIDE_ANGLE, 0.0)
' EgtSetInfo(nEnt, INFO_SIDE_ANGLE2, dSideAng)
' EgtSetInfo(nEnt, INFO_OFFSET2, -(dTh - dHeel) * Math.Tan(dSideAng * Math.PI / 180))
' EgtSetInfo(nEnt, INFO_DEPTH2, (dTh - dHeel) + AGG_DEPTH)
' ' altrimenti, tallone superiore a spessore -> non c'è taglio inclinato
' Else
' EgtSetInfo(nEnt, INFO_SIDE_ANGLE, 0.0)
' EgtSetInfo(nEnt, INFO_SIDE_ANGLE2, 0.0)
' EgtRemoveInfo(nEnt, INFO_OFFSET2)
' EgtRemoveInfo(nEnt, INFO_DEPTH2)
' End If
' ' Angolo interno
' Else
' ' Se tallone inferiore a spessore
' If dHeel < dTh - 10 * EPS_SMALL Then
' EgtSetInfo(nEnt, INFO_OFFSET, dHeel * Math.Tan(-dSideAng * Math.PI / 180))
' EgtSetInfo(nEnt, INFO_SIDE_ANGLE2, 0.0)
' EgtSetInfo(nEnt, INFO_DEPTH2, dHeel + AGG_DEPTH)
' ' altrimenti, tallone superiore a spessore -> non c'è taglio inclinato
' Else
' EgtSetInfo(nEnt, INFO_SIDE_ANGLE, 0.0)
' EgtRemoveInfo(nEnt, INFO_OFFSET)
' EgtRemoveInfo(nEnt, INFO_SIDE_ANGLE2)
' EgtRemoveInfo(nEnt, INFO_DEPTH2)
' End If
' End If
' ' Se altrimenti inclinazione esterna
' ElseIf dSideAng > EPS_ANG_SMALL Then
' EgtSetInfo(nEnt, INFO_OFFSET, -dTh * Math.Tan(dSideAng * Math.PI / 180))
' End If
' Next
' Return True
'End Function
'Public Function StoreOnePart(ByVal nId As Integer, Optional ByVal bForced As Boolean = False) As Boolean
' ' Se pezzo in grezzo, metto in parcheggio (sempre possibile)
' If bForced OrElse
' (m_nRawId <> GDB_ID.NULL AndAlso EgtGetParent(nId) = m_nRawId) Then
' ' Ripristino lo stato originale
' PreRemoveOnePart( nId)
' ' Parcheggio
' PackPartInStore(nId)
' ' Aggiusto la posizione in Z
' Dim ptPartMin, ptPartMax As Point3d
' If EgtGetBBoxGlob(nId, GDB_BB.IGNORE_DIM + GDB_BB.IGNORE_TEXT, ptPartMin, ptPartMax) And m_nRawId <> GDB_ID.NULL Then
' EgtMove(nId, New Vector3d(0, 0, m_b3Raw.Max().z - ptPartMax.z), GDB_RT.GLOB)
' End If
' Return True
' End If
' Return False
'End Function
'Public Function PackPartInStore(nId As Integer) As Boolean
' ' Recupero box tavola
' Dim b3Tab As New BBox3d
' If Not EgtGetTableArea(1, b3Tab) Then
' b3Tab.Add(New Point3d(0, 0, 0))
' b3Tab.Add(New Point3d(-3600, -2600, 0))
' End If
' ' Parcheggio
' Const STORE_LARGH As Double = 6000
' Const STORE_DIST As Double = 200
' Const STORE_OFFS As Double = 20
' Dim dStXmin As Double = b3Tab.Min().x - 0.5 * (STORE_LARGH - b3Tab.DimX())
' Return EgtPackBox(nId, dStXmin, -INFINITO, dStXmin + STORE_LARGH, b3Tab.Min().y - STORE_DIST, STORE_OFFS, False)
'End Function
'Friend Function VerifyPartsNesting(bReducedCut As Boolean) As Boolean
' ' Aggiorno regioni per nesting
' UpdateNestRegions()
' EnableReferenceRegion(False)
' ' Ciclo su tutti i pezzi in tavola
' Dim nPartId As Integer = EgtGetFirstGroupInGroup(m_nRawId)
' While nPartId <> GDB_ID.NULL
' If Not EgtVerifyPart(nPartId, bReducedCut) Then
' Return False
' End If
' nPartId = EgtGetNextGroup(nPartId)
' End While
' Return True
'End Function
'Friend Function StoreCollisionParts(bReducedCut As Boolean) As Boolean
' ' Aggiorno regioni per nesting
' UpdateNestRegions()
' EnableReferenceRegion(False)
' ' Ciclo su tutti i pezzi in tavola (dall'ultimo)
' Dim nPartId As Integer = EgtGetLastGroupInGroup(m_nRawId)
' While nPartId <> GDB_ID.NULL
' Dim nPrevPartId As Integer = EgtGetPrevGroup(nPartId)
' If Not EgtVerifyPart(nPartId, bReducedCut) Then
' StoreOnePart(nPartId, True)
' End If
' nPartId = nPrevPartId
' End While
' Return True
'End Function
'Public Function UpdateNestRegions() As Boolean
' ' Se necessario, creo la regione fuori kerf
' Dim nKerfId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_KERF)
' EgtCreateOutRegion(GetRawId(), nKerfId)
' ' Se necessario, creo la regione di riferimento
' EgtCreateReferenceRegion(GetRawId(), nKerfId, True)
' ' Se necessario, creo le regioni per le aree danneggiate
' Dim nId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_DAMAGED)
' While nId <> GDB_ID.NULL
' EgtCreateDamagedRegion(GetRawId(), nId)
' nId = EgtGetNextName(nId, NAME_DAMAGED)
' End While
' Return True
'End Function
'Public Function EnableReferenceRegion(bEnable As Boolean) As Boolean
' ' Recupero identificativo della regione di riferimento
' Dim nRegId As Integer = EgtGetFirstNameInGroup(GetRawId(), NAME_REF_REG)
' If nRegId = GDB_ID.NULL Then Return False
' ' Imposto l'abilitazione voluta
' If bEnable Then
' EgtRemoveInfo(nRegId, KEY_REF_REG_OFF)
' Else
' EgtSetInfo(nRegId, KEY_REF_REG_OFF, 1)
' End If
' Return True
'End Function
'Public Function AddTopToPartRegion( nRegId As Integer) As Boolean
' Dim frReg As New Frame3d : EgtGetGroupGlobFrame( nRegId, frReg)
' Dim b3Reg As New BBox3d : EgtGetBBoxGlob( nRegId, GDB_BB.STANDARD, b3Reg)
' Dim dH As Double = Math.Min(0.1 * b3Reg.DimY(), 30)
' Dim ptIns As New Point3d( b3Reg.Center().x, b3Reg.Max().y - dH, 0)
' ptIns.ToLoc( frReg)
' Dim nSfrId As Integer = EgtGetFirstInGroup( nRegId)
' While nSfrId <> GDB_ID.NULL
' If EgtGetType( nSfrId) = GDB_TY.SRF_FRGN Then Exit While
' nSfrId = EgtGetNext( nSfrId)
' End While
' If nSfrId <> GDB_ID.NULL Then
' Dim ptStart As New Point3d ( b3Reg.Min().x, b3Reg.Max().y - dH, 0)
' ptStart.ToLoc( frReg)
' Dim ptEnd As New Point3d ( b3Reg.Max().x, b3Reg.Max().y - dH, 0)
' ptEnd.ToLoc( frReg)
' Dim nLineId As Integer = EgtCreateLine( nRegId, ptStart, ptEnd)
' Dim nCount As Integer = 0
' Dim nNewId As Integer = EgtTrimCurveWithRegion( nLineId, nSfrId, True, False, nCount)
' If nNewId <> GDB_ID.NULL Then
' If nCount > 0 Then EgtMidPoint( nNewId, ptIns)
' For nTmpId As Integer = nNewId To nNewId + nCount - 1
' EgtErase( nTmpId)
' Next
' Else
' EgtErase( nLineId)
' End If
' End If
' Dim vtDir As New Vector3d( 1, 0, 0)
' vtDir.ToLoc( frReg)
' Dim dLen, dAngV, dAngH As Double
' vtDir.ToSpherical( dLen, dAngV, dAngH)
' Dim nText As Integer = EgtCreateTextAdv(nRegId, ptIns, dAngH, "*TOP*", "", 500, False, dH, 1, 0, INS_POS.MC)
' Return ( nText <> GDB_ID.NULL)
'End Function
End Module
+521
View File
@@ -0,0 +1,521 @@
'----------------------------------------------------------------------------
' EgalTech 2015-2017
'----------------------------------------------------------------------------
' File : GenPhoto.vb Data : 12.04.17 Versione : 1.8d1
' Contenuto : Modulo gestione fotografie.
' Ogni gruppo di lavoro può avere una sua foto della lastra.
'
'
' Modifiche : 12.04.17 DS Creazione modulo.
'
'
'----------------------------------------------------------------------------
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Module EstPhoto
Friend Function LoadPhoto(sPath As String,
ByRef nSlabId As Integer, ByRef sBlockCode As String, ByRef sSlabCode As String, ByRef sSlabName As String, ByRef sMat As String) As Boolean
' Verifico esistenza file immagine
If Not File.Exists(sPath) Then Return False
' Leggo eventuale file dati aggiuntivi
Dim dThick As Double = 0
Dim ptOri As New Point3d(0, 0, 0)
Dim ptCen As New Point3d(0, 0, INFINITO)
Dim dMMxPixel As Double = 1
Dim dCoeff As Double = 1
If Not ReadAuxData(sPath, nSlabId, sBlockCode, sSlabCode, sSlabName, sMat, dThick, ptOri, ptCen, dMMxPixel, dCoeff) Then Return False
' Aggiungo eventuali offset
ptOri += CurrentMachine.PhotoOffset
ptCen += CurrentMachine.PhotoOffset
' Imposto eventuale spezzore grezzo
If dThick > EPS_SMALL Then
OmagOFFICEMap.refRawPartTabVM.Height = DoubleToString( dThick, 3)
End If
' Altezza eventuale tavola aggiuntiva
Dim dAddTable As Double = CurrentMachine.dAdditionalTable
' Aggiusto dati per spessore grezzo
If Math.Abs(EstCalc.GetRawHeight() + dAddTable) > EPS_SMALL Then
' Coefficiente di scalatura
Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z)
dMMxPixel *= dFsca
ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca
ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca
ptOri.z = EstCalc.GetRawHeight() + dAddTable
End If
' Recupero origine della tavola e porto i punti in globale
Dim ptTab As Point3d
If Not EgtGetTableRef(1, ptTab) Then Return False
ptOri.ToGlob(New Frame3d(ptTab))
ptCen.ToGlob(New Frame3d(ptTab))
' Recupero le dimensioni della tavola
Dim b3Tab As New BBox3d
If Not EgtGetTableArea(1, b3Tab) Then Return False
b3Tab.Expand(100, 100, 0)
' Elimino eventuale precedente foto
Dim nOldPhotoId = GetPhoto()
If nOldPhotoId <> GDB_ID.NULL Then EgtErase(nOldPhotoId)
' Se non esiste il gruppo per le foto, lo creo
Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP)
If nPhGrpId = GDB_ID.NULL Then
nPhGrpId = EgtCreateGroup(GDB_ID.ROOT)
If nPhGrpId = GDB_ID.NULL Then Return False
EgtSetName(nPhGrpId, PHOTO_GRP)
End If
EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM)
' Carico la fotografia
Return EgtAddPhoto(GetPhotoName(), sPath, ptOri, ptCen, dMMxPixel, nPhGrpId, b3Tab.Min(), b3Tab.Max()) <> GDB_ID.NULL
End Function
Friend Function LoadContour(sPath As String) As Boolean
' Elimino eventuale vecchio contorno
RemoveContour()
' Leggo eventuale file dati aggiuntivi
Dim nSlabId As Integer = 0
Dim sBlockCode As String = ""
Dim sSlabCode As String = ""
Dim sSlabName As String = ""
Dim sMat As String = ""
Dim dThick As Double = 0
Dim ptOri As New Point3d(0, 0, 0)
Dim ptCen As New Point3d(0, 0, INFINITO)
Dim dMMxPixel As Double = 1
Dim dCoeff As Double = 1
If Not ReadAuxData(sPath, nSlabId, sBlockCode, sSlabCode, sSlabName, sMat, dThick, ptOri, ptCen, dMMxPixel, dCoeff) Then Return False
' Aggiungo eventuali offset
ptOri += CurrentMachine.PhotoOffset
ptCen += CurrentMachine.PhotoOffset
' Recupero dimensione della immagine originale della fotografia
Dim nPixelX As Integer = 0
Dim nPixelY As Integer = 0
If Not EgtGetPhotoImagePixels(GetPhoto(), nPixelX, nPixelY) Then Return False
' Altezza eventuale tavola aggiuntiva
Dim dAddTable As Double = CurrentMachine.dAdditionalTable
' Aggiusto dati per spessore grezzo
If Math.Abs(EstCalc.GetRawHeight() + dAddTable) > EPS_SMALL Then
' Coefficiente di scalatura
Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z)
dMMxPixel *= dFsca
ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca
ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca
ptOri.z = EstCalc.GetRawHeight() + dAddTable
End If
' Recupero origine della tavola e porto i punti in globale
Dim ptTab As Point3d
If Not EgtGetTableRef(1, ptTab) Then Return False
ptOri.ToGlob(New Frame3d(ptTab))
ptCen.ToGlob(New Frame3d(ptTab))
' Verifico coefficiente scalatura Pixel (per MapaScan, normalmente 1)
If dCoeff < EPS_SMALL Then
EgtOutLog("ReadContour : coefficiente di scalatura pixel nullo")
Return False
End If
' Se esiste file dxf lancio lettore standard, altrimenti quello personalizzato
Dim nCrvId As Integer = GDB_ID.NULL
Dim sCntPath As String = Path.ChangeExtension(sPath, ".dxf")
If My.Computer.FileSystem.FileExists(sCntPath) Then
nCrvId = LoadStandardContour(sCntPath, ptOri, dMMxPixel, nPixelY, dCoeff)
Else
nCrvId = LoadCustomContour(sPath, ptOri, dMMxPixel, nPixelY, dCoeff)
End If
' Eseguo le semplificazioni
Dim nApprType As Integer = APP_TYPE.LEFT_LINES
Dim dTol As Double = GetMainPrivateProfileDouble(S_CAMERA, K_CAM_TOLERANCE, 5)
EgtApproxCurve(nCrvId, nApprType, dTol)
Dim ptNew As Point3d
EgtMidPoint(nCrvId, ptNew)
EgtChangeClosedCurveStartPoint(nCrvId, ptNew)
EgtApproxCurve(nCrvId, nApprType, dTol)
Return True
End Function
Private Function LoadStandardContour(sPath As String, ptOri As Point3d, dMMxPixel As Double, nPixelY As Integer, dCoeff As Double) As Integer
' Carico Dxf del contorno
If Not EgtImportDxf(sPath, 1) Then Return GDB_ID.NULL
Dim nPartId As Integer = EgtGetLastPart()
Dim nLayerId As Integer = EgtGetFirstLayer(nPartId)
EgtSetName(nPartId, NAME_RAW_PHOTO_OUTLINE)
EgtSetLevel(nPartId, GDB_LV.SYSTEM)
If nPartId = GDB_ID.NULL Or nLayerId = GDB_ID.NULL Then Return GDB_ID.NULL
' Ribalto rispetto a YZ locale (i contorni da CW diventano CCW)
EgtMirror(nLayerId, New Point3d(0, nPixelY * dCoeff / 2, 0), Vector3d.Y_AX(), GDB_RT.GLOB)
' Eseguo scalatura
Dim dScaCoeff As Double = dMMxPixel / dCoeff
EgtScale(nLayerId, New Frame3d(), dScaCoeff, dScaCoeff, dScaCoeff, GDB_RT.GLOB)
' Eseguo spostamento
EgtMove(nLayerId, (ptOri - Point3d.ORIG()), GDB_RT.GLOB)
' Eseguo concatenamento
EgtSelectGroupObjs(nLayerId)
EgtCreateCurveCompoByReorder(nLayerId, 1, {GDB_ID.SEL}, New Point3d(), True)
' Conservo la curva chiusa di area massima
Dim dAreaMax As Double = 0
Dim nCrvId As Integer = GDB_ID.NULL
Dim nCurrCrvId As Integer = EgtGetFirstInGroup(nLayerId)
While nCurrCrvId <> GDB_ID.NULL
Dim dArea As Double = 0
If Not EgtCurveAreaXY(nCurrCrvId, dArea) OrElse dArea <= dAreaMax Then
Dim nToEraseId = nCurrCrvId
nCurrCrvId = EgtGetNext(nCurrCrvId)
EgtErase(nToEraseId)
Else
dAreaMax = dArea
EgtErase(nCrvId)
nCrvId = nCurrCrvId
nCurrCrvId = EgtGetNext(nCurrCrvId)
End If
End While
EgtSetColor(nCrvId, New Color3d(0, 255, 0))
Return nCrvId
End Function
Private Function LoadCustomContour(sPath As String, ptOri As Point3d, dMMxPixel As Double, nPixelY As Integer, dCoeff As Double) As Integer
' Definizione variabili
EgtLuaCreateGlobTable("RCT")
EgtLuaSetGlobStringVar("RCT.FILE", sPath)
' Esecuzione
Dim nErr As Integer = 999
If EgtLuaExecFile(OmagOFFICEMap.refMainWindowVM.MainWindowM.sImgAutoDir & "\ReadContour.lua") AndAlso
EgtLuaCallFunction("RCT.ReadContour") Then
' Verifica stato di errore
EgtLuaGetGlobIntVar("RCT.ERR", nErr)
End If
If nErr <> 0 Then
EgtOutLog("Error in ReadContour : " & nErr.ToString())
Return GDB_ID.NULL
End If
' Leggo i risultati
Dim nPartId As Integer = GDB_ID.NULL
EgtLuaGetGlobIntVar("RCT.PARTID", nPartId)
If nPartId = GDB_ID.NULL Then Return GDB_ID.NULL
EgtSetName(nPartId, NAME_RAW_PHOTO_OUTLINE)
EgtSetLevel(nPartId, GDB_LV.SYSTEM)
Dim nCrvId As Integer = GDB_ID.NULL
EgtLuaGetGlobIntVar("RCT.CRVID", nCrvId)
EgtLuaResetGlobVar("RCT")
If nCrvId = GDB_ID.NULL Then Return GDB_ID.NULL
EgtSetColor(nCrvId, New Color3d(0, 255, 0))
' Ribalto rispetto a YZ locale (i contorni da CW diventano CCW)
EgtMirror(nCrvId, New Point3d(0, nPixelY * dCoeff / 2, 0), Vector3d.Y_AX(), GDB_RT.GLOB)
' Eseguo scalatura
Dim dScaCoeff As Double = dMMxPixel / dCoeff
EgtScale(nCrvId, New Frame3d(), dScaCoeff, dScaCoeff, dScaCoeff, GDB_RT.GLOB)
' Eseguo spostamento
EgtMove(nCrvId, (ptOri - Point3d.ORIG()), GDB_RT.GLOB)
' Deve essere CCW
Dim dArea As Double = 0
If EgtCurveAreaXY(nCrvId, dArea) AndAlso dArea < 0 Then
EgtInvertCurve(nCrvId)
End If
Return nCrvId
End Function
Private Function ReadAuxData(sPath As String,
ByRef nSlabId As Integer, ByRef sBlockCode As String, ByRef sSlabCode As String, ByRef sSlabName As String, ByRef sMat As String,
ByRef dThick As Double, ByRef ptOri As Point3d, ByRef ptCen As Point3d, ByRef dMMxPixel As Double, ByRef dCoeff As Double) As Boolean
' Se esiste file txt lancio lettore standard, altrimenti quello personalizzato
Dim sAuxPath As String = Path.ChangeExtension(sPath, ".txt")
If My.Computer.FileSystem.FileExists(sAuxPath) Then
Return ReadStandardAuxData(sAuxPath, nSlabId, sBlockCode, sSlabCode, sSlabName, sMat, dThick, ptOri, ptCen, dMMxPixel, dCoeff)
Else
Return ReadCustomAuxData(sPath, nSlabId, sBlockCode, sSlabCode, sSlabName, sMat, dThick, ptOri, ptCen, dMMxPixel, dCoeff)
End If
End Function
Private Function ReadStandardAuxData(sAuxPath As String,
ByRef nSlabId As Integer, ByRef sBlockCode As String, ByRef sSlabCode As String, ByRef sSlabName As String, ByRef sMat As String,
ByRef dThick As Double, ByRef ptOri As Point3d, ByRef ptCen As Point3d, ByRef dMMxPixel As Double, ByRef dCoeff As Double) As Boolean
nSlabId = 0
sBlockCode = ""
sSlabCode = ""
sSlabName = ""
sMat = ""
dThick = 0
dCoeff = 1
Try
Dim sLine As String = String.Empty
Dim sr As StreamReader = New StreamReader(sAuxPath)
Do While sr.Peek() > -1
sLine = sr.ReadLine()
sLine = sLine.Replace(" ", "")
If sLine.StartsWith("X=") Then
StringToDouble(sLine.Substring(2), ptOri.x)
ElseIf sLine.StartsWith("Y=") Then
StringToDouble(sLine.Substring(2), ptOri.y)
ElseIf sLine.StartsWith("Z_Lastra=") Then
StringToDouble(sLine.Substring(9), ptOri.z)
ElseIf sLine.StartsWith("X_ScaleCenter=") Then
StringToDouble(sLine.Substring(14), ptCen.x)
ElseIf sLine.StartsWith("Y_ScaleCenter=") Then
StringToDouble(sLine.Substring(14), ptCen.y)
ElseIf sLine.StartsWith("Z_ScaleCenter=") Then
StringToDouble(sLine.Substring(14), ptCen.z)
ElseIf sLine.StartsWith("Pixelxmm=") Then
Dim dTmp As Double
StringToDouble(sLine.Substring(9), dTmp)
If dTmp > EPS_SMALL Then
dMMxPixel = 1 / dTmp
End If
End If
Loop
sr.Close()
Return True
Catch ex As Exception
EgtOutLog("LoadPhoto Error on auxfile : " & sAuxPath)
Return False
End Try
End Function
Private Function ReadCustomAuxData(sPath As String,
ByRef nSlabId As Integer, ByRef sBlockCode As String, ByRef sSlabCode As String, ByRef sSlabName As String, ByRef sMat As String,
ByRef dThick As Double, ByRef ptOri As Point3d, ByRef ptCen As Point3d, ByRef dMMxPixel As Double, ByRef dCoeff As Double) As Boolean
' Definizione variabili
EgtLuaCreateGlobTable("RDT")
EgtLuaSetGlobStringVar("RDT.FILE", sPath)
' Esecuzione
Dim nErr As Integer = 999
If EgtLuaExecFile(OmagOFFICEMap.refMainWindowVM.MainWindowM.sImgAutoDir & "\ReadData.lua") AndAlso
EgtLuaCallFunction("RDT.ReadData") Then
' Verifica stato di errore
EgtLuaGetGlobIntVar("RDT.ERR", nErr)
End If
If nErr <> 0 Then
EgtOutLog("Error in ReadData : " & nErr.ToString())
Return False
End If
' Leggo i risultati
If Not EgtLuaGetGlobIntVar("RDT.SLABID", nSlabId) Then nSlabId = 0
If Not EgtLuaGetGlobStringVar("RDT.SLABNAME", sSlabName) Then sSlabName = String.Empty
If Not EgtLuaGetGlobStringVar("RDT.BLOCKCODE", sBlockCode) Then sBlockCode = String.Empty
If Not EgtLuaGetGlobStringVar("RDT.SLABCODE", sSlabCode) Then sSlabCode = String.Empty
If Not EgtLuaGetGlobStringVar("RDT.MATERIAL", sMat) Then sMat = String.Empty
if Not EgtLuaGetGlobNumVar("RDT.TH", dThick) Then dThick = 0
EgtLuaGetGlobPointVar("RDT.ORI", ptOri)
EgtLuaGetGlobPointVar("RDT.CEN", ptCen)
EgtLuaGetGlobNumVar("RDT.COEFF", dCoeff)
EgtLuaGetGlobNumVar("RDT.MMXPIXEL", dMMxPixel)
EgtLuaResetGlobVar("RDT")
Return True
End Function
Public Function GetPhotoName() As String
' Recupero il nome del gruppo di lavoro corrente
Dim sMGrp As String = String.Empty
If Not EgtGetMachGroupName(EgtGetCurrMachGroup(), sMGrp) Then Return ""
' Creo il nome della foto
Return PHOTO_NAME & sMGrp
End Function
Public Function GetPhoto() As Integer
' Recupero Id del gruppo delle foto
Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP)
' Recupero Id della foto
Return EgtGetFirstNameInGroup(nPhGrpId, GetPhotoName())
End Function
Public Function GetPhotoTexturePath() As String
' Recupero la foto
Dim nId As Integer = GetPhoto()
If nId = GDB_ID.NULL Then Return ""
' Recupero la path della texture
Dim sPath As String = String.Empty
If EgtGetPhotoPath(nId, sPath) Then
Return sPath
Else
Return ""
End If
End Function
Public Function GetPhotoTextureRef(ByRef refTxr As Frame3d) As Boolean
' Recupero la foto
Dim nId As Integer = GetPhoto()
If nId = GDB_ID.NULL Then Return False
' Recupero il riferimento in globale
Return EgtGetTextureFrame(nId, GDB_ID.ROOT, refTxr)
End Function
Public Function ShowPhoto(ByVal bShow As Boolean, Optional bDisableModified As Boolean = True) As Boolean
' Recupero la foto
Dim nId As Integer = GetPhoto()
If nId = GDB_ID.NULL Then Return False
' Se richiesto, disabilito impostazione modificato
Dim bOldEnMod As Boolean = False
If bDisableModified Then
bOldEnMod = EgtGetEnableModified()
If bOldEnMod Then EgtDisableModified()
End If
' Ne cambio lo stato
Dim bOk As Boolean = EgtSetStatus(nId, If(bShow, GDB_ST.ON_, GDB_ST.OFF))
' Se necessario, ripristino precedente impostazione modificato
If bOldEnMod Then EgtEnableModified()
Return bOk
End Function
Public Function GetPhotoOffsetRot(ByRef dOffsetX As Double, ByRef dOffsetY As Double, ByRef dRot As Double) As Boolean
' Verifico esistenza oggetto foto
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId = GDB_ID.NULL Then Return False
' Recupero valori
If Not EgtGetInfo(nPhotoId, "OffsX", dOffsetX) Then dOffsetX = 0
If Not EgtGetInfo(nPhotoId, "OffsY", dOffsetY) Then dOffsetY = 0
If Not EgtGetInfo(nPhotoId, "Rot", dRot) Then dRot = 0
Return True
End Function
Public Function UpdatePhoto() As Boolean
' Verifico esistenza oggetto foto
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId = GDB_ID.NULL Then Return False
' Verifico esistenza texture della foto
Dim sPath As String = String.Empty
If Not EgtGetPhotoPath(nPhotoId, sPath) OrElse Not File.Exists(sPath) Then Return False
' Recupero i dati aggiuntivi della foto
Dim ptOri As New Point3d(0, 0, 0)
If Not EgtGetPhotoOrigin(nPhotoId, ptOri) Then Return False
Dim ptCen As New Point3d(0, 0, 1)
If Not EgtGetPhotoCenter(nPhotoId, ptCen) Then Return False
Dim dDimX, dDimY As Double
If Not EgtGetPhotoDimensions(nPhotoId, dDimX, dDimY) Then Return False
' Recupero origine della tavola
Dim ptTab As Point3d
If Not EgtGetTableRef(1, ptTab) Then Return False
' Porto i punti in locale
ptOri.ToLoc(New Frame3d(ptTab))
ptCen.ToLoc(New Frame3d(ptTab))
' Altezza eventuale tavola aggiuntiva
Dim dAddTable As Double = CurrentMachine.dAdditionalTable
' Aggiusto dati per spessore grezzo (Coefficiente di scalatura)
Dim dFsca As Double = (ptCen.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptOri.z)
dDimX *= dFsca
dDimY *= dFsca
ptOri.x = ptCen.x + (ptOri.x - ptCen.x) * dFsca
ptOri.y = ptCen.y + (ptOri.y - ptCen.y) * dFsca
ptOri.z = EstCalc.GetRawHeight() + dAddTable
' Porto i punti in globale
ptOri.ToGlob(New Frame3d(ptTab))
ptCen.ToGlob(New Frame3d(ptTab))
' Carico gli offset
Dim dOffsetX As Double = 0
EgtGetInfo(nPhotoId, "OffsX", dOffsetX)
Dim dOffsetY As Double = 0
EgtGetInfo(nPhotoId, "OffsY", dOffsetY)
Dim dRot As Double = 0
EgtGetInfo(nPhotoId, "Rot", dRot)
' Recupero le dimensioni della tavola
Dim ptMin, ptMax As Point3d
If Not EgtGetTableArea(1, ptMin, ptMax) Then Return False
' Elimino precedente foto
EgtErase(nPhotoId)
' Se non esiste il gruppo per le foto, lo creo
Dim nPhGrpId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP)
If nPhGrpId = GDB_ID.NULL Then
nPhGrpId = EgtCreateGroup(GDB_ID.ROOT)
If nPhGrpId = GDB_ID.NULL Then Return False
EgtSetName(nPhGrpId, PHOTO_GRP)
End If
EgtSetLevel(nPhGrpId, GDB_LV.SYSTEM)
' Carico la fotografia
Dim nNewPhotoId As Integer = EgtAddPhoto2(GetPhotoName(), sPath, ptOri, ptCen, dDimX, dDimY, nPhGrpId, ptMin, ptMax)
If nNewPhotoId = GDB_ID.NULL Then Return False
' Eseguo eventuale rotazione attorno all'origine
EgtRotatePhoto(nNewPhotoId, ptOri, Vector3d.Z_AX(), dRot)
' Salvo gli offset
EgtSetInfo(nNewPhotoId, "OffsX", dOffsetX)
EgtSetInfo(nNewPhotoId, "OffsY", dOffsetY)
EgtSetInfo(nNewPhotoId, "Rot", dRot)
Return True
End Function
Public Function ChangeOffsetPhoto(dOffsetX As Double, dOffsetY As Double) As Boolean
' Verifico esistenza oggetto foto
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId = GDB_ID.NULL Then Return False
' Verifico esistenza texture della foto
Dim sPath As String = String.Empty
EgtGetPhotoPath(nPhotoId, sPath)
If Not File.Exists(sPath) Then Return False
' Recupero offset corrente
Dim dOldOffsX As Double = 0
EgtGetInfo(nPhotoId, "OffsX", dOldOffsX)
Dim dOldOffsY As Double = 0
EgtGetInfo(nPhotoId, "OffsY", dOldOffsY)
' Eseguo traslazione
Dim vtMove As New Vector3d(dOffsetX - dOldOffsX, dOffsetY - dOldOffsY, 0)
EgtMovePhoto(nPhotoId, vtMove)
' Aggiorno valori di offset
EgtSetInfo(nPhotoId, "OffsX", dOffsetX)
EgtSetInfo(nPhotoId, "OffsY", dOffsetY)
Return True
End Function
Public Function ChangeRotationPhoto(ptAx As Point3d, dRot As Double) As Boolean
' Verifico esistenza oggetto foto
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId = GDB_ID.NULL Then Return False
' Verifico esistenza texture della foto
Dim sPath As String = String.Empty
EgtGetPhotoPath(nPhotoId, sPath)
If Not File.Exists(sPath) Then Return False
' Recupero rotazione corrente
Dim dOldRot As Double = 0
EgtGetInfo(nPhotoId, "Rot", dOldRot)
' Eseguo rotazione
EgtRotatePhoto(nPhotoId, ptAx, Vector3d.Z_AX(), dRot - dOldRot)
' Aggiorno valore di rotazione
EgtSetInfo(nPhotoId, "Rot", dRot)
Return True
End Function
Public Function UpdateContour() As Boolean
' Verifico esistenza oggetto contorno
Dim nCrvId As Integer = GetContour()
If nCrvId = GDB_ID.NULL Then Return False
' Verifico esistenza oggetto foto
Dim nPhotoId As Integer = GetPhoto()
If nPhotoId = GDB_ID.NULL Then Return False
' Recupero centro della foto
Dim ptCen As New Point3d(0, 0, 1)
EgtGetPhotoCenter(nPhotoId, ptCen)
' Recupero origine della tavola
Dim ptTab As Point3d
If Not EgtGetTableRef(1, ptTab) Then Return False
' Altezza eventuale tavola aggiuntiva
Dim dAddTable As Double = CurrentMachine.dAdditionalTable
' Recupero inizio contorno
Dim ptStart As Point3d
EgtStartPoint(nCrvId, GDB_ID.ROOT, ptStart)
' Calcolo coefficiente di scalatura
Dim dFsca As Double = (ptCen.z - ptTab.z - EstCalc.GetRawHeight() - dAddTable) / (ptCen.z - ptStart.z)
' Scalo opportunamente
EgtScale(nCrvId, New Frame3d(ptCen), dFsca, dFsca, 1, GDB_RT.GLOB)
' Sposto in Z
Dim vtMove As New Vector3d(0, 0, ptTab.z + EstCalc.GetRawHeight() + dAddTable - ptStart.z)
EgtMove(nCrvId, vtMove, GDB_RT.GLOB)
Return True
End Function
Public Function GetContour() As Integer
Dim nPartId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE)
Dim nLayerId As Integer = EgtGetFirstGroupInGroup(nPartId)
Dim nCrvId As Integer = EgtGetFirstInGroup(nLayerId)
Return nCrvId
End Function
Friend Sub RemoveContour()
EgtErase(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE))
End Sub
Public Sub ShowContour(bShow As Boolean)
' Disabilito impostazione modificato
Dim bOldEnMod As Boolean = EgtGetEnableModified()
If bOldEnMod Then EgtDisableModified()
' Cambio stato di visualizzazione
EgtSetStatus(EgtGetFirstNameInGroup(GDB_ID.ROOT, NAME_RAW_PHOTO_OUTLINE), If(bShow, GDB_ST.ON_, GDB_ST.OFF))
' Se necessario, ripristino precedente impostazione modificato
If bOldEnMod Then EgtEnableModified()
End Sub
End Module
+44
View File
@@ -0,0 +1,44 @@
Imports EgtUILib
Module EstProject
Public Function FilterNge() As Boolean
' Rimuovo eventuali gruppi con livello System
Dim nId As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT)
While nId <> GDB_ID.NULL
' Recupero il prossimo gruppo
Dim nNextId = EgtGetNextGroup(nId)
' Verifico il livello e se necessario cancello
Dim nLevel As Integer = GDB_LV.USER
EgtGetLevel(nId, nLevel)
If nLevel = GDB_LV.SYSTEM Then
EgtErase(nId)
End If
' Passo al prossimo gruppo
nId = nNextId
End While
' Processo i sottogruppi, se di livello System li rimuovo altrimenti ne cancello il nome
Dim nGrpId As Integer = EgtGetFirstGroupInGroup(GDB_ID.ROOT)
While nGrpId <> GDB_ID.NULL
' Ciclo sui sottogruppi
Dim nSubId As Integer = EgtGetFirstGroupInGroup(nGrpId)
While nSubId <> GDB_ID.NULL
' Recupero il prossimo sottogruppo
Dim nNextSubId = EgtGetNextGroup(nSubId)
' Verifico il livello, eventuale cancellazione o rimozione nome
Dim nLevel As Integer = GDB_LV.USER
EgtGetLevel(nSubId, nLevel)
If nLevel = GDB_LV.SYSTEM Then
EgtErase(nSubId)
Else
EgtRemoveName(nSubId)
End If
nSubId = nNextSubId
End While
' Passo al prossimo gruppo
nGrpId = EgtGetNextGroup(nGrpId)
End While
Return True
End Function
End Module
+115
View File
@@ -0,0 +1,115 @@
Imports EgtUILib
Module GeomCalc
Public Function GetRegionOutLoop(nRegId As Integer, nDestGrpId As Integer) As Integer
Dim nCount As Integer = 0
Dim nOutId As Integer = EgtExtractSurfFrChunkLoops(nRegId, 0, nDestGrpId, nCount)
If nOutId <> GDB_ID.NULL Then
For nId As Integer = nOutId + 1 To nOutId + nCount - 1
EgtErase(nId)
Next
End If
Return nOutId
End Function
Public Function CreateSolidFromRegion(nRegId As Integer, vtExtr As Vector3d, nDestGrpId As Integer) As Integer
Dim nOutId As Integer = GetRegionOutLoop(nRegId, nDestGrpId)
If nOutId = GDB_ID.NULL Then Return GDB_ID.NULL
Dim nSolId As Integer = EgtCreateSurfTmByRegionExtrusion(nDestGrpId, 1, {nOutId}, vtExtr,
100 * EPS_SMALL, GDB_RT.GLOB)
EgtErase(nOutId)
Return nSolId
End Function
Public Function GetMaxSideId(nPartId As Integer) As Integer
Dim nId As Integer = EgtGetFirstInGroup(nPartId)
Dim sName As String = String.Empty
While nId <> GDB_ID.NULL
EgtGetName(nId, sName)
If sName = NAME_OUTLOOP Then
Exit While
End If
nId = EgtGetNext(nId)
End While
Dim nIdMax As Integer = EgtGetFirstInGroup(nId)
Dim nIdCurr As Integer = nIdMax
Dim dLen As Double
Dim dLenMax As Double
EgtCurveLength(nIdMax, dLen)
dLenMax = dLen
nIdCurr = EgtGetNext(nIdCurr)
While nIdCurr <> GDB_ID.NULL
EgtCurveLength(nIdCurr, dLen)
If dLen > dLenMax Then
nIdMax = nIdCurr
End If
nIdCurr = EgtGetNext(nIdCurr)
End While
Return nIdMax
End Function
Friend Function UpdateSolidForDrip(nPartId As Integer) As Boolean
' se non ci sono lavorazioni da sotto nel pezzo si esce
If EgtGetGroupObjs(EgtGetFirstNameInGroup(nPartId, NAME_DRIPCUT)) = 0 AndAlso
EgtGetGroupObjs(EgtGetFirstNameInGroup(nPartId, NAME_UNDERDRILL)) = 0 Then Return True
' Recupero lo spessore del grezzo
Dim dThick As Double = EstCalc.GetRawHeight()
' Recupero layer Regione
Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION)
' Elimino eventuale vecchio solido
EgtErase(EgtGetFirstNameInGroup(nGrpRegId, NAME_DRIP_SOLID))
' Recupero la regione del pezzo
Dim nRegId As Integer = EgtGetFirstInGroup(nGrpRegId)
While nRegId <> GDB_ID.NULL
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then Exit While
nRegId = EgtGetNext(nRegId)
End While
' Ne derivo il solido di estrusione
Dim nSolId As Integer = CreateSolidFromRegion(nRegId, -dThick * Vector3d.Z_AX(), nGrpRegId)
EgtSetName(nSolId, NAME_DRIP_SOLID)
EgtSetColor(nSolId, New Color3d(0, 255, 255, 25))
EgtSetStatus(nSolId, GDB_ST.OFF)
Return nSolId <> GDB_ID.NULL
End Function
Friend Function EraseSolidForDrip(nPartId As Integer) As Boolean
' Recupero layer Regione
Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION)
' Elimino eventuale vecchio solido
EgtErase(EgtGetFirstNameInGroup(nGrpRegId, NAME_DRIP_SOLID))
Return True
End Function
Friend Function GetPartArea(nPartId As Integer) As Double
Dim nRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION)
Dim nSurfId As Integer = EgtGetFirstInGroup(nRegId)
While nSurfId <> GDB_ID.NULL And EgtGetType(nSurfId) <> GDB_TY.SRF_FRGN
nSurfId = EgtGetNext(nSurfId)
End While
Dim dArea As Double = 0
EgtSurfFrGrossArea(nSurfId, dArea)
Return dArea
End Function
Public Function EgtGetPartCenter(nPartId As Integer, ByRef ptCenter As Point3d) As Boolean
Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION)
Dim nRegId As Integer = EgtGetFirstInGroup(nGrpRegId)
While nRegId <> GDB_ID.NULL
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then Exit While
nRegId = EgtGetNext(nRegId)
End While
Return EgtCentroid(nRegId, GDB_ID.ROOT, ptCenter)
End Function
Public Function GetPointInTableRef(ByVal ptCenter As Point3d, ByRef ptTable As Point3d) As Point3d
' setto il riferimento del tavolo1 (passo l'indice della tavola e il punto su cui salvare l'informazione)
If Not EgtGetTableRef(1, ptTable) Then Return Nothing
Dim ptResult As New Point3d
ptResult.x = ptCenter.x - ptTable.x
ptResult.y = ptCenter.y - ptTable.y
ptResult.z = ptCenter.z - ptTable.z
Return ptResult
End Function
End Module
+810
View File
@@ -0,0 +1,810 @@
Imports EgtUILib
Imports EgtWPFLib5
Public Module SplitAuto
Private m_dLastDT As Double = 0
'-----------------------------------------------------------------------------------------------
Friend Class SplitMach
Public m_nId As Integer
Public m_vOthId As New List(Of Integer)
Public m_nType As Integer
Public m_dSideAng As Double
Public m_sLay As String
Public m_nNbrId As Integer
Public m_nInterf As Integer
Public m_bCanStartAll As Boolean
Public m_bCanEndAll As Boolean
Public m_bStartAll As Boolean
Public m_bEndAll As Boolean
Public m_bEnabled As Boolean
Public m_bPause As Boolean
Public m_bInvert As Boolean
Public m_bIsLine As Boolean
Public m_dPrevAng As Double
Public m_dNextAng As Double
Public m_dStartFreeLen As Double
Public m_dEndFreeLen As Double
End Class
'-----------------------------------------------------------------------------------------------
Friend Function CalculateSplitMachList(nCurrPhase As Integer, ByRef MachSplitList As List(Of SplitMach)) As Boolean
' Pulisco la lista delle lavorazioni
MachSplitList.Clear()
' La riempio
Dim nOperId As Integer = EgtGetFirstOperation()
While nOperId <> GDB_ID.NULL
' verifico sia una lavorazione valida della fase corrente
If IsValidMachining(nOperId) And EgtGetOperationPhase(nOperId) = nCurrPhase Then
' se appartiene ad un grezzo attivo la inserisco in lista
If IsMachiningInActiveRaw(nOperId) Then
Dim Mach As New SplitMach
' identificativo
Mach.m_nId = nOperId
' eventuali lavorazioni inglobate
Dim sInfo As String = String.Empty
If EgtGetInfo(nOperId, INFO_MCH_OTHMID, sInfo) Then
Dim sItems() As String = sInfo.Split(",".ToCharArray)
For Each sId In sItems
Dim nId As Integer = 0
StringToInt(sId, nId)
If nId > 0 Then Mach.m_vOthId.Add(nId)
Next
End If
' tipo
Mach.m_nType = EgtGetOperationType(nOperId)
' layer di origine
EgtGetInfo(nOperId, INFO_MCH_LAYER, Mach.m_sLay)
' se taglio con lama
If Mach.m_nType = MCH_OY.SAWING Then
' verifica interferenza
If Mach.m_sLay = NAME_OUTLOOP Then
EgtVerifyMachining(nOperId, Mach.m_nInterf)
For Each nId As Integer In Mach.m_vOthId
Dim nRes As Integer = FMI_TYPE.LI Or FMI_TYPE.RM Or FMI_TYPE.LO
EgtVerifyMachining(nId, nRes)
Mach.m_nInterf = Mach.m_nInterf Or nRes
Next
Else
Mach.m_nInterf = FMI_TYPE.NONE
End If
' la imposto come lavorazione corrente
EgtSetCurrMachining(nOperId)
' inversione
EgtGetMachiningParam(MCH_MP.INVERT, Mach.m_bInvert)
' recupero l'angolo di fianco
EgtGetMachiningParam(MCH_MP.SIDEANGLE, Mach.m_dSideAng)
' recupero allungamento iniziale e finale (negativi vicino ad angoli interni)
Dim dStartAddLen As Double = -10
EgtGetMachiningParam(MCH_MP.STARTADDLEN, dStartAddLen)
Dim dEndAddLen As Double = -10
EgtGetMachiningParam(MCH_MP.ENDADDLEN, dEndAddLen)
' recupero tipo entità, ancolo con entità precedente e successiva, lunghezze libere iniziale e finale
Mach.m_bIsLine = True
Mach.m_dPrevAng = 0
Mach.m_dNextAng = 0
Mach.m_dStartFreeLen = FREELEN_INF + 1
Mach.m_dEndFreeLen = FREELEN_INF + 1
Dim nEntId, nSub As Integer
If EgtGetMachiningGeometry( 0, nEntId, nSub) Then
If EgtGetType( nEntId) = GDB_TY.CRV_ARC OrElse EgtGetType( nEntId) = GDB_TY.CRV_COMPO Then Mach.m_bIsLine = False
EgtGetInfo( nEntId, If( Not Mach.m_bInvert, INFO_PREVANG, INFO_NEXTANG), Mach.m_dPrevAng)
EgtGetInfo( nEntId, If( Not Mach.m_bInvert, INFO_NEXTANG, INFO_PREVANG), Mach.m_dNextAng)
EgtGetInfo( nEntId, If( Not Mach.m_bInvert, INFO_START_FREELEN, INFO_END_FREELEN), Mach.m_dStartFreeLen)
EgtGetInfo( nEntId, If( Not Mach.m_bInvert, INFO_END_FREELEN, INFO_START_FREELEN), Mach.m_dEndFreeLen)
End If
' verifico se trasformabile in un taglio di separazione (almeno da un lato)
If (dStartAddLen > -EPS_SMALL Or dEndAddLen > -EPS_SMALL) And
Mach.m_sLay = NAME_OUTLOOP And Mach.m_nInterf = FMI_TYPE.NONE Then
Dim nRes As Integer = EgtVerifyCutAsSplitting(nOperId)
Mach.m_bCanStartAll = (dStartAddLen > -EPS_SMALL And (nRes And CAR_RES.LI_OK) <> 0) And
Mach.m_dStartFreeLen > FREELEN_INF And Mach.m_bIsLine
Mach.m_bCanEndAll = (dEndAddLen > -EPS_SMALL And (nRes And CAR_RES.LO_OK) <> 0) And
Mach.m_dEndFreeLen > FREELEN_INF And Mach.m_bIsLine
End If
' se trasformabile in taglio di separazione, verifico se lo è
If Mach.m_bCanStartAll Or Mach.m_bCanEndAll Then
EgtSetCurrMachining(nOperId)
Dim nLiType As Integer
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiType)
Dim nLoType As Integer
EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoType)
Mach.m_bStartAll = (nLiType = MCH_SAW_LI.EXT_CENT Or nLiType = MCH_SAW_LI.EXT_OUT)
Mach.m_bEndAll = (nLoType = MCH_SAW_LO.EXT_CENT Or nLoType = MCH_SAW_LO.EXT_OUT)
Else
Mach.m_bStartAll = False
Mach.m_bEndAll = False
End If
' Waterjet
ElseIf Mach.m_nType = MCH_OY.WATERJETTING Then
Mach.m_nInterf = FMI_TYPE.NONE
' recupero l'angolo di fianco
EgtGetMachiningParam(MCH_MP.SIDEANGLE, Mach.m_dSideAng)
Mach.m_bCanStartAll = False
Mach.m_bCanEndAll = False
Mach.m_bStartAll = False
Mach.m_bEndAll = False
' Forature e fresature
Else
Mach.m_nInterf = FMI_TYPE.NONE
Mach.m_dSideAng = 0
Mach.m_bCanStartAll = False
Mach.m_bCanEndAll = False
Mach.m_bStartAll = False
Mach.m_bEndAll = False
End If
' abilitazione
Mach.m_bEnabled = Not EgtExistsInfo(nOperId, INFO_MCH_USER_OFF)
' pausa
Mach.m_bPause = GetPause(nOperId)
' inserisco in lista
MachSplitList.Add(Mach)
' altrimenti la disattivo
Else
EgtSetOperationMode(nOperId, False)
End If
End If
nOperId = EgtGetNextOperation(nOperId)
End While
Return True
End Function
'-----------------------------------------------------------------------------------------------
Friend Sub ColorMachining(MachSplit As SplitMach, Optional bReset As Boolean = False)
EgtDisableModified()
' Assegno stato
Dim bEnabled As Boolean = MachSplit.m_bEnabled
Dim nInterf As Integer = If(bReset, FMI_TYPE.NONE, MachSplit.m_nInterf)
' Colore della lavorazione principale
ColorSingleMachining(MachSplit.m_nId, MachSplit.m_sLay, MachSplit.m_dSideAng, bEnabled, nInterf)
' Colore delle lavorazioni inglobate
For Each nId As Integer In MachSplit.m_vOthId
ColorSingleMachining(nId, MachSplit.m_sLay, MachSplit.m_dSideAng, bEnabled, nInterf)
Next
EgtEnableModified()
End Sub
Private Sub ColorSingleMachining(nOperId As Integer, sLay As String, dSideAng As Double, bEnabled As Boolean, nInterf As Integer)
' Verifico se è un taglio da sopra o da sotto
Dim bOnCut As Boolean = (sLay = NAME_ONPATH)
Dim bDrip As Boolean = (sLay = NAME_DRIPCUT Or sLay = NAME_UNDERDRILL)
' Recupero il preview della lavorazione
Dim nPvId As Integer = GDB_ID.NULL
EgtGetInfo(EgtGetFirstNameInGroup(nOperId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
' Cambio il colore
Dim nGrpId As Integer = EgtGetFirstGroupInGroup(nPvId)
While nGrpId <> GDB_ID.NULL
Dim vCutId As New List(Of Integer)
Dim nId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_CUT)
While nId <> GDB_ID.NULL
vCutId.Add(nId)
nId = EgtGetNextName(nId, NAME_PV_CUT)
End While
Dim nPrcId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_PRECUT)
Dim nPocId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_POSTCUT)
Dim nDwnCutId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_CUT)
Dim nDwnPrcId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_PRECUT)
Dim nDwnPocId As Integer = EgtGetFirstNameInGroup(nGrpId, NAME_PV_DOWN_POSTCUT)
If Not bEnabled Then
For Each nId In vCutId
EgtSetColor(nId, COL_MCH_DISABLED)
Next
EgtSetColor(nDwnCutId, COL_MCH_DISABLED)
Dim bFreeStart As Boolean = (nInterf And FMI_TYPE.LI) <> FMI_TYPE.LI
EgtSetColor(nPrcId, If(bFreeStart, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
EgtSetColor(nDwnPrcId, If(bFreeStart, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
Dim bFreeEnd As Boolean = (nInterf And FMI_TYPE.LO) <> FMI_TYPE.LO
EgtSetColor(nPocId, If(bFreeEnd, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
EgtSetColor(nDwnPocId, If(bFreeEnd, COL_MCH_DISABLED, COL_MCH_DIS_INTERF))
Else
Dim colCut As Color3d
If bOnCut Then
colCut = COL_MCH_ONCUT()
ElseIf bDrip Then
colCut = COL_MCH_DRIPCUT()
ElseIf Math.Abs(dSideAng) > EPS_ANG_SMALL Then
colCut = COL_MCH_CUT_ANG()
Else
colCut = COL_MCH_CUT()
End If
For Each nId In vCutId
EgtSetColor(nId, colCut)
Next
EgtSetColor(nDwnCutId, colCut)
Dim colStart As Color3d = COL_MCH_INTERF()
If (nInterf And FMI_TYPE.LI) <> FMI_TYPE.LI Then
If bOnCut Then
colStart = COL_MCH_ONFREE()
ElseIf bDrip Then
colStart = COL_MCH_DRIPFREE()
Else
colStart = COL_MCH_FREE()
End If
End If
EgtSetColor(nPrcId, colStart)
EgtSetColor(nDwnPrcId, colStart)
Dim colEnd As Color3d = COL_MCH_INTERF()
If (nInterf And FMI_TYPE.LO) <> FMI_TYPE.LO Then
If bOnCut Then
colEnd = COL_MCH_ONFREE()
ElseIf bDrip Then
colEnd = COL_MCH_DRIPFREE()
Else
colEnd = COL_MCH_FREE()
End If
End If
EgtSetColor(nPocId, colEnd)
EgtSetColor(nDwnPocId, colEnd)
End If
nGrpId = EgtGetNextGroup(nGrpId)
End While
End Sub
'-----------------------------------------------------------------------------------------------
Friend Sub ShowOnePhaseMachiningPreview(nPhase As Integer)
Dim bOldEnMod As Boolean = EgtGetEnableModified()
EgtDisableModified()
Dim nOpeId = EgtGetFirstOperation()
While nOpeId <> GDB_ID.NULL
If EgtGetOperationType(nOpeId) <> MCH_OY.DISP And
(EgtGetOperationMode(nOpeId) OrElse EgtExistsInfo(nOpeId, INFO_MCH_USER_OFF) OrElse EgtExistsInfo(nOpeId, INFO_MCH_DUPLED)) Then
Dim nStatus As Integer = If(EgtGetOperationPhase(nOpeId) = nPhase, GDB_ST.ON_, GDB_ST.OFF)
' Lavorazione principale
Dim nPvId As Integer = GDB_ID.NULL
EgtGetInfo(EgtGetFirstNameInGroup(nOpeId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
EgtSetStatus(nPvId, nStatus)
' Eventuali lavorazioni inglobate
Dim sInfo As String = String.Empty
If EgtGetInfo(nOpeId, INFO_MCH_OTHMID, sInfo) Then
Dim sItems() As String = sInfo.Split(",".ToCharArray)
For Each sId In sItems
Dim nId As Integer = GDB_ID.NULL
StringToInt(sId, nId)
Dim nPvId2 As Integer = GDB_ID.NULL
EgtGetInfo(EgtGetFirstNameInGroup(nId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId2)
EgtSetStatus(nPvId2, nStatus)
Next
End If
End If
nOpeId = EgtGetNextOperation(nOpeId)
End While
If bOldEnMod Then EgtEnableModified()
End Sub
Friend Sub ShowAllPhasesMachiningPreview()
Dim bOldEnMod As Boolean = EgtGetEnableModified()
EgtDisableModified()
Dim nOpeId = EgtGetFirstOperation()
While nOpeId <> GDB_ID.NULL
If EgtGetOperationType(nOpeId) <> MCH_OY.DISP And
(EgtGetOperationMode(nOpeId) OrElse EgtExistsInfo(nOpeId, INFO_MCH_USER_OFF) OrElse EgtExistsInfo(nOpeId, INFO_MCH_DUPLED)) Then
Dim nStatus As Integer = GDB_ST.ON_
' Lavorazione principale
Dim nPvId As Integer = GDB_ID.NULL
EgtGetInfo(EgtGetFirstNameInGroup(nOpeId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
EgtSetStatus(nPvId, nStatus)
' Eventuali lavorazioni inglobate
Dim sInfo As String = String.Empty
If EgtGetInfo(nOpeId, INFO_MCH_OTHMID, sInfo) Then
Dim sItems() As String = sInfo.Split(",".ToCharArray)
For Each sId In sItems
Dim nId As Integer = GDB_ID.NULL
StringToInt(sId, nId)
Dim nPvId2 As Integer = GDB_ID.NULL
EgtGetInfo(EgtGetFirstNameInGroup(nId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId2)
EgtSetStatus(nPvId2, nStatus)
Next
End If
End If
nOpeId = EgtGetNextOperation(nOpeId)
End While
If bOldEnMod Then EgtEnableModified()
End Sub
'-----------------------------------------------------------------------------------------------
Friend Function SplitRawParts(nPrevPhase As Integer, vCuts() As Integer,
ByRef vNewRaws As List(Of Integer)) As Boolean
' Aggiorno preview di questi tagli lasciandoli nella lavorazione
For Each nCut As Integer In vCuts
UpdateMachiningPreview(nCut, False)
Next
' Creo nuova fase
Dim nNewPhase As Integer = EgtAddPhase()
' Origine della tavola
Dim ptOri As Point3d
EgtGetTableRef(1, ptOri)
Dim vtOri As New Vector3d(ptOri.x, ptOri.y, ptOri.z)
' Eseguo eventuali spezzature dei grezzi e vi sposto i pezzi (i grezzi devono essere sempre copiati per Registrazione con rotazione)
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL
' se il grezzo è presente nella fase precedente
If EgtVerifyRawPartPhase(nRawId, nPrevPhase) Then
' Calcolo nuovi grezzi
Dim nRaw1Id = EgtSplitFlatRawPartWithMachinings(nRawId, vCuts)
' Fisso posizione dei nuovi grezzi
Dim nNewRawId = nRaw1Id
While nNewRawId <> GDB_ID.NULL
Dim ptMin, ptMax As Point3d
EgtGetRawPartBBox(nNewRawId, ptMin, ptMax)
EgtMoveToCornerRawPart(nNewRawId, ptMin - vtOri, MCH_CR.BL)
nNewRawId = EgtGetNextRawPart(nNewRawId)
End While
' Se almeno 2 grezzi da uno vecchio, li considero nuovi
If EgtGetNextRawPart(nRaw1Id) <> GDB_ID.NULL Then
nNewRawId = nRaw1Id
While nNewRawId <> GDB_ID.NULL
vNewRaws.Add(nNewRawId)
nNewRawId = EgtGetNextRawPart(nNewRawId)
End While
End If
' Assegno ai nuovi grezzi eventuale texture del grezzo originale
Dim nSolidId = EgtGetFirstNameInGroup(nRawId, NAME_RAW_SOLID)
Dim nameTxr As String = String.Empty
If EgtGetTextureName(nSolidId, nameTxr) Then
Dim refTxr As New Frame3d
EgtGetTextureFrame(nSolidId, GDB_ID.ROOT, refTxr)
nNewRawId = nRaw1Id
While nNewRawId <> GDB_ID.NULL
' Carico la texture sul nuovo grezzo
Dim nNewSolidId = EgtGetFirstNameInGroup(nNewRawId, NAME_RAW_SOLID)
EgtSetTextureName(nNewSolidId, nameTxr)
' Sistemo il riferimento della texture
EgtSetTextureFrame(nNewSolidId, refTxr, GDB_RT.GLOB)
' Passo al grezzo successivo
nNewRawId = EgtGetNextRawPart(nNewRawId)
End While
End If
End If
' passo al successivo grezzo
nRawId = EgtGetNextRawPart(nRawId)
End While
' Cancello preview dei tagli allungati dalla lavorazione
For Each nCut As Integer In vCuts
RemoveMachiningPreview(nCut)
Next
' Sposto tutte le lavorazioni disabilitate e le eventuali inglobate nella nuova fase
Dim nId = EgtGetFirstOperation()
While nId <> GDB_ID.NULL
Dim nNextId = EgtGetNextOperation(nId)
If IsValidMachining(nId) And EgtGetOperationPhase(nId) = nNewPhase - 1 And EgtExistsInfo(nId, INFO_MCH_USER_OFF) Then
' sposto la lavorazione
EgtChangeOperationPhase(nId, nNewPhase)
' sposto le inglobate
Dim sInfo As String = String.Empty
If EgtGetInfo(nId, INFO_MCH_OTHMID, sInfo) Then
Dim sItems() As String = sInfo.Split(",".ToCharArray)
For Each sId2 In sItems
Dim nId2 As Integer = 0
StringToInt(sId2, nId2)
If nId2 > 0 Then EgtChangeOperationPhase(nId2, nNewPhase)
Next
End If
End If
nId = nNextId
End While
Return True
End Function
'-----------------------------------------------------------------------------------------------
Friend Function CalculateSplitAuto() As Boolean
' Fase iniziale
EgtSetCurrPhase(1)
' Cancello tutte le lavorazioni
EraseMachinings(GDB_ID.NULL)
' Reinserisco tutte le lavorazioni
Dim nWarn As Integer = 0
AddMachinings(GDB_ID.NULL, nWarn)
If nWarn = 1 Then OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(MSG_SPLITPAGEUC + 11), MSG_TYPE.WARNING) ' Lama troppo grande per utilizzo ventosa
' Carico ventose
LoadVacuumCups()
' Lancio calcolo separazione
Dim bFinished As Boolean = False
While CalculateOnePhaseSplitAuto(bFinished)
If bFinished Then
Exit While
End If
End While
' Se non finito con successo, verifico se necessario limitare lavorazioni
If Not bFinished Then
If Not TestMachiningCurrPhaseForStrict() Then
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90321), MSG_TYPE.WARNING) 'Ridotte alcune lavorazioni per evitare interferenze
End If
End If
EgtSetCurrPhase(1)
' Scarico ventose
RemoveVacuumCups()
Return bFinished
End Function
'-----------------------------------------------------------------------------------------------
Friend Function CalculateOnePhaseSplitAuto(ByRef bFinished As Boolean) As Boolean
' Faccio ordine automatico delle lavorazioni
If Not SortAllMachinings() Then Return False
EstCalc.SetOrderMachiningFlag()
' Recupero l'indice della fase corrente
Dim nCurrPhase As Integer = EgtGetCurrPhase()
' Preparo la lista delle lavorazioni
Dim MachSplitList As New List(Of SplitMach)
If Not CalculateSplitMachList(nCurrPhase, MachSplitList) Then Return False
' Se non ci sono interferenze
If Not FindInterferences(MachSplitList) Then
' Abilito tutte le lavorazioni della lista
EnableAllMachinings(MachSplitList)
' Dichiaro conclusione ed esco
bFinished = True
Return True
End If
' Disabilito tutte le lavorazioni della lista
DisableAllMachinings(MachSplitList)
' Cerco il miglior taglio di separazione
Dim nCutInd As Integer = FindBestSeparationCut(MachSplitList)
If nCutInd < 0 Then Return False
' Eseguo il taglio
If Not MakeSeparatingCut(MachSplitList(nCutInd).m_nId) Then Return False
MachSplitList(nCutInd).m_bEnabled = True
MachSplitList(nCutInd).m_bStartAll = True
MachSplitList(nCutInd).m_bEndAll = True
ColorMachining(MachSplitList(nCutInd))
' Spezzo i grezzi creando una nuova fase di lavoro
Dim vCuts() As Integer = {MachSplitList(nCutInd).m_nId}
Dim vNewRaws As New List(Of Integer)
If SplitRawParts(nCurrPhase, vCuts, vNewRaws) Then
' Eseguo gli spostamenti dei grezzi
If MoveRawParts(MachSplitList(nCutInd).m_nId, vNewRaws) Then
While vNewRaws.Count() >= 4
vNewRaws.RemoveAt(0)
vNewRaws.RemoveAt(0)
MoveRawParts(MachSplitList(nCutInd).m_nId, vNewRaws)
End While
bFinished = False
Return True
End If
End If
' Ci sono stati errori dopo aver creato la nuova fase, ripristino la vecchia
RemoveLastPhase()
bFinished = False
Return False
End Function
'-----------------------------------------------------------------------------------------------
'-----------------------------------------------------------------------------------------------
Private Function FindInterferences(ByRef MachSplitList As List(Of SplitMach)) As Boolean
Dim bInterf As Boolean = False
For Each MachSplit As SplitMach In MachSplitList
If MachSplit.m_nInterf <> FMI_TYPE.NONE Then
bInterf = True
Exit For
End If
Next
Return bInterf
End Function
Private Function EnableAllMachinings(ByRef MachSplitList As List(Of SplitMach)) As Boolean
For nI As Integer = 0 To MachSplitList.Count() - 1
If Not MachSplitList(nI).m_bEnabled Then
MachSplitList(nI).m_bEnabled = True
EgtSetOperationMode(MachSplitList(nI).m_nId, True)
EgtRemoveInfo(MachSplitList(nI).m_nId, INFO_MCH_USER_OFF)
ColorMachining(MachSplitList(nI))
End If
Next
Return True
End Function
Private Function DisableAllMachinings(ByRef MachSplitList As List(Of SplitMach)) As Boolean
For nI As Integer = 0 To MachSplitList.Count() - 1
If MachSplitList(nI).m_bEnabled Then
MachSplitList(nI).m_bEnabled = False
EgtSetOperationMode(MachSplitList(nI).m_nId, False)
EgtSetInfo(MachSplitList(nI).m_nId, INFO_MCH_USER_OFF, True)
ColorMachining(MachSplitList(nI))
End If
Next
Return True
End Function
Private Function FindBestSeparationCut(MachSplitList As List(Of SplitMach)) As Integer
Dim nInd As Integer = -1
Dim nMaxInterf As Integer = 0
m_dLastDT = 0
For nI As Integer = 0 To MachSplitList.Count() - 1
Dim MachSplit As SplitMach = MachSplitList(nI)
' Se non allungabile ad entrambi gli estremi, vado oltre
If Not MachSplit.m_bCanStartAll Or Not MachSplit.m_bCanEndAll Then Continue For
' Se ci sono lavorazioni componenti, calcolo preview completo in lavorazione
If MachSplit.m_vOthId.Count() > 0 Then
UpdateMachiningPreview(MachSplit.m_nId, False)
End If
' Contatore interferenze altri tagli con taglio corrente
Dim nCurrInterf As Integer = 0
' Lunghezza baffi altri tagli che interferiscono su taglio corrente
Dim dCurrInterfLen As Double = 0
' Determino quanti tagli con interferenza interseca
For Each MachSplit2 As SplitMach In MachSplitList
' Se coincide con il precedente, vado oltre
If MachSplit2.m_nId = MachSplit.m_nId Then Continue For
' Se non interferisce, vado oltre
If MachSplit2.m_nInterf = FMI_TYPE.NONE Then Continue For
' Se ci sono lavorazioni componenti, calcolo preview completo in lavorazione
If MachSplit2.m_vOthId.Count() > 0 Then
UpdateMachiningPreview(MachSplit2.m_nId, False)
End If
' Eseguo verifica tra le lavorazioni
Dim bInterf As Boolean = False
If GetInterferenceWithOtherCut(MachSplit.m_nId, MachSplit2.m_nId, MachSplit2.m_nInterf) Then
bInterf = True
' Recupero lunghezza baffo secondo taglio
Dim nPvId As Integer = GDB_ID.NULL
EgtGetInfo(EgtGetFirstNameInGroup(MachSplit2.m_nId, NAME_PREVIEW), INFO_PV_ONPART_ID, nPvId)
Dim dDT As Double
If EgtGetInfo(EgtGetFirstGroupInGroup(nPvId), "DT", dDT) And dDT > dCurrInterfLen Then
dCurrInterfLen = dDT
End If
End If
If bInterf Then nCurrInterf += 1
' Rimozione eventuale preview completo in lavorazione
RemoveMachiningPreview(MachSplit2.m_nId)
Next
' Verifico se taglio corrente è nuovo campione
If nCurrInterf > nMaxInterf Then
nMaxInterf = nCurrInterf
nInd = nI
m_dLastDT = dCurrInterfLen
End If
' Rimozione eventuale preview completo in lavorazione
RemoveMachiningPreview(MachSplit.m_nId)
Next
Return nInd
End Function
Private Function GetInterferenceWithOtherCut(nId As Integer, nId2 As Integer, nInterf2 As Integer) As Boolean
' Se il secondo non ha interferenze, esco subito
If nInterf2 = FMI_TYPE.NONE Then Return False
' Regione di taglio ridotta del primo
Dim nPvId As Integer = EgtGetFirstNameInGroup(nId, NAME_PREVIEW)
If EgtGetGroupObjs(nPvId) = 0 Then EgtGetInfo(nPvId, INFO_PV_ONPART_ID, nPvId)
Dim nRCutId As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(nPvId), NAME_PV_RCUT)
' Se il secondo ha l'attacco che interferisce
If (nInterf2 And FMI_TYPE.LI) <> 0 Then
' Recupero regione dell'attacco
Dim nPv2Id As Integer = EgtGetFirstNameInGroup(nId2, NAME_PREVIEW)
If EgtGetGroupObjs(nPv2Id) = 0 Then EgtGetInfo(nPv2Id, INFO_PV_ONPART_ID, nPv2Id)
Dim nRLiCut2Id As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(nPv2Id), NAME_PV_RLICUT)
' Verifico se questa regione interferisce con quella del taglio di riferimento
If EgtSurfFrChunkSimpleClassify(nRCutId, 0, nRLiCut2Id, 0, 20 * EPS_SMALL) <> REGC.OUT Then Return True
End If
' Se il secondo ha l'uscita che interferisce
If (nInterf2 And FMI_TYPE.LO) <> 0 Then
' Recupero Id della regione dell'uscita
Dim nPv2Id As Integer = EgtGetFirstNameInGroup(nId2, NAME_PREVIEW)
If EgtGetGroupObjs(nPv2Id) = 0 Then EgtGetInfo(nPv2Id, INFO_PV_ONPART_ID, nPv2Id)
Dim nRLoCut2Id As Integer = EgtGetFirstNameInGroup(EgtGetFirstGroupInGroup(nPv2Id), NAME_PV_RLOCUT)
' Verifico se questa regione interferisce con quella del taglio di riferimento
If EgtSurfFrChunkSimpleClassify(nRCutId, 0, nRLoCut2Id, 0, 20 * EPS_SMALL) <> REGC.OUT Then Return True
End If
Return False
End Function
Private Function MakeSeparatingCut(nCutId As Integer) As Boolean
EgtSetCurrMachining(nCutId)
Dim nLiPrev As Integer
EgtGetMachiningParam(MCH_MP.LEADINTYPE, nLiPrev)
Dim nLoPrev As Integer
EgtGetMachiningParam(MCH_MP.LEADOUTTYPE, nLoPrev)
' allungo
If nLiPrev = MCH_SAW_LI.OUT Then
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_OUT)
Else
EgtSetMachiningParam(MCH_MP.LEADINTYPE, MCH_SAW_LI.EXT_CENT)
End If
If nLoPrev = MCH_SAW_LO.OUT Then
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_OUT)
Else
EgtSetMachiningParam(MCH_MP.LEADOUTTYPE, MCH_SAW_LO.EXT_CENT)
End If
UpdateMachiningPreview(nCutId, True)
EgtSetOperationMode(nCutId, True)
EgtRemoveInfo(nCutId, INFO_MCH_USER_OFF)
Return True
End Function
Private Function MoveRawParts(nCutId As Integer, vNewRaws As List(Of Integer)) As Boolean
' Almeno 2 nuovi grezzi (dovrebbero essere solo 2)
If vNewRaws.Count() < 2 Then Return False
' Privilegio il grezzo più piccolo (lo porto in seconda posizione per essere mosso per primo)
If GetSmallerRaw(vNewRaws(0), vNewRaws(1)) = 1 Then
Dim nTmp As Integer = vNewRaws(0)
vNewRaws(0) = vNewRaws(1)
vNewRaws(1) = nTmp
End If
' Centri dei primi 2 grezzi
Dim ptCen0 As Point3d
If Not EgtGetRawPartCenter(vNewRaws(0), ptCen0) Then Return False
Dim ptCen1 As Point3d
If Not EgtGetRawPartCenter(vNewRaws(1), ptCen1) Then Return False
' Direzione del taglio
EgtSetCurrMachining(nCutId)
Dim nEntId, nSub As Integer
If Not EgtGetMachiningGeometry(0, nEntId, nSub) Then Return False
Dim vtCutDir As Vector3d
EgtStartVector(nEntId, GDB_ID.ROOT, vtCutDir)
' Distanza minima di spostamento
Dim dExtraL As Double = 0
EgtMdbGetGeneralParam(MCH_GP.EXTRALONCUTREG, dExtraL)
Dim dMinMove As Double = m_dLastDT + dExtraL + 1
' Decido cosa muovere
Dim nDispId As Integer = EgtGetPhaseDisposition(EgtGetCurrPhase())
Dim dDeltaX = ptCen1.x - ptCen0.x
Dim dDeltaY = ptCen1.y - ptCen0.y
If Math.Abs(dDeltaX) < Math.Abs(dDeltaY) Then
Dim vtMoveY As New Vector3d(0, dMinMove / Math.Abs(vtCutDir.x), 0)
If dDeltaY < 0 Then vtMoveY = -vtMoveY
If Not ExecMove(nDispId, vNewRaws, vtMoveY, dMinMove) Then
If Math.Abs(dDeltaX) > 0.2 Then
Dim vtMoveX As New Vector3d(dMinMove / Math.Abs(vtCutDir.y), 0, 0)
If dDeltaX < 0 Then vtMoveX = -vtMoveX
If Not ExecMove(nDispId, vNewRaws, vtMoveX, dMinMove) Then
Return False
End If
Else
Return False
End If
End If
Else
Dim vtMoveX As New Vector3d(dMinMove / Math.Abs(vtCutDir.y), 0, 0)
If dDeltaX < 0 Then vtMoveX = -vtMoveX
If Not ExecMove(nDispId, vNewRaws, vtMoveX, dMinMove) Then
If Math.Abs(dDeltaY) > 0.2 Then
Dim vtMoveY As New Vector3d(0, dMinMove / Math.Abs(vtCutDir.x), 0)
If dDeltaY < 0 Then vtMoveY = -vtMoveY
If Not ExecMove(nDispId, vNewRaws, vtMoveY, dMinMove) Then
Return False
End If
Else
Return False
End If
End If
End If
Return True
End Function
Private Function TestMachiningCurrPhaseForStrict() As Boolean
' Recupero l'indice della fase corrente
Dim nCurrPhase As Integer = EgtGetCurrPhase()
' Preparo la lista delle lavorazioni
Dim MachSplitList As New List(Of SplitMach)
If Not CalculateSplitMachList(nCurrPhase, MachSplitList) Then Return False
' Affondamento ridotto
Dim dReducedDepth As Double = GetPrivateProfileDouble(S_MACH_NEST, K_MACH_REDUCEDDEPTH, 1, CurrentMachine.sMachIniFile)
' Restringo o rialzo lavorazioni abilitate ma con interferenza
Dim bModified As Boolean = False
For Each Mach As SplitMach In MachSplitList
If Mach.m_bEnabled And Mach.m_nInterf <> FMI_TYPE.NONE Then
If AdjustMachining(Mach.m_nId, Mach.m_nInterf, dReducedDepth) Then
bModified = True
End If
End If
Next
Return bModified
End Function
Private Function GetSmallerRaw(nRaw1Id As Integer, nRaw2Id As Integer) As Integer
' Area del primo grezzo
Dim nRc1Id As Integer = EgtGetFirstNameInGroup(nRaw1Id, NAME_RAW_OUTLINE)
Dim dArea1 As Double = 0
If Not EgtCurveAreaXY(nRc1Id, dArea1) Then Return 0
' Area del secondo grezzo
Dim nRc2Id As Integer = EgtGetFirstNameInGroup(nRaw2Id, NAME_RAW_OUTLINE)
Dim dArea2 As Double = 0
If Not EgtCurveAreaXY(nRc2Id, dArea2) Then Return 0
' Confronto le aree
If dArea1 < dArea2 Then
Return 1
Else
Return 2
End If
End Function
Private Function ExecMove(nDispId As Integer, vNewRaws As List(Of Integer),
vtMove As Vector3d, dMinMove As Double) As Boolean
Dim vtMove2 As Vector3d = -vtMove
Dim rmData As New RawMoveData
If PutVacuumCupsOnRaw(vNewRaws(1), rmData) AndAlso
SafeMoveRawPart(vNewRaws(1), vtMove, dMinMove) Then
rmData.m_vtRawMove = vtMove
SaveOneMoveInfoInDisposition(nDispId, rmData)
Return True
ElseIf PutVacuumCupsOnRaw(vNewRaws(0), rmData) AndAlso
SafeMoveRawPart(vNewRaws(0), vtMove2, dMinMove) Then
rmData.m_vtRawMove = vtMove2
SaveOneMoveInfoInDisposition(nDispId, rmData)
Return True
Else
Return False
End If
End Function
Private Function SafeMoveRawPart(nRawId As Integer, ByRef vtMove As Vector3d, dMindist As Double) As Boolean
' Se esce dalla tavola, movimento già annullato ed esco con errore
If Not EgtMoveRawPart(nRawId, vtMove) Then Return False
' Se interferisce con altri grezzi, annullo movimento ed esco con errore
If Not VerifyRawWithOtherRaws(nRawId, dMindist) Then
EgtMoveRawPart(nRawId, -vtMove)
Return False
End If
' Provo ad aggiungere un altro movimento
If EgtMoveRawPart(nRawId, vtMove) Then
If VerifyRawWithOtherRaws(nRawId, dMindist) Then
vtMove += vtMove
Else
EgtMoveRawPart(nRawId, -vtMove)
End If
End If
' Provo ad aggiungere un movimento dimezzato
If EgtMoveRawPart(nRawId, 0.5 * vtMove) Then
If VerifyRawWithOtherRaws(nRawId, dMindist) Then
vtMove += 0.5 * vtMove
Else
EgtMoveRawPart(nRawId, -0.5 * vtMove)
End If
End If
' Provo ad aggiunger un movimento 1/4
If EgtMoveRawPart(nRawId, 0.25 * vtMove) Then
If VerifyRawWithOtherRaws(nRawId, dMindist) Then
vtMove += 0.25 * vtMove
Else
EgtMoveRawPart(nRawId, -0.25 * vtMove)
End If
End If
Return True
End Function
Private Function VerifyRawWithOtherRaws(nRawId As Integer, dMindist As Double) As Boolean
' Contorno del grezzo in esame
Dim nRcId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_RAW_OUTLINE)
If nRcId = GDB_ID.NULL Then Return False
' Fase corrente
Dim nCurrPhase As Integer = EgtGetCurrPhase()
' Recupero elenco dei contorni degli altri grezzi della fase indicata
Dim OthRawList As New List(Of Integer)
Dim nOthId As Integer = EgtGetFirstRawPart()
While nOthId <> GDB_ID.NULL
If EgtVerifyRawPartPhase(nOthId, nCurrPhase) Then
If nOthId <> nRawId Then
Dim nOthRcId As Integer = EgtGetFirstNameInGroup(nOthId, NAME_RAW_OUTLINE)
If nOthRcId <> GDB_ID.NULL Then OthRawList.Add(nOthRcId)
End If
End If
nOthId = EgtGetNextRawPart(nOthId)
End While
' Box del grezzo in esame
Dim b3Raw As New BBox3d
EgtGetBBoxGlob(nRcId, GDB_BB.STANDARD, b3Raw)
b3Raw.Expand(dMindist)
' Creo la curva offsettata della minima distanza (considero solo la prima, ovvero la più lunga)
Dim nCount As Integer = 0
Dim nOffsId = EgtOffsetCurveAdv(nRcId, dMindist, OFF_TYPE.FILLET, nCount)
' Verifico
Dim bInterf As Boolean = False
For Each nId As Integer In OthRawList
Dim b3OthRaw As New BBox3d
EgtGetBBoxGlob(nId, GDB_BB.STANDARD, b3OthRaw)
' Se i box interferiscono
If b3Raw.OverlapsXY(b3OthRaw) Then
' Verifico i contorni esterni
If EgtClosedCurveClassify(nOffsId, nId) <> CCREGC.OUT Then
bInterf = True
Exit For
End If
End If
Next
' Cancello curve offset
For i = 0 To nCount - 1
EgtErase(nOffsId + i)
Next
Return (Not bInterf)
End Function
End Module
+766
View File
@@ -0,0 +1,766 @@
Imports EgtUILib
Module VacuumCups
' Tipo manipolatore con ventosa (0=assente, 1=dietro, 2=laterale)
Private m_nVacType As Integer = 0
' Dati del manipolatore
Private m_nTempId As Integer = GDB_ID.NULL
Private m_nVacId As Integer = GDB_ID.NULL
Private m_nRefId As Integer = GDB_ID.NULL
' utilizzati per gestire il posizionamento delle ventose
Private m_dPreferredRot As Double = 0
Private m_dDripRefAng As Double = 0
' Nome del gruppo temporaneo per le ventose
Private Const VACTMP_GRP As String = "VacTmp"
Friend Function GetVacuumType() As Integer
Return m_nVacType
End Function
Friend Function GetVacuumId() As Integer
Return m_nVacId
End Function
Friend Function LoadVacuumCups() As Boolean
' Leggo tipo manipolatore con ventosa
m_nVacType = 0
EgtGetInfo(EgtGetHeadId(VACUUM_HEAD), 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)
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)
If nT1Id = GDB_ID.NULL Then Return False
' Creo gruppo temporaneo in cui copiarli
m_nTempId = EgtCreateGroup(GDB_ID.ROOT)
If m_nTempId = GDB_ID.NULL Then Return False
EgtSetName(m_nTempId, VACTMP_GRP)
EgtSetLevel(m_nTempId, GDB_LV.TEMP)
' Eseguo copia in globale
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)
' 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
EgtSetStatus(m_nVacId, GDB_ST.OFF)
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)
End Select
nId = EgtGetNext(nId)
End While
m_nRefId = EgtCopyGlob(nT1Id, m_nVacId)
If m_nRefId = GDB_ID.NULL Then Return False
EgtSetStatus(m_nRefId, GDB_ST.ON_)
Return True
End Function
Friend Function RemoveVacuumCups() As Boolean
' Cancello eventuali gruppi per ventose usati appena prima
EgtErase(m_nTempId)
m_nTempId = GDB_ID.NULL
m_nVacId = GDB_ID.NULL
m_nRefId = GDB_ID.NULL
' Cancello eventuali vecchi gruppi per ventose
Dim nId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, VACTMP_GRP)
While nId <> GDB_ID.NULL
Dim nNextId As Integer = EgtGetNextName(nId, VACTMP_GRP)
EgtErase(nId)
nId = nNextId
End While
Return True
End Function
Friend Function ResetVacuumCups() As Boolean
' Ripristino posizione e rotazione originali
Dim frOriRef As New Frame3d
EgtFrame(EgtGetFirstNameInGroup(EgtGetHeadId(VACUUM_HEAD), 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)
frCurrRef.ToLoc(frOriRef)
Dim dLen, dAngVertDeg, dAngOrizzDeg As Double
frCurrRef.VersX().ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
EgtRotate(m_nVacId, frOriRef.Orig(), frOriRef.VersZ(), -dAngOrizzDeg, GDB_RT.GLOB)
' Ripristino visualizzazione originale
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)
End Select
nId = EgtGetNext(nId)
End While
EgtSetStatus(m_nRefId, GDB_ST.ON_)
Return True
End Function
Friend Function PutVacuumCupsOnRaw(nRawId As Integer, ByRef rmData As RawMoveData) As Boolean
' Ripristino posizione originale ventose
ResetVacuumCups()
' Box e baricentro del grezzo (riportato sopra al grezzo)
Dim b3Raw As New BBox3d
EgtGetRawPartBBox(nRawId, b3Raw)
Dim ptRawCen As Point3d
EgtGetRawPartCenter(nRawId, ptRawCen)
ptRawCen.z += b3Raw.DimZ() / 2
' Se non esiste, creo la regione del kerf del grezzo
Dim nKerfId As Integer = EgtGetFirstNameInGroup(nRawId, NAME_KERF)
Dim nRKerfId = EgtGetFirstNameInGroup(nRawId, NAME_KERF_REGION)
If nRKerfId = GDB_ID.NULL Then
nRKerfId = EgtCreateSurfFlatRegion(nRawId, nKerfId)
' se non sono riuscito a crearla, allora è nulla e posso uscire
If nRKerfId = GDB_ID.NULL Then Return False
EgtSetName(nRKerfId, NAME_KERF_REGION)
EgtSetMode(nRKerfId, GDB_MD.HIDDEN)
End If
' Box e baricentro della regione di kerf
Dim b3Kerf As New BBox3d
EgtGetBBoxGlob(nRKerfId, GDB_BB.STANDARD, b3Kerf)
Dim ptKerfCen As Point3d
EgtCentroid(nRKerfId, GDB_ID.ROOT, ptKerfCen)
' Eseguo ricerca
If FindVacuumCupsOnRaw(nRawId, ptRawCen, b3Kerf, ptKerfCen, nKerfId, nRKerfId, rmData) Then
Return True
End If
' In caso di fallimento, provo riducendo con offset la regione di kerf
' (così si simula la proiezione del centro sul MAT - medial axis transform)
Dim bOkFind As Boolean = False
Dim vOffset() As Double = {-450, -350, -250, -150}
For i As Integer = 0 To vOffset.Length() - 1
Dim nRKerfOffsId = EgtCopy(nRKerfId, nRKerfId, GDB_POS.AFTER)
If EgtSurfFrOffset(nRKerfOffsId, vOffset(i), OFF_TYPE.FILLET) AndAlso
EgtCentroid(nRKerfOffsId, GDB_ID.ROOT, ptKerfCen) Then
Dim nOutOffsId As Integer = GetRegionOutLoop(nRKerfOffsId, nRawId)
bOkFind = FindVacuumCupsOnRaw(nRawId, ptRawCen, b3Kerf, ptKerfCen, nOutOffsId, nRKerfId, rmData)
EgtErase(nOutOffsId)
End If
EgtErase(nRKerfOffsId)
If bOkFind Then Return True
Next
Return False
End Function
Friend Function PutVacuumCupsOnPart(nPartId As Integer,
ByRef rmData As RawMoveData, ByRef b3Part As BBox3d) As Boolean
' Ripristino posizione originale ventose
ResetVacuumCups()
' Verifico sia veramente un pezzo
If EgtGetRawPartFromPart(nPartId) = GDB_ID.NULL Then Return False
' Cerco la direzione del primo taglio attivo da sotto
Dim nDripLayId As Integer = EgtGetFirstNameInGroup( nPartId, NAME_DRIPCUT)
Dim nDripLineId As Integer = EgtGetFirstInGroup( nDripLayId)
While nDripLineId <> GDB_ID.NULL
Dim nMchId As Integer = EgtGetOperationId( "DripSaw" & nDripLineId.ToString())
Dim nMode As Integer
If EgtGetMode( nMchId, nMode) AndAlso nMode = GDB_MD.STD Then Exit While
nDripLineId = EgtGetNext( nDripLineId)
End While
Dim vtDir As New Vector3d
if EgtStartVector( nDripLineId, GDB_ID.ROOT, vtDir) Then
Dim dLen, dAngV, dAngH As Double
vtDir.ToSpherical( dLen, dAngV, dAngH)
Dim dOffsAng = dAngH - m_dDripRefAng
While dOffsAng - m_dPreferredRot >= 90
dOffsAng -= 180
End While
While dOffsAng - m_dPreferredRot <= -90
dOffsAng += 180
End While
m_dPreferredRot = dOffsAng
End If
' Recupero la regione del pezzo
Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION)
Dim nRegId As Integer = EgtGetFirstInGroup(nGrpRegId)
While nRegId <> GDB_ID.NULL
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then Exit While
nRegId = EgtGetNext(nRegId)
End While
If nRegId = GDB_ID.NULL Then Return False
' Box e baricentro del pezzo (sempre sopra)
EgtGetBBoxGlob(nRegId, GDB_BB.STANDARD, b3Part)
Dim ptPartCen As Point3d
EgtCentroid(nRegId, GDB_ID.ROOT, ptPartCen)
' Calcolo il contorno esterno del pezzo
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
EgtErase(nOutId)
Return True
Else
EgtErase(nOutId)
End If
' In caso di fallimento, provo riducendo con offset la regione di kerf
' (così si simula la proiezione del centro sul MAT - medial axis transform)
Dim bOkFind As Boolean = False
Dim vOffset() As Double = {-450, -350, -250, -150}
For i As Integer = 0 To vOffset.Length() - 1
Dim nRegOffsId As Integer = EgtCopy(nRegId, nRegId, GDB_POS.AFTER)
Dim ptRegOffsCen As Point3d
If EgtSurfFrOffset(nRegOffsId, vOffset(i), OFF_TYPE.FILLET) AndAlso
EgtCentroid(nRegOffsId, GDB_ID.ROOT, ptRegOffsCen) Then
Dim nOutOffsId As Integer = GetRegionOutLoop(nRegOffsId, nGrpRegId)
bOkFind = FindVacuumCupsOnRaw(nPartId, ptRegOffsCen, b3Part, ptPartCen, nOutOffsId, nRegId, rmData)
EgtErase(nOutOffsId)
End If
EgtErase(nRegOffsId)
If bOkFind Then Return True
Next
Return False
End Function
Friend Function MyPutVacuumCupsOnPart(nPartId As Integer,
ByRef rmData As RawMoveData, ByRef b3Part As BBox3d) As Boolean
' Ripristino posizione originale ventose
ResetVacuumCups()
' Verifico sia veramente un pezzo
If EgtGetRawPartFromPart(nPartId) = GDB_ID.NULL Then Return False
' Recupero la regione del pezzo
Dim nGrpRegId As Integer = EgtGetFirstNameInGroup(nPartId, ConstMach.NAME_REGION)
Dim nRegId As Integer = EgtGetFirstInGroup(nGrpRegId)
While nRegId <> GDB_ID.NULL
If EgtGetType(nRegId) = GDB_TY.SRF_FRGN Then Exit While
nRegId = EgtGetNext(nRegId)
End While
If nRegId = GDB_ID.NULL Then Return False
Dim nCount As Integer = 0
' recupero il contorno del pezzo
Dim nIdCurve As Integer = GetRegionOutLoop(nRegId, nGrpRegId)
If nIdCurve = GDB_ID.NULL OrElse nCount > 1 Then Return False
' recuper il versore
Dim frFrame As New Frame3d
' recupero le dimensioni del minimo rettangolo
Dim dLengthX As Double = 0
Dim dLengthY As Double = 0
EgtCurveMinAreaRectangleXY(nIdCurve, GDB_ID.ROOT, frFrame, dLengthX, dLengthY)
rmData.m_vtRect.x = dLengthX / 2
rmData.m_vtRect.y = dLengthY / 2
' recupero il centro del rettangolo (nel piano XY)
Dim ptCetMinRect As Point3d = frFrame.Orig()
rmData.m_ptCenMinRect = ptCetMinRect
' 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
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
'vtDir.ToSpherical(dLen, dAngV, dAngH)
' misuro il delta tra l'angolo calcolato e quello provilegiato per il taglio da sotto (sempre nullo)
'Dim dOffsAng = dMyAngH - m_dDripRefAng
'While dOffsAng - m_dPreferredRot >= 90
' dOffsAng -= 180
'End While
'While dOffsAng - m_dPreferredRot <= -90
' dOffsAng += 180
'End While
'm_dPreferredRot = dOffsAng
' Box e baricentro del pezzo (sempre sopra)
EgtGetBBoxGlob(nRegId, GDB_BB.STANDARD, b3Part)
Dim ptPartCen As Point3d
EgtCentroid(nRegId, GDB_ID.ROOT, ptPartCen)
' Calcolo il contorno esterno del pezzo
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
EgtErase(nOutId)
Return True
Else
EgtErase(nOutId)
End If
' In caso di fallimento, provo riducendo con offset la regione di kerf
' (così si simula la proiezione del centro sul MAT - medial axis transform)
Dim bOkFind As Boolean = False
Dim vOffset() As Double = {-450, -350, -250, -150}
For i As Integer = 0 To vOffset.Length() - 1
Dim nRegOffsId As Integer = EgtCopy(nRegId, nRegId, GDB_POS.AFTER)
Dim ptRegOffsCen As Point3d
If EgtSurfFrOffset(nRegOffsId, vOffset(i), OFF_TYPE.FILLET) AndAlso
EgtCentroid(nRegOffsId, GDB_ID.ROOT, ptRegOffsCen) Then
Dim nOutOffsId As Integer = GetRegionOutLoop(nRegOffsId, nGrpRegId)
bOkFind = FindVacuumCupsOnRaw(nPartId, ptRegOffsCen, b3Part, ptPartCen, nOutOffsId, nRegId, rmData)
EgtErase(nOutOffsId)
End If
EgtErase(nRegOffsId)
If bOkFind Then Return True
Next
Return False
End Function
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
' Cerco migliore configurazione di ventose per prendere il grezzo
Const MAX_SEL As Integer = 20
For nI As Integer = 1 To MAX_SEL
' Recupero la configurazione di ventose nI-esima
Dim sCups() As String = Nothing
Dim sCups2() As String = Nothing
If Not GetVacuumCupSelection(nI, sCups, sCups2) Then Return False
' Determino validità soluzioni della configurazione
Dim vtMove As New Vector3d
Dim ptRotCen As New Point3d
Dim dRotAngDeg As Double = 0
Dim vtMove2 As New Vector3d
Dim ptRotCen2 As New Point3d
Dim dRotAngDeg2 As Double = 0
' 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
End If
' Eseguo il movimento
EgtMove(m_nVacId, vtMove, GDB_RT.GLOB)
EgtRotate(m_nVacId, ptRotCen, Vector3d.Z_AX(), dRotAngDeg, GDB_RT.GLOB)
' Visualizzo le ventose
For nJ As Integer = 0 To sCups.Length() - 1
Dim nCupId = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ))
EgtSetStatus(nCupId, GDB_ST.ON_)
Next
' Calcolo delta posizione (rispetto all'origine delle ventose)
Dim frCurrRef As New Frame3d
EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef)
Dim vtDelta As Vector3d = frCurrRef.Orig() - ptRawCen
' correggo le coordinate (x,y) considerando il centro del minimo rettangolo
Dim vtOffsetCenter As Vector3d = ptRawCen - rmData.m_ptCenMinRect
Dim zDelta As Double = vtDelta.z
vtDelta = vtDelta + vtOffsetCenter
' reimposto il valore della z
vtDelta.z = zDelta
' Assegno dati noti al movimento del grezzo
rmData.m_nId = nRawId
rmData.m_vtRawMove = Vector3d.NULL()
rmData.m_vtDelta = vtDelta
rmData.m_dAngRotDeg = dRotAngDeg
Dim sVal As String = String.Empty
For Each sCup As String In sCups
If String.IsNullOrEmpty(sVal) Then
sVal &= sCup
Else
sVal &= "," & sCup
End If
Next
rmData.m_sCups = sVal
Return True
Next
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()
Dim sVal As String = String.Empty
' recupero la selezione "nInd"
If Not EgtGetInfo(m_nVacId, sSel, sVal) Then Return False
' verifico se esiste più di una configurazione: V1,V2/V5,V6
If sVal.IndexOf("/") >= 0 Then
Dim sSplit() As String = sVal.Split("/".ToCharArray)
If sSplit.Length() >= 2 Then
' slavo la prima selezione: v1,V2
sCups = sSplit(0).Split(",".ToCharArray)
' salvo la seconda selezione: V5,V6
sCups2 = sSplit(1).Split(",".ToCharArray)
ElseIf sSplit.Length() >= 1 Then
sCups = sSplit(0).Split(",".ToCharArray)
sCups2 = Nothing
Else
' nessuna definizione assciata: /
sCups = Nothing
sCups2 = Nothing
End If
Else
' definizione di una sola selezione: V7,V8
sCups = sVal.Split(",".ToCharArray)
sCups2 = Nothing
End If
Return True
End Function
Private Function GetVacRotAxisSteps(ByRef vAngRot As List(Of Double)) As Boolean
' Recupero l'asse rotante della testa ventosa
Dim nRotAxId As Integer = EgtGetParent(EgtGetHeadId(VACUUM_HEAD))
' Verifico se contiene info con STEPS
Dim sSteps As String = ""
If Not EgtGetInfo(nRotAxId, KEY_ROTVAC_STEPS, sSteps) Then Return False
' Leggo gli step previsti
Dim vStep() As String = sSteps.Split(",".ToCharArray)
For Each sStep As String In vStep
Dim dStep As Double = 0
If StringToDouble(sStep, dStep) Then
vAngRot.Add(dStep)
End If
Next
Return True
End Function
Private Function TestVacuumCupSelection(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) As Double
' Se definizione mancante, scarto soluzione
If IsNothing(sCups) Then Return INFINITO
' Ne calcolo il box
Dim b3Vac As New BBox3d
For nJ As Integer = 0 To sCups.Length() - 1
' recupero l'Id della camera (V_nJ)
Dim nCupId = EgtGetFirstNameInGroup(m_nVacId, sCups(nJ))
Dim b3Cup As New BBox3d
' se la costruzione del Box va a buon fine allora lo aggiungo all'inisieme (per generare il Box complessivo)
If EgtGetBBoxGlob(nCupId, GDB_BB.STANDARD, b3Cup) Then b3Vac.Add(b3Cup)
Next
' se non ho generato un Box esco
If b3Vac.IsEmpty() Then Return INFINITO
' Se box maggiore di quello del pezzo, scarto soluzione
If b3Vac.Radius() > b3Raw.Radius() Then Return INFINITO
' Determino il movimento per portare il set di camere sopra al pezzo
vtMove = ptRawCen - b3Vac.Center()
b3Vac.Move(vtMove)
' Determino la rotazione, allineando il lato lungo delle ventose con quello del grezzo
ptRotCen = b3Vac.Center()
'Dim frMinRect As New Frame3d
'If EgtCurveMinAreaRectangleXY(nOutlineId, GDB_ID.ROOT, frMinRect) Then
' Dim dLen, dAngVertDeg, dAngOrizzDeg As Double
' frMinRect.VersX().ToSpherical(dLen, dAngVertDeg, dAngOrizzDeg)
' dRotAngDeg = dAngOrizzDeg
' If b3Vac.DimY() > b3Vac.DimX() + EPS_SMALL Then dRotAngDeg -= 90
' Dim dAngDelta As Double = If(Math.Abs(b3Vac.DimY() - b3Vac.DimX()) < 10 * EPS_SMALL, 90, 180)
' While dRotAngDeg - m_dPreferredRot >= dAngDelta / 2
' dRotAngDeg -= dAngDelta
' End While
' While dRotAngDeg - m_dPreferredRot <= -dAngDelta / 2
' dRotAngDeg += dAngDelta
' End While
'Else
' dRotAngDeg = 0
' If (b3Vac.DimX() >= b3Vac.DimY() And b3Raw.DimX() < b3Raw.DimY()) Or
' (b3Vac.DimX() < b3Vac.DimY() And b3Raw.DimX() >= b3Raw.DimY()) Then
' dRotAngDeg = m_dPreferredRot
' 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
' Eseguo verifica delle ventose rispetto al grezzo
Dim bVacOk As Boolean = False
For i As Integer = 0 To vAngRot.Count() - 1
If TestVacuumCups(nCups, nRawRegId, vtMove, ptRotCen, dRotAngDeg + vAngRot(i)) Then
dRotAngDeg += vAngRot(i)
bVacOk = True
Exit For
End If
Next
If Not bVacOk Then Return INFINITO
' Recupero riferimento della testa ventose
Dim frCurrRef As New Frame3d
EgtFrame(m_nRefId, GDB_ID.ROOT, frCurrRef)
Dim ptRef As Point3d = frCurrRef.Orig()
' Applico movimento e rotazione al punto
ptRef.Move(vtMove)
ptRef.Rotate(ptRotCen, Vector3d.Z_AX(), dRotAngDeg)
' Ne calcolo la distanza dal centro della tavola
Dim b3Tab As New BBox3d
EgtGetTableArea(1, b3Tab)
Dim dDist As Double = Point3d.DistXY(ptRef, b3Tab.Center())
Return dDist
End Function
Private Function TestVacuumCups(nCups() As Integer, nRawRegId As Integer,
vtMove As Vector3d, ptRotCen As Point3d, dRotAngDeg As Double) As Boolean
' Eseguo verifica delle ventose rispetto al grezzo
Dim bVacOk As Boolean = True
For nJ As Integer = 0 To nCups.Length() - 1
' recupero l'id della ventosa corrente
Dim nCupId = nCups(nJ)
' Eseguo rototraslazione delle ventose per verificare se sono contenute nel grezzo
EgtMove(nCupId, vtMove, GDB_RT.GLOB)
EgtRotate(nCupId, ptRotCen, Vector3d.Z_AX(), dRotAngDeg, GDB_RT.GLOB)
' Confronto le regioni
If EgtSurfFrChunkSimpleClassify(nRawRegId, 0, nCupId, 0) <> REGC.IN2 Then bVacOk = False
' Annullo rototraslazione
EgtRotate(nCupId, ptRotCen, Vector3d.Z_AX(), -dRotAngDeg, GDB_RT.GLOB)
EgtMove(nCupId, -vtMove, GDB_RT.GLOB)
' Se verifica fallita, esco dal ciclo
If Not bVacOk Then Exit For
Next
Return bVacOk
End Function
Friend Function SaveOneMoveInfo(nId As Integer, rmData As RawMoveData) As Boolean
' Assegno le informazioni
EgtSetInfo(nId, "Id", rmData.m_nId)
EgtSetInfo(nId, "Mv", rmData.m_vtRawMove)
EgtSetInfo(nId, "Rr", rmData.m_dRawAngRotDeg)
EgtSetInfo(nId, "Dt", rmData.m_vtDelta)
EgtSetInfo(nId, "Ad", rmData.m_dAngRotDeg)
EgtSetInfo(nId, "Vc", rmData.m_sCups)
EgtSetInfo(nId, "Vt", GetVacuumType())
Return True
End Function
Friend Function RemoveOneMoveInfo(nId As Integer) As Boolean
' Rimuovo le informazioni
EgtRemoveInfo(nId, "Id")
EgtRemoveInfo(nId, "Mv")
EgtRemoveInfo(nId, "Rr")
EgtRemoveInfo(nId, "Dt")
EgtRemoveInfo(nId, "Ad")
EgtRemoveInfo(nId, "Vc")
EgtRemoveInfo(nId, "Vt")
Return True
End Function
Friend Function SaveOneMoveInfoInDisposition(nDispId As Integer, rmData As RawMoveData) As Boolean
' Se movimento e rotazione trascurabili, inutile salvare
If rmData.m_vtRawMove.IsSmall() AndAlso Math.Abs(rmData.m_dRawAngRotDeg) < EPS_ANG_SMALL Then Return True
' Creo il gruppo
Dim nRpmId As Integer = EgtCreateGroup(nDispId)
If nRpmId = GDB_ID.NULL Then Return False
EgtSetName(nRpmId, "Rpm" & rmData.m_nId.ToString())
' Assegno le informazioni
SaveOneMoveInfo(nRpmId, rmData)
Return True
End Function
Friend Function SaveMoveInfoInDisposition(nDispId As Integer, rmList As List(Of RawMoveData)) As Boolean
' Verifico DispId
If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False
' aggiungo al gruppo disposizione dei sottogruppi con i dati di movimento dei grezzi spostati
For Each rmData As RawMoveData In rmList
If Not SaveOneMoveInfoInDisposition(nDispId, rmData) Then Return False
Next
Return True
End Function
Friend Function GetMoveInfoInDisposition(nDispId As Integer, ByRef rmList As List(Of RawMoveData)) As Boolean
' Verifico DispId
If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False
' Recupero i gruppi con i dati
Dim nRpmId As Integer = EgtGetFirstNameInGroup(nDispId, "Rpm*")
While nRpmId <> GDB_ID.NULL
' Recupero le informazioni
Dim rmData As New RawMoveData
EgtGetInfo(nRpmId, "Id", rmData.m_nId)
EgtGetInfo(nRpmId, "Mv", rmData.m_vtRawMove)
EgtGetInfo(nRpmId, "Rr", rmData.m_dRawAngRotDeg)
EgtGetInfo(nRpmId, "Dt", rmData.m_vtDelta)
EgtGetInfo(nRpmId, "Ad", rmData.m_dAngRotDeg)
EgtGetInfo(nRpmId, "Vc", rmData.m_sCups)
EgtGetInfo(nRpmId, "Vt", GetVacuumType())
' se non già presenti, le inserisco nella lista
If FindRawMoveData(rmData.m_nId, rmList) = -1 Then
rmList.Add(rmData)
End If
' Cerco un altro gruppo
nRpmId = EgtGetNextName(nRpmId, "Rpm*")
End While
Return True
End Function
Friend Function FindRawMoveData(nRawId As Integer, ByRef rmList As List(Of RawMoveData)) As Integer
' Cerco in lista record con dati del grezzo indicato
Dim nInd As Integer = -1
For i As Integer = 0 To rmList.Count() - 1
If rmList(i).m_nId = nRawId Then
nInd = i
Exit For
End If
Next
Return nInd
End Function
Private Function AddRawMoveData(nRawId As Integer, ByRef rmList As List(Of RawMoveData)) As Integer
' Cerco in lista record con dati del grezzo indicato
Dim nInd As Integer = -1
For i As Integer = 0 To rmList.Count() - 1
If rmList(i).m_nId = nRawId Then
nInd = i
Exit For
End If
Next
' Se trovato
If nInd <> -1 Then
' Se con movimenti trascurabili e non alla fine, lo sposto alla fine
If rmList(nInd).m_vtRawMove.IsSmall() AndAlso Math.Abs(rmList(nInd).m_dRawAngRotDeg) < EPS_ANG_SMALL AndAlso nInd <> rmList.Count() - 1 Then
rmList.Add(rmList(nInd))
rmList.RemoveAt(nInd)
nInd = rmList.Count() - 1
End If
' Se non trovato, lo accodo
Else
rmList.Add(New RawMoveData(nRawId))
nInd = rmList.Count() - 1
End If
Return nInd
End Function
Friend Function AddRawMoveData(nRawId As Integer, vtMove As Vector3d, ByRef rmList As List(Of RawMoveData)) As Integer
' Recupero o creo record con dati del grezzo indicato
Dim nInd As Integer = AddRawMoveData(nRawId, rmList)
If nInd = -1 Then Return -1
' Aggiorno i valori
rmList(nInd).m_vtRawMove += vtMove
Return nInd
End Function
Friend Function AddRawMoveData(nRawId As Integer, dRawAngRotDeg As Double, ByRef rmList As List(Of RawMoveData)) As Integer
' Recupero o creo record con dati del grezzo indicato
Dim nInd As Integer = AddRawMoveData(nRawId, rmList)
If nInd = -1 Then Return -1
' Aggiorno i valori
rmList(nInd).m_dRawAngRotDeg += dRawAngRotDeg
Return nInd
End Function
Friend Function AddRawMoveData(rmData As RawMoveData, ByRef rmList As List(Of RawMoveData)) As Integer
' Recupero o creo record con dati del grezzo indicato
Dim nInd As Integer = AddRawMoveData(rmData.m_nId, rmList)
If nInd = -1 Then Return -1
' Aggiorno i valori (tengo conto di quanto già ruotato il pezzo)
Dim vtDeltaRot As New Vector3d(rmData.m_vtDelta)
vtDeltaRot.Rotate(Vector3d.Z_AX(), -rmList(nInd).m_dRawAngRotDeg)
rmList(nInd).m_vtDelta = vtDeltaRot
rmList(nInd).m_dAngRotDeg = rmData.m_dAngRotDeg - rmList(nInd).m_dRawAngRotDeg
rmList(nInd).m_sCups = rmData.m_sCups
Return nInd
End Function
Friend Sub RemoveRawMoveData(nRawId As Integer, ByRef rmList As List(Of RawMoveData))
' Cerco in lista record con dati del grezzo indicato
Dim nInd As Integer = -1
For i As Integer = 0 To rmList.Count() - 1
If rmList(i).m_nId = nRawId Then
nInd = i
Exit For
End If
Next
' Se trovato, lo elimino
If nInd >= 0 Then
rmList.RemoveAt(nInd)
End If
End Sub
Friend Function SaveRemoveByHandInDisposition(nDispId As Integer, bRemoveByHand As Boolean) As Boolean
' Verifico DispId
If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False
' Imposto flag
EgtSetInfo(nDispId, "Rbh", bRemoveByHand)
Return True
End Function
Friend Function GetRemoveByHandInDisposition(nDispId As Integer) As Boolean
' Verifico DispId
If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False
' Leggo flag
Dim bRemoveByHand As Boolean = False
EgtGetInfo(nDispId, "Rbh", bRemoveByHand)
Return bRemoveByHand
End Function
Friend Function SaveMovePartsOnAuxTable(nDispId As Integer, bMovePartsOnAuxTab As Boolean) As Boolean
' Verifico DispId
If EgtGetOperationType(nDispId) <> MCH_OY.DISP Then Return False
' Imposto flag
EgtSetInfo(nDispId, "Pat", bMovePartsOnAuxTab)
Return True
End Function
End Module
' in precedenza era di tipo friend ed interno al modulo sopra, portato fuori per poter salvare in ogni pezzo queste info
Public Class RawMoveData
Public m_nId As Integer
Public m_vtRawMove As Vector3d
Public m_dRawAngRotDeg As Double
Public m_vtDelta As Vector3d
Public m_dAngRotDeg As Double
Public m_sCups As String
' vettore centro-vertice on alto a sinistra MinimoRettangolo
Public m_vtRect As New Vector3d
' versore del lato più lungo nel sistema assoluto
Public m_vtDirX As New Vector3d
Public m_vtOrtoDirX As New Vector3d
' centro del rettangolo minimo
Public m_ptCenMinRect As New Point3d
Sub New()
m_nId = GDB_ID.NULL
m_vtRawMove = Vector3d.NULL()
m_dRawAngRotDeg = 0
m_vtDelta = Vector3d.NULL()
m_dAngRotDeg = 0
m_sCups = String.Empty
End Sub
Sub New(nId As Integer)
m_nId = nId
m_vtRawMove = Vector3d.NULL()
m_dRawAngRotDeg = 0
m_vtDelta = Vector3d.NULL()
m_dAngRotDeg = 0
m_sCups = String.Empty
End Sub
End Class
+32
View File
@@ -0,0 +1,32 @@
<Window x:Class="VeinMatchingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="500" Width="500" ShowInTaskbar="False" Initialized="Window_Initialized" MinWidth="300" MinHeight="300">
<Grid Name="VeinMatchingGrid" Background="{StaticResource Omag_Gray}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="91"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
<ToggleButton Name="ShowTextBtn" Height="40" Width="80"
Margin="0,5,0,0"
Content="ShowText"/>
<ToggleButton Name="EditBtn" Height="40" Width="80"
Margin="0,5,0,0"
Content="Edit"/>
<ToggleButton Name="VerifyBtn" Height="40" Width="80"
Margin="0,5,0,0"
Content="Verify"/>
<ToggleButton Name="MagneticBtn" Height="40" Width="80"
Margin="0,5,0,0"
Content="Magnetic"/>
<Button Name="ExportBtn" Height="40" Width="80"
Margin="0,5,0,0"
Content="Export"/>
</StackPanel>
</Grid>
</Window>
File diff suppressed because it is too large Load Diff
+42
View File
@@ -0,0 +1,42 @@
<UserControl x:Class="GridBoxesV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:OmagVIEWPlus="clr-namespace:OmagVIEWPlus"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary Source = "/OmagVIEWPlus;component/Utility/Dictionary.xaml"/>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<UniformGrid Grid.Row="0" Columns="2" Margin="10,0,10,0">
<ToggleButton Name="Pallet"
Content="Pallet"
IsChecked="{Binding IsPallet}"/>
<ToggleButton Name="Rack"
Content="Rack"
IsChecked="{Binding IsRack}"/>
</UniformGrid>
<ItemsControl ItemsSource="{Binding CurrBoxList}"
Grid.Row="1">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="1" Rows="{Binding nRows}"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<OmagVIEWPlus:BoxV/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>
+11
View File
@@ -0,0 +1,11 @@
Public Class GridBoxesV
Private m_refGridBoxesVM As GridBoxesVM
Sub New()
' La chiamata è richiesta dalla finestra di progettazione.
InitializeComponent()
' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent().
End Sub
End Class
+105
View File
@@ -0,0 +1,105 @@
Imports System.Collections.ObjectModel
Imports EgtUILib
Imports EgtWPFLib5
Public Class GridBoxesVM
Inherits VMBase
' riferimento al magazzino
Private m_refWarehouse As WarehouseVM
' indice della colonna del magazzino
Private m_Column As ColumnsWarehouse
Public ReadOnly Property Column As ColumnsWarehouse
Get
Return m_Column
End Get
End Property
' lista dei box presenti nella colonna corrente
Private m_BoxList As New ObservableCollection(Of Box)
Public Property BoxList As ObservableCollection(Of Box)
Get
Return m_BoxList
End Get
Set(value As ObservableCollection(Of Box))
m_BoxList = value
End Set
End Property
Private m_CurrBoxList As New ObservableCollection(Of Box)
Public ReadOnly Property CurrBoxList As ObservableCollection(Of Box)
Get
m_CurrBoxList.Clear()
For Each ItemBox In m_BoxList
If IsPallet And ItemBox.enConfigBox = ConfigBox.PALLET Then
m_CurrBoxList.Add(ItemBox)
ElseIf IsRack And ItemBox.enConfigBox = ConfigBox.RACK Then
m_CurrBoxList.Add(ItemBox)
End If
Next
Return m_CurrBoxList
End Get
End Property
'---------------------------------------------------------------------
Public ReadOnly Property nRows As Integer
Get
If m_IsPallet Then
Return 2
Else
Return 1
End If
End Get
End Property
' identifica la configurazione della colonna
Private m_IsPallet As Boolean = True
Public Property IsPallet As Boolean
Get
Return m_IsPallet
End Get
Set(value As Boolean)
m_IsPallet = value
m_IsRack = Not value
NotifyPropertyChanged("IsRack")
NotifyPropertyChanged("CurrBoxList")
NotifyPropertyChanged("nRows")
End Set
End Property
Private m_IsRack As Boolean = False
Public Property IsRack As Boolean
Get
Return m_IsRack
End Get
Set(value As Boolean)
m_IsRack = value
m_IsPallet = Not value
NotifyPropertyChanged("IsPallet")
NotifyPropertyChanged("CurrBoxList")
NotifyPropertyChanged("nRows")
End Set
End Property
#Region "CONSTUCTOR"
Sub New(enColumnWarehouse As ColumnsWarehouse, CurrWarehouseVM As WarehouseVM, enConfig As ConfigWarehose)
m_Column = enColumnWarehouse
m_refWarehouse = CurrWarehouseVM
If enConfig = ConfigWarehose.PALLET Then
IsPallet = True
Else
IsRack = True
End If
End Sub
#End Region ' CONSTRUCTOR
#Region "METHOD"
#End Region ' METHOD
End Class
+57
View File
@@ -0,0 +1,57 @@
<UserControl x:Class="WarehouseV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:OmagVIEWPlus="clr-namespace:OmagVIEWPlus"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<GroupBox BorderBrush="Black" Margin="5,0,0,5">
<GroupBox.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Id}"
Margin="10,0,5,0"/>
<TextBlock Text="{Binding FillPercentage}"
Margin="5,0,10,0"
Visibility="{Binding FillPercentage_Visibility}"/>
</StackPanel>
</GroupBox.Header>
<Grid IsEnabled="{Binding IsEnabled}" Margin="0,0,0,-5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ItemsControl ItemsSource="{Binding GridBoxList}"
Grid.Row="0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="3" Rows="1"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<OmagVIEWPlus:GridBoxesV/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<UniformGrid Grid.Row="1" Grid.Column="1"
Width="100" Height="35"
HorizontalAlignment="Center">
<Button Content="Confirm" Margin="0,-10,0,10"
VerticalContentAlignment="Center"
Command="{Binding Confirm_Command}"
Visibility="{Binding VisibilityConfirmBtn}"/>
<Button Content="Unloaded" Margin="5,0,10,0"
VerticalContentAlignment="Center"
Command="{Binding Unloaded_Command}"
Visibility="Collapsed"/>
</UniformGrid>
</Grid>
</GroupBox>
</UserControl>
+3
View File
@@ -0,0 +1,3 @@
Public Class WarehouseV
End Class
+340 -1
View File
@@ -1,7 +1,9 @@
Imports System.Threading
Imports System.Collections.ObjectModel
Imports System.Threading
Imports System.Math
Imports EgtUILib
Imports EgtWPFLib5
Imports System.Windows.Forms.Integration
Public Class MainWindowM
@@ -21,6 +23,32 @@ Public Class MainWindowM
End Get
End Property
' direttorio progetto -> conitne il progetto corrente "CurrProj.nge"
Private m_sProjDir As String = String.Empty
Public ReadOnly Property sProjDir As String
Get
Return m_sProjDir
End Get
End Property
' macchina corrente
Private m_sMachinesRoot As String = String.Empty
Public ReadOnly Property sMachinesRoot As String
Get
Return m_sMachinesRoot
End Get
End Property
Private m_sCurrMachine As String = String.Empty
' direttorio degli utensili -> attualmente non eè in uso
Private m_sToolMakersDir As String
Friend ReadOnly Property sToolMakersDir As String
Get
Return m_sToolMakersDir
End Get
End Property
Private m_nDebug As Integer = 0
Private m_objMutex As Mutex
@@ -89,6 +117,36 @@ Public Class MainWindowM
End Get
End Property
'Lista pezzi attivi
Private m_vParts As New List(Of Integer)
Public ReadOnly Property vParts As List(Of Integer)
Get
Return m_vParts
End Get
End Property
' numero progetto -> assegnato in OmgaCUT
Private m_nProjInd As Integer
Public ReadOnly Property nProjInd As Integer
Get
Return m_nProjInd
End Get
End Property
Public Sub SetProjInd(ProjInd As Integer)
m_nProjInd = ProjInd
End Sub
' Flag di ultimo progetto trasmesso
Private m_bLastProj As Boolean = False
' elenco dei progetti in elaborazione dalla macchina-> utilizzato dalla tavola 2
Private m_ProjIndList As New List(Of Proj)
Public ReadOnly Property ProjIndList As List(Of Proj)
Get
Return m_ProjIndList
End Get
End Property
#End Region ' FIELDS
#Region "CONSTRUCTOR"
@@ -115,6 +173,24 @@ Public Class MainWindowM
m_sLogDir = m_sDataRoot & "\" & LOG_DIR
' Impostazione path Ini file
IniFile.m_sIniFile = m_sConfigDir & "\" & INI_FILE_NAME
' impostazioen part WarehouseIniFile
m_WarehouseIniFile = m_sConfigDir & "\" & "Warehouse.ini"
' Impostazione direttorio per le macchine
If GetPrivateProfileString(S_MACH, K_MACHINESDIR, "", m_sMachinesRoot, m_sIniFile) = 0 Then
m_sMachinesRoot = m_sDataRoot & "\" & MACHINES_DFL_DIR
End If
' Impostazione direttorio per toolmakers
If GetMainPrivateProfileString(S_MACH, K_TOOLMAKERSDIR, "", m_sToolMakersDir) = 0 Then
m_sToolMakersDir = m_sDataRoot & "\" & TOOLMAKERS_DFL_DIR
End If
' Imposto il direttorio per il progetto corrente
If GetPrivateProfileString(S_GENERAL, K_PROJDIR, "", m_sProjDir, m_sIniFile) = 0 Then
m_sProjDir = m_sDataRoot & "\" & S_DATA
End If
' imposto macchina corrente
If GetPrivateProfileString(S_MACH, "CurrMach", "", m_sCurrMachine, m_sIniFile) = 0 Then
m_sCurrMachine = "Omag-Area5"
End If
' Verifico indice di istanza
ManageInstance()
' Imposto tipo di chiave
@@ -156,6 +232,13 @@ Public Class MainWindowM
m_nUserLevel = Math.Min(m_nKeyLevel, GetMainPrivateProfileInt(S_GENERAL, K_USERLEVEL, 1))
' Info su opzioni chiave
EgtOutLog("KeyOptions : " & bKey.ToString() & " " & m_nKeyOptions.ToString() & " " & bProd.ToString())
' Imposto dir di default per libreria Lua e lancio libreria di base
Dim sLuaLibsDir As String = String.Empty
GetPrivateProfileString(S_LUA, K_LIBSDIR, "", sLuaLibsDir, m_sIniFile)
EgtSetLuaLibs(sLuaLibsDir)
Dim sLuaBaseLib As String = String.Empty
GetPrivateProfileString(S_LUA, K_BASELIB, "EgtBase", sLuaBaseLib, m_sIniFile)
EgtLuaRequire(sLuaBaseLib)
End Sub
Private Sub ManageInstance()
@@ -221,6 +304,119 @@ Public Class MainWindowM
Return ((m_nKeyOptions And nKeyOpt) <> 0)
End Function
Public Function LoadProject() As Boolean
' Reset elenco pezzi e indice progetto
m_vParts.Clear()
m_nProjInd = 0
' Carico il file
If Not EgtOpenFile(m_sProjDir & "\" & CURR_PROJ_NAME) Then Return False
' creo una copia del progetto (direttorio Temp)
EgtSaveFile(m_sTempDir & "\" & CURR_PROJ_NAME, NGE.BIN)
If Not EgtOpenFile(m_sTempDir & "\" & CURR_PROJ_NAME) Then Return False
' Recupero l'indice di progetto
Dim nMarkId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, ConstGen.NAME_PROJMARK)
EgtGetInfo(nMarkId, ConstGen.INFO_PROJINDEX, m_nProjInd)
' imposto una nuova macchina di lavoro
Dim nMachGroupId As Integer = EgtGetFirstMachGroup()
EgtSetInfo(nMachGroupId, "Machine", m_sCurrMachine)
' salvo le modifiche nel nuov file
EgtSaveFile(m_sTempDir & "\" & CURR_PROJ_NAME, NGE.BIN)
'----------------------------------------------------------
'SOLO PER SIMULAZIONE INTERNA
'm_nProjInd = ProjIndList.Count + 1
'----------------------------------------------------------
' aggliungo il progetto alla lista dei progetti caricati dalla tavola1
m_ProjIndList.Add(New Proj(m_nProjInd))
' Nascondo eventuali info su aree
EgtSetStatus(nMarkId, GDB_ST.OFF)
' Rendo corrente il primo (e unico gruppo di lavoro)
If Not EgtSetCurrMachGroup(nMachGroupId) Then Return False
' Visualizzo solo la tavola della macchina
EgtShowOnlyTable(True)
' Attivo ultima fase di lavorazione
EgtSetCurrPhase(EgtGetPhaseCount())
' Nascondo lavorazioni
HideAllMachinings()
' Recupero elenco dei pezzi attivi nella fase
MakePartList()
' Nascondo parti ausiliarie per nesting
Dim nRawId = EgtGetFirstRawPart()
Dim nSoId = EgtGetFirstNameInGroup(nRawId, ConstGen.NAME_OUTKERF_REG)
EgtSetStatus(nSoId, GDB_ST.OFF)
Dim nRrId = EgtGetFirstNameInGroup(nRawId, ConstGen.NAME_REF_REG)
EgtSetStatus(nRrId, GDB_ST.OFF)
' Nascondo preview lavorazioni nei pezzi
For Each nPartId As Integer In m_vParts
Dim nPV = EgtGetFirstNameInGroup(nPartId, ConstGen.NAME_PREVIEW)
If nPV <> GDB_ID.NULL Then
EgtSetStatus(nPV, GDB_ST.OFF)
End If
Next
' Assegno colore blu ai pezzi non classificati
Dim nInd As Integer = 0
While nInd < m_vParts.Count()
Dim nPartId As Integer = m_vParts(nInd)
' Se pezzo già classificato, passo al successivo
Dim nOk As Integer = -1
If EgtGetInfo(nPartId, INFO_PARTOK, nOk) Then
nInd += 1
Continue While
End If
' Cerco layer regione
Dim nRegId = EgtGetFirstNameInGroup(nPartId, ConstGen.NAME_REGION)
If nRegId = GDB_ID.NULL Then
m_vParts.RemoveAt(nInd)
Continue While
End If
' Cerco prima regione nel layer
Dim nId = EgtGetFirstInGroup(nRegId)
While nId <> GDB_ID.NULL
If EgtGetType(nId) = GDB_TY.SRF_FRGN Then
EgtSetColor(nId, New Color3d(0, 255, 255, 80)) ' Aqua
Exit While
End If
nId = EgtGetNext(nId)
End While
nInd += 1
End While
' Imposto lo zoom
EgtZoom(ZM.ALL)
OutLogProcess("LoadProject() -> Caricato il progetto '" & m_sProjDir & "\" & CURR_PROJ_NAME)
Return True
End Function
Private Function HideAllMachinings() As Boolean
Dim nId As Integer = EgtGetFirstOperation()
While nId <> GDB_ID.NULL
If EgtGetOperationType(nId) <> MCH_OY.DISP Then
EgtSetOperationStatus(nId, False)
End If
nId = EgtGetNextOperation(nId)
End While
Return True
End Function
Private Function MakePartList() As Boolean
' Ciclo su tutti i grezzi dell'ultima fase
Dim nLastPhase = EgtGetPhaseCount()
Dim nRawId As Integer = EgtGetFirstRawPart()
While nRawId <> GDB_ID.NULL
If EgtVerifyRawPartPhase(nRawId, nLastPhase) Then
' Ciclo su tutti i pezzi del grezzo
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId)
While nPartId <> GDB_ID.NULL
m_vParts.Add(nPartId)
nPartId = EgtGetNextPartInRawPart(nPartId)
End While
End If
nRawId = EgtGetNextRawPart(nRawId)
End While
Return True
End Function
Friend Sub Close()
' Terminazione generale di EgtInterface
EgtExit()
@@ -232,6 +428,149 @@ Public Class MainWindowM
WriteMainPrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString())
End Sub
Public Function SavePartStatus() As Boolean
' Gestione file
Try
' Recupero materiale
Dim sMaterial As String = String.Empty
EgtGetInfo(EgtGetFirstNameInGroup(GDB_ID.ROOT, ConstGen.NAME_PROJMARK), ConstGen.INFO_PROJMAT, sMaterial)
' Recupero spessore
Dim nSolidRawId As Integer = EgtGetFirstNameInGroup(EgtGetFirstRawPart(), ConstGen.NAME_RAW_SOLID)
Dim b3RawBox As New BBox3d
EgtGetBBoxGlob(nSolidRawId, GDB_BB.STANDARD, b3RawBox)
Dim dThick As Double = If(b3RawBox.IsEmpty(), 0, b3RawBox.DimZ())
' Recupero path originale di carico
Dim sCutPath As String = String.Empty
EgtGetInfo(EgtGetFirstNameInGroup(GDB_ID.ROOT, ConstGen.NAME_PROJMARK), ConstGen.INFO_LOADPATH, sCutPath)
' Apro i file
Dim RuinedWrt As New IO.StreamWriter(m_sProjDir & "\" & CURR_PROJ_EPL, False)
Dim ProdWrt As New IO.StreamWriter(m_sProjDir & "\" & CURR_PROJ_PPL, False)
' Intestazioni epl
RuinedWrt.WriteLine("[General]")
If String.IsNullOrEmpty(sCutPath) Then
RuinedWrt.WriteLine("Path=*RuinedParts*")
Else
RuinedWrt.WriteLine("Path=" & sCutPath)
End If
' intestazione ppl
ProdWrt.WriteLine("[General]")
If String.IsNullOrEmpty(sCutPath) Then
ProdWrt.WriteLine("Path=*ProducedParts*")
Else
ProdWrt.WriteLine("Path=" & sCutPath)
End If
' Ciclo sui pezzi
Dim nI As Integer = 0
Dim nJ As Integer = 0
' lista dei pezzi rovinati che si trovano sul tavolo
Dim RuinedPart As ObservableCollection(Of Part) = Map.refUnloadingAreaVM.GetParts(Place.ON_TABLE, StatusPart.WASTE)
' lista di tutti i pezzi buoni del progetto
Dim UnloadedPart As New ObservableCollection(Of Part)
' lista di tutti i pezzi buoni sulla rulliera
For Each ItemPart In Map.refUnloadingAreaVM.GetParts(Place.ON_MOTOR_RULLER)
UnloadedPart.Add(ItemPart)
Next
' tutti i pezzi non prelevabili ancora presenti sulla rulliera (dovrebbe essere sempre vuota)
For Each ItemPart In Map.refUnloadingAreaVM.GetParts(Place.ON_MOTOR_RULLER, StatusPart.NOT_LOADED)
UnloadedPart.Add(ItemPart)
Next
' tutti i pezzi non prelevabili tolti dalla rulliera
For Each ItemPart In Map.refUnloadingAreaVM.GetParts(Place.ON_WASTE_BOX, StatusPart.NOT_LOADED)
UnloadedPart.Add(ItemPart)
Next
' tutti i pezzi defpositati nei Box
For Each ItemPart In Map.refUnloadingAreaVM.GetParts(Place.ON_BOX)
UnloadedPart.Add(ItemPart)
Next
' tutti i pezzi prelavati a mano
For Each ItemPart In Map.refUnloadingAreaVM.GetParts(Place.ON_MANUAL_BOX)
UnloadedPart.Add(ItemPart)
Next
For Each ItemPart As Part In RuinedPart
nI = nI + 1
RuinedWrt.WriteLine("[P" & nI.ToString() & "]")
Dim sName As String = String.Empty
EgtGetInfo(ItemPart.IdPart, ConstGen.INFO_CSV_PART, sName)
RuinedWrt.WriteLine("Nam=" & sName)
RuinedWrt.WriteLine("Mat=" & sMaterial)
RuinedWrt.WriteLine("Act=1")
RuinedWrt.WriteLine("Cnt=0")
RuinedWrt.WriteLine("Add=1")
RuinedWrt.WriteLine("ToN=1")
Dim sCompo As String = String.Empty
EgtGetInfo(ItemPart.IdPart, "CMP", sCompo)
RuinedWrt.WriteLine("Rct=" & If(sCompo = "Rettangolo", "1", "0"))
Dim dDimX As Double = 0
EgtGetInfo(ItemPart.IdPart, "V1", dDimX)
RuinedWrt.WriteLine("DX=" & DoubleToString(dDimX, 4))
Dim dDimY As Double = 0
EgtGetInfo(ItemPart.IdPart, "V2", dDimY)
RuinedWrt.WriteLine("DY=" & DoubleToString(dDimY, 4))
RuinedWrt.WriteLine("Th=" & DoubleToString(dThick, 4))
RuinedWrt.WriteLine("OIn=" & nI.ToString())
Next
For Each ItemPart As Part In UnloadedPart
nJ += 1
ProdWrt.WriteLine("[P" & nJ.ToString() & "]")
Dim sName As String = String.Empty
EgtGetInfo(ItemPart.IdPart, ConstGen.INFO_CSV_PART, sName)
ProdWrt.WriteLine("Nam=" & sName)
ProdWrt.WriteLine("Mat=" & sMaterial)
ProdWrt.WriteLine("Act=1")
ProdWrt.WriteLine("Cnt=1")
ProdWrt.WriteLine("Add=0")
ProdWrt.WriteLine("ToN=0")
Dim sCompo As String = String.Empty
EgtGetInfo(ItemPart.IdPart, "CMP", sCompo)
ProdWrt.WriteLine("Rct=" & If(sCompo = "Rettangolo", "1", "0"))
Dim dDimX As Double = 0
EgtGetInfo(ItemPart.IdPart, "V1", dDimX)
ProdWrt.WriteLine("DX=" & DoubleToString(dDimX, 4))
Dim dDimY As Double = 0
EgtGetInfo(ItemPart.IdPart, "V2", dDimY)
ProdWrt.WriteLine("DY=" & DoubleToString(dDimY, 4))
ProdWrt.WriteLine("Th=" & DoubleToString(dThick, 4))
ProdWrt.WriteLine("OIn=" & nJ.ToString())
Next
' Terminatori
RuinedWrt.WriteLine("[END]")
ProdWrt.WriteLine("[END]")
' Chiudo i file
RuinedWrt.Close()
ProdWrt.Close()
Return True
' Errore
Catch ex As Exception
EgtOutLog("Error writing epl file")
Return False
End Try
End Function
#End Region ' METHODS
End Class
Public Class Proj
Private m_nProjInd As Integer = 0
Public ReadOnly Property nProjInd As Integer
Get
Return m_nProjInd
End Get
End Property
Private m_enStatus As StatusProj = StatusProj.WAITING
Public Property enStatus As StatusProj
Get
Return m_enStatus
End Get
Set(value As StatusProj)
m_enStatus = value
End Set
End Property
Sub New(nProjInd As Integer)
m_nProjInd = nProjInd
End Sub
End Class
+21 -7
View File
@@ -13,14 +13,28 @@
CloseCommand="{Binding CloseApplicationCommand,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">-->
<!--Pannello principale -->
<DockPanel LastChildFill="True">
<!--StatusBar --><!--
<DockPanel LastChildFill="True" Background="Gray">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<!--<ToggleButton Content="Scene!" Grid.Row="0"
IsChecked="{Binding SceneIsChecked}"/>
<ToggleButton Content="Storage!" Grid.Row="1"
IsChecked="{Binding UnloadingAreaIsChecked}"/>-->
</Grid>
<!--StatusBar
<OmagOFFICE:StatusBarV DataContext="{StaticResource StatusBarVM}"
DockPanel.Dock="Bottom"/>-->
<!--Magazzino -->
<OmagVIEWPlus:UnloadingAreaV DataContext="{StaticResource UnloadingAreaVM}"/>
<!--Magazzino-->
<!--<OmagVIEWPlus:UnloadingAreaV DataContext="{StaticResource UnloadingAreaVM}"/>-->
<!--<OmagVIEWPlus:SceneHostV/>-->
<ContentControl Grid.Column="0" Grid.Row="1" Content="{Binding PageControl}"/>
</DockPanel>
<!--Scena restituita sotto forma di WindowsFormsHost-->
<!--<OmagVIEWPlus:SceneHostV/>-->
</DockPanel>
</EgtWPFLib5:EgtCustomWindow>
+100 -1
View File
@@ -5,6 +5,61 @@ Imports System.IO
Public Class MainWindowVM
Inherits VMBase
Private m_SceneHostV As SceneHostV
Private m_UnloadingAreaV As UnloadingAreaV
Private m_MySceneHostVM As MySceneHostVM
Private m_UnloadingAreaVM As UnloadingAreaVM
Private m_WaitingConfirmManualPart As Boolean = False
Public ReadOnly Property WaitingConfirmManualPart As Boolean
Get
Return m_WaitingConfirmManualPart
End Get
End Property
Private m_SceneIsChecked As Boolean = False
Public Property SceneIsChecked As Boolean
Get
Return m_SceneIsChecked
End Get
Set(value As Boolean)
m_SceneIsChecked = value
m_UnloadingAreaIsChecked = Not value
Map.refSceneHostVM.NotifyPropertyChanged("IsLayoutCheched")
Map.refSceneHostVM.NotifyPropertyChanged("VisibilityManulaPartCommand")
EgtZoom(ZM.ALL)
NotifyPropertyChanged("PageControl")
End Set
End Property
Private m_UnloadingAreaIsChecked As Boolean = True
Public Property UnloadingAreaIsChecked As Boolean
Get
Return m_UnloadingAreaIsChecked
End Get
Set(value As Boolean)
m_UnloadingAreaIsChecked = value
m_SceneIsChecked = Not value
Map.refUnloadingAreaVM.NotifyPropertyChanged("refScenaIsChecked")
NotifyPropertyChanged("PageControl")
End Set
End Property
Public ReadOnly Property PageControl As ContentControl
Get
If m_SceneIsChecked Then
NotifyPropertyChanged("SceneIsChecked")
NotifyPropertyChanged("UnloadingAreaIsChecked")
Return m_SceneHostV
Else
NotifyPropertyChanged("SceneIsChecked")
NotifyPropertyChanged("UnloadingAreaIsChecked")
Return m_UnloadingAreaV
End If
End Get
End Property
' Riferimento al Model della MainWindow
Private m_MainWindowM As MainWindowM
Friend ReadOnly Property MainWindowM As MainWindowM
@@ -36,9 +91,21 @@ Public Class MainWindowVM
End Set
End Property
Private m_ContentControl As UserControl
Public Property ContentControl As UserControl
Get
Return m_ContentControl
End Get
Set(value As UserControl)
m_ContentControl = value
End Set
End Property
' definizione comandi
Private m_cmdAboutBox As ICommand
Private m_cmdCloseApplication As ICommand
Private m_cmdOpenScene As ICommand
Private m_cmdOpenUnloadingArea As ICommand
#Region "CONSTRUCTOR"
@@ -47,6 +114,14 @@ Public Class MainWindowVM
Map.BeginInit(Me)
' Creo Model della MainWindow
m_MainWindowM = New MainWindowM
' Genero il contenuto della scena
m_MySceneHostVM = New MySceneHostVM()
' Genero la scena
m_SceneHostV = New SceneHostV
' Genero il contenuto dell'UnloadingArea
m_UnloadingAreaVM = New UnloadingAreaVM
' Genero UnloadingArea
m_UnloadingAreaV = New UnloadingAreaV
End Sub
#End Region ' CONSTRUCTOR
@@ -68,9 +143,33 @@ Public Class MainWindowVM
End If
' Creazione gestore comunicazione con PLC
m_CNCommunication = New NCCommunication
SetTitle("OmagVIEWPlus")
'SetTitle("OmagVIEWPlus")
End Sub
Friend Function StartUnloadingProject() As Boolean
' prima di iniziare verifico la presenza del file .new
' carico progetto corrente solo se il file non è stato confermato
If Not m_WaitingConfirmManualPart Then
m_WaitingConfirmManualPart = MainWindowM.LoadProject()
SetTitle("CurrProj " & m_MainWindowM.nProjInd.ToString & " - OmagVIEWPlus")
End If
' se non sono riuscito a caricare esco
If Not m_WaitingConfirmManualPart Then Return False
' rendo visibile la freccia rossa
Map.refUnloadingAreaVM.Table1ArrowVisibility = Visibility.Visible
' eventualmente rendo visibilie il bottone per la conferma selezione manuale
Map.refSceneHostVM.NotifyPropertyChanged("VisibilityManulaPartCommand")
' se non ho dato conferma del pezzo allora aspetto (bottone acceso)
If Map.refUnloadingAreaVM.IsChecked_Manual Then Return False
' significa che la selezione è avvenuta
m_WaitingConfirmManualPart = False
' nascondo la freccia rossa
Map.refUnloadingAreaVM.Table1ArrowVisibility = Visibility.Collapsed
' passo al posizionamento delle ventose
Return MyUpdateVacuumsForUnloading()
End Function
#End Region ' METHODS
#Region "COMMANDS"
+500
View File
@@ -0,0 +1,500 @@
Imports EgtUILib
Imports EgtWPFLib5
Imports System.IO
Public Class Part
Inherits VMBase
#Region "PROPERTIES"
' posizione tavola rispetto ad origine macchina
Private m_ptTable1 As New Point3d
Public ReadOnly Property ptTable1 As Point3d
Get
Return m_ptTable1
End Get
End Property
' Dimensioni minime del rettangolo che circonda il pezzo
Private m_MinRectY As Double
Public Property MinRectY As Double
Get
Return m_MinRectY
End Get
Set(value As Double)
m_MinRectY = value
End Set
End Property
Private m_MinRectX As Double
Public Property MinRectX As Double
Get
Return m_MinRectX
End Get
Set(value As Double)
m_MinRectX = value
End Set
End Property
' numerazione del progetto
Private m_IdProject As Integer
Public ReadOnly Property IdProject As Integer
Get
Return m_IdProject
End Get
End Property
' Id gruppo: identificativo del pezzo
Private m_IdPart As Integer
Public ReadOnly Property IdPart As Integer
Get
Return m_IdPart
End Get
End Property
' Id del box che accohlierà il pezzo
Private m_IdBox As Integer = -1
Public Property IdBox As Integer
Get
Return m_IdBox
End Get
Set(value As Integer)
m_IdBox = value
PartWritePrivateProfileString(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "IdBox", m_IdBox.ToString)
End Set
End Property
' Id Warehouse dei box
Private m_enWarehouse As Warehouses = 0
Public Property enWarehouse As Warehouses
Get
Return m_enWarehouse
End Get
Set(value As Warehouses)
m_enWarehouse = value
PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "IdWarehouse", CInt(m_enWarehouse))
End Set
End Property
Private m_IsLast As Boolean
Public ReadOnly Property IsLast As Boolean
Get
Return m_IsLast
End Get
End Property
' coordinate del pezzo ripsetto alla tavola
Private m_CenterPartTable As New Point3d
Public ReadOnly Property CeneterPartTable As Point3d
Get
Return m_CenterPartTable
End Get
End Property
' posizione angolare del pezzo
Private m_DegAngOnTable As Double = 0
Public ReadOnly Property DegAngOnTable As Double
Get
Return m_MoveTable1.m_dAngRotDeg
End Get
End Property
' altezza del pezzo
Private m_Height As Double
Public ReadOnly Property Height As Double
Get
Return m_Height
End Get
End Property
Public Sub SetHeight(dHeight As Double)
m_Height = dHeight
End Sub
' salvo localmente le informazioni relative all'pezzo sulla tavola 1
Private m_MoveTable1 As New RawMoveData
Public ReadOnly Property MoveTable1 As RawMoveData
Get
Return m_MoveTable1
End Get
End Property
' salvo localmente le informazioni relative all'pezzo sulla tavola 2
Private m_MoveTable2 As New RawMoveData
Public ReadOnly Property MoveTable2 As RawMoveData
Get
Return m_MoveTable2
End Get
End Property
#End Region ' PROPERIES
#Region "STATES"
' inidica la posizione attuale del pezzo-> di default ON_TABLE
Private m_enPlace As Place
Public Property enPlace As Place
Get
Return m_enPlace
End Get
Set(value As Place)
m_enPlace = value
PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, ConstIni.K_PLACE, CInt(m_enPlace))
End Set
End Property
' indica lo stato attuale del pezzo-> di default GOOD
Private m_enStatus As StatusPart
Public Property enStatus As StatusPart
Get
Return m_enStatus
End Get
Set(value As StatusPart)
m_enStatus = value
PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, ConstIni.K_STATUS, CInt(m_enStatus))
End Set
End Property
' indica il tipo di scarico previsto per il pezzo
Private m_enUnloading As Unloading
Public Property enUnloading As Unloading
Get
Return m_enUnloading
End Get
Set(value As Unloading)
m_enUnloading = value
PartWritePrivateProfileInt(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, ConstIni.K_UNLOADING, CInt(m_enUnloading))
End Set
End Property
#End Region ' STATES
#Region "CONSTUCTOR"
Sub New(nIdPart As Integer, nProjId As Integer)
SetIdPart(nIdPart)
SetIdProject(nProjId)
' -> MyUpdateVacuumsForUnloading: tavolo
m_enPlace = Place.ON_TABLE
m_enStatus = StatusPart.GOOD
m_enUnloading = Unloading.AUTOMATIC
m_IsLast = False
End Sub
#End Region 'CONSTUCTOR
#Region "METHODS"
' verifico che l'id del progetto sia un intero
Public Sub SetIdProject(nIdProject As Integer)
If IsNumeric(nIdProject) Then
m_IdProject = nIdProject
End If
End Sub
' verifico che l'id del pezzo sia un un numero
Public Sub SetIdPart(nIdPart As Integer)
If IsNumeric(nIdPart) Then
m_IdPart = nIdPart
End If
End Sub
' verifico che l'Id del box sia un numero
Public Sub SetIdBox(nIdBox As Integer)
If IsNumeric(nIdBox) Then
m_IdBox = nIdBox
End If
End Sub
Public Sub SetWareHouse(IdWarehouse As Integer)
If IsNumeric(IdWarehouse) Then
m_enWarehouse = CType(IdWarehouse, Warehouses)
End If
End Sub
Public Sub SetIsLast(bIsLast As Boolean)
m_IsLast = bIsLast
End Sub
' cordinate del centro del pezzo rispetto alla tavola
Public Sub SetCenterPartTable(ptCenter As Point3d)
' salvo le coordinate di riferimento della tavola
m_CenterPartTable = GetPointInTableRef(ptCenter, m_ptTable1)
End Sub
' coordinate del centro del rettangolo rispetto alla tavola
Public Function GetPointOnTable1(ptCenter As Point3d) As Point3d
Dim ptResult As New Point3d()
ptResult.x = ptCenter.x - m_ptTable1.x
ptResult.y = ptCenter.y - m_ptTable1.y
ptResult.z = ptCenter.z - m_ptTable1.z
Return ptResult
End Function
' salvo le info del pezzo sulla tavola 1
Public Sub SetInfoTable1(RawData As RawMoveData, dDimz As Double)
m_MoveTable1 = RawData
SetHeight(dDimz)
End Sub
' salvo le info del pezzo sulla tavola 2
Public Sub SetInfoTable2(RawData As RawMoveData)
m_MoveTable2 = RawData
End Sub
' restituisce la poszione della testa
Public Function GetUnloadingPosTable1() As Point3d
Dim ptResult As Point3d
ptResult.x = GetPointOnTable1(m_MoveTable1.m_ptCenMinRect).x + m_MoveTable1.m_vtDelta.x
ptResult.y = GetPointOnTable1(m_MoveTable1.m_ptCenMinRect).y + m_MoveTable1.m_vtDelta.y
ptResult.z = m_Height
Return ptResult
End Function
' 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)
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
ptUnLoad.x = -1534 / 2
Else
ptUnLoad.x = vtResult.x
End If
' se la distanza y è minore della lunghezza della ventosa allo ra correggo
If vtResult.y + 350 / 2 > 0 Then
ptUnLoad.y = -350 / 2
Else
ptUnLoad.y = vtResult.y
End If
ptUnLoad.z = m_Height
Return ptUnLoad
End Function
' restuisce la poszione di prelievo dalla rulliera
Public Function GetLoadingPosRuller() As Point3d
Dim ptLoad As New Point3d
' assegno come punto di riferimento l'angolo in alto a sinistra del pezzo
Dim vtRectTopLeft As New Vector3d(-m_MoveTable2.m_vtRect.x, m_MoveTable2.m_vtRect.y, 0)
Dim vtResult As Vector3d = m_MoveTable2.m_vtDelta - vtRectTopLeft
ptLoad.x = vtResult.x
ptLoad.y = vtResult.y
ptLoad.z = m_Height
Return ptLoad
End Function
' 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
Dim vtResult As Vector3d = m_MoveTable2.m_vtDelta + vtCurrOffset
ptUnload.x = vtResult.x
ptUnload.y = vtResult.y
ptUnload.z = vtCurrOffset.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
If m_MoveTable1.m_sCups.Contains(sVacuum) Then
Return 1
End If
Else
If m_MoveTable2.m_sCups.Contains(sVacuum) Then
Return 1
End If
End If
Return 0
End Function
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)
' 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)
' info Table 1
For nIndex = 1 To 2
Dim objRawMoveData As New RawMoveData
If nIndex = 1 Then
objRawMoveData = m_MoveTable1
Else
objRawMoveData = m_MoveTable2
End If
' RawMove
PartWritePrivateProfileVector(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "RawMove" & nIndex.ToString, objRawMoveData.m_vtRawMove)
' Delta
PartWritePrivateProfileVector(m_IdProject, ConstIni.S_PART & m_IdPart.ToString, "Delta" & nIndex.ToString, objRawMoveData.m_vtDelta)
' 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)
Next
Return True
End Function
Shared Function GetListOfPart() As Boolean
' recupero l'elenco dei file da caricare dal file Warehouese.ini
Dim sVal As String = String.Empty
WarehauseGetPrivateProfileString("Warehouse", "IdProj", "", sVal)
If String.IsNullOrEmpty(sVal) Then
Return False
End If
' separo l'elenco di progetti
Dim sItemIdProj As String() = sVal.Split(","c)
For Each ItemId In sItemIdProj
' costruisco il nome del file
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & ItemId.Trim & ".ini"
' verifico che esista il file
If Not My.Computer.FileSystem.FileExists(sFile) Then
Continue For
End If
' converto l'Id del progetto in un intero
Dim nIdProj As Integer
If Not IsNumeric(ItemId) Then
Continue For
End If
nIdProj = CInt(ItemId)
Dim objProj As New Proj(nIdProj)
objProj.enStatus = StatusProj.LOADING
If Map.refMainWindowVM.MainWindowM.nProjInd < 1 Then
Map.refMainWindowVM.MainWindowM.SetProjInd(nIdProj)
Map.refUnloadingAreaVM.IdProjTable2 = objProj
End If
Map.refMainWindowVM.MainWindowM.ProjIndList.Add(objProj)
' recupero l'elenco dei pezzi contenuti nel progetto
Dim sParts As String = String.Empty
Dim sValue As String = String.Empty
Dim nInd As Integer = 1
While PartGetPrivateProfileString(nIdProj, "PartList", "IdPart" & nInd.ToString, "0", sValue) > 1
If nInd = 1 Then
sParts = sValue
Else
sParts = sParts & "," & sValue
End If
nInd = nInd + 1
End While
Dim sItemIdPart As String() = sParts.Split(","c)
Dim bIsWorking As Boolean = False
' leggo le info per ogni part del progetto
For Each ItemPart In sItemIdPart
' converto l'Id del Part in un intero
Dim nIdPart As Integer
If Not IsNumeric(ItemPart) Then
Continue For
End If
nIdPart = CInt(ItemPart)
Dim sIpAppName As String = "Part" & Trim(ItemPart)
' inizio la lettura dei dati della piastrella
Dim LocalPart As New Part(nIdPart, nIdProj)
' stato della piastrella
Dim nValue As Integer = 0
LocalPart.enStatus = CType(PartGetPrivateProfileIntger(nIdProj, ConstIni.S_PART & nIdPart.ToString, ConstIni.K_STATUS, nValue), StatusPart)
LocalPart.enPlace = CType(PartGetPrivateProfileIntger(nIdProj, ConstIni.S_PART & nIdPart.ToString, ConstIni.K_PLACE, nValue), Place)
LocalPart.enUnloading = CType(PartGetPrivateProfileIntger(nIdProj, ConstIni.S_PART & nIdPart.ToString, ConstIni.K_UNLOADING, nValue), Unloading)
' posizione della tavola
PartGetPrivateProfilePoint(nIdProj, ConstIni.S_PART & nIdPart.ToString, "Table1ref", LocalPart.m_ptTable1)
' posizione del pezzo sulla tavola
PartGetPrivateProfilePoint(nIdProj, ConstIni.S_PART & nIdPart.ToString, "CenterPartTable1", LocalPart.m_CenterPartTable)
' IdWarehouse
Dim nIdWarehouse As Integer = 0
LocalPart.SetWareHouse(PartGetPrivateProfileIntger(nIdProj, ConstIni.S_PART & nIdPart.ToString, "IdWarehouse", nIdWarehouse))
' IdBox
Dim nIdBox As Integer = -1
LocalPart.SetIdBox(PartGetPrivateProfileIntger(nIdProj, ConstIni.S_PART & nIdPart.ToString, "IdBox", nIdBox))
' altezza della piastrella
Dim dHeight As Double = 0
LocalPart.SetHeight(PartGetPrivateProfileDouble(nIdProj, ConstIni.S_PART & nIdPart.ToString, "Height", dHeight))
' IsLast
Dim bIsLats As Boolean = sItemIdPart(nInd - 2) = ItemPart
LocalPart.SetIsLast(bIsLats)
' info Table 1
For nIndex As Integer = 1 To 2
Dim objRawMoveData As New RawMoveData
If nIndex = 1 Then
objRawMoveData = LocalPart.m_MoveTable1
Else
objRawMoveData = LocalPart.m_MoveTable2
End If
' RawMove
PartGetPrivateProfileVector(nIdProj, ConstIni.S_PART & nIdPart.ToString, "RawMove" & nIndex.ToString, objRawMoveData.m_vtRawMove)
' Delta
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)
' DirX
PartGetPrivateProfileVector(nIdProj, ConstIni.S_PART & nIdPart.ToString, "DirX" & nIndex.ToString, objRawMoveData.m_vtDirX)
' OrtoDirX
PartGetPrivateProfileVector(nIdProj, ConstIni.S_PART & nIdPart.ToString, "OrtoDirX" & nIndex.ToString, objRawMoveData.m_vtOrtoDirX)
' 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)
' RotAngDeg
PartWritePrivateProfileDouble(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)
Next
Map.refUnloadingAreaVM.ListPart.Add(LocalPart)
' terminata la costruzione della lista dei pezzi, genero la lista per i box del progetto corrente
For Each ItemWarehouse In Map.refUnloadingAreaVM.WarehouseList
' ricavo il magazzino corrente
If ItemWarehouse.Id = CType(nIdWarehouse, Warehouses) Then
For Each ItemBox In ItemWarehouse.Boxes
If ItemBox.Id = LocalPart.IdBox Then
ItemBox.MyListPart.Add(LocalPart)
End If
Next
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
bIsWorking = True
End If
Next
If bIsWorking Then
objProj.enStatus = StatusProj.WORKING
Else
objProj.enStatus = StatusProj.LOADING
End If
Next
' se esiste attivo il magazzino del primo progetto caricato
If Map.refUnloadingAreaVM.ListPart.Count > 0 Then
Dim CurrWarehouse As WarehouseVM = Map.refUnloadingAreaVM.GetWarehouse(Map.refUnloadingAreaVM.ListPart(0).enWarehouse)
If Not IsNothing(CurrWarehouse) Then Map.refUnloadingAreaVM.SetActiveWarehouse(CurrWarehouse.Id)
'CurrWarehouse.SetState(States.AVAILABLE)
'CurrWarehouse.NotifyPropertyChanged("IsEnabled")
End If
OutLogProcess("GetListOfPart() -> Recuperato i progetti: PartList" & sVal & ".ini")
Return True
End Function
#End Region ' METHODS
End Class
+3 -3
View File
@@ -57,7 +57,7 @@ Imports System.Windows
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("94b31015-df05-4395-a323-6e03d97e183b")>
<Assembly: Guid("94b31015-df05-4395-a323-6e03d97e183b")>
' Version information for an assembly consists of the following four values:
'
@@ -70,5 +70,5 @@ Imports System.Windows
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("2.1.2.1")>
<Assembly: AssemblyFileVersion("2.1.2.1")>
<Assembly: AssemblyVersion("2.2.10.1")>
<Assembly: AssemblyFileVersion("2.2.10.1")>
+567
View File
@@ -0,0 +1,567 @@
Imports System.Windows.Interop
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Imports System.Text.RegularExpressions
Public Class MySceneHostVM
Inherits EgtWPFLib5.SceneHostVM
Public Property IsLayoutCheched As Boolean
Get
Return Map.refMainWindowVM.UnloadingAreaIsChecked
End Get
Set(value As Boolean)
Map.refMainWindowVM.UnloadingAreaIsChecked = value
End Set
End Property
Public ReadOnly Property VisibilityManulaPartCommand As Visibility
Get
' verifico che la lastra sia prenotata
If Not Map.refUnloadingAreaVM.IsChecked_Manual Then Return Visibility.Collapsed
' verifico se il progetto corrente è già stato scaricato sulla rulliera
Dim CurrProj As Proj = Nothing
For Each ItemProj In Map.refMainWindowVM.MainWindowM.ProjIndList
If ItemProj.nProjInd = Map.refMainWindowVM.MainWindowM.nProjInd Then
CurrProj = ItemProj
End If
Next
If IsNothing(CurrProj) Then Return Visibility.Collapsed
If CurrProj.enStatus <> StatusProj.WAITING Then Return Visibility.Collapsed
Return Visibility.Visible
End Get
End Property
Private m_cmdConfirmManaulPart As ICommand
#Region "CONSTRUCTOR"
Sub New()
MyBase.New()
AddHandler MainController.OnNewProject, AddressOf OnNewProject
AddHandler MainController.OnOpenProject, AddressOf OnOpenProject
'AddHandler MainController.OnSavingProject, AddressOf OnSavingProject
'AddHandler MainController.OnSavedProject, AddressOf OnSavedProject
Map.SetRefSceneHostVM(Me)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Overrides Sub InitScene()
InitSceneEvents()
' Inizializzazione Scena
PreInitializeScene()
' Se tutto bene -> And Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.OFFICE_BASE)
If MainScene.Init() Then
PostInitializeScene()
' Imposto stato gestione mouse diretto della scena a nessuno
'MainScene.SetStatusNull()
' Recupero e imposto handle finestra principale
Dim hMainWnd As IntPtr = New WindowInteropHelper(Application.Current.MainWindow).Handle
EgtSetMainWindowHandle(hMainWnd)
' inizializzo gestore lavorazioni
EgtInitMachMgr(Map.refMainWindowVM.MainWindowM.sMachinesRoot, Map.refMainWindowVM.MainWindowM.sToolMakersDir)
Return
End If
' Problemi : MainWindowM->InitializeEgtEnvironment()
' Se manca la chiave
'If OmagOFFICEMap.refMainWindowVM.MainWindowM.nKeyLevel = -1 Or OmagOFFICEMap.refMainWindowVM.MainWindowM.nKeyLevel = -2 Then
' EgtOutLog("Missing Dongle")
' ' Box di avviso chiave mancante : "Chiave non presente. \n Inserirla e riavviare il programma." "Errore"
' Dim sText As String = EgtMsg(MSG_MISSINGKEYWD + 2) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 3)
' Dim sTitle As String = EgtMsg(MSG_MISSINGKEYWD + 1)
' MessageBox.Show(sText, sTitle, MessageBoxButton.OK, MessageBoxImage.Error)
'' Altrimenti manca la licenza
'Else
' EgtOutLog("Problems with Licence")
' ' Box di avviso licenza con problemi : "Programma senza licenza. \n Caricala e riavvia il programma." "Errore"
' Dim sText As String = EgtMsg(MSG_MISSINGKEYWD + 5) & vbCrLf & EgtMsg(MSG_MISSINGKEYWD + 6)
' Dim sTitle As String = EgtMsg(MSG_MISSINGKEYWD + 1)
' If MessageBox.Show(sText, sTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) = MessageBoxResult.OK Then
' ' Apro dialogo per richiesta file licenza
' Dim LicDlg As New Microsoft.Win32.OpenFileDialog() With {
' .DefaultExt = ".lic",
' .Filter = "Licences (.lic)|*.lic",
' .CheckFileExists = True,
' .ValidateNames = True
' }
' If LicDlg.ShowDialog() = True Then
' ' Recupero il direttorio del file
' Dim sDir As String = Path.GetDirectoryName(LicDlg.FileName)
' ' Se il file non è già nel direttorio di configurazione lo copio
' If Not String.Equals(Path.GetFullPath(sDir), Path.GetFullPath(OmagOFFICEMap.refMainWindowVM.MainWindowM.sConfigDir), StringComparison.OrdinalIgnoreCase) Then
' Try
' File.Copy(LicDlg.FileName, Path.Combine(OmagOFFICEMap.refMainWindowVM.MainWindowM.sConfigDir, LicDlg.SafeFileName), True)
' Catch ex As Exception
' End Try
' End If
' ' Imposto il nuovo file di licenza nell'Ini
' WriteMainPrivateProfileString(S_GENERAL, K_LICENCE, LicDlg.SafeFileName)
' End If
' End If
'End If
' Chiudo il programma
End
End Sub
Public Overrides Sub InitSceneEvents()
AddHandler MainScene.OnMouseDownScene, AddressOf OnMouseDownScene
'AddHandler MainScene.OnMouseMoveScene, AddressOf OnMouseMoveScene
AddHandler MainScene.OnMouseUpScene, AddressOf OnMouseUpScene
'AddHandler MainScene.KeyDown, AddressOf OnKeyDownScene
'AddHandler MainScene.OnCursorPos, AddressOf OnCursorPos
'AddHandler MainScene.OnShowDistance, AddressOf OnShowDistance
'AddHandler MainScene.OnChangedSnapPointType, AddressOf OnChangedSnapPointType
End Sub
Private Sub PreInitializeScene()
' imposto colore di default
Dim DefColor As New Color3d(0, 0, 0)
GetMainPrivateProfileColor(S_GEOMDB, K_DEFAULTCOLOR, DefColor)
MainScene.SetDefaultMaterial(DefColor)
' imposto colori sfondo
Dim BackTopColor As New Color3d(192, 192, 192)
GetMainPrivateProfileColor(S_SCENE, K_BACKTOP, BackTopColor)
Dim BackBotColor As New Color3d(BackTopColor)
GetMainPrivateProfileColor(S_SCENE, K_BACKBOTTOM, BackBotColor)
MainScene.SetViewBackground(BackTopColor, BackBotColor)
' imposto colore di evidenziazione
Dim MarkColor As New Color3d(255, 255, 0)
GetMainPrivateProfileColor(S_SCENE, K_MARK, MarkColor)
MainScene.SetMarkMaterial(MarkColor)
' imposto colore per superfici selezionate
Dim SelSurfColor As New Color3d(255, 255, 192)
GetMainPrivateProfileColor(S_SCENE, K_SELSURF, SelSurfColor)
MainScene.SetSelSurfMaterial(SelSurfColor)
' imposto tipo e colore del rettangolo di zoom
Dim bOutline As Boolean = True
Dim ZwColor As New Color3d(0, 0, 0)
GetMainPrivateProfileZoomWin(S_SCENE, K_ZOOMWIN, bOutline, ZwColor)
MainScene.SetZoomWinAttribs(bOutline, ZwColor)
' imposto colore della linea di distanza
Dim DstLnColor As New Color3d(255, 0, 0)
GetMainPrivateProfileColor(S_SCENE, K_DISTLINE, DstLnColor)
MainScene.SetDistLineMaterial(DstLnColor)
' imposto parametri OpenGL
Dim nDriver As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DRIVER, 3)
Dim b2Buff As Boolean = (GetMainPrivateProfileInt(S_OPENGL, K_DOUBLEBUFFER, 1) <> 0)
Dim nColorBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_COLORBITS, 32)
Dim nDepthBits As Integer = GetMainPrivateProfileInt(S_OPENGL, K_DEPTHBITS, 32)
MainScene.SetViewAttributes(nDriver, b2Buff, nColorBits, nDepthBits)
End Sub
Private Sub PostInitializeScene()
' Impostazioni Controller
MainController.SetScene(MainScene)
' imposto tipo coordinate
MainScene.SetGridCursorPos(True)
' modo di visualizzazione
Dim nShowMode As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWMODE, SM.SHADING)
'OmagOFFICEMap.refShowPanelVM.SetShowMode(DirectCast(nShowMode, SM))
' visualizzazione avanzata dei triangoli costituenti le superfici
Dim bShowTriaAdv As Boolean = (GetMainPrivateProfileInt(S_SCENE, K_SHOWTRIAADV, 1) <> 0)
EgtSetShowTriaAdv(bShowTriaAdv)
' tipo visualizzazione per Zmap
Dim nShowZmap As Integer = GetMainPrivateProfileInt(S_SCENE, K_SHOWZMAP, 1)
EgtSetShowZmap(DirectCast(nShowZmap, ZSM), False)
' dimensione lineare max in pixel delle textures
Dim nTxrMaxLinPix As Integer = GetMainPrivateProfileInt(S_SCENE, K_TEXMAXLINPIX, 4096)
EgtSetTextureMaxLinPixels(nTxrMaxLinPix)
' tipo snap point
MainScene.SetSnapPointType(SP.PT_SKETCH)
End Sub
Public Overrides Sub SaveProject()
MyBase.SaveProject()
' Imposto stato gestione mouse diretto della scena a nessuno
'MainScene.SetStatusNull()
End Sub
Public Overrides Sub SaveAsProject()
MyBase.SaveAsProject()
' Imposto stato gestione mouse diretto della scena a nessuno
'MainScene.SetStatusNull()
End Sub
#End Region ' METHODS
#Region "ProjectManager"
Public Overrides Sub NewProject()
EgtSetCurrentContext(MainScene.GetCtx())
Dim bOk As Boolean = MainController.NewProject()
'MainScene.SetStatusNull()
End Sub
Public Overrides Sub OpenProject(sFilePath As String)
EgtSetCurrentContext(MainScene.GetCtx())
Dim bOk As Boolean = False
If String.IsNullOrEmpty(sFilePath) Then
' Recupero cartella dell'ultimo progetto aperto
Dim sDir As String = MainController.GetCurrFile()
If String.IsNullOrWhiteSpace(sDir) Then
GetMainPrivateProfileString(S_MRUFILES, K_FILE, "", sDir)
End If
If Not String.IsNullOrWhiteSpace(sDir) Then
sDir = Path.GetDirectoryName(sDir)
End If
bOk = MainController.OpenProject(sDir)
Else
bOk = MainController.OpenProject(sFilePath, False)
End If
'MainScene.SetStatusNull()
End Sub
#End Region ' ProjectManager
#Region "EVENTS"
Private Sub OnNewProject(sender As Object, bOk As Boolean)
Map.refMainWindowVM.Title = " New - OmagVIEWPlus"
End Sub
Private Sub OnOpenProject(sender As Object, sFile As String, bOk As Boolean)
' Verifico la validità del file appena aperto (deve contenere almeno un gruppo di lavoro)
If EgtGetMachGroupCount() = 0 Then bOk = False
' Procedo a seconda del risultato
If bOk Then
Map.refMainWindowVM.Title = sFile & " - OmagVIEWPlus"
WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFile)
'OmagOFFICEMap.refTopCommandBarVM.m_MruFiles.Add(sFile)
Else
EgtNewFile()
Map.refMainWindowVM.Title = " New - OmagVIEWPlus"
'OmagOFFICEMap.refTopCommandBarVM.m_MruFiles.Remove(sFile)
Dim sMsg As String = EgtMsg(10003) & " '" & sFile & "'" 'Error opening file
MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) 'Error
End If
'MainScene.SetStatusNull()
MainScene.SetObjFilterForSel(False, False, True, False, False)
End Sub
'Private Sub OnSavingProject(ByVal sender As Object, sFile As String)
' ' Recupero tutti i file di texture associabili ai gruppi di lavoro del progetto
' Dim sDirToSearch As String = Path.GetDirectoryName(sFile)
' Dim sFileToSearch As String = Path.GetFileNameWithoutExtension(sFile) & "." & PHOTO_NAME & "*"
' Dim vsTxrFile As New List(Of String)
' For Each sTxrFile In My.Computer.FileSystem.GetFiles(sDirToSearch, FileIO.SearchOption.SearchTopLevelOnly, sFileToSearch)
' vsTxrFile.Add(sTxrFile)
' Next
' ' Rinomino path di eventuali fotografie
' Dim nPhotoId As Integer = EgtGetFirstInGroup(EgtGetFirstNameInGroup(GDB_ID.ROOT, PHOTO_GRP))
' While nPhotoId <> GDB_ID.NULL
' ' Path originale
' Dim sPhoto As String = String.Empty
' If EgtGetPhotoPath(nPhotoId, sPhoto) Then
' ' Nome della foto
' Dim sName As String = String.Empty
' EgtGetName(nPhotoId, sName)
' ' Nuova path
' Dim sNewPhoto As String = Path.GetDirectoryName(sFile) & "\" &
' Path.GetFileNameWithoutExtension(sFile) & "." & sName &
' Path.GetExtension(sPhoto)
' ' Se diverse, eseguo copia
' If String.Compare(sPhoto, sNewPhoto, True) <> 0 Then
' Try
' ' Eseguo copia
' File.Copy(sPhoto, sNewPhoto, True)
' ' Notifico a foto il cambio di path
' EgtChangePhotoPath(nPhotoId, sNewPhoto)
' ' Eventuale notifica a VeinMatching del cambio di path
' VeinMatching.ChangePhotoPath(sPhoto, sNewPhoto)
' Catch ex As Exception
' End Try
' End If
' ' Tolgo da lista file texture associabili, se presente
' vsTxrFile.Remove(sNewPhoto)
' End If
' ' passo alla successiva
' nPhotoId = EgtGetNext(nPhotoId)
' End While
' ' Se rimasti file associabili, li cancello
' For Each sTxrFile In vsTxrFile
' Try
' My.Computer.FileSystem.DeleteFile(sTxrFile)
' Catch
' End Try
' Next
'End Sub
'Private Sub OnSavedProject(ByVal sender As Object, ByVal sFile As String, ByVal bOk As Boolean)
' ' Se salvataggio non riuscito, esco subito
' If Not bOk Then
' OmagOFFICEMap.refTopCommandBarVM.m_MruFiles.Remove(sFile)
' Dim sMsg As String = EgtMsg(10004) & " '" & sFile & "'" 'Error saving file
' MessageBox.Show(sMsg, EgtMsg(10001), MessageBoxButton.OK, MessageBoxImage.Error) ' Error
' Return
' End If
' ' Eventuale salvataggio VM
' Dim sVmFile As String = Path.ChangeExtension(sFile, ".vme")
' VeinMatching.Save(sVmFile)
' ' Eventuale salvataggio CSV
' CsvM.SaveCsvPartList()
' ' Aggiornamento titolo
' OmagOFFICEMap.refMainWindowVM.Title = sFile & " - OmagOFFICE"
' ' Riabilito visualizzazione pezzi in parcheggio
' EstCalc.ShowParkedParts()
' ' Inserisco nome in MRU
' OmagOFFICEMap.refTopCommandBarVM.m_MruFiles.Add(sFile)
' ' Salvo nome ultimo file
' WriteMainPrivateProfileString(S_GENERAL, K_LASTPROJ, sFile)
'End Sub
'' selezione della scena: Grezzo, Nesting, lavorazione, simulazione
'Private Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs)
' ' Si può selezionare solo con il tasto sinistro e se stato NULL
' If e.Button <> Windows.Forms.MouseButtons.Left Or Not MainScene.IsStatusNull() Then Return
' ' Chiamo l'opportuno gestore
' Select Case OmagOFFICEMap.refOptionPanelVM.SelItem
' Case OptionPanelVM.Tabs.RAWPART
' OmagOFFICEMap.refRawPartTabVM.OnMouseDownScene(sender, e)
' Case OptionPanelVM.Tabs.NESTING
' OmagOFFICEMap.refNestingTabVM.OnMouseDownScene(sender, e)
' Case OptionPanelVM.Tabs.MACHINING
' OmagOFFICEMap.refMachiningTabVM.OnMouseDownScene(sender, e)
' Case OptionPanelVM.Tabs.SIMUL
' End Select
'End Sub
'Private Sub OnMouseMoveScene(sender As Object, e As Windows.Forms.MouseEventArgs)
' ' Chiamo l'opportuno gestore
' Select Case OmagOFFICEMap.refOptionPanelVM.SelItem
' Case OptionPanelVM.Tabs.RAWPART
' OmagOFFICEMap.refRawPartTabVM.OnMouseMoveScene(sender, e)
' Case OptionPanelVM.Tabs.NESTING
' OmagOFFICEMap.refNestingTabVM.OnMouseMoveScene(sender, e)
' Case OptionPanelVM.Tabs.MACHINING
' Case OptionPanelVM.Tabs.SIMUL
' End Select
'End Sub
'Private Sub OnMouseUpScene(sender As Object, e As Windows.Forms.MouseEventArgs)
' ' Chiamo l'opportuno gestore
' Select Case OmagOFFICEMap.refOptionPanelVM.SelItem
' Case OptionPanelVM.Tabs.RAWPART
' OmagOFFICEMap.refRawPartTabVM.OnMouseUpScene(sender, e)
' Case OptionPanelVM.Tabs.NESTING
' OmagOFFICEMap.refNestingTabVM.OnMouseUpScene(sender, e)
' Case OptionPanelVM.Tabs.MACHINING
' Case OptionPanelVM.Tabs.SIMUL
' End Select
'End Sub
'Private Sub OnKeyDownScene(sender As Object, e As System.Windows.Forms.KeyEventArgs)
' ' Chiamo l'opportuno gestore
' Select Case OmagOFFICEMap.refOptionPanelVM.SelItem
' Case OptionPanelVM.Tabs.RAWPART
' Case OptionPanelVM.Tabs.NESTING
' OmagOFFICEMap.refNestingTabVM.OnKeyDownScene(sender, e)
' Case OptionPanelVM.Tabs.MACHINING
' Case OptionPanelVM.Tabs.SIMUL
' End Select
'End Sub
'Private Sub OnCursorPos(ByVal sender As Object, ByVal sCursorPos As String)
' OmagOFFICEMap.refStatusBarVM.SetCurrPos(sCursorPos)
'End Sub
'Private Sub OnShowDistance(ByVal sender As Object, ByVal sDistance As String)
' OmagOFFICEMap.refStatusBarVM.SetOutputMessage(sDistance)
'End Sub
'Private Sub OnChangedSnapPointType(ByVal sender As Object, ByVal nSpType As SP, ByVal bUser As Boolean)
' Dim BtnColor As Brush
' If bUser Then
' BtnColor = New SolidColorBrush(SystemColors.ControlColor)
' Else
' BtnColor = Brushes.Bisque
' End If
' Select Case nSpType
' Case SP.PT_SKETCH
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1102), BtnColor) 'Sketch Point
' Case SP.PT_GRID
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1104), BtnColor) 'Grid Point
' Case SP.PT_END
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1106), BtnColor) 'End Point
' Case SP.PT_MID
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1108), BtnColor) 'Mid Point
' Case SP.CENTER
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1110), BtnColor) 'Center
' Case SP.CENTROID
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1112), BtnColor) 'Centroid
' Case SP.PT_NEAR
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1114), BtnColor) 'Near Point
' Case SP.PT_INTERS
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1116), BtnColor) 'Inters Point
' Case SP.PT_TANGENT
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1118), BtnColor) 'Tang Point
' Case SP.PT_PERPENDICULAR
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1120), BtnColor) 'Perp Point
' Case SP.PT_MINDIST
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType(EgtMsg(1122), BtnColor) 'MinDist Point
' Case Else
' OmagOFFICEMap.refStatusBarVM.SetSnapPointType("---", BtnColor)
' End Select
'End Sub
Private m_bDrag As Boolean = False
Private m_nIdToSel As Integer = GDB_ID.NULL
Private m_nIdToDesel As Integer = GDB_ID.NULL
Friend Sub OnMouseDownScene(sender As Object, e As Windows.Forms.MouseEventArgs)
' devo attendere che sia terminato lo scarico della tavola 1 -> GetPart(Place.ON_TABLE).Count = 0
If Not IsNothing(Map.refUnloadingAreaVM) AndAlso Not Map.refUnloadingAreaVM.IsChecked_Manual Then Return
' Per default no drag
m_bDrag = False
' Verifico se selezionato indicativo di pezzo
EgtSetObjFilterForSelWin(True, True, True, True, True)
Dim nSel As Integer
EgtSelect(e.Location, Scene.DIM_SEL, Scene.DIM_SEL, nSel)
Dim nId As Integer = EgtGetFirstObjInSelWin()
' usato come test (tutto inuna sola funzione)
'Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
'If EgtGetRawPartFromPart(nPartId) = GDB_ID.NULL Then Return
'Dim nStat As Integer = GDB_ST.ON_
'EgtGetStatus(nPartId, nStat)
'If nStat = GDB_ST.SEL Then
' EgtDeselectObj(nPartId)
'Else
' EgtSelectObj(nPartId)
'End If
While nId <> GDB_ID.NULL
' Recupero l'identificativo del pezzo cui appartiene
Dim nPartId As Integer = EgtGetParent(EgtGetParent(nId))
Dim bPartInTable As Boolean = (EgtGetParent(nPartId) = GetRawId())
If EgtGetRawPartFromPart(nPartId) <> GDB_ID.NULL Then
Dim nStat As Integer = GDB_ST.ON_
EgtGetStatus(nPartId, nStat)
' Se già selezionato
If nStat = GDB_ST.SEL Then
' Memorizzo Id da deselezionare
m_nIdToDesel = nPartId
Else
' Memorizzo Id da selezionare
m_nIdToSel = nPartId
End If
' Drag possibile
m_bDrag = True
Exit While
End If
nId = EgtGetNextObjInSelWin()
End While
'' Dati per drag
'm_locPrev = e.Location
'm_bDrag = m_bDrag AndAlso EgtUnProjectPoint(e.Location, m_ptPrev)
'm_bDragToStart = m_bDrag
'm_bVerify = m_bDrag AndAlso (Keyboard.Modifiers And ModifierKeys.Shift) > 0
'm_vtTotMove = Vector3d.NULL()
End Sub
Private m_nPartPos As Integer = PART_POS.NONE_TABLE
Enum PART_POS As Integer
IN_TABLE = -1
NONE_TABLE = 0
OUT_TABLE = 1
End Enum
Friend Sub OnMouseUpScene(sender As Object, e As System.Windows.Forms.MouseEventArgs)
' Se eseguito drag
'If Not m_bDragToStart Then
' ' Se movimento con sola verifica finale
' If m_bVerify Then
' ' Determino cosa verificare
' Dim nMoveId = If(m_nIdToSel <> GDB_ID.NULL, m_nIdToSel, GDB_ID.SEL)
' ' Aggiorno regioni per nesting
' UpdateNestRegions()
' EnableReferenceRegion(False)
' ' Eseguo verifica
' If EgtVerifyPart(nMoveId, CurrentMachine.bReducedCut) Then
' EstCalc.ResetOrderMachiningFlag()
' ' Non superata riporto alla posizione iniziale
' Else
' If m_bFromParking Then
' PreRemoveOnePart(nMoveId)
' VeinMatching.OnRemovePartFromRaw(nMoveId)
' Else
' EgtMove(nMoveId, -m_vtTotMove)
' ' Eventuale notifica al VeinMatching
' If nMoveId = GDB_ID.SEL Then
' Dim nId As Integer = EgtGetFirstSelectedObj()
' While nId <> GDB_ID.NULL
' VeinMatching.OnMovePartInRaw(nId)
' nId = EgtGetNextSelectedObj()
' End While
' Else
' VeinMatching.OnMovePartInRaw(nMoveId)
' End If
' End If
' End If
' m_bFromParking = False
' ' altrimenti caso con verifica durante il movimento
' Else
' ' Basta reset alla fine
' End If
' ' Se selezione da eseguire ---> ElseIf
If m_nIdToSel <> GDB_ID.NULL Then
'' Determino se pezzo in tavola o in parcheggio
'Dim bPartInTable As Boolean = (EgtGetParent(m_nIdToSel) = GetRawId())
'' Se ci sono pezzi già selezionati nella posizione opposta, li deseleziono
'If (bPartInTable And m_nPartPos = PART_POS.OUT_TABLE) Or
' (Not bPartInTable And m_nPartPos = PART_POS.IN_TABLE) Then
' EgtDeselectAll()
' ' Aggiornamento eventuale VeinMatching
' VeinMatching.OnDeselectAll()
'End If
' Eseguo la selezione
EgtSelectObj(m_nIdToSel)
''' Eventuale aggiornamento VeinMatching
'VeinMatching.OnSelectPart(m_nIdToSel)
'' Set flag posizione selezionati
'm_nPartPos = If(bPartInTable, PART_POS.IN_TABLE, PART_POS.OUT_TABLE)
' Se deselezione da eseguire
ElseIf m_nIdToDesel <> GDB_ID.NULL Then
EgtDeselectObj(m_nIdToDesel)
'' Eventuale aggiornamento VeinMatching
'VeinMatching.OnDeselectPart(m_nIdToDesel)
End If
' Reset
m_bDrag = False
m_nIdToSel = GDB_ID.NULL
m_nIdToDesel = GDB_ID.NULL
' Se nessun pezzo selezionato, reset flag posizione selezionati
If EgtGetSelectedObjCount() = 0 Then
m_nPartPos = PART_POS.NONE_TABLE
End If
EgtDraw()
End Sub
#End Region ' EVENTS
#Region "COMMAND"
Public ReadOnly Property ConfirmManualPart_Command() As ICommand
Get
If m_cmdConfirmManaulPart Is Nothing Then
m_cmdConfirmManaulPart = New Command(AddressOf ConfirmManualPart)
End If
Return m_cmdConfirmManaulPart
End Get
End Property
' scarico tutti i pezzi manuali rimasti sulla rulliera
Public Sub ConfirmManualPart()
If VisibilityManulaPartCommand <> Visibility.Visible Then Return
Map.refUnloadingAreaVM.IsChecked_Manual = False
End Sub
#End Region ' COMMAND
End Class
+23
View File
@@ -0,0 +1,23 @@
<Window x:Class="SceneWindowV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:OmagVIEWPlus"
xmlns:OmagVIEWPlus="clr-namespace:OmagVIEWPlus"
mc:Ignorable="d"
Title="SceneWindowV" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="35"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<DockPanel HorizontalAlignment="Right" Grid.Row="0">
<ToggleButton Content="Storage!"
IsChecked="{Binding UnloadingAreaIsChecked}"/>
</DockPanel>
<local:SceneHostV Grid.Row="1"/>
</Grid>
</Window>
+3
View File
@@ -0,0 +1,3 @@
Public Class MySceneHostV
End Class
+7
View File
@@ -0,0 +1,7 @@
Imports EgtUILib
Imports EgtWPFLib5
Imports System.IO
Public Class SceneWindowVM
End Class
+482 -153
View File
@@ -1,4 +1,5 @@
Imports System.Windows.Threading
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
@@ -63,6 +64,14 @@ Public Class NCCommunication
AddHandler m_RefreshTimer.Tick, AddressOf RefreshTimer_Tick
m_RefreshTimer.Interval = TimeSpan.FromMilliseconds(GetMainPrivateProfileInt(S_NUMERICALCONTROL, K_TIMERINTERVAL, 1000))
m_RefreshTimer.Start()
' elimino il file di ProcessLog precedente
If My.Computer.FileSystem.FileExists(Map.refMainWindowVM.MainWindowM.sTempDir & "\ProcessLog.txt") Then
My.Computer.FileSystem.DeleteFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\ProcessLog.txt")
End If
' eseguo la ricerca dei part
Part.GetListOfPart()
' Eseguo subito la prima lettura variabili
Refresh()
End Sub
@@ -78,6 +87,7 @@ Public Class NCCommunication
End Sub
Private Sub Refresh()
OutLogProcess("----------------------- " & My.Computer.Clock.LocalTime.ToLongTimeString & "-----------------------")
'Dim n1Value As Integer = 0
'Dim x As Boolean = m_NC.ReadInt(81, 0, n1Value)
'Dim y As Boolean = m_NC.WriteInt(81, 0, 547)
@@ -96,179 +106,444 @@ Public Class NCCommunication
'x = TryCast(m_NC, Nc_Siemens).ReadString(81, 8, 6, s)
'x = TryCast(m_NC, Nc_Siemens).WriteString(81, 8, "tres")
Dim nValue As Integer = 0
Dim nValue2 As Integer = 0
' variabile che indica se legge almeno una variabile
Dim bRaededVariable As Boolean = False
' Variabili prima lettura dopo cambio attivazione
Dim bAFirstNotActive As Boolean = False
Dim bBFirstNotActive As Boolean = False
' Leggo magazzino attivo
Dim ActiveStorage As Warehouses = Warehouses.A
If ReadInt("ActiveStorage", nValue) Then
bRaededVariable = True
If nValue >= 0 OrElse nValue < 3 Then ActiveStorage = DirectCast(nValue, Warehouses)
If ActiveStorage <> Map.refUnloadingAreaVM.ActiveWarehouse Then
If Map.refUnloadingAreaVM.ActiveWarehouse = Warehouses.A Then bAFirstNotActive = True
If Map.refUnloadingAreaVM.ActiveWarehouse = Warehouses.B Then bBFirstNotActive = True
Else
bAFirstNotActive = False
bBFirstNotActive = False
End If
Map.refUnloadingAreaVM.SetActiveWarehouse(ActiveStorage)
End If
' Se magazzino 2 attivo
If ActiveStorage = Warehouses.A OrElse bAFirstNotActive Then
Dim WarehouseA As WarehouseVM = Map.refUnloadingAreaVM.WarehouseList(UnloadingAreaVM.GetWarehouseIndex(Warehouses.A))
' Leggo se secondo magazzino è pallet o rack
Dim Storage2_IsPallet As Boolean = True
If ReadInt("Storage2_IsPallet", nValue) Then
bRaededVariable = True
Storage2_IsPallet = (nValue <> 0)
Map.refUnloadingAreaVM.SetWarehouse_IsPallet(Warehouses.A, Storage2_IsPallet)
End If
' Leggo box attivo
Dim ActiveBox As Integer = 0
If ReadInt("ActiveBox", nValue) Then
bRaededVariable = True
If nValue >= 0 OrElse nValue <= 6 Then ActiveBox = nValue
Map.refUnloadingAreaVM.SetBoxIsActive(ActiveBox)
End If
' Leggo stato secondo magazzino
Dim Storage2_Stato As States = States.NOT_AVAILABLE
If ReadInt("Storage2_Stato", nValue) Then
bRaededVariable = True
If nValue >= 0 OrElse nValue <= 3 Then Storage2_Stato = DirectCast(nValue, States)
WarehouseA.SetState(Storage2_Stato)
End If
' Leggo stati dei box del magazzino
Dim StorageX_BoxX_Stato As States = States.NOT_AVAILABLE
Dim MaxBoxX As Integer = If(Storage2_IsPallet, 6, 3)
For BoxX As Integer = 1 To MaxBoxX
StorageX_BoxX_Stato = States.NOT_AVAILABLE
If ReadInt("Storage2_Box" & BoxX & "_Stato", nValue) Then
bRaededVariable = True
If nValue >= 0 OrElse nValue <= 3 Then StorageX_BoxX_Stato = DirectCast(nValue, States)
Map.refUnloadingAreaVM.SetBoxState(Warehouses.A, BoxX, StorageX_BoxX_Stato)
' 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
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
End If
Next
End If
' Se magazzino 1 attivo
If ActiveStorage = Warehouses.B OrElse bBFirstNotActive Then
Dim WarehouseB As WarehouseVM = Map.refUnloadingAreaVM.WarehouseList(UnloadingAreaVM.GetWarehouseIndex(Warehouses.B))
' Leggo se primo magazzino è pallet o rack
Dim Storage1_IsPallet As Boolean = True
If ReadInt("Storage1_IsPallet", nValue) Then
' leggo dalla macchina se è terminato lo sacrico manuale
If ReadInt("UnloadManual", nValue) Then
bRaededVariable = True
Storage1_IsPallet = (nValue <> 0)
Map.refUnloadingAreaVM.SetWarehouse_IsPallet(Warehouses.B, Storage1_IsPallet)
If nValue = 0 Then bManualUnloading = False
End If
' Leggo box attivo
Dim ActiveBox As Integer = 0
If ReadInt("ActiveBox", nValue) Then
bRaededVariable = True
If nValue >= 0 OrElse nValue <= 6 Then ActiveBox = nValue
Map.refUnloadingAreaVM.SetBoxIsActive(ActiveBox)
End If
' Leggo stato primo magazzino
Dim Storage1_Stato As States = States.NOT_AVAILABLE
If ReadInt("Storage1_Stato", nValue) Then
bRaededVariable = True
If nValue >= 0 OrElse nValue <= 3 Then Storage1_Stato = DirectCast(nValue, States)
WarehouseB.SetState(Storage1_Stato)
End If
' Leggo stati dei box del magazzino
Dim StorageX_BoxX_Stato As States = States.NOT_AVAILABLE
Dim MaxBoxX As Integer = If(Storage1_IsPallet, 6, 3)
For BoxX As Integer = 1 To MaxBoxX
StorageX_BoxX_Stato = States.NOT_AVAILABLE
If ReadInt("Storage1_Box" & BoxX & "_Stato", nValue) Then
bRaededVariable = True
If nValue >= 0 OrElse nValue <= 3 Then StorageX_BoxX_Stato = DirectCast(nValue, States)
Map.refUnloadingAreaVM.SetBoxState(Warehouses.B, BoxX, StorageX_BoxX_Stato)
' se lo scarico manuale è terminato procedo a caricare nuovo progetto
If Not bManualUnloading Then
' svuoto la rulliera dai paìezzi manuali
Map.refUnloadingAreaVM.UnloadedManualPart()
' nascondo la freccai rossa
Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Collapsed
' carico il nuovo progetto
Dim sProjNew As String = Map.refMainWindowVM.MainWindowM.sProjDir & "\" & CURR_PROJ_NEW
Dim sProjLock As String = Map.refMainWindowVM.MainWindowM.sProjDir & "\" & CURR_PROJ_LOCK
' Se c'è file segnalazione nuovo lo trasformo in segnalazione bloccato
If My.Computer.FileSystem.FileExists(sProjNew) Then
OutLogProcess("[0] Trovato nuovo progetto")
' se riesco a posizionare tutte le ventose
If Map.refMainWindowVM.StartUnloadingProject() Then
' Rinomino segnalazione nuovo in segnalazione blocco
My.Computer.FileSystem.MoveFile(sProjNew, sProjLock, True)
End If
End If
Next
End If
' Leggo numero massimo righe e colonne
Dim MaxNRighe As Integer = 0
Dim MaxNColonne As Integer = 0
If ReadInt("MaxNRighe", nValue) AndAlso ReadInt("MaxNColonne", nValue2) Then
bRaededVariable = True
If nValue >= 0 Then MaxNRighe = nValue
If nValue2 >= 0 Then MaxNColonne = nValue2
Map.refUnloadingAreaVM.MaxFillActiveBox(MaxNRighe, MaxNColonne)
End If
' Leggo numero riga e colonna corrente su box attivo
Dim ActBox_Livello As Integer = 0
Dim ActBox_Riga As Integer = 0
If ReadInt("ActBox_Livello", nValue) AndAlso ReadInt("ActBox_Riga", nValue2) Then
bRaededVariable = True
If nValue >= 0 Then ActBox_Livello = nValue
If nValue2 >= 0 Then ActBox_Riga = nValue2
Map.refUnloadingAreaVM.FillActiveBox(ActBox_Livello, ActBox_Riga)
End If
' Leggo contatori
Dim Table1Counter As Integer = 0
Dim Table2Counter As Integer = 0
If ReadInt("Table1Counter", nValue) AndAlso ReadInt("Table2Counter", nValue2) Then
bRaededVariable = True
If nValue >= 0 Then Table1Counter = nValue
If nValue2 >= 0 Then Table2Counter = nValue2
Map.refUnloadingAreaVM.SetTableCounters(Table1Counter, Table2Counter)
End If
' Leggo riga corrente tavolo 1
Dim Table1CurrRow As Integer = 0
Dim Table1NRow As Integer = 0
If ReadInt("Table1CurrRow", nValue) AndAlso ReadInt("Table1NRow", nValue2) Then
bRaededVariable = True
If nValue >= 0 Then Table1CurrRow = nValue
If nValue2 >= 0 Then Table1NRow = nValue2
Map.refUnloadingAreaVM.SetTable1Percentage(Table1CurrRow, Table1NRow)
End If
' Leggo tipo di piastrella
Dim TipoPiastrella As Integer = 0
If ReadInt("TipoPiastrella", nValue) Then
bRaededVariable = True
If nValue >= 1 OrElse nValue <= 5 Then TipoPiastrella = nValue
'Map.refUnloadingAreaVM.SetBoxIsActive(TipoPiastrella)
End If
' Leggo spessore
Dim DimensioneZ As Integer = 0
If ReadInt("DimensioneZ", nValue) Then
bRaededVariable = True
If nValue >= 0 Then DimensioneZ = nValue
'Map.refUnloadingAreaVM.SetBoxIsActive(TipoPiastrella)
End If
' Leggo ultima lastra
Dim UltimaLastra As Integer = 0
If ReadInt("UltimaLastra", nValue) Then
bRaededVariable = True
If nValue >= 0 Then UltimaLastra = nValue
'Map.refUnloadingAreaVM.SetBoxIsActive(TipoPiastrella)
End If
' se Debug, incremento tempo
If Connection_State = Connection_States.DEBUG Then
If bRaededVariable Then
TryCast(m_NC, Nc_Debug).IncrementTime()
Else
TryCast(m_NC, Nc_Debug).SetTime(0)
'' avendo caricato un nuovo progetto devo disporre il nuovo magazzino (se non ho altri progetti prima)
'Map.refUnloadingAreaVM.bOrganizeWarehouse = True
End If
End If
m_nTime += 1
m_bFirst = False
' aggiorno l'elenco dei progetti in esecuzione nel file Warehouse.ini
Dim sListIndProj As String = String.Empty
For Each ItemProj In Map.refMainWindowVM.MainWindowM.ProjIndList
If ItemProj.enStatus = StatusProj.LOADING Or ItemProj.enStatus = StatusProj.WORKING Then
' costruisco la stringa che contiene l'elenco dei progetti in esecuzione sulla macchina
If String.IsNullOrEmpty(sListIndProj) Then
sListIndProj = ItemProj.nProjInd.ToString
Else
sListIndProj = sListIndProj & "," & ItemProj.nProjInd.ToString
End If
End If
Next
' scrivo nel file ini l'elenco
WarehauseWritePrivateProfileString("Warehouse", "IdProj", sListIndProj)
' leggo lo stato SCARICATORE StatusMachine1
Dim StatusMachine1 As StatusMachine = StatusMachine.MOVING
If ReadInt("StatusMachine1", nValue) Then
bRaededVariable = True
' converto in Enum
If nValue >= 0 OrElse nValue <= 4 Then
StatusMachine1 = DirectCast(nValue, StatusMachine)
End If
Select Case StatusMachine1
Case StatusMachine.WAITING_POINT
OutLogProcess("[1] Stato macchina 1: 0")
' la macchina è ferma ed è pronta a ricevere le nuove coordinate
' se esiste un pezzo corrente allora significa che è stato scaricato correttamente
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)
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()
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()
End Select
' aggiorno Pezzi rimasti sul tavolo (esclusi quelli rovinati)
Map.refUnloadingAreaVM.NotifyPropertyChanged("Table1Percentage")
' aggiorno Pezzi attualmente sulla rulliera motorizzata
Map.refUnloadingAreaVM.NotifyPropertyChanged("TableDifference")
End If
' mentre scarico la macchina1 attendo che la macchina2 sia pronta
Dim bFoundStorage As Boolean = False
' cambio progetto sulla tavola 2, devo attendere che i box di tipo LOADING siano stati riempiti
OutLogProcess("[2] Stato progetto corrente: " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString & " - " & Map.refUnloadingAreaVM.IdProjTable2.enStatus.ToString)
' se il progetto corrente (se nessun file .ini di progetto è caricato nell'OrganizeWarehouse) è in fase LOADING oppure DONE, passo al successivo
If (Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.DONE Or Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.LOADING Or
Map.refUnloadingAreaVM.IdProjTable2.nProjInd = -1) And
EndedUnloading() Then
' verifico lo stato del magazzino corrente se è ancora disponibile (altrimenti lo disattivo)
CurrWarehaouseIsAvailable(Map.refUnloadingAreaVM.GetCurrentWarehouse())
' se il progetto è prenotato allora rendo i magazzini non disponibili alla macchina e disattivi
If Map.refMainWindowVM.WaitingConfirmManualPart Then
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)
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)
' 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")
For Each ItemWarehouse In Map.refUnloadingAreaVM.WarehouseList
If ItemWarehouse.State = States.AVAILABLE Then
Map.refUnloadingAreaVM.bOrganizeWarehouse = Not SetCurrStorage(ItemWarehouse)
End If
Next
End If
End If
End If
' recupero il MAGAZZINO attivo, se non c'è magazzino attivo il pallettizzatore aspetta
Dim CurrWarehouse As WarehouseVM = Map.refUnloadingAreaVM.GetCurrentWarehouse()
If IsNothing(CurrWarehouse) Then Return
If Not CurrWarehouse.IsActive Then Return
' 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)
End If
' comunico nuovo magazzino
SetActiveWarehouse(CurrWarehouse)
' leggo lo stao del pallettizzatore
Dim StatusMachine2 As StatusMachine = StatusMachine.MOVING
If ReadInt("StatusMachine2", nValue) Then
bRaededVariable = True
' converto in Enum
If nValue >= 0 OrElse nValue <= 4 Then
StatusMachine2 = DirectCast(nValue, StatusMachine)
End If
Select Case StatusMachine2
Case StatusMachine.WAITING_POINT
OutLogProcess("[3] Stato macchina 2: 0")
If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable2) AndAlso
Map.refUnloadingAreaVM.CurrPartTable2.enUnloading = Unloading.AUTOMATIC Then
Map.refUnloadingAreaVM.CurrPartTable2.enPlace = Place.ON_BOX
OutLogProcess("[3] Pezzo depositato nel Box: " & Map.refUnloadingAreaVM.CurrPartTable2.IdPart.ToString & " - " & Map.refUnloadingAreaVM.CurrPartTable2.IdBox.ToString)
' aggiorno la percentuale del box
If Not IsNothing(Map.refUnloadingAreaVM.CurrBox) Then Map.refUnloadingAreaVM.CurrBox.NotifyPropertyChanged("nFillPercentage")
' se è l'ultimo pezzo comunico che il progetto è stato elaborato
If Map.refUnloadingAreaVM.CurrPartTable2.IsLast Then
Map.refUnloadingAreaVM.IdProjTable2.enStatus = StatusProj.DONE
OutLogProcess("[3] Progetto terminato: " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString)
' elimino il file ini associato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString & ".ini"
If My.Computer.FileSystem.FileExists(sFile) Then
My.Computer.FileSystem.DeleteFile(sFile)
OutLogProcess("[3] Eliminato file: " & sFile)
End If
End If
' nascondo la freccia rossa sulla rulliera
Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Collapsed
End If
' salvo le coordinate per afferrare e depositare i pezzi (solo quelli automatici)
Map.refUnloadingAreaVM.CurrPartTable2 = UnLoadTable2(CurrWarehouse, Map.refUnloadingAreaVM.IdProjTable2.nProjInd)
Case StatusMachine.CHANGE_POINT
OutLogProcess("[3] Stato macchina 2: 3")
' rendo visibile la freccia rossa sulla rulliera
Map.refUnloadingAreaVM.RullerArrowVisibility = Visibility.Visible
' significa che devo prendere il pezzo successivo a quello indicato prima (aggiungo OffsetX = MinRectX)
If Not IsNothing(Map.refUnloadingAreaVM.CurrPartTable2) AndAlso
Map.refUnloadingAreaVM.CurrPartTable2.enUnloading = Unloading.AUTOMATIC Then
Map.refUnloadingAreaVM.CurrPartTable2.enStatus = StatusPart.NOT_LOADED
Map.refUnloadingAreaVM.CurrPartTable2.enPlace = Place.ON_WASTE_BOX
OutLogProcess("[3] Pezzo non prelevabile : " & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString)
End If
' nessun pezzo, aspetto che la macchina torni as assere in stato 0->WAITING_POINT (comandato dalla macchina)
Map.refUnloadingAreaVM.CurrPartTable2 = Nothing
' attendo che il pezzo sia scaricato a mano
End Select
End If
' Pezzi attualmente sulla rulliera motorizzata
Map.refUnloadingAreaVM.NotifyPropertyChanged("TableDifference")
' Percentuale di pezzi depositati nel totale dei box disponibili magazzino
CurrWarehouse.NotifyPropertyChanged("FillPercentage")
End Sub
' salvo le coordinate per afferrare e depositare il pezzo sulla tavola 1
Private Function UnLoadTable1() As Part
Dim LocalPart As Part = Nothing
' la macchina è ferma e ha scartato un pezzo-> comunico le coordinate di aggancio del nuovo pezzo
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)
WriteReal("C_Table1", LocalPart.DegAngOnTable)
' 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)
' salvo le ventose che devono essere attivate
For IndexVacuum = 1 To 6
WriteInt("Tb1Vacuum" & IndexVacuum.ToString, LocalPart.GetVacuumLoadingStatus("V" & IndexVacuum.ToString))
Next
' 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
OutLogProcess("UnLoadTable1() -> Communico punto di prelievo pezzo: " & LocalPart.IdPart.ToString)
OutLogProcess("UnLoadTable1() -> Stato macchina 1: 1" & LocalPart.IdPart.ToString)
End If
Return LocalPart
End Function
' verifico se ho terminato il carcio dei Box
Private Function EndedUnloading() As Boolean
If IsNothing(Map.refUnloadingAreaVM.GetCurrentWarehouse) Then Return True
For Each ItemBox In Map.refUnloadingAreaVM.GetCurrentWarehouse.Boxes
If ItemBox.State = States.LOADING Then
Return False
End If
Next
OutLogProcess("EndedUnloading() -> Terimnato riempimento Boxs")
Return True
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
' verifico che il magazzino è disponibile
If CurrWareouse.State = States.AVAILABLE Then
For Each ItemGridBox In CurrWareouse.GridBoxList
For Each ItemBox In ItemGridBox.CurrBoxList
If ItemBox.State = States.AVAILABLE Or ItemBox.State = States.LOADING Then
OutLogProcess("CurrWarehaouseIsAvailable() -> Magazzino corrente disponibile: " & CurrWareouse.Id.ToString)
Return True
End If
Next
Next
End If
'CurrWareouse.SetIsActive(False)
CurrWareouse.SetState(States.NOT_AVAILABLE)
OutLogProcess("CurrWarehaouseIsAvailable() -> Magazzino corrente non disponibile: " & CurrWareouse.Id.ToString)
'CurrWareouse.NotifyPropertyChanged("IsEnabled")
Return False
End Function
' 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
End Sub
' verifico che il magazzino corrente possa accogliere i nuovi pezzi
Private Function SetCurrStorage(objWarehouse As WarehouseVM) As Boolean
' se il magazzino attivo non è più disponibile
If objWarehouse.State <> States.AVAILABLE Then
' allora comunico che non è attivo
objWarehouse.SetIsActive(False)
OutLogProcess("SetCurrStorage() -> Disattivo magazzino corrente: " & objWarehouse.Id.ToString)
'esco
Return False
End If
' se il magazzino corrente è disponibile
Map.refUnloadingAreaVM.SetActiveWarehouse(objWarehouse.Id)
' verifico che il progetto possa essere scaricato
Dim bStorageFound As Boolean = Map.refUnloadingAreaVM.OrganaizeWarehouse()
If Not bStorageFound Then
objWarehouse.SetIsActive(False)
objWarehouse.SetState(States.NOT_AVAILABLE)
objWarehouse.NotifyPropertyChanged("IsEnabled")
OutLogProcess("SetCurrStorage() -> magazzino corrente non disponibile per scarico: " & objWarehouse.Id.ToString)
End If
Return bStorageFound
End Function
' salvo le coordinate per afferrare e depositare il pezzo sulla tavola 2
Private Function UnLoadTable2(CurrWarehouse As WarehouseVM, IdProjTable2 As Integer) As Part
Dim LocalPart As Part = Nothing
' devo ricercare i pezzi del progetto che sto scricando
If Not IsNothing(Map.refUnloadingAreaVM.GetParts(IdProjTable2, Place.ON_MOTOR_RULLER)) AndAlso
Map.refUnloadingAreaVM.GetParts(IdProjTable2, Place.ON_MOTOR_RULLER).Count > 0 Then
LocalPart = Map.refUnloadingAreaVM.GetParts(IdProjTable2, Place.ON_MOTOR_RULLER)(0)
' se lo scarico previsto è manuale allora interrompo
If LocalPart.enUnloading = Unloading.MANUAL Then
Return Nothing
End If
Dim bFoundBox As Boolean = False
' ricerco tra tutti i box del magazzino quello che deve accogliere il pezzo
For Each ItemBox In CurrWarehouse.Boxes
For Each ItemPart In ItemBox.MyListPart
If ItemPart.IdPart = LocalPart.IdPart AndAlso
ItemPart.IdProject = LocalPart.IdProject Then
' mi basta che un solo pezzo sia stato depositato per definire il box FULL (non disponibile per altri progetti)
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)
' cumunico l'id del box ativo
WriteInt("ActiveBox", ItemBox.Id)
' riconosco il tipo di box
Dim C_Ang As Double = 90
Dim B_Ang As Double = 0
If ItemBox.enConfigBox = ConfigBox.PALLET Then
ItemPart.MoveTable2.m_vtDelta.Rotate(Vector3d.Z_AX(), 90)
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)
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)
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)
WriteReal("C_Box", C_Ang)
WriteReal("B_Box", B_Ang)
End If
' salvo le ventose che devono essere attivate
For IndexVacuum = 1 To 6
WriteInt("Tb2Vacuum" & IndexVacuum.ToString, LocalPart.GetVacuumLoadingStatus("V" & IndexVacuum.ToString, "Table2"))
Next
bFoundBox = True
WriteInt("StatusMachine2", CInt(StatusMachine.LOADED_POINT))
OutLogProcess("UnLoadTable2() -> Communico punto di prelievo pezzo: " & LocalPart.IdPart.ToString)
OutLogProcess("UnLoadTable2() -> Stato macchina 2: 1")
Exit For
End If
Next
If bFoundBox Then Exit For
Next
End If
Return LocalPart
End Function
' definito il nome della variabile recupero l'inidirzzo variabile PLC e restituisco il valore letto da PLC
Private Function ReadInt(sVarName As String, ByRef nValue As Integer) As Boolean
Dim bok As Boolean = True
Dim sVar As String = String.Empty
' Lettura variabile
' leggo da file OmagVIEWPlus l'indirizzo della variabile associata
If GetMainPrivateProfileString(S_VARIABLES, sVarName, "", sVar) > 0 Then
' Spezzatura nei componenti
' Spezzatura nei componenti: sVar -> ActiveStorage=81,0,2
Dim sVarSplit() As String = sVar.Split(","c)
If sVarSplit.Length = 3 Then
' elimino spazi
@@ -277,13 +552,16 @@ Public Class NCCommunication
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 è intero
If Type = 2 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.ReadInt(DbNumber, Start, nValue) Then
' scrivo in backup
Dim sBackupFolder As String = Map.refMainWindowVM.MainWindowM.sLogDir & "\" & Date.Today.Year & "-" &
@@ -302,6 +580,7 @@ Public Class NCCommunication
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 = 2 Then
@@ -336,7 +615,7 @@ Public Class NCCommunication
If m_NC.WriteInt(81, 144, nValue) And m_NC.WriteInt(81, 140, 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"
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)
Return True
@@ -347,6 +626,56 @@ Public Class NCCommunication
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 = 2 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(1), nType)
If nType >= 0 AndAlso nType <= 7 Then Type = DirectCast(nType, Types)
If Type = 2 Then
Dim RNumber As Integer = 0
Integer.TryParse(sVarSplit(0), RNumber)
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(81, 140, 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(81, 144, dValue) And m_NC.WriteInt(81, 140, 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", dValue.ToString, sBackupFolder)
Return True
End If
End If
End If
End If
Return False
End Function
Private Function WriteBool(sVarName As String, nValue As Boolean) As Boolean
Dim bok As Boolean = True
Dim sVar As String = String.Empty
+5
View File
@@ -11,16 +11,21 @@ Public Class Nc_Siemens
Private StringBuffer(65536) As Byte ' Buffer
Private Client As New S7Client ' Client Object
' Avvio la connessione Hardware-Client
Friend Overrides Function InitConnection() As Boolean
Dim Result As Integer
Dim sIp As String = ""
' Ip del'Hardware
GetMainPrivateProfileString(S_NUMERICALCONTROL, K_IP, "", sIp)
' unità usate dall'Hardware (Rack e Slot)
Dim nRack As Integer = GetMainPrivateProfileInt(S_NUMERICALCONTROL, K_RACK, 0)
Dim nSlot As Integer = GetMainPrivateProfileInt(S_NUMERICALCONTROL, K_SLOT, 0)
Result = Client.ConnectTo(sIp, nRack, nSlot)
' se la connessione è restituisce 0
Return Result = 0
End Function
' chiudo la connessione
Friend Overrides Sub CloseConnection()
Client.Disconnect()
End Sub
+53 -6
View File
@@ -67,15 +67,15 @@
<OutputPath>bin\x86\Debug\</OutputPath>
<DocumentationFile>
</DocumentationFile>
<Optimize>true</Optimize>
<Optimize>false</Optimize>
<NoWarn>
</NoWarn>
<DebugType>Full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<DebugSymbols>true</DebugSymbols>
<DefineDebug>false</DefineDebug>
<DefineTrace>false</DefineTrace>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<DefineTrace>false</DefineTrace>
@@ -106,6 +106,8 @@
<HintPath>..\..\EgtProg\OmagVIEWPlus\Sharp7.net.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System" />
@@ -117,6 +119,7 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="Application.xaml">
@@ -132,9 +135,30 @@
</Compile>
<Compile Include="Constants\ConstGen.vb" />
<Compile Include="Constants\ConstIni.vb" />
<Compile Include="EgtStoneLib\CamAuto.vb" />
<Compile Include="EgtStoneLib\ConstMach.vb" />
<Compile Include="EgtStoneLib\EstCalc.vb" />
<Compile Include="EgtStoneLib\GeomCalc.vb" />
<Compile Include="EgtStoneLib\VacuumCups.vb" />
<Compile Include="GridBox\GridBoxesV.xaml.vb">
<DependentUpon>GridBoxesV.xaml</DependentUpon>
</Compile>
<Compile Include="GridBox\GridBoxesVM.vb" />
<Compile Include="GridStorage\WarehouseV.xaml.vb">
<DependentUpon>WarehouseV.xaml</DependentUpon>
</Compile>
<Compile Include="MainWindow\Part.vb" />
<Compile Include="MySceneHost\SceneWindowV.xaml.vb">
<DependentUpon>SceneWindowV.xaml</DependentUpon>
</Compile>
<Compile Include="MySceneHost\MySceneHostVM.vb" />
<Compile Include="MySceneHost\SceneWindowVM.vb" />
<Compile Include="NCCommunication\Nc_Debug.vb" />
<Compile Include="NCCommunication\Nc_Parent.vb" />
<Compile Include="NCCommunication\Nc_Siemens.vb" />
<Compile Include="SceneHost\SceneHostV.xaml.vb">
<DependentUpon>SceneHostV.xaml</DependentUpon>
</Compile>
<Compile Include="UnloadingArea\UnloadingAreaV.xaml.vb">
<DependentUpon>UnloadingAreaV.xaml</DependentUpon>
</Compile>
@@ -145,9 +169,10 @@
<Compile Include="Utility\Enums.vb" />
<Compile Include="Utility\Map.vb" />
<Compile Include="NCCommunication\NCCommunication.vb" />
<Compile Include="Utility\Utility.vb" />
<Compile Include="Warehouse\Box.vb" />
<Compile Include="Warehouse\WarehouseV.xaml.vb">
<DependentUpon>WarehouseV.xaml</DependentUpon>
<Compile Include="Warehouse\BoxV.xaml.vb">
<DependentUpon>BoxV.xaml</DependentUpon>
</Compile>
<Compile Include="Warehouse\WarehouseVM.vb" />
</ItemGroup>
@@ -213,10 +238,26 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="GridBox\GridBoxesV.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="GridStorage\WarehouseV.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow\MainWindowV.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MySceneHost\SceneWindowV.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SceneHost\SceneHostV.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="UnloadingArea\UnloadingAreaV.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -225,7 +266,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Warehouse\WarehouseV.xaml">
<Page Include="Warehouse\BoxV.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
@@ -270,6 +311,12 @@
<ItemGroup>
<Resource Include="Resources\OmagVIEWPlus.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\RedArrow.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\WhiteArrow.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<PropertyGroup>
<PostBuildEvent>IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\OmagVIEWPlus\OmagVIEWPlusR32.exe
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

+25
View File
@@ -0,0 +1,25 @@
<UserControl x:Class="SceneHostV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:EgtUILib="clr-namespace:EgtUILib;assembly=EgtUILib">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<DockPanel HorizontalAlignment="Right" Grid.Row="1">
<Button Content="Confirm" Width="100"
Visibility="{Binding VisibilityManulaPartCommand}"
Command="{Binding ConfirmManualPart_Command}"/>
<ToggleButton Content="LayOut" Width="100"
IsChecked="{Binding IsLayoutCheched}"/>
</DockPanel>
<WindowsFormsHost Grid.Row="0">
<EgtUILib:Scene x:Name="MainScene"/>
</WindowsFormsHost>
</Grid>
</UserControl>
+22
View File
@@ -0,0 +1,22 @@
Imports System.Windows.Interop
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class SceneHostV
Private m_SceneHostVM As MySceneHostVM
Sub New()
' This call is required by the designer.
InitializeComponent()
' Assegno al riferimento locale al VM il VM preso dal DataContext
Me.DataContext = Map.refSceneHostVM
m_SceneHostVM = DirectCast(Me.DataContext, MySceneHostVM)
m_SceneHostVM.SetMainScene(MainScene)
MainScene.SetStatusNull()
'MainScene.SetObjFilterForSel(False, False, True, False, False)
'EgtSetObjFilterForSelect(False, False, True, False, False)
End Sub
End Class
+75 -57
View File
@@ -1,67 +1,85 @@
<Grid x:Class="UnloadingAreaV"
<UserControl x:Class="UnloadingAreaV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:OmagVIEWPlus="clr-namespace:OmagVIEWPlus"
xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.2*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<ItemsControl ItemsSource="{Binding WarehouseList}"
Grid.Row="1">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="1" Rows="2"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<OmagVIEWPlus:WarehouseV/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.2*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image Source="/Resources/Nastro.png"
Stretch="UniformToFill"
Grid.ColumnSpan="2"
Margin="10"/>
<!--Magazzino-->
<!--<UniformGrid Grid.Row="1" Columns="1" Rows="2">
<OmagVIEWPlus:WarehouseV DataContext="{Binding WarehouseA}"/>
<OmagVIEWPlus:WarehouseV DataContext="{Binding WarehouseB}"/>
</UniformGrid>-->
<ItemsControl ItemsSource="{Binding WarehouseList}"
Grid.Row="1" Grid.RowSpan="3">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="1" Rows="2"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<OmagVIEWPlus:WarehouseV/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Image Source="/Resources/Tavola1.png"
Stretch="Uniform"
Grid.Row="1" Grid.Column="1"
Margin="10"/>
<!--Tappeto-->
<Image Source="/Resources/Nastro.png"
Stretch="UniformToFill"
Grid.ColumnSpan="2"
ToolTip="{Binding InfoRuller}"
Margin="10"/>
<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}"/>
<TextBlock Text="{Binding TableDifference}"
Grid.ColumnSpan="2"
Style="{StaticResource CounterPercentageTextBlock}"/>
<!--comandi per selezioni tavola-->
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1" >
<ToggleButton VerticalAlignment="Top"
Margin="10, 20, 0, 0" Height="35" Width="100"
Content="{Binding ManualUnload}"
IsChecked="{Binding IsChecked_Manual}"/>
<TextBlock Text="{Binding TextReserve}"
TextAlignment="Center"
Padding="8"
Margin="10, 20, 0, 0" Height="35" Width="Auto"
Visibility="{Binding VisibilityTextReserve}"/>
</StackPanel>
<!--<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Table1Counter}"
Grid.Column="1"
Style="{StaticResource CounterPercentageTextBlock}"/>
</Grid>
<!--Tavola-->
<Image Source="/Resources/Tavola1.png"
Stretch="Uniform"
Grid.Row="2" Grid.Column="1"
ToolTip="{Binding InfoTable1}"
Margin="10"/>
<Image Source="{Binding Table1ArrowImage}"
Grid.Row="2" Grid.Column="1"
Stretch="None" VerticalAlignment="Center" Margin="141.2,170.4,-140.6,180.2"/>
<TextBlock Text="{Binding Table1Percentage}"
Grid.Row="2" Grid.Column="1"
Style="{StaticResource CounterPercentageTextBlock}" VerticalAlignment="Center"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Table2Counter}"
Style="{StaticResource CounterPercentageTextBlock}"/>
</Grid>-->
<TextBlock Text="{Binding Table1Percentage}"
Grid.Column="1" Grid.Row="1"
Style="{StaticResource CounterPercentageTextBlock}"/>
</Grid>
<!--comandi per simulazione test-->
<DockPanel HorizontalAlignment="Right" Height="35" Width="100"
Grid.Row="3" Grid.Column="1">
<ToggleButton Content="Machine" Grid.Row="0"
IsChecked="{Binding refScenaIsChecked}"/>
</DockPanel>
</Grid>
</UserControl>
+17 -1
View File
@@ -1,3 +1,19 @@
Public Class UnloadingAreaV
Imports System.Windows.Interop
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class UnloadingAreaV
Private m_UnloadingAreaVM As UnloadingAreaVM
Sub New()
' La chiamata è richiesta dalla finestra di progettazione.
InitializeComponent()
' Assegno al riferimento locale al VM il VM preso dal DataContext
Me.DataContext = Map.refUnloadingAreaVM
End Sub
End Class
+689 -25
View File
@@ -5,13 +5,44 @@ Imports EgtWPFLib5
Public Class UnloadingAreaVM
Inherits VMBase
'-----------------------------------------------------------------------------------------
' non è più utilizzato perchè sono solo due oggetti!
Private m_WarehouseList As New ObservableCollection(Of WarehouseVM)
Public ReadOnly Property WarehouseList As ObservableCollection(Of WarehouseVM)
Get
Return m_WarehouseList
End Get
End Property
'-----------------------------------------------------------------------------------------
' definsice se deve ricalcolato la disposizione dei pezzi nel magazzino
Private m_bOrganizeWarehouse As Boolean = False
Public Property bOrganizeWarehouse As Boolean
Get
Return m_bOrganizeWarehouse
End Get
Set(value As Boolean)
m_bOrganizeWarehouse = value
End Set
End Property
'' magazzino A: contiene 3 GridBox per un totale di 6 pallet e 3 rack
'Private m_WarehouseA As WarehouseVM
'Public ReadOnly Property WarehouseA As WarehouseVM
' Get
' Return m_WarehouseA
' End Get
'End Property
'' magazzino A: contiene 3 GridBox per un totale di 6 pallet e 3 rack
'Private m_WarehouseB As WarehouseVM
'Public ReadOnly Property WarehouseB As WarehouseVM
' Get
' Return m_WarehouseB
' End Get
'End Property
' indica il magazzino attivo (letto dalla macchina)
Private m_ActiveWarehouse As Warehouses
Public ReadOnly Property ActiveWarehouse As Warehouses
Get
@@ -19,13 +50,332 @@ Public Class UnloadingAreaVM
End Get
End Property
Private m_Table1CurrRow As Integer
Private m_Table1NRow As Integer
Public ReadOnly Property Table1Percentage As String
' attendo la definizione dei pezzi manuali
Private m_IsChecked_Manual As Boolean = False
Public Property IsChecked_Manual As Boolean
Get
Return DoubleToString(m_Table1CurrRow / m_Table1NRow * 100, 0) & "%"
' se la lastra è prenotata e non ci sono pezzi sul tavolo
If m_IsChecked_Manual AndAlso GetParts(Place.ON_TABLE).Count = 0 Then
Map.refSceneHostVM.MainScene.SetObjFilterForSel(False, False, True, False, False)
Else
Map.refSceneHostVM.MainScene.SetStatusNull()
End If
Return m_IsChecked_Manual
End Get
Set(value As Boolean)
m_IsChecked_Manual = value
NotifyPropertyChanged("ManualUnload")
NotifyPropertyChanged("VisibilityTextReserve")
NotifyPropertyChanged("IsChecked_Manual")
End Set
End Property
#Region "PARTS"
' elenco pezzi da scaricare (già ordinati) definita dalla funzione: CamAuto/MyUpdateVacuumsForUnloading()
Private m_ListPart As New List(Of Part)
Friend Property ListPart As List(Of Part)
Get
Return m_ListPart
End Get
Set(value As List(Of Part))
m_ListPart = value
End Set
End Property
' salvo locamente il pezzo correntemente manipolato dallo scaricatore
Private m_CurrPartTable1 As Part
Public Property CurrPartTable1 As Part
Get
Return m_CurrPartTable1
End Get
Set(value As Part)
m_CurrPartTable1 = value
End Set
End Property
' salvo locamente il pezzo correntemente manipolato dal pallettizzatore
Private m_CurrPartTable2 As Part
Public Property CurrPartTable2 As Part
Get
Return m_CurrPartTable2
End Get
Set(value As Part)
m_CurrPartTable2 = value
End Set
End Property
' salvo localmente l'ultimo Box utilizzato nel magazzino
Private m_CurrBox As Box
Public Property CurrBox As Box
Get
Return m_CurrBox
End Get
Set(value As Box)
m_CurrBox = value
End Set
End Property
' salvo l'IdProj attualmente in lavorazione sulla tavola 2
Private m_IdProjTable2 As New Proj(-1)
Public Property IdProjTable2 As Proj
Get
Return m_IdProjTable2
End Get
Set(value As Proj)
m_IdProjTable2 = value
End Set
End Property
#End Region ' PARTS
#Region "OFFSET PALLET/RACK"
' quanto fuori dalle corse devono essere posizionati i pezzi per determinare le giuste ventose
Private m_OffsetRullerX As Double = 0
Public ReadOnly Property OffsetRullerX As Double
Get
Return m_OffsetRullerX
End Get
End Property
Private m_OffsetRullerY As Double = 0
Public ReadOnly Property OffsetRullerY As Double
Get
Return m_OffsetRullerY
End Get
End Property
' le origini dei pallet sono in basso a siniatra (nel piano xy), gli offset restituiscono il centro
Private m_OffsetPalletX As Double = 0
Public ReadOnly Property OffsetPalletX As Double
Get
Return m_OffsetPalletX
End Get
End Property
Private m_OffsetPalletY As Double = 0
Public ReadOnly Property OffsetPalletY As Double
Get
Return m_OffsetPalletY
End Get
End Property
Private m_OffsetPalletZ As Double = 0
Public ReadOnly Property OffsetPalletZ As Double
Get
Return m_OffsetPalletZ
End Get
End Property
' le origini sono in mezzo al rack (nel piano xy)
Private m_OffsetRackX As Double = 0
Public ReadOnly Property OffsetRackX As Double
Get
Return m_OffsetRackX
End Get
End Property
Private m_OffsetRackY As Double = 0
Public ReadOnly Property OffsetRackY As Double
Get
Return m_OffsetRackY
End Get
End Property
Private m_OffsetRackZ As Double = 0
Public ReadOnly Property OffsetRackZ As Double
Get
Return m_OffsetRackZ
End Get
End Property
Private m_AngRack As Double
Public ReadOnly Property AngRack As Double
Get
Return m_AngRack
End Get
End Property
' altezza massima sul pallet
Private m_MaxHeight As Double
Public ReadOnly Property MaxHeight As Double
Get
Return m_MaxHeight
End Get
End Property
' lunghezza massima caricabile su pallet
Private m_MaxLength As Double
Public ReadOnly Property MaxLength As Double
Get
Return m_MaxLength
End Get
End Property
' larghezza massima caricabile su pallet
Private m_MaxWidth As Double
Public ReadOnly Property MaxWidth As Double
Get
Return m_MaxWidth
End Get
End Property
' numero massimo di pezzi su rack
Private m_MaxTile As Integer
Public ReadOnly Property MaxTile As Integer
Get
Return m_MaxTile
End Get
End Property
#End Region ' Offset pallet/rack
#Region "PROPERTIES"
' bottone per la selezione della scena
Public Property refScenaIsChecked As Boolean
Get
Return Map.refMainWindowVM.SceneIsChecked
End Get
Set(value As Boolean)
Map.refMainWindowVM.SceneIsChecked = value
End Set
End Property
' notifico nella grafica la percentuale di pezzi presenti sulla tavola
Public ReadOnly Property Table1Percentage As String
Get
' numero di pezzi buoni rimasti sulla tavola
Dim nTable As Integer = GetParts(Place.ON_TABLE).Count
' numero di pezzi scartati rimasti sulla tavola
Dim nWaist As Integer = GetParts(Place.ON_TABLE, StatusPart.WASTE).Count
' numero totale di pezzi da scaricare
Dim nTotal As Integer = GetParts(Place.ON_TABLE).Count + GetParts(Place.ON_TABLE, StatusPart.WASTE).Count
nTotal = nTotal + GetParts(Place.ON_MOTOR_RULLER).Count + GetParts(Place.ON_MOTOR_RULLER, StatusPart.WASTE).Count
nTotal = nTotal + GetParts(Place.ON_BOX).Count + GetParts(Place.ON_BOX, StatusPart.WASTE).Count
nTotal = nTotal + GetParts(Place.ON_MANUAL_BOX).Count + GetParts(Place.ON_MANUAL_BOX, StatusPart.WASTE).Count
' notifico anche la finestra delle info
NotifyPropertyChanged("InfoTable1")
If Map.refMainWindowVM.WaitingConfirmManualPart Then
Return "--"
End If
' restituisce la parcentula di pezzi prelevabili (esclusi quelli da scartare)
Return DoubleToString(If(nTotal = 0, 0, nTable / nTotal * 100), 0) & "%"
End Get
End Property
' notifico il numero di pezzi presenti sulla rulliera motorizzata (anche progetti diversi)
Public ReadOnly Property TableDifference As String
Get
NotifyPropertyChanged("InfoRuller")
Dim nCount As Integer = GetAllParts(Place.ON_MOTOR_RULLER).Count
nCount = nCount + GetAllParts(Place.ON_MOTOR_RULLER, StatusPart.NOT_LOADED).Count
Return DoubleToString(nCount, 0)
End Get
End Property
Public ReadOnly Property InfoTable1 As String
Get
Dim sInfo As String = String.Empty
sInfo &= "IdProj: " & Map.refMainWindowVM.MainWindowM.nProjInd.ToString
sInfo &= System.Environment.NewLine & "Counter Good: " & GetParts(Place.ON_TABLE).Count.ToString
sInfo &= System.Environment.NewLine & "Counter Waste: " & GetParts(Place.ON_TABLE, StatusPart.WASTE).Count.ToString
Return sInfo
End Get
End Property
Public ReadOnly Property InfoRuller As String
Get
Dim sInfo As String = String.Empty
sInfo &= "IdProj Table1: " & Map.refMainWindowVM.MainWindowM.nProjInd.ToString
sInfo &= System.Environment.NewLine & "Counter : " & GetParts(Place.ON_MOTOR_RULLER).Count.ToString
sInfo &= System.Environment.NewLine & "IdProj Table2: " & m_IdProjTable2.nProjInd
sInfo &= System.Environment.NewLine & "Counter Good: " & GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER).Count.ToString
' devo contare anche i pezzi da scaricare manualmente (ed emettere un messaggio di avviso)
sInfo &= System.Environment.NewLine & "Counter not unloadble: " & GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER, StatusPart.NOT_LOADED).Count.ToString
Return sInfo
End Get
End Property
' testo all'interno del bottone per la prenotazione
Private m_ManualUnload As String = String.Empty
Public ReadOnly Property ManualUnload As String
Get
If Not m_IsChecked_Manual Then
m_ManualUnload = "Reserve"
' se non sono nalla scena deseleziono tutto
If Not refScenaIsChecked Then
EgtDeselectAll()
End If
Else
m_ManualUnload = "Cancel"
End If
Return m_ManualUnload
End Get
End Property
' visibilità del testo a lato del bottone per la prenotazione
Private m_VisibilityTextReserve As Visibility = Visibility.Collapsed
Public ReadOnly Property VisibilityTextReserve As Visibility
Get
If Not m_IsChecked_Manual Then
m_VisibilityTextReserve = Visibility.Collapsed
Else
m_VisibilityTextReserve = Visibility.Visible
End If
Return m_VisibilityTextReserve
End Get
End Property
' messaggio di avvenuto prenotazione e conseguete stop di impianto
Private m_TextReserve As String = "Waiting selection manual part"
Public ReadOnly Property TextReserve As String
Get
Return m_TextReserve
End Get
End Property
' rendo visibile la freccia se: scarico manuale, pezzo non afferrabile
Private m_RullerArrowVisibility As Visibility = Visibility.Collapsed
Public Property RullerArrowVisibility As Visibility
Get
Return m_RullerArrowVisibility
End Get
Set(value As Visibility)
m_RullerArrowVisibility = value
NotifyPropertyChanged("RullerArrowVisibility")
NotifyPropertyChanged("RullerArrowImage")
End Set
End Property
Private m_RullerArrowImage As String = "/Resources/WhiteArrow.png"
Public ReadOnly Property RullerArrowImage As String
Get
If m_RullerArrowVisibility = Visibility.Visible Then
m_RullerArrowImage = "/Resources/RedArrow.png"
Else
m_RullerArrowImage = "/Resources/WhiteArrow.png"
End If
Return m_RullerArrowImage
End Get
End Property
' rendo visibile le freccia se: attesa di caricare la tavola
Private m_Table1ArrowVisibility As Visibility = Visibility.Collapsed
Public Property Table1ArrowVisibility As Visibility
Get
Return m_Table1ArrowVisibility
End Get
Set(value As Visibility)
m_Table1ArrowVisibility = value
NotifyPropertyChanged("Table1ArrowVisibility")
NotifyPropertyChanged("Table1ArrowImage")
End Set
End Property
Private m_Table1ArrowImage As String = "/Resources/WhiteArrow.png"
Public ReadOnly Property Table1ArrowImage As String
Get
If m_Table1ArrowVisibility = Visibility.Visible Then
m_Table1ArrowImage = "/Resources/RedArrow.png"
Else
m_Table1ArrowImage = "/Resources/WhiteArrow.png"
End If
Return m_Table1ArrowImage
End Get
End Property
#End Region ' PROPERTIES
Private m_TileType As Integer
Public ReadOnly Property TileType As String
@@ -40,17 +390,13 @@ Public Class UnloadingAreaVM
Return m_Table1Counter.ToString
End Get
End Property
Private m_Table2Counter As Integer
Public ReadOnly Property Table2Counter As String
Get
Return m_Table2Counter.ToString
End Get
End Property
Public ReadOnly Property TableDifference As String
Get
Return (m_Table1Counter - m_Table2Counter).ToString
End Get
End Property
Private m_TileThickness As Double
Public ReadOnly Property TileThickness As String
@@ -58,6 +404,7 @@ Public Class UnloadingAreaVM
Return LenToString(m_TileThickness, 1)
End Get
End Property
Private m_LastSlab As Boolean
Public ReadOnly Property LastSlab As Boolean
Get
@@ -65,11 +412,16 @@ Public Class UnloadingAreaVM
End Get
End Property
' definizione comandi
Private m_cmdChangeWarehouse As ICommand
Private m_cmdUnloadedWaistPart As ICommand
Private m_cmdUnloadedManualPart As ICommand
#Region "CONSTRUCTOR"
Sub New()
' Creo riferimento a questa classe in CompoWindowMap
Map.SetRefUnloadingAreaVM(Me)
Init()
m_WarehouseList.Add(New WarehouseVM(Warehouses.A))
m_WarehouseList.Add(New WarehouseVM(Warehouses.B))
End Sub
@@ -78,28 +430,31 @@ Public Class UnloadingAreaVM
#Region "METHODS"
' Modificato eliminando la lista m_WarehouseList
Friend Sub SetActiveWarehouse(ActiveWarehouse As Warehouses)
' verifico che il valore sia corretto, alrimenti assegno 0-> entrambi i magazzini sono disattivi
If ActiveWarehouse < 0 OrElse ActiveWarehouse > 2 Then
m_ActiveWarehouse = 0
Else
m_ActiveWarehouse = ActiveWarehouse
End If
' attivo il magazzino selezionato
If ActiveWarehouse = Warehouses.A Then
m_WarehouseList(GetWarehouseIndex(Warehouses.A)).SetIsActive(True)
m_WarehouseList(GetWarehouseIndex(Warehouses.B)).SetIsActive(False)
GetWarehouse(Warehouses.A).SetIsActive(True)
GetWarehouse(Warehouses.B).SetIsActive(False)
OutLogProcess("ActiveWarehouse() -> Attivo magazzino A")
ElseIf ActiveWarehouse = Warehouses.B Then
m_WarehouseList(GetWarehouseIndex(Warehouses.A)).SetIsActive(False)
m_WarehouseList(GetWarehouseIndex(Warehouses.B)).SetIsActive(True)
GetWarehouse(Warehouses.A).SetIsActive(False)
GetWarehouse(Warehouses.B).SetIsActive(True)
OutLogProcess("ActiveWarehouse() -> Attivo magazzino B")
Else
m_WarehouseList(GetWarehouseIndex(Warehouses.A)).SetIsActive(False)
m_WarehouseList(GetWarehouseIndex(Warehouses.B)).SetIsActive(False)
GetWarehouse(Warehouses.A).SetIsActive(False)
GetWarehouse(Warehouses.B).SetIsActive(False)
OutLogProcess("ActiveWarehouse() -> Disattivo magazzini A B")
End If
End Sub
Friend Sub SetWarehouse_IsPallet(Warehouse As Warehouses, IsPallet As Boolean)
m_WarehouseList(GetWarehouseIndex(Warehouse)).SetIsPallet(IsPallet)
End Sub
'--------------------------------------------------------------------------------------
Friend Sub SetBoxIsActive(BoxId As Integer)
If Not m_ActiveWarehouse > 0 AndAlso m_ActiveWarehouse <= 2 Then
m_WarehouseList(GetWarehouseIndex(Warehouses.A)).SetBoxIsActive(0)
@@ -135,11 +490,11 @@ Public Class UnloadingAreaVM
NotifyPropertyChanged("Table2Counter")
End Sub
Friend Sub SetTable1Percentage(Table1CurrRow As Integer, Table1NRow As Integer)
m_Table1CurrRow = Table1CurrRow
m_Table1NRow = Table1NRow
NotifyPropertyChanged("Table1Percentage")
End Sub
'Friend Sub SetTable1Percentage(Table1CurrRow As Integer, Table1NRow As Integer)
' m_Table1CurrRow = Table1CurrRow
' m_Table1NRow = Table1NRow
' NotifyPropertyChanged("Table1Percentage")
'End Sub
Friend Sub SetTileType(TyleType As Integer)
m_TileType = TyleType
@@ -166,6 +521,315 @@ Public Class UnloadingAreaVM
Return 0
End If
End Function
'--------------------------------------------------------------------------------------
#End Region ' METHODS
#Region "New METHODS"
Public Function Init() As Boolean
' verifico che siano state caricate correttamente le costanti
Dim bSetOffset As Boolean = SetOffset(K_PALLETX, m_OffsetPalletX) AndAlso
SetOffset(K_PALLETY, m_OffsetPalletY) AndAlso
SetOffset(K_PALLETZ, m_OffsetPalletZ) AndAlso
SetOffset(K_RACKX, m_OffsetRackX) AndAlso
SetOffset(K_RACKZ, m_OffsetRackZ) AndAlso
SetOffset(K_RACKY, m_OffsetRackY) AndAlso
SetOffset(K_ANGRACK, m_AngRack) AndAlso
SetOffset(K_RULLERX, m_OffsetRullerX) AndAlso
SetOffset(K_RULLERY, m_OffsetRullerY)
Dim bSetMaxPallet As Boolean = SetMaxPallet(K_MAX_HEIGHT, m_MaxHeight) AndAlso
SetMaxPallet(K_MAX_LENGTH, m_MaxLength) AndAlso
SetMaxPallet(K_MAX_WIDTH, m_MaxWidth)
Dim bSetMaxRack As Boolean = SetMaxTileRack(K_MAX_TILE, m_MaxTile)
Return bSetOffset And bSetMaxPallet And bSetMaxRack
End Function
' leggo dalla configurazione gli offset dei pallet e dei rack
Public Function SetOffset(sName As String, ByRef dVal As Double) As Boolean
Dim sVal As String = String.Empty
If GetMainPrivateProfileString(S_OFFSET, sName, "0", sVal) < 0 Then
EgtOutLog("Error reading file Config.ini [Offset] -> " & sName)
Return False
Else
If Not StringToLen(sVal, dVal) Then
EgtOutLog("Error reading file Config.ini [Offset] -> " & sName & " is not numeric")
Return False
End If
End If
Return True
End Function
' leggo le dimensioni massime caricabili su pallet
Public Function SetMaxPallet(ByVal sName As String, ByRef dVal As Double) As Boolean
Dim sVal As String = String.Empty
If GetMainPrivateProfileString(S_BOX, sName, "0", sVal) < 0 Then
EgtOutLog("Error reading file Config.ini [Box] -> " & sName)
Return False
Else
If Not StringToLen(sVal, dVal) Then
EgtOutLog("Error reading file Config.ini [Box] -> " & sName & " is not numeric")
Return False
End If
End If
Return True
End Function
' leggo del dimansioni massim e caricabili su rack
Public Function SetMaxTileRack(ByVal sName As String, ByRef nVal As Integer) As Boolean
Dim sVal As String = String.Empty
If GetMainPrivateProfileString(S_BOX, sName, "0", sVal) < 0 Then
EgtOutLog("Error reading file Config.ini [Box] -> " & sName)
Return False
Else
If Not IsNumeric(sVal) Then
EgtOutLog("Error reading file Config.ini [Box] -> " & sName & " is not numeric")
Return False
End If
End If
nVal = CInt(sVal)
Return True
End Function
' restituisco la lista di tutti i pezzi identificati dalla stessa posizione (di default quelli buoni) del progetto corrente
Public Function GetParts(DefinePlce As Place, Optional DefineStatus As StatusPart = StatusPart.GOOD) As ObservableCollection(Of Part)
Dim CurrList As New ObservableCollection(Of Part)
For Each Item In Map.refUnloadingAreaVM.ListPart
If Item.IdProject = Map.refMainWindowVM.MainWindowM.nProjInd And Item.enPlace = DefinePlce And DefineStatus = Item.enStatus Then
CurrList.Add(Item)
End If
Next
Return CurrList
End Function
' restituisco la lista di tutti i pezzi identificati dalla stessa posizione (di default quelli buoni) del progetto indicato
Public Function GetParts(IdProj As Integer, DefinePlce As Place, Optional DefineStatus As StatusPart = StatusPart.GOOD) As ObservableCollection(Of Part)
Dim CurrList As New ObservableCollection(Of Part)
For Each Item In Map.refUnloadingAreaVM.ListPart
If Item.IdProject = IdProj And Item.enPlace = DefinePlce And DefineStatus = Item.enStatus Then
CurrList.Add(Item)
End If
Next
Return CurrList
End Function
' restituisce la lista di tutti i pezzi identificati dalla stessa posizione (di default quelli buoni) di tutti i progetti caricati
Public Function GetAllParts(DefinePlce As Place, Optional DefineStatus As StatusPart = StatusPart.GOOD) As ObservableCollection(Of Part)
Dim CurrList As New ObservableCollection(Of Part)
For Each Item In Map.refUnloadingAreaVM.ListPart
If Item.enPlace = DefinePlce And DefineStatus = Item.enStatus Then
CurrList.Add(Item)
End If
Next
Return CurrList
End Function
Public Function GetWarehouse(WarehouseId As Warehouses) As WarehouseVM
For Each ItemWarehouse In m_WarehouseList
If ItemWarehouse.Id = WarehouseId Then Return ItemWarehouse
Next
Return Nothing
End Function
' restituisce il magazzino corrente, se nessun magazzino corrente restituisco nothing
Public Function GetCurrentWarehouse() As WarehouseVM
If ActiveWarehouse = Warehouses.A Then
Return GetWarehouse(Warehouses.A)
ElseIf ActiveWarehouse = Warehouses.B Then
Return GetWarehouse(Warehouses.B)
End If
Return Nothing
End Function
' quando si ha conferma dell'organizzazione del magazzino allora organizzo la pallettizzazione (false: mancano i Box)
Public Function OrganaizeWarehouse(Optional ByVal Me_Warehouse As WarehouseVM = Nothing) As Boolean
' Se il progetto è terminato (scarico dell'ultimo pezzo avvenuto)
If m_IdProjTable2.enStatus = StatusProj.DONE Then
' ricerco il primo proggetto in attesa di essere alaborato dalla tavola 2 (LOADING)
For Each ItemProj In Map.refMainWindowVM.MainWindowM.ProjIndList
If ItemProj.enStatus = StatusProj.LOADING Then
m_IdProjTable2 = ItemProj
Exit For
End If
Next
ElseIf Map.refMainWindowVM.MainWindowM.ProjIndList.Count = 0 Then
' se non ci sono progetti esco
Return True
ElseIf Map.refMainWindowVM.MainWindowM.ProjIndList.Count = 1 Then
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
' lista dei box disponibili (pallet/rack)
Dim nPallet As Integer = 0
Dim nRack As Integer = 0
Dim AvailablePalletList As New ObservableCollection(Of Box)
Dim AvailableRackList As New ObservableCollection(Of Box)
For Each ItemGridBox In CurrWarehause.GridBoxList
For Each ItemBox In ItemGridBox.CurrBoxList
If ItemBox.State = States.AVAILABLE Then
If ItemGridBox.IsPallet Then
AvailablePalletList.Add(ItemBox)
nPallet = nPallet + 1
Else
AvailableRackList.Add(ItemBox)
nRack = nRack + 1
End If
End If
Next
Next
' divido i pezzi in due liste (palle/rack) solo quelli con scarico automatico
Dim nPartOnPallet As Integer = 0
Dim nPartOnRack As Integer = 0
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)
If ItemPart.enUnloading = Unloading.AUTOMATIC Then
If ItemPart.MinRectX > m_MaxLength Or ItemPart.MinRectY > m_MaxWidth Then
RackPartList.Add(ItemPart)
nPartOnRack = nPartOnRack + 1
Else
PalletPartList.Add(ItemPart)
nPartOnPallet = nPartOnPallet + 1
End If
End If
Next
' tutti quelli ancora sul tavolo
For Each ItemPart In GetParts(m_IdProjTable2.nProjInd, Place.ON_TABLE)
If ItemPart.enUnloading = Unloading.AUTOMATIC Then
If ItemPart.MinRectX > m_MaxLength Or ItemPart.MinRectY > m_MaxWidth Then
RackPartList.Add(ItemPart)
nPartOnRack = nPartOnRack + 1
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
EgtOutLog("Warning: no parts for unloading")
Return True
End If
' verifico la presenza del numero minimo di rack: impossibile scaricare-> cambio magazzino
Dim nTemRack As Integer = CInt(Math.Ceiling(nPartOnRack / m_MaxTile))
If nTemRack > nRack Then
EgtOutLog("Error: needs rack for unloading some parts")
Return False
End If
' verifico numero di pallet necessari-> cambio magazzino
Dim nTemPallet As Integer = CInt(Math.Ceiling((nPartOnPallet * dHeightTile) / (m_MaxHeight)))
If nTemPallet > nPallet Then
EgtOutLog("Error: needs more pallets for unloading")
Return False
End If
' riempio i box con i part che ho trovato, partendo dai rack perchè sono i pezzi più grandi
For IndexPart = 0 To RackPartList.Count - 1
For IndexBox = 0 To nTemRack - 1
If IndexPart <= RackPartList.Count - 1 Then
RackPartList(IndexPart).IdBox = AvailableRackList(IndexBox).Id
RackPartList(IndexPart).enWarehouse = CurrWarehause.Id
AvailableRackList(IndexBox).MyListPart.Add(RackPartList(IndexPart))
IndexPart = IndexPart + 1
End If
If IndexPart > 0 Then
IndexPart = IndexPart - 1
End If
Next
Next
For IndexPart = 0 To PalletPartList.Count - 1
For IndexBox = 0 To nTemPallet - 1
If IndexPart <= PalletPartList.Count - 1 Then
PalletPartList(IndexPart).IdBox = AvailablePalletList(IndexBox).Id
PalletPartList(IndexPart).enWarehouse = CurrWarehause.Id
AvailablePalletList(IndexBox).MyListPart.Add(PalletPartList(IndexPart))
IndexPart = IndexPart + 1
End If
Next
If IndexPart > 0 Then
IndexPart = IndexPart - 1
End If
Next
OutLogProcess("OrganaizeWarehouse() -> Organizzato magazzino per progetto: " & m_IdProjTable2.nProjInd.ToString)
Return True
End Function
#End Region 'New METHODS
#Region "COMMANDS"
#Region "Confirm"
' Returns a command that manage the MainWindow_Unloaded command
Public ReadOnly Property UnloadedWaistPart_Command() As ICommand
Get
If m_cmdUnloadedWaistPart Is Nothing Then
m_cmdUnloadedWaistPart = New Command(AddressOf UnloadedWaistPart)
End If
Return m_cmdUnloadedWaistPart
End Get
End Property
' scarico tutti i pezzi rovinati rimasti sulla rulliera
Public Sub UnloadedWaistPart()
For Each ItemPart In GetParts(m_IdProjTable2.nProjInd, Place.ON_MOTOR_RULLER, StatusPart.NOT_LOADED)
ItemPart.enPlace = Place.ON_WASTE_BOX
Next
' Pezzi attualmente sulla rulliera motorizzata
NotifyPropertyChanged("TableDifference")
End Sub
#End Region ' Confirm
#Region "Unloaded"
Public ReadOnly Property UnloadedManualPart_Command() As ICommand
Get
If m_cmdUnloadedManualPart Is Nothing Then
m_cmdUnloadedManualPart = New Command(AddressOf UnloadedManualPart)
End If
Return m_cmdUnloadedManualPart
End Get
End Property
' 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)
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
OutLogProcess("UnloadedManualPart() -> Pezzi manuali scaricati")
OutLogProcess("UnloadedManualPart() -> Progetto terimnato: " & m_IdProjTable2.nProjInd.ToString)
' elimino il file ini associato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & Map.refUnloadingAreaVM.IdProjTable2.nProjInd.ToString & ".ini"
If My.Computer.FileSystem.FileExists(sFile) Then
My.Computer.FileSystem.DeleteFile(sFile)
OutLogProcess("UnloadedManualPart() -> Eliminato file: " & sFile)
End If
End Sub
#End Region ' Unloaded
#End Region ' COMMANDS
End Class
+25 -23
View File
@@ -206,10 +206,10 @@
</Style>
<Style x:Key="UnloadingArea_ToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource {x:Type ToggleButton}}">
<Setter Property="Margin" Value="25"/>
<Setter Property="Margin" Value="25,15,25,25"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="Background" Value="{StaticResource Omag_Green}"/>
<!--<Setter Property="Background" Value="{StaticResource Omag_Green}"/>-->
<Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="BorderThickness" Value="1"/>
@@ -221,24 +221,24 @@
<Border x:Name="border" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.MouseOver.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Omag_Red}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
</Trigger>
</ControlTemplate.Triggers>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.MouseOver.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.MouseOver.Border}"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Pressed.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger>
<!--<Trigger Property="IsChecked" Value="true">
<Setter Property="Background" TargetName="border" Value="{StaticResource Omag_Red}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Pressed.Border}"/>
</Trigger>-->
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="border" Value="{StaticResource Button.Disabled.Background}"/>
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource Button.Disabled.Border}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
@@ -359,8 +359,9 @@
<!-- DataTemplate per pallet e rack -->
<DataTemplate x:Key="PalletTemplate">
<ToggleButton IsChecked="{Binding State_IsChecked}"
<DataTemplate x:Key="PalletTemplate" x:Name="Pallet">
<ToggleButton Visibility="{Binding VisibilityPallet}"
IsChecked="{Binding State_IsChecked}"
Style="{StaticResource UnloadingArea_ToggleButton}">
<ToggleButton.Content>
<Grid>
@@ -377,7 +378,8 @@
</DataTemplate>
<DataTemplate x:Key="RackTemplate">
<ToggleButton IsChecked="{Binding State_IsChecked}"
<ToggleButton Visibility="{Binding VisibilityRack}"
IsChecked="{Binding State_IsChecked}"
Style="{StaticResource UnloadingArea_ToggleButton}">
<ToggleButton.Content>
<Grid>
+2 -2
View File
@@ -11,14 +11,14 @@
End Get
End Property
Private Shared m_Button_Static_Background As SolidColorBrush = New BrushConverter().ConvertFrom("#FFDDDDDD")
Private Shared m_Button_Static_Background As SolidColorBrush = DirectCast(New BrushConverter().ConvertFrom("#FFDDDDDD"), SolidColorBrush)
Public Shared ReadOnly Property Button_Static_Background As SolidColorBrush
Get
Return m_Button_Static_Background
End Get
End Property
Private Shared m_TabControl_Header_Background As LinearGradientBrush = Application.Current.FindResource("TabItem.Static.Background")
Private Shared m_TabControl_Header_Background As LinearGradientBrush = DirectCast(Application.Current.FindResource("TabItem.Static.Background"), LinearGradientBrush)
Public Shared ReadOnly Property TabControl_Header_Background As LinearGradientBrush
Get
Return m_TabControl_Header_Background
+60
View File
@@ -5,10 +5,70 @@
A = 2
End Enum
Public Enum ColumnsWarehouse As Integer
FIRST = 0
SECOND = 1
THIRD = 2
End Enum
Public Enum ConfigWarehose As Integer
PALLET = 0
RACK = 1
End Enum
Public Enum ConfigBox As Integer
PALLET = 0
RACK = 1
End Enum
Public Enum States As Integer
NOT_AVAILABLE = 0
AVAILABLE = 1
FULL = 2
LOADING = 3
End Enum
#Region "PART"
' decrizione della posizione del pezzo
Public Enum Place As Integer
ON_TABLE = 0
ON_MOTOR_RULLER = 1
ON_MANUAL_BOX = 2
ON_BOX = 3
ON_WASTE_BOX = 4
End Enum
' descrizione dello stato del pezzo
Public Enum StatusPart As Integer
GOOD = 0
WASTE = 1
NOT_LOADED = 2
End Enum
' descrizione del tipo di scarico del pezzo
Public Enum Unloading As Integer
AUTOMATIC = 0
MANUAL = 1
End Enum
#End Region ' PART
Public Enum StatusMachine As Integer
WAITING_POINT = 0
LOADED_POINT = 1
MOVING = 2
CHANGE_POINT = 3
EXCEPTION = 4
End Enum
Public Enum StatusProj As Integer
DONE = 0
WORKING = 1
WAITING = 2
LOADING = 3
End Enum
End Module
+24 -1
View File
@@ -4,6 +4,7 @@ Module Map
Private m_refMainWindowVM As MainWindowVM
Private m_refUnloadingAreaVM As UnloadingAreaVM
Private m_refSceneHostVM As SceneHostVM
#Region "Get"
@@ -19,6 +20,16 @@ Module Map
End Get
End Property
Public ReadOnly Property refSceneHostVM As SceneHostVM
Get
' bisogna usare la nuova funzione dell'EgtWPFLib5 che gestisce le liste di scene
If IsNothing(m_refSceneHostVM) Then
m_refSceneHostVM = LibMap.refSceneHostVM
End If
Return m_refSceneHostVM
End Get
End Property
#End Region ' Get
#Region "Set"
@@ -33,6 +44,11 @@ Module Map
Return Not IsNothing(m_refUnloadingAreaVM)
End Function
Friend Function SetRefSceneHostVM(SceneHostVM As SceneHostVM) As Boolean
LibMap.SetRefSceneHostVM(SceneHostVM)
Return Not IsNothing(LibMap.refSceneHostVM)
End Function
#End Region ' Set
#Region "Init"
@@ -41,9 +57,16 @@ Module Map
m_refMainWindowVM = MainWindowVM
Return Not IsNothing(m_refMainWindowVM)
End Function
Friend Function EndInit() As Boolean
' ripulisco il file di log dei processi
Try
My.Computer.FileSystem.DeleteFile(Map.refMainWindowVM.MainWindowM.sTempDir & "\ProcessLog.txt")
Catch ex As Exception
End Try
' Verifico se tutti i pezzi necessari sono stati caricati
Return Not IsNothing(m_refMainWindowVM) AndAlso Not IsNothing(m_refUnloadingAreaVM) ' AndAlso LibMap.EndInit()
Return Not IsNothing(m_refMainWindowVM) AndAlso Not IsNothing(m_refUnloadingAreaVM) AndAlso
Not IsNothing(LibMap.refSceneHostVM) ' AndAlso LibMap.EndInit()
End Function
#End Region ' Init
+194
View File
@@ -0,0 +1,194 @@
Imports EgtWPFLib5
Imports EgtUILib
Module Utility
Friend m_WarehouseIniFile As String = String.Empty
' leggo le informazioni del magazzino
Friend Function WarehauseGetPrivateProfileString(ByVal IpAppName As String, ByVal IpKeyName As String, ByVal IpDefault As String, ByRef IpString As String) As Integer
Return EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, m_WarehouseIniFile)
End Function
' scrivo le infomramzioni dle magazzino
Friend Function WarehauseWritePrivateProfileString(ByVal IpAppName As String, ByVal IpKeyName As String, ByRef IpString As String) As Boolean
Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, IpString, m_WarehouseIniFile)
End Function
' leggo le informazioni pezzi
Friend Function PartGetPrivateProfileString(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ByVal IpDefault As String, ByRef IpString As String) As Integer
' genero il file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
Return EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, sFile)
End Function
' leggo le informazioni pezzi
Friend Function PartGetPrivateProfileBoolean(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ByRef IpBoolean As Boolean) As Boolean
' genero il file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
Dim IpString As String = String.Empty
EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, "0", IpString, sFile)
IpBoolean = (IpString = "1")
Return IpBoolean
End Function
' leggo le informazioni pezzi
Friend Function PartGetPrivateProfileIntger(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ByRef IpIntger As Integer) As Integer
' genero il file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
IpIntger = EgtUILib.GetPrivateProfileInt(IpAppName, IpKeyName, IpIntger, sFile)
Return IpIntger
End Function
' leggo le informazioni pezzi
Friend Function PartGetPrivateProfileDouble(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ByRef IpDouble As Double) As Double
' genero il file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
IpDouble = EgtUILib.GetPrivateProfileDouble(IpAppName, IpKeyName, IpDouble, sFile)
Return IpDouble
End Function
' leggo le informazioni pezzi
Friend Function PartGetPrivateProfileVector(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ByRef vtVector As Vector3d) As Integer
' genero il file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
Dim sValue As String = String.Empty
EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, "", sValue, sFile)
Dim sItem As String() = sValue.Split(","c)
Dim x As Double = 0
If Not StringToDouble(sItem(0), x) Then Return -1
Dim y As Double = 0
If Not StringToDouble(sItem(1), y) Then Return -1
Dim z As Double = 0
If Not StringToDouble(sItem(2), z) Then Return -1
vtVector = New Vector3d(x, y, z)
Return 0
End Function
' leggo le informazioni pezzi
Friend Function PartGetPrivateProfilePoint(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ByRef ptPoint As Point3d) As Integer
' genero il file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
Dim sValue As String = String.Empty
EgtUILib.GetPrivateProfileString(IpAppName, IpKeyName, "", sValue, sFile)
Dim sItem As String() = sValue.Split(","c)
Dim x As Double = 0
If Not StringToDouble(sItem(0), x) Then Return -1
Dim y As Double = 0
If Not StringToDouble(sItem(1), y) Then Return -1
Dim z As Double = 0
If Not StringToDouble(sItem(2), z) Then Return -1
ptPoint = New Point3d(x, y, z)
Return 0
End Function
' scrivo le informazioni pezzi
Friend Function PartWritePrivateProfileString(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ByRef IpString As String) As Boolean
' genero il nome del file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
' se non esiste il file allora lo genero
If Not My.Computer.FileSystem.FileExists(sFile) Then
' creo il file ini del progetto
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(sFile, False)
file.WriteLine("; Commento per evitare BOM con UTF-8")
file.Close()
End If
Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, IpString, sFile)
End Function
' scrivo le informazioni pezzi
Friend Function PartWritePrivateProfileBoolean(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ByRef IpBoolean As Boolean) As Boolean
' genero il nome del file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
' se non esiste il file allora lo genero
If Not My.Computer.FileSystem.FileExists(sFile) Then
' creo il file ini del progetto
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(sFile, False)
file.WriteLine("; Commento per evitare BOM con UTF-8")
file.Close()
End If
Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, If(IpBoolean, "1", "0"), sFile)
End Function
' scrivo le informazioni pezzi
Friend Function PartWritePrivateProfileInt(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ByRef IpInteger As Integer) As Boolean
' genero il nome del file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
' se non esiste il file allora lo genero
If Not My.Computer.FileSystem.FileExists(sFile) Then
' creo il file ini del progetto
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(sFile, False)
file.WriteLine("; Commento per evitare BOM con UTF-8")
file.Close()
End If
Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, IpInteger.ToString, sFile)
End Function
' scrivo le informazioni pezzi
Friend Function PartWritePrivateProfileDouble(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ByRef IpDouble As Double) As Boolean
' genero il nome del file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
' se non esiste il file allora lo genero
If Not My.Computer.FileSystem.FileExists(sFile) Then
' creo il file ini del progetto
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(sFile, False)
file.WriteLine("; Commento per evitare BOM con UTF-8")
file.Close()
End If
Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, DoubleToString(IpDouble, 5), sFile)
End Function
' scrivo le informazioni pezzi
Friend Function PartWritePrivateProfileVector(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, vtVector As Vector3d) As Boolean
' genero il nome del file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
' se non esiste il file allora lo genero
If Not My.Computer.FileSystem.FileExists(sFile) Then
' creo il file ini del progetto
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(sFile, False)
file.WriteLine("; Commento per evitare BOM con UTF-8")
file.Close()
End If
Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, VectorToString(vtVector), sFile)
End Function
' scrivo le informazioni pezzi
Friend Function PartWritePrivateProfilePoint(ByRef IdProj As Integer, ByVal IpAppName As String, ByVal IpKeyName As String, ptPoint As Point3d) As Boolean
' genero il nome del file in funzione del progetto caricato
Dim sFile As String = Map.refMainWindowVM.MainWindowM.sTempDir & "\PartList" & IdProj.ToString & ".ini"
' se non esiste il file allora lo genero
If Not My.Computer.FileSystem.FileExists(sFile) Then
' creo il file ini del progetto
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(sFile, False)
file.WriteLine("; Commento per evitare BOM con UTF-8")
file.Close()
End If
Return EgtUILib.WritePrivateProfileString(IpAppName, IpKeyName, PointToString(ptPoint), sFile)
End Function
Public Function VectorToString(vtVector As Vector3d) As String
Dim sVector As String = String.Empty
sVector = DoubleToString(vtVector.x, 5) & " ," & DoubleToString(vtVector.y, 5) & " ," & DoubleToString(vtVector.z, 5)
Return sVector
End Function
Public Function PointToString(ptPoint As Point3d) As String
Dim sPoint As String = String.Empty
sPoint = ptPoint.x.ToString.Replace(","c, "."c) & " ," & ptPoint.y.ToString.Replace(","c, "."c) & " ," & ptPoint.z.ToString.Replace(","c, "."c)
Return sPoint
End Function
' scrivo in un file di testo le infomrazioni tutte le info che mi servono per studiare il percorso dei dati
Friend Sub OutLogProcess(sRow As String)
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(Map.refMainWindowVM.MainWindowM.sTempDir & "\ProcessLog.txt", True)
file.WriteLine(sRow)
file.Close()
End Sub
End Module
+221 -21
View File
@@ -5,35 +5,138 @@ Public Class Box
#Region "FIELDS & PROPERTIES"
' riferiento al bottone corrente
Private m_refBoxV As BoxV
' riferimento al magazzino corrente
Private m_refWarehouse As WarehouseVM
Private m_Id As Integer
#Region "PROPERTIES"
Private m_State As States
Public ReadOnly Property State As States
' Identificativo del pallet
Private m_Id As Integer
Public ReadOnly Property Id As Integer
Get
Return m_State
Return m_Id
End Get
End Property
' indice per la configurazione dell'origine del box: G500-> 500
Private m_OrigDefCN As Integer
Public ReadOnly Property OrigDefCN As Integer
Get
Return m_OrigDefCN
End Get
End Property
' immagine da caricare nel bottone
Private m_ImagePath As String
Public ReadOnly Property ImagePath As String
Get
Return m_ImagePath
End Get
End Property
' indice della colonna del magazzino
Private m_ColumnWarehouse As ColumnsWarehouse
Public ReadOnly Property ColumnWarehouse As ColumnsWarehouse
Get
Return m_ColumnWarehouse
End Get
End Property
' elenco dei pezzi che devono essere contenuti nel box
Private m_MyListPart As New List(Of Part)
Public Property MyListPart As List(Of Part)
Get
Return m_MyListPart
End Get
Set(value As List(Of Part))
m_MyListPart = value
End Set
End Property
' comandato dal click in interfaccia
Public Property State_IsChecked As Boolean
Get
Return (m_State <> States.AVAILABLE)
End Get
Set(value As Boolean)
' ripulisco la lista dei pezzi del box
m_MyListPart.Clear()
If value Then
m_State = States.NOT_AVAILABLE
Else
m_State = States.AVAILABLE
End If
' salvo le info nel file Warehouse.ini
WarehauseWritePrivateProfileString("Warehouse", "Box" & m_refWarehouse.Id.ToString & Id.ToString, CInt(m_State).ToString & " ,G" & m_OrigDefCN.ToString)
NotifyPropertyChanged("ImagePath")
NotifyPropertyChanged("BackGroundColor")
NotifyPropertyChanged("Image_Visibility")
NotifyPropertyChanged("nFillPercentage")
m_refWarehouse.NotifyPropertyChanged("VisibilityUnloadedBtn")
End Set
End Property
Private m_Livello As Integer
Private m_Fila As Integer
Private m_MaxLivello As Integer = 1
Private m_MaxFila As Integer = 1
' definisco il colore di sfondo in funzione dello stato del bottone
Private m_BackGroundColor As SolidColorBrush = DirectCast(New BrushConverter().ConvertFrom("LightGray"), SolidColorBrush)
Public ReadOnly Property BackGroundColor As SolidColorBrush
Get
Select Case m_State
Case States.AVAILABLE
m_BackGroundColor = DirectCast(New BrushConverter().ConvertFrom("LawnGreen"), SolidColorBrush)
Case States.FULL
m_BackGroundColor = DirectCast(New BrushConverter().ConvertFrom("Red"), SolidColorBrush)
Case States.NOT_AVAILABLE
m_BackGroundColor = DirectCast(New BrushConverter().ConvertFrom("LightGray"), SolidColorBrush)
End Select
Return m_BackGroundColor
End Get
End Property
Public ReadOnly Property InfoBox As String
Get
Dim sInfo As String = String.Empty
sInfo = "G" & m_OrigDefCN.ToString
Dim nPart As Integer = 0
Dim nIdProj As Integer = 0
For Each ItemPart In m_MyListPart
nIdProj = ItemPart.IdProject
If ItemPart.enPlace = Place.ON_BOX Then
nPart = nPart + 1
End If
Next
sInfo &= System.Environment.NewLine & "IdProj: " & nIdProj.ToString
sInfo &= System.Environment.NewLine & "Counter: " & nPart.ToString
Return sInfo
End Get
End Property
#End Region ' PROPERTIES
#Region "STATES"
' definizione del tipo di box
Private m_enConfigBox As ConfigBox
Friend ReadOnly Property enConfigBox As ConfigBox
Get
Return m_enConfigBox
End Get
End Property
' definizione dello stato del Box
Private m_State As States
Public Property State As States
Get
Return m_State
End Get
Set(value As States)
m_State = value
WarehauseWritePrivateProfileString("Warehouse", "Box" & m_refWarehouse.Id.ToString & Id.ToString, CInt(m_State).ToString & " ,G" & m_OrigDefCN.ToString)
NotifyPropertyChanged("State_IsChecked")
End Set
End Property
Private m_Warehouse_IsActive As Boolean
Private m_IsActive As Boolean = False
Friend ReadOnly Property IsActive As Boolean
Get
@@ -41,34 +144,75 @@ Public Class Box
End Get
End Property
#End Region ' STATES
Private m_Livello As Integer
Private m_Fila As Integer
Private m_MaxLivello As Integer = 1
Private m_MaxFila As Integer = 1
Private m_Warehouse_IsActive As Boolean
' valore pecentuale di riempimento del box
Private m_FillPercentage As Integer = 0
Public ReadOnly Property nFillPercentage As Integer
Get
Dim nPart As Integer = 0
Dim nPartOnBox As Integer = 0
' quando leggo la configurazione da file ini conosco solo lo satato, se lo stato è FULL ignoro le liste del box
If m_State <> States.FULL Then
For Each ItemPart In m_MyListPart
' conto il numero di pezzi attualmente depositati nel box
If ItemPart.enPlace = Place.ON_BOX Then
nPartOnBox = nPartOnBox + 1
End If
' conto il numero totale di pezzi sani da caricare nel box
If ItemPart.enStatus = StatusPart.GOOD Then
nPart = nPart + 1
End If
Next
m_FillPercentage = If(nPart > 0, CInt(nPartOnBox / nPart * 100), 0)
End If
' se raggiungo il massimo riempimento prevedibile allora comunico il nuovo stato
If m_FillPercentage = 100 Then
m_State = States.FULL
m_refWarehouse.SetCurrentWerahouse()
NotifyPropertyChanged("State")
End If
NotifyPropertyChanged("BackGroundColor")
Return m_FillPercentage
End Get
End Property
' messaggio a video del livello di riempimento del Box corrente
Public ReadOnly Property FillPercentage As String
Get
Return If(m_State = States.NOT_AVAILABLE, "--", m_FillPercentage & " %")
End Get
End Property
Private m_IsPallet As Boolean
Friend ReadOnly Property IsPallet As Boolean
Get
Return m_IsPallet
Dim Message As String = "--"
Select Case m_State
Case States.FULL
' definisco a video il livello di riempimento dedotto dallo stato FULL
m_FillPercentage = 100
Message = m_FillPercentage.ToString & " %"
Case States.LOADING
Message = m_FillPercentage.ToString & " %"
Case States.AVAILABLE
Message = m_FillPercentage.ToString & " %"
End Select
Return Message
End Get
End Property
' se il magazzino è ATTIVO (non è impiegato per lo scarico) allora nascondo le immagini dei pallet/rack
Public ReadOnly Property Percentage_Visibility As Visibility
Get
Return If(m_Warehouse_IsActive, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
' se il magazzino è DISATTIVO (non è impiegato per lo scarico) allora nascondo le immagini dei pallet/rack
Public ReadOnly Property Image_Visibility As Visibility
Get
Return If(Not m_Warehouse_IsActive, Visibility.Visible, Visibility.Collapsed)
Return If(Not m_Warehouse_IsActive And State <> States.NOT_AVAILABLE, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
@@ -76,17 +220,73 @@ Public Class Box
#Region "CONSTRUCTOR"
Sub New(nId As Integer, bIsPallet As Boolean, Warehouse As WarehouseVM)
Sub New(nId As Integer, enConfigBox As ConfigBox, Warehouse As WarehouseVM, enStatus As States, nOrigDef As Integer, enColumnWarehouse As ColumnsWarehouse)
m_Id = nId
m_IsPallet = bIsPallet
m_enConfigBox = enConfigBox
m_refWarehouse = Warehouse
m_State = States.AVAILABLE
m_State = enStatus
m_OrigDefCN = nOrigDef
m_ColumnWarehouse = enColumnWarehouse
If m_enConfigBox = ConfigBox.PALLET Then
m_ImagePath = "/Resources/Pallet.png"
Else
m_ImagePath = "/Resources/Rack.png"
End If
m_refBoxV = New BoxV
m_refBoxV.DataContext = Me
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
' restituisce l'altezza corrente del pallet
Public Function GetPalletOffsetZ() As Double
' recupero l'altezza del pallet
Dim dHeight As Double = 0
' inizializzo l'altezza di deposito con lo spessore del pezzo
For Each ItemPart In MyListPart
dHeight = ItemPart.Height
Exit For
Next
For Each ItemPart In MyListPart
If ItemPart.enPlace = Place.ON_BOX Then
dHeight = dHeight + ItemPart.Height
End If
Next
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
Dim dHeight As Double = 1
' inizializzo l'altezza di deposito con lo spessore del pezzo
For Each ItemPart In MyListPart
dHeight = ItemPart.Height
Exit For
Next
For Each ItemPart In MyListPart
If ItemPart.enPlace = Place.ON_BOX Then
nCounter = nCounter + 1
dHeight = ItemPart.Height
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
OffsetX = nCounter * OffsetX
Return OffsetX - MinRectY / 2 * Math.Cos(RadAngRack)
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
End Function
'--------------------------------------------------------------------------------------------------------------------
Friend Sub SetState(State As States)
m_State = State
Select Case m_State
+29
View File
@@ -0,0 +1,29 @@
<UserControl x:Class="BoxV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:OmagVIEWPlus"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="200">
<Grid>
<ToggleButton Grid.Row="1" Name="MyBox"
Visibility="{Binding VisibilityBtn}"
IsChecked="{Binding State_IsChecked}"
Background="{Binding BackGroundColor}"
ToolTip="{Binding InfoBox}"
Style="{StaticResource UnloadingArea_ToggleButton}">
<ToggleButton.Content>
<Grid>
<Image Source="{Binding ImagePath}"
Stretch="Uniform"
Visibility="{Binding Image_Visibility}"/>
<TextBlock Text="{Binding FillPercentage}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Visibility="{Binding Percentage_Visibility}"/>
</Grid>
</ToggleButton.Content>
</ToggleButton>
</Grid>
</UserControl>
+12
View File
@@ -0,0 +1,12 @@
Public Class BoxV
Private m_refBox As Box
Sub New()
' La chiamata è richiesta dalla finestra di progettazione.
InitializeComponent()
'm_refBox = refBox
'Me.DataContext = m_refBox
' Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent().
End Sub
End Class
-48
View File
@@ -1,48 +0,0 @@
<GroupBox x:Class="WarehouseV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:OmagVIEWPlus="clr-namespace:OmagVIEWPlus"
IsEnabled="{Binding IsEnabled}">
<GroupBox.Header>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Id}"
Margin="10,0,5,0"/>
<TextBlock Text="{Binding FillPercentage}"
Margin="5,0,10,0"
Visibility="{Binding FillPercentage_Visibility}"/>
</StackPanel>
</GroupBox.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid.Resources>
<OmagVIEWPlus:BoxTemplateSelector x:Key="BoxTemplateSelector"/>
</Grid.Resources>
<UniformGrid Columns="3">
<RadioButton Content="Pallet"
IsChecked="{Binding IsPallet}"
Style="{StaticResource OptionPanel_ToggleButton}"/>
<RadioButton Content="Rack"
IsChecked="{Binding NotIsPallet}"
Style="{StaticResource OptionPanel_ToggleButton}"/>
<Button Content="Confirm"
Command="{Binding Confirm_Command}"
Style="{StaticResource OptionPanel_TextButton}"/>
</UniformGrid>
<ItemsControl ItemsSource="{Binding Boxes}"
ItemTemplateSelector="{StaticResource BoxTemplateSelector}"
Grid.Row="1">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="3"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
</GroupBox>
+264 -63
View File
@@ -7,6 +7,9 @@ Public Class WarehouseVM
#Region "FIELDS & PROPERTIES"
Private m_GridBoxesV As GridBoxesV
' identificativo del magazzino: A=2, B=1
Private m_Id As Warehouses
Public ReadOnly Property Id As Warehouses
Get
@@ -14,6 +17,7 @@ Public Class WarehouseVM
End Get
End Property
' stato del magazzino (può essere disponibile ma non attivo)
Private m_State As States
Friend ReadOnly Property State As States
Get
@@ -21,30 +25,7 @@ Public Class WarehouseVM
End Get
End Property
Private m_IsPallet As Boolean
Public Property IsPallet As Boolean
Get
Return m_IsPallet
End Get
Set(value As Boolean)
If value <> m_IsPallet Then
CreateBoxList(value)
m_IsPallet = value
End If
End Set
End Property
Public Property NotIsPallet As Boolean
Get
Return Not m_IsPallet
End Get
Set(value As Boolean)
If value = m_IsPallet Then
CreateBoxList(Not value)
m_IsPallet = Not value
End If
End Set
End Property
' identifica se il magazzino corrente è attivo
Private m_IsActive As Boolean = True
Friend ReadOnly Property IsActive As Boolean
Get
@@ -52,21 +33,59 @@ Public Class WarehouseVM
End Get
End Property
' definisce il magazzino in uso-> disabilita le selezioni da interfaccia
Private m_IsEnable As Boolean = True
Public ReadOnly Property IsEnabled As Boolean
Get
'If m_IsActive Then
' Return False
'Else
' If m_State = States.AVAILABLE Then
' Return False
' Else
' Return True
' End If
'End If
Return Not (m_IsActive Or m_State = States.AVAILABLE)
m_IsEnable = Not (m_IsActive Or m_State = States.AVAILABLE)
Return m_IsEnable
End Get
End Property
'-----------------------------------------------------------------------------
' queste propprietà sono state spostate all'interno della GridBoxVM
Private m_Configuration As ConfigWarehose = ConfigWarehose.PALLET
Public ReadOnly Property Configuration As ConfigWarehose
Get
Return m_Configuration
End Get
End Property
' associato al bottone "Pallet"
Private m_IsPallet As Boolean
Public Property IsPallet As Boolean
Get
Return m_IsPallet
End Get
Set(value As Boolean)
If value Then
m_Configuration = ConfigWarehose.PALLET
m_IsPallet = value
m_IsRack = Not value
End If
NotifyPropertyChanged("IsRack")
End Set
End Property
' Associato al bottone "Rack"
Private m_IsRack As Boolean
Public Property IsRack As Boolean
Get
Return m_IsRack
End Get
Set(value As Boolean)
If value Then
m_Configuration = ConfigWarehose.RACK
m_IsRack = value
m_IsPallet = Not value
End If
NotifyPropertyChanged("IsPallet")
End Set
End Property
'-----------------------------------------------------------------------------
' lista dei Box contenuti nella Werahouse
Private m_Boxes As New ObservableCollection(Of Box)
Public Property Boxes As ObservableCollection(Of Box)
Get
@@ -77,31 +96,73 @@ Public Class WarehouseVM
End Set
End Property
Private m_nColumnWarehouse As Integer = 3
' lista delle colonne magazzino
Private m_GridBoxList As New ObservableCollection(Of GridBoxesVM)
Public ReadOnly Property GridBoxList As ObservableCollection(Of GridBoxesVM)
Get
Return m_GridBoxList
End Get
End Property
' configurazione colonne in magazzino-> utilizzato solo nella Init() per inizializzare le colonne
Private m_ConfigurationList As New ObservableCollection(Of ConfigWarehose)
' indice del Box attivo
Private m_ActiveBox_Index As Integer
' riferiento al Box attivo
Private m_ActiveBox As Box
' indica la media delle percentuali dei box riempiti
Public ReadOnly Property FillPercentage As String
Get
Dim Counter As Integer = 0
Dim Fill As Integer = 0
For Each Box In Boxes
If Box.State <> States.NOT_AVAILABLE Then
For Each ItemBox In Boxes
' conto tutti box disponibili e pieni, trascuro quelli non disponibili
If ItemBox.State <> States.NOT_AVAILABLE Then
Counter += 1
Fill += Box.nFillPercentage
Fill += ItemBox.nFillPercentage
ItemBox.NotifyPropertyChanged("FillPercentage")
End If
Next
Return DoubleToString(Fill / Counter, 0) & "%"
End Get
End Property
' se il magazzino è attivo allora mostro la media delle percentuali dei box
Public ReadOnly Property FillPercentage_Visibility As Visibility
Get
Return If(m_IsActive, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
' se il magazzino non è attivo allora può essere confermato
Private m_VisibilityConfirmBtn As Visibility = Visibility.Visible
Public ReadOnly Property VisibilityConfirmBtn As Visibility
Get
Return If(IsEnabled, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
' se il magazzino contiene almeno un box pieno allora rendo visibile il bottone
Private m_VisibilityUnloadedBtn As Visibility = Visibility.Visible
Public ReadOnly Property VisibilityUnloadedBtn As Visibility
Get
Dim bIsEmpty As Boolean = True
For Each Item In m_Boxes
If Item.State = States.FULL Then
bIsEmpty = False
Exit For
End If
Next
Return If(bIsEmpty Or Not IsEnabled, Visibility.Collapsed, Visibility.Visible)
End Get
End Property
' definizione comandi
Private m_cmdConfirm As ICommand
Private m_cmdUnloaded As ICommand
#End Region ' FIELDS & PROPERTIES
@@ -110,42 +171,54 @@ Public Class WarehouseVM
Sub New(nWarehouse As Warehouses)
m_Id = nWarehouse
NotifyPropertyChanged("Id")
' valore da leggere da macchina
IsPallet = True
' inizializzo il magazzino corrente
Init()
' definisco le colonne del magazzino
For IndexColumn = 0 To m_nColumnWarehouse - 1
Dim enColumn As ColumnsWarehouse = DirectCast(IndexColumn, ColumnsWarehouse)
Dim LocalGridBox As New GridBoxesVM(enColumn, Me, m_ConfigurationList(IndexColumn))
' costruisco la lista locale dei Box
For Each ItemBox In m_Boxes
If ItemBox.ColumnWarehouse = LocalGridBox.Column Then
LocalGridBox.BoxList.Add(ItemBox)
End If
Next
GridBoxList.Add(LocalGridBox)
m_GridBoxesV = New GridBoxesV
m_GridBoxesV.DataContext = LocalGridBox
Next
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Private Sub CreateBoxList(bIsPallet As Boolean)
m_Boxes.Clear()
' aggiungo i box
Dim nBox As Integer = If(bIsPallet, 6, 3)
For Index = 1 To nBox
Boxes.Add(New Box(Index, bIsPallet, Me))
Next
End Sub
' definisce lo stato del magazzino
Friend Sub SetState(State As States)
m_State = State
NotifyPropertyChanged("IsEnabled")
NotifyPropertyChanged("VisibilityConfirmBtn")
NotifyPropertyChanged("FillPercentage_Visibility")
End Sub
' definisce se il magazzino deve essere attivato
Friend Sub SetIsActive(bIsActive As Boolean)
m_IsActive = bIsActive
For Index = 0 To m_Boxes.Count - 1
m_Boxes(Index).SetWarehouse_IsActive(bIsActive)
Next
NotifyPropertyChanged("IsEnabled")
NotifyPropertyChanged("VisibilityConfirmBtn")
NotifyPropertyChanged("FillPercentage_Visibility")
End Sub
Friend Sub SetIsPallet(IsPallet As Boolean)
Me.IsPallet = IsPallet
NotifyPropertyChanged("IsPallet")
NotifyPropertyChanged("NotIsPallet")
Private Sub CreateBoxList(bIsPallet As Boolean)
m_Boxes.Clear()
' aggiungo i box
Dim nBox As Integer = If(bIsPallet, 6, 3)
For Index = 1 To nBox
'm_Boxes.Add(New Box(Index, bIsPallet, Me))
Next
End Sub
Friend Sub SetBoxState(Id As Integer, State As States)
@@ -226,22 +299,150 @@ Public Class WarehouseVM
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
Public Sub Confirm(ByVal param As Object)
m_State = States.AVAILABLE
' indico che il magazzino è disponibile per la macchine (non disponibile all'operatore)
SetState(States.AVAILABLE)
If IsNothing(Map.refUnloadingAreaVM.GetCurrentWarehouse) Then Map.refUnloadingAreaVM.SetActiveWarehouse(m_Id)
NotifyPropertyChanged("IsEnabled")
' Scrivo se magazzino è pallet o rack
Map.refMainWindowVM.m_CNCommunication.WriteInt("WStorage" & m_Id & "_IsPallet", If(m_IsPallet, 1, 0))
' Scrivo stati del magazzino non attivo
Dim MaxBoxX As Integer = If(m_IsPallet, 6, 3)
For BoxX As Integer = 1 To MaxBoxX
Dim nState As Integer = m_Boxes(ConvertBoxIndex(BoxX) - 1).State
Map.refMainWindowVM.m_CNCommunication.WriteInt("WStorage" & m_Id & "_Box" & BoxX & "_Stato", nState)
Next
' Scrivo stato del magazzino come disponibile
Map.refMainWindowVM.m_CNCommunication.WriteInt("WStorage" & m_Id & "_Stato", States.AVAILABLE)
' salvo la configurazione del magazzino
SetCurrentWerahouse()
End Sub
#End Region ' Confirm
#Region "Unloaded"
Public ReadOnly Property Unloaded_Command() As ICommand
Get
If m_cmdUnloaded Is Nothing Then
m_cmdUnloaded = New Command(AddressOf Unloaded)
End If
Return m_cmdUnloaded
End Get
End Property
' svuota il magazzino corrente da tutti i pezzi depositati sui palet
Public Sub Unloaded()
For Each ItemBox In Boxes
ItemBox.MyListPart.Clear()
' soltanto i box FULL tornano ad essere disponibili
Select Case ItemBox.State
Case States.FULL
ItemBox.State = States.AVAILABLE
End Select
' fino a quando non si riconferma la warehouse come disponibile aspetto
SetCurrentWerahouse()
NotifyPropertyChanged("FillPercentage")
NotifyPropertyChanged("VisibilityUnloadedBtn")
Next
End Sub
#End Region ' Unloaded
#End Region ' COMMANDS
#Region "New METHOD"
Public Function Init() As Boolean
GetCurrentWareHause()
Return True
End Function
' leggo la configurazione del magazzino corrente
Public Function GetCurrentWareHause() As Boolean
' leggo lo STATO del magazzino corrente
Dim sActive As String = String.Empty
If WarehauseGetPrivateProfileString(S_WAREHOUSE, K_ACTIVESTORAGE, "0", sActive) < 0 Then
EgtOutLog("Error reading file Config.ini [Warehause] -> ActiveStorage")
End If
m_IsActive = (Trim(sActive) = m_Id.ToString)
If m_IsActive Then
' significa che era stato confermato
m_State = States.AVAILABLE
End If
' leggo la CONFIGURAZIONE delle colonne del magazzino corrente
Dim sConfigWarehouse As String = String.Empty
For IndexColumn = 0 To m_nColumnWarehouse - 1
Dim Column As Integer = IndexColumn + 1
Dim x As String = "Column" & Column.ToString & K_STORAGE & m_Id.ToString
If WarehauseGetPrivateProfileString(S_WAREHOUSE, "Column" & Column.ToString & K_STORAGE & m_Id.ToString, "0", sConfigWarehouse) < 0 Then
EgtOutLog("Error reading file Config.ini [Warehause] -> ConfigStorage")
End If
If Trim(sConfigWarehouse) = "0" Then
m_ConfigurationList.Add(ConfigWarehose.PALLET)
Else
m_ConfigurationList.Add(ConfigWarehose.RACK)
End If
Next
' inizializzo l'elenco dei box da file Config
m_Boxes.Clear()
' inizio la lettura della configurazione da file Config.ini
For Index = 0 To 8
Dim IdBox = Index + 1
Dim sVal As String = String.Empty
Dim sName As String = K_BOX & m_Id.ToString & IdBox.ToString
If WarehauseGetPrivateProfileString(S_WAREHOUSE, sName, "0,0", sVal) < 0 Then
EgtOutLog("Error reading file Config.ini [Warehause] -> " & sName)
End If
Dim sItems As String() = sVal.Split(","c)
' definisco il TIPO di Box
Dim bIsPallet As Boolean = IdBox <= 6
Dim enStatus As States = States.NOT_AVAILABLE
' carico lo STATO del Box (di default non è disponibile)
If sItems.Count >= 1 And IsNumeric(sItems(0)) Then
enStatus = CType(CInt(sItems(0)), States)
End If
' carico la definizione della sua origine
Dim nOrig As Integer = 0
If sItems.Count >= 2 Then
Dim sOrig As String = sItems(1).Replace("G"c, "")
If IsNumeric(sOrig) Then
nOrig = CInt(sOrig)
Else
EgtOutLog("Error reading file Config.ini [Warehause] -> " & sName & ", wrong CN orig definition")
End If
End If
' definisco la colonna di appartenenza
Dim enColumnsWarehouse As ColumnsWarehouse = ColumnsWarehouse.THIRD
If IdBox <= 2 Or IdBox = 7 Then
enColumnsWarehouse = ColumnsWarehouse.FIRST
ElseIf IdBox = 3 Or IdBox = 4 Or IdBox = 8 Then
enColumnsWarehouse = ColumnsWarehouse.SECOND
End If
' aggiungo il Box creato alla lista (solo se appartiene alla configurazione)
Dim CurrBox As New Box(IdBox, If(bIsPallet, ConfigBox.PALLET, ConfigBox.RACK), Me, enStatus, nOrig, enColumnsWarehouse)
CurrBox.NotifyPropertyChanged("")
m_Boxes.Add(CurrBox)
Next
Return True
End Function
' salvo la configurazione attuale del magazzino
Public Function SetCurrentWerahouse() As Boolean
' salvo il nome del magazzino attivo
If m_IsActive Then
WarehauseWritePrivateProfileString(S_WAREHOUSE, K_ACTIVESTORAGE, m_Id.ToString)
End If
' salvo la configurazione attuale del magazzino
Dim Index As Integer = 1
For Each ItemGridBox In GridBoxList
WarehauseWritePrivateProfileString(S_WAREHOUSE, "Column" & Index.ToString & K_STORAGE & m_Id.ToString, If(ItemGridBox.IsPallet, "0", "1"))
Index = Index + 1
Next
' salvo la configurazione dei box
For Index = 0 To m_Boxes.Count - 1
Dim sName As String = K_BOX & m_Id.ToString & m_Boxes(Index).Id.ToString
' converto lo stato nell'indice associato
Dim nState As Integer = CInt(m_Boxes(Index).State)
Dim sInfo As String = nState.ToString & ", G" & m_Boxes(Index).OrigDefCN.ToString
WarehauseWritePrivateProfileString(S_WAREHOUSE, sName, sInfo)
Next
Return True
End Function
#End Region 'New METHOD
End Class