File tree Expand file tree Collapse file tree
ThreeByte.LinkLib.Projector Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ namespace ThreeByte . LinkLib . ProjectorLink . Commands
2+ {
3+ public abstract class Command
4+ {
5+ public delegate void CommandResultHandler ( Command sender , CommandResponse response ) ;
6+
7+ protected CommandResponse _cmdResponse ;
8+
9+ internal virtual string GetCommandString ( )
10+ {
11+ //NOOP
12+ return "" ;
13+ }
14+
15+ internal virtual bool ProcessAnswerString ( string a )
16+ {
17+ if ( a . IndexOf ( "=ERR1" ) >= 0 )
18+ {
19+ _cmdResponse = CommandResponse . UNDEFINED_CMD ;
20+ }
21+ else if ( a . IndexOf ( "=ERR2" ) >= 0 )
22+ {
23+ _cmdResponse = CommandResponse . UNDEFINED_CMD ;
24+ }
25+ else if ( a . IndexOf ( "=ERR3" ) >= 0 )
26+ {
27+ _cmdResponse = CommandResponse . UNAVAILABLE_TIME ;
28+ }
29+ else if ( a . IndexOf ( "=ERR4" ) >= 0 )
30+ {
31+ _cmdResponse = CommandResponse . PROJECTOR_FAILURE ;
32+ }
33+ else if ( a . IndexOf ( " ERRA" ) >= 0 )
34+ {
35+ _cmdResponse = CommandResponse . AUTH_FAILURE ;
36+ }
37+ else //OK or query answer...
38+ {
39+ _cmdResponse = CommandResponse . SUCCESS ;
40+ }
41+
42+ return _cmdResponse == CommandResponse . SUCCESS ;
43+ }
44+
45+ public CommandResponse CmdResponse
46+ {
47+ get { return _cmdResponse ; }
48+ }
49+
50+ public virtual string DumpToString ( )
51+ {
52+ return "" ;
53+ }
54+ }
55+ }
Original file line number Diff line number Diff line change 1+ namespace ThreeByte . LinkLib . ProjectorLink . Commands
2+ {
3+ public enum CommandResponse
4+ {
5+ SUCCESS ,
6+ UNDEFINED_CMD ,
7+ OUT_OF_PARAMETER ,
8+ UNAVAILABLE_TIME ,
9+ PROJECTOR_FAILURE ,
10+ AUTH_FAILURE ,
11+ COMMUNICATION_ERROR
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ namespace ThreeByte . LinkLib . ProjectorLink . Commands
2+ {
3+ public class ManufacturerNameCommand : Command
4+ {
5+ private string _name = "" ;
6+
7+ public ManufacturerNameCommand ( )
8+ {
9+ }
10+
11+ internal override string GetCommandString ( )
12+ {
13+ return "%1INF1 ?" ;
14+ }
15+
16+ internal override bool ProcessAnswerString ( string a )
17+ {
18+ if ( ! base . ProcessAnswerString ( a ) )
19+ {
20+ return false ;
21+ }
22+
23+ _name = a . Replace ( "%1INF1=" , "" ) ;
24+
25+ return true ;
26+ }
27+
28+
29+ public override string DumpToString ( )
30+ {
31+ string toRet = "Manufacturer: " + _name ;
32+ return toRet ;
33+ }
34+
35+ public string Manufacturer
36+ {
37+ get { return _name ; }
38+ }
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ namespace ThreeByte . LinkLib . ProjectorLink . Commands
2+ {
3+ public class PowerCommand : Command
4+ {
5+ private PowerStatus _status = PowerStatus . UNKNOWN ;
6+ private Power _cmdDetail ;
7+
8+ public enum Power
9+ {
10+ QUERY ,
11+ ON ,
12+ OFF
13+ }
14+
15+ public PowerCommand ( Power cmd )
16+ {
17+ _cmdDetail = cmd ;
18+ }
19+
20+ internal override string GetCommandString ( )
21+ {
22+ string cmdString = "%1POWR " ;
23+
24+ switch ( _cmdDetail )
25+ {
26+
27+ case Power . QUERY :
28+ cmdString += "?" ;
29+ break ;
30+ case Power . OFF :
31+ cmdString += "0" ;
32+ break ;
33+ case Power . ON :
34+ cmdString += "1" ;
35+ break ;
36+ }
37+
38+ return cmdString ;
39+ }
40+
41+ internal override bool ProcessAnswerString ( string a )
42+ {
43+ if ( ! base . ProcessAnswerString ( a ) )
44+ {
45+ _status = PowerStatus . UNKNOWN ;
46+ return false ;
47+ }
48+
49+ if ( _cmdDetail == Power . QUERY )
50+ {
51+ a = a . Replace ( "%1POWR=" , "" ) ;
52+ int retVal = int . Parse ( a ) ;
53+ if ( retVal >= ( int ) PowerStatus . OFF && retVal <= ( int ) PowerStatus . WARMUP )
54+ {
55+ _status = ( PowerStatus ) retVal ;
56+ }
57+ else
58+ {
59+ _status = PowerStatus . UNKNOWN ;
60+ }
61+ }
62+
63+ return true ;
64+ }
65+
66+ public PowerStatus Status
67+ {
68+ get { return _status ; }
69+ }
70+ }
71+ }
Original file line number Diff line number Diff line change 1+ namespace ThreeByte . LinkLib . ProjectorLink . Commands
2+ {
3+ public enum PowerStatus
4+ {
5+ OFF ,
6+ ON ,
7+ COOLING ,
8+ WARMUP ,
9+ UNKNOWN
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ namespace ThreeByte . LinkLib . ProjectorLink . Commands
2+ {
3+ public class ProductNameCommand : Command
4+ {
5+ private string _name = "" ;
6+
7+ public ProductNameCommand ( )
8+ {
9+ }
10+
11+ internal override string GetCommandString ( )
12+ {
13+ return "%1INF2 ?" ;
14+ }
15+
16+ internal override bool ProcessAnswerString ( string a )
17+ {
18+ if ( ! base . ProcessAnswerString ( a ) )
19+ {
20+ return false ;
21+ }
22+
23+ _name = a . Replace ( "%1INF2=" , "" ) ;
24+
25+ return true ;
26+ }
27+
28+ public override string DumpToString ( )
29+ {
30+ string toRet = "ProductName: " + _name ;
31+ return toRet ;
32+ }
33+
34+ public string ProductName
35+ {
36+ get { return _name ; }
37+ }
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ using System . Text ;
2+
3+ namespace ThreeByte . LinkLib . ProjectorLink . Commands
4+ {
5+ public class ProjectorNameCommand : Command
6+ {
7+ private string _name = "" ;
8+
9+ public ProjectorNameCommand ( )
10+ {
11+ }
12+
13+ internal override string GetCommandString ( )
14+ {
15+ return "%1NAME ?" ;
16+ }
17+
18+ internal override bool ProcessAnswerString ( string a )
19+ {
20+ if ( ! base . ProcessAnswerString ( a ) )
21+ {
22+ return false ;
23+ }
24+
25+ a = a . Replace ( "%1NAME=" , "" ) ;
26+
27+ byte [ ] dec = Encoding . ASCII . GetBytes ( a ) ;
28+ _name = Encoding . UTF8 . GetString ( dec ) ;
29+
30+ return true ;
31+ }
32+
33+
34+ public override string DumpToString ( )
35+ {
36+ return "Name: " + _name ;
37+ }
38+
39+ public string Name
40+ {
41+ get { return _name ; }
42+ }
43+ }
44+ }
You can’t perform that action at this time.
0 commit comments