-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPowerCommand.cs
More file actions
71 lines (61 loc) · 1.65 KB
/
PowerCommand.cs
File metadata and controls
71 lines (61 loc) · 1.65 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
69
70
71
namespace ThreeByte.LinkLib.ProjectorLink.Commands
{
public class PowerCommand : Command
{
private PowerStatus _status = PowerStatus.UNKNOWN;
private Power _cmdDetail;
public enum Power
{
QUERY,
ON,
OFF
}
public PowerCommand(Power cmd)
{
_cmdDetail = cmd;
}
internal override string GetCommandString()
{
string cmdString = "%1POWR ";
switch (_cmdDetail)
{
case Power.QUERY:
cmdString += "?";
break;
case Power.OFF:
cmdString += "0";
break;
case Power.ON:
cmdString += "1";
break;
}
return cmdString;
}
internal override bool ProcessAnswerString(string a)
{
if (!base.ProcessAnswerString(a))
{
_status = PowerStatus.UNKNOWN;
return false;
}
if (_cmdDetail == Power.QUERY)
{
a = a.Replace("%1POWR=", "");
int retVal = int.Parse(a);
if (retVal >= (int)PowerStatus.OFF && retVal <= (int)PowerStatus.WARMUP)
{
_status = (PowerStatus)retVal;
}
else
{
_status = PowerStatus.UNKNOWN;
}
}
return true;
}
public PowerStatus Status
{
get { return _status; }
}
}
}