Merge branch 'develop'
This commit is contained in:
@@ -134,6 +134,12 @@ Public Class ExecProcessManager
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public ReadOnly Property nFreeOrWaitingAnswerProcesses As Integer
|
||||
Get
|
||||
Return ThreadDataList.Count(Function(x) x IsNot Nothing AndAlso (x.ProcessStatus = ThreadData.ProcessStatuses.NULL OrElse x.ProcessStatus = ThreadData.ProcessStatuses.ANSWERRECEIVED))
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private PerMinResultQueueLock As New Object
|
||||
Private m_PerMinResultQueue As New Queue(Of Integer)
|
||||
Public ReadOnly Property PerMinResultQueue As Queue(Of Integer)
|
||||
|
||||
@@ -28,5 +28,5 @@ Imports System.Runtime.InteropServices
|
||||
' Revision
|
||||
'
|
||||
|
||||
<Assembly: AssemblyVersion("2.7.12.2")>
|
||||
<Assembly: AssemblyFileVersion("2.7.12.2")>
|
||||
<Assembly: AssemblyVersion("3.1.1.2")>
|
||||
<Assembly: AssemblyFileVersion("3.1.1.2")>
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<ApplicationManifest>My Project\app.manifest</ApplicationManifest>
|
||||
<Copyright>Copyright © 2020-2025 by Egalware s.r.l.</Copyright>
|
||||
<AssemblyVersion>2.7.12.1</AssemblyVersion>
|
||||
<FileVersion>2.7.12.1</FileVersion>
|
||||
<AssemblyVersion>3.1.1.2</AssemblyVersion>
|
||||
<FileVersion>3.1.1.2</FileVersion>
|
||||
<Company>Egalware s.r.l.</Company>
|
||||
<Version>2.7.12.1</Version>
|
||||
<Version>3.1.1.2</Version>
|
||||
<Authors>Emmanuele Sassi</Authors>
|
||||
<Description>Specifiche comunicazione con EgwMultiEngineManager</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -72,10 +72,26 @@
|
||||
m_nQuestionInQueue = nQuestionInQueue
|
||||
End Sub
|
||||
|
||||
Sub New(Statistics As Statistics)
|
||||
m_nEngineRunningQty = Statistics.nEngineRunningQty
|
||||
m_nEngineProcessingQty = Statistics.nEngineProcessingQty
|
||||
m_dMinProcessingTime = Statistics.dMinProcessingTime
|
||||
m_dMidProcessingTime = Statistics.dMidProcessingTime
|
||||
m_dMaxProcessingTime = Statistics.dMaxProcessingTime
|
||||
m_nLastMinAnswer = Statistics.nLastMinAnswer
|
||||
m_nLast5MinAnswer = Statistics.nLast5MinAnswer
|
||||
m_nLastHourAnswer = Statistics.nLastHourAnswer
|
||||
m_nQuestionInQueue = Statistics.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
|
||||
|
||||
Public Function Copy() As Statistics
|
||||
Return New Statistics(Me)
|
||||
End Function
|
||||
|
||||
End Class
|
||||
@@ -1,6 +1,8 @@
|
||||
Imports System.Drawing
|
||||
Imports System.Windows.Forms
|
||||
Imports System.Windows.Threading
|
||||
Imports EgwMultiEngineManager.Data
|
||||
Imports EgwMultiEngineManager.Tray.ExecEnvironmentManager
|
||||
|
||||
Class Application
|
||||
|
||||
@@ -11,8 +13,7 @@ Class Application
|
||||
Private m_bIsShuttingDown As Boolean = False
|
||||
Private m_NotifyIcon As NotifyIcon
|
||||
|
||||
Private m_WindowStatistics As Statistics
|
||||
Private m_AedificaStatistics As Statistics
|
||||
Private m_StatisticsTimer As New DispatcherTimer
|
||||
|
||||
Protected Overrides Sub OnStartup(e As StartupEventArgs)
|
||||
MyBase.OnStartup(e)
|
||||
@@ -20,8 +21,6 @@ Class Application
|
||||
' creo Vm e quindi avvio processi
|
||||
m_MainWindowVM = New MainWindowVM
|
||||
AddHandler m_MainWindowVM.QuitApplication, AddressOf MainWindowVM_QuitApplication
|
||||
AddHandler m_MainWindowVM.WindowStatisticUpdate, AddressOf MainWindowVM_WindowStatisticUpdate
|
||||
AddHandler m_MainWindowVM.AedificaStatisticUpdate, AddressOf MainWindowVM_AedificaStatisticUpdate
|
||||
m_MainWindowVM.Init()
|
||||
' creo icona di notifica nella tray
|
||||
m_NotifyIcon = New NotifyIcon
|
||||
@@ -40,6 +39,11 @@ Class Application
|
||||
ContextMenu.MenuItems.Add(QuitBtn)
|
||||
m_NotifyIcon.ContextMenu = ContextMenu
|
||||
AddHandler m_NotifyIcon.Click, AddressOf NotifyIcon_Click
|
||||
' inizializzo timer statistiche
|
||||
m_StatisticsTimer.Interval = New TimeSpan(0, 0, 10)
|
||||
AddHandler m_StatisticsTimer.Tick, AddressOf StatisticsTimer_Tick
|
||||
StatisticsTimer_Tick()
|
||||
m_StatisticsTimer.Start()
|
||||
End Sub
|
||||
|
||||
Sub NotifyIcon_Click(sender As Object, e As EventArgs)
|
||||
@@ -108,34 +112,108 @@ Class Application
|
||||
Application.Current.Shutdown()
|
||||
End Sub
|
||||
|
||||
Private Sub MainWindowVM_WindowStatisticUpdate(e As Statistics)
|
||||
Dim Tooltip As String = "QRun " & e.nEngineRunningQty & Environment.NewLine &
|
||||
"QProc " & e.nEngineProcessingQty & Environment.NewLine &
|
||||
"MidT " & e.nQuestionInQueue.ToString("N1") & Environment.NewLine &
|
||||
"Que " & e.nQuestionInQueue & Environment.NewLine &
|
||||
"1MAns " & e.nLastMinAnswer & Environment.NewLine &
|
||||
"5MAns " & e.nLast5MinAnswer & Environment.NewLine &
|
||||
"HAns " & e.nLastHourAnswer
|
||||
'"MinT " & e.dMinProcessingTime.ToString("N1") & Environment.NewLine &
|
||||
'"MaxT " & e.nQuestionInQueue.ToString("N1") & Environment.NewLine &
|
||||
Tooltip = Tooltip.Substring(0, Math.Min(60, Tooltip.Length))
|
||||
m_WindowStatistics = e
|
||||
m_NotifyIcon.Text = Tooltip
|
||||
Private Sub StatisticsTimer_Tick()
|
||||
If True Then
|
||||
Dim sTooltip As String = "RPTQ15H" & Environment.NewLine
|
||||
Dim sEnvironment As String = ""
|
||||
For nGroupType = EnvironmentCommunicationTypes.REDIS To EnvironmentCommunicationTypes.REST
|
||||
Dim nGroupIndex As Integer = 1
|
||||
Dim sGroupName As String = If(nGroupType = EnvironmentCommunicationTypes.REST, S_RESTEXECGROUP, S_EXECGROUP) & nGroupIndex.ToString()
|
||||
While GetMainPrivateProfileString(sGroupName, K_ENVIRONMENT, "", sEnvironment) > 0
|
||||
Dim CurrStatistics As Statistics = m_MainWindowVM.GetValueFromKeyInStatisticsList(sGroupName)
|
||||
If Not IsNothing(CurrStatistics) Then
|
||||
sTooltip &= If(nGroupType = EnvironmentCommunicationTypes.REST, "R", "G") & nGroupIndex.ToString() &
|
||||
CurrStatistics.nEngineRunningQty &
|
||||
CurrStatistics.nEngineProcessingQty &
|
||||
(CurrStatistics.dMidProcessingTime / 1000).ToString("N1") &
|
||||
CurrStatistics.nQuestionInQueue &
|
||||
CurrStatistics.nLastMinAnswer &
|
||||
CurrStatistics.nLast5MinAnswer &
|
||||
CurrStatistics.nLastHourAnswer & Environment.NewLine
|
||||
'"MinT " & e.dMinProcessingTime.ToString("N1") & Environment.NewLine &
|
||||
'"MaxT " & e.nQuestionInQueue.ToString("N1") & Environment.NewLine &
|
||||
End If
|
||||
nGroupIndex += 1
|
||||
sGroupName = If(nGroupType = EnvironmentCommunicationTypes.REST, S_RESTEXECGROUP, S_EXECGROUP) & nGroupIndex.ToString()
|
||||
End While
|
||||
Next
|
||||
sTooltip = sTooltip.Substring(0, Math.Min(60, sTooltip.Length))
|
||||
m_NotifyIcon.Text = sTooltip
|
||||
Return
|
||||
Dim ExecEnvironment As EXECENVIRONMENTS = ExecEnvironmentManager.GetExecEnvironmentFromString(sEnvironment)
|
||||
If ExecEnvironment <> EXECENVIRONMENTS.NULL Then
|
||||
Dim CurrStatistics As Statistics = m_MainWindowVM.GetValueFromKeyInStatisticsList(ExecEnvironment)
|
||||
If Not IsNothing(CurrStatistics) Then
|
||||
Dim Tooltip As String = "QRun " & CurrStatistics.nEngineRunningQty & Environment.NewLine &
|
||||
"QProc " & CurrStatistics.nEngineProcessingQty & Environment.NewLine &
|
||||
"MidT " & CurrStatistics.dMidProcessingTime.ToString("N1") & Environment.NewLine &
|
||||
"Que " & CurrStatistics.nQuestionInQueue & Environment.NewLine &
|
||||
"1MAns " & CurrStatistics.nLastMinAnswer & Environment.NewLine &
|
||||
"5MAns " & CurrStatistics.nLast5MinAnswer & Environment.NewLine &
|
||||
"HAns " & CurrStatistics.nLastHourAnswer
|
||||
'"MinT " & e.dMinProcessingTime.ToString("N1") & Environment.NewLine &
|
||||
'"MaxT " & e.nQuestionInQueue.ToString("N1") & Environment.NewLine &
|
||||
Tooltip = Tooltip.Substring(0, Math.Min(60, Tooltip.Length))
|
||||
m_NotifyIcon.Text = Tooltip
|
||||
End If
|
||||
End If
|
||||
ElseIf False Then
|
||||
Dim sEnvironment As String = ""
|
||||
GetMainPrivateProfileString(S_EXECGROUP & 1.ToString(), K_ENVIRONMENT, "", sEnvironment)
|
||||
Dim ExecEnvironment As EXECENVIRONMENTS = ExecEnvironmentManager.GetExecEnvironmentFromString(sEnvironment)
|
||||
If ExecEnvironment <> EXECENVIRONMENTS.NULL Then
|
||||
Dim CurrStatistics As Statistics = m_MainWindowVM.GetValueFromKeyInStatisticsList(ExecEnvironment)
|
||||
If Not IsNothing(CurrStatistics) Then
|
||||
Dim Tooltip As String = "QRun " & CurrStatistics.nEngineRunningQty & Environment.NewLine &
|
||||
"QProc " & CurrStatistics.nEngineProcessingQty & Environment.NewLine &
|
||||
"MidT " & CurrStatistics.dMidProcessingTime.ToString("N1") & Environment.NewLine &
|
||||
"Que " & CurrStatistics.nQuestionInQueue & Environment.NewLine &
|
||||
"1MAns " & CurrStatistics.nLastMinAnswer & Environment.NewLine &
|
||||
"5MAns " & CurrStatistics.nLast5MinAnswer & Environment.NewLine &
|
||||
"HAns " & CurrStatistics.nLastHourAnswer
|
||||
'"MinT " & e.dMinProcessingTime.ToString("N1") & Environment.NewLine &
|
||||
'"MaxT " & e.nQuestionInQueue.ToString("N1") & Environment.NewLine &
|
||||
Tooltip = Tooltip.Substring(0, Math.Min(60, Tooltip.Length))
|
||||
m_NotifyIcon.Text = Tooltip
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
Dim KeyList As List(Of String) = m_MainWindowVM.GetStatisticsListKeyCollection()
|
||||
Dim StatisticsList As New List(Of Statistics)
|
||||
Dim sQRun As String = "QRun__"
|
||||
Dim sQProc As String = "QProc_"
|
||||
Dim sMidT As String = "MidT__"
|
||||
Dim sQue As String = "Que___"
|
||||
Dim s1MAns As String = "1MAns_"
|
||||
Dim s5MAns As String = "5MAns_"
|
||||
Dim sHAns As String = "HAns__"
|
||||
For Each Key In KeyList
|
||||
Dim KeyStatistics As Statistics = m_MainWindowVM.GetValueFromKeyInStatisticsList(Key)
|
||||
sQRun &= KeyStatistics.nEngineRunningQty.ToString("00000") & " "
|
||||
sQProc &= KeyStatistics.nEngineProcessingQty.ToString("00000") & " "
|
||||
sMidT &= Math.Ceiling(KeyStatistics.dMidProcessingTime).ToString("00000") & " "
|
||||
sQue &= KeyStatistics.nQuestionInQueue.ToString("00000") & " "
|
||||
s1MAns &= KeyStatistics.nLastMinAnswer.ToString("00000") & " "
|
||||
s5MAns &= KeyStatistics.nLast5MinAnswer.ToString("00000") & " "
|
||||
sHAns &= KeyStatistics.nLastHourAnswer.ToString("00000") & " "
|
||||
Next
|
||||
Dim Tooltip As String = sQRun & Environment.NewLine &
|
||||
sQProc & Environment.NewLine &
|
||||
sMidT & Environment.NewLine &
|
||||
sQue & Environment.NewLine &
|
||||
s1MAns & Environment.NewLine &
|
||||
s5MAns & Environment.NewLine &
|
||||
sHAns
|
||||
'"MinT " & e.dMinProcessingTime.ToString("N1") & Environment.NewLine &
|
||||
'"MaxT " & e.nQuestionInQueue.ToString("N1") & Environment.NewLine &
|
||||
'Tooltip = Tooltip.Substring(0, Math.Min(60, Tooltip.Length))
|
||||
'm_NotifyIcon.Text = Tooltip
|
||||
m_NotifyIcon.BalloonTipTitle = "EgwMultiEngineManager"
|
||||
m_NotifyIcon.BalloonTipIcon = ToolTipIcon.Info
|
||||
m_NotifyIcon.BalloonTipText = Tooltip
|
||||
m_NotifyIcon.ShowBalloonTip(5000)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub MainWindowVM_AedificaStatisticUpdate(e As Statistics)
|
||||
Dim Tooltip As String = "QRun " & e.nEngineRunningQty & Environment.NewLine &
|
||||
"QProc " & e.nEngineProcessingQty & Environment.NewLine &
|
||||
"MidT " & e.nQuestionInQueue.ToString("N1") & Environment.NewLine &
|
||||
"Que " & e.nQuestionInQueue & Environment.NewLine &
|
||||
"1MAns " & e.nLastMinAnswer & Environment.NewLine &
|
||||
"5MAns " & e.nLast5MinAnswer & Environment.NewLine &
|
||||
"HAns " & e.nLastHourAnswer
|
||||
'"MinT " & e.dMinProcessingTime.ToString("N1") & Environment.NewLine &
|
||||
'"MaxT " & e.nQuestionInQueue.ToString("N1") & Environment.NewLine &
|
||||
Tooltip = Tooltip.Substring(0, Math.Min(60, Tooltip.Length))
|
||||
m_AedificaStatistics = e
|
||||
m_NotifyIcon.Text = Tooltip
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
@@ -66,8 +66,8 @@
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EgtDotNETBasis, Version=2.7.11.20, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EgtDotNETBasis.2.7.11.20\lib\EgtDotNETBasis.dll</HintPath>
|
||||
<Reference Include="EgtDotNETBasis, Version=3.1.1.3, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EgtDotNETBasis.3.1.1.3\lib\EgtDotNETBasis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EgwWPFBaseLib">
|
||||
<HintPath>..\..\EgwWPFBaseLib\EgwWPFBaseLib\bin\Debug\EgwWPFBaseLib.dll</HintPath>
|
||||
@@ -247,10 +247,10 @@
|
||||
<ErrorText>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}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\build\Microsoft.Extensions.Logging.Abstractions.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\EgtDotNETBasis.2.7.11.20\build\EgtDotNETBasis.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EgtDotNETBasis.2.7.11.20\build\EgtDotNETBasis.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\EgtDotNETBasis.3.1.1.3\build\EgtDotNETBasis.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EgtDotNETBasis.3.1.1.3\build\EgtDotNETBasis.targets'))" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\post-build.ps1 $(ConfigurationName) $(TargetDir) $(TargetPath)</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="..\packages\EgtDotNETBasis.2.7.11.20\build\EgtDotNETBasis.targets" Condition="Exists('..\packages\EgtDotNETBasis.2.7.11.20\build\EgtDotNETBasis.targets')" />
|
||||
<Import Project="..\packages\EgtDotNETBasis.3.1.1.3\build\EgtDotNETBasis.targets" Condition="Exists('..\packages\EgtDotNETBasis.3.1.1.3\build\EgtDotNETBasis.targets')" />
|
||||
</Project>
|
||||
@@ -47,6 +47,32 @@ Public Class MainWindowVM
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_Lock_StatisticsList As New Object
|
||||
Private m_StatisticsList As New Dictionary(Of String, Statistics)
|
||||
Friend Function GetValueFromKeyInStatisticsList(sGroupName As String) As Statistics
|
||||
SyncLock m_Lock_StatisticsList
|
||||
If m_StatisticsList.ContainsKey(sGroupName) Then
|
||||
Return m_StatisticsList(sGroupName).Copy()
|
||||
Else
|
||||
Return Nothing
|
||||
End If
|
||||
End SyncLock
|
||||
End Function
|
||||
Friend Sub SetValueToKeyInStatisticsList(sGroupName As String, Statistics As Statistics)
|
||||
SyncLock m_Lock_StatisticsList
|
||||
If m_StatisticsList.ContainsKey(sGroupName) Then
|
||||
m_StatisticsList(sGroupName) = Statistics
|
||||
Else
|
||||
m_StatisticsList.Add(sGroupName, Statistics)
|
||||
End If
|
||||
End SyncLock
|
||||
End Sub
|
||||
Friend Function GetStatisticsListKeyCollection() As List(Of String)
|
||||
SyncLock m_Lock_StatisticsList
|
||||
Return m_StatisticsList.Keys.ToList()
|
||||
End SyncLock
|
||||
End Function
|
||||
|
||||
Private m_ExecEnvironmentList As New List(Of ExecEnvironmentManager)
|
||||
Public ReadOnly Property ExecEnvironmentList As List(Of ExecEnvironmentManager)
|
||||
Get
|
||||
@@ -138,6 +164,7 @@ Public Class MainWindowVM
|
||||
While ExecEnvironmentManager.CreateExecEnvironmentManager(ExecEnvironmentManager.EnvironmentCommunicationTypes.REDIS, nGroupIndex, NewExecProcessManager)
|
||||
If Not IsNothing(NewExecProcessManager) Then
|
||||
m_ExecEnvironmentList.Add(NewExecProcessManager)
|
||||
AddHandler NewExecProcessManager.StatisticUpdate, AddressOf NewExecProcessManager_StatisticUpdate
|
||||
End If
|
||||
NewExecProcessManager = Nothing
|
||||
nGroupIndex += 1
|
||||
@@ -148,6 +175,7 @@ Public Class MainWindowVM
|
||||
While ExecEnvironmentManager.CreateExecEnvironmentManager(ExecEnvironmentManager.EnvironmentCommunicationTypes.REST, nGroupIndex, NewExecProcessManager)
|
||||
If Not IsNothing(NewExecProcessManager) Then
|
||||
m_ExecEnvironmentList.Add(NewExecProcessManager)
|
||||
AddHandler NewExecProcessManager.StatisticUpdate, AddressOf NewExecProcessManager_StatisticUpdate
|
||||
End If
|
||||
NewExecProcessManager = Nothing
|
||||
nGroupIndex += 1
|
||||
@@ -155,6 +183,10 @@ Public Class MainWindowVM
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub NewExecProcessManager_StatisticUpdate(sGroupName As String, Statistics As Statistics)
|
||||
SetValueToKeyInStatisticsList(sGroupName, Statistics)
|
||||
End Sub
|
||||
|
||||
Private Sub ManageInstance()
|
||||
Dim bCreated As Boolean
|
||||
Try
|
||||
|
||||
@@ -52,5 +52,5 @@ Imports System.Windows
|
||||
' Revision
|
||||
'
|
||||
|
||||
<Assembly: AssemblyVersion("2.7.12.2")>
|
||||
<Assembly: AssemblyFileVersion("2.7.12.2")>
|
||||
<Assembly: AssemblyVersion("3.1.1.2")>
|
||||
<Assembly: AssemblyFileVersion("3.1.1.2")>
|
||||
|
||||
@@ -19,6 +19,8 @@ Public Class ExecEnvironmentManager
|
||||
REST = 2
|
||||
End Enum
|
||||
|
||||
Public Event StatisticUpdate(sGroupName As String, Statistics As Statistics)
|
||||
|
||||
Private ConstChnName_EgwEngineInput As String = "EgwEngineInput"
|
||||
Private ConstChnName_EgwEngineOutput As String = "EgwEngineOutput"
|
||||
Private ConstChnName_EgwStatistics As String = "EgwStatistics"
|
||||
@@ -54,6 +56,13 @@ Public Class ExecEnvironmentManager
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_sGroupName As String = String.Empty
|
||||
Friend ReadOnly Property GroupName As String
|
||||
Get
|
||||
Return m_sGroupName
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private Shared m_RedisManager As RedisManager
|
||||
Friend Shared Sub SetRedisManager(RedisManager As RedisManager)
|
||||
m_RedisManager = RedisManager
|
||||
@@ -94,6 +103,7 @@ Public Class ExecEnvironmentManager
|
||||
End Property
|
||||
|
||||
Private m_chnEgwEngineOutput As RedisChannel
|
||||
Private m_chnEgwEngineInput As RedisChannel
|
||||
Private m_chnEgwStatistics As RedisChannel
|
||||
|
||||
' statistics
|
||||
@@ -114,58 +124,49 @@ Public Class ExecEnvironmentManager
|
||||
Dim sPipeLuaFile As String = ""
|
||||
Dim nMaxCamInstances As Integer = 0
|
||||
Dim bDebug As Boolean = False
|
||||
Dim sGroupTitle As String = If(nType = EnvironmentCommunicationTypes.REST, S_RESTEXECGROUP, S_EXECGROUP)
|
||||
If GetMainPrivateProfileString(sGroupTitle & nGroupIndex.ToString(), K_ENVIRONMENT, "", sEnvironment) > 0 AndAlso
|
||||
GetMainPrivateProfileString(sGroupTitle & nGroupIndex.ToString(), K_PIPELUAFILE, "", sPipeLuaFile) AndAlso
|
||||
GetMainPrivateProfileString(sGroupTitle & nGroupIndex.ToString(), K_MAXCAMINSTANCES, "", nMaxCamInstances) Then
|
||||
Dim sGroupName As String = If(nType = EnvironmentCommunicationTypes.REST, S_RESTEXECGROUP, S_EXECGROUP) & nGroupIndex.ToString()
|
||||
If GetMainPrivateProfileString(sGroupName, K_ENVIRONMENT, "", sEnvironment) > 0 AndAlso
|
||||
GetMainPrivateProfileString(sGroupName, K_PIPELUAFILE, "", sPipeLuaFile) AndAlso
|
||||
GetMainPrivateProfileString(sGroupName, K_MAXCAMINSTANCES, "", nMaxCamInstances) Then
|
||||
EgtOutLog(If(nType = EnvironmentCommunicationTypes.REST, "REST", "") & "Group" & nGroupIndex.ToString())
|
||||
EgtOutLog("Environment = " & sEnvironment)
|
||||
EgtOutLog("PipeLuaFile = " & sPipeLuaFile)
|
||||
EgtOutLog("MaxCAMInstances = " & nMaxCamInstances)
|
||||
If nMaxCamInstances <= 0 Then
|
||||
EgtOutLog("No Cam instances assigned!")
|
||||
EgtOutLog(String.Format(sGroupTitle & "{0} will not be created!", nGroupIndex.ToString()))
|
||||
EgtOutLog(String.Format(sGroupName & " will not be created!"))
|
||||
nGroupIndex += 1
|
||||
Return True
|
||||
End If
|
||||
Dim ExecEnvironment As EXECENVIRONMENTS = EXECENVIRONMENTS.NULL
|
||||
Select Case sEnvironment
|
||||
Case "WINDOW"
|
||||
ExecEnvironment = EXECENVIRONMENTS.WINDOW
|
||||
Case "BEAM"
|
||||
ExecEnvironment = EXECENVIRONMENTS.BEAM
|
||||
Case "WALL"
|
||||
ExecEnvironment = EXECENVIRONMENTS.WALL
|
||||
Case "CABINET"
|
||||
ExecEnvironment = EXECENVIRONMENTS.CABINET
|
||||
End Select
|
||||
Dim ExecEnvironment As EXECENVIRONMENTS = GetExecEnvironmentFromString(sEnvironment)
|
||||
If ExecEnvironment = EXECENVIRONMENTS.NULL Then
|
||||
EgtOutLog("No ExecEnvironment assigned!")
|
||||
EgtOutLog(String.Format(sGroupTitle & "{0} will not be created!", nGroupIndex.ToString()))
|
||||
EgtOutLog(String.Format(sGroupName & " will not be created!"))
|
||||
nGroupIndex += 1
|
||||
Return True
|
||||
End If
|
||||
Dim sPipeLuaPath As String = Map.refMainWindowVM.sDataRoot & "\" & sPipeLuaDirName & "\" & sPipeLuaFile
|
||||
If Not File.Exists(sPipeLuaPath) Then
|
||||
EgtOutLog("Lua file not assigned or not found!")
|
||||
EgtOutLog(String.Format(sGroupTitle & "{0} will not be created!", nGroupIndex.ToString()))
|
||||
EgtOutLog(String.Format(sGroupName & " will not be created!"))
|
||||
nGroupIndex += 1
|
||||
Return True
|
||||
End If
|
||||
Dim sProcessArguments As String = """" & sPipeLuaPath & """ " & """" & sConnection & """"
|
||||
' leggo se modalita' debug
|
||||
Dim nDebug As Integer = GetMainPrivateProfileInt(sGroupTitle & nGroupIndex.ToString(), K_DEBUG, 0)
|
||||
Dim nDebug As Integer = GetMainPrivateProfileInt(sGroupName, K_DEBUG, 0)
|
||||
bDebug = (nDebug = 1)
|
||||
NewExecEnvironmentManager = New ExecEnvironmentManager(nType, ExecEnvironment, nGroupIndex, sCamExePath, sProcessArguments, nMaxCamInstances, ExecProcessManager.ReturnModes.EVENT_, bDebug)
|
||||
EgtOutLog(String.Format(sGroupTitle & "{0} created", nGroupIndex.ToString()))
|
||||
NewExecEnvironmentManager = New ExecEnvironmentManager(nType, sGroupName, ExecEnvironment, nGroupIndex, sCamExePath, sProcessArguments, nMaxCamInstances, ExecProcessManager.ReturnModes.EVENT_, bDebug)
|
||||
EgtOutLog(String.Format(sGroupName & " created"))
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Sub New(nType As EnvironmentCommunicationTypes, nEnvironment As EXECENVIRONMENTS, nGroupId As Integer, sProcessFileName As String, sProcessArguments As String, nMaxCamInstances As Integer, bReturnMode As ExecProcessManager.ReturnModes, bDebug As Boolean)
|
||||
Sub New(nType As EnvironmentCommunicationTypes, sGroupName As String, nEnvironment As EXECENVIRONMENTS, nGroupId As Integer, sProcessFileName As String, sProcessArguments As String, nMaxCamInstances As Integer, bReturnMode As ExecProcessManager.ReturnModes, bDebug As Boolean)
|
||||
m_EnvironmentCommunicationType = nType
|
||||
m_sGroupName = sGroupName
|
||||
Select Case m_EnvironmentCommunicationType
|
||||
Case EnvironmentCommunicationTypes.REDIS
|
||||
m_ExecEnvironment = nEnvironment
|
||||
@@ -190,13 +191,15 @@ Public Class ExecEnvironmentManager
|
||||
ConstChnName_EgwStatistics = sStatisticsChannelName.Replace("%%", "").Replace("@@", sIpAddress)
|
||||
ConstChnName_EgwDevStatistics = sStatisticsChannelName.Replace("%%", "Dev").Replace("@@", sIpAddress)
|
||||
m_chnEgwEngineOutput = New RedisChannel(ChnName_EgwEngineOutput, RedisChannel.PatternMode.Auto)
|
||||
m_chnEgwEngineInput = New RedisChannel(ChnName_EgwEngineInput, RedisChannel.PatternMode.Auto)
|
||||
m_chnEgwStatistics = New RedisChannel(ChnName_EgwStatistics, RedisChannel.PatternMode.Auto)
|
||||
m_RedisManager.SubscribeChannel(ChnName_EgwEngineInput, AddressOf EgwEngineInputHandler)
|
||||
m_RedisManager.SubscribeChannel(m_chnEgwEngineInput, AddressOf EgwEngineInputHandler)
|
||||
Case EnvironmentCommunicationTypes.REST
|
||||
m_ExecEnvironment = nEnvironment
|
||||
m_ExecProcessManager = New ExecProcessManager(nGroupId + 1000, nEnvironment, sProcessFileName, sProcessArguments, nMaxCamInstances, ExecProcessManager.ReturnModes.EVENT_, bDebug)
|
||||
m_chnEgwStatistics = New RedisChannel(ChnName_EgwStatistics, RedisChannel.PatternMode.Auto)
|
||||
AddHandler m_ExecProcessManager.m_AnswerReceived, AddressOf ExecProcessManager_AnswerReceived
|
||||
'AddHandler m_ExecProcessManager.m_Statistics, AddressOf ExecProcessManager_Statistics
|
||||
AddHandler m_ExecProcessManager.m_Statistics, AddressOf ExecProcessManager_Statistics
|
||||
m_ExecProcessManager.StartExecutionThread()
|
||||
'm_Client = New RestClient("https://office.egalware.com/lux/srv/api")
|
||||
m_Client = New RestClient("https://iis01.egalware.com/lux/srv/api")
|
||||
@@ -207,6 +210,21 @@ Public Class ExecEnvironmentManager
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Friend Shared Function GetExecEnvironmentFromString(sEnvironment As String) As EXECENVIRONMENTS
|
||||
Select Case sEnvironment
|
||||
Case "WINDOW"
|
||||
Return EXECENVIRONMENTS.WINDOW
|
||||
Case "BEAM"
|
||||
Return EXECENVIRONMENTS.BEAM
|
||||
Case "WALL"
|
||||
Return EXECENVIRONMENTS.WALL
|
||||
Case "CABINET"
|
||||
Return EXECENVIRONMENTS.CABINET
|
||||
Case Else
|
||||
Return EXECENVIRONMENTS.NULL
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Private Async Sub RestTimer_Tick(sender As Object, e As EventArgs)
|
||||
Dim nProcessedQuestion As Integer = 0
|
||||
While m_ExecProcessManager.nFreeProcesses > 0 And m_ExecProcessManager.ArgumentsQueueCount < m_ExecProcessManager.nFreeProcesses And nProcessedQuestion < m_ExecProcessManager.nRunningProcesses
|
||||
@@ -251,7 +269,7 @@ Public Class ExecEnvironmentManager
|
||||
End If
|
||||
End If
|
||||
EgtOutLog(DateTime.Now.ToString("HH:mm:ss.fff") & " Environment=" & m_ExecEnvironment & " Channel=" & chnEgwEngineOutput.ToString() & " Answer Id=" & Answer.nId)
|
||||
m_RedisManager.Subscriber.Publish(chnEgwEngineOutput, JsonConvert.SerializeObject(Answer))
|
||||
m_RedisManager.Publish(chnEgwEngineOutput, JsonConvert.SerializeObject(Answer))
|
||||
m_stopWatch.Stop()
|
||||
' Format and display the TimeSpan value.
|
||||
Dim elapsedTime As String = String.Format("{0:N3}", m_stopWatch.Elapsed.TotalMilliseconds)
|
||||
@@ -276,6 +294,10 @@ Public Class ExecEnvironmentManager
|
||||
request = New RestRequest("Prod/jobreturn", Method.Post)
|
||||
Case 2
|
||||
request = New RestRequest("Prod/jobreturn", Method.Post)
|
||||
Case 3
|
||||
request = New RestRequest("Prod/jobreturn", Method.Post)
|
||||
Case 4
|
||||
request = New RestRequest("Prod/jobreturn", Method.Post)
|
||||
End Select
|
||||
End Select
|
||||
'request.AddBody(JsonConvert.SerializeObject(Answer))
|
||||
@@ -310,9 +332,9 @@ Public Class ExecEnvironmentManager
|
||||
Private Sub ExecProcessManager_Statistics(e As Statistics)
|
||||
Dim CurrManagerStatistics As Statistics = e
|
||||
CurrManagerStatistics.SetProcessingTimes(m_dMinProcessingTime, m_dMidProcessingTime, m_dMaxProcessingTime)
|
||||
'RaiseEvent WindowStatisticUpdate(CurrManagerStatistics)
|
||||
RaiseEvent StatisticUpdate(m_sGroupName, CurrManagerStatistics)
|
||||
If Not IsNothing(m_chnEgwStatistics) Then
|
||||
m_RedisManager.Subscriber.Publish(m_chnEgwStatistics, JsonConvert.SerializeObject(CurrManagerStatistics))
|
||||
m_RedisManager.Publish(m_chnEgwStatistics, JsonConvert.SerializeObject(CurrManagerStatistics))
|
||||
End If
|
||||
m_nProcessingQty = 0
|
||||
m_dMinProcessingTime = 100000
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Imports System
|
||||
Imports EgtDotNETBasis
|
||||
Imports StackExchange.Redis
|
||||
|
||||
Public Class RedisManager
|
||||
@@ -36,10 +36,25 @@ Public Class RedisManager
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Friend Sub SubscribeChannel(sName As String, Handler As Action(Of RedisChannel, RedisValue))
|
||||
Dim InputChn As New RedisChannel(sName, RedisChannel.PatternMode.Auto)
|
||||
Subscriber.Subscribe(InputChn, Handler)
|
||||
End Sub
|
||||
Friend Function SubscribeChannel(channel As RedisChannel, handler As Action(Of RedisChannel, RedisValue)) As Boolean
|
||||
Try
|
||||
Subscriber.Subscribe(channel, handler)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
EgtOutLog(String.Format("Errore! Errore nella sottoscrizione Redis al canale {0}!", channel) & Environment.NewLine & ex.Message)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Friend Function Publish(channel As RedisChannel, message As RedisValue) As Boolean
|
||||
Try
|
||||
Subscriber.Publish(channel, message)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
EgtOutLog(String.Format("Errore! Errore nella pubblicazione Redis sul canale {0} del messaggio {1}!", channel, message) & Environment.NewLine & ex.Message)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Protected Overridable Sub Dispose(disposing As Boolean)
|
||||
If Not disposedValue Then
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EgtDotNETBasis" version="2.7.11.20" targetFramework="net472" />
|
||||
<package id="EgtDotNETBasis" version="3.1.1.3" targetFramework="net472" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Extensions.Logging.Abstractions" version="6.0.0" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.4" targetFramework="net472" />
|
||||
|
||||
Reference in New Issue
Block a user