a0d7687214
- piccole modifiche per simulazione con Virtual Additive.
115 lines
4.3 KiB
VB.net
115 lines
4.3 KiB
VB.net
Imports System.Collections.ObjectModel
|
|
Imports System.IO
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class MySimulation
|
|
Inherits SimulationVM
|
|
|
|
#Region "FIELDS & PROPERTIES"
|
|
|
|
Public Overrides Property SliderValue As Double
|
|
Get
|
|
Return m_SliderValue
|
|
End Get
|
|
Set(value As Double)
|
|
If Math.Abs(value - m_SliderValue) > EPS_SMALL Then
|
|
m_SliderValue = value
|
|
EgtSimSetStep(m_SliderValue * GetSliderX())
|
|
NotifyPropertyChanged("SliderValue")
|
|
End If
|
|
End Set
|
|
End Property
|
|
|
|
#End Region ' FIELDS & PROPERTIES
|
|
|
|
#Region "CONSTRUCTOR"
|
|
|
|
Sub New()
|
|
SetPlayImagePath("/Resources/SimulationPanel/Play.png")
|
|
SetPauseImagePath("/Resources/SimulationPanel/Pause.png")
|
|
SetPauseMsg(EgtMsg(90561)) ' Pausa
|
|
SetStopMsg(EgtMsg(90562)) ' Simulazione interrotta
|
|
SetHomeMsg(EgtMsg(90564)) ' Home
|
|
End Sub
|
|
|
|
#End Region ' CONSTRUCTOR
|
|
|
|
#Region "METHODS"
|
|
|
|
Public Overrides Sub ExecSim()
|
|
EgtSimStart(False)
|
|
EgtSimSetStep(SliderValue * GetSliderX())
|
|
Dim nShowDataCounter As Integer = 0
|
|
While GetStatus() <> MCH_SIM_ST.UI_STOP
|
|
' Se simulazione in svolgimento
|
|
If GetStatus() = MCH_SIM_ST.UI_PLAY Or GetStatus() = MCH_SIM_ST.UI_STEP Then
|
|
' Eseguo movimento
|
|
Dim nMove As Integer
|
|
Dim bMove As Boolean = EgtSimMove(nMove)
|
|
' Se arrivato a fine step e sono in step
|
|
If bMove Then
|
|
If GetStatus() = MCH_SIM_ST.UI_STEP And nMove = MCH_SIM.END_STEP Then
|
|
' Imposto stato Pausa
|
|
SetSimulationStatus(MCH_SIM_ST.UI_PAUSE)
|
|
StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 11) ' Pausa
|
|
' Aggiornamenti per bottone Play/Pause
|
|
SetShowPlay(True)
|
|
NotifyPropertyChanged("PlayPauseImage")
|
|
End If
|
|
' Se movimento non riuscito
|
|
Else
|
|
SetSimulationStatus(MCH_SIM_ST.UI_STOP)
|
|
' Aggiornamenti per bottone Play/Pause
|
|
SetShowPlay(True)
|
|
NotifyPropertyChanged("PlayPauseImage")
|
|
' Abilito check VMill
|
|
VMill_IsEnabled = True
|
|
Select Case nMove
|
|
Case MCH_SIM.END_
|
|
StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 1) 'Simulazione completata
|
|
Case MCH_SIM.STOP_
|
|
' Simulazione fermata dall'utente (non necessita messaggio)
|
|
Case MCH_SIM.OUTSTROKE
|
|
Dim sInfo As String = String.Empty
|
|
EgtGetOutstrokeInfo(sInfo)
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATIONPAGEUC + 2) & " " & sInfo, EgtMsg(MSG_SIMULATIONPAGEUC + 5), MessageBoxButton.OK, MessageBoxImage.Stop) 'Extracorsa ...
|
|
Case MCH_SIM.DIR_ERR
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATIONPAGEUC + 3), EgtMsg(MSG_SIMULATIONPAGEUC + 5), MessageBoxButton.OK, MessageBoxImage.Stop) 'Direzione utensile irraggiungibile
|
|
Case Else
|
|
MessageBox.Show(EgtMsg(MSG_SIMULATIONPAGEUC + 4), EgtMsg(MSG_SIMULATIONPAGEUC + 5), MessageBoxButton.OK, MessageBoxImage.Stop) 'Errore
|
|
End Select
|
|
End If
|
|
' Aggiorno stato visualizzazione macchina (dipende anche da utensile)
|
|
UpdateMachView()
|
|
' Aggiorno visualizzazione
|
|
EgtDraw()
|
|
' Aggiorno dati CNC
|
|
ShowCncData()
|
|
Else
|
|
' Per evitare di ciclare rapidissimamente e consumare inutilmente CPU
|
|
System.Threading.Thread.Sleep(1)
|
|
End If
|
|
' Costringo ad aggiornare UI
|
|
UpdateUI()
|
|
End While
|
|
End Sub
|
|
|
|
Public Overrides Sub OnPostSetSimulationStatus(value As MCH_SIM_ST)
|
|
If Map.refMainWindowVM.MainWindowM.nUserLevel >= 5 AndAlso
|
|
(GetStatus() = MCH_SIM_ST.UI_PAUSE OrElse GetStatus() = MCH_SIM_ST.UI_STOP) Then
|
|
For Index = 0 To MachineAxisList.Count - 1
|
|
MachineAxisList(Index).IsReadOnlyAxesValue = False
|
|
Next
|
|
Else
|
|
For Index = 0 To MachineAxisList.Count - 1
|
|
MachineAxisList(Index).IsReadOnlyAxesValue = True
|
|
Next
|
|
End If
|
|
EgtSimSetUiStatus(GetStatus())
|
|
End Sub
|
|
|
|
#End Region ' METHODS
|
|
|
|
End Class
|