69 lines
2.8 KiB
VB.net
69 lines
2.8 KiB
VB.net
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
|