e2df14e44d
- migliorato splashscreen - eliminate classi spostate in Lib
109 lines
4.4 KiB
VB.net
109 lines
4.4 KiB
VB.net
Imports System.IO
|
|
Imports System.Windows.Threading
|
|
Imports Effector.Plugin.Lib
|
|
|
|
Public Class FiniteStateMachineManager
|
|
|
|
Private m_FiniteStateMachineTimer As New DispatcherTimer
|
|
|
|
Private m_FiniteStateMachineList As New List(Of FiniteStateMachine)
|
|
Friend ReadOnly Property FiniteStateMachineList As List(Of FiniteStateMachine)
|
|
Get
|
|
Return m_FiniteStateMachineList
|
|
End Get
|
|
End Property
|
|
|
|
Private m_PreProcPath As String = ""
|
|
Private m_PostProcPath As String = ""
|
|
|
|
Sub New()
|
|
LuaManager.SetGlobVar("EFFECTOR.DATADIR", Map.refMainWindowVM.MainWindowM.sDataRoot)
|
|
' leggo file inizializzazione variabili lua
|
|
Dim sLuaInitPath As String = ""
|
|
If GetMainPrivateProfileString(S_GENERAL, K_INITLUA, "", sLuaInitPath) > 0 Then
|
|
LuaManager.ExecFile(Map.refMainWindowVM.MainWindowM.sScriptDir & "\" & sLuaInitPath)
|
|
End If
|
|
'' leggo configurazioni
|
|
'Dim sPreProcName As String = ""
|
|
'If GetMainPrivateProfileString(S_GENERAL, K_PREPROC, "", sPreProcName) > 0 AndAlso
|
|
' Not String.IsNullOrWhiteSpace(sPreProcName) Then
|
|
' m_PreProcPath = Map.refMainWindowVM.MainWindowM.sScriptDir & "\" & sPreProcName
|
|
' If File.Exists(m_PreProcPath) Then
|
|
' ' lancio esecuzione file preprocessore
|
|
' LuaManager.SetGlobVar("PREPROC.ERROR", 0)
|
|
' LuaManager.SetGlobVar("PREPROC.ERROR_MSG", "")
|
|
' LuaManager.ExecFile(m_PreProcPath)
|
|
' Dim nError As Integer = 0
|
|
' If Not LuaManager.GetGlobVar("PREPROC.ERROR", nError) Then
|
|
' nError = 1
|
|
' End If
|
|
' If nError > 0 Then
|
|
' Dim sErrorMsg As String = ""
|
|
' If LuaManager.GetGlobVar("PREPROC.ERROR_MSG", sErrorMsg) Then
|
|
' EgtOutLog("Error in PreProc! #" & nError & ":" & sErrorMsg)
|
|
' End If
|
|
' End If
|
|
' End If
|
|
'End If
|
|
'Dim sPostProcName As String = ""
|
|
'If GetMainPrivateProfileString(S_GENERAL, K_POSTPROC, "", sPostProcName) > 0 AndAlso
|
|
' Not String.IsNullOrWhiteSpace(m_PostProcPath) Then
|
|
' m_PostProcPath = Map.refMainWindowVM.MainWindowM.sScriptDir & "\" & sPostProcName
|
|
' If File.Exists(m_PostProcPath) Then
|
|
' LuaManager.ExecFile(m_PostProcPath)
|
|
' End If
|
|
'End If
|
|
Dim nIndex As Integer = 1
|
|
Dim sMachineState As String = ""
|
|
While GetMainPrivateProfileString(S_GENERAL, K_MACHINESTATE & nIndex.ToString(), "", sMachineState) > 0
|
|
m_FiniteStateMachineList.Add(New FiniteStateMachine(sMachineState))
|
|
nIndex += 1
|
|
End While
|
|
|
|
' avvio timer macchine a stati
|
|
m_FiniteStateMachineTimer.Interval = New TimeSpan(500)
|
|
AddHandler m_FiniteStateMachineTimer.Tick, AddressOf FiniteStateMachineTimer_Tick
|
|
m_FiniteStateMachineTimer.Start()
|
|
End Sub
|
|
|
|
'Private m_bFiniteStateMachineExecuting As Boolean = False
|
|
|
|
Private Sub FiniteStateMachineTimer_Tick(sender As Object, e As EventArgs)
|
|
'If m_bFiniteStateMachineExecuting Then Return
|
|
'm_bFiniteStateMachineExecuting = True
|
|
' lancio esecuzione macchine a stati
|
|
For nMachineIndex = 0 To m_FiniteStateMachineList.Count - 1
|
|
If m_FiniteStateMachineList(nMachineIndex).bLuaExecuted Then
|
|
LuaManager.ExecLuaFunction("MACHINE" & (nMachineIndex + 1).ToString() & "_Tick", -1, Nothing)
|
|
End If
|
|
Next
|
|
|
|
'' lancio esecuzione preprocessore
|
|
'LuaManager.SetGlobVar("PREPROC.ERROR", 0)
|
|
'LuaManager.SetGlobVar("PREPROC.ERROR_MSG", "")
|
|
'LuaManager.ExecLuaFunction("PREPROC_Tick", -1, Nothing)
|
|
'Dim nError As Integer = 0
|
|
'If Not LuaManager.GetGlobVar("PREPROC.ERROR", nError) Then
|
|
' nError = 1
|
|
'End If
|
|
'If nError > 0 Then
|
|
' Dim sErrorMsg As String = ""
|
|
' If LuaManager.GetGlobVar("PREPROC.ERROR_MSG", sErrorMsg) Then
|
|
' EgtOutLog("Error in PreProc! #" & nError & ":" & sErrorMsg)
|
|
' End If
|
|
'End If
|
|
' lancio esecuzione postprocessore
|
|
'LuaManager.ExecLuaFunction("Tick", -1, Nothing)
|
|
'm_bFiniteStateMachineExecuting = False
|
|
End Sub
|
|
|
|
Friend Sub ResetFiniteStateMachineTimer()
|
|
If Not IsNothing(m_FiniteStateMachineTimer) AndAlso m_FiniteStateMachineTimer.IsEnabled Then
|
|
m_FiniteStateMachineTimer.Stop()
|
|
RemoveHandler m_FiniteStateMachineTimer.Tick, AddressOf FiniteStateMachineTimer_Tick
|
|
m_FiniteStateMachineTimer = Nothing
|
|
End If
|
|
End Sub
|
|
|
|
End Class
|