1: using System;
2: using System.Collections.Generic;
3:
4: namespace Ia.Ngn.Cl.Model.Business.Huawei
5: {
6: ////////////////////////////////////////////////////////////////////////////
7:
8: /// <summary publish="true">
9: /// Huawei's Board support class of Next Generation Network'a (NGN's) business model.
10: /// </summary>
11: ///
12: /// <remarks>
13: /// Copyright © 2016-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
14: ///
15: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
16: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
17: ///
18: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20: ///
21: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
22: ///
23: /// Copyright notice: This notice may not be removed or altered from any source distribution.
24: /// </remarks>
25: public partial class Board
26: {
27: private static int sequentialEmsDevDevQueueOriginalCount;
28: private static Queue<Ia.Ngn.Cl.Model.Huawei.EmsBoard> sequentialEmsBoardQueue = new Queue<Ia.Ngn.Cl.Model.Huawei.EmsBoard>();
29:
30: ////////////////////////////////////////////////////////////////////////////
31:
32: /// <summary>
33: ///
34: /// </summary>
35: public class MduDevBoard
36: {
37: public string Type;
38: public string Version;
39: public int Fn;
40: public int Sn;
41: public int TelPortCount;
42: public int EthernetPortCount;
43:
44: ////////////////////////////////////////////////////////////////////////////
45:
46: /// <summary>
47: ///
48: /// </summary>
49: public MduDevBoard(string boardBt, string boardBname, string boardBver, int fn, int sn)
50: {
51: TelPortAndEthernetPortCountFromBoardNameAndVersion(boardBname, boardBver, out string version, out int telPorts, out int ethernetPorts);
52:
53: this.Type = boardBt;
54: this.Version = version;
55: this.Fn = fn;
56: this.Sn = sn;
57: this.TelPortCount = telPorts;
58: this.EthernetPortCount = ethernetPorts;
59: }
60:
61: ////////////////////////////////////////////////////////////////////////////
62:
63: /// <summary>
64: ///
65: /// </summary>
66: private void TelPortAndEthernetPortCountFromBoardNameAndVersion(string boardBname, string boardBver, out string boardVersion, out int telPorts, out int ethernetPort)
67: {
68: // select distinct BNAME from EmsBoards where BT = 'PSTN' or BT = 'ETH'
69:
70: if (boardBname == "H848ASNB" || boardBver.Contains("H848ASNB"))
71: {
72: boardVersion = "H848ASNB";
73: telPorts = 16;
74: ethernetPort = 0;
75: }
76: else if (boardBname == "H838ASRB" || boardBver.Contains("H838ASRB"))
77: {
78: boardVersion = "H838ASRB";
79: telPorts = 32;
80: ethernetPort = 0;
81: }
82: else if (boardBname == "H838ASPB" || boardBver.Contains("H838ASPB"))
83: {
84: boardVersion = "H838ASPB";
85: telPorts = 64;
86: ethernetPort = 0;
87: }
88: else if (boardBname == "HS22EPGD" || boardBver.Contains("HS22EPGD"))
89: {
90: boardVersion = "HS22EPGD";
91: telPorts = 0;
92: ethernetPort = 8;
93: }
94: else if (boardBname == "H831EIUD" || boardBver.Contains("H831EIUD"))
95: {
96: boardVersion = "H831EIUD";
97: telPorts = 0;
98: ethernetPort = 4;
99: }
100: else if (boardBver.Contains("--"))
101: {
102: boardVersion = "--";
103: telPorts = 0;
104: ethernetPort = 0;
105: }
106: else
107: {
108: throw new Exception("Unknown board version: board.Bver: " + boardBver) { };
109: }
110: }
111:
112: ////////////////////////////////////////////////////////////////////////////
113: }
114:
115: /// <summary/>
116: public Board() { }
117:
118: ////////////////////////////////////////////////////////////////////////////
119:
120: /// <summary>
121: ///
122: /// </summary>
123: public static string BoardId(int devId, int fn, int sn)
124: {
125: /*
126: * Id: OLT_01 Id-Frame-Slot-Port-OnuID
127: * FN SN PN ONTID
128: *
129: * Dev: did
130: * Board: FN SN
131: * Port: FN SN PN
132: * Ont: FN SN PN ONTID
133: *
134: * /// FN INTEGER 0-255 Indicates the subrack ID of the OLT.
135: * /// SN INTEGER 0-35 Indicates the slot ID of the OLT.
136: * /// PN INTEGER 0-63 Indicates the port ID of the OLT.
137: * /// ONTID INTEGER 0-255 NOTE If the UNI port is of 10G GPON, the value range is 0-255; if the UNI port is of 1G GPON, the value range is 0-127. Indicates the ONT ID.
138: */
139:
140: string id;
141:
142: if (devId > 0 && fn >= 0 && fn <= 255 && sn >= 0 && sn <= 35)
143: {
144: id = devId.ToString() + fn.ToString().PadLeft(3, '0') + sn.ToString().PadLeft(2, '0');
145: }
146: else
147: {
148: throw new System.ArgumentOutOfRangeException("fn, sn", "fn or sn is out of range");
149: }
150:
151: return id;
152: }
153:
154: ////////////////////////////////////////////////////////////////////////////
155:
156: /// <summary>
157: ///
158: /// </summary>
159: public static Ia.Ngn.Cl.Model.Huawei.EmsBoard SequentialEmsBoardListItem(out int sequentialEmsBoardQueueCount, out string progressCounterString)
160: {
161: Ia.Ngn.Cl.Model.Huawei.EmsBoard item;
162: List<Ia.Ngn.Cl.Model.Huawei.EmsBoard> list;
163:
164: if (sequentialEmsBoardQueue.Count == 0)
165: {
166: list = Ia.Ngn.Cl.Model.Data.Huawei.Board.List();
167:
168: sequentialEmsBoardQueue = new Queue<Ia.Ngn.Cl.Model.Huawei.EmsBoard>(list.Shuffle());
169:
170: sequentialEmsDevDevQueueOriginalCount = sequentialEmsBoardQueue.Count;
171: }
172:
173: if (sequentialEmsBoardQueue.Count > 0) item = sequentialEmsBoardQueue.Dequeue();
174: else item = null;
175:
176: progressCounterString = "(" + sequentialEmsBoardQueue.Count + "/" + sequentialEmsDevDevQueueOriginalCount + ")";
177:
178: sequentialEmsBoardQueueCount = sequentialEmsBoardQueue.Count;
179:
180: return item;
181: }
182:
183: ////////////////////////////////////////////////////////////////////////////
184: ////////////////////////////////////////////////////////////////////////////
185: }
186:
187: ////////////////////////////////////////////////////////////////////////////
188: ////////////////////////////////////////////////////////////////////////////
189: }