diff --git a/WebDoorCreator.CamSrv/ProcMan.vb b/WebDoorCreator.CamSrv/ProcMan.vb index 61a0dd5..357c0de 100644 --- a/WebDoorCreator.CamSrv/ProcMan.vb +++ b/WebDoorCreator.CamSrv/ProcMan.vb @@ -175,96 +175,102 @@ Public Class ProcMan Dim sCurrDdfDir As String = "" Dim nDdfId As Integer = 1 - Dim bStopMainProcess As Boolean = False - Dim n30SecCounter As Integer = 0 - While Not bStopMainProcess - bStopMainProcess = m_bStopProcess - Dim bOk As Boolean = False - While Not bOk - If Not bStopMainProcess AndAlso Not m_bStopProcess Then - ' ogni 30 secondi - If n30SecCounter = 30 OrElse n30SecCounter = 0 Then - ' verifica connessione - 'Dim risultatoPing As PingReply = currWDC.testPing - 'bOk = risultatoPing.Status = IPStatus.Success + Dim bStopMainProcess As Boolean = False + Dim n30SecCounter As Integer = 0 + While Not bStopMainProcess + bStopMainProcess = m_bStopProcess + Dim bOk As Boolean = False + While Not bOk + If Not bStopMainProcess AndAlso Not m_bStopProcess Then + ' ogni 30 secondi + If n30SecCounter = 30 OrElse n30SecCounter = 0 Then + ' verifica connessione + 'Dim risultatoPing As PingReply = currWDC.testPing + 'bOk = risultatoPing.Status = IPStatus.Success - ' test boolean diretto - bOk = currWDC.testPingOk - If bOk Then - bOk = currWDC.testAlive + ' test boolean diretto + bOk = currWDC.testPingOk + If bOk Then + bOk = currWDC.testAlive + End If + Else + bOk = True + End If + End If + ' se connessione non ok o processo fermato, fermo i thread + If Not bOk OrElse bStopMainProcess Then + If Not IsNothing(ThreadList) AndAlso ThreadList.Count > 0 AndAlso Not IsNothing(ThreadList(0)) Then + ' li fermo + m_bStopProcess = True + ' verifico siano terminati + Dim bOneNotEnded As Boolean = True + While bOneNotEnded + bOneNotEnded = False + For Each Thread In ThreadList + If Not IsNothing(Thread) Then + If Thread.IsAlive Then + bOneNotEnded = True + End If End If - Else - bOk = True - End If - End If - ' se connessione non ok o processo fermato, fermo i thread - If Not bOk OrElse bStopMainProcess Then - If Not IsNothing(ThreadList) AndAlso ThreadList.Count > 0 AndAlso Not IsNothing(ThreadList(0)) Then - ' li fermo - m_bStopProcess = True - ' verifico siano terminati - Dim bOneNotEnded As Boolean = True - While bOneNotEnded - bOneNotEnded = False - For Each Thread In ThreadList - If Not IsNothing(Thread) Then - If Thread.IsAlive Then - bOneNotEnded = True - End If - End If - Next - End While - ' pulisco la lista - For ThreadIndex = 0 To ThreadList.Count - 1 - ThreadList(ThreadIndex) = Nothing - Next - End If - If bStopMainProcess Then - m_bExecutionThreadStoped = True - Return - End If - End If - If Not bOk Then Thread.Sleep(10) - End While + Next + End While + ' pulisco la lista + For ThreadIndex = 0 To ThreadList.Count - 1 + ThreadList(ThreadIndex) = Nothing + Next + End If + If bStopMainProcess Then + m_bExecutionThreadStoped = True + Return + End If + End If + If Not bOk Then Thread.Sleep(10) + End While - If bOk AndAlso (IsNothing(ThreadList) OrElse ThreadList.Count = 0 OrElse IsNothing(ThreadList(0))) Then - ThreadList = New Thread(m_MaxCamInstances - 1) {} - ThreadDataList = New ThreadData(m_MaxCamInstances - 1) {} - For nThreadIndex = 0 To m_MaxCamInstances - 1 - Dim ThreadId As Integer = nThreadIndex - ThreadList(nThreadIndex) = New Thread(Sub() - ThreadFunction(ThreadId) - End Sub) - ThreadList(nThreadIndex).SetApartmentState(ApartmentState.STA) - ' avvio thread di gestione della macchina che avvia la connessione - ThreadList(nThreadIndex).Start() - Thread.Sleep(10) - Next - End If - ' se qualche processo in stop, lo faccio ripartire - For ThreadIndex = 0 To ThreadList.Count - 1 - Dim Thread = ThreadList(ThreadIndex) - If Not IsNothing(Thread) Then - If Thread.ThreadState = ThreadState.Stopped OrElse Thread.ThreadState = ThreadState.Aborted OrElse - Thread.ThreadState = ThreadState.Suspended Then - Thread.Abort() - Thread.Sleep(1000) - While Not Thread.ThreadState = ThreadState.Aborted - Thread.Sleep(1000) - End While - Dim ThreadId As Integer = ThreadIndex - Thread = New Thread(Sub() - ThreadFunction(ThreadId) - End Sub) - End If - End If + If bOk AndAlso (IsNothing(ThreadList) OrElse ThreadList.Count = 0) Then + ThreadList = New Thread(m_MaxCamInstances - 1) {} + ThreadDataList = New ThreadData(m_MaxCamInstances - 1) {} + For nThreadIndex = 0 To m_MaxCamInstances - 1 + Dim ThreadId As Integer = nThreadIndex + ThreadList(nThreadIndex) = New Thread(Sub() + ThreadFunction(ThreadId) + End Sub) + ThreadList(nThreadIndex).SetApartmentState(ApartmentState.STA) + ' avvio thread di gestione della macchina che avvia la connessione + ThreadList(nThreadIndex).Start() + Thread.Sleep(100) Next - If n30SecCounter <= 30 Then - n30SecCounter += 1 + End If + ' se qualche processo in stop, lo faccio ripartire + For ThreadIndex = 0 To ThreadList.Count - 1 + Dim Thread = ThreadList(ThreadIndex) + If Not IsNothing(Thread) Then + If Thread.ThreadState = ThreadState.Stopped OrElse Thread.ThreadState = ThreadState.Aborted OrElse + Thread.ThreadState = ThreadState.Suspended Then + Thread.Abort() + Thread.Sleep(500) + While Not Thread.ThreadState = ThreadState.Aborted + Thread.Sleep(100) + End While + Thread = Nothing + Dim ThreadId As Integer = ThreadIndex + Thread = New Thread(Sub() + ThreadFunction(ThreadId) + End Sub) + End If Else - n30SecCounter = 1 + Dim ThreadId As Integer = ThreadIndex + Thread = New Thread(Sub() + ThreadFunction(ThreadId) + End Sub) End If - Thread.Sleep(1000) + Next + If n30SecCounter <= 30 Then + n30SecCounter += 1 + Else + n30SecCounter = 1 + End If + Thread.Sleep(1000) End While @@ -587,21 +593,23 @@ Public Class ProcMan TimerProgBar.Start() End Sub - Private Sub stopAllThreads() - m_bStopProcess = True - - While Not m_bExecutionThreadStoped + Private Sub stopAllThreads() + m_bStopProcess = True + While Not m_bExecutionThreadStoped + Thread.Sleep(100) + End While + If Not IsNothing(m_ExecutionThread) Then + m_ExecutionThread.Abort() + While Not m_ExecutionThread.ThreadState = ThreadState.Aborted Thread.Sleep(100) - End While - m_ExecutionThread.Abort() - While Not m_ExecutionThread.ThreadState = ThreadState.Aborted - Thread.Sleep(100) - End While - m_ExecutionThread = Nothing - ' fix timer - TimerProgBar.Enabled = False - TimerProgBar.Stop() - End Sub + End While + m_ExecutionThread = Nothing + End If + ThreadList = Nothing + ' fix timer + TimerProgBar.Enabled = False + TimerProgBar.Stop() + End Sub Private Sub StopProcess_Click(sender As Object, e As EventArgs) Handles StopProcess.Click stopAllThreads() @@ -931,41 +939,42 @@ Public Class ProcMan CheckStartAutoRestart() End Sub - Private Sub CheckStartAutoRestart() - TimerCheck.Enabled = chkAutoRestart.Checked - If chkAutoRestart.Checked Then - If Not IsNothing(m_ExecutionThread) AndAlso (m_ExecutionThread.ThreadState = ThreadState.Aborted OrElse m_ExecutionThread.ThreadState = ThreadState.Stopped OrElse - m_ExecutionThread.ThreadState = ThreadState.Suspended) Then - stopAllThreads() - Thread.Sleep(200) - While Not IsNothing(m_ExecutionThread) - Thread.Sleep(100) - End While - Thread.Sleep(100) - startAllThreads() - End If - TimerCheck.Start() - Else - TimerCheck.Stop() - End If - End Sub + Private Sub CheckStartAutoRestart() + TimerCheck.Enabled = chkAutoRestart.Checked + If chkAutoRestart.Checked Then + If IsNothing(m_ExecutionThread) Then + startAllThreads() + ElseIf m_ExecutionThread.ThreadState = ThreadState.Aborted OrElse m_ExecutionThread.ThreadState = ThreadState.Stopped OrElse + m_ExecutionThread.ThreadState = ThreadState.Suspended Then + stopAllThreads() + Thread.Sleep(200) + While Not IsNothing(m_ExecutionThread) + Thread.Sleep(100) + End While + Thread.Sleep(100) + startAllThreads() + End If + TimerCheck.Start() + Else + TimerCheck.Stop() + End If + End Sub Private Sub TimerCheck_Tick(sender As Object, e As EventArgs) Handles TimerCheck.Tick restartAll() End Sub - Private Sub restartAll() - ' eseguo riavvio forzato ogni 30 sec! - If Not IsNothing(m_ExecutionThread) Then - stopAllThreads() - Thread.Sleep(200) - While Not IsNothing(m_ExecutionThread) - Thread.Sleep(100) - End While + Private Sub restartAll() + If Not IsNothing(m_ExecutionThread) Then + stopAllThreads() + Thread.Sleep(200) + While Not IsNothing(m_ExecutionThread) Thread.Sleep(100) - End If - startAllThreads() - End Sub + End While + Thread.Sleep(100) + End If + startAllThreads() + End Sub #End Region diff --git a/WebDoorCreator.UI/Pages/OrdersHomePage.razor.css b/WebDoorCreator.UI/Pages/OrdersHomePage.razor.css index 06db017..ceb5ef1 100644 --- a/WebDoorCreator.UI/Pages/OrdersHomePage.razor.css +++ b/WebDoorCreator.UI/Pages/OrdersHomePage.razor.css @@ -6,4 +6,19 @@ /*box-shadow: rgba(0, 0, 0, 0.45) 0px 20px 22px -9px;*/ margin-top: 0.5rem; margin-bottom: 1rem; -} \ No newline at end of file +} +/*div { + background-color: red; + animation-name: example; + animation-duration: 4s; +} + +@keyframes example { + from { + background-color: transparent; + } + + to { + background-color: yellow; + } +}*/ \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/OrdersHomePage.razor.less b/WebDoorCreator.UI/Pages/OrdersHomePage.razor.less index e2da35d..223f52c 100644 --- a/WebDoorCreator.UI/Pages/OrdersHomePage.razor.less +++ b/WebDoorCreator.UI/Pages/OrdersHomePage.razor.less @@ -7,3 +7,19 @@ margin-top: 0.5rem; margin-bottom: 1rem; } + +/*div { + background-color: red; + animation-name: example; + animation-duration: 4s; +} + +@keyframes example { + from { + background-color: transparent; + } + + to { + background-color: yellow; + } +}*/ \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/TestAnim.razor b/WebDoorCreator.UI/Pages/TestAnim.razor new file mode 100644 index 0000000..19f1cb3 --- /dev/null +++ b/WebDoorCreator.UI/Pages/TestAnim.razor @@ -0,0 +1,129 @@ +@using WebDoorCreator.UI.Components.SvgComp +@using WebDoorCreator.UI.Data +@page "/TestAnim" + +@inject WebDoorCreatorService WDCService + + +