1
wxr
2023-03-31 7e42cc13a14b7de31c9f5d5c61cdf24f3246335d
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Collections.Generic;
using Shared;
using Shared.SimpleControl;
 
namespace Shared
{
    [System.Serializable]
    public class InfraredMode : Common
    {
        public InfraredMode () : base ()
        {
            this.Type = DeviceType.InfraredMode;
            //if (InfraredType == InfraredType.TV)
            DeviceTextID = SimpleControl.R.MyInternationalizationString.TV;
            //else if (InfraredType == InfraredType.AC)
            //DeviceTextID = SimpleControl.R.MyInternationalizationString.AC;
        }
        public InfraredType InfraredType = InfraredType.NULL;
 
        //设备码:DeviceID 0:投影机  1:风扇  2:机顶盒  3:DVD    4:TV   5:空调  6:IPTV
 
        public List<InfraredCustomFunction> TV_CustomFuntion = new List<InfraredCustomFunction> ();
 
        public string Port = "1";
 
        //DeviceTextID 
 
        public bool isControlTV = true;
 
        /// <summary>
        /// 电视绑定机顶盒的路径
        /// </summary>
        public string LinkInfraredMode = string.Empty;
 
        public string deviceFilePath {
            get {
                return "Equipment_InfraredMode_" + SubnetID.ToString () + "_" + DeviceID.ToString () + "_" + (LoopID.ToString ().Length < 2 ? "0" + LoopID.ToString () : LoopID.ToString ());
            }
        }
 
        public bool isOpen = false;
 
 
        public void InitTVFunction ()
        {
            TV_CustomFuntion.Add (new InfraredCustomFunction () {
                TextID = 4,
                UnSelectedImagePath = "TV/TVIcon.png",
                SelectedImagePath = "TV/TV_On.png",
                DeviceFilePath = deviceFilePath,
                FunctionCode = (int)InfraredCode_TV.VolUp,
            });
            TV_CustomFuntion.Add (new InfraredCustomFunction () {
                UnSelectedImagePath = "TV/TVIcon.png",
                SelectedImagePath = "TV/TV_On.png",
                TextID = 0,
                DeviceFilePath = deviceFilePath,
                FunctionCode = (int)InfraredCode_TV.VolDown,
            });
            TV_CustomFuntion.Add (new InfraredCustomFunction () {
                UnSelectedImagePath = "TV/TVIcon.png",
                SelectedImagePath = "TV/TV_On.png",
                TextID = 1,
                DeviceFilePath = deviceFilePath,
                FunctionCode = (int)InfraredCode_TV.ChannelUp,
            });
            TV_CustomFuntion.Add (new InfraredCustomFunction () {
                UnSelectedImagePath = "TV/TVIcon.png",
                SelectedImagePath = "TV/TV_On.png",
                TextID = 3,
                DeviceFilePath = deviceFilePath,
                FunctionCode = (int)InfraredCode_TV.ChannelDown,
            });
            TV_CustomFuntion.Add (new InfraredCustomFunction () {
                UnSelectedImagePath = "TV/TVIcon.png",
                SelectedImagePath = "TV/TV_On.png",
                TextID = 2,
                DeviceFilePath = deviceFilePath,
                FunctionCode = (int)InfraredCode_TV.Menu,
            });
 
            TV_CustomFuntion.Add (new InfraredCustomFunction () {
                UnSelectedImagePath = "TV/TVIcon.png",
                SelectedImagePath = "TV/TV_On.png",
                TextID = 6,
                DeviceFilePath = deviceFilePath,
                FunctionCode = (int)InfraredCode_TV.Mute,
            });
 
            IO.FileUtils.SaveEquipmentMessage (this, this.LoopID.ToString ());
        }
 
        public List<InfraredCustomChannel> InfraredCustomChannel = new List<InfraredCustomChannel> ();
    }
 
    public enum InfraredType
    {
        STB = 2,
        TV = 4,
        AC = 5,
        NULL = 255,
    }
 
    [System.Serializable]
    public class InfraredCustomFunction
    {
        public int TextID;
        public bool IsTV = true;
        public string SelectedImagePath;
        public string UnSelectedImagePath = "Item/TV_Bottom.png";
        /// <summary>
        /// 红外模块回路(红外库)路径
        /// </summary>
        public string DeviceFilePath;
        public int FunctionCode = 254;
 
    }
 
 
    /// <summary>
    /// 用户自定频道
    /// </summary>
    [System.Serializable]
    public class InfraredCustomChannel
    {
        public string ChannelName;
        public string ChannelNumber;
        public string BackgroundImagePath = "TV/TV3_4.png";
        public string ChannelIconPath;
        public bool isTV = true;
        public byte subnetID;
        public byte deviceID;
        public byte loopID;
        public byte port;
 
        public void Send ()
        {
            for (int i = 0; i < ChannelNumber.Length; i++) {
                int cn = Convert.ToInt32 (ChannelNumber.Substring (i, 1));
                Random ran = new Random ();
                int RandKey = ran.Next (0, 255);
                if (isTV)
                    Control.ControlBytesSend (Command.InfraredControl, subnetID, deviceID, new byte [] { port, loopID,
                    Convert.ToByte(cn+7), 0, 0, (byte)RandKey });
                else
                    Control.ControlBytesSend (Command.InfraredControl, subnetID, deviceID, new byte [] { port, loopID,
                    Convert.ToByte(cn+1), 0, 0, (byte)RandKey });
            }
        }
    }
}