319 lines
10 KiB
VB.net
319 lines
10 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class SimulTabVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
' Definizione comandi
|
|
Private m_cmdToolMode As ICommand
|
|
Private m_cmdHeadMode As ICommand
|
|
Private m_cmdMachMode As ICommand
|
|
|
|
#Region "Messages"
|
|
|
|
Public ReadOnly Property MachViewMsg As String
|
|
Get
|
|
Return EgtMsg(91667)
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property EstimationMsg As String
|
|
Get
|
|
Return EgtMsg(91668)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' Messages
|
|
|
|
#Region "ToolTip"
|
|
|
|
Public ReadOnly Property OneStepToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATION + 8)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property PlayPauseToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATION + 9)
|
|
End Get
|
|
End Property
|
|
Public ReadOnly Property StopHomeToolTip As String
|
|
Get
|
|
Return EgtMsg(MSG_SIMULATION + 10)
|
|
End Get
|
|
End Property
|
|
|
|
#End Region ' ToolTip
|
|
|
|
Private m_MySimul As MySimulation
|
|
Public Property MySimul As MySimulation
|
|
Get
|
|
Return m_MySimul
|
|
End Get
|
|
Set(value As MySimulation)
|
|
m_MySimul = value
|
|
NotifyPropertyChanged("MySimul")
|
|
End Set
|
|
End Property
|
|
|
|
Private m_MyEstim As MyEstimations
|
|
Public Property MyEstim As MyEstimations
|
|
Get
|
|
Return m_MyEstim
|
|
End Get
|
|
Set(value As MyEstimations)
|
|
m_MyEstim = value
|
|
NotifyPropertyChanged("MyEstim")
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in OmagOFFICEMap
|
|
OmagOFFICEMap.SetRefSimulTabVM(Me)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub Refresh(PrevMeasureUnit As MeasureUnitOpt)
|
|
|
|
End Sub
|
|
|
|
Friend Sub InitSimulation()
|
|
' Qua dentro viene inizializzato il contenuto di SimulTab, quindi sia la parte della Simulazione che quella delle Stime
|
|
|
|
MySimul = New MySimulation
|
|
MyEstim = New MyEstimations
|
|
|
|
EgtSetCurrentContext(OmagOFFICEMap.refSceneHostVM.MainScene.GetCtx())
|
|
' Disabilito Machine Panel (utensili, lavoraz...)
|
|
OmagOFFICEMap.refMachinePanelVM.MachPanel_IsEnabled = False
|
|
' Deseleziono pezzi
|
|
EgtDeselectAll()
|
|
VeinMatching.OnDeselectAll()
|
|
' L'attrezzaggio utensili è verificato all'avvio simulazione (con attrezzaggio salvato)
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Aggiorno flag per lavaggio
|
|
EstCalc.UpdateWashingFlag()
|
|
' Se non c'è ordine delle lavorazioni, ne faccio uno automatico
|
|
Dim bOk As Boolean = True
|
|
If Not EstCalc.GetOrderMachiningFlag() Then
|
|
ResetAllMachinings()
|
|
bOk = SortAllMachinings()
|
|
If bOk Then EstCalc.SetOrderMachiningFlag()
|
|
Dim bModif As Boolean = TestAllMachiningsForStrict()
|
|
If bModif Then
|
|
' Ridotte alcune lavorazioni per evitare interferenze
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90321), 3, MSG_TYPE.WARNING)
|
|
Else
|
|
' Aggiornate tutte le lavorazioni
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90399), 3, MSG_TYPE.INFO)
|
|
End If
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Disabilito impostazione modificato
|
|
EgtDisableModified()
|
|
' Aggiorno le lavorazioni
|
|
bOk = UpdateAllMachiningsToolpaths() And bOk
|
|
' Aggiorno posizionamento ventose sui pezzi per eventuali tagli da sotto con lama
|
|
bOk = UpdateVacuumsForDrip() And bOk
|
|
' Se errore in generazione, segnalo l'errore
|
|
If Not bOk Then
|
|
' Errore nella generazione del programma CN
|
|
OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90314), MSG_TYPE.ERROR_)
|
|
End If
|
|
' Eseguo la stima di tempi, lunghezze ...
|
|
Dim bEstim As Boolean = (GetPrivateProfileInt(S_MACH_ESTIMATIONS, K_ENABLEEST, 0, CurrentMachine.sMachIniFile) <> 0)
|
|
If bEstim Then
|
|
MyEstim.Estimation_IsEnabled = True
|
|
EgtSetCurrPhase(1)
|
|
EgtEstimate(OmagOFFICEMap.refMainWindowVM.MainWindowM.sTempDir & "\MachProj.html", "OmagCut ver." & OmagOFFICEMap.refMainWindowVM.MainWindowM.sVersion)
|
|
Else
|
|
MyEstim.Estimation_IsEnabled = False
|
|
End If
|
|
' Impostazioni box stime
|
|
MyEstim.NotifyPropertyChanged("Time")
|
|
MyEstim.NotifyPropertyChanged("CutLen")
|
|
MyEstim.NotifyPropertyChanged("NetArea")
|
|
MyEstim.NotifyPropertyChanged("Usage")
|
|
' Nascondo eventuali pezzi in parcheggio
|
|
HideParkedParts()
|
|
' Nascondo eventuale contorno da foto
|
|
EstPhoto.ShowContour(False)
|
|
' Imposto prima fase
|
|
EgtSetCurrPhase(1)
|
|
ShowAllCurrPhaseMachinings()
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
'Cambio la vista della scena
|
|
EgtSetView(VT.ISO_SE, False)
|
|
MySimul.SetMachLook(MCH_LOOK.ALL)
|
|
EgtSetMachineLook(MySimul.GetMachLook())
|
|
EgtZoom(ZM.ALL)
|
|
' Avvio ambiente di simulazione
|
|
If Not EgtSimInit() OrElse Not EgtSimStart() Then
|
|
If EgtGetLastMachMgrErrorId() <> 0 Then
|
|
Dim sErr As String = EgtGetLastMachMgrErrorString()
|
|
MessageBox.Show(sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
|
Else
|
|
MessageBox.Show(EgtMsg(MSG_MESSAGEBOX + 10), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error)
|
|
End If
|
|
End If
|
|
' Imposto stato corrente
|
|
MySimul.SetSimulationStatus(MCH_SIM_ST.UI_STOP)
|
|
MySimul.SetShowPlay(True)
|
|
MySimul.SetSliderX(GetMainPrivateProfileDouble(S_SIMUL, K_SLIDERX, 1))
|
|
Dim SliderVal As Double = GetMainPrivateProfileDouble(S_SIMUL, K_SLIDERVAL, 10)
|
|
MySimul.SliderValue = SliderVal
|
|
' Carico utensili specializzato
|
|
LoadCurrTools()
|
|
EgtDraw()
|
|
MySimul.ShowCncData()
|
|
MySimul.StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 14) ' Home
|
|
End Sub
|
|
|
|
Private Function LoadCurrTools() As Boolean
|
|
' Se macchina con cambio utensile non devo fare alcunché
|
|
If CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.TOOLCHANGER Then
|
|
Return True
|
|
End If
|
|
' Imposto la lama corrente
|
|
Dim sSaw As String = CurrentMachine.sCurrSaw
|
|
If Not EgtLoadTool("H1", 1, sSaw) Then
|
|
Return False
|
|
End If
|
|
' Imposto eventuale secondo utensile montato
|
|
If CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL Then
|
|
Dim sTool As String = CurrentMachine.sCurrDrill
|
|
If String.IsNullOrEmpty(sTool) Then sTool = CurrentMachine.sCurrMill
|
|
If Not String.IsNullOrEmpty(sTool) AndAlso Not EgtLoadTool("H1", 2, sTool) Then
|
|
Return False
|
|
End If
|
|
End If
|
|
Return True
|
|
End Function
|
|
|
|
Friend Sub ExitSimulation()
|
|
OmagOFFICEMap.refStatusBarVM.ClearOutputMessage()
|
|
' Mi assicuro di terminare la simulazione
|
|
MySimul.ResetSimulation()
|
|
' Ripristino visibilità standard
|
|
MySimul.SetMachLook(MCH_LOOK.TAB)
|
|
EgtSetMachineLook(MySimul.GetMachLook())
|
|
' Nascondo tutte le lavorazioni
|
|
CamAuto.HideAllMachinings()
|
|
' Abilito impostazione modificato
|
|
EgtEnableModified()
|
|
' Cambio la vista della scena
|
|
EgtSetView(VT.TOP, False)
|
|
EgtZoom(ZM.ALL)
|
|
' Riabilito Machine Panel (utensili, lavoraz...)
|
|
OmagOFFICEMap.refMachinePanelVM.MachPanel_IsEnabled = True
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "ToolModeCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property ToolModeCommand As ICommand
|
|
Get
|
|
If m_cmdToolMode Is Nothing Then
|
|
m_cmdToolMode = New Command(AddressOf ToolMode)
|
|
End If
|
|
Return m_cmdToolMode
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub ToolMode(ByVal param As Object)
|
|
' aggiorno lo stato
|
|
If MySimul.GetMachLook() <> MCH_LOOK.TAB_TOOL Then
|
|
MySimul.SetMachLook(MCH_LOOK.TAB_TOOL)
|
|
End If
|
|
' aggiorno lo stato della macchina e la sua visualizzazione
|
|
EgtSetMachineLook(MySimul.GetMachLook())
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' ToolModeCommand
|
|
|
|
#Region "HeadModeCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property HeadModeCommand As ICommand
|
|
Get
|
|
If m_cmdHeadMode Is Nothing Then
|
|
m_cmdHeadMode = New Command(AddressOf HeadMode)
|
|
End If
|
|
Return m_cmdHeadMode
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub HeadMode(ByVal param As Object)
|
|
' aggiorno lo stato
|
|
If MySimul.GetMachLook() <> MCH_LOOK.TAB_HEAD Then
|
|
MySimul.SetMachLook(MCH_LOOK.TAB_HEAD)
|
|
End If
|
|
' aggiorno lo stato della macchina e la sua visualizzazione
|
|
EgtSetMachineLook(MySimul.GetMachLook())
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' HeadModeCommand
|
|
|
|
#Region "MachModeCommand"
|
|
|
|
''' <summary>
|
|
''' Returns a command that create a new tool.
|
|
''' </summary>
|
|
Public ReadOnly Property MachModeCommand As ICommand
|
|
Get
|
|
If m_cmdMachMode Is Nothing Then
|
|
m_cmdMachMode = New Command(AddressOf MachMode)
|
|
End If
|
|
Return m_cmdMachMode
|
|
End Get
|
|
End Property
|
|
|
|
''' <summary>
|
|
''' Creata the new tool. This method is invoked by the NewCommand.
|
|
''' </summary>
|
|
Public Sub MachMode(ByVal param As Object)
|
|
' aggiorno lo stato
|
|
If MySimul.GetMachLook() <> MCH_LOOK.ALL Then
|
|
MySimul.SetMachLook(MCH_LOOK.ALL)
|
|
End If
|
|
' aggiorno lo stato della macchina e la sua visualizzazione
|
|
EgtSetMachineLook(MySimul.GetMachLook())
|
|
EgtDraw()
|
|
End Sub
|
|
|
|
#End Region ' MachModeCommand
|
|
|
|
#End Region ' COMMANDS
|
|
|
|
End Class
|