From 9add240f1d3964e709b8ca97ec7f36a1c4825f4b Mon Sep 17 00:00:00 2001 From: Emmanuele Sassi Date: Tue, 23 Jul 2024 15:56:02 +0200 Subject: [PATCH] - commit iniziale --- Supervisor.Plugin.Interface/IHost.vb | 13 + Supervisor.Plugin.Interface/IPluginControl.vb | 8 + .../My Project/AssemblyInfo.vb | 59 +++ .../My Project/Resources.Designer.vb | 62 +++ .../My Project/Resources.resx | 117 ++++++ .../My Project/Settings.Designer.vb | 73 ++++ .../My Project/Settings.settings | 7 + .../Supervisor.Plugin.Interface.vbproj | 116 ++++++ Supervisor.sln | 65 ++++ Supervisor/App.config | 6 + Supervisor/Application.xaml | 8 + Supervisor/Application.xaml.vb | 16 + Supervisor/Comms/GenericCN.vb | 19 + Supervisor/Comms/OsaiCn.vb | 3 + Supervisor/Constants/ConstGen.vb | 74 ++++ Supervisor/Constants/ConstIni.vb | 31 ++ Supervisor/FiniteStateMachine.vb | 16 + .../FiniteStateMachineManager.vb | 93 +++++ Supervisor/LUA/LuaManager.vb | 181 +++++++++ Supervisor/LUA/Lua_Aux.vb | 363 ++++++++++++++++++ Supervisor/LUA/Lua_General.vb | 287 ++++++++++++++ Supervisor/MEFPlugin/MefPlugin.vb | 76 ++++ Supervisor/MEFPlugin/SupervisorFunctions.vb | 36 ++ Supervisor/MainWindow/MainWindowM.vb | 296 ++++++++++++++ Supervisor/MainWindow/MainWindowV.xaml | 12 + Supervisor/MainWindow/MainWindowV.xaml.vb | 23 ++ Supervisor/MainWindow/MainWindowVM.vb | 80 ++++ Supervisor/My Project/AssemblyInfo.vb | 59 +++ .../My Project/MyExtensions/MyWpfExtension.vb | 121 ++++++ Supervisor/My Project/Resources.Designer.vb | 62 +++ Supervisor/My Project/Resources.resx | 117 ++++++ Supervisor/My Project/Settings.Designer.vb | 73 ++++ Supervisor/My Project/Settings.settings | 7 + Supervisor/Supervisor.vbproj | 238 ++++++++++++ Supervisor/Utility/GenInterface.vb | 76 ++++ Supervisor/Utility/IniFile.vb | 66 ++++ Supervisor/Utility/Map.vb | 100 +++++ Supervisor/Utility/RedisManager.vb | 56 +++ Supervisor/packages.config | 16 + 39 files changed, 3131 insertions(+) create mode 100644 Supervisor.Plugin.Interface/IHost.vb create mode 100644 Supervisor.Plugin.Interface/IPluginControl.vb create mode 100644 Supervisor.Plugin.Interface/My Project/AssemblyInfo.vb create mode 100644 Supervisor.Plugin.Interface/My Project/Resources.Designer.vb create mode 100644 Supervisor.Plugin.Interface/My Project/Resources.resx create mode 100644 Supervisor.Plugin.Interface/My Project/Settings.Designer.vb create mode 100644 Supervisor.Plugin.Interface/My Project/Settings.settings create mode 100644 Supervisor.Plugin.Interface/Supervisor.Plugin.Interface.vbproj create mode 100644 Supervisor.sln create mode 100644 Supervisor/App.config create mode 100644 Supervisor/Application.xaml create mode 100644 Supervisor/Application.xaml.vb create mode 100644 Supervisor/Comms/GenericCN.vb create mode 100644 Supervisor/Comms/OsaiCn.vb create mode 100644 Supervisor/Constants/ConstGen.vb create mode 100644 Supervisor/Constants/ConstIni.vb create mode 100644 Supervisor/FiniteStateMachine.vb create mode 100644 Supervisor/FiniteStateMachineManager/FiniteStateMachineManager.vb create mode 100644 Supervisor/LUA/LuaManager.vb create mode 100644 Supervisor/LUA/Lua_Aux.vb create mode 100644 Supervisor/LUA/Lua_General.vb create mode 100644 Supervisor/MEFPlugin/MefPlugin.vb create mode 100644 Supervisor/MEFPlugin/SupervisorFunctions.vb create mode 100644 Supervisor/MainWindow/MainWindowM.vb create mode 100644 Supervisor/MainWindow/MainWindowV.xaml create mode 100644 Supervisor/MainWindow/MainWindowV.xaml.vb create mode 100644 Supervisor/MainWindow/MainWindowVM.vb create mode 100644 Supervisor/My Project/AssemblyInfo.vb create mode 100644 Supervisor/My Project/MyExtensions/MyWpfExtension.vb create mode 100644 Supervisor/My Project/Resources.Designer.vb create mode 100644 Supervisor/My Project/Resources.resx create mode 100644 Supervisor/My Project/Settings.Designer.vb create mode 100644 Supervisor/My Project/Settings.settings create mode 100644 Supervisor/Supervisor.vbproj create mode 100644 Supervisor/Utility/GenInterface.vb create mode 100644 Supervisor/Utility/IniFile.vb create mode 100644 Supervisor/Utility/Map.vb create mode 100644 Supervisor/Utility/RedisManager.vb create mode 100644 Supervisor/packages.config diff --git a/Supervisor.Plugin.Interface/IHost.vb b/Supervisor.Plugin.Interface/IHost.vb new file mode 100644 index 0000000..892be3b --- /dev/null +++ b/Supervisor.Plugin.Interface/IHost.vb @@ -0,0 +1,13 @@ +Imports System.ComponentModel.Composition + + +Public Interface IHost + + Property PluginTestInfo As Integer + 'Function PlgOutLog(sLogMsg As String) As Boolean + 'Function PlgGetPrivateProfileInt(lpAppName As String, lpKeyName As String, nDefault As Integer, lpFileName As String) As Integer + 'Function PlgGetPrivateProfileDouble(lpAppName As String, lpKeyName As String, dDefault As Double, lpFileName As String) As Double + 'Function PlgGetPrivateProfileString(lpAppName As String, lpKeyName As String, lpDefault As String, ByRef lpString As String, lpFileName As String) As Integer + 'Function PlgWritePrivateProfileString(lpAppName As String, lpKeyName As String, lpString As String, lpFileName As String) As Boolean + +End Interface diff --git a/Supervisor.Plugin.Interface/IPluginControl.vb b/Supervisor.Plugin.Interface/IPluginControl.vb new file mode 100644 index 0000000..8035eac --- /dev/null +++ b/Supervisor.Plugin.Interface/IPluginControl.vb @@ -0,0 +1,8 @@ +Public Interface IPluginControl + + 'Function PlgGetPrivateProfileInt(lpAppName As String, lpKeyName As String, nDefault As Integer, lpFileName As String) As Integer + 'Function PlgGetPrivateProfileDouble(lpAppName As String, lpKeyName As String, dDefault As Double, lpFileName As String) As Double + 'Function PlgGetPrivateProfileString(lpAppName As String, lpKeyName As String, lpDefault As String, lpReturnedString As StringBuilder, nSize As Integer, lpFileName As String) As Integer + 'Function PlgWritePrivateProfileString(lpAppName As String, lpKeyName As String, lpString As String, lpFileName As String) As Boolean + +End Interface diff --git a/Supervisor.Plugin.Interface/My Project/AssemblyInfo.vb b/Supervisor.Plugin.Interface/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..adea5a4 --- /dev/null +++ b/Supervisor.Plugin.Interface/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices +Imports System.Globalization +Imports System.Resources +Imports System.Windows + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Supervisor.Plugin.Interface/My Project/Resources.Designer.vb b/Supervisor.Plugin.Interface/My Project/Resources.Designer.vb new file mode 100644 index 0000000..e7ecddc --- /dev/null +++ b/Supervisor.Plugin.Interface/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("$safeprojectname$.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Supervisor.Plugin.Interface/My Project/Resources.resx b/Supervisor.Plugin.Interface/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Supervisor.Plugin.Interface/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Supervisor.Plugin.Interface/My Project/Settings.Designer.vb b/Supervisor.Plugin.Interface/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c88c9a0 --- /dev/null +++ b/Supervisor.Plugin.Interface/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Supervisor.Plugin.Interface.My.MySettings + Get + Return Global.Supervisor.Plugin.Interface.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Supervisor.Plugin.Interface/My Project/Settings.settings b/Supervisor.Plugin.Interface/My Project/Settings.settings new file mode 100644 index 0000000..40ed9fd --- /dev/null +++ b/Supervisor.Plugin.Interface/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Supervisor.Plugin.Interface/Supervisor.Plugin.Interface.vbproj b/Supervisor.Plugin.Interface/Supervisor.Plugin.Interface.vbproj new file mode 100644 index 0000000..4d74b22 --- /dev/null +++ b/Supervisor.Plugin.Interface/Supervisor.Plugin.Interface.vbproj @@ -0,0 +1,116 @@ + + + + Debug + AnyCPU + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + Supervisor.Plugin.Interface + Supervisor.Plugin.Interface + Library + v4.7.2 + Custom + true + {7D14D864-2BDC-4785-80F4-320164C2D5E4} + + + true + full + true + true + true + bin\Debug\ + Supervisor.Plugin.Interface.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + pdbonly + false + false + true + false + true + bin\Release\ + Supervisor.Plugin.Interface.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + On + + + Binary + + + Off + + + On + + + + + + + + + + + 4.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\Supervisor\Supervisor.Plugin.InterfaceR32.dll +IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\Supervisor\Supervisor.Plugin.InterfaceD32.dll +IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\Supervisor\Supervisor.Plugin.InterfaceR64.dll +IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\Supervisor\Supervisor.Plugin.InterfaceD64.dll + + \ No newline at end of file diff --git a/Supervisor.sln b/Supervisor.sln new file mode 100644 index 0000000..52d44b8 --- /dev/null +++ b/Supervisor.sln @@ -0,0 +1,65 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34309.116 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Supervisor", "Supervisor\Supervisor.vbproj", "{38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Supervisor.Plugin.Interface", "Supervisor.Plugin.Interface\Supervisor.Plugin.Interface.vbproj", "{7D14D864-2BDC-4785-80F4-320164C2D5E4}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Supervisor.Plugin.FiveLakes", "..\Supervisor.Plugin.FiveLakes\Supervisor.Plugin.FiveLakes\Supervisor.Plugin.FiveLakes.vbproj", "{7C77F537-8235-40AB-B24A-4E71CFB96D2C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|Any CPU.ActiveCfg = Debug|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|Any CPU.Build.0 = Debug|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|x64.ActiveCfg = Debug|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|x64.Build.0 = Debug|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|x86.ActiveCfg = Debug|x86 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|x86.Build.0 = Debug|x86 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|Any CPU.ActiveCfg = Release|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|Any CPU.Build.0 = Release|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|x64.ActiveCfg = Release|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|x64.Build.0 = Release|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|x86.ActiveCfg = Release|x86 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|x86.Build.0 = Release|x86 + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x64.ActiveCfg = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x64.Build.0 = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x86.ActiveCfg = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x86.Build.0 = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|Any CPU.Build.0 = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x64.ActiveCfg = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x64.Build.0 = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x86.ActiveCfg = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x86.Build.0 = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x64.ActiveCfg = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x64.Build.0 = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x86.ActiveCfg = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x86.Build.0 = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|Any CPU.Build.0 = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x64.ActiveCfg = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x64.Build.0 = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x86.ActiveCfg = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F9D87F62-BDA1-4B0C-BE15-C43A682829E8} + EndGlobalSection +EndGlobal diff --git a/Supervisor/App.config b/Supervisor/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/Supervisor/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Supervisor/Application.xaml b/Supervisor/Application.xaml new file mode 100644 index 0000000..344fc45 --- /dev/null +++ b/Supervisor/Application.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/Supervisor/Application.xaml.vb b/Supervisor/Application.xaml.vb new file mode 100644 index 0000000..9c7dc71 --- /dev/null +++ b/Supervisor/Application.xaml.vb @@ -0,0 +1,16 @@ +Class Application + + ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException + ' can be handled in this file. + Protected Overrides Sub OnStartup(e As StartupEventArgs) + MyBase.OnStartup(e) + ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose + ' Creo la View principale + Dim MainWindowVM As New MainWindowVM + Me.MainWindow = New MainWindowV + Me.MainWindow.DataContext = MainWindowVM + ' Mostro la View principale + Me.MainWindow.Show() + End Sub + +End Class diff --git a/Supervisor/Comms/GenericCN.vb b/Supervisor/Comms/GenericCN.vb new file mode 100644 index 0000000..01324b6 --- /dev/null +++ b/Supervisor/Comms/GenericCN.vb @@ -0,0 +1,19 @@ +Public Class GenericCN + + Friend Function Init() + + End Function + + Friend Function ReadVariable() + + End Function + + Friend Function WriteVariable() + + End Function + + Friend Function Close() + + End Function + +End Class diff --git a/Supervisor/Comms/OsaiCn.vb b/Supervisor/Comms/OsaiCn.vb new file mode 100644 index 0000000..efdadf8 --- /dev/null +++ b/Supervisor/Comms/OsaiCn.vb @@ -0,0 +1,3 @@ +Public Class OsaiCn + +End Class diff --git a/Supervisor/Constants/ConstGen.vb b/Supervisor/Constants/ConstGen.vb new file mode 100644 index 0000000..ebad325 --- /dev/null +++ b/Supervisor/Constants/ConstGen.vb @@ -0,0 +1,74 @@ +'---------------------------------------------------------------------------- +' EgalTech 2015-2017 +'---------------------------------------------------------------------------- +' File : ConstGen.vb Data : 08.05.24 Versione : 2.6e1 +' Contenuto : Modulo costanti generali. +' +' +' +' Modifiche : 08.05.24 ES Creazione modulo. +' +' +'---------------------------------------------------------------------------- + +Public Module ConstGen + + ' File con direttorio radice dei dati + Public Const DAT_FILE_NAME As String = "DataRoot.Ini" + Public Const S_DATA As String = "Data" + Public Const K_DATAROOT As String = "DataRoot" + + ' File con dati di licenza + Public Const LIC_FILE_NAME As String = "EgtBEAMWALL.lic" + Public Const S_LICENCE As String = "Licence" + Public Const K_LOCKID As String = "LockId" + Public Const K_KEY As String = "Key" + + + ' Abilitazioni licenza + Public Enum KEY_OPT As UInteger + SUPERVISOR = 1 + 'WALL = 2 + 'NESTING_AUTO = 4 + 'SUPERVISOR = 8 + 'NETWORK = 16 + 'ANY_DB = 32 + End Enum + + ' File di log generale + Public Const GENLOG_FILE_NAME As String = "Supervisor#.txt" + + ' Sottodirettorio di configurazione + Public Const CONF_DIR As String = "Config" + ' Sottodirettorio delle risorse + Public Const RES_DIR As String = "Resources" + ' Sottodirettorio script + Public Const SCRIPT_DIR As String = "Script" + ' Sottodirettorio temporaneo + Public Const TEMP_DIR As String = "Temp" + '' Sottodirettorio per Cam automatico + 'Public Const PROJS_DIR As String = "Projs" + '' Sottodirettorio per Csv automatico + 'Public Const PRODS_DIR As String = "Prods" + '' Sottodirettorio per Macro + 'Public Const MACRO_DIR As String = "Macro" + '' Sottodirettorio per Magazzino + 'Public Const WAREHOUSE_DIR As String = "Warehouse" + '' Sottodirettorio per lavorazioni travi + 'Public Const BEAM_DIR As String = "Beam" + '' Sottodirettorio per lavorazioni pareti + 'Public Const WALL_DIR As String = "Wall" + '' Sottodirettorio di default per il salvataggio con nome + 'Public Const SAVE_DFL_NAMEDIR As String = "MyProjects" + '' Sottodirettorio di default per le macchine + 'Public Const MACHINES_DFL_DIR As String = "Machines" + '' Sottodirettorio di default per toolmakers + 'Public Const TOOLMAKERS_DFL_DIR As String = "ToolMakers" + '' Nome file Lua con le funzioni di attrezzaggio + 'Public Const SETUP_LUA As String = "SetUp.lua" + '' Nome eseguibile per stampa + 'Public Const ZEBRAPRINTER_EXE As String = "ZebraPrinterUtilitiesD32.exe" + '' Sottodirettorio di default per macro + 'Public Const MACRO_DFL_DIR As String = "Macro" + +End Module diff --git a/Supervisor/Constants/ConstIni.vb b/Supervisor/Constants/ConstIni.vb new file mode 100644 index 0000000..8c41db7 --- /dev/null +++ b/Supervisor/Constants/ConstIni.vb @@ -0,0 +1,31 @@ +'---------------------------------------------------------------------------- +' EgalTech 2015-2024 +'---------------------------------------------------------------------------- +' File : ConstIni.vb Data : 08.05.24 Versione : 2.6e1 +' Contenuto : Modulo costanti sezione e chiavi per file Ini. +' +' +' +' Modifiche : 08.05.24 ES Creazione modulo. +' +' +'---------------------------------------------------------------------------- +Module ConstIni + + Public Const INI_FILE_NAME As String = "Supervisor.ini" + + Public Const S_GENERAL As String = "General" + 'Public Const K_DEBUG As String = "Debug" + 'Public Const K_LICENCE As String = "Licence" + 'Public Const K_USERLEVEL As String = "UserLevel" + 'Public Const K_MAXINST As String = "MaxInstances" + Public Const K_INSTANCES As String = "Instances" + Public Const K_PREPROC As String = "PreProc" + Public Const K_POSTPROC As String = "PostProc" + Public Const K_MACHINESTATE As String = "MachineState" + Public Const K_INITLUA As String = "InitLua" + + Public Const S_REDIS As String = "Redis" + Public Const K_DBINDEX As String = "DbIndex" + +End Module diff --git a/Supervisor/FiniteStateMachine.vb b/Supervisor/FiniteStateMachine.vb new file mode 100644 index 0000000..604bcc5 --- /dev/null +++ b/Supervisor/FiniteStateMachine.vb @@ -0,0 +1,16 @@ +Public Class FiniteStateMachine + + Private m_State As Integer + Private m_sLuaPath As String + Friend ReadOnly Property sLuaPath As String + Get + Return m_sLuaPath + End Get + End Property + + Sub New(sLuaPath As String) + m_sLuaPath = sLuaPath + LuaManager.ExecFile(Map.refMainWindowVM.MainWindowM.sScriptDir & "\" & sLuaPath) + End Sub + +End Class diff --git a/Supervisor/FiniteStateMachineManager/FiniteStateMachineManager.vb b/Supervisor/FiniteStateMachineManager/FiniteStateMachineManager.vb new file mode 100644 index 0000000..fa19ca8 --- /dev/null +++ b/Supervisor/FiniteStateMachineManager/FiniteStateMachineManager.vb @@ -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 diff --git a/Supervisor/LUA/LuaManager.vb b/Supervisor/LUA/LuaManager.vb new file mode 100644 index 0000000..47af67c --- /dev/null +++ b/Supervisor/LUA/LuaManager.vb @@ -0,0 +1,181 @@ +Imports System +Imports System.Diagnostics +Imports System.IO +Imports KeraLua + + +Public Module LuaManager + + Private state As Lua + Friend func_print As LuaFunction = AddressOf Print + + Friend Function SetGlobVar(sName As String, bValue As Boolean) As Boolean + Return Lua_Aux.LuaSetGlobVar(state, sName, bValue) + End Function + + Friend Function SetGlobVar(sName As String, nValue As Integer) As Boolean + Return Lua_Aux.LuaSetGlobVar(state, sName, nValue) + End Function + + Friend Function SetGlobVar(sName As String, dValue As Double) As Boolean + Return Lua_Aux.LuaSetGlobVar(state, sName, dValue) + End Function + + Friend Function SetGlobVar(sName As String, sValue As String) As Boolean + Return Lua_Aux.LuaSetGlobVar(state, sName, sValue) + End Function + + Friend Function GetGlobVar(sName As String, ByRef bValue As Boolean) As Boolean + Return Lua_Aux.LuaGetGlobVar(state, sName, bValue) + End Function + + Friend Function GetGlobVar(sName As String, ByRef nValue As Integer) As Boolean + Return Lua_Aux.LuaGetGlobVar(state, sName, nValue) + End Function + + Friend Function GetGlobVar(sName As String, ByRef dValue As Double) As Boolean + Return Lua_Aux.LuaGetGlobVar(state, sName, dValue) + End Function + + Friend Function GetGlobVar(sName As String, ByRef sValue As String) As Boolean + Return Lua_Aux.LuaGetGlobVar(state, sName, sValue) + End Function + + Friend Function CreateGlobTable(sName As String) As Boolean + Return Lua_Aux.LuaCreateGlobTable(state, sName) + End Function + + Private Function Print(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + Dim n As Integer = state.GetTop() + Dim i As Integer + + For i = 1 To n + Dim type As LuaType = state.Type(i) + + Select Case type + Case LuaType.Nil + Trace.Write("nil") + Case LuaType.String + Dim s As String = state.ToString(i, False) + Trace.Write(s) + Case LuaType.Number + Dim number As Double = state.ToNumber(i) + Trace.Write(number) + Case LuaType.None + Case LuaType.Boolean + Dim bBoolean As Boolean = state.ToBoolean(i) + Trace.Write(bBoolean) + Case LuaType.LightUserData + Case LuaType.Table + Case LuaType.[Function] + Case LuaType.UserData + Case LuaType.Thread + Case Else + End Select + Next + state.PushInteger(544) + Trace.WriteLine(vbLf) + Return 1 + End Function + + Public Function ExecFile(ByVal sPath As String) As Boolean + ' verifico ambiente lua + If IsNothing(state) Then Return False + ' eseguo la linea + Dim result As LuaStatus = state.LoadFile(sPath) + Dim sError As String = String.Empty + If result <> LuaStatus.OK Then + sError = state.ToString(1) + EgtOutLog("Fail loading file: " & sPath & "ERROR:" & sError) + End If + result = state.PCall(0, -1, 0) + If result <> LuaStatus.OK Then + sError = state.ToString(1) + state.Pop(1) + EgtOutLog("Fail calling file: " & sPath & " ERROR: " & sError) + End If + Return result = LuaStatus.OK + End Function + + + Public Function ExecLuaFunction(ByVal sName As String, nReturns As Integer, Params() As Object) As Boolean + ' recupero la funzione + If Not sName.Contains("."c) Then + ' e' direttamente la funzione + state.GetGlobal(sName) + Else + ' e' in una table + Dim sTableName As String = "", sFunctionName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sFunctionName = sParams(1) + state.GetGlobal(sTableName) + If Not state.IsTable(-1) Then Return False + state.GetField(-1, sFunctionName) + ' porto la funzione uno slot sotto e diminuisco lo stack di uno (per essere come caso sopra) + state.Copy(-1, -2) + state.Pop(1) + End If + Dim nParamCount = 0 + If Not IsNothing(Params) Then + ' numero di parametri + nParamCount = Params.Count() + ' inserisco i parametri sullo stack + For Each Param In Params + Select Case Param.GetType() + Case GetType(Boolean) + state.PushBoolean(CBool(Param)) + Case GetType(Integer) + state.PushInteger(CInt(Param)) + Case GetType(Double) + state.PushNumber(CDbl(Param)) + Case GetType(String) + state.PushString(CStr(Param)) + End Select + Next + End If + ' eseguo la chiamata + Dim result As LuaStatus = state.PCall(nParamCount, -1, 0) + ' senza errori + If result = LuaStatus.OK Then + Return True + Else + ' recupero il messaggio di errore + Dim sError As String = state.ToString(-1) + state.Pop(1) + EgtOutLog("Fail calling function: " & sName & " ERROR: " & sError) + Return False + End If + End Function + + Public Function Init() As Boolean + ' se già aperto, lo fermo per riavviarlo + If Not IsNothing(state) Then + state.Close() + state = Nothing + End If + ' inizializzo Lua + state = New Lua() + If IsNothing(state) Then + EgtOutLog("Error in Lua interpreter starting (LuaManager.Init)") + Return False + End If + ' carico le librerie standard + state.OpenLibs() + If Not LuaInstallGeneral(state) Then + Return False + End If + Return True + End Function + + Public Function Close() As Boolean + ' verifico ambiente lua + If IsNothing(state) Then Return False + ' termino Lua + state.Close() + state = Nothing + Return True + End Function + +End Module diff --git a/Supervisor/LUA/Lua_Aux.vb b/Supervisor/LUA/Lua_Aux.vb new file mode 100644 index 0000000..31a7fe6 --- /dev/null +++ b/Supervisor/LUA/Lua_Aux.vb @@ -0,0 +1,363 @@ +Imports KeraLua + +Public Module Lua_Aux + + Friend Function LuaClearStack(state As Lua) + Dim nIndex As Integer = state.GetTop() + If nIndex > 0 Then + state.Pop(nIndex) + End If + Return True + End Function + + Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef bValue As Boolean) + If Not LuaGetParam(state, nIndex, bValue) Then + Return state.Error(" Invalid Parameter # " & nIndex) + End If + Return True + End Function + + Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef nValue As Integer) + If Not LuaGetParam(state, nIndex, nValue) Then + Return state.Error(" Invalid Parameter # " & nIndex) + End If + Return True + End Function + + Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef dValue As Double) + If Not LuaGetParam(state, nIndex, dValue) Then + Return state.Error(" Invalid Parameter # " & nIndex) + End If + Return True + End Function + + Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef sValue As String) + If Not LuaGetParam(state, nIndex, sValue) Then + Return state.Error(" Invalid Parameter # " & nIndex) + End If + Return True + End Function + + Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef bValue As Boolean) As Boolean + If Not state.IsBoolean(nIndex) Then Return False + bValue = state.ToBoolean(nIndex) + Return True + End Function + + Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef nValue As Integer) As Boolean + If Not state.IsNumber(nIndex) Then Return False + nValue = Math.Round(state.ToNumber(nIndex)) + Return True + End Function + + Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef dValue As Double) As Boolean + If Not state.IsNumber(nIndex) Then Return False + dValue = state.ToNumber(nIndex) + Return True + End Function + + Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef sValue As String) As Boolean + If Not state.IsString(nIndex) Then Return False + sValue = state.ToString(nIndex) + Return True + End Function + + Friend Function LuaSetParam(state As Lua) As Boolean + Try + state.PushNil() + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaSetParam(state As Lua, ByRef bValue As Boolean) As Boolean + Try + state.PushBoolean(bValue) + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaSetParam(state As Lua, ByRef nValue As Integer) As Boolean + Try + state.PushInteger(nValue) + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaSetParam(state As Lua, ByRef dValue As Double) As Boolean + Try + state.PushNumber(dValue) + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaSetParam(state As Lua, ByRef sValue As String) As Boolean + Try + state.PushString(sValue) + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef bValue As Boolean) As Boolean + If Not state.IsTable(nIndex) Then Return False + state.GetField(nIndex, sVarName) + Dim bResult As Boolean = LuaGetParam(state, -1, bValue) + state.Pop(1) + Return bResult + End Function + + Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef nValue As Integer) As Boolean + If Not state.IsTable(nIndex) Then Return False + state.GetField(nIndex, sVarName) + Dim bResult As Boolean = LuaGetParam(state, -1, nValue) + state.Pop(1) + Return bResult + End Function + + Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef dValue As Double) As Boolean + If Not state.IsTable(nIndex) Then Return False + state.GetField(nIndex, sVarName) + Dim bResult As Boolean = LuaGetParam(state, -1, dValue) + state.Pop(1) + Return bResult + End Function + + Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef sValue As String) As Boolean + If Not state.IsTable(nIndex) Then Return False + state.GetField(nIndex, sVarName) + Dim bResult As Boolean = LuaGetParam(state, -1, sValue) + state.Pop(1) + Return bResult + End Function + + Friend Function LuaGetGlobVar(state As Lua, ByRef sName As String, ByRef bValue As Boolean) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + state.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(state, -1, bValue) + state.Pop(1) + Return bResult + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, bValue) + state.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaGetGlobVar(state As Lua, ByRef sName As String, ByRef nValue As Integer) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + state.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(state, -1, nValue) + state.Pop(1) + Return bResult + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, nValue) + state.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaGetGlobVar(state As Lua, ByRef sName As String, ByRef dValue As Double) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + state.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(state, -1, dValue) + state.Pop(1) + Return bResult + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, dValue) + state.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaGetGlobVar(state As Lua, ByRef sName As String, ByRef sValue As String) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + state.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(state, -1, sValue) + state.Pop(1) + Return bResult + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, sValue) + state.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaSetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String) As Boolean + If Not state.IsTable(nIndex) Then Return False + If Not LuaSetParam(state) Then Return False + Dim nPos As Integer = (If(nIndex > 0, nIndex, nIndex - 1)) + state.SetField(nPos, sVarName) + Return True + End Function + + Friend Function LuaSetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef bValue As Boolean) As Boolean + If Not state.IsTable(nIndex) Then Return False + If Not LuaSetParam(state, bValue) Then Return False + Dim nPos As Integer = (If(nIndex > 0, nIndex, nIndex - 1)) + state.SetField(nPos, sVarName) + Return True + End Function + + Friend Function LuaSetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef nValue As Integer) As Boolean + If Not state.IsTable(nIndex) Then Return False + If Not LuaSetParam(state, nValue) Then Return False + Dim nPos As Integer = (If(nIndex > 0, nIndex, nIndex - 1)) + state.SetField(nPos, sVarName) + Return True + End Function + + Friend Function LuaSetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef dValue As Double) As Boolean + If Not state.IsTable(nIndex) Then Return False + If Not LuaSetParam(state, dValue) Then Return False + Dim nPos As Integer = (If(nIndex > 0, nIndex, nIndex - 1)) + state.SetField(nPos, sVarName) + Return True + End Function + + Friend Function LuaSetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef sValue As String) As Boolean + If Not state.IsTable(nIndex) Then Return False + If Not LuaSetParam(state, sValue) Then Return False + Dim nPos As Integer = (If(nIndex > 0, nIndex, nIndex - 1)) + state.SetField(nPos, sVarName) + Return True + End Function + + Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef bValue As Boolean) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(state, bValue) Then Return False + state.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(state, -1, sVarName, bValue) + state.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef nValue As Integer) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(state, nValue) Then Return False + state.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(state, -1, sVarName, nValue) + state.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef dValue As Double) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(state, dValue) Then Return False + state.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(state, -1, sVarName, dValue) + state.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef sValue As String) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(state, sValue) Then Return False + state.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(state, -1, sVarName, sValue) + state.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaResetGlobVar(state As Lua, ByRef sName As String) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(state) Then Return False + state.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(state, -1, sVarName) + state.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaCreateGlobTable(state As Lua, ByRef sName As String) As Boolean + Try + state.NewTable() + state.SetGlobal(sName) + Catch ex As Exception + Return False + End Try + Return True + End Function + +End Module diff --git a/Supervisor/LUA/Lua_General.vb b/Supervisor/LUA/Lua_General.vb new file mode 100644 index 0000000..d5a7444 --- /dev/null +++ b/Supervisor/LUA/Lua_General.vb @@ -0,0 +1,287 @@ +Imports KeraLua +Imports StackExchange.Redis +Imports System.IO + +Public Module Lua_General + + ' 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 + + ' 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_EntGetNumberFromIni As LuaFunction = AddressOf Lua_EntGetNumberFromIni + Friend func_EntGetStringFromIni As LuaFunction = AddressOf Lua_EntGetStringFromIni + Friend func_EntWriteStringToIni As LuaFunction = AddressOf Lua_EntWriteStringToIni + 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_ReadVariable As LuaFunction = AddressOf Lua_ReadVariable + Friend func_WriteVariable As LuaFunction = AddressOf Lua_WriteVariable + + 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_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_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_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_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) + ' 1 parametro: sKey + Dim sKey As String = "" + LuaCheckParam(state, 1, sKey) + LuaClearStack(state) + Dim Result As RedisValue = 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 + 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 + 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_ReadVariable(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + If state.Type(1) <> LuaType.String Then Return 0 + Dim sVarAddr As String = state.ToString(1, False) + 'state.Pop(1) + Dim dResult As Double = 0 + If ReadVariable(sVarAddr, dResult) Then + state.PushNumber(dResult) + Return 1 + Else + Return 0 + End If + End Function + + Private Function ReadVariable(sVarAddr As String, ByRef dResult As Double) As Boolean + Select Case sVarAddr + Case "a" + dResult = 256 + Case "b" + dResult = 257 + Case "c" + dResult = 258 + Case "d" + dResult = 259 + Case "e" + dResult = 260 + Case "f" + dResult = 261 + Case Else + Return False + End Select + Return True + End Function + + Private Function Lua_WriteVariable(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + If state.Type(1) <> LuaType.String OrElse state.Type(2) <> LuaType.String Then Return 0 + Dim sVarAddr As String = state.ToString(1, False) + Dim sValue As String = state.ToString(2, False) + 'state.Pop(2) + Dim bResult As Boolean = False + If WriteVariable(sVarAddr, sValue, bResult) Then + state.PushBoolean(bResult) + ' state.PushInteger(If(bResult, 1, 0)) + Return 1 + Else + Return 0 + End If + End Function + + Private Function WriteVariable(sVarAddr As String, sValue As String, ByRef bResult As Boolean) As Boolean + Select Case sVarAddr + Case "a" + bResult = sValue = "abbecedario" + Case "b" + bResult = sValue = "bullone" + Case "c" + bResult = sValue = "cane" + Case "d" + bResult = sValue = "diario" + Case "e" + bResult = sValue = "elefante" + Case "f" + bResult = sValue = "foglia" + Case Else + Return False + End Select + 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("EntGetNumberFromIni", func_EntGetNumberFromIni) + state.Register("EntGetStringFromIni", func_EntGetStringFromIni) + state.Register("EntWriteStringToIni", func_EntWriteStringToIni) + state.Register("RdsStringGet", func_RdsStringGet) + state.Register("RdsStringSetAsync", func_RdsStringSetAsync) + state.Register("RdsPublishAsync", func_RdsPublishAsync) + state.Register("ReadVariable", func_ReadVariable) + state.Register("WriteVariable", func_WriteVariable) + state.Register("print", func_print) + Return True + End Function + +End Module diff --git a/Supervisor/MEFPlugin/MefPlugin.vb b/Supervisor/MEFPlugin/MefPlugin.vb new file mode 100644 index 0000000..3ae9ca8 --- /dev/null +++ b/Supervisor/MEFPlugin/MefPlugin.vb @@ -0,0 +1,76 @@ +Imports System.ComponentModel.Composition +Imports System.ComponentModel.Composition.Hosting + +Public Class MEFLoader + + Private importers As Dictionary(Of String, List(Of Object)) = New Dictionary(Of String, List(Of Object))() + + Public Overridable Function LoadByTag(Of T)(ByVal path As String, ByVal tag As String) As ICollection(Of T) + Dim importer = GetImporter(Of T)(path) + Return importer.LoadByMEF(path, tag) + End Function + + Protected Function GetImporter(Of T)(ByVal path As String) As MEFImporter(Of T) + Dim importerList = GetImporterList(path) + Dim importer = importerList.OfType(Of MEFImporter(Of T))().FirstOrDefault() + + If importer Is Nothing Then + importer = New MEFImporter(Of T)(path) + importerList.Add(importer) + End If + + Return importer + End Function + + Protected Function GetImporterList(ByVal path As String) As List(Of Object) + If importers.ContainsKey(path) = False Then importers.Add(path, New List(Of Object)()) + Return importers(path) + End Function + + Public Overridable Function LoadByType(Of T)(ByVal path As String) As ICollection(Of T) + Return LoadByTag(Of T)(path, String.Empty) + End Function +End Class + +Public Interface IMetadata + ReadOnly Property Name As String +End Interface + +Public Class MEFImporter(Of T) + + + Public Property [imports] As IEnumerable(Of Lazy(Of T, IMetadata)) + + Private Sub New() + End Sub + + Public Sub New(ByVal path As String) + Me.New() + directoryCatalog = New DirectoryCatalog(path) + End Sub + + Protected directoryCatalog As DirectoryCatalog = Nothing + + Protected Sub DoImport(ByVal path As String) + Dim catalog = New AggregateCatalog() + catalog.Catalogs.Add(directoryCatalog) + catalog.Catalogs.Add(New AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly())) + Dim container As CompositionContainer = New CompositionContainer(catalog) + container.ComposeParts(Me) + End Sub + + Public Function LoadByMEF(ByVal path As String, ByVal name As String) As ICollection(Of T) + Dim res = New List(Of T)() + DoImport(path) + + For Each [module] As Lazy(Of T, IMetadata) In [imports] + + If [module].Metadata.Name = name OrElse String.IsNullOrEmpty(name) Then + res.Add([module].Value) + End If + Next + + Return res + End Function + +End Class diff --git a/Supervisor/MEFPlugin/SupervisorFunctions.vb b/Supervisor/MEFPlugin/SupervisorFunctions.vb new file mode 100644 index 0000000..1169723 --- /dev/null +++ b/Supervisor/MEFPlugin/SupervisorFunctions.vb @@ -0,0 +1,36 @@ +Imports System.ComponentModel.Composition +Imports Supervisor.Plugin.Interface + + +Public Class SupervisorFunctions + Implements IHost + + Public Property PluginTestInfo As Integer Implements IHost.PluginTestInfo + Get + Return Map.refMainWindowVM.m_PluginTestInfo + End Get + Set(value As Integer) + Throw New NotImplementedException() + End Set + End Property + 'Public Function PlgOutLog(sLogMsg As String) As Boolean Implements IHost.PlgOutLog + ' Return EgtOutLog(sLogMsg) + 'End Function + + 'Public Function PlgGetPrivateProfileInt(lpAppName As String, lpKeyName As String, nDefault As Integer, lpFileName As String) As Integer Implements IHost.PlgGetPrivateProfileInt + ' Return GetPrivateProfileInt(lpAppName, lpKeyName, nDefault, lpFileName) + 'End Function + + 'Public Function PlgGetPrivateProfileDouble(lpAppName As String, lpKeyName As String, dDefault As Double, lpFileName As String) As Double Implements IHost.PlgGetPrivateProfileDouble + ' Return GetPrivateProfileDouble(lpAppName, lpKeyName, dDefault, lpFileName) + 'End Function + + 'Public Function PlgGetPrivateProfileString(lpAppName As String, lpKeyName As String, lpDefault As String, ByRef lpString As String, lpFileName As String) As Integer Implements IHost.PlgGetPrivateProfileString + ' Return GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, lpString, lpFileName) + 'End Function + + 'Public Function PlgWritePrivateProfileString(lpAppName As String, lpKeyName As String, lpString As String, lpFileName As String) As Boolean Implements IHost.PlgWritePrivateProfileString + ' Return WritePrivateProfileString(lpAppName, lpKeyName, lpString, lpFileName) + 'End Function + +End Class diff --git a/Supervisor/MainWindow/MainWindowM.vb b/Supervisor/MainWindow/MainWindowM.vb new file mode 100644 index 0000000..f9315c0 --- /dev/null +++ b/Supervisor/MainWindow/MainWindowM.vb @@ -0,0 +1,296 @@ +Imports System.Threading +Imports System.Math +Imports System.IO + +Public Class MainWindowM + +#Region "FIELDS" + + ' massimo numero di istanze del programma ammesse + Const MAX_INST As Integer = 1 + + Private m_objMutex As Mutex + + Private m_sDataRoot As String = String.Empty + Friend ReadOnly Property sDataRoot As String + Get + Return m_sDataRoot + End Get + End Property + + Private m_sDataDir As String = String.Empty + Friend ReadOnly Property sDataDir As String + Get + Return m_sDataDir + End Get + End Property + + Private m_sConfigDir As String = String.Empty + Public ReadOnly Property sConfigDir As String + Get + Return m_sConfigDir + End Get + End Property + + Private m_sScriptDir As String = String.Empty + Public ReadOnly Property sScriptDir As String + Get + Return m_sScriptDir + End Get + End Property + + Private m_nDebug As Integer = 0 + Public ReadOnly Property DebugLevel As Integer + Get + Return m_nDebug + End Get + End Property + + Private m_bFirstInstance As Boolean = False + Friend ReadOnly Property bFirstInstance As Boolean + Get + Return m_bFirstInstance + End Get + End Property + + Private m_nInstance As Integer = 0 + Friend ReadOnly Property nInstance As Integer + Get + Return m_nInstance + End Get + End Property + + Private m_nUserLevel As Integer = 1 + Friend ReadOnly Property nUserLevel As Integer + Get + Return m_nUserLevel + End Get + End Property + + Private m_nKeyLevel As Integer = 0 + Friend ReadOnly Property nKeyLevel As Integer + Get + Return m_nKeyLevel + End Get + End Property + + Private m_nKeyOptions As UInteger = 0 + Friend ReadOnly Property nKeyOptions As Integer + Get + Return m_nKeyOptions + End Get + End Property + + Friend ReadOnly Property sVersion As String + Get + Return My.Application.Info.Version.Major.ToString() & "." & + My.Application.Info.Version.Minor.ToString() & + (ChrW(97 - 1 + My.Application.Info.Version.Build)).ToString() & + My.Application.Info.Version.Revision.ToString() + End Get + End Property + + Private m_sTempDir As String + Friend ReadOnly Property sTempDir As String + Get + Return m_sTempDir + End Get + End Property + + Private m_sResourcesRoot As String + Friend ReadOnly Property sResourcesRoot As String + Get + Return m_sResourcesRoot + End Get + End Property + + Private m_sLogFile As String + Friend ReadOnly Property sLogFile As String + Get + Return m_sLogFile + End Get + End Property + +#End Region ' FIELDS + +#Region "CONSTRUCTOR" + + Sub New() + InitializeEgtEnvironment() + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Private Sub InitializeEgtEnvironment() + ' Impostazione path radice per i dati + m_sDataRoot = System.AppDomain.CurrentDomain.BaseDirectory + If GetPrivateProfileString(S_DATA, K_DATAROOT, "", m_sDataRoot, m_sDataRoot & "\" & DAT_FILE_NAME) = 0 Then + m_sDataRoot = System.AppDomain.CurrentDomain.BaseDirectory + End If + ' Impostazione direttorio di configurazione + m_sConfigDir = m_sDataRoot & "\" & CONF_DIR + ' Impostazione direttorio per file script + m_sScriptDir = m_sDataRoot & "\" & SCRIPT_DIR + ' Impostazione direttorio per file temporanei + m_sTempDir = m_sDataRoot & "\" & TEMP_DIR + ' Impostazione path Ini file + IniFile.SetIniFile(m_sConfigDir & "\" & INI_FILE_NAME) + ' Impostazione path resources dir + m_sResourcesRoot = m_sDataRoot & "\" & RES_DIR + ' Verifico indice di istanza + ManageInstance() + '' Imposto tipo di chiave + 'EgtSetLockType(KEY_TYPE.HW) + '' Leggo e imposto chiave di protezione + 'Dim sLicFileName As String = String.Empty + 'GetMainPrivateProfileString(S_GENERAL, K_LICENCE, LIC_FILE_NAME, sLicFileName) + 'Dim sLicFile As String = m_sConfigDir & "\" & sLicFileName + 'Dim sKey As String = String.Empty + 'EgtUILib.GetPrivateProfileString(S_LICENCE, K_KEY, "", sKey, sLicFile) + 'EgtSetKey(sKey) + '' Recupero livello e opzioni della chiave + 'Dim bKey As Boolean = EgtGetKeyLevel(5583, 2605, 1, m_nKeyLevel) And + ' EgtGetKeyOptions(5583, 2605, 1, m_nKeyOptions) + '' Inizializzazione generale di EgtInterface + 'm_nDebug = GetMainPrivateProfileInt(S_GENERAL, K_DEBUG, 0) + ' inizializzo log + m_sLogFile = m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", m_nInstance.ToString()) + Lua_General.SetLogPath(m_sLogFile) + If File.Exists(m_sLogFile) Then + Try + File.Copy(m_sLogFile, m_sLogFile & ".bak", True) + File.Delete(m_sLogFile) + Catch ex As Exception + EgtOutLog("Old log delete failed!" & ex.Message) + End Try + End If + Dim sLogMsg As String = "User " & Environment.MachineName & "\" & Environment.UserName & " (" & m_nInstance.ToString() & ")" & vbLf & + My.Application.Info.Title.ToString() & " ver. " & + My.Application.Info.Version.Major.ToString() & + "." & My.Application.Info.Version.Minor.ToString() & + (ChrW(97 - 1 + My.Application.Info.Version.Build)).ToString() & + My.Application.Info.Version.Revision.ToString() + EgtOutLog(sLogMsg) + 'EgtInit(m_nDebug, m_sLogFile, sLogMsg) + 'EgtSetTempDir(m_sTempDir) + 'EgtSetIniFile(IniFile.m_sIniFile) + ' Leggo direttorio dei messaggi (se manca uso direttorio di configurazione) + 'Dim sMsgDir As String = String.Empty + 'If GetMainPrivateProfileString(S_GENERAL, K_MESSAGESDIR, "", sMsgDir) = 0 Then + ' sMsgDir = m_sConfigDir + 'End If + ''' Inizializzo OptionModule + ''OptionModule.InitOptionModule() + '' Leggo lingua corrente + 'Dim sLanguage As String = String.Empty + 'GetMainPrivateProfileString(S_GENERAL, K_MESSAGES, "", sLanguage) + '' Recupero nome file dei messaggi della lingua corrente + 'Dim sMsgName As String = "EgalTechIta.txt" + 'Dim nIndex As Integer = 1 + 'While True + ' Dim ReadLanguage As Language = GetMainPrivateProfileLanguage(S_LANGUAGES, K_LANGUAGE & nIndex) + ' If IsNothing(ReadLanguage) Then Exit While + ' If String.Compare(ReadLanguage.Name, sLanguage, True) = 0 Then + ' sMsgName = ReadLanguage.FilePath + ' Exit While + ' End If + ' nIndex += 1 + 'End While + '' Leggo file messaggi + 'Dim sMsgFilePath As String = sMsgDir & "\" & sMsgName + 'If Not EgtLoadMessages(sMsgFilePath) Then + ' EgtOutLog("Error in EgtLoadMessages") + 'End If + ' Leggo e imposto livello utilizzatore + ' m_nUserLevel = Math.Min(m_nKeyLevel, GetMainPrivateProfileInt(S_GENERAL, K_USERLEVEL, 1)) + ' Info su opzioni chiave + 'EgtOutLog("KeyOptions : " & bKey.ToString() & " " & m_nKeyOptions.ToString()) + ' inizializzo ambiente Lua + LuaManager.Init() + End Sub + + Private Sub ManageInstance() + Dim bCreated As Boolean + Try + m_objMutex = New Mutex(False, "Global\Supervisor", bCreated) + Catch + bCreated = False + End Try + m_bFirstInstance = bCreated + If bCreated Then + ' Prima istanza + m_nInstance = 1 + ' Aggiorno stato istanze attive + WriteMainPrivateProfileString(S_GENERAL, K_INSTANCES, m_nInstance.ToString()) + Else + ' Leggo il massimo numero di istanze ammesse + Dim nMaxInst As Integer = GetMaxInstances() + ' Cerco il primo indice di istanza libero + Dim nTmp As Integer = GetMainPrivateProfileInt(S_GENERAL, K_INSTANCES, 0) + m_nInstance = 1 + Dim nMask As Integer = 1 + While (nTmp And nMask) <> 0 And m_nInstance <= MAX_INST + m_nInstance += 1 + nMask *= 2 + End While + ' Se l'indice supera il massimo + If m_nInstance > nMaxInst Then + ' porto in primo piano la prima istanza + Dim bFound As Boolean = False + ' processi del programma a 32 bit + Dim localProc As Process() = Process.GetProcessesByName("SupervisorR32") + For Each p As Process In localProc + If p.Id <> Process.GetCurrentProcess().Id Then + bFound = True + ShowWindow(p.MainWindowHandle, 1) + Exit For + End If + Next + ' se non trovati processi a 32 bit provo a 64 bit + If Not bFound Then + localProc = Process.GetProcessesByName("SupervisorR64") + For Each p As Process In localProc + If p.Id <> Process.GetCurrentProcess().Id Then + bFound = True + ShowWindow(p.MainWindowHandle, SW.RESTORE) + Exit For + End If + Next + End If + ' esco dal programma + End + End If + ' Aggiorno stato istanze attive + nTmp += (1 << (m_nInstance - 1)) + WriteMainPrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString()) + End If + End Sub + + Friend Function GetKeyOption(nKeyOpt As KEY_OPT) As Boolean + Return ((m_nKeyOptions And nKeyOpt) <> 0) + End Function + + Friend Function GetMaxInstances() As Integer + ' Leggo il massimo numero di istanze ammesse + ' Dim nMaxInst As Integer = GetMainPrivateProfileInt(S_GENERAL, K_MAXINST, 1) + Return 1 ' Max(1, Min(nMaxInst, MAX_INST)) + End Function + + Friend Sub Close() + '' Terminazione generale di EgtInterface + 'EgtExit() + ' Aggiorno istanze usate + m_objMutex.WaitOne(1000) + Dim nTmp As Integer = GetMainPrivateProfileInt(S_GENERAL, K_INSTANCES, 0) + nTmp -= (1 << (m_nInstance - 1)) + WriteMainPrivateProfileString(S_GENERAL, K_INSTANCES, nTmp.ToString()) + m_objMutex.ReleaseMutex() + ' Rilascio mutex + If Not IsNothing(m_objMutex) Then m_objMutex.Close() + End Sub + +#End Region ' METHODS + +End Class diff --git a/Supervisor/MainWindow/MainWindowV.xaml b/Supervisor/MainWindow/MainWindowV.xaml new file mode 100644 index 0000000..020fcd2 --- /dev/null +++ b/Supervisor/MainWindow/MainWindowV.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/Supervisor/MainWindow/MainWindowV.xaml.vb b/Supervisor/MainWindow/MainWindowV.xaml.vb new file mode 100644 index 0000000..224e738 --- /dev/null +++ b/Supervisor/MainWindow/MainWindowV.xaml.vb @@ -0,0 +1,23 @@ +Class MainWindowV + + Private m_MainWindowVM As MainWindowVM + +#Region "CONSTRUCTOR" + + Sub New() + ' Funzione che interpreta l'xaml + InitializeComponent() + ' Assegno al riferimento locale al VM il VM preso dal DataContext + m_MainWindowVM = DirectCast(Me.DataContext, MainWindowVM) + AddHandler Me.Closed, AddressOf MainWindowV_Closed + End Sub + +#End Region ' CONSTRUCTOR + + Private Sub MainWindowV_Closed(sender As Object, e As EventArgs) + If Not IsNothing(m_MainWindowVM) AndAlso Not IsNothing(m_MainWindowVM.FiniteStateMachineManager) Then m_MainWindowVM.FiniteStateMachineManager.ResetFiniteStateMachineTimer() + LuaManager.Close() + EgtOutLog("Exit") + End Sub + +End Class diff --git a/Supervisor/MainWindow/MainWindowVM.vb b/Supervisor/MainWindow/MainWindowVM.vb new file mode 100644 index 0000000..a80a69e --- /dev/null +++ b/Supervisor/MainWindow/MainWindowVM.vb @@ -0,0 +1,80 @@ +Imports System.IO +Imports System.Windows.Threading +Imports Supervisor.Plugin.Interface + +Public Class MainWindowVM + + Friend m_PluginTestInfo As Integer = 764 + + ' Riferimento al Model della MainWindow + Private m_MainWindowM As MainWindowM + Friend ReadOnly Property MainWindowM As MainWindowM + Get + Return m_MainWindowM + End Get + End Property + + ' Riferimento al gestore delle macchine a stati + Private m_FiniteStateMachineManager As FiniteStateMachineManager + Friend ReadOnly Property FiniteStateMachineManager As FiniteStateMachineManager + Get + Return m_FiniteStateMachineManager + End Get + End Property + + ' Riferimento al gestore del server Redis + Private m_RedisManager As RedisManager + Friend ReadOnly Property RedisManager As RedisManager + Get + Return m_RedisManager + End Get + End Property + + Private m_ContentPanel As Panel + Public Property ContentPanel As Panel + Get + Return m_ContentPanel + End Get + Set(value As Panel) + m_ContentPanel = value + End Set + End Property + + Sub New() + ' Avvio l'inizializzazione della mappa passandogli il riferimento al MainWindowVM + Map.BeginInit(Me) + ' Creo Model della MainWindow + m_MainWindowM = New MainWindowM + + ' creo gestore delle macchine a stati + m_FiniteStateMachineManager = New FiniteStateMachineManager + + m_RedisManager = New RedisManager + + Dim PluginUI As IPluginControl = GetControlByName(Of IPluginControl)("Supervisor.Plugin.FiveLakes") + ContentPanel = PluginUI + End Sub + +#Region "Plugin" + + Private m_Loader As MEFLoader = New MEFLoader() + + Private Function GetPathByName(ByVal name As String) As String + 'Dim PluginNameSplit() As String = name.Split("."c) + 'Dim res = MainWindowM.sDataRoot & "\Plugin\" & PluginNameSplit(0) + Dim res = MainWindowM.sDataRoot & "\Plugin\" & name + Return res + End Function + + Friend Function GetControlByName(Of T)(sName As String) As Panel + Dim PlugInControl As Object = m_Loader.LoadByTag(Of T)(GetPathByName(sName), sName).FirstOrDefault() + Dim PluginPanel As Panel = Nothing + If PlugInControl.GetType().BaseType.FullName = GetType(Panel).FullName OrElse PlugInControl.GetType().BaseType.FullName = GetType(Grid).FullName Then + PluginPanel = TryCast(PlugInControl, Panel) + End If + Return PluginPanel + End Function + +#End Region ' Plugin + +End Class diff --git a/Supervisor/My Project/AssemblyInfo.vb b/Supervisor/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..601cdbe --- /dev/null +++ b/Supervisor/My Project/AssemblyInfo.vb @@ -0,0 +1,59 @@ +Imports System +Imports System.Globalization +Imports System.Reflection +Imports System.Resources +Imports System.Runtime.InteropServices +Imports System.Windows + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'In order to begin building localizable applications, set +'CultureYouAreCodingWith in your .vbproj file +'inside a . For example, if you are using US english +'in your source files, set the to "en-US". Then uncomment the +'NeutralResourceLanguage attribute below. Update the "en-US" in the line +'below to match the UICulture setting in the project file. + +' + + +'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found. +'1st parameter: where theme specific resource dictionaries are located +'(used if a resource is not found in the page, +' or application resource dictionaries) + +'2nd parameter: where the generic resource dictionary is located +'(used if a resource is not found in the page, +'app, and any theme specific resource dictionaries) + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/Supervisor/My Project/MyExtensions/MyWpfExtension.vb b/Supervisor/My Project/MyExtensions/MyWpfExtension.vb new file mode 100644 index 0000000..22f84b7 --- /dev/null +++ b/Supervisor/My Project/MyExtensions/MyWpfExtension.vb @@ -0,0 +1,121 @@ +#If _MyType <> "Empty" Then + +Namespace My + ''' + ''' Module used to define the properties that are available in the My Namespace for WPF + ''' + ''' + _ + Module MyWpfExtension + Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) + Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) + Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) + Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) + ''' + ''' Returns the application object for the running application + ''' + _ + Friend ReadOnly Property Application() As Application + Get + Return CType(Global.System.Windows.Application.Current, Application) + End Get + End Property + ''' + ''' Returns information about the host computer. + ''' + _ + Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer + Get + Return s_Computer.GetInstance() + End Get + End Property + ''' + ''' Returns information for the current user. If you wish to run the application with the current + ''' Windows user credentials, call My.User.InitializeWithWindowsUser(). + ''' + _ + Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User + Get + Return s_User.GetInstance() + End Get + End Property + ''' + ''' Returns the application log. The listeners can be configured by the application's configuration file. + ''' + _ + Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log + Get + Return s_Log.GetInstance() + End Get + End Property + + ''' + ''' Returns the collection of Windows defined in the project. + ''' + _ + Friend ReadOnly Property Windows() As MyWindows + _ + Get + Return s_Windows.GetInstance() + End Get + End Property + _ + _ + Friend NotInheritable Class MyWindows + _ + Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T + If Instance Is Nothing Then + If s_WindowBeingCreated IsNot Nothing Then + If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then + Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") + End If + Else + s_WindowBeingCreated = New Global.System.Collections.Hashtable() + End If + s_WindowBeingCreated.Add(GetType(T), Nothing) + Return New T() + s_WindowBeingCreated.Remove(GetType(T)) + Else + Return Instance + End If + End Function + _ + _ + Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) + instance = Nothing + End Sub + _ + _ + Public Sub New() + MyBase.New() + End Sub + Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable + Public Overrides Function Equals(ByVal o As Object) As Boolean + Return MyBase.Equals(o) + End Function + Public Overrides Function GetHashCode() As Integer + Return MyBase.GetHashCode + End Function + _ + _ + Friend Overloads Function [GetType]() As Global.System.Type + Return GetType(MyWindows) + End Function + Public Overrides Function ToString() As String + Return MyBase.ToString + End Function + End Class + End Module +End Namespace +Partial Class Application + Inherits Global.System.Windows.Application + _ + _ + Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo + _ + Get + Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) + End Get + End Property +End Class +#End If \ No newline at end of file diff --git a/Supervisor/My Project/Resources.Designer.vb b/Supervisor/My Project/Resources.Designer.vb new file mode 100644 index 0000000..b22e10f --- /dev/null +++ b/Supervisor/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:$clrversion$ +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("$safeprojectname$.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/Supervisor/My Project/Resources.resx b/Supervisor/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Supervisor/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Supervisor/My Project/Settings.Designer.vb b/Supervisor/My Project/Settings.Designer.vb new file mode 100644 index 0000000..00edecd --- /dev/null +++ b/Supervisor/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.Supervisor.My.MySettings + Get + Return Global.Supervisor.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/Supervisor/My Project/Settings.settings b/Supervisor/My Project/Settings.settings new file mode 100644 index 0000000..40ed9fd --- /dev/null +++ b/Supervisor/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Supervisor/Supervisor.vbproj b/Supervisor/Supervisor.vbproj new file mode 100644 index 0000000..3d7ac87 --- /dev/null +++ b/Supervisor/Supervisor.vbproj @@ -0,0 +1,238 @@ + + + + Debug + AnyCPU + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA} + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + WinExe + Supervisor + Supervisor + v4.7.2 + Custom + true + true + + + + + On + + + Binary + + + Off + + + On + + + true + true + true + bin\x86\Debug\ + Supervisor.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + full + x86 + true + + + true + bin\x86\Release\ + Supervisor.xml + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + pdbonly + x86 + true + + + true + true + true + bin\x64\Debug\ + Supervisor.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + full + x64 + true + + + true + bin\x64\Release\ + Supervisor.xml + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + pdbonly + x64 + true + + + + ..\packages\KeraLua.1.4.1\lib\net46\KeraLua.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Pipelines.Sockets.Unofficial.2.2.8\lib\net472\Pipelines.Sockets.Unofficial.dll + + + ..\packages\StackExchange.Redis.2.7.33\lib\net472\StackExchange.Redis.dll + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + True + True + + + ..\packages\System.IO.Pipelines.5.0.1\lib\net461\System.IO.Pipelines.dll + + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Channels.5.0.0\lib\net461\System.Threading.Channels.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + + + + + + 4.0 + + + + + + + + + MSBuild:Compile + Designer + + + + + + + + + + + + + + + + + + MSBuild:Compile + Designer + + + Application.xaml + Code + + + + MainWindowV.xaml + Code + + + + + + + + + + + + + + + + + + + + + + + + + Code + + + Microsoft.VisualBasic.WPF.MyExtension + 1.0.0.0 + + + True + True + Resources.resx + + + True + Settings.settings + True + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + + + + + {7D14D864-2BDC-4785-80F4-320164C2D5E4} + Supervisor.Plugin.Interface + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\Supervisor\SupervisorR32.exe +IF "$(PlatformName)"=="x86" IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\Supervisor\SupervisorD32.exe +IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Release" copy $(TargetPath) c:\EgtProg\Supervisor\SupervisorR64.exe +IF "$(PlatformName)"=="x64" IF "$(ConfigurationName)" == "Debug" copy $(TargetPath) c:\EgtProg\Supervisor\SupervisorD64.exe + + + \ No newline at end of file diff --git a/Supervisor/Utility/GenInterface.vb b/Supervisor/Utility/GenInterface.vb new file mode 100644 index 0000000..f7bf24d --- /dev/null +++ b/Supervisor/Utility/GenInterface.vb @@ -0,0 +1,76 @@ +Imports System.Globalization +Imports System.Runtime.InteropServices +Imports System.Text + +Public Module GenInterface + + '-------------------------------- IniFile : Get -------------------------------------------------- + + Public Function GetPrivateProfileInt( + lpAppName As String, + lpKeyName As String, + nDefault As Integer, + lpFileName As String) As Integer + End Function + + Public Function GetPrivateProfileDouble( + lpAppName As String, + lpKeyName As String, + dDefault As Double, + lpFileName As String) As Double + Dim sValue As String = String.Empty + GetPrivateProfileString(lpAppName, lpKeyName, dDefault.ToString(), sValue, lpFileName) + Dim nPos As Integer = sValue.IndexOf(";") + If nPos >= 0 Then + sValue = sValue.Remove(nPos) + End If + Dim dValue As Double + If Not Double.TryParse(sValue, NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, dValue) Then + dValue = dDefault + End If + Return dValue + End Function + + + Private Function GetPrivateProfileString( + lpAppName As String, + lpKeyName As String, + lpDefault As String, + lpReturnedString As StringBuilder, + nSize As Integer, + lpFileName As String) As Integer + End Function + Public Function GetPrivateProfileString( + lpAppName As String, + lpKeyName As String, + lpDefault As String, + ByRef lpString As String, + lpFileName As String) As Integer + Dim sb As New StringBuilder(1024) + Dim nRet As Integer = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, sb, sb.Capacity, lpFileName) + lpString = sb.ToString + Return nRet + End Function + + '-------------------------------- IniFile : Write ------------------------------------------------ + + Public Function WritePrivateProfileString( + lpAppName As String, + lpKeyName As String, + lpString As String, + lpFileName As String) As Boolean + End Function + + '-------------------------------- Windows -------------------------------------------------------- + Public Enum SW As Integer + HIDE = 0 + SHOWMAXIMIZED = 3 + RESTORE = 9 + End Enum + + + Public Function ShowWindow(hWnd As IntPtr, nCmdShow As Integer) As Boolean + End Function + + +End Module diff --git a/Supervisor/Utility/IniFile.vb b/Supervisor/Utility/IniFile.vb new file mode 100644 index 0000000..2e61f35 --- /dev/null +++ b/Supervisor/Utility/IniFile.vb @@ -0,0 +1,66 @@ +'---------------------------------------------------------------------------- +' EgalTech 2017-2017 +'---------------------------------------------------------------------------- +' File : IniFile.vb Data : 08.05.24 Versione : 2.6e1 +' Contenuto : Modulo IniFile per gestione lettura/scrittura da file INI. +' +' +' +' Modifiche : 08.05.24 ES Creazione modulo. +' +' +'---------------------------------------------------------------------------- + + +Imports System.Collections.ObjectModel +Imports EgtUILib + +Public Module IniFile + + Private m_sPath As String + Public ReadOnly Property sPath As String + Get + Return m_sPath + End Get + End Property + Friend Sub SetIniFile(sPath) + m_sPath = sPath + End Sub + + Public Function GetMainPrivateProfileInt(IpAppName As String, IpKeyName As String, nDefault As Integer) As Integer + Return GetPrivateProfileInt(IpAppName, IpKeyName, nDefault, m_sPath) + End Function + + Public Function GetMainPrivateProfileDouble(IpAppName As String, IpKeyName As String, dDefault As Double) As Double + Return GetPrivateProfileDouble(IpAppName, IpKeyName, dDefault, m_sPath) + End Function + + Public Function GetMainPrivateProfileString(IpAppName As String, IpKeyName As String, IpDefault As String, ByRef IpString As String) As Integer + Return GetPrivateProfileString(IpAppName, IpKeyName, IpDefault, IpString, m_sPath) + End Function + + 'Public Function GetPrivateProfileLanguage(lpAppName As String, lpKeyName As String, lpFileName As String) As Language + ' Dim sVal As String = String.Empty + ' GetPrivateProfileString(lpAppName, lpKeyName, "", sVal, lpFileName) + ' Dim sItems() As String = sVal.Split(",".ToCharArray) + ' If sItems.Count() = 2 Then + ' Return New Language(sItems(0), sItems(1)) + ' End If + ' Return Nothing + 'End Function + + 'Public Function GetMainPrivateProfileLanguage(lpAppName As String, lpKeyName As String) As Language + ' Dim sVal As String = String.Empty + ' GetMainPrivateProfileString(lpAppName, lpKeyName, "", sVal) + ' Dim sItems() As String = sVal.Split(",".ToCharArray) + ' If sItems.Count() = 2 Then + ' Return New Language(sItems(0), sItems(1)) + ' End If + ' Return Nothing + 'End Function + + Public Function WriteMainPrivateProfileString(IpAppName As String, IpKeyName As String, ByRef IpString As String) As Boolean + Return WritePrivateProfileString(IpAppName, IpKeyName, IpString, m_sPath) + End Function + +End Module diff --git a/Supervisor/Utility/Map.vb b/Supervisor/Utility/Map.vb new file mode 100644 index 0000000..fa22dee --- /dev/null +++ b/Supervisor/Utility/Map.vb @@ -0,0 +1,100 @@ +Imports EgtWPFLib5 + +Module Map + + Private m_refMainWindowVM As MainWindowVM + 'Private m_refMyStatusBarVM As MyStatusBarVM + 'Private m_refProjManagerVM As ProjManagerVM + 'Private m_refProjectVM As ProjectVM + 'Private m_refSecondaryWindowVM As SecondaryWindowVM + 'Private m_refSecondaryWindowV As SecondaryWindowV + +#Region "Get" + + Public ReadOnly Property refMainWindowVM As MainWindowVM + Get + Return m_refMainWindowVM + End Get + End Property + + 'Public ReadOnly Property refMyStatusBarVM As MyStatusBarVM + ' Get + ' Return LibMap.refStatusBarVM + ' End Get + 'End Property + + 'Public ReadOnly Property refProjManagerVM As ProjManagerVM + ' Get + ' Return m_refProjManagerVM + ' End Get + 'End Property + + 'Public ReadOnly Property refProjectVM As ProjectVM + ' Get + ' Return m_refProjectVM + ' End Get + 'End Property + + 'Public ReadOnly Property refSecondaryWindowVM As SecondaryWindowVM + ' Get + ' Return m_refSecondaryWindowVM + ' End Get + 'End Property + 'Public ReadOnly Property refSecondaryWindowV As SecondaryWindowV + ' Get + ' Return m_refSecondaryWindowV + ' End Get + 'End Property + +#End Region ' Get + +#Region "Set" + + 'Friend Function SetRefMyStatusBarVM(MyStatusBarVM As MyStatusBarVM) As Boolean + ' LibMap.SetRefStatusBarVM(MyStatusBarVM) + ' Return Not IsNothing(LibMap.refStatusBarVM) + 'End Function + + 'Friend Function SetRefProjManagerVM(ProjManagerVM As ProjManagerVM) As Boolean + ' m_refProjManagerVM = ProjManagerVM + ' Return Not IsNothing(m_refProjManagerVM) + 'End Function + + 'Friend Function SetRefProjectVM(ProjectVM As ProjectVM) As Boolean + ' m_refProjectVM = ProjectVM + ' Return Not IsNothing(m_refProjectVM) + 'End Function + + 'Friend Function SetRefSecondaryWindowVM(SecondaryWindowVM As SecondaryWindowVM) As Boolean + ' m_refSecondaryWindowVM = SecondaryWindowVM + ' Return Not IsNothing(m_refSecondaryWindowVM) + 'End Function + 'Friend Function SetRefSecondaryWindowV(SecondaryWindowV As SecondaryWindowV) As Boolean + ' m_refSecondaryWindowV = SecondaryWindowV + ' Return Not IsNothing(m_refSecondaryWindowV) + 'End Function + +#End Region ' Set + +#Region "Init" + + Friend Function BeginInit(MainWindowVM As MainWindowVM) As Boolean + m_refMainWindowVM = MainWindowVM + Return Not IsNothing(m_refMainWindowVM) + End Function + Friend Function EndInit() As Boolean + ' Verifico se tutti i pezzi necessari sono stati caricati + 'Return Not IsNothing(m_refMainWindowVM) AndAlso Not IsNothing(m_refProjectVM) AndAlso + ' Not IsNothing(LibMap.refStatusBarVM) AndAlso Not IsNothing(m_refProjectManagerVM) AndAlso + ' Not IsNothing(LibMap.refSceneHostVM) AndAlso Not IsNothing(LibMap.refShowPanelVM) AndAlso + ' Not IsNothing(m_refVeinMatchPanelVM) AndAlso + ' Not IsNothing(m_refOptionPanelVM) AndAlso Not IsNothing(m_refRawPartTabVM) AndAlso + ' Not IsNothing(m_refNestingTabVM) AndAlso Not IsNothing(m_refSimulTabVM) AndAlso + ' Not IsNothing(m_refMachiningTabVM) AndAlso + ' LibMap.EndInit() + Return Not IsNothing(m_refMainWindowVM) + End Function + +#End Region ' Init + +End Module diff --git a/Supervisor/Utility/RedisManager.vb b/Supervisor/Utility/RedisManager.vb new file mode 100644 index 0000000..c476856 --- /dev/null +++ b/Supervisor/Utility/RedisManager.vb @@ -0,0 +1,56 @@ +Imports StackExchange +Imports StackExchange.Redis + +Class RedisManager + + ' connessione al server Redis + Private m_RedisConnection As ConnectionMultiplexer + Public ReadOnly Property RedisConnection As ConnectionMultiplexer + Get + Return m_RedisConnection + End Get + End Property + + ' indice del Db Redis + Private m_nRedisDbIndex As Integer = 0 + Public ReadOnly Property nRedisDbIndex As Integer + Get + Return m_nRedisDbIndex + End Get + End Property + + ' Database Redis + Private m_RedisDb As IDatabase + Public ReadOnly Property RedisDb As IDatabase + Get + Return m_RedisDb + End Get + End Property + + ' gestore sottoscrizioni + Private m_Subscriber As ISubscriber + Public ReadOnly Property Subscriber As ISubscriber + Get + Return m_Subscriber + End Get + End Property + + Sub New() + Try + ' inizializzo connessione al server Redis + m_RedisConnection = ConnectionMultiplexer.Connect("localhost") + m_nRedisDbIndex = GetMainPrivateProfileInt(S_REDIS, K_DBINDEX, 0) + m_RedisDb = m_RedisConnection.GetDatabase(m_nRedisDbIndex) + ' inizializzo sottoscrizioni + m_Subscriber = m_RedisConnection.GetSubscriber() + m_Subscriber.Subscribe("Messages", AddressOf SubscribeHandler) + Catch ex As Exception + EgtOutLog("Redis connection error!! " & Environment.NewLine & ex.Message) + End Try + End Sub + + Private Sub SubscribeHandler(RedisChannel As RedisChannel, RedisValue As RedisValue) + EgtOutLog("Ricevuto valore " & RedisValue.ToString() & " dal canale " & RedisChannel.ToString()) + End Sub + +End Class diff --git a/Supervisor/packages.config b/Supervisor/packages.config new file mode 100644 index 0000000..adb8bb8 --- /dev/null +++ b/Supervisor/packages.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file