8d548dee9c
- bloccato altri comandi quando in simulazione
335 lines
10 KiB
VB.net
335 lines
10 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class SimulationPanelVM
|
|
Inherits VMBase
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Public Enum MachViews As Integer
|
|
TOOL = 0
|
|
HEAD = 1
|
|
MACHINE = 2
|
|
End Enum
|
|
|
|
Private m_dPrevAngVertDegView As Double
|
|
Private m_dPrevAngHorizDegView As Double
|
|
|
|
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_MachViewList As New List(Of String)({"Tool", "Head", "Machine"})
|
|
Public ReadOnly Property MachViewList As List(Of String)
|
|
Get
|
|
Return m_MachViewList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_nSelMachView As MachViews
|
|
Public Property nSelMachView As Integer
|
|
Get
|
|
Return m_nSelMachView
|
|
End Get
|
|
Set(value As Integer)
|
|
m_nSelMachView = value
|
|
Select Case m_nSelMachView
|
|
Case MachViews.TOOL
|
|
ToolMode()
|
|
Case MachViews.HEAD
|
|
HeadMode()
|
|
Case MachViews.MACHINE
|
|
MachMode()
|
|
End Select
|
|
End Set
|
|
End Property
|
|
Friend Sub SetSelMachView(value As MachViews)
|
|
nSelMachView = value
|
|
NotifyPropertyChanged(NameOf(nSelMachView))
|
|
End Sub
|
|
|
|
' Definizione comandi
|
|
Private m_cmdOk As ICommand
|
|
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 "View"
|
|
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
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
' Creo riferimento a questa classe in OmagOFFICEMap
|
|
Map.SetRefSimulationPanelVM(Me)
|
|
MySimul = New MySimulation
|
|
' leggo vista macchina da ini e la imposto
|
|
SetSelMachView(MachViews.MACHINE)
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Friend Sub Refresh(PrevMeasureUnit As MeasureUnitOpt)
|
|
|
|
End Sub
|
|
|
|
Friend Sub InitSimulation()
|
|
' Deseleziono tutto
|
|
EgtDeselectAll()
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
' Disabilito impostazione modificato
|
|
EgtDisableModified()
|
|
' Imposto prima fase
|
|
EgtSetCurrPhase(1)
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
'Cambio la vista della scena
|
|
EgtGetGenericView(m_dPrevAngVertDegView, m_dPrevAngHorizDegView)
|
|
EgtSetView(VT.ISO_SW, False)
|
|
MySimul.SetMachLook(MCH_LOOK.ALL)
|
|
EgtSetMachineLook(MySimul.GetMachLook())
|
|
' Nascondo griglia
|
|
EgtSetGridShow(False, False)
|
|
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
|
|
MySimul.ShowCncData()
|
|
MySimul.StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 14) ' Home
|
|
' nascondo slider strati e layer da visualizzare
|
|
Map.refSliderManagerVM.SetSliderVisibility(False)
|
|
Map.refViewLayerManagerVM.SetViewLayerManagerVisibility(False)
|
|
' disattivo comandi progetto
|
|
Map.refProjManagerVM.SetProjCmdIsEnabled(False)
|
|
' disabilito ProjManager, TopPanel, TFS, Slider, bottoni e uscita dal programma
|
|
Map.refProjManagerVM.SetProjCmdIsEnabled(False)
|
|
Map.refTopPanelVM.SetTopPanelIsEnabled(False)
|
|
Map.refViewLayerManagerVM.SetViewLayerManagerIsEnabled(False)
|
|
Map.refSliceManagerVM.SetButtonsIsEnabled(False)
|
|
Map.refSliderManagerVM.SetLayerIndexIsEnabled(False)
|
|
Map.refSliderManagerVM.SetLayerAdvancementIsEnabled(False)
|
|
Map.refInstrumentPanelVM.SetEdgeAnalysisIsEnabled(False)
|
|
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()
|
|
Map.refMyStatusBarVM.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()
|
|
' Ripristino vista griglia
|
|
EgtSetGridShow(True, True)
|
|
' Cambio la vista della scena
|
|
EgtSetGenericView(m_dPrevAngVertDegView, m_dPrevAngHorizDegView, False)
|
|
EgtZoom(ZM.ALL)
|
|
' mostro slider strati e layer da visualizzare
|
|
Map.refSliderManagerVM.SetSliderVisibility(True)
|
|
Map.refViewLayerManagerVM.SetViewLayerManagerVisibility(True)
|
|
' disattivo comandi progetto
|
|
Map.refProjManagerVM.SetProjCmdIsEnabled(True)
|
|
' riabilito ProjManager, TopPanel, TFS, Slider, bottoni e uscita dal programma
|
|
Map.refProjManagerVM.SetProjCmdIsEnabled(True)
|
|
Map.refTopPanelVM.SetTopPanelIsEnabled(True)
|
|
Map.refViewLayerManagerVM.SetViewLayerManagerIsEnabled(True)
|
|
Map.refSliceManagerVM.SetButtonsIsEnabled(True)
|
|
Map.refSliderManagerVM.SetLayerIndexIsEnabled(True)
|
|
Map.refSliderManagerVM.SetLayerAdvancementIsEnabled(True)
|
|
Map.refInstrumentPanelVM.SetEdgeAnalysisIsEnabled(True)
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
#Region "COMMANDS"
|
|
|
|
#Region "Ok"
|
|
|
|
Public ReadOnly Property Ok_Command As ICommand
|
|
Get
|
|
If m_cmdOk Is Nothing Then
|
|
m_cmdOk = New Command(AddressOf Ok)
|
|
End If
|
|
Return m_cmdOk
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub Ok()
|
|
' reset gruppo
|
|
EgtResetCurrMachGroup()
|
|
' eseguo script di uscita da gruppo corrente
|
|
Map.refSliceManagerVM.ExecExitMachScript()
|
|
' ripristino modalita' standard
|
|
Map.refTopPanelVM.SelPage = Pages.SLICE
|
|
End Sub
|
|
|
|
#End Region ' Ok
|
|
|
|
#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()
|
|
' 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()
|
|
' 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()
|
|
' 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
|