diff --git a/WebDoorCreator.CamSrv/ProcMan.vb b/WebDoorCreator.CamSrv/ProcMan.vb
index 357c0de..e6cc576 100644
--- a/WebDoorCreator.CamSrv/ProcMan.vb
+++ b/WebDoorCreator.CamSrv/ProcMan.vb
@@ -8,172 +8,176 @@ Public Class ProcMan
#Region "Public Constructors"
- Public Sub New()
+ Public Sub New()
- ' This call is required by the designer.
- InitializeComponent()
+ ' This call is required by the designer.
+ InitializeComponent()
- ' Add any initialization after the InitializeComponent() call.
- synchronizationContext = SynchronizationContext.Current
- m_bStopProcess = True
- SetMaxCamInstances(1)
- StartUiThread()
- ' preparo lista thread...
- LISTThreadStatus.BeginUpdate()
- LISTThreadStatus.Items.Clear()
- LISTThreadStatus.Items.Add(New ListViewItem(New String() {"init", "waiting", "-"}))
- LISTThreadStatus.EndUpdate()
+ ' Add any initialization after the InitializeComponent() call.
+ synchronizationContext = SynchronizationContext.Current
+ m_bStopProcess = True
+ SetMaxCamInstances(1)
+ StartUiThread()
+ ' preparo lista thread...
+ LISTThreadStatus.BeginUpdate()
+ LISTThreadStatus.Items.Clear()
+ LISTThreadStatus.Items.Add(New ListViewItem(New String() {"init", "waiting", "-"}))
+ LISTThreadStatus.EndUpdate()
- ' verifico SE avviare
- If chkAutoRestart.Checked Then
- startAllThreads()
- End If
- CheckStartAutoRestart()
+ ' verifico SE avviare
+ If chkAutoRestart.Checked Then
+ startAllThreads()
+ End If
+ CheckStartAutoRestart()
- End Sub
+ End Sub
#End Region
#Region "Private Fields"
- Private ReadOnly synchronizationContext As SynchronizationContext
+ Private ReadOnly synchronizationContext As SynchronizationContext
- ' caricamento del NEXT STACK da redis (come oggetto) PROD http : https://iis01.egalware.com/WDC/SRV/
- ' DEV: https : https://localhost:7043/
- Dim baseIp As String = "iis01.egalware.com"
+ ' caricamento del NEXT STACK da redis (come oggetto) PROD http : https://iis01.egalware.com/WDC/SRV/
+ ' DEV: https : https://localhost:7043/
+ Dim baseIp As String = "iis01.egalware.com"
- Dim baseUrl As String = "https://iis01.egalware.com/WDC/SRV/"
+ Dim baseUrl As String = "https://iis01.egalware.com/WDC/SRV/"
- Dim codPost As String = "WRK001"
+ Dim codPost As String = "WRK001"
- ' nome macchina calcolo
- Dim currWDC As WDC = New WDC(baseIp, baseUrl, codPost)
+ ' nome macchina calcolo
+ Dim currWDC As WDC = New WDC(baseIp, baseUrl, codPost)
- Dim idxSim As Integer = 0
+ Dim idxSim As Integer = 0
- Dim m_bExecutionThreadStoped As Boolean = False
+ Dim m_bExecutionThreadStoped As Boolean = False
- Dim m_bStopProcess As Boolean = False
+ Dim m_bStopProcess As Boolean = False
- Dim m_ExecutionThread As Thread
+ Dim m_ExecutionThread As Thread
- 'Private m_MaxCamInstances As Integer = 8
- Private m_MaxCamInstances As Integer = 1
+ 'Private m_MaxCamInstances As Integer = 8
+ Private m_MaxCamInstances As Integer = 1
- Dim risultatoPing As PingReply = Nothing
+ Dim risultatoPing As PingReply = Nothing
- Dim ThreadList As Thread()
+ Dim ThreadList As Thread()
- Dim ThreadDataList As ThreadData()
+ Dim ThreadDataList As ThreadData()
+
+ Dim m_bPingOk As Boolean = False
+ Dim m_bAliveOk As Boolean = False
#End Region
- Enum ThreadOperations As Integer
- WaitingData = 1
- FoundRequest = 2
- WritingDdf = 3
- ProcessingDdf = 4
- ReadingSvg = 5
- SendResult = 6
- Closed = 10
- End Enum
+ Enum ThreadOperations As Integer
+ WaitingData = 1
+ FoundRequest = 2
+ WritingDdf = 3
+ ProcessingDdf = 4
+ ReadingSvg = 5
+ SendResult = 6
+ Closed = 10
+ End Enum
- Private Class ThreadData
+ Private Class ThreadData
- 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_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
- Return m_Process
- End Get
- End Property
- Friend Sub SetProcess(value As Process)
- m_Process = value
- End Sub
+ Private m_Process As Process
+ Public ReadOnly Property Process As Process
+ Get
+ Return m_Process
+ End Get
+ End Property
+ Friend Sub SetProcess(value As Process)
+ m_Process = value
+ End Sub
- End Class
+ End Class
#Region "Private Methods"
- Private Sub UpdateThreadCurrentStatus()
- synchronizationContext.Post(New SendOrPostCallback(
+ Private Sub UpdateThreadCurrentStatus()
+ synchronizationContext.Post(New SendOrPostCallback(
Sub(o)
- ThreadCurrentStatusList.BeginUpdate()
- ThreadCurrentStatusList.Items.Clear()
+ ThreadCurrentStatusList.BeginUpdate()
+ ThreadCurrentStatusList.Items.Clear()
- If Not IsNothing(ThreadList) Then
- For ThreadIndex = 0 To ThreadList.Count - 1
- If Not IsNothing(ThreadList(ThreadIndex)) Then
- Dim ThreadProcessState As String = "Nothing"
- 'If Not IsNothing(ThreadDataList(ThreadIndex)) AndAlso Not IsNothing(ThreadDataList(ThreadIndex).Process) AndAlso
- 'Not IsNothing(ThreadDataList(ThreadIndex).Process.HasExited) Then
- ' ThreadProcessState = ThreadDataList(ThreadIndex).Process.HasExited
- 'End If
- ThreadCurrentStatusList.Items.Add(New ListViewItem(New String() {ThreadIndex,
+ If Not IsNothing(ThreadList) Then
+ For ThreadIndex = 0 To ThreadList.Count - 1
+ If Not IsNothing(ThreadList(ThreadIndex)) Then
+ Dim ThreadProcessState As String = "Nothing"
+ 'If Not IsNothing(ThreadDataList(ThreadIndex)) AndAlso Not IsNothing(ThreadDataList(ThreadIndex).Process) AndAlso
+ 'Not IsNothing(ThreadDataList(ThreadIndex).Process.HasExited) Then
+ ' ThreadProcessState = ThreadDataList(ThreadIndex).Process.HasExited
+ 'End If
+ ThreadCurrentStatusList.Items.Add(New ListViewItem(New String() {ThreadIndex,
ThreadList(ThreadIndex).ThreadState.ToString(),
ThreadProcessState,
ThreadDataList(ThreadIndex).ThreadOperation.ToString()}))
- Else
- ThreadCurrentStatusList.Items.Add(New ListViewItem(New String() {ThreadIndex,
+ Else
+ ThreadCurrentStatusList.Items.Add(New ListViewItem(New String() {ThreadIndex,
"nothing"}))
- End If
- Next
- End If
- ThreadCurrentStatusList.EndUpdate()
-
+ End If
+ Next
+ End If
+ ThreadCurrentStatusList.EndUpdate()
+ lblpingTest.Text = m_bPingOk.ToString()
+ lblTestAlive.Text = m_bAliveOk.ToString()
End Sub), "")
- End Sub
+ End Sub
- Private Sub btnQueueStatus_Click(sender As Object, e As EventArgs) Handles btnQueueStatus.Click
- DisplayQueueStatus()
- End Sub
+ Private Sub btnQueueStatus_Click(sender As Object, e As EventArgs) Handles btnQueueStatus.Click
+ DisplayQueueStatus()
+ End Sub
- Private Sub btnResetQueue_Click(sender As Object, e As EventArgs) Handles btnResetQueue.Click
- currWDC.ResetQueue()
- txtOut.Text = "Queue Resetted!"
- End Sub
+ Private Sub btnResetQueue_Click(sender As Object, e As EventArgs) Handles btnResetQueue.Click
+ currWDC.ResetQueue()
+ txtOut.Text = "Queue Resetted!"
+ End Sub
- Private Sub btnTestAlive_Click(sender As Object, e As EventArgs) Handles btnTestAlive.Click
- Dim answ As String = ""
- If (currWDC.testAlive) Then
- lblTestAlive.Text = "Server Alive!!!"
- Else
- lblTestAlive.Text = "Alive test failed!"
- End If
- End Sub
+ Private Sub btnTestAlive_Click(sender As Object, e As EventArgs) Handles btnTestAlive.Click
+ Dim answ As String = ""
+ If (currWDC.testAlive) Then
+ lblTestAlive.Text = "Server Alive!!!"
+ Else
+ lblTestAlive.Text = "Alive test failed!"
+ End If
+ End Sub
- Private Sub btnTestPing_Click(sender As Object, e As EventArgs) Handles btnTestPing.Click
- ' chiamo test ping...
- risultatoPing = currWDC.testPing
- lblpingTest.Text = risultatoPing.Status.ToString()
- End Sub
+ Private Sub btnTestPing_Click(sender As Object, e As EventArgs) Handles btnTestPing.Click
+ ' chiamo test ping...
+ risultatoPing = currWDC.testPing
+ lblpingTest.Text = risultatoPing.Status.ToString()
+ End Sub
- Private Sub DisplayQueueStatus()
- Dim queueStatus As New Dictionary(Of String, Long)
- queueStatus = currWDC.queueStatus
- Dim sb As StringBuilder
- sb = New StringBuilder
- For Each item As KeyValuePair(Of String, Long) In queueStatus
- sb.AppendLine($"{item.Key}: {item.Value}")
- Next
- sb.AppendLine()
- txtQueue.Text = sb.ToString()
- txtQueue.Invalidate()
- End Sub
+ Private Sub DisplayQueueStatus()
+ Dim queueStatus As New Dictionary(Of String, Long)
+ queueStatus = currWDC.queueStatus
+ Dim sb As StringBuilder
+ sb = New StringBuilder
+ For Each item As KeyValuePair(Of String, Long) In queueStatus
+ sb.AppendLine($"{item.Key}: {item.Value}")
+ Next
+ sb.AppendLine()
+ txtQueue.Text = sb.ToString()
+ txtQueue.Invalidate()
+ End Sub
- Private Sub ExecutionProcess()
- ' recupero Id dei DDF
- Dim sDdfRoot As String = "c:\EgtData\WebDoor\Ddf"
- Dim sCurrDdfDir As String = ""
- Dim nDdfId As Integer = 1
+ Private Sub ExecutionProcess()
+ ' recupero Id dei DDF
+ Dim sDdfRoot As String = "c:\EgtData\WebDoor\Ddf"
+ Dim sCurrDdfDir As String = ""
+ Dim nDdfId As Integer = 1
Dim bStopMainProcess As Boolean = False
Dim n30SecCounter As Integer = 0
@@ -190,8 +194,12 @@ Public Class ProcMan
' test boolean diretto
bOk = currWDC.testPingOk
+ m_bPingOk = bOk
If bOk Then
bOk = currWDC.testAlive
+ m_bAliveOk = bOk
+ Else
+ m_bAliveOk = False
End If
Else
bOk = True
@@ -218,6 +226,7 @@ Public Class ProcMan
For ThreadIndex = 0 To ThreadList.Count - 1
ThreadList(ThreadIndex) = Nothing
Next
+ m_bStopProcess = False
End If
If bStopMainProcess Then
m_bExecutionThreadStoped = True
@@ -257,12 +266,18 @@ Public Class ProcMan
Thread = New Thread(Sub()
ThreadFunction(ThreadId)
End Sub)
+ Thread.SetApartmentState(ApartmentState.STA)
+ ' avvio thread di gestione della macchina che avvia la connessione
+ Thread.Start()
End If
Else
Dim ThreadId As Integer = ThreadIndex
- Thread = New Thread(Sub()
- ThreadFunction(ThreadId)
- End Sub)
+ ThreadList(ThreadIndex) = New Thread(Sub()
+ ThreadFunction(ThreadId)
+ End Sub)
+ ThreadList(ThreadIndex).SetApartmentState(ApartmentState.STA)
+ ' avvio thread di gestione della macchina che avvia la connessione
+ ThreadList(ThreadIndex).Start()
End If
Next
If n30SecCounter <= 30 Then
@@ -272,83 +287,83 @@ Public Class ProcMan
End If
Thread.Sleep(1000)
- End While
+ End While
- End Sub
+ End Sub
- Private Function GetFileContent(ByVal filePath As String, ByRef fileContent As String) As Boolean
+ Private Function GetFileContent(ByVal filePath As String, ByRef fileContent As String) As Boolean
- Dim bOk As Boolean = File.Exists(filePath)
- If bOk Then
- Try
- fileContent = File.ReadAllText(filePath)
- Catch ex As Exception
- bOk = False
- fileContent = ""
- End Try
- End If
- Return bOk
- End Function
+ Dim bOk As Boolean = File.Exists(filePath)
+ If bOk Then
+ Try
+ fileContent = File.ReadAllText(filePath)
+ Catch ex As Exception
+ bOk = False
+ fileContent = ""
+ End Try
+ End If
+ Return bOk
+ End Function
- Private Sub performBarAdvance()
- synchronizationContext.Post(New SendOrPostCallback(
+ Private Sub performBarAdvance()
+ synchronizationContext.Post(New SendOrPostCallback(
Sub(o)
- tsProgBar.PerformStep()
- If tsProgBar.Value >= tsProgBar.Maximum Then
- tsProgBar.Value = 0
- End If
+ tsProgBar.PerformStep()
+ If tsProgBar.Value >= tsProgBar.Maximum Then
+ tsProgBar.Value = 0
+ End If
- tsProgBar.Invalidate()
+ tsProgBar.Invalidate()
End Sub
), "")
- End Sub
+ End Sub
- Private Sub performUpdateUI()
- synchronizationContext.Post(New SendOrPostCallback(
+ Private Sub performUpdateUI()
+ synchronizationContext.Post(New SendOrPostCallback(
Sub(o)
- 'verifico thread attivi e se calano --> riavvia..
- If ThreadCount() <> m_MaxCamInstances And Not m_bStopProcess Then
- 'stopAllThreads()
- 'Thread.Sleep(100)
- 'startAllThreads()
- End If
+ 'verifico thread attivi e se calano --> riavvia..
+ If ThreadCount() <> m_MaxCamInstances And Not m_bStopProcess Then
+ 'stopAllThreads()
+ 'Thread.Sleep(100)
+ 'startAllThreads()
+ End If
- lblRunning.Text = $"threads: {ThreadCount()}/{m_MaxCamInstances}"
- lblRunning.Invalidate()
- DisplayQueueStatus()
- ' colore btn start / stop...
- If m_bStopProcess Then
+ lblRunning.Text = $"threads: {ThreadCount()}/{m_MaxCamInstances}"
+ lblRunning.Invalidate()
+ DisplayQueueStatus()
+ ' colore btn start / stop...
+ If m_bStopProcess Then
- StartProcess.BackColor = ButtonBase.DefaultBackColor
- StartProcess.ForeColor = ButtonBase.DefaultForeColor
- StopProcess.BackColor = Color.Green
- StopProcess.ForeColor = Color.White
- Else
- StartProcess.BackColor = Color.Green
- StartProcess.ForeColor = Color.White
- StopProcess.BackColor = ButtonBase.DefaultBackColor
- StopProcess.ForeColor = ButtonBase.DefaultForeColor
- End If
+ StartProcess.BackColor = ButtonBase.DefaultBackColor
+ StartProcess.ForeColor = ButtonBase.DefaultForeColor
+ StopProcess.BackColor = Color.Green
+ StopProcess.ForeColor = Color.White
+ Else
+ StartProcess.BackColor = Color.Green
+ StartProcess.ForeColor = Color.White
+ StopProcess.BackColor = ButtonBase.DefaultBackColor
+ StopProcess.ForeColor = ButtonBase.DefaultForeColor
+ End If
End Sub
), "")
- End Sub
+ End Sub
- Private Sub SetMaxCamInstances(value As Integer)
- ' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI)
- Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, value)
- m_MaxCamInstances = nMaxThread
- End Sub
+ Private Sub SetMaxCamInstances(value As Integer)
+ ' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI)
+ Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, value)
+ m_MaxCamInstances = nMaxThread
+ End Sub
- Private Sub startAllThreads()
- m_bStopProcess = False
- m_bExecutionThreadStoped = False
- m_ExecutionThread = New Thread(Sub()
- ExecutionProcess()
- End Sub)
+ Private Sub startAllThreads()
+ m_bStopProcess = False
+ m_bExecutionThreadStoped = False
+ m_ExecutionThread = New Thread(Sub()
+ ExecutionProcess()
+ End Sub)
- m_ExecutionThread.SetApartmentState(ApartmentState.STA)
- ' avvio thread di gestione della macchina che avvia la connessione
- m_ExecutionThread.Start()
+ m_ExecutionThread.SetApartmentState(ApartmentState.STA)
+ ' avvio thread di gestione della macchina che avvia la connessione
+ m_ExecutionThread.Start()
#If False Then
'' recupero Id dei DDF
'Dim sDdfRoot As String = "c:\EgtData\WebDoor\Ddf"
@@ -576,22 +591,22 @@ Public Class ProcMan
' End If
#End If
- End Sub
+ End Sub
- Private Sub StartProcess_Click(sender As Object, e As EventArgs) Handles StartProcess.Click
- startAllThreads()
- End Sub
+ Private Sub StartProcess_Click(sender As Object, e As EventArgs) Handles StartProcess.Click
+ startAllThreads()
+ End Sub
- Private Sub StartUiThread()
- ' avvio timer progBar
- TimerUI.Enabled = True
- TimerUI.Start()
+ Private Sub StartUiThread()
+ ' avvio timer progBar
+ TimerUI.Enabled = True
+ TimerUI.Start()
- ' avvio il timer di refresh
- TimerProgBar.Enabled = True
- TimerProgBar.Start()
- End Sub
+ ' avvio il timer di refresh
+ TimerProgBar.Enabled = True
+ TimerProgBar.Start()
+ End Sub
Private Sub stopAllThreads()
m_bStopProcess = True
@@ -611,244 +626,244 @@ Public Class ProcMan
TimerProgBar.Stop()
End Sub
- Private Sub StopProcess_Click(sender As Object, e As EventArgs) Handles StopProcess.Click
- stopAllThreads()
- End Sub
+ Private Sub StopProcess_Click(sender As Object, e As EventArgs) Handles StopProcess.Click
+ stopAllThreads()
+ End Sub
- Private Function ThreadCount() As Integer
- Dim numCount = 0
- If Not IsNothing(ThreadList) Then
- ' conto i NON nulli
- For Each Thread In ThreadList
- If Not IsNothing(Thread) Then
- numCount += 1
- End If
- Next
- End If
- ' rendo
- Return numCount
- End Function
+ Private Function ThreadCount() As Integer
+ Dim numCount = 0
+ If Not IsNothing(ThreadList) Then
+ ' conto i NON nulli
+ For Each Thread In ThreadList
+ If Not IsNothing(Thread) Then
+ numCount += 1
+ End If
+ Next
+ End If
+ ' rendo
+ Return numCount
+ End Function
- Private Sub ThreadFunction(ThreadIndex As Integer)
- Dim MyThreadData As New ThreadData
- ThreadDataList(ThreadIndex) = MyThreadData
- Dim sExePath As String = "c:\EgtProg\EgtEngine\EgtEngineR32.exe"
- Dim sCurrDdfDir As String = "c:\EgtData\WebDoor\Ddf"
- Dim stopWatch As New Stopwatch()
- Dim lExeTime As Long = 0
- Dim lOtherTime As Long = 0
+ Private Sub ThreadFunction(ThreadIndex As Integer)
+ Dim MyThreadData As New ThreadData
+ ThreadDataList(ThreadIndex) = MyThreadData
+ Dim sExePath As String = "c:\EgtProg\EgtEngine\EgtEngineR32.exe"
+ Dim sCurrDdfDir As String = "c:\EgtData\WebDoor\Ddf"
+ Dim stopWatch As New Stopwatch()
+ Dim lExeTime As Long = 0
+ Dim lOtherTime As Long = 0
- While Not m_bStopProcess
- MyThreadData.SetThreadOperation(ThreadOperations.WaitingData)
- ' se c'e' qualcosa da processare
- If currWDC.numTask2proc > 0 Then
- Dim LastRequest As Dictionary(Of String, String) = currWDC.queueList(1)
- If LastRequest.Count > 0 Then
- MyThreadData.SetThreadOperation(ThreadOperations.FoundRequest)
- Dim Item As KeyValuePair(Of String, String) = LastRequest.First()
- Dim bOk As Boolean = Not IsNothing(Item)
- If bOk Then
+ While Not m_bStopProcess
+ MyThreadData.SetThreadOperation(ThreadOperations.WaitingData)
+ ' se c'e' qualcosa da processare
+ If currWDC.numTask2proc > 0 Then
+ Dim LastRequest As Dictionary(Of String, String) = currWDC.queueList(1)
+ If LastRequest.Count > 0 Then
+ MyThreadData.SetThreadOperation(ThreadOperations.FoundRequest)
+ Dim Item As KeyValuePair(Of String, String) = LastRequest.First()
+ Dim bOk As Boolean = Not IsNothing(Item)
+ If bOk Then
- ' avvio cronometro
- 'stopWatch.Reset()
+ ' 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
+ File.Delete(sFile)
+ Next
+ End If
+
+ ' scrivo ddf
+ MyThreadData.SetThreadOperation(ThreadOperations.WritingDdf)
+ Dim sDdfPath As String = sCurrDdfDir & "\" & Item.Key & ".ddf"
+ Try
+ File.WriteAllText(sDdfPath, Item.Value)
+ Catch ex As Exception
+ bOk = False
+ End Try
+
+ If bOk Then
+ MyThreadData.SetThreadOperation(ThreadOperations.ProcessingDdf)
+
+ ' eseguo calcolo
+ Dim Proc As Process = New Process()
+ MyThreadData.SetProcess(Proc)
+ Proc.StartInfo.FileName = sExePath
+ Proc.StartInfo.Arguments = """C:\EgtData\WebDoor\Main.lua""" & " """ & sDdfPath & """"
+ Proc.StartInfo.UseShellExecute = False
+
+ If Proc.Start() Then
+
+ While Not Proc.HasExited
+ Thread.Sleep(1)
+ End While
+ MyThreadData.SetProcess(Nothing)
+ ' salvo exe time...
+ stopWatch.Stop()
+ lExeTime = stopWatch.ElapsedMilliseconds
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
- File.Delete(sFile)
- Next
+ 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)
+ ' invio risposta
+ currRes.Validated = Proc.ExitCode = 0 AndAlso bOk
+ currRes.DoorIdVers = Item.Key
+ ' se NON fosse validato --> messo il messaggio...
+ If (currRes.Validated) Then
+ currRes.SvgGen = fContent
+ Else
+ bOk = GetFileContent(Path.ChangeExtension(sDdfPath, "txt"), fContent)
+ currRes.ErrorMsg = fContent
End If
+ MyThreadData.SetThreadOperation(ThreadOperations.SendResult)
- ' scrivo ddf
- MyThreadData.SetThreadOperation(ThreadOperations.WritingDdf)
- Dim sDdfPath As String = sCurrDdfDir & "\" & Item.Key & ".ddf"
+ procResults.Add(currRes)
+ Dim respPut As String = currWDC.SendProcResults(procResults)
+
+ stopWatch.Stop()
+ lOtherTime = stopWatch.ElapsedMilliseconds
+ ' 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.WriteAllText(sDdfPath, Item.Value)
+ File.Delete(NewSvg)
Catch ex As Exception
- bOk = False
End Try
-
- If bOk Then
- MyThreadData.SetThreadOperation(ThreadOperations.ProcessingDdf)
-
- ' eseguo calcolo
- Dim Proc As Process = New Process()
- MyThreadData.SetProcess(Proc)
- Proc.StartInfo.FileName = sExePath
- Proc.StartInfo.Arguments = """C:\EgtData\WebDoor\Main.lua""" & " """ & sDdfPath & """"
- Proc.StartInfo.UseShellExecute = False
-
- If Proc.Start() Then
-
- While Not Proc.HasExited
- Thread.Sleep(1)
- End While
- MyThreadData.SetProcess(Nothing)
- ' 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)
- ' invio risposta
- currRes.Validated = Proc.ExitCode = 0 AndAlso bOk
- currRes.DoorIdVers = Item.Key
- ' se NON fosse validato --> messo il messaggio...
- If (currRes.Validated) Then
- currRes.SvgGen = 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
- ' 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
- End If
- stopWatch.Stop()
- End If
- End If
- End If
+ 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
+ End If
+ stopWatch.Stop()
+ End If
+ End If
End If
- End While
- MyThreadData.SetThreadOperation(ThreadOperations.Closed)
+ End If
+ End While
+ MyThreadData.SetThreadOperation(ThreadOperations.Closed)
- End Sub
+ End Sub
- Private Sub TimerProgBar_Tick(sender As Object, e As EventArgs) Handles TimerProgBar.Tick
- ' esegue refresh prog bar
- performBarAdvance()
- End Sub
+ Private Sub TimerProgBar_Tick(sender As Object, e As EventArgs) Handles TimerProgBar.Tick
+ ' esegue refresh prog bar
+ performBarAdvance()
+ End Sub
- Private Sub TimerUI_Tick(sender As Object, e As EventArgs) Handles TimerUI.Tick
- ' effettuo refresh code e status thread
- performUpdateUI()
- UpdateThreadCurrentStatus()
- End Sub
+ Private Sub TimerUI_Tick(sender As Object, e As EventArgs) Handles TimerUI.Tick
+ ' effettuo refresh code e status thread
+ performUpdateUI()
+ UpdateThreadCurrentStatus()
+ End Sub
- Private Sub txtNumThread_TextChanged(sender As Object, e As EventArgs) Handles txtNumThread.TextChanged
- Dim numReq As Integer = 1
- Integer.TryParse(txtNumThread.Text, numReq)
- ' controllo se cambiato il num thread
- If numReq <> m_MaxCamInstances Then
- If m_bStopProcess = False Then
- stopAllThreads()
- Thread.Sleep(200)
- End If
- ' imposto
- SetMaxCamInstances(numReq)
- End If
- End Sub
+ Private Sub txtNumThread_TextChanged(sender As Object, e As EventArgs) Handles txtNumThread.TextChanged
+ Dim numReq As Integer = 1
+ Integer.TryParse(txtNumThread.Text, numReq)
+ ' controllo se cambiato il num thread
+ If numReq <> m_MaxCamInstances Then
+ If m_bStopProcess = False Then
+ stopAllThreads()
+ Thread.Sleep(200)
+ End If
+ ' imposto
+ SetMaxCamInstances(numReq)
+ End If
+ End Sub
- Private isUpdatingThreads As Boolean = False
- '''
- ''' Esecuzione update display lista stato threads
- '''
- Private Sub UpdateThreadList(tId As String, tExeCam As Long, tOther As Long)
- synchronizationContext.Post(New SendOrPostCallback(
+ Private isUpdatingThreads As Boolean = False
+ '''
+ ''' Esecuzione update display lista stato threads
+ '''
+ Private Sub UpdateThreadList(tId As String, tExeCam As Long, tOther As Long)
+ synchronizationContext.Post(New SendOrPostCallback(
Sub(o)
- If Not isUpdatingThreads Then
- isUpdatingThreads = True
- ProcStats.RecordData(m_MaxCamInstances, tExeCam, tOther)
- ProcStats.RecordList.Enqueue((tId, tExeCam, tOther))
- 'Begin the update
- LISTThreadStatus.BeginUpdate()
- LISTThreadStatus.Items.Clear()
+ If Not isUpdatingThreads Then
+ isUpdatingThreads = True
+ ProcStats.RecordData(m_MaxCamInstances, tExeCam, tOther)
+ ProcStats.RecordList.Enqueue((tId, tExeCam, tOther))
+ 'Begin the update
+ LISTThreadStatus.BeginUpdate()
+ LISTThreadStatus.Items.Clear()
- ' compilo in base al tipo di stat richiesta
- If (chkStatAggr.Checked) Then
- ' statistiche di sintesi
- Dim sorted = From pair In ProcStats.ExeCumSum
- Order By pair.Key
- For Each item In sorted
- LISTThreadStatus.Items.Add(
+ ' compilo in base al tipo di stat richiesta
+ If (chkStatAggr.Checked) Then
+ ' statistiche di sintesi
+ Dim sorted = From pair In ProcStats.ExeCumSum
+ Order By pair.Key
+ For Each item In sorted
+ LISTThreadStatus.Items.Add(
New ListViewItem(New String() {item.Key,
$"{item.Value.NumRec} x {item.Value.ExeTime / item.Value.NumRec:N2} ms",
$"{item.Value.NumRec} x {item.Value.OthTime / item.Value.NumRec:N2} ms"
}))
- Next
- Else
- ' formato log
- Dim maxItems As Integer = 15
- While ProcStats.RecordList.Count > maxItems
- Dim oldItem As (String, Long, Long) = ("", 0, 0)
- ProcStats.RecordList.TryDequeue(oldItem)
- End While
+ Next
+ Else
+ ' formato log
+ Dim maxItems As Integer = 15
+ While ProcStats.RecordList.Count > maxItems
+ Dim oldItem As (String, Long, Long) = ("", 0, 0)
+ ProcStats.RecordList.TryDequeue(oldItem)
+ End While
- For Each item As (String, Long, Long) In ProcStats.RecordList.Reverse
- LISTThreadStatus.Items.Add(New ListViewItem(New String() {
+ For Each item As (String, Long, Long) In ProcStats.RecordList.Reverse
+ LISTThreadStatus.Items.Add(New ListViewItem(New String() {
item.Item1,
$"{item.Item2} ms",
$"{item.Item3} ms"
}))
- Next
+ Next
- End If
+ End If
- 'End the update
- LISTThreadStatus.EndUpdate()
- isUpdatingThreads = False
- End If
+ 'End the update
+ LISTThreadStatus.EndUpdate()
+ isUpdatingThreads = False
+ End If
End Sub
), "")
- End Sub
+ End Sub
#End Region
@@ -894,50 +909,50 @@ Public Class ProcMan
#Region "Private Structs"
- Private Structure MyProc
+ Private Structure MyProc
#Region "Public Fields"
- Public bEnable As Boolean
- Public nBar As Integer
- Public Proc As Process
- Public Thread As Thread
+ Public bEnable As Boolean
+ Public nBar As Integer
+ Public Proc As Process
+ Public Thread As Thread
#End Region
- End Structure
+ End Structure
- '''
- ''' Esportazione statistiche attuali esecuzione
- '''
- '''
- '''
- Private Sub btnExportStats_Click(sender As Object, e As EventArgs) Handles btnExportStats.Click
- ' statistiche di sintesi
- Dim sorted = From pair In ProcStats.ExeCumSum
- Order By pair.Key
- ' preparo il file export...
- Dim fileName As String
- Dim adesso As DateTime = DateTime.Now
- fileName = Path.Combine("C:\Temp\", $"WDC_Stats_{adesso:yyyyMMdd-HHmmss}.csv")
- Dim sb As StringBuilder = New StringBuilder
- sb.AppendLine("Threads;Samples;ExeTime;OtherTime;FullTime")
- For Each item In sorted
- ' preparo la linea CSV...
- sb.AppendLine($"{item.Key};{item.Value.NumRec};{item.Value.ExeTime / item.Value.NumRec:N2};{item.Value.OthTime / item.Value.NumRec:N2};{(item.Value.ExeTime + item.Value.OthTime) / item.Key:N2}")
- Next
- ' scrivo!
- File.WriteAllText(fileName, sb.ToString())
- End Sub
+ '''
+ ''' Esportazione statistiche attuali esecuzione
+ '''
+ '''
+ '''
+ Private Sub btnExportStats_Click(sender As Object, e As EventArgs) Handles btnExportStats.Click
+ ' statistiche di sintesi
+ Dim sorted = From pair In ProcStats.ExeCumSum
+ Order By pair.Key
+ ' preparo il file export...
+ Dim fileName As String
+ Dim adesso As DateTime = DateTime.Now
+ fileName = Path.Combine("C:\Temp\", $"WDC_Stats_{adesso:yyyyMMdd-HHmmss}.csv")
+ Dim sb As StringBuilder = New StringBuilder
+ sb.AppendLine("Threads;Samples;ExeTime;OtherTime;FullTime")
+ For Each item In sorted
+ ' preparo la linea CSV...
+ sb.AppendLine($"{item.Key};{item.Value.NumRec};{item.Value.ExeTime / item.Value.NumRec:N2};{item.Value.OthTime / item.Value.NumRec:N2};{(item.Value.ExeTime + item.Value.OthTime) / item.Key:N2}")
+ Next
+ ' scrivo!
+ File.WriteAllText(fileName, sb.ToString())
+ End Sub
- Private Sub ProcMan_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
- ' forzo chiusura threads!
- stopAllThreads()
- End Sub
+ Private Sub ProcMan_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
+ ' forzo chiusura threads!
+ stopAllThreads()
+ End Sub
- Private Sub chkAutoRestart_CheckedChanged(sender As Object, e As EventArgs) Handles chkAutoRestart.CheckedChanged
- CheckStartAutoRestart()
- End Sub
+ Private Sub chkAutoRestart_CheckedChanged(sender As Object, e As EventArgs) Handles chkAutoRestart.CheckedChanged
+ CheckStartAutoRestart()
+ End Sub
Private Sub CheckStartAutoRestart()
TimerCheck.Enabled = chkAutoRestart.Checked
@@ -960,9 +975,9 @@ Public Class ProcMan
End If
End Sub
- Private Sub TimerCheck_Tick(sender As Object, e As EventArgs) Handles TimerCheck.Tick
- restartAll()
- End Sub
+ Private Sub TimerCheck_Tick(sender As Object, e As EventArgs) Handles TimerCheck.Tick
+ restartAll()
+ End Sub
Private Sub restartAll()
If Not IsNothing(m_ExecutionThread) Then