- corretto indici lista macchine
- eliminate chiamate di test da gestore macchine a stati - anticipata caricamento comunicazione macchine rispetto alle macchine a stati - allungato counter di esecuzione processi lanciati - aggiunto dictionary - iniziata gestione finestra custom
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Supervisor">
|
||||
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
<ResourceDictionary Source="Utility/Dictionary.xaml"/>
|
||||
</Application.Resources>
|
||||
|
||||
</Application>
|
||||
|
||||
@@ -11,28 +11,14 @@ Public Class MachineManager
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_Machine1 As NC.NC_generic
|
||||
Public ReadOnly Property Machine1 As NC.NC_generic
|
||||
Get
|
||||
Return m_Machine1
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_Machine2 As NC.NC_generic
|
||||
Public ReadOnly Property Machine2 As NC.NC_generic
|
||||
Get
|
||||
Return m_Machine2
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Sub New()
|
||||
End Sub
|
||||
|
||||
Sub Init()
|
||||
If GetMainPrivateProfileInt(S_NC, K_NC_SIMULATE, 0) = 1 Then
|
||||
Dim nMachineIndex As Integer = 1
|
||||
Dim nMachineIndex As Integer = 0
|
||||
Dim sMachine As String = ""
|
||||
While GetMainPrivateProfileString(S_NC, K_MACHINE & nMachineIndex.ToString(), "", sMachine) > 0
|
||||
While GetMainPrivateProfileString(S_NC, K_MACHINE & (nMachineIndex + 1).ToString(), "", sMachine) > 0
|
||||
Dim NewSimulatedMachine As New NC.Simulated
|
||||
NewSimulatedMachine.Connect("")
|
||||
m_MachineList(nMachineIndex) = NewSimulatedMachine
|
||||
@@ -60,8 +46,11 @@ Public Class MachineManager
|
||||
End Sub
|
||||
|
||||
Sub Close()
|
||||
m_Machine1.Disconnect()
|
||||
m_Machine2.Disconnect()
|
||||
For Each Machine In m_MachineList
|
||||
If Not IsNothing(Machine) Then
|
||||
Machine.Disconnect()
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
@@ -16,36 +16,36 @@ Public Class FiniteStateMachineManager
|
||||
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
|
||||
'' 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
|
||||
@@ -59,27 +59,32 @@ Public Class FiniteStateMachineManager
|
||||
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 Each FiniteStateMachine In m_FiniteStateMachineList
|
||||
LuaManager.ExecLuaFunction("MACHINE1_Tick", -1, Nothing)
|
||||
For nMachineIndex = 0 To m_FiniteStateMachineList.Count - 1
|
||||
LuaManager.ExecLuaFunction("MACHINE" & (nMachineIndex + 1).ToString() & "_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 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()
|
||||
|
||||
+344
-374
@@ -4,402 +4,372 @@ Imports System.IO
|
||||
|
||||
Public Module Lua_General
|
||||
|
||||
' Lock per scrittura file di log
|
||||
Private m_Lock_OutLog As New Object
|
||||
' Lock per scrittura file di log
|
||||
Private m_Lock_OutLog As New Object
|
||||
|
||||
Private m_sLogPath As String
|
||||
Friend Sub SetLogPath(sPath As String)
|
||||
m_sLogPath = sPath
|
||||
End Sub
|
||||
Private m_sLogPath As String
|
||||
Friend Sub SetLogPath(sPath As String)
|
||||
m_sLogPath = sPath
|
||||
End Sub
|
||||
|
||||
' da eliminare quando arriva funzione di libreria!!
|
||||
Public Function EgtOutLog(sLogMsg As String) As Boolean
|
||||
SyncLock (m_Lock_OutLog)
|
||||
Using LogStreamWriter As StreamWriter = File.AppendText(m_sLogPath)
|
||||
LogStreamWriter.WriteLine(DateTime.Now.ToLongTimeString() & " " & sLogMsg)
|
||||
End Using
|
||||
End SyncLock
|
||||
Return True
|
||||
End Function
|
||||
' da eliminare quando arriva funzione di libreria!!
|
||||
Public Function EgtOutLog(sLogMsg As String) As Boolean
|
||||
SyncLock (m_Lock_OutLog)
|
||||
Using LogStreamWriter As StreamWriter = File.AppendText(m_sLogPath)
|
||||
LogStreamWriter.WriteLine(DateTime.Now.ToLongTimeString() & " " & sLogMsg)
|
||||
End Using
|
||||
End SyncLock
|
||||
Return True
|
||||
End Function
|
||||
|
||||
Friend func_EntIs64bit As LuaFunction = AddressOf Lua_EntIs64bit
|
||||
Friend func_EntOutLog As LuaFunction = AddressOf Lua_EntOutLog
|
||||
Friend func_EntExistsDirectory As LuaFunction = AddressOf Lua_EntExistsDirectory
|
||||
Friend func_EntCopyFile As LuaFunction = AddressOf Lua_EntCopyFile
|
||||
Friend func_EntGetIniFile As LuaFunction = AddressOf Lua_EntGetIniFile
|
||||
Friend func_EntGetDataDir As LuaFunction = AddressOf Lua_EntGetDataDir
|
||||
Friend func_EntGetNumberFromIni As LuaFunction = AddressOf Lua_EntGetNumberFromIni
|
||||
Friend func_EntGetStringFromIni As LuaFunction = AddressOf Lua_EntGetStringFromIni
|
||||
Friend func_EntWriteStringToIni As LuaFunction = AddressOf Lua_EntWriteStringToIni
|
||||
Friend func_EntExecProcess As LuaFunction = AddressOf Lua_ExecProcess
|
||||
Friend func_RdsStringGet As LuaFunction = AddressOf Lua_RdsStringGet
|
||||
Friend func_RdsStringSetAsync As LuaFunction = AddressOf Lua_RdsStringSetAsync
|
||||
Friend func_RdsPublishAsync As LuaFunction = AddressOf Lua_RdsPublishAsync
|
||||
Friend func_ComReadShortVar As LuaFunction = AddressOf Lua_ComReadShortVar
|
||||
Friend func_ComWriteShortVar As LuaFunction = AddressOf Lua_ComWriteShortVar
|
||||
Friend func_ComReadDoubleVar As LuaFunction = AddressOf Lua_ComReadDoubleVar
|
||||
Friend func_ComWriteDoubleVar As LuaFunction = AddressOf Lua_ComWriteDoubleVar
|
||||
Friend func_ComReadBitVar As LuaFunction = AddressOf Lua_ComReadBitVar
|
||||
Friend func_ComWriteBitVar As LuaFunction = AddressOf Lua_ComWriteBitVar
|
||||
Friend func_EntIs64bit As LuaFunction = AddressOf Lua_EntIs64bit
|
||||
Friend func_EntOutLog As LuaFunction = AddressOf Lua_EntOutLog
|
||||
Friend func_EntExistsDirectory As LuaFunction = AddressOf Lua_EntExistsDirectory
|
||||
Friend func_EntCopyFile As LuaFunction = AddressOf Lua_EntCopyFile
|
||||
Friend func_EntGetIniFile As LuaFunction = AddressOf Lua_EntGetIniFile
|
||||
Friend func_EntGetDataDir As LuaFunction = AddressOf Lua_EntGetDataDir
|
||||
Friend func_EntGetNumberFromIni As LuaFunction = AddressOf Lua_EntGetNumberFromIni
|
||||
Friend func_EntGetStringFromIni As LuaFunction = AddressOf Lua_EntGetStringFromIni
|
||||
Friend func_EntWriteStringToIni As LuaFunction = AddressOf Lua_EntWriteStringToIni
|
||||
Friend func_EntExecProcess As LuaFunction = AddressOf Lua_EntExecProcess
|
||||
Friend func_RdsStringGet As LuaFunction = AddressOf Lua_RdsStringGet
|
||||
Friend func_RdsStringSetAsync As LuaFunction = AddressOf Lua_RdsStringSetAsync
|
||||
Friend func_RdsPublishAsync As LuaFunction = AddressOf Lua_RdsPublishAsync
|
||||
Friend func_ComReadShortVar As LuaFunction = AddressOf Lua_ComReadShortVar
|
||||
Friend func_ComWriteShortVar As LuaFunction = AddressOf Lua_ComWriteShortVar
|
||||
Friend func_ComReadDoubleVar As LuaFunction = AddressOf Lua_ComReadDoubleVar
|
||||
Friend func_ComWriteDoubleVar As LuaFunction = AddressOf Lua_ComWriteDoubleVar
|
||||
Friend func_ComReadBitVar As LuaFunction = AddressOf Lua_ComReadBitVar
|
||||
Friend func_ComWriteBitVar As LuaFunction = AddressOf Lua_ComWriteBitVar
|
||||
|
||||
Private Function Lua_EntIs64bit(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
state.PushBoolean(Not IntPtr.Size = 4)
|
||||
Return 1
|
||||
End Function
|
||||
Private Function Lua_EntIs64bit(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
state.PushBoolean(Not IntPtr.Size = 4)
|
||||
Return 1
|
||||
End Function
|
||||
|
||||
Private Function Lua_EntOutLog(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 1 o 2 parametri : stringa da emettere [, DebugLevel = 0]
|
||||
Dim sLogMsg As String = ""
|
||||
Dim nDebugLevel As Integer = 0
|
||||
LuaCheckParam(state, 1, sLogMsg)
|
||||
LuaGetParam(state, 2, nDebugLevel)
|
||||
LuaClearStack(state)
|
||||
' accodo il messaggio nel file di log
|
||||
EgtOutLog(sLogMsg)
|
||||
' non c'è risultato
|
||||
Return 0
|
||||
End Function
|
||||
Private Function Lua_EntOutLog(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 1 o 2 parametri : stringa da emettere [, DebugLevel = 0]
|
||||
Dim sLogMsg As String = ""
|
||||
Dim nDebugLevel As Integer = 0
|
||||
LuaCheckParam(state, 1, sLogMsg)
|
||||
LuaGetParam(state, 2, nDebugLevel)
|
||||
LuaClearStack(state)
|
||||
' accodo il messaggio nel file di log
|
||||
EgtOutLog(sLogMsg)
|
||||
' non c'è risultato
|
||||
Return 0
|
||||
End Function
|
||||
|
||||
Private Function Lua_EntExistsDirectory(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 1 parametro : sDir
|
||||
Dim sDirectory As String = ""
|
||||
LuaCheckParam(state, 1, sDirectory)
|
||||
LuaClearStack(state)
|
||||
Dim bResult As Boolean
|
||||
Try
|
||||
' verifico esistenza direttorio
|
||||
bResult = Directory.Exists(sDirectory)
|
||||
Catch ex As Exception
|
||||
bResult = False
|
||||
EgtOutLog("Lua_EntExistsDirectory on " & sDirectory & " failed! " & ex.Message)
|
||||
End Try
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, bResult)
|
||||
Return 1
|
||||
End Function
|
||||
Private Function Lua_EntExistsDirectory(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 1 parametro : sDir
|
||||
Dim sDirectory As String = ""
|
||||
LuaCheckParam(state, 1, sDirectory)
|
||||
LuaClearStack(state)
|
||||
Dim bResult As Boolean
|
||||
Try
|
||||
' verifico esistenza direttorio
|
||||
bResult = Directory.Exists(sDirectory)
|
||||
Catch ex As Exception
|
||||
bResult = False
|
||||
EgtOutLog("Lua_EntExistsDirectory on " & sDirectory & " failed! " & ex.Message)
|
||||
End Try
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, bResult)
|
||||
Return 1
|
||||
End Function
|
||||
|
||||
Private Function Lua_EntCopyFile(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 2 parametri : sFile, sNewFile
|
||||
Dim sSourcePath As String = ""
|
||||
Dim sDestinationPath As String = ""
|
||||
LuaCheckParam(state, 1, sSourcePath)
|
||||
LuaCheckParam(state, 2, sDestinationPath)
|
||||
LuaClearStack(state)
|
||||
Dim bResult As Boolean
|
||||
Try
|
||||
' copio il file
|
||||
File.Copy(sSourcePath, sDestinationPath, True)
|
||||
bResult = True
|
||||
Catch ex As Exception
|
||||
bResult = False
|
||||
EgtOutLog("Lua_EntCopyFile from " & sSourcePath & " to " & sDestinationPath & " failed! " & ex.Message)
|
||||
End Try
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, bResult)
|
||||
Return 1
|
||||
End Function
|
||||
Private Function Lua_EntCopyFile(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 2 parametri : sFile, sNewFile
|
||||
Dim sSourcePath As String = ""
|
||||
Dim sDestinationPath As String = ""
|
||||
LuaCheckParam(state, 1, sSourcePath)
|
||||
LuaCheckParam(state, 2, sDestinationPath)
|
||||
LuaClearStack(state)
|
||||
Dim bResult As Boolean
|
||||
Try
|
||||
' copio il file
|
||||
File.Copy(sSourcePath, sDestinationPath, True)
|
||||
bResult = True
|
||||
Catch ex As Exception
|
||||
bResult = False
|
||||
EgtOutLog("Lua_EntCopyFile from " & sSourcePath & " to " & sDestinationPath & " failed! " & ex.Message)
|
||||
End Try
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, bResult)
|
||||
Return 1
|
||||
End Function
|
||||
|
||||
Private Function Lua_EntGetIniFile(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, IniFile.sPath)
|
||||
Return 1
|
||||
End Function
|
||||
Private Function Lua_EntGetIniFile(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, IniFile.sPath)
|
||||
Return 1
|
||||
End Function
|
||||
|
||||
Private Function Lua_EntGetDataDir(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, Map.refMainWindowVM.MainWindowM.sDataRoot)
|
||||
Return 1
|
||||
End Function
|
||||
Private Function Lua_EntGetDataDir(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, Map.refMainWindowVM.MainWindowM.sDataRoot)
|
||||
Return 1
|
||||
End Function
|
||||
|
||||
Private Function Lua_EntGetNumberFromIni(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 4 parametri: sSec, sKey, dDef, sIniFile
|
||||
Dim sSec As String = ""
|
||||
Dim sKey As String = ""
|
||||
Dim dDef As Integer = 0
|
||||
Dim sIniFile As String = ""
|
||||
LuaCheckParam(state, 1, sSec)
|
||||
LuaCheckParam(state, 2, sKey)
|
||||
LuaCheckParam(state, 3, dDef)
|
||||
LuaCheckParam(state, 4, sIniFile)
|
||||
LuaClearStack(state)
|
||||
Dim nResult As Integer = GetPrivateProfileInt(sSec, sKey, dDef, sIniFile)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, nResult)
|
||||
Return 1
|
||||
End Function
|
||||
Private Function Lua_EntGetNumberFromIni(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 4 parametri: sSec, sKey, dDef, sIniFile
|
||||
Dim sSec As String = ""
|
||||
Dim sKey As String = ""
|
||||
Dim dDef As Integer = 0
|
||||
Dim sIniFile As String = ""
|
||||
LuaCheckParam(state, 1, sSec)
|
||||
LuaCheckParam(state, 2, sKey)
|
||||
LuaCheckParam(state, 3, dDef)
|
||||
LuaCheckParam(state, 4, sIniFile)
|
||||
LuaClearStack(state)
|
||||
Dim nResult As Integer = GetPrivateProfileInt(sSec, sKey, dDef, sIniFile)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, nResult)
|
||||
Return 1
|
||||
End Function
|
||||
|
||||
Private Function Lua_EntGetStringFromIni(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 4 parametri: sSec, sKey, sDef, sIniFile
|
||||
Dim sSec As String = ""
|
||||
Dim sKey As String = ""
|
||||
Dim sDef As String = 0
|
||||
Dim sIniFile As String = ""
|
||||
LuaCheckParam(state, 1, sSec)
|
||||
LuaCheckParam(state, 2, sKey)
|
||||
LuaCheckParam(state, 3, sDef)
|
||||
LuaCheckParam(state, 4, sIniFile)
|
||||
LuaClearStack(state)
|
||||
Dim sResult As String = ""
|
||||
GetPrivateProfileString(sSec, sKey, sDef, sResult, sIniFile)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, sResult)
|
||||
Return 1
|
||||
End Function
|
||||
Private Function Lua_EntGetStringFromIni(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 4 parametri: sSec, sKey, sDef, sIniFile
|
||||
Dim sSec As String = ""
|
||||
Dim sKey As String = ""
|
||||
Dim sDef As String = 0
|
||||
Dim sIniFile As String = ""
|
||||
LuaCheckParam(state, 1, sSec)
|
||||
LuaCheckParam(state, 2, sKey)
|
||||
LuaCheckParam(state, 3, sDef)
|
||||
LuaCheckParam(state, 4, sIniFile)
|
||||
LuaClearStack(state)
|
||||
Dim sResult As String = ""
|
||||
GetPrivateProfileString(sSec, sKey, sDef, sResult, sIniFile)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, sResult)
|
||||
Return 1
|
||||
End Function
|
||||
|
||||
Private Function Lua_EntWriteStringToIni(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 4 parametri: sSec, sKey, sVal, sIniFile
|
||||
Dim sSec As String = ""
|
||||
Dim sKey As String = ""
|
||||
Dim sVal As Integer = 0
|
||||
Dim sIniFile As String = ""
|
||||
LuaCheckParam(state, 1, sSec)
|
||||
LuaCheckParam(state, 2, sKey)
|
||||
LuaCheckParam(state, 3, sVal)
|
||||
LuaCheckParam(state, 4, sIniFile)
|
||||
LuaClearStack(state)
|
||||
Dim bResult As Boolean = WritePrivateProfileString(sSec, sKey, sVal, sIniFile)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, bResult)
|
||||
Return 1
|
||||
End Function
|
||||
Private Function Lua_EntWriteStringToIni(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 4 parametri: sSec, sKey, sVal, sIniFile
|
||||
Dim sSec As String = ""
|
||||
Dim sKey As String = ""
|
||||
Dim sVal As Integer = 0
|
||||
Dim sIniFile As String = ""
|
||||
LuaCheckParam(state, 1, sSec)
|
||||
LuaCheckParam(state, 2, sKey)
|
||||
LuaCheckParam(state, 3, sVal)
|
||||
LuaCheckParam(state, 4, sIniFile)
|
||||
LuaClearStack(state)
|
||||
Dim bResult As Boolean = WritePrivateProfileString(sSec, sKey, sVal, sIniFile)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, bResult)
|
||||
Return 1
|
||||
End Function
|
||||
|
||||
Private Function Lua_RdsStringGet(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
If IsNothing(Map.refMainWindowVM.RedisManager) OrElse IsNothing(Map.refMainWindowVM.RedisManager.Subscriber) Then
|
||||
EgtOutLog("Error! Trying to get string from a non existent redis!")
|
||||
LuaSetParam(state)
|
||||
Return 1
|
||||
End If
|
||||
' 1 parametro: sKey
|
||||
Dim sKey As String = ""
|
||||
LuaCheckParam(state, 1, sKey)
|
||||
LuaClearStack(state)
|
||||
Dim Result As RedisValue
|
||||
Result = Map.refMainWindowVM.RedisManager.RedisDb.StringGet(sKey)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, Result)
|
||||
Return 1
|
||||
End Function
|
||||
Private Function Lua_RdsStringGet(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
If IsNothing(Map.refMainWindowVM.RedisManager) OrElse IsNothing(Map.refMainWindowVM.RedisManager.Subscriber) Then
|
||||
EgtOutLog("Error! Trying to get string from a non existent redis!")
|
||||
LuaSetParam(state)
|
||||
Return 1
|
||||
End If
|
||||
' 1 parametro: sKey
|
||||
Dim sKey As String = ""
|
||||
LuaCheckParam(state, 1, sKey)
|
||||
LuaClearStack(state)
|
||||
Dim Result As RedisValue
|
||||
Result = Map.refMainWindowVM.RedisManager.RedisDb.StringGet(sKey)
|
||||
' restituisco il risultato
|
||||
LuaSetParam(state, Result)
|
||||
Return 1
|
||||
End Function
|
||||
|
||||
Private Function Lua_RdsStringSetAsync(ByVal p As IntPtr) As Integer
|
||||
If IsNothing(Map.refMainWindowVM.RedisManager) OrElse IsNothing(Map.refMainWindowVM.RedisManager.Subscriber) Then
|
||||
EgtOutLog("Error! Trying to set string on a non existent redis!")
|
||||
Return 0
|
||||
End If
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 2 parametri: sKey, sVal
|
||||
Dim sKey As String = ""
|
||||
Dim sVal As String = 0
|
||||
LuaCheckParam(state, 1, sKey)
|
||||
LuaCheckParam(state, 2, sVal)
|
||||
LuaClearStack(state)
|
||||
Map.refMainWindowVM.RedisManager.RedisDb.StringSetAsync(sKey, sVal)
|
||||
Return 0
|
||||
End Function
|
||||
Private Function Lua_RdsStringSetAsync(ByVal p As IntPtr) As Integer
|
||||
If IsNothing(Map.refMainWindowVM.RedisManager) OrElse IsNothing(Map.refMainWindowVM.RedisManager.Subscriber) Then
|
||||
EgtOutLog("Error! Trying to set string on a non existent redis!")
|
||||
Return 0
|
||||
End If
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 2 parametri: sKey, sVal
|
||||
Dim sKey As String = ""
|
||||
Dim sVal As String = 0
|
||||
LuaCheckParam(state, 1, sKey)
|
||||
LuaCheckParam(state, 2, sVal)
|
||||
LuaClearStack(state)
|
||||
Map.refMainWindowVM.RedisManager.RedisDb.StringSetAsync(sKey, sVal)
|
||||
Return 0
|
||||
End Function
|
||||
|
||||
Private Function Lua_RdsPublishAsync(ByVal p As IntPtr) As Integer
|
||||
If IsNothing(Map.refMainWindowVM.RedisManager) OrElse IsNothing(Map.refMainWindowVM.RedisManager.Subscriber) Then
|
||||
EgtOutLog("Error! Trying to publish on a non existent redis!")
|
||||
Return 0
|
||||
End If
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 2 parametri: sKey, sVal
|
||||
Dim sChannel As String = ""
|
||||
Dim sMessage As String = 0
|
||||
LuaCheckParam(state, 1, sChannel)
|
||||
LuaCheckParam(state, 2, sMessage)
|
||||
LuaClearStack(state)
|
||||
Map.refMainWindowVM.RedisManager.Subscriber.PublishAsync(sChannel, sMessage)
|
||||
Return 0
|
||||
End Function
|
||||
Private Function Lua_RdsPublishAsync(ByVal p As IntPtr) As Integer
|
||||
If IsNothing(Map.refMainWindowVM.RedisManager) OrElse IsNothing(Map.refMainWindowVM.RedisManager.Subscriber) Then
|
||||
EgtOutLog("Error! Trying to publish on a non existent redis!")
|
||||
Return 0
|
||||
End If
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 2 parametri: sKey, sVal
|
||||
Dim sChannel As String = ""
|
||||
Dim sMessage As String = 0
|
||||
LuaCheckParam(state, 1, sChannel)
|
||||
LuaCheckParam(state, 2, sMessage)
|
||||
LuaClearStack(state)
|
||||
Map.refMainWindowVM.RedisManager.Subscriber.PublishAsync(sChannel, sMessage)
|
||||
Return 0
|
||||
End Function
|
||||
|
||||
Private Function Lua_ComReadShortVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic
|
||||
If nMachine = 1 Then
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine1
|
||||
Else
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine2
|
||||
End If
|
||||
Dim nResult As Short = 0
|
||||
If Machine.ReadShortVar(nVarAddr, nResult) Then
|
||||
state.PushNumber(nResult)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
Private Function Lua_ComReadShortVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic = Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)
|
||||
Dim nResult As Short = 0
|
||||
If Machine.ReadShortVar(nVarAddr, nResult) Then
|
||||
state.PushInteger(nResult)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function Lua_ComReadBitVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim nBit As Integer = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, nBit)
|
||||
LuaCheckParam(state, 3, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic
|
||||
If nMachine = 1 Then
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine1
|
||||
Else
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine2
|
||||
End If
|
||||
Dim bResult As Boolean = 0
|
||||
If Machine.ReadBitVar(nVarAddr, nBit, bResult) Then
|
||||
state.PushBoolean(bResult)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
Private Function Lua_ComReadBitVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim nBit As Integer = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, nBit)
|
||||
LuaCheckParam(state, 3, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic = Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)
|
||||
Dim bResult As Boolean = 0
|
||||
If Machine.ReadBitVar(nVarAddr, nBit, bResult) Then
|
||||
state.PushBoolean(bResult)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function Lua_ComReadDoubleVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic
|
||||
If nMachine = 1 Then
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine1
|
||||
Else
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine2
|
||||
End If
|
||||
Dim dResult As Double = 0
|
||||
If Machine.ReadDoubleVar(nVarAddr, dResult) Then
|
||||
state.PushBoolean(dResult)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
Private Function Lua_ComReadDoubleVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic = Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)
|
||||
Dim dResult As Double = 0
|
||||
If Machine.ReadDoubleVar(nVarAddr, dResult) Then
|
||||
state.PushNumber(dResult)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function Lua_ComWriteShortVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim nValue As Integer = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, nValue)
|
||||
LuaCheckParam(state, 3, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic
|
||||
If nMachine = 1 Then
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine1
|
||||
Else
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine2
|
||||
End If
|
||||
If Machine.WriteShortVar(nVarAddr, nValue) Then
|
||||
state.PushBoolean(True)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
Private Function Lua_ComWriteShortVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim nValue As Integer = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, nValue)
|
||||
LuaCheckParam(state, 3, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic = Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)
|
||||
If Machine.WriteShortVar(nVarAddr, nValue) Then
|
||||
state.PushBoolean(True)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function Lua_ComWriteBitVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim nBit As Integer = 0
|
||||
Dim bValue As Boolean = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, nBit)
|
||||
LuaCheckParam(state, 3, bValue)
|
||||
LuaCheckParam(state, 4, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic
|
||||
If nMachine = 1 Then
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine1
|
||||
Else
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine2
|
||||
End If
|
||||
If Machine.WriteBitVar(nVarAddr, nBit, bValue) Then
|
||||
state.PushBoolean(True)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
Private Function Lua_ComWriteBitVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim nBit As Integer = 0
|
||||
Dim bValue As Boolean = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, nBit)
|
||||
LuaCheckParam(state, 3, bValue)
|
||||
LuaCheckParam(state, 4, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic = Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)
|
||||
If Machine.WriteBitVar(nVarAddr, nBit, bValue) Then
|
||||
state.PushBoolean(True)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function Lua_ComWriteDoubleVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim dValue As Double = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, dValue)
|
||||
LuaCheckParam(state, 3, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic
|
||||
If nMachine = 1 Then
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine1
|
||||
Else
|
||||
Machine = Map.refMainWindowVM.MachineManager.Machine2
|
||||
End If
|
||||
If Machine.WriteDoubleVar(nVarAddr, dValue) Then
|
||||
state.PushBoolean(True)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
Private Function Lua_ComWriteDoubleVar(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim nVarAddr As Integer = 0
|
||||
Dim dValue As Double = 0
|
||||
Dim nMachine As Integer = 0
|
||||
LuaCheckParam(state, 1, nVarAddr)
|
||||
LuaCheckParam(state, 2, dValue)
|
||||
LuaCheckParam(state, 3, nMachine)
|
||||
LuaClearStack(state)
|
||||
Dim Machine As NGP_COMM_DLL.NC.NC_generic = Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)
|
||||
If Machine.WriteDoubleVar(nVarAddr, dValue) Then
|
||||
state.PushBoolean(True)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function Lua_ExecProcess(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim sFileName As String = ""
|
||||
Dim sMainLuaPath As String = ""
|
||||
Dim sArguments As String = ""
|
||||
LuaCheckParam(state, 1, sFileName)
|
||||
LuaCheckParam(state, 2, sMainLuaPath)
|
||||
LuaCheckParam(state, 3, sArguments)
|
||||
LuaClearStack(state)
|
||||
If ExecProcessManager.ExecProcess(sFileName, sMainLuaPath, sArguments) Then
|
||||
state.PushBoolean(True)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
Private Function Lua_EntExecProcess(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
Dim sFileName As String = ""
|
||||
Dim sMainLuaPath As String = ""
|
||||
Dim sArguments As String = ""
|
||||
LuaCheckParam(state, 1, sFileName)
|
||||
LuaCheckParam(state, 2, sMainLuaPath)
|
||||
LuaCheckParam(state, 3, sArguments)
|
||||
LuaClearStack(state)
|
||||
If ExecProcessManager.ExecProcess(sFileName, sMainLuaPath, sArguments) Then
|
||||
state.PushBoolean(True)
|
||||
Return 1
|
||||
Else
|
||||
Return 0
|
||||
End If
|
||||
End Function
|
||||
|
||||
Friend Function LuaInstallGeneral(state As Lua) As Boolean
|
||||
If IsNothing(state) Then Return False
|
||||
state.Register("EntIs64bit", func_EntIs64bit)
|
||||
state.Register("EntOutLog", func_EntOutLog)
|
||||
state.Register("EntExistsDirectory", func_EntExistsDirectory)
|
||||
state.Register("EntCopyFile", func_EntCopyFile)
|
||||
state.Register("EntGetIniFile", func_EntGetIniFile)
|
||||
state.Register("EntGetDataDir", func_EntGetDataDir)
|
||||
state.Register("EntGetNumberFromIni", func_EntGetNumberFromIni)
|
||||
state.Register("EntGetStringFromIni", func_EntGetStringFromIni)
|
||||
state.Register("EntWriteStringToIni", func_EntWriteStringToIni)
|
||||
state.Register("EntExecProcess", func_EntExecProcess)
|
||||
state.Register("RdsStringGet", func_RdsStringGet)
|
||||
state.Register("RdsStringSetAsync", func_RdsStringSetAsync)
|
||||
state.Register("RdsPublishAsync", func_RdsPublishAsync)
|
||||
state.Register("ComReadShortVar", func_ComReadShortVar)
|
||||
state.Register("ComWriteShortVar", func_ComWriteShortVar)
|
||||
state.Register("ComReadDoubleVar", func_ComReadDoubleVar)
|
||||
state.Register("ComWriteDoubleVar", func_ComWriteDoubleVar)
|
||||
state.Register("ComReadBitVar", func_ComReadBitVar)
|
||||
state.Register("ComWriteBitVar", func_ComWriteBitVar)
|
||||
Return True
|
||||
End Function
|
||||
Friend Function LuaInstallGeneral(state As Lua) As Boolean
|
||||
If IsNothing(state) Then Return False
|
||||
state.Register("EntIs64bit", func_EntIs64bit)
|
||||
state.Register("EntOutLog", func_EntOutLog)
|
||||
state.Register("EntExistsDirectory", func_EntExistsDirectory)
|
||||
state.Register("EntCopyFile", func_EntCopyFile)
|
||||
state.Register("EntGetIniFile", func_EntGetIniFile)
|
||||
state.Register("EntGetDataDir", func_EntGetDataDir)
|
||||
state.Register("EntGetNumberFromIni", func_EntGetNumberFromIni)
|
||||
state.Register("EntGetStringFromIni", func_EntGetStringFromIni)
|
||||
state.Register("EntWriteStringToIni", func_EntWriteStringToIni)
|
||||
state.Register("EntExecProcess", func_EntExecProcess)
|
||||
state.Register("RdsStringGet", func_RdsStringGet)
|
||||
state.Register("RdsStringSetAsync", func_RdsStringSetAsync)
|
||||
state.Register("RdsPublishAsync", func_RdsPublishAsync)
|
||||
state.Register("ComReadShortVar", func_ComReadShortVar)
|
||||
state.Register("ComWriteShortVar", func_ComWriteShortVar)
|
||||
state.Register("ComReadDoubleVar", func_ComReadDoubleVar)
|
||||
state.Register("ComWriteDoubleVar", func_ComWriteDoubleVar)
|
||||
state.Register("ComReadBitVar", func_ComReadBitVar)
|
||||
state.Register("ComWriteBitVar", func_ComWriteBitVar)
|
||||
Return True
|
||||
End Function
|
||||
|
||||
End Module
|
||||
|
||||
@@ -33,48 +33,48 @@ Public Class SupervisorFunctions
|
||||
Return ExecProcessManager.ExecProcess(sFileName, sMainLuaPath, sArguments)
|
||||
End Function
|
||||
Public Function ComReadShortVar(nVarAddr As Integer, ByRef nResult As Short, nMachine As Integer) As Boolean Implements IHost.ComReadShortVar
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine).ReadShortVar(nVarAddr, nResult)
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1).ReadShortVar(nVarAddr, nResult)
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function ComReadBitVar(nVarAddr As Integer, nBit As Integer, ByRef bResult As Boolean, nMachine As Integer) As Boolean Implements IHost.ComReadBitVar
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine).ReadBitVar(nVarAddr, nBit, bResult)
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1).ReadBitVar(nVarAddr, nBit, bResult)
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function ComReadDoubleVar(nVarAddr As Integer, ByRef dResult As Double, nMachine As Integer) As Boolean Implements IHost.ComReadDoubleVar
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine).ReadDoubleVar(nVarAddr, dResult)
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1).ReadDoubleVar(nVarAddr, dResult)
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function ComWriteShortVar(nVarAddr As Integer, nValue As Integer, nMachine As Integer) As Boolean Implements IHost.ComWriteShortVar
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine).WriteShortVar(nVarAddr, nValue)
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1).WriteShortVar(nVarAddr, nValue)
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function ComWriteBitVar(nVarAddr As Integer, nBit As Integer, bValue As Boolean, nMachine As Integer) As Boolean Implements IHost.ComWriteBitVar
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine).WriteBitVar(nVarAddr, nBit, bValue)
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1).WriteBitVar(nVarAddr, nBit, bValue)
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function ComWriteDoubleVar(nVarAddr As Integer, dValue As Double, nMachine As Integer) As Boolean Implements IHost.ComWriteDoubleVar
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine).WriteDoubleVar(nVarAddr, dValue)
|
||||
If Map.refMainWindowVM.MachineManager.MachineList.Count >= nMachine AndAlso Not IsNothing(Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1)) Then
|
||||
Return Map.refMainWindowVM.MachineManager.MachineList(nMachine - 1).WriteDoubleVar(nVarAddr, dValue)
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Supervisor"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="450" Width="800">
|
||||
Title="MainWindow" Height="950" Width="1600"
|
||||
Style="{StaticResource MainWindow}">
|
||||
<Grid>
|
||||
<ContentControl Content="{Binding ContentPanel}"/>
|
||||
</Grid>
|
||||
|
||||
@@ -55,14 +55,16 @@ Public Class MainWindowVM
|
||||
' Creo Model della MainWindow
|
||||
m_MainWindowM = New MainWindowM
|
||||
|
||||
' creo gestore della comunicazione
|
||||
m_MachineManager = New MachineManager
|
||||
m_MachineManager.Init()
|
||||
|
||||
' creo gestore delle macchine a stati
|
||||
m_FiniteStateMachineManager = New FiniteStateMachineManager
|
||||
If GetMainPrivateProfileInt(S_REDIS, K_ENABLED, 0) = 1 Then
|
||||
m_RedisManager = New RedisManager
|
||||
End If
|
||||
|
||||
m_MachineManager = New MachineManager
|
||||
m_MachineManager.Init()
|
||||
|
||||
' recuper nome del plugin
|
||||
Dim sPluginName As String = ""
|
||||
@@ -72,8 +74,8 @@ Public Class MainWindowVM
|
||||
Application.Current.Resources.MergedDictionaries.Add(PluginDictionary)
|
||||
'' aggiungo MainMenu dal plugin
|
||||
Dim PluginMainMenu As IPluginControl = GetControlByName(Of IPluginControl)(sPluginName, "MainMenu")
|
||||
'' aggiungo MainMenu dal plugin
|
||||
'ContentPanel = PluginMainMenu
|
||||
'' aggiungo manager delle funzioni Lua del Plugin
|
||||
Dim PluginLuaManager As IPluginLuaManager = Map.refMainWindowVM.GetLuaManager(Of IPluginLuaManager)(sPluginName)
|
||||
PluginLuaManager.PlgInit(LuaManager.state)
|
||||
' aggiungo Project dal plugin
|
||||
|
||||
@@ -159,6 +159,9 @@
|
||||
<Compile Include="LUA\LuaManager.vb" />
|
||||
<Compile Include="MEFPlugin\MefPlugin.vb" />
|
||||
<Compile Include="MEFPlugin\SupervisorFunctions.vb" />
|
||||
<Compile Include="Utility\Dictionary.xaml.vb">
|
||||
<DependentUpon>Dictionary.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utility\ExecProcessManager.vb" />
|
||||
<Compile Include="Utility\GenInterface.vb" />
|
||||
<Compile Include="Utility\IniFile.vb" />
|
||||
@@ -178,6 +181,10 @@
|
||||
<DependentUpon>MainWindowV.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="Utility\Dictionary.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="System.Threading.Tasks" />
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<ResourceDictionary x:Class="Dictionary"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
>
|
||||
|
||||
<!--
|
||||
Assign a Key to every Panel ViewModel to use
|
||||
it in xaml file(ProjectView.xaml).
|
||||
-->
|
||||
<!--<local:FiveLakesUIVM x:Key="FiveLakesUIVM"/>
|
||||
<local:DoorListPageVM x:Key="DoorListVM"/>
|
||||
<local:MachinePageVM x:Key="MachinePageVM"/>-->
|
||||
|
||||
<!--Colori predefiniti-->
|
||||
<SolidColorBrush x:Key="EgaltechBlue1" Color="#FF4D84C4" />
|
||||
<SolidColorBrush x:Key="EgaltechBlue2" Color="#FF7096CE" />
|
||||
<SolidColorBrush x:Key="EgaltechBlue3" Color="#FF90ABD9" />
|
||||
<SolidColorBrush x:Key="EgaltechBlue4" Color="#FFB2C3E4" />
|
||||
<SolidColorBrush x:Key="EgaltechWhite" Color="#FFFFFFFF" />
|
||||
<SolidColorBrush x:Key="EgaltechGray" Color="#FF585858" />
|
||||
<SolidColorBrush x:Key="EgaltechLightGray" Color="LightGray" />
|
||||
<SolidColorBrush x:Key="EgaltechUltralightGray" Color="#FFF2F2F2" />
|
||||
<SolidColorBrush x:Key="EgaltechGreen" Color="#FF00FF00" />
|
||||
|
||||
<!--#92908d-->
|
||||
<Color x:Key="Icarus_Gray_Color" R="146" G="144" B="141" A="255"/>
|
||||
<SolidColorBrush x:Key="Icarus_Gray" Color="{StaticResource Icarus_Gray_Color}" />
|
||||
<!--#3c89c9-->
|
||||
<Color x:Key="Icarus_LightBlue_Color" R="60" G="137" B="201" A="255"/>
|
||||
<SolidColorBrush x:Key="Icarus_LightBlue" Color="{StaticResource Icarus_LightBlue_Color}" />
|
||||
<!--#2e5a81-->
|
||||
<Color x:Key="Icarus_Blue_Color" R="46" G="90" B="129" A="255"/>
|
||||
<SolidColorBrush x:Key="Icarus_Blue" Color="{StaticResource Icarus_Blue_Color}" />
|
||||
<!--#50A388-->
|
||||
<Color x:Key="Icarus_Green_Color" R="80" G="163" B="136" A="255"/>
|
||||
<SolidColorBrush x:Key="Icarus_Green" Color="{StaticResource Icarus_Green_Color}" />
|
||||
<!--#BC373E-->
|
||||
<Color x:Key="Icarus_Orange_Color" R="188" G="55" B="62" A="255"/>
|
||||
<SolidColorBrush x:Key="Icarus_Orange" Color="{StaticResource Icarus_Orange_Color}" />
|
||||
<!--#A74C77-->
|
||||
<Color x:Key="Icarus_Purple_Color" R="167" G="76" B="119" A="255"/>
|
||||
<SolidColorBrush x:Key="Icarus_Purple" Color="{StaticResource Icarus_Purple_Color}" />
|
||||
|
||||
<!--Colori per EgtWPFLib5-->
|
||||
<SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
|
||||
|
||||
<!--Risorsa che toglie le animazioni dai menù popup per evitare che i menù mru di scelta dei file rimangano aperti se il file è grosso -->
|
||||
<!--o viene eseguito un lua che non aggiorna l'interfaccia-->
|
||||
<PopupAnimation x:Key="{x:Static SystemParameters.MenuPopupAnimationKey}">None</PopupAnimation>
|
||||
|
||||
<!--convertert per visibilita' stringa di testo con misure in StatusBar-->
|
||||
<!--
|
||||
<PrintApp:StringToVisibilityConverter x:Key="StringToVisibilityConverter"/>-->
|
||||
|
||||
<GridLength x:Key="TitleBarHeight">30</GridLength>
|
||||
<Thickness x:Key="WindowBorder_Thickness">2</Thickness>
|
||||
<sys:Double x:Key="WindowBorder_Height">2</sys:Double>
|
||||
|
||||
<Style x:Key="MainWindow" TargetType="{x:Type Window}">
|
||||
<Setter Property="WindowChrome.WindowChrome">
|
||||
<Setter.Value>
|
||||
<WindowChrome GlassFrameThickness="35"
|
||||
ResizeBorderThickness="3"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Window}">
|
||||
<Border BorderThickness="0"
|
||||
BorderBrush="LightGray"
|
||||
Background="{TemplateBinding Background}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentPresenter Grid.Row="1"
|
||||
Content="{TemplateBinding Content}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="WindowState" Value="Maximized">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Window}">
|
||||
<Border BorderThickness="7"
|
||||
BorderBrush="LightGray"
|
||||
Background="{TemplateBinding Background}">
|
||||
<Grid>
|
||||
<ContentPresenter Content="{TemplateBinding Content}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,108 @@
|
||||
Imports System.ComponentModel.Composition
|
||||
Imports System.Globalization
|
||||
Imports Supervisor.Plugin.Interface
|
||||
|
||||
<Export(GetType(IPluginControl))>
|
||||
<ExportMetadata("Name", "Dictionary")>
|
||||
Public Class Dictionary
|
||||
Inherits ResourceDictionary
|
||||
Implements IPluginControl
|
||||
|
||||
Public Shared ReadOnly MySceneHostVM As String = "MySceneHostVM"
|
||||
|
||||
#Region "Colors"
|
||||
|
||||
'Private m_Omag_Red As SolidColorBrush = Brushes.Red
|
||||
'Public ReadOnly Property Omag_Red As SolidColorBrush
|
||||
' Get
|
||||
' Return m_Omag_Red
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
'Private Shared m_Button_Static_Background As SolidColorBrush = New BrushConverter().ConvertFrom("#FFDDDDDD")
|
||||
'Public Shared ReadOnly Property Button_Static_Background As SolidColorBrush
|
||||
' Get
|
||||
' Return m_Button_Static_Background
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
'Private Shared m_TabControl_Header_Background As LinearGradientBrush = Application.Current.FindResource("TabItem.Static.Background")
|
||||
'Public Shared ReadOnly Property TabControl_Header_Background As LinearGradientBrush
|
||||
' Get
|
||||
' Return m_TabControl_Header_Background
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
|
||||
'Private Shared m_Icarus_Gray As SolidColorBrush = Application.Current.FindResource("Icarus_Gray")
|
||||
'Public Shared ReadOnly Property Icarus_Gray As SolidColorBrush
|
||||
' Get
|
||||
' Return m_Icarus_Gray
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
'Private Shared m_Icarus_LightBlue As SolidColorBrush = Application.Current.FindResource("Icarus_LightBlue")
|
||||
'Public Shared ReadOnly Property Icarus_LightBlue As SolidColorBrush
|
||||
' Get
|
||||
' Return m_Icarus_LightBlue
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
'Private Shared m_Icarus_Blue As SolidColorBrush = Application.Current.FindResource("Icarus_Blue")
|
||||
'Public Shared ReadOnly Property Icarus_Blue As SolidColorBrush
|
||||
' Get
|
||||
' Return m_Icarus_Blue
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
'Private Shared m_Icarus_Green As SolidColorBrush = Application.Current.FindResource("Icarus_Green")
|
||||
'Public Shared ReadOnly Property Icarus_Green As SolidColorBrush
|
||||
' Get
|
||||
' Return m_Icarus_Green
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
'Private Shared m_Icarus_Orange As SolidColorBrush = Application.Current.FindResource("Icarus_Orange")
|
||||
'Public Shared ReadOnly Property Icarus_Orange As SolidColorBrush
|
||||
' Get
|
||||
' Return m_Icarus_Orange
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
'Private Shared m_Icarus_Purple As SolidColorBrush = Application.Current.FindResource("Icarus_Purple")
|
||||
'Public Shared ReadOnly Property Icarus_Purple As SolidColorBrush
|
||||
' Get
|
||||
' Return m_Icarus_Purple
|
||||
' End Get
|
||||
'End Property
|
||||
|
||||
'<SolidColorBrush x : Key="Icarus_Gray" Color="#92908d" />
|
||||
'<SolidColorBrush x : Key="Icarus_LightBlue" Color="#3c89c9" />
|
||||
'<SolidColorBrush x : Key="Icarus_Blue" Color="#2e5a81" />
|
||||
'<SolidColorBrush x : Key="Icarus_Green" Color="#40826d" />
|
||||
'<SolidColorBrush x : Key="Icarus_Orange" Color="#C37636" />
|
||||
'<SolidColorBrush x : Key="Icarus_Purple" Color="#990066" />
|
||||
|
||||
#End Region ' Colors
|
||||
|
||||
End Class
|
||||
|
||||
Public Class CenterToolTipConverter
|
||||
Implements IMultiValueConverter
|
||||
|
||||
Public Function Convert(ByVal values As Object(), ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IMultiValueConverter.Convert
|
||||
For Each value In values
|
||||
If TypeOf (value) IsNot Double Then
|
||||
Return Double.NaN
|
||||
End If
|
||||
Next
|
||||
Dim dPlacementTarget As Double = CDbl(values(0))
|
||||
Dim dToolTip As Double = CDbl(values(1))
|
||||
Return (dPlacementTarget / 2.0) - (dToolTip / 2.0)
|
||||
End Function
|
||||
|
||||
Public Function ConvertBack(ByVal value As Object, ByVal targetTypes As Type(), ByVal parameter As Object, ByVal culture As CultureInfo) As Object() Implements IMultiValueConverter.ConvertBack
|
||||
Throw New NotSupportedException()
|
||||
End Function
|
||||
|
||||
End Class
|
||||
@@ -13,7 +13,7 @@
|
||||
Dim ExecCounter = 0
|
||||
If Proc.Start Then
|
||||
While Not Proc.HasExited
|
||||
If ExecCounter >= 100 Then
|
||||
If ExecCounter >= 300 Then
|
||||
bResult = False
|
||||
Proc.Kill()
|
||||
Exit While
|
||||
|
||||
Reference in New Issue
Block a user