diff --git a/EgwMultiEngineManager.Console/App.config b/EgwMultiEngineManager.Console/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/EgwMultiEngineManager.Console/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/EgwMultiEngineManager.Console/EgwMultiEngineManager.Console.vbproj b/EgwMultiEngineManager.Console/EgwMultiEngineManager.Console.vbproj new file mode 100644 index 0000000..9b9a3a1 --- /dev/null +++ b/EgwMultiEngineManager.Console/EgwMultiEngineManager.Console.vbproj @@ -0,0 +1,169 @@ + + + + + Debug + AnyCPU + {95E6D3B9-1E04-4A63-86ED-4F1F6593B71C} + Exe + EgwMultiEngineManager.Console.MainModule + EgwMultiEngineManager.Console + EgwMultiEngineManager.Console + 512 + Console + v4.7.2 + true + true + + + + + AnyCPU + true + full + true + true + bin\Debug\ + EgwMultiEngineManager.Console.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + AnyCPU + pdbonly + false + true + true + bin\Release\ + EgwMultiEngineManager.Console.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Pipelines.Sockets.Unofficial.2.2.8\lib\net472\Pipelines.Sockets.Unofficial.dll + + + ..\packages\StackExchange.Redis.2.8.47\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 + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + + {6359139b-a3ad-4502-90f3-2d422119273d} + EgwMultiEngineManager + + + + + + + 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}. + + + + \ No newline at end of file diff --git a/EgwMultiEngineManager.Console/MainModule.vb b/EgwMultiEngineManager.Console/MainModule.vb new file mode 100644 index 0000000..418cab6 --- /dev/null +++ b/EgwMultiEngineManager.Console/MainModule.vb @@ -0,0 +1,68 @@ +Imports System.IO +Imports EgwMultiEngineManager.ExecProcessManager +Imports Newtonsoft.Json +Imports Pipelines.Sockets.Unofficial.SocketConnection +Imports StackExchange.Redis + +Module MainModule + + Private m_bDebug As Boolean = True + + Private m_ExecProcessManager As ExecProcessManager + + ' 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 InputChn As New RedisChannel("EgwEngineInput", RedisChannel.PatternMode.Auto) + Private OutputChn As New RedisChannel("EgwEngineOutput", RedisChannel.PatternMode.Auto) + + Sub Main() + If IsNothing(m_ExecProcessManager) Then + Dim sCamExePath As String = "c:\EgtProg\EgtEngine\EgtEngineR32.exe" + Dim sMainLuaPath As String = "c:\Temp\EgwMultiEngineManager\Pipe.lua" + m_ExecProcessManager = New ExecProcessManager(sCamExePath, sMainLuaPath, 1, ReturnModes.EVENT_) + m_ExecProcessManager.StartExecutionThread() + AddHandler m_ExecProcessManager.m_AnswerReceived, AddressOf ExecProcessManager_AnswerReceived + End If + m_RedisManager = New RedisManager("localhost", 1) + m_RedisManager.SubscribeChannel("EgwEngineInput", AddressOf EgwEngineInputHandler) + m_RedisManager.SubscribeChannel("EgwEngineOutput", AddressOf EgwEngineOutputHandler) + + ' funzionamento simulato + If m_bDebug Then + Dim sRead As String = System.Console.ReadLine() + While Not String.IsNullOrWhiteSpace(sRead) + ' passo dati per esecuzione + Dim Args As New Dictionary(Of String, String) + Dim ReadFile As String = File.ReadAllText("c:\Temp\EgwMultiEngineManager\AntaSingola.jwd") + Args.Add("Mode", "1") + Args.Add("Jwd", ReadFile) + Dim InputValue As New RedisValue(New ProcessArgs(1, Args).sProcessArgs) + + m_RedisManager.Subscriber.Publish(InputChn, InputValue) + + sRead = System.Console.ReadLine() + End While + End If + End Sub + + Private Sub ExecProcessManager_AnswerReceived(Answer As ProcessArgsResult) + m_RedisManager.Subscriber.Publish(OutputChn, JsonConvert.SerializeObject(Answer)) + End Sub + + Private Sub EgwEngineInputHandler(RedisChannel As RedisChannel, RedisValue As RedisValue) + System.Console.WriteLine("Ricevuto valore " & RedisValue.ToString() & " dal canale " & RedisChannel.ToString()) + Dim Request As ProcessArgs = JsonConvert.DeserializeObject(Of ProcessArgs)(RedisValue) + m_ExecProcessManager.ArgumentsEnqueue(Request) + End Sub + + Private Sub EgwEngineOutputHandler(RedisChannel As RedisChannel, RedisValue As RedisValue) + System.Console.WriteLine("Ricevuto valore " & RedisValue.ToString() & " dal canale " & RedisChannel.ToString()) + End Sub + +End Module diff --git a/EgwMultiEngineManager.Console/My Project/Application.Designer.vb b/EgwMultiEngineManager.Console/My Project/Application.Designer.vb new file mode 100644 index 0000000..88dd01c --- /dev/null +++ b/EgwMultiEngineManager.Console/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' 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 + diff --git a/EgwMultiEngineManager.Console/My Project/Application.myapp b/EgwMultiEngineManager.Console/My Project/Application.myapp new file mode 100644 index 0000000..e62f1a5 --- /dev/null +++ b/EgwMultiEngineManager.Console/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 2 + true + diff --git a/EgwMultiEngineManager.Console/My Project/AssemblyInfo.vb b/EgwMultiEngineManager.Console/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..21c6256 --- /dev/null +++ b/EgwMultiEngineManager.Console/My Project/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' 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 + + + + + + + + + + +'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 +' + + + diff --git a/EgwMultiEngineManager.Console/My Project/Resources.Designer.vb b/EgwMultiEngineManager.Console/My Project/Resources.Designer.vb new file mode 100644 index 0000000..3c35b81 --- /dev/null +++ b/EgwMultiEngineManager.Console/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' 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.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("EgwMultiEngineManager.Console.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/EgwMultiEngineManager.Console/My Project/Resources.resx b/EgwMultiEngineManager.Console/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/EgwMultiEngineManager.Console/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/EgwMultiEngineManager.Console/My Project/Settings.Designer.vb b/EgwMultiEngineManager.Console/My Project/Settings.Designer.vb new file mode 100644 index 0000000..c4b90ea --- /dev/null +++ b/EgwMultiEngineManager.Console/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.EgwMultiEngineManager.Console.My.MySettings + Get + Return Global.EgwMultiEngineManager.Console.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/EgwMultiEngineManager.Console/My Project/Settings.settings b/EgwMultiEngineManager.Console/My Project/Settings.settings new file mode 100644 index 0000000..85b890b --- /dev/null +++ b/EgwMultiEngineManager.Console/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/EgwMultiEngineManager.Console/Utility/RedisManager.vb b/EgwMultiEngineManager.Console/Utility/RedisManager.vb new file mode 100644 index 0000000..6964fa0 --- /dev/null +++ b/EgwMultiEngineManager.Console/Utility/RedisManager.vb @@ -0,0 +1,62 @@ +Imports System +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(sConnection As String, nDbIndex As Integer) + Try + ' inizializzo connessione al server Redis + m_RedisConnection = ConnectionMultiplexer.Connect(sConnection) + m_RedisDb = m_RedisConnection.GetDatabase(nDbIndex) + ' inizializzo sottoscrizioni + m_Subscriber = m_RedisConnection.GetSubscriber() + 'Dim InputChn As New RedisChannel("Messages", RedisChannel.PatternMode.Auto) + 'm_Subscriber.Subscribe(InputChn, AddressOf SubscribeHandler) + Catch ex As Exception + System.Console.WriteLine("Redis connection error!! " & Environment.NewLine & ex.Message) + End Try + End Sub + + Private Sub SubscribeHandler(RedisChannel As RedisChannel, RedisValue As RedisValue) + System.Console.WriteLine("Ricevuto valore " & RedisValue.ToString() & " dal canale " & RedisChannel.ToString()) + End Sub + + Friend Sub SubscribeChannel(sName As String, Handler As Action(Of RedisChannel, RedisValue)) + m_Subscriber = m_RedisConnection.GetSubscriber() + Dim InputChn As New RedisChannel(sName, RedisChannel.PatternMode.Auto) + m_Subscriber.Subscribe(InputChn, Handler) + End Sub + +End Class diff --git a/EgwMultiEngineManager.Console/packages.config b/EgwMultiEngineManager.Console/packages.config new file mode 100644 index 0000000..fb4a43b --- /dev/null +++ b/EgwMultiEngineManager.Console/packages.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EgwMultiEngineManager.Test/MainWindow/MainWindowVM.vb b/EgwMultiEngineManager.Test/MainWindow/MainWindowVM.vb index d8aa2e1..2db4a86 100644 --- a/EgwMultiEngineManager.Test/MainWindow/MainWindowVM.vb +++ b/EgwMultiEngineManager.Test/MainWindow/MainWindowVM.vb @@ -10,6 +10,7 @@ Public Class MainWindowVM Private m_RefreshGraphicsTimer As New DispatcherTimer Private m_ExecProcessManager As ExecProcessManager + Private m_nCounter As Integer = 0 Public ReadOnly Property nCounter As Integer Get @@ -17,6 +18,7 @@ Public Class MainWindowVM Return m_nCounter End Get End Property + ' Definizione comandi Private m_cmdAddToList As ICommand @@ -27,10 +29,10 @@ Public Class MainWindowVM m_ExecProcessManager = New ExecProcessManager(sCamExePath, sMainLuaPath, 1, ReturnModes.EVENT_) 'm_ExecProcessManager.SetPostProcess(AddressOf ExecProcessManager_PostProcess) AddHandler m_ExecProcessManager.m_AllArgsProcessed, AddressOf ExecProcessManager_AllArgsProcessed - m_ExecProcessManager.SetMaxCamInstances(1) + ' m_ExecProcessManager.SetMaxCamInstances(1) m_ExecProcessManager.StartExecutionThread() End If - m_RefreshGraphicsTimer.Interval = New TimeSpan(0, 0, 1) + m_RefreshGraphicsTimer.Interval = New TimeSpan(0, 0, 10) AddHandler m_RefreshGraphicsTimer.Tick, AddressOf RefreshGraphicsTimer_Tick End Sub diff --git a/EgwMultiEngineManager.sln b/EgwMultiEngineManager.sln index 1060677..e1d6282 100644 --- a/EgwMultiEngineManager.sln +++ b/EgwMultiEngineManager.sln @@ -1,12 +1,14 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.14.36301.6 d17.14 +VisualStudioVersion = 17.14.36301.6 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgwMultiEngineManager", "EgwMultiEngineManager\EgwMultiEngineManager.vbproj", "{6359139B-A3AD-4502-90F3-2D422119273D}" EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgwMultiEngineManager.Test", "EgwMultiEngineManager.Test\EgwMultiEngineManager.Test.vbproj", "{EB14FB72-41BA-4BF3-A24C-14AD2BDD3ABE}" EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgwMultiEngineManager.Console", "EgwMultiEngineManager.Console\EgwMultiEngineManager.Console.vbproj", "{95E6D3B9-1E04-4A63-86ED-4F1F6593B71C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {EB14FB72-41BA-4BF3-A24C-14AD2BDD3ABE}.Debug|Any CPU.Build.0 = Debug|Any CPU {EB14FB72-41BA-4BF3-A24C-14AD2BDD3ABE}.Release|Any CPU.ActiveCfg = Release|Any CPU {EB14FB72-41BA-4BF3-A24C-14AD2BDD3ABE}.Release|Any CPU.Build.0 = Release|Any CPU + {95E6D3B9-1E04-4A63-86ED-4F1F6593B71C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95E6D3B9-1E04-4A63-86ED-4F1F6593B71C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95E6D3B9-1E04-4A63-86ED-4F1F6593B71C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95E6D3B9-1E04-4A63-86ED-4F1F6593B71C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/EgwMultiEngineManager/ExecProcessManager.vb b/EgwMultiEngineManager/ExecProcessManager.vb index f75b60d..f0e65e9 100644 --- a/EgwMultiEngineManager/ExecProcessManager.vb +++ b/EgwMultiEngineManager/ExecProcessManager.vb @@ -668,7 +668,7 @@ Public Class ProcessArgs End Property - Friend ReadOnly Property sProcessArgs As String + Public ReadOnly Property sProcessArgs As String Get Return JsonConvert.SerializeObject(Me, Formatting.None) End Get