DreamineVMS
1.0.0.0
Windows PC의 RTSP·USB 카메라 영상을 HLS로 변환해 원격 CCTV Viewer에 전달하는 데스크톱 에이전트입니다.
Toggle main menu visibility
로딩중...
검색중...
일치하는것 없음
VmsDashboardStateService.cs
이 파일의 문서화 페이지로 가기
1
using
Dreamine.Hybrid.Interfaces;
2
using
DreamineVMS.Models
;
3
using
DreamineVMS.Services.Cameras
;
4
using
DreamineVMS.Services.Runtime
;
5
using
DreamineVMS.States
;
6
7
namespace
DreamineVMS.Services.Dashboard
;
8
25
public
sealed
class
VmsDashboardStateService
:
IVmsDashboardStateService
, IDisposable
26
{
35
private
readonly
IVmsCameraRepository
_repository
;
44
private
readonly
ICameraRuntimeStateService
_runtimeState
;
53
private
readonly IHybridStateStore<VmsDashboardState>
_stateStore
;
62
private
readonly
object
_gate
=
new
();
71
private
bool
_isStarted
;
80
private
bool
_isDisposed
;
81
122
public
VmsDashboardStateService
(
123
IVmsCameraRepository
repository,
124
ICameraRuntimeStateService
runtimeState,
125
IHybridStateStore<VmsDashboardState> stateStore)
126
{
127
_repository
= repository ??
throw
new
ArgumentNullException(nameof(repository));
128
_runtimeState
= runtimeState ??
throw
new
ArgumentNullException(nameof(runtimeState));
129
_stateStore
= stateStore ??
throw
new
ArgumentNullException(nameof(stateStore));
130
}
131
140
public
void
Start
()
141
{
142
lock (
_gate
)
143
{
144
if
(
_isStarted
||
_isDisposed
)
145
{
146
return
;
147
}
148
149
_runtimeState.StateChanged +=
OnRuntimeStateChanged
;
150
_isStarted
=
true
;
151
}
152
153
// 시작 시 1회 초기 동기화.
154
Refresh
(
"VMS application started."
);
155
}
156
173
public
void
Refresh
(
string
? lastEvent =
null
)
174
{
175
if
(
_isDisposed
)
176
{
177
return
;
178
}
179
180
IReadOnlyList<CameraDevice> cameras =
_repository
.GetAll();
181
IReadOnlyList<CameraRuntimeState> states =
_runtimeState
.GetAll();
182
183
int
connectedCount = states.Count(state => state.State ==
CameraConnectionState
.Connected);
184
185
VmsDashboardState
previous =
_stateStore
.State;
186
string
finalLastEvent = lastEvent ?? previous.
LastEvent
;
187
188
_stateStore
.SetState(
new
VmsDashboardState
189
{
190
TotalCameraCount = cameras.Count,
191
ConnectedCameraCount = connectedCount,
192
RecordingCameraCount = 0,
193
LastEvent = finalLastEvent,
194
LastUpdated = DateTimeOffset.Now
195
});
196
}
197
206
public
void
Dispose
()
207
{
208
lock (
_gate
)
209
{
210
if
(
_isDisposed
)
211
{
212
return
;
213
}
214
215
if
(
_isStarted
)
216
{
217
_runtimeState.StateChanged -=
OnRuntimeStateChanged
;
218
_isStarted
=
false
;
219
}
220
221
_isDisposed
=
true
;
222
}
223
}
224
249
private
void
OnRuntimeStateChanged
(
object
? sender,
CameraRuntimeState
e)
250
{
251
Refresh
(e.
LastMessage
);
252
}
253
}
DreamineVMS.Models
Definition
CameraConnectionState.cs:1
DreamineVMS.Models.CameraConnectionState
CameraConnectionState
Definition
CameraConnectionState.cs:12
DreamineVMS.Services.Cameras
Definition
CameraRepositoryChangedEventArgs.cs:3
DreamineVMS.Services.Dashboard
Definition
IVmsDashboardStateService.cs:1
DreamineVMS.Services.Runtime
Definition
CameraRuntimeStateService.cs:4
DreamineVMS.States
Definition
VmsDashboardState.cs:1
DreamineVMS.Models.CameraRuntimeState
Definition
CameraRuntimeState.cs:15
DreamineVMS.Models.CameraRuntimeState.LastMessage
string LastMessage
Definition
CameraRuntimeState.cs:105
DreamineVMS.Services.Cameras.IVmsCameraRepository
Definition
IVmsCameraRepository.cs:14
DreamineVMS.Services.Dashboard.IVmsDashboardStateService
Definition
IVmsDashboardStateService.cs:20
DreamineVMS.Services.Dashboard.VmsDashboardStateService.Dispose
void Dispose()
Definition
VmsDashboardStateService.cs:206
DreamineVMS.Services.Dashboard.VmsDashboardStateService._isStarted
bool _isStarted
Definition
VmsDashboardStateService.cs:71
DreamineVMS.Services.Dashboard.VmsDashboardStateService._repository
readonly IVmsCameraRepository _repository
Definition
VmsDashboardStateService.cs:35
DreamineVMS.Services.Dashboard.VmsDashboardStateService.Refresh
void Refresh(string? lastEvent=null)
Definition
VmsDashboardStateService.cs:173
DreamineVMS.Services.Dashboard.VmsDashboardStateService._stateStore
readonly IHybridStateStore< VmsDashboardState > _stateStore
Definition
VmsDashboardStateService.cs:53
DreamineVMS.Services.Dashboard.VmsDashboardStateService.VmsDashboardStateService
VmsDashboardStateService(IVmsCameraRepository repository, ICameraRuntimeStateService runtimeState, IHybridStateStore< VmsDashboardState > stateStore)
Definition
VmsDashboardStateService.cs:122
DreamineVMS.Services.Dashboard.VmsDashboardStateService._gate
readonly object _gate
Definition
VmsDashboardStateService.cs:62
DreamineVMS.Services.Dashboard.VmsDashboardStateService.OnRuntimeStateChanged
void OnRuntimeStateChanged(object? sender, CameraRuntimeState e)
Definition
VmsDashboardStateService.cs:249
DreamineVMS.Services.Dashboard.VmsDashboardStateService._runtimeState
readonly ICameraRuntimeStateService _runtimeState
Definition
VmsDashboardStateService.cs:44
DreamineVMS.Services.Dashboard.VmsDashboardStateService.Start
void Start()
Definition
VmsDashboardStateService.cs:140
DreamineVMS.Services.Dashboard.VmsDashboardStateService._isDisposed
bool _isDisposed
Definition
VmsDashboardStateService.cs:80
DreamineVMS.Services.Runtime.ICameraRuntimeStateService
Definition
ICameraRuntimeStateService.cs:14
DreamineVMS.States.VmsDashboardState
Definition
VmsDashboardState.cs:12
DreamineVMS.States.VmsDashboardState.LastEvent
string LastEvent
Definition
VmsDashboardState.cs:61
Services
Dashboard
VmsDashboardStateService.cs
다음에 의해 생성됨 :
1.17.0