- commit iniziale
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
Imports System.IO
|
||||
Imports System.Windows.Threading
|
||||
|
||||
Public Class FiniteStateMachineManager
|
||||
|
||||
Private m_FiniteStateMachineTimer As New DispatcherTimer
|
||||
|
||||
Private m_FiniteStateMachineList As New List(Of FiniteStateMachine)
|
||||
|
||||
Private m_PreProcPath As String = ""
|
||||
Private m_PostProcPath As String = ""
|
||||
|
||||
Sub New()
|
||||
' 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 Sub FiniteStateMachineTimer_Tick(sender As Object, e As EventArgs)
|
||||
' lancio esecuzione macchine a stati
|
||||
For Each FiniteStateMachine In m_FiniteStateMachineList
|
||||
LuaManager.ExecLuaFunction("MACHINE1.Tick", -1, Nothing)
|
||||
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)
|
||||
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
|
||||
Reference in New Issue
Block a user