- aggiunta comunicazione REST

- aggiunta Map
- spostato lettura ini in environment
- aggiornato debug in file .ps1
This commit is contained in:
Emmanuele Sassi
2025-12-04 16:36:09 +01:00
parent bb16fbd02c
commit ca015f5c69
9 changed files with 381 additions and 142 deletions
@@ -128,6 +128,12 @@ Public Class ExecProcessManager
End Get
End Property
Public ReadOnly Property nFreeProcesses As Integer
Get
Return ThreadDataList.Count(Function(x) x IsNot Nothing AndAlso x.ProcessStatus = ThreadData.ProcessStatuses.NULL)
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)
+17 -1
View File
@@ -1,6 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@@ -17,11 +17,13 @@ Module ConstIni
Public Const S_GENERAL As String = "General"
Public Const K_CAMEXEPATH As String = "CAMExePath"
Public Const K_PIPELUADIR As String = "PipeLuaDir"
Public Const K_PIPELUADIRNAME As String = "PipeLuaDirName"
Public Const K_REDISCONNECTION As String = "RedisConnection"
Public Const K_MAXINST As String = "MaxInstances"
Public Const K_INSTANCES As String = "Instances"
Public Const S_EXECGROUP As String = "ExecGroup"
Public Const S_RESTEXECGROUP As String = "RESTExecGroup"
Public Const K_ENVIRONMENT As String = "Environment"
Public Const K_PIPELUAFILE As String = "PipeLuaFile"
Public Const K_MAXCAMINSTANCES As String = "MaxCAMInstances"
@@ -72,8 +72,8 @@
<Reference Include="EgwWPFBaseLib">
<HintPath>..\..\EgwWPFBaseLib\EgwWPFBaseLib\bin\Debug\EgwWPFBaseLib.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.6.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.6.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
@@ -84,6 +84,9 @@
<Reference Include="Pipelines.Sockets.Unofficial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=42ea0a778e13fbe2, processorArchitecture=MSIL">
<HintPath>..\packages\Pipelines.Sockets.Unofficial.2.2.8\lib\net472\Pipelines.Sockets.Unofficial.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=112.1.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.112.1.0\lib\net471\RestSharp.dll</HintPath>
</Reference>
<Reference Include="StackExchange.Redis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c219ff1ca8c2ce46, processorArchitecture=MSIL">
<HintPath>..\packages\StackExchange.Redis.2.8.58\lib\net472\StackExchange.Redis.dll</HintPath>
</Reference>
@@ -100,15 +103,21 @@
<Reference Include="System.IO.Pipelines, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Pipelines.5.0.1\lib\net461\System.IO.Pipelines.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.8.0.4\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Channels, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Channels.5.0.0\lib\net461\System.Threading.Channels.dll</HintPath>
@@ -116,6 +125,10 @@
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@@ -140,6 +153,7 @@
<Compile Include="Utility\GenInterface.vb" />
<Compile Include="Utility\GetPcData.vb" />
<Compile Include="Utility\IniFile.vb" />
<Compile Include="Utility\Map.vb" />
<Compile Include="Utility\RedisManager.vb" />
<Page Include="MainWindow\MainWindowV.xaml">
<Generator>MSBuild:Compile</Generator>
@@ -233,7 +247,7 @@
<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'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\post-build.ps1 $(ConfigurationName) $(TargetDir)</PostBuildEvent>
<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')" />
</Project>
@@ -1,9 +1,10 @@
Imports System.IO
Imports System.Threading
Imports EgtDotNETBasis
Imports EgwMultiEngineManager.Core
Imports EgwMultiEngineManager.Data
Imports EgwMultiEngineManager.Data.Constants
Imports EgwWPFBaseLib
Imports EgtDotNETBasis
Public Class MainWindowVM
Inherits VMBase
@@ -46,8 +47,8 @@ Public Class MainWindowVM
End Get
End Property
Private m_ExecEnvironmentList As New Dictionary(Of EXECENVIRONMENTS, ExecEnvironmentManager)
Public ReadOnly Property ExecEnvironmentList As Dictionary(Of EXECENVIRONMENTS, ExecEnvironmentManager)
Private m_ExecEnvironmentList As New List(Of ExecEnvironmentManager)
Public ReadOnly Property ExecEnvironmentList As List(Of ExecEnvironmentManager)
Get
Return m_ExecEnvironmentList
End Get
@@ -62,6 +63,8 @@ Public Class MainWindowVM
End Property
Sub New()
' Avvio l'inizializzazione della mappa passandogli il riferimento al MainWindowVM
Map.BeginInit(Me)
' Impostazione path radice per i dati
m_sDataRoot = System.AppDomain.CurrentDomain.BaseDirectory
If GetPrivateProfileString(ConstGen.S_DATA, ConstGen.K_DATAROOT, "", m_sDataRoot, m_sDataRoot & "\" & ConstGen.DAT_FILE_NAME) = 0 Then
@@ -129,59 +132,27 @@ Public Class MainWindowVM
End If
' imposto log per ExecProcessManager
ExecProcessManager.SetEgtOutLog(AddressOf EgtOutLog)
' carico ambienti
' carico ambienti Redis
Dim nGroupIndex As Integer = 1
Dim sEnvironment As String = ""
Dim sPipeLuaFile As String = ""
Dim nMaxCamInstances As Integer = 0
Dim bDebug As Boolean = False
While GetMainPrivateProfileString(S_EXECGROUP & nGroupIndex.ToString(), K_ENVIRONMENT, "", sEnvironment) > 0 AndAlso
GetMainPrivateProfileString(S_EXECGROUP & nGroupIndex.ToString(), K_PIPELUAFILE, "", sPipeLuaFile) AndAlso
GetMainPrivateProfileString(S_EXECGROUP & nGroupIndex.ToString(), K_MAXCAMINSTANCES, "", nMaxCamInstances)
EgtOutLog("Group" & nGroupIndex.ToString())
EgtOutLog("Environment = " & sEnvironment)
EgtOutLog("PipeLuaFile = " & sPipeLuaFile)
EgtOutLog("MaxCAMInstances = " & nMaxCamInstances)
If nMaxCamInstances <= 0 Then
EgtOutLog("No Cam instances assigned!")
EgtOutLog(String.Format("Group{0} will not be created!", nGroupIndex.ToString()))
nGroupIndex += 1
Continue While
Dim NewExecProcessManager As ExecEnvironmentManager = Nothing
While ExecEnvironmentManager.CreateExecEnvironmentManager(ExecEnvironmentManager.EnvironmentCommunicationTypes.REDIS, nGroupIndex, NewExecProcessManager)
If Not IsNothing(NewExecProcessManager) Then
m_ExecEnvironmentList.Add(NewExecProcessManager)
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
If ExecEnvironment = EXECENVIRONMENTS.NULL Then
EgtOutLog("No ExecEnvironment assigned!")
EgtOutLog(String.Format("Group{0} will not be created!", nGroupIndex.ToString()))
nGroupIndex += 1
Continue While
End If
Dim sPipeLuaPath As String = sPipeLuaDir & "\" & sPipeLuaFile
If Not File.Exists(sPipeLuaPath) Then
EgtOutLog("Lua file not assigned or not found!")
EgtOutLog(String.Format("Group{0} will not be created!", nGroupIndex.ToString()))
nGroupIndex += 1
Continue While
End If
Dim sProcessArguments As String = """" & sPipeLuaPath & """" &
If(ExecEnvironment = EXECENVIRONMENTS.WINDOW, " " & """" & sConnection & """", "")
' leggo se modalita' debug
Dim nDebug As Integer = GetMainPrivateProfileInt(S_EXECGROUP & nGroupIndex.ToString(), K_DEBUG, 0)
bDebug = (nDebug = 1)
Dim NewExecProcessManager As New ExecEnvironmentManager(ExecEnvironment, nGroupIndex, sCamExePath, sProcessArguments, nMaxCamInstances, ExecProcessManager.ReturnModes.EVENT_, bDebug)
m_ExecEnvironmentList.Add(ExecEnvironment, NewExecProcessManager)
EgtOutLog(String.Format("Group{0} created", nGroupIndex.ToString()))
NewExecProcessManager = Nothing
nGroupIndex += 1
End While
' carico ambienti REST
nGroupIndex = 1
NewExecProcessManager = Nothing
While ExecEnvironmentManager.CreateExecEnvironmentManager(ExecEnvironmentManager.EnvironmentCommunicationTypes.REST, nGroupIndex, NewExecProcessManager)
If Not IsNothing(NewExecProcessManager) Then
m_ExecEnvironmentList.Add(NewExecProcessManager)
End If
NewExecProcessManager = Nothing
nGroupIndex += 1
End While
End Sub
Private Sub ManageInstance()
@@ -259,8 +230,8 @@ Public Class MainWindowVM
End Sub
Public Sub Quit()
For Each Key In m_ExecEnvironmentList.Keys
m_ExecEnvironmentList(Key).Dispose()
For Each ExecEnvironment In m_ExecEnvironmentList
ExecEnvironment.Dispose()
Next
If Not IsNothing(m_RedisManager) Then m_RedisManager.Dispose()
If m_bManageMutexRes Then
@@ -1,13 +1,24 @@
Imports EgwMultiEngineManager.Core
Imports System.IO
Imports System.Net.Http
Imports System.Text.Json.Nodes
Imports System.Windows.Threading
Imports EgtDotNETBasis
Imports EgwMultiEngineManager.Core
Imports EgwMultiEngineManager.Data
Imports EgwMultiEngineManager.Data.Constants
Imports Newtonsoft.Json
Imports RestSharp
Imports StackExchange.Redis
Imports EgtDotNETBasis
Public Class ExecEnvironmentManager
Implements IDisposable
Public Enum EnvironmentCommunicationTypes As Integer
NULL = 0
REDIS = 1
REST = 2
End Enum
Private ConstChnName_EgwEngineInput As String = "EgwEngineInput"
Private ConstChnName_EgwEngineOutput As String = "EgwEngineOutput"
Private ConstChnName_EgwStatistics As String = "EgwStatistics"
@@ -27,6 +38,15 @@ Public Class ExecEnvironmentManager
End Get
End Property
Private m_RestTimer As New DispatcherTimer
Friend ReadOnly Property RestTimer As DispatcherTimer
Get
Return m_RestTimer
End Get
End Property
Private m_EnvironmentCommunicationType As EnvironmentCommunicationTypes
Private m_ExecEnvironment As EXECENVIRONMENTS = EXECENVIRONMENTS.NULL
Friend ReadOnly Property ExecEnvironment As EXECENVIRONMENTS
Get
@@ -66,6 +86,13 @@ Public Class ExecEnvironmentManager
End Get
End Property
Private m_Client As RestClient
Friend ReadOnly Property Client As RestClient
Get
Return m_Client
End Get
End Property
Private m_chnEgwEngineOutput As RedisChannel
Private m_chnEgwStatistics As RedisChannel
@@ -76,72 +103,217 @@ Public Class ExecEnvironmentManager
Private m_dMaxProcessingTime As Double = 0
Private m_nProcessingQty As Integer = 0
Sub New(nEnvironment As EXECENVIRONMENTS, nGroupId As Integer, sProcessFileName As String, sProcessArguments As String, nMaxCamInstances As Integer, bReturnMode As ExecProcessManager.ReturnModes, bDebug As Boolean)
m_ExecEnvironment = nEnvironment
m_ExecProcessManager = New ExecProcessManager(nGroupId, nEnvironment, sProcessFileName, sProcessArguments, nMaxCamInstances, ExecProcessManager.ReturnModes.EVENT_, bDebug)
AddHandler m_ExecProcessManager.m_AnswerReceived, AddressOf ExecProcessManager_AnswerReceived
AddHandler m_ExecProcessManager.m_Statistics, AddressOf ExecProcessManager_Statistics
m_ExecProcessManager.StartExecutionThread()
' leggo canali input/output
Dim sIniGroup As String = S_EXECGROUP & nGroupId.ToString()
m_bChannelFromAnswer = (GetMainPrivateProfileInt(sIniGroup, K_CHANNELFROMANSWER, 0) = 1)
Dim sInputChannelName As String = ""
GetMainPrivateProfileString(sIniGroup, K_INPUTCHANNEL, "Egw%%EngineInput", sInputChannelName)
ConstChnName_EgwEngineInput = sInputChannelName.Replace("%%", "").Replace("@@", "")
ConstChnName_EgwDevEngineInput = sInputChannelName.Replace("%%", "Dev").Replace("@@", "")
Dim sOutputChannelName As String = ""
GetMainPrivateProfileString(sIniGroup, K_OUTPUTCHANNEL, "Egw%%EngineOutput", sOutputChannelName)
ConstChnName_EgwEngineOutput = sOutputChannelName.Replace("%%", "").Replace("@@", "")
ConstChnName_EgwDevEngineOutput = sOutputChannelName.Replace("%%", "Dev").Replace("@@", "")
Dim sStatisticsChannelName As String = ""
GetMainPrivateProfileString(sIniGroup, K_STATISTICSCHANNEL, "Egw%%Statistics@@", sStatisticsChannelName)
Dim sIpAddress As String = ":" & GetPcData.GetIPAddress().ToString
ConstChnName_EgwStatistics = sStatisticsChannelName.Replace("%%", "").Replace("@@", sIpAddress)
ConstChnName_EgwDevStatistics = sStatisticsChannelName.Replace("%%", "Dev").Replace("@@", sIpAddress)
m_chnEgwEngineOutput = New RedisChannel(ChnName_EgwEngineOutput, RedisChannel.PatternMode.Auto)
m_chnEgwStatistics = New RedisChannel(ChnName_EgwStatistics, RedisChannel.PatternMode.Auto)
m_RedisManager.SubscribeChannel(ChnName_EgwEngineInput, AddressOf EgwEngineInputHandler)
Friend Shared Function CreateExecEnvironmentManager(nType As EnvironmentCommunicationTypes, nGroupIndex As Integer, ByRef NewExecEnvironmentManager As ExecEnvironmentManager) As Boolean
Dim sConnection As String = "localhost"
GetMainPrivateProfileString(S_GENERAL, K_REDISCONNECTION, "", sConnection)
Dim sCamExePath As String = ""
GetMainPrivateProfileString(S_GENERAL, K_CAMEXEPATH, "", sCamExePath)
Dim sPipeLuaDirName As String = ""
GetMainPrivateProfileString(S_GENERAL, K_PIPELUADIRNAME, "", sPipeLuaDirName)
Dim sEnvironment As String = ""
Dim sPipeLuaFile As String = ""
Dim nMaxCamInstances As Integer = 0
Dim bDebug As Boolean = False
Dim sGroupTitle As String = If(nType = 2, 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
EgtOutLog("Group" & nGroupIndex.ToString())
EgtOutLog("Environment = " & sEnvironment)
EgtOutLog("PipeLuaFile = " & sPipeLuaFile)
EgtOutLog("MaxCAMInstances = " & nMaxCamInstances)
If nMaxCamInstances <= 0 Then
EgtOutLog("No Cam instances assigned!")
EgtOutLog(String.Format("Group{0} will not be created!", nGroupIndex.ToString()))
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
If ExecEnvironment = EXECENVIRONMENTS.NULL Then
EgtOutLog("No ExecEnvironment assigned!")
EgtOutLog(String.Format("Group{0} will not be created!", nGroupIndex.ToString()))
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("Group{0} will not be created!", nGroupIndex.ToString()))
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)
bDebug = (nDebug = 1)
NewExecEnvironmentManager = New ExecEnvironmentManager(nType, ExecEnvironment, nGroupIndex, sCamExePath, sProcessArguments, nMaxCamInstances, ExecProcessManager.ReturnModes.EVENT_, bDebug)
EgtOutLog(String.Format("Group{0} created", nGroupIndex.ToString()))
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)
m_EnvironmentCommunicationType = nType
Select Case m_EnvironmentCommunicationType
Case EnvironmentCommunicationTypes.REDIS
m_ExecEnvironment = nEnvironment
m_ExecProcessManager = New ExecProcessManager(nGroupId, nEnvironment, sProcessFileName, sProcessArguments, nMaxCamInstances, ExecProcessManager.ReturnModes.EVENT_, bDebug)
AddHandler m_ExecProcessManager.m_AnswerReceived, AddressOf ExecProcessManager_AnswerReceived
AddHandler m_ExecProcessManager.m_Statistics, AddressOf ExecProcessManager_Statistics
m_ExecProcessManager.StartExecutionThread()
' leggo canali input/output
Dim sIniGroup As String = S_EXECGROUP & nGroupId.ToString()
m_bChannelFromAnswer = (GetMainPrivateProfileInt(sIniGroup, K_CHANNELFROMANSWER, 0) = 1)
Dim sInputChannelName As String = ""
GetMainPrivateProfileString(sIniGroup, K_INPUTCHANNEL, "Egw%%EngineInput", sInputChannelName)
ConstChnName_EgwEngineInput = sInputChannelName.Replace("%%", "").Replace("@@", "")
ConstChnName_EgwDevEngineInput = sInputChannelName.Replace("%%", "Dev").Replace("@@", "")
Dim sOutputChannelName As String = ""
GetMainPrivateProfileString(sIniGroup, K_OUTPUTCHANNEL, "Egw%%EngineOutput", sOutputChannelName)
ConstChnName_EgwEngineOutput = sOutputChannelName.Replace("%%", "").Replace("@@", "")
ConstChnName_EgwDevEngineOutput = sOutputChannelName.Replace("%%", "Dev").Replace("@@", "")
Dim sStatisticsChannelName As String = ""
GetMainPrivateProfileString(sIniGroup, K_STATISTICSCHANNEL, "Egw%%Statistics@@", sStatisticsChannelName)
Dim sIpAddress As String = ":" & GetPcData.GetIPAddress().ToString
ConstChnName_EgwStatistics = sStatisticsChannelName.Replace("%%", "").Replace("@@", sIpAddress)
ConstChnName_EgwDevStatistics = sStatisticsChannelName.Replace("%%", "Dev").Replace("@@", sIpAddress)
m_chnEgwEngineOutput = New RedisChannel(ChnName_EgwEngineOutput, RedisChannel.PatternMode.Auto)
m_chnEgwStatistics = New RedisChannel(ChnName_EgwStatistics, RedisChannel.PatternMode.Auto)
m_RedisManager.SubscribeChannel(ChnName_EgwEngineInput, AddressOf EgwEngineInputHandler)
Case EnvironmentCommunicationTypes.REST
m_ExecEnvironment = nEnvironment
m_ExecProcessManager = New ExecProcessManager(nGroupId + 1000, nEnvironment, sProcessFileName, sProcessArguments, nMaxCamInstances, ExecProcessManager.ReturnModes.EVENT_, bDebug)
AddHandler m_ExecProcessManager.m_AnswerReceived, AddressOf ExecProcessManager_AnswerReceived
'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")
m_RestTimer.Interval = TimeSpan.FromMilliseconds(1000)
AddHandler m_RestTimer.Tick, AddressOf RestTimer_Tick
m_RestTimer.Start()
'RestTimer_Tick(Nothing, Nothing)
End Select
End Sub
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
Dim request As New RestRequest("Prod/getnext", Method.Get)
Dim response = Await m_Client.ExecuteAsync(request)
If response.StatusCode = Net.HttpStatusCode.OK Then
m_stopWatch.Restart()
Dim Question As QuestionDTO = JsonConvert.DeserializeObject(Of QuestionDTO)(response.Content)
If Not IsNothing(Question) AndAlso Question.ExecEnvironment = m_ExecEnvironment Then
Question.SetId(nRequestCounter)
EgtOutLog(DateTime.Now.ToString("HH:mm:ss.fff") & " Environment=" & m_ExecEnvironment & " Channel=REST Question Id=" & Question.nId)
m_ExecProcessManager.ArgumentsEnqueue(Question)
nProcessedQuestion += 1
Else
EgtOutLog(DateTime.Now.ToString("HH:mm:ss.fff") & "Errore! Environment=" & m_ExecEnvironment & " Channel=REST Content=" & response.Content)
End If
Else
' se non ci sono domande, esco
Return
End If
End While
End Sub
Private Sub EgwEngineInputHandler(RedisChannel As RedisChannel, RedisValue As RedisValue)
m_stopWatch.Restart()
Dim Request As QuestionDTO = JsonConvert.DeserializeObject(Of QuestionDTO)(RedisValue)
If Request.ExecEnvironment = m_ExecEnvironment Then
Request.SetId(nRequestCounter)
EgtOutLog(DateTime.Now.ToString("HH:mm:ss.fff") & " Environment=" & m_ExecEnvironment & " Channel=" & RedisChannel.ToString() & " Question Id=" & Request.nId)
m_ExecProcessManager.ArgumentsEnqueue(Request)
Dim Question As QuestionDTO = JsonConvert.DeserializeObject(Of QuestionDTO)(RedisValue)
If Question.ExecEnvironment = m_ExecEnvironment Then
Question.SetId(nRequestCounter)
EgtOutLog(DateTime.Now.ToString("HH:mm:ss.fff") & " Environment=" & m_ExecEnvironment & " Channel=" & RedisChannel.ToString() & " Question Id=" & Question.nId)
m_ExecProcessManager.ArgumentsEnqueue(Question)
End If
End Sub
Private Sub ExecProcessManager_AnswerReceived(Answer As AnswerDTO)
Dim chnEgwEngineOutput As RedisChannel = m_chnEgwEngineOutput
If m_bChannelFromAnswer Then
Dim ChnName_Output As String = Answer.Args("OutputChannel")
If Not String.IsNullOrWhiteSpace(ChnName_Output) Then
chnEgwEngineOutput = New RedisChannel(ChnName_Output, RedisChannel.PatternMode.Auto)
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_stopWatch.Stop()
' Format and display the TimeSpan value.
Dim elapsedTime As String = String.Format("{0:N3}", m_stopWatch.Elapsed.TotalMilliseconds)
m_nProcessingQty += 1
If m_dMinProcessingTime = 0 OrElse m_stopWatch.Elapsed.TotalMilliseconds < m_dMinProcessingTime Then m_dMinProcessingTime = m_stopWatch.Elapsed.TotalMilliseconds
If m_nProcessingQty > 1 Then
m_dMidProcessingTime = ((m_dMidProcessingTime * (m_nProcessingQty - 1)) / m_nProcessingQty) + (m_stopWatch.Elapsed.TotalMilliseconds / m_nProcessingQty)
Else
m_dMidProcessingTime = m_stopWatch.Elapsed.TotalMilliseconds
End If
If m_stopWatch.Elapsed.TotalMilliseconds > m_dMaxProcessingTime Then m_dMaxProcessingTime = m_stopWatch.Elapsed.TotalMilliseconds
EgtOutLog("Answer calculated in " & elapsedTime & "ms")
Select Case m_EnvironmentCommunicationType
Case EnvironmentCommunicationTypes.REDIS
Dim chnEgwEngineOutput As RedisChannel = m_chnEgwEngineOutput
If m_bChannelFromAnswer AndAlso Answer.Args.ContainsKey("OutputChannel") Then
Dim ChnName_Output As String = Answer.Args("OutputChannel")
If Not String.IsNullOrWhiteSpace(ChnName_Output) Then
chnEgwEngineOutput = New RedisChannel(ChnName_Output, RedisChannel.PatternMode.Auto)
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_stopWatch.Stop()
' Format and display the TimeSpan value.
Dim elapsedTime As String = String.Format("{0:N3}", m_stopWatch.Elapsed.TotalMilliseconds)
m_nProcessingQty += 1
If m_dMinProcessingTime = 0 OrElse m_stopWatch.Elapsed.TotalMilliseconds < m_dMinProcessingTime Then m_dMinProcessingTime = m_stopWatch.Elapsed.TotalMilliseconds
If m_nProcessingQty > 1 Then
m_dMidProcessingTime = ((m_dMidProcessingTime * (m_nProcessingQty - 1)) / m_nProcessingQty) + (m_stopWatch.Elapsed.TotalMilliseconds / m_nProcessingQty)
Else
m_dMidProcessingTime = m_stopWatch.Elapsed.TotalMilliseconds
End If
If m_stopWatch.Elapsed.TotalMilliseconds > m_dMaxProcessingTime Then m_dMaxProcessingTime = m_stopWatch.Elapsed.TotalMilliseconds
EgtOutLog("Answer " & Answer.nId & " calculated in " & elapsedTime & "ms")
Case EnvironmentCommunicationTypes.REST
If Answer.Args.ContainsKey("Mode") AndAlso Answer.Args.ContainsKey("SubMode") Then
Dim request As RestRequest = Nothing
Dim nMode As Integer = Answer.Args("Mode")
Dim nSubMode As Integer = Answer.Args("SubMode")
Select Case nMode
Case 5
Select Case nSubMode
Case 1
request = New RestRequest("Prod/jobreturn", Method.Post)
Case 2
request = New RestRequest("Prod/jobreturn", Method.Post)
End Select
End Select
'request.AddBody(JsonConvert.SerializeObject(Answer))
request.AddStringBody(JsonConvert.SerializeObject(Answer), DataFormat.Json)
EgtOutLog(DateTime.Now.ToString("HH:mm:ss.fff") & " Environment=" & m_ExecEnvironment & " Channel=REST Answer Id=" & Answer.nId)
' Eseguo la chiamata
Dim response As RestResponse = Client.Execute(request)
' Controllo l'esito
If response.IsSuccessful Then
Console.WriteLine("Answer Id=" & Answer.nId & "inviata con successo!")
Else
Console.WriteLine("Errore! Answer Id=" & Answer.nId & " Description=" & response.StatusDescription)
End If
Else
EgtOutLog("Errore! Risposta senza Mode o SubMode!")
End If
m_stopWatch.Stop()
' Format and display the TimeSpan value.
Dim elapsedTime As String = String.Format("{0:N3}", m_stopWatch.Elapsed.TotalMilliseconds)
m_nProcessingQty += 1
If m_dMinProcessingTime = 0 OrElse m_stopWatch.Elapsed.TotalMilliseconds < m_dMinProcessingTime Then m_dMinProcessingTime = m_stopWatch.Elapsed.TotalMilliseconds
If m_nProcessingQty > 1 Then
m_dMidProcessingTime = ((m_dMidProcessingTime * (m_nProcessingQty - 1)) / m_nProcessingQty) + (m_stopWatch.Elapsed.TotalMilliseconds / m_nProcessingQty)
Else
m_dMidProcessingTime = m_stopWatch.Elapsed.TotalMilliseconds
End If
If m_stopWatch.Elapsed.TotalMilliseconds > m_dMaxProcessingTime Then m_dMaxProcessingTime = m_stopWatch.Elapsed.TotalMilliseconds
EgtOutLog("Answer " & Answer.nId & " calculated in " & elapsedTime & "ms")
End Select
End Sub
Private Sub ExecProcessManager_Statistics(e As Statistics)
Dim CurrManagerStatistics As Statistics = e
CurrManagerStatistics.SetProcessingTimes(m_dMinProcessingTime, m_dMidProcessingTime, m_dMaxProcessingTime)
'RaiseEvent WindowStatisticUpdate(CurrManagerStatistics)
m_RedisManager.Subscriber.Publish(m_chnEgwStatistics, JsonConvert.SerializeObject(CurrManagerStatistics))
If Not IsNothing(m_chnEgwStatistics) Then
m_RedisManager.Subscriber.Publish(m_chnEgwStatistics, JsonConvert.SerializeObject(CurrManagerStatistics))
End If
m_nProcessingQty = 0
m_dMinProcessingTime = 100000
m_dMidProcessingTime = 0
+32
View File
@@ -0,0 +1,32 @@
Module Map
Private m_refMainWindowVM As MainWindowVM
#Region "Get"
Public ReadOnly Property refMainWindowVM As MainWindowVM
Get
Return m_refMainWindowVM
End Get
End Property
#End Region ' Get
#Region "Set"
#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)
End Function
#End Region ' Init
End Module
+7 -3
View File
@@ -1,17 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EgtDotNETBasis" version="2.7.11.20" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" 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" />
<package id="Pipelines.Sockets.Unofficial" version="2.2.8" targetFramework="net472" />
<package id="RestSharp" version="112.1.0" targetFramework="net472" />
<package id="StackExchange.Redis" version="2.8.58" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net472" />
<package id="System.IO.Pipelines" version="5.0.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net472" />
<package id="System.Text.Json" version="8.0.4" targetFramework="net472" />
<package id="System.Threading.Channels" version="5.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>
+45 -23
View File
@@ -1,33 +1,55 @@
param (
[string]$config,
[string]$directory
[string]$directory,
[string]$TargetPath
)
Write-Host "Inizio processing After Build: configurazione $config , directory $directory"
switch ($config) {
"Release" {
Write-Host "Release processing..."
#Get-ChildItem -Path "$directory" -Recurse -Include *.pdb, *.xml | Remove-Item -Force
#Get-ChildItem -Path "$directory\lib" -Recurse -Include *.pdb | Remove-Item -Force
Write-Host "Release: eliminato pdb + xml!!!"
}
"Debug" {
Write-Host "Debug processing..."
}
"RemoteDebug" {
Write-Host "RemoteDebug processing, effettuo copia script verso server remoto (ROBOCOPY)"
# copio DataRoot
$datarootdest = Join-Path $directory "DataRoot.ini"
Copy-Item "c:\EgtDev\EgwMultiEngineManager\ExtData\Tray.DataRoot.ini" $datarootdest -Force
# Uncomment the appropriate ROBOCOPY line(s) as needed
# Write-Host "Debug remoto: effettuo robocopy sync (verificare remote per cliente)"
ROBOCOPY "$directory" "\\w11-calc-01\c$\EgtProg\EgwMultiEngineManager" /MIR
}
default {
Write-Host "Configurazione non riconosciuta: $config"
}
"Release" {
Write-Host "Release processing..."
#Get-ChildItem -Path "$directory" -Recurse -Include *.pdb, *.xml | Remove-Item -Force
#Get-ChildItem -Path "$directory\lib" -Recurse -Include *.pdb | Remove-Item -Force
Write-Host "Release: eliminato pdb + xml!!!"
}
"Debug" {
Write-Host "Debug processing..."
$destDir = "c:\EgtProg\EgwMultiEngineManager"
# Crea la cartella se non esiste
if (-not (Test-Path $destDir)) {
New-Item -ItemType Directory -Path $destDir | Out-Null
}
# Copia l'exe principale
Copy-Item $TargetPath $destDir -Force
# Copia DLL necessarie
Get-ChildItem -Path $directory -Recurse -Include *.dll |
Copy-Item -Destination $destDir -Force
# Copia file di configurazione
#Get-ChildItem -Path $directory -Recurse -Include *.config, *.json, *.ini |
# Copy-Item -Destination $destDir -Force
Write-Host "Debug: copiati exe + dll + config nella cartella $destDir"
#Copy-Item $TargetPath "c:\EgtProg\EgwMultiEngineManager\EgwMultiEngineManager.Tray.exe" -Force
}
"RemoteDebug" {
Write-Host "RemoteDebug processing, effettuo copia script verso server remoto (ROBOCOPY)"
# copio DataRoot
$datarootdest = Join-Path $directory "DataRoot.ini"
Copy-Item "c:\EgtDev\EgwMultiEngineManager\ExtData\Tray.DataRoot.ini" $datarootdest -Force
# Uncomment the appropriate ROBOCOPY line(s) as needed
# Write-Host "Debug remoto: effettuo robocopy sync (verificare remote per cliente)"
ROBOCOPY "$directory" "\\w11-calc-01\c$\EgtProg\EgwMultiEngineManager" /MIR
}
default {
Write-Host "Configurazione non riconosciuta: $config"
}
}
Write-Host "Fatto!"