Status.cs
1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/********************************************************************************
** 类名称: Status
** 描述 : 用于存放运行过程中的状态
** 作者 : 丁书杰
** 创建时间:2019/03/26
** 版权所有 (C) :中科视语(北京)科技有限公司
*********************************************************************************/
using OS.Spin.Common;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OS.Spin.Running.Infos
{
public class Status
{
private Dictionary<int, bool> _cameraImg = new Dictionary<int, bool>();
private static Status _cDk;
private static readonly object ObjLock = new object();
public static Status GetInstance()
{
lock (ObjLock)
{
return _cDk ?? (_cDk = new Status());
}
}
public bool CameraReady(int cameraId)
{
try
{
if (_cameraImg.Keys.Contains(cameraId))
{
return _cameraImg[cameraId];
}
return false;
}
catch (Exception ex)
{
LogisTrac.WriteLog(string.Format("CameraReady:{0}", ex.Message));
return false;
}
}
public void ChangedCameraReady(int cameraId)
{
try
{
if (_cameraImg.Keys.Contains(cameraId))
{
_cameraImg[cameraId] = !_cameraImg[cameraId];
return;
}
// 初始值
_cameraImg[cameraId] = true;
}
catch (Exception ex)
{
LogisTrac.WriteLog(string.Format("ChangedCameraReady:{0}", ex.Message));
}
}
}
}