diff --git a/EgwMultiEngineManager.Console/EgwMultiEngineManager.Console.vbproj b/EgwMultiEngineManager.Console/EgwMultiEngineManager.Console.vbproj
index 6aa3e13..0fb1e2f 100644
--- a/EgwMultiEngineManager.Console/EgwMultiEngineManager.Console.vbproj
+++ b/EgwMultiEngineManager.Console/EgwMultiEngineManager.Console.vbproj
@@ -156,6 +156,10 @@
+
+ {4d7f7c94-4aaa-4005-8995-f25065280c59}
+ EgwMultiEngineManager.Data
+
{6359139b-a3ad-4502-90f3-2d422119273d}
EgwMultiEngineManager
diff --git a/EgwMultiEngineManager.Console/MainModule.vb b/EgwMultiEngineManager.Console/MainModule.vb
index 9b4ec9d..bf3d380 100644
--- a/EgwMultiEngineManager.Console/MainModule.vb
+++ b/EgwMultiEngineManager.Console/MainModule.vb
@@ -1,4 +1,5 @@
-Imports EgwMultiEngineManager.ExecProcessManager
+Imports EgwMultiEngineManager.Data
+Imports EgwMultiEngineManager.ExecProcessManager
Imports Newtonsoft.Json
Imports StackExchange.Redis
@@ -54,7 +55,7 @@ Module MainModule
End If
End Sub
- Private Sub ExecProcessManager_AnswerReceived(Answer As ProcessArgsResult)
+ Private Sub ExecProcessManager_AnswerReceived(Answer As Answer)
m_RedisManager.Subscriber.Publish(OutputChn, JsonConvert.SerializeObject(Answer))
m_stopWatch.Stop()
' Format and display the TimeSpan value.
@@ -65,7 +66,7 @@ Module MainModule
Private Sub EgwEngineInputHandler(RedisChannel As RedisChannel, RedisValue As RedisValue)
System.Console.WriteLine("Received value from channel " & RedisChannel.ToString())
m_stopWatch.Restart()
- Dim Request As ProcessArgs = JsonConvert.DeserializeObject(Of ProcessArgs)(RedisValue)
+ Dim Request As Question = JsonConvert.DeserializeObject(Of Question)(RedisValue)
m_ExecProcessManager.ArgumentsEnqueue(Request)
End Sub
diff --git a/EgwMultiEngineManager.Data/Answer.vb b/EgwMultiEngineManager.Data/Answer.vb
new file mode 100644
index 0000000..79ef362
--- /dev/null
+++ b/EgwMultiEngineManager.Data/Answer.vb
@@ -0,0 +1,41 @@
+Imports Newtonsoft.Json
+
+Public Class Answer
+
+ Private m_nThreadIndex As Integer
+ Public ReadOnly Property nThreadIndex As Integer
+ Get
+ Return m_nThreadIndex
+ End Get
+ End Property
+
+ Private m_nId As Integer
+ Public ReadOnly Property nId As Integer
+ Get
+ Return m_nId
+ End Get
+ End Property
+
+ Private m_nResult As Integer
+ Public ReadOnly Property nResult As Integer
+ Get
+ Return m_nResult
+ End Get
+ End Property
+
+ Private m_Args As New Dictionary(Of String, String)
+ Public ReadOnly Property Args As Dictionary(Of String, String)
+ Get
+ Return m_Args
+ End Get
+ End Property
+
+
+ Sub New(nThreadIndex As Integer, nId As Integer, nResult As Integer, Args As Dictionary(Of String, String))
+ m_nThreadIndex = nThreadIndex
+ m_nId = nId
+ m_nResult = nResult
+ m_Args = Args
+ End Sub
+
+End Class
diff --git a/EgwMultiEngineManager.Data/EgwMultiEngineManager.Data.vbproj b/EgwMultiEngineManager.Data/EgwMultiEngineManager.Data.vbproj
new file mode 100644
index 0000000..64e654a
--- /dev/null
+++ b/EgwMultiEngineManager.Data/EgwMultiEngineManager.Data.vbproj
@@ -0,0 +1,12 @@
+
+
+
+ EgwMultiEngineManager.Data
+ netstandard2.0
+
+
+
+
+
+
+
diff --git a/EgwMultiEngineManager.Data/Question.vb b/EgwMultiEngineManager.Data/Question.vb
new file mode 100644
index 0000000..39b10b2
--- /dev/null
+++ b/EgwMultiEngineManager.Data/Question.vb
@@ -0,0 +1,41 @@
+Imports Newtonsoft.Json
+
+Public Class Question
+
+ Private m_nThreadIndex As Integer
+ Public ReadOnly Property nThreadIndex As Integer
+ Get
+ Return m_nThreadIndex
+ End Get
+ End Property
+ Public Sub SetThreadIndex(nIndex As Integer)
+ m_nThreadIndex = nIndex
+ End Sub
+
+ Private m_nId As Integer
+ Public ReadOnly Property nId As Integer
+ Get
+ Return m_nId
+ End Get
+ End Property
+
+ Private m_Args As New Dictionary(Of String, String)
+ Public ReadOnly Property Args As Dictionary(Of String, String)
+ Get
+ Return m_Args
+ End Get
+ End Property
+
+
+ Public ReadOnly Property sProcessArgs As String
+ Get
+ Return JsonConvert.SerializeObject(Me, Formatting.None)
+ End Get
+ End Property
+
+ Sub New(nId As Integer, Args As Dictionary(Of String, String))
+ m_nId = nId
+ m_Args = Args
+ End Sub
+
+End Class
diff --git a/EgwMultiEngineManager.Data/Statistics.vb b/EgwMultiEngineManager.Data/Statistics.vb
new file mode 100644
index 0000000..b079b41
--- /dev/null
+++ b/EgwMultiEngineManager.Data/Statistics.vb
@@ -0,0 +1,81 @@
+Public Class Statistics
+
+ Private m_nEngineRunningQty As Integer
+ Public ReadOnly Property nEngineRunningQty As Integer
+ Get
+ Return m_nEngineRunningQty
+ End Get
+ End Property
+
+ Private m_nEngineProcessingQty As Integer
+ Public ReadOnly Property nEngineProcessingQty As Integer
+ Get
+ Return m_nEngineProcessingQty
+ End Get
+ End Property
+
+ Private m_dMinProcessingTime As Double
+ Public ReadOnly Property dMinProcessingTime As Double
+ Get
+ Return m_dMinProcessingTime
+ End Get
+ End Property
+
+ Private m_dMidProcessingTime As Double
+ Public ReadOnly Property dMidProcessingTime As Double
+ Get
+ Return m_dMidProcessingTime
+ End Get
+ End Property
+
+ Private m_dMaxProcessingTime As Double
+ Public ReadOnly Property dMaxProcessingTime As Double
+ Get
+ Return m_dMaxProcessingTime
+ End Get
+ End Property
+
+ Private m_nLastMinAnswer As Integer
+ Public ReadOnly Property nLastMinAnswer As Integer
+ Get
+ Return m_nLastMinAnswer
+ End Get
+ End Property
+
+ Private m_nLast5MinAnswer As Integer
+ Public ReadOnly Property nLast5MinAnswer As Integer
+ Get
+ Return m_nLast5MinAnswer
+ End Get
+ End Property
+
+ Private m_nLastHourAnswer As Integer
+ Public ReadOnly Property nLastHourAnswer As Integer
+ Get
+ Return m_nLastHourAnswer
+ End Get
+ End Property
+
+ Private m_nQuestionInQueue As Integer
+ Public ReadOnly Property nQuestionInQueue As Integer
+ Get
+ Return m_nQuestionInQueue
+ End Get
+ End Property
+
+ Sub New(nEngineRunningQty As Integer, nEngineProcessingQty As Integer, nLastMinAnswer As Integer, nLast5MinAnswer As Integer, nLastHourAnswer As Integer, nQuestionInQueue As Integer)
+ m_nEngineRunningQty = nEngineRunningQty
+ m_nEngineProcessingQty = nEngineProcessingQty
+ m_nLastMinAnswer = nLastMinAnswer
+ m_nLast5MinAnswer = nLast5MinAnswer
+ m_nLastHourAnswer = nLastHourAnswer
+ m_nQuestionInQueue = nQuestionInQueue
+ End Sub
+
+ Public Sub SetProcessingTimes(dMinProcessingTime As Double, dMidProcessingTime As Double, dMaxProcessingTime As Double)
+ m_dMinProcessingTime = dMinProcessingTime
+ m_dMidProcessingTime = dMidProcessingTime
+ m_dMaxProcessingTime = dMaxProcessingTime
+ End Sub
+
+End Class
\ No newline at end of file
diff --git a/EgwMultiEngineManager.Service/EgwMultiEngineManager.Service.vbproj b/EgwMultiEngineManager.Service/EgwMultiEngineManager.Service.vbproj
index dff684d..edc05e4 100644
--- a/EgwMultiEngineManager.Service/EgwMultiEngineManager.Service.vbproj
+++ b/EgwMultiEngineManager.Service/EgwMultiEngineManager.Service.vbproj
@@ -175,6 +175,10 @@
+
+ {4d7f7c94-4aaa-4005-8995-f25065280c59}
+ EgwMultiEngineManager.Data
+
{6359139b-a3ad-4502-90f3-2d422119273d}
EgwMultiEngineManager
diff --git a/EgwMultiEngineManager.Service/MainService.vb b/EgwMultiEngineManager.Service/MainService.vb
index 54845de..de9ee8c 100644
--- a/EgwMultiEngineManager.Service/MainService.vb
+++ b/EgwMultiEngineManager.Service/MainService.vb
@@ -1,4 +1,5 @@
-Imports EgwMultiEngineManager.ExecProcessManager
+Imports EgwMultiEngineManager.Data
+Imports EgwMultiEngineManager.ExecProcessManager
Imports Newtonsoft.Json
Imports StackExchange.Redis
@@ -57,7 +58,7 @@ Public Class MainService
End If
End Sub
- Private Sub ExecProcessManager_AnswerReceived(Answer As ProcessArgsResult)
+ Private Sub ExecProcessManager_AnswerReceived(Answer As Answer)
m_RedisManager.Subscriber.Publish(OutputChn, JsonConvert.SerializeObject(Answer))
m_stopWatch.Stop()
' Format and display the TimeSpan value.
@@ -68,7 +69,7 @@ Public Class MainService
Private Sub EgwEngineInputHandler(RedisChannel As RedisChannel, RedisValue As RedisValue)
System.Console.WriteLine("Received value from channel " & RedisChannel.ToString())
m_stopWatch.Restart()
- Dim Request As ProcessArgs = JsonConvert.DeserializeObject(Of ProcessArgs)(RedisValue)
+ Dim Request As Question = JsonConvert.DeserializeObject(Of Question)(RedisValue)
m_ExecProcessManager.ArgumentsEnqueue(Request)
End Sub
diff --git a/EgwMultiEngineManager.Test/Application.xaml.vb b/EgwMultiEngineManager.Test/Application.xaml.vb
index 66161c6..1ebd441 100644
--- a/EgwMultiEngineManager.Test/Application.xaml.vb
+++ b/EgwMultiEngineManager.Test/Application.xaml.vb
@@ -1,5 +1,6 @@
Imports System.Drawing
Imports System.Windows.Forms
+Imports EgwMultiEngineManager.Data
Class Application
@@ -103,7 +104,7 @@ Class Application
Application.Current.Shutdown()
End Sub
- Private Sub ExecProcessManager_StatisticUpdate(e As ManagerStatistics)
+ Private Sub ExecProcessManager_StatisticUpdate(e As Statistics)
Dim Tooltip As String = "QRun " & e.nEngineRunningQty & Environment.NewLine &
"QProc " & e.nEngineProcessingQty & Environment.NewLine &
"MidT " & e.nQuestionInQueue.ToString("N1") & Environment.NewLine &
diff --git a/EgwMultiEngineManager.Test/EgwMultiEngineManager.Test.vbproj b/EgwMultiEngineManager.Test/EgwMultiEngineManager.Test.vbproj
index 6eb5b76..049eca1 100644
--- a/EgwMultiEngineManager.Test/EgwMultiEngineManager.Test.vbproj
+++ b/EgwMultiEngineManager.Test/EgwMultiEngineManager.Test.vbproj
@@ -192,6 +192,10 @@
+
+ {4d7f7c94-4aaa-4005-8995-f25065280c59}
+ EgwMultiEngineManager.Data
+
{6359139b-a3ad-4502-90f3-2d422119273d}
EgwMultiEngineManager
diff --git a/EgwMultiEngineManager.Test/MainWindow/MainWindowVM.vb b/EgwMultiEngineManager.Test/MainWindow/MainWindowVM.vb
index 758c9ba..c4c0ecf 100644
--- a/EgwMultiEngineManager.Test/MainWindow/MainWindowVM.vb
+++ b/EgwMultiEngineManager.Test/MainWindow/MainWindowVM.vb
@@ -1,4 +1,5 @@
-Imports EgwMultiEngineManager.ExecProcessManager
+Imports EgwMultiEngineManager.Data
+Imports EgwMultiEngineManager.ExecProcessManager
Imports EgwWPFBaseLib
Imports Newtonsoft.Json
Imports StackExchange.Redis
@@ -7,7 +8,7 @@ Public Class MainWindowVM
Inherits VMBase
Public Event QuitApplication()
- Public Event StatisticUpdate(Statistics As ManagerStatistics)
+ Public Event StatisticUpdate(Statistics As Statistics)
Private Const ChnName_EgwEngineInput As String = "EgwEngineInput"
Private Const ChnName_EgwEngineOutput As String = "EgwEngineOutput"
@@ -73,7 +74,7 @@ Public Class MainWindowVM
AddHandler m_ExecProcessManager.m_AnswerReceived, AddressOf ExecProcessManager_AnswerReceived
End Sub
- Private Sub ExecProcessManager_AnswerReceived(Answer As ProcessArgsResult)
+ Private Sub ExecProcessManager_AnswerReceived(Answer As Answer)
m_RedisManager.Subscriber.Publish(m_chnEgwEngineOutput, JsonConvert.SerializeObject(Answer))
m_stopWatch.Stop()
' Format and display the TimeSpan value.
@@ -92,12 +93,12 @@ Public Class MainWindowVM
Private Sub EgwEngineInputHandler(RedisChannel As RedisChannel, RedisValue As RedisValue)
System.Console.WriteLine("Received value from channel " & RedisChannel.ToString())
m_stopWatch.Restart()
- Dim Request As ProcessArgs = JsonConvert.DeserializeObject(Of ProcessArgs)(RedisValue)
+ Dim Request As Question = JsonConvert.DeserializeObject(Of Question)(RedisValue)
m_ExecProcessManager.ArgumentsEnqueue(Request)
End Sub
- Private Sub ExecProcessManager_Statistics(e As ManagerStatistics)
- Dim CurrManagerStatistics As ManagerStatistics = e
+ Private Sub ExecProcessManager_Statistics(e As Statistics)
+ Dim CurrManagerStatistics As Statistics = e
CurrManagerStatistics.SetProcessingTimes(m_dMinProcessingTime, m_dMidProcessingTime, m_dMaxProcessingTime)
RaiseEvent StatisticUpdate(CurrManagerStatistics)
m_RedisManager.Subscriber.Publish(m_chnEgwStatistics, JsonConvert.SerializeObject(CurrManagerStatistics))
diff --git a/EgwMultiEngineManager.sln b/EgwMultiEngineManager.sln
index 5982cba..f5392c4 100644
--- a/EgwMultiEngineManager.sln
+++ b/EgwMultiEngineManager.sln
@@ -11,6 +11,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgwMultiEngineManager.Conso
EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgwMultiEngineManager.Service", "EgwMultiEngineManager.Service\EgwMultiEngineManager.Service.vbproj", "{8E7E3A34-B34C-4F21-AFB7-8CF1FD702EB9}"
EndProject
+Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgwMultiEngineManager.Data", "EgwMultiEngineManager.Data\EgwMultiEngineManager.Data.vbproj", "{4D7F7C94-4AAA-4005-8995-F25065280C59}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +35,10 @@ Global
{8E7E3A34-B34C-4F21-AFB7-8CF1FD702EB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E7E3A34-B34C-4F21-AFB7-8CF1FD702EB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E7E3A34-B34C-4F21-AFB7-8CF1FD702EB9}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4D7F7C94-4AAA-4005-8995-F25065280C59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4D7F7C94-4AAA-4005-8995-F25065280C59}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4D7F7C94-4AAA-4005-8995-F25065280C59}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4D7F7C94-4AAA-4005-8995-F25065280C59}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/EgwMultiEngineManager/EgwMultiEngineManager.vbproj b/EgwMultiEngineManager/EgwMultiEngineManager.vbproj
index ede1472..6ad7f50 100644
--- a/EgwMultiEngineManager/EgwMultiEngineManager.vbproj
+++ b/EgwMultiEngineManager/EgwMultiEngineManager.vbproj
@@ -9,6 +9,10 @@
+
+
+
+
..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\WindowsBase.dll
diff --git a/EgwMultiEngineManager/ExecProcessManager.vb b/EgwMultiEngineManager/ExecProcessManager.vb
index 1d4cbb6..7f74401 100644
--- a/EgwMultiEngineManager/ExecProcessManager.vb
+++ b/EgwMultiEngineManager/ExecProcessManager.vb
@@ -1,5 +1,6 @@
Imports System.Threading
Imports System.Windows.Threading
+Imports EgwMultiEngineManager.Data
Imports EgwMultiEngineManager.ThreadData
Imports Newtonsoft.Json
@@ -8,8 +9,8 @@ Public Class ExecProcessManager
Public Event m_AllArgsProcessed()
- Public Event m_AnswerReceived(result As ProcessArgsResult)
- Public Event m_Statistics(Statistics As ManagerStatistics)
+ Public Event m_AnswerReceived(result As Answer)
+ Public Event m_Statistics(Statistics As Statistics)
Public Enum ExecutionThreadStatuses As Integer
RUNNING = 1
@@ -64,34 +65,34 @@ Public Class ExecProcessManager
Private m_sProcessArguments As String = ""
' coda delle cose da eseguire
Private ArgumentsQueueLock As New Object
- Private m_ArgumentsQueue As New Queue(Of ProcessArgs)
- Public ReadOnly Property ArgumentsQueue As Queue(Of ProcessArgs)
+ Private m_ArgumentsQueue As New Queue(Of Question)
+ Public ReadOnly Property ArgumentsQueue As Queue(Of Question)
Get
Return m_ArgumentsQueue
End Get
End Property
' coda dei risultati
Private ArgumentsResultQueueLock As New Object
- Private m_ArgumentsResultQueue As New Queue(Of ProcessArgsResult)
- Public ReadOnly Property ArgumentsResultQueue As Queue(Of ProcessArgsResult)
+ Private m_ArgumentsResultQueue As New Queue(Of Answer)
+ Public ReadOnly Property ArgumentsResultQueue As Queue(Of Answer)
Get
Return m_ArgumentsResultQueue
End Get
End Property
' funzione che richiede prossimo elemento da processare
- Private m_delGetNextProcessArgs As Func(Of ProcessArgs)
- Public Sub SetGetNextProcessArgs(GetNextProcessArgs As Func(Of ProcessArgs))
+ Private m_delGetNextProcessArgs As Func(Of Question)
+ Public Sub SetGetNextProcessArgs(GetNextProcessArgs As Func(Of Question))
m_delGetNextProcessArgs = GetNextProcessArgs
End Sub
' funzione di pre processing dell'elemento
- Private m_delPreProcess As Func(Of ProcessArgs, ProcessArgs)
- Public Sub SetPreProcess(PreProcess As Func(Of ProcessArgs, ProcessArgs))
+ Private m_delPreProcess As Func(Of Question, Question)
+ Public Sub SetPreProcess(PreProcess As Func(Of Question, Question))
m_delPreProcess = PreProcess
End Sub
' funzione di post processing dell'elemento
- Private m_delPostProcess As Action(Of ProcessArgsResult)
- Public Sub SetPostProcess(PostProcess As Action(Of ProcessArgsResult))
+ Private m_delPostProcess As Action(Of Answer)
+ Public Sub SetPostProcess(PostProcess As Action(Of Answer))
m_delPostProcess = PostProcess
End Sub
@@ -139,7 +140,7 @@ Public Class ExecProcessManager
#End Region ' CONSTRUCTORS
- Public Function ArgumentsEnqueue(ProcessArgs As ProcessArgs) As Boolean
+ Public Function ArgumentsEnqueue(ProcessArgs As Question) As Boolean
If ProcessArgs.nId <= 0 OrElse ProcessArgs.Args.Count = 0 Then Return False
SyncLock ArgumentsQueueLock
m_ArgumentsQueue.Enqueue(ProcessArgs)
@@ -147,8 +148,8 @@ Public Class ExecProcessManager
Return True
End Function
- Public Function ArgumentsDequeue() As ProcessArgs
- Dim DequeueProcessArgs As ProcessArgs = Nothing
+ Public Function ArgumentsDequeue() As Question
+ Dim DequeueProcessArgs As Question = Nothing
SyncLock ArgumentsQueueLock
If m_ArgumentsQueue.Count > 0 Then
DequeueProcessArgs = m_ArgumentsQueue.Dequeue()
@@ -165,15 +166,15 @@ Public Class ExecProcessManager
Return nCount
End Function
- Public Function ArgumentsResultEnqueue(ProcessArgsResult As ProcessArgsResult) As Boolean
+ Public Function ArgumentsResultEnqueue(ProcessArgsResult As Answer) As Boolean
SyncLock ArgumentsResultQueueLock
m_ArgumentsResultQueue.Enqueue(ProcessArgsResult)
End SyncLock
Return True
End Function
- Public Function ArgumentsResultDequeue() As ProcessArgsResult
- Dim DequeueProcessArgsResult As ProcessArgsResult = Nothing
+ Public Function ArgumentsResultDequeue() As Answer
+ Dim DequeueProcessArgsResult As Answer = Nothing
SyncLock ArgumentsResultQueueLock
If m_ArgumentsResultQueue.Count > 0 Then
DequeueProcessArgsResult = m_ArgumentsResultQueue.Dequeue()
@@ -212,7 +213,7 @@ Public Class ExecProcessManager
nLastHourAnswer = m_PerMinResultQueue.Sum()
End SyncLock
m_nLastMinAnswerCounter = 0
- Dim CurrManagerStatistics As New ManagerStatistics(nRunningProcesses, nCalculatingProcesses, nLastMinAnswer, nLast5MinAnswer, nLastHourAnswer, nQuestionInQueue)
+ Dim CurrManagerStatistics As New Statistics(nRunningProcesses, nCalculatingProcesses, nLastMinAnswer, nLast5MinAnswer, nLastHourAnswer, nQuestionInQueue)
RaiseEvent m_Statistics(CurrManagerStatistics)
End Sub
@@ -367,7 +368,7 @@ Public Class ExecProcessManager
End If
If Not m_bFirstStatistics Then
m_bFirstStatistics = True
- RaiseEvent m_Statistics(New ManagerStatistics(nRunningProcesses, nCalculatingProcesses, 0, 0, 0, 0))
+ RaiseEvent m_Statistics(New Statistics(nRunningProcesses, nCalculatingProcesses, 0, 0, 0, 0))
End If
Thread.Sleep(1000)
End While
@@ -377,14 +378,6 @@ Public Class ExecProcessManager
Private Sub ThreadFunction(ThreadIndex As Integer)
Dim MyThreadData As New ThreadData
m_ThreadDataList(ThreadIndex) = MyThreadData
- 'Dim CurrThreadStat As New ThreadStat(ThreadIndex, DateTime.Now)
- 'HistoryThreadDataList.Add(CurrThreadStat)
- 'MyThreadData.SetThreadStat(CurrThreadStat)
- 'Dim sDrive As String = "c" ' If(ThreadIndex Mod 2 = 0, "A", "B")
- 'Dim sCurrDdfDir As String = sDrive & ":\EgtData\WebDoor\Ddf"
- 'Dim stopWatch As New Stopwatch()
- 'Dim lExeTime As Long = 0
- 'Dim lOtherTime As Long = 0
' avvio processo
Dim ProcInfo As New ProcessStartInfo(m_sProcessFileName, ThreadIndex.ToString() & " """ & m_sProcessArguments & """")
@@ -392,47 +385,18 @@ Public Class ExecProcessManager
ProcInfo.RedirectStandardOutput = True
ProcInfo.UseShellExecute = False
ProcInfo.CreateNoWindow = True
- 'Dim Proc As Process = New Process()
- 'Proc.StartInfo.FileName = m_sProcessFileName
- 'Proc.StartInfo.RedirectStandardInput = True
- 'Proc.StartInfo.RedirectStandardOutput = True
- 'Proc.StartInfo.Arguments = ThreadIndex.ToString() & " """ & m_sProcessArguments & """"
- 'Proc.StartInfo.UseShellExecute = False
- 'Proc.StartInfo.CreateNoWindow = True
- 'If Proc.Start() Then
Dim Proc = Process.Start(ProcInfo)
AddHandler Proc.OutputDataReceived, AddressOf Thread_OutputDataReceived
If Not (Proc Is Nothing) Then
- 'Dim CurrPocStat As New ProcStat(DateTime.Now)
- 'CurrThreadStat.ProcExecutionList.Add(CurrPocStat)
Proc.BeginOutputReadLine()
MyThreadData.SetProcess(Proc)
MyThreadData.SetProcessStatus(ProcessStatuses.NULL)
-
- 'Dim nProc0Wait As Integer = 0
' ciclo per leggere coda ed eseguire
While Not m_bStopProcess AndAlso Not Proc.HasExited
Select Case MyThreadData.ProcessStatus
Case ThreadData.ProcessStatuses.NULL
- 'MyThreadData.SetThreadOperation(ThreadOperations.WaitingData)
- ' se c'e' qualcosa da processare
- 'Dim nNumTaskToProcess As Integer = 0
- 'If ThreadIndex = 0 Then
- ' nNumTaskToProcess = currWDC.numTask2proc
- ' If nNumTaskToProcess > 0 Then
- ' If Not m_bCheckOrder Then m_bCheckOrder = True
- ' Else
- ' If m_bCheckOrder Then m_bCheckOrder = False
- ' Thread.Sleep(100)
- ' End If
- 'ElseIf m_bCheckOrder Then
- ' nNumTaskToProcess = currWDC.numTask2proc
- ' If nNumTaskToProcess = 0 Then
- ' m_bCheckOrder = False
- ' End If
- 'End If
- Dim NextProcessArgs As ProcessArgs = Nothing
+ Dim NextProcessArgs As Question = Nothing
If m_delGetNextProcessArgs IsNot Nothing Then
NextProcessArgs = m_delGetNextProcessArgs()
Else
@@ -445,66 +409,9 @@ Public Class ExecProcessManager
End If
MyThreadData.SetCurrRequest(NextProcessArgs)
NextProcessArgs.SetThreadIndex(ThreadIndex)
- 'Dim JsonThread As New JsonThread(ThreadIndex, NextProcessArgs.Args)
- 'Dim sThreadData As String = JsonConvert.SerializeObject(JsonThread, Formatting.None)
Proc.StandardInput.WriteLine("#8477271#" & NextProcessArgs.sProcessArgs & "#8477271#")
MyThreadData.SetProcessStatus(ThreadData.ProcessStatuses.WAITINGANSWER)
End If
- 'If m_bCheckOrder Then
- ' Dim LastRequest As Dictionary(Of String, CalcReqtDTO) = currWDC.queueList(1)
- ' If LastRequest.Count > 0 Then
- ' MyThreadData.SetThreadOperation(ThreadOperations.FoundRequest)
-
- ' Dim ConvItem As KeyValuePair(Of String, String)
- ' ConvItem = New KeyValuePair(Of String, String)(LastRequest.First().Key, LastRequest.First().Value.DDF)
- ' MyThreadData.SetCurrRequest(ConvItem)
-
- ' ' vecchia versione
- ' 'MyThreadData.SetCurrRequest(LastRequest.First())
-
- ' Dim Item As KeyValuePair(Of String, String) = MyThreadData.CurrRequest
- ' Dim bOk As Boolean = Not IsNothing(Item)
- ' If bOk Then
-
- ' ' avvio cronometro
- ' 'stopWatch.Reset()
- ' stopWatch.Restart()
- ' ' svuoto vecchio set file della porta richiesta
- ' Dim fileList As String() = Directory.GetFiles(sCurrDdfDir, Item.Key + ".*")
- ' ' elimino vecchi
- ' If Not IsNothing(fileList) Then
- ' For Each sFile In fileList
- ' Try
- ' File.Delete(sFile)
- ' Catch ex As Exception
- ' End Try
- ' Next
- ' End If
-
- ' ' scrivo ddf
- ' MyThreadData.SetThreadOperation(ThreadOperations.WritingDdf)
- ' MyThreadData.SetDdfPath(sCurrDdfDir & "\" & Item.Key & ".ddf")
- ' Dim sDdfPath As String = MyThreadData.sDdfPath
- ' Try
- ' File.WriteAllText(sDdfPath, Item.Value)
- ' Catch ex As Exception
- ' bOk = False
- ' End Try
-
- ' If bOk Then
- ' MyThreadData.SetThreadOperation(ThreadOperations.ProcessingDdf)
-
- ' Proc.StandardInput.WriteLine(ThreadIndex & "," & sDdfPath)
-
- ' MyThreadData.SetWaitProcAnswer(ThreadData.ProcComm.WaitingAnswer)
- ' End If
- ' End If
- ' Else
- ' Thread.Sleep(100)
- ' End If
- 'Else
- ' Thread.Sleep(100)
- 'End If
Case ThreadData.ProcessStatuses.WAITINGANSWER
Thread.Sleep(10)
Case ThreadData.ProcessStatuses.ANSWERRECEIVED
@@ -518,123 +425,25 @@ Public Class ExecProcessManager
Case ReturnModes.EVENT_
RaiseEvent m_AnswerReceived(MyThreadData.nProcResult)
End Select
- 'Dim Item As ProcessArgs = MyThreadData.CurrRequest
- 'Dim sDdfPath As String = MyThreadData.sDdfPath
- 'Dim bOk As Boolean = True
- '' salvo exe time...
- 'stopWatch.Stop()
- 'lExeTime = stopWatch.ElapsedMilliseconds
- 'stopWatch.Restart()
- 'Dim procResults As New List(Of CalcResultDTO)
- 'Dim currRes As New CalcResultDTO
- 'Dim fContent As String = ""
- 'MyThreadData.SetThreadOperation(ThreadOperations.ReadingSvg)
- '' verifico esistenza file svg e lo carico
- 'bOk = GetFileContent(Path.ChangeExtension(sDdfPath, "svg"), fContent)
- '' !!! ToDo: inserire TIPO di richiesta secondo quanto ricevuto....
- '' invio risposta
- 'currRes.Validated = MyThreadData.nProcResult = 0 AndAlso bOk
- 'currRes.DoorIdVers = Item.Key
- '' per ora cablato a svg, prendere da MimeType richiesta...
- 'currRes.MimeType = "svg"
-
- '' se NON fosse validato --> messo il messaggio...
- 'If (currRes.Validated) Then
- ' currRes.RawContent = fContent
- 'Else
- ' bOk = GetFileContent(Path.ChangeExtension(sDdfPath, "txt"), fContent)
- ' currRes.ErrorMsg = fContent
- 'End If
- 'MyThreadData.SetThreadOperation(ThreadOperations.SendResult)
-
- 'procResults.Add(currRes)
- 'Dim respPut As String = currWDC.SendProcResults(procResults)
-
- 'stopWatch.Stop()
- 'lOtherTime = stopWatch.ElapsedMilliseconds
- 'CurrPocStat.IncrementDoneRequest()
- '' aggiorno thread display...
- 'UpdateThreadList(Item.Key, lExeTime, lOtherTime)
- '' cambio nomi file generati in old
- 'Dim OldSvg As String = Path.ChangeExtension(sDdfPath, "svg")
- 'Dim NewSvg As String = Path.GetDirectoryName(sDdfPath) & "\" & Path.GetFileNameWithoutExtension(sDdfPath) & "_old.svg"
- 'Try
- ' File.Delete(NewSvg)
- 'Catch ex As Exception
- 'End Try
- 'Try
- ' File.Delete(Path.ChangeExtension(NewSvg, "txt"))
- 'Catch ex As Exception
- 'End Try
- 'Try
- ' File.Delete(Path.ChangeExtension(NewSvg, "log"))
- 'Catch ex As Exception
- 'End Try
- 'Try
- ' File.Delete(Path.ChangeExtension(NewSvg, "nge"))
- 'Catch ex As Exception
- 'End Try
- 'Try
- ' File.Delete(Path.ChangeExtension(NewSvg, "ddf"))
- 'Catch ex As Exception
- 'End Try
- 'Try
- ' File.Move(OldSvg, NewSvg)
- 'Catch ex As Exception
- 'End Try
- 'Try
- ' File.Move(Path.ChangeExtension(OldSvg, "txt"), Path.ChangeExtension(NewSvg, "txt"))
- 'Catch ex As Exception
- 'End Try
- 'Try
- ' File.Move(Path.ChangeExtension(OldSvg, "log"), Path.ChangeExtension(NewSvg, "log"))
- 'Catch ex As Exception
- 'End Try
- 'Try
- ' File.Move(Path.ChangeExtension(OldSvg, "nge"), Path.ChangeExtension(NewSvg, "nge"))
- 'Catch ex As Exception
- 'End Try
- 'Try
- ' File.Move(Path.ChangeExtension(OldSvg, "ddf"), Path.ChangeExtension(NewSvg, "ddf"))
- 'Catch ex As Exception
- 'End Try
MyThreadData.SetProcessStatus(ThreadData.ProcessStatuses.NULL)
End Select
Threading.Thread.Sleep(10)
End While
- ' CurrPocStat.SetStopProc(DateTime.Now)
If m_bStopProcess Then
Proc.StandardInput.WriteLine("quit")
End If
End If
-
- ' CurrThreadStat.SetStopThread(DateTime.Now)
MyThreadData.SetProcess(Nothing)
- ' MyThreadData.SetThreadOperation(ThreadOperations.Closed)
-
End Sub
Private Sub Thread_OutputDataReceived(sender As Object, e As DataReceivedEventArgs)
Dim sResult As String = e.Data
If Not String.IsNullOrWhiteSpace(sResult) AndAlso sResult.StartsWith("#8376261#") AndAlso sResult.EndsWith("#8376261#") Then
sResult = sResult.Substring(9, sResult.Length - 18)
- Dim Result As ProcessArgsResult = JsonConvert.DeserializeObject(Of ProcessArgsResult)(sResult)
+ Dim Result As Answer = JsonConvert.DeserializeObject(Of Answer)(sResult)
m_ThreadDataList(Result.nId).SetProcResult(Result)
m_ThreadDataList(Result.nId).SetProcessStatus(ThreadData.ProcessStatuses.ANSWERRECEIVED)
End If
- 'If Not String.IsNullOrWhiteSpace(sResult) AndAlso sResult.StartsWith("#42315#,") Then
- ' Dim Results() As String = sResult.Split(","c)
- ' If Results.Count >= 2 Then
- ' Dim nIndex As Integer = -1
- ' Dim nResult As Integer = -1
- ' If Integer.TryParse(Results(1), nIndex) AndAlso nIndex >= 0 Then
- ' If Integer.TryParse(Results(2), nResult) AndAlso nResult >= 0 Then
- ' m_ThreadDataList(nIndex).SetProcResult(nResult)
- ' End If
- ' m_ThreadDataList(nIndex).SetProcessStatus(ThreadData.ProcessStatuses.ANSWERRECEIVED)
- ' End If
- ' End If
- 'End If
End Sub
Protected Overridable Sub Dispose(disposing As Boolean)
@@ -664,193 +473,3 @@ Public Class ExecProcessManager
End Sub
End Class
-
-Public Class JsonThread
-
- Private m_nIndex As Integer
- Public ReadOnly Property nIndex As Integer
- Get
- Return m_nIndex
- End Get
- End Property
-
- Private m_Args As New Dictionary(Of String, String)
- Public ReadOnly Property Args As Dictionary(Of String, String)
- Get
- Return m_Args
- End Get
- End Property
-
- Sub New(nIndex As Integer, Args As Dictionary(Of String, String))
- m_nIndex = nIndex
- m_Args = Args
- End Sub
-
-End Class
-
-Public Class ProcessArgs
-
- Private m_nThreadIndex As Integer
- Public ReadOnly Property nThreadIndex As Integer
- Get
- Return m_nThreadIndex
- End Get
- End Property
- Friend Sub SetThreadIndex(nIndex As Integer)
- m_nThreadIndex = nIndex
- End Sub
-
- Private m_nId As Integer
- Public ReadOnly Property nId As Integer
- Get
- Return m_nId
- End Get
- End Property
-
- Private m_Args As New Dictionary(Of String, String)
- Public ReadOnly Property Args As Dictionary(Of String, String)
- Get
- Return m_Args
- End Get
- End Property
-
-
- Public ReadOnly Property sProcessArgs As String
- Get
- Return JsonConvert.SerializeObject(Me, Formatting.None)
- End Get
- End Property
-
- Sub New(nId As Integer, Args As Dictionary(Of String, String))
- m_nId = nId
- m_Args = Args
- End Sub
-
-End Class
-
-Public Class ProcessArgsResult
-
-
- Private m_ProcessArgs As ProcessArgs
- Public ReadOnly Property pProcessArgs As ProcessArgs
- Get
- Return m_ProcessArgs
- End Get
- End Property
-
- Private m_nResult As Integer
- Public ReadOnly Property nResult As Integer
- Get
- Return m_nResult
- End Get
- End Property
-
- Private m_nId As Integer
- Public ReadOnly Property nId As Integer
- Get
- Return m_nId
- End Get
- End Property
-
- Private m_Args As New Dictionary(Of String, String)
- Public ReadOnly Property Args As Dictionary(Of String, String)
- Get
- Return m_Args
- End Get
- End Property
-
- Sub New(pProcessArgs As ProcessArgs, nResult As Integer)
- m_ProcessArgs = pProcessArgs
- m_nResult = nResult
- End Sub
-
-
- Sub New(nId As Integer, nResult As Integer, Args As Dictionary(Of String, String))
- m_nId = nId
- m_nResult = nResult
- m_Args = Args
- End Sub
-
-End Class
-
-Public Class ManagerStatistics
-
- Private m_nEngineRunningQty As Integer
- Public ReadOnly Property nEngineRunningQty As Integer
- Get
- Return m_nEngineRunningQty
- End Get
- End Property
-
- Private m_nEngineProcessingQty As Integer
- Public ReadOnly Property nEngineProcessingQty As Integer
- Get
- Return m_nEngineProcessingQty
- End Get
- End Property
-
- Private m_dMinProcessingTime As Double
- Public ReadOnly Property dMinProcessingTime As Double
- Get
- Return m_dMinProcessingTime
- End Get
- End Property
-
- Private m_dMidProcessingTime As Double
- Public ReadOnly Property dMidProcessingTime As Double
- Get
- Return m_dMidProcessingTime
- End Get
- End Property
-
- Private m_dMaxProcessingTime As Double
- Public ReadOnly Property dMaxProcessingTime As Double
- Get
- Return m_dMaxProcessingTime
- End Get
- End Property
-
- Private m_nLastMinAnswer As Integer
- Public ReadOnly Property nLastMinAnswer As Integer
- Get
- Return m_nLastMinAnswer
- End Get
- End Property
-
- Private m_nLast5MinAnswer As Integer
- Public ReadOnly Property nLast5MinAnswer As Integer
- Get
- Return m_nLast5MinAnswer
- End Get
- End Property
-
- Private m_nLastHourAnswer As Integer
- Public ReadOnly Property nLastHourAnswer As Integer
- Get
- Return m_nLastHourAnswer
- End Get
- End Property
-
- Private m_nQuestionInQueue As Integer
- Public ReadOnly Property nQuestionInQueue As Integer
- Get
- Return m_nQuestionInQueue
- End Get
- End Property
-
- Sub New(nEngineRunningQty As Integer, nEngineProcessingQty As Integer, nLastMinAnswer As Integer, nLast5MinAnswer As Integer, nLastHourAnswer As Integer, nQuestionInQueue As Integer)
- m_nEngineRunningQty = nEngineRunningQty
- m_nEngineProcessingQty = nEngineProcessingQty
- m_nLastMinAnswer = nLastMinAnswer
- m_nLast5MinAnswer = nLast5MinAnswer
- m_nLastHourAnswer = nLastHourAnswer
- m_nQuestionInQueue = nQuestionInQueue
- End Sub
-
- Public Sub SetProcessingTimes(dMinProcessingTime As Double, dMidProcessingTime As Double, dMaxProcessingTime As Double)
- m_dMinProcessingTime = dMinProcessingTime
- m_dMidProcessingTime = dMidProcessingTime
- m_dMaxProcessingTime = dMaxProcessingTime
- End Sub
-
-End Class
\ No newline at end of file
diff --git a/EgwMultiEngineManager/ThreadData.vb b/EgwMultiEngineManager/ThreadData.vb
index 2599516..eb262de 100644
--- a/EgwMultiEngineManager/ThreadData.vb
+++ b/EgwMultiEngineManager/ThreadData.vb
@@ -1,14 +1,6 @@
-Public Class ThreadData
+Imports EgwMultiEngineManager.Data
- 'Enum ThreadOperations As Integer
- ' WaitingData = 1
- ' FoundRequest = 2
- ' WritingDdf = 3
- ' ProcessingDdf = 4
- ' ReadingSvg = 5
- ' SendResult = 6
- ' Closed = 10
- 'End Enum
+Public Class ThreadData
Public Enum ProcessStatuses As Integer
NULL = 0
@@ -27,46 +19,26 @@
m_ProcessStatus = value
End Sub
- Private m_CurrRequest As ProcessArgs
- Public ReadOnly Property CurrRequest As ProcessArgs
+ Private m_CurrRequest As Question
+ Public ReadOnly Property CurrRequest As Question
Get
Return m_CurrRequest
End Get
End Property
- Friend Sub SetCurrRequest(value As ProcessArgs)
+ Friend Sub SetCurrRequest(value As Question)
m_CurrRequest = value
End Sub
- 'Private m_sDdfPath As String
- 'Public ReadOnly Property sDdfPath As String
- ' Get
- ' Return m_sDdfPath
- ' End Get
- 'End Property
- 'Friend Sub SetDdfPath(value As String)
- ' m_sDdfPath = value
- 'End Sub
-
- Private m_nProcResult As ProcessArgsResult
- Public ReadOnly Property nProcResult As ProcessArgsResult
+ Private m_nProcResult As Answer
+ Public ReadOnly Property nProcResult As Answer
Get
Return m_nProcResult
End Get
End Property
- Friend Sub SetProcResult(value As ProcessArgsResult)
+ Friend Sub SetProcResult(value As Answer)
m_nProcResult = value
End Sub
- 'Private m_ThreadOperation As ThreadOperations
- 'Public ReadOnly Property ThreadOperation As ThreadOperations
- ' Get
- ' Return m_ThreadOperation
- ' End Get
- 'End Property
- 'Friend Sub SetThreadOperation(value As ThreadOperations)
- ' m_ThreadOperation = value
- 'End Sub
-
Private m_Process As Process
Public ReadOnly Property Process As Process
Get
@@ -77,14 +49,4 @@
m_Process = value
End Sub
- 'Private m_ThreadStat As ThreadStat
- 'Public ReadOnly Property ThreadStat As ThreadStat
- ' Get
- ' Return m_ThreadStat
- ' End Get
- 'End Property
- 'Friend Sub SetThreadStat(value As ThreadStat)
- ' m_ThreadStat = value
- 'End Sub
-
End Class
\ No newline at end of file