1: using System.Linq;
2: using System.Text.RegularExpressions;
3:
4: namespace Ia.Ngn.Cl.Model.Business.Nokia
5: {
6: ////////////////////////////////////////////////////////////////////////////
7:
8: /// <summary publish="true">
9: /// ONT support class of Next Generation Network'a (NGN's) Nokia business model.
10: /// </summary>
11: ///
12: /// <remarks>
13: /// Copyright © 2006-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 Ont
26: {
27: /// <summary/>
28: public enum FamilyType { Undefined = 0, Sfu = 1, Soho = 2, Mdu = 3 };
29:
30: /// <summary/>
31: public Ont() { }
32:
33: ////////////////////////////////////////////////////////////////////////////
34:
35: /// <summary>
36: ///
37: /// </summary>
38: public static string OntId(string ponId, int ontNumber)
39: {
40: string id;
41:
42: id = Ia.Ngn.Cl.Model.Business.Default.OntId(ponId, ontNumber);
43:
44: return id;
45: }
46:
47: ////////////////////////////////////////////////////////////////////////////
48:
49: /// <summary>
50: ///
51: /// </summary>
52: public static string OntId(string amsName, string cardPortOntSequence)
53: {
54: string id;
55: string ontPosition;
56:
57: ontPosition = Ia.Ngn.Cl.Model.Business.Nokia.Ams.OntPositionFromAmsNameAndCardPortOntSquence(amsName, cardPortOntSequence);
58:
59: id = (from o in Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.OntList where o.Position == ontPosition select o.Id).SingleOrDefault();
60:
61: return id;
62: }
63:
64: ////////////////////////////////////////////////////////////////////////////
65:
66: /// <summary>
67: ///
68: /// </summary>
69: public static Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType FamilyTypeFromString(string familyTypeString)
70: {
71: // this will convert string format of ONU type from both email submittals and from EMSONT EQUIPMENTID values from NCE
72:
73: Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
74:
75: if (!string.IsNullOrEmpty(familyTypeString))
76: {
77: switch (familyTypeString.ToUpper())
78: {
79: case "SFU": familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu; break;
80: case "SOHO": familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho; break;
81: case "MDU": familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu; break;
82:
83: default: familyType = Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Undefined; break;
84: }
85: }
86: else familyType = 0;
87:
88: return familyType; // Undefined
89: }
90:
91: ////////////////////////////////////////////////////////////////////////////
92:
93: /// <summary>
94: ///
95: /// </summary>
96: public static string FamilyTypeStringFromFamilyTypeId(int familyTypeId)
97: {
98: string familyTypeString;
99: Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType familyType;
100:
101: familyType = (Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType)familyTypeId;
102:
103: switch (familyType)
104: {
105: case Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Sfu: familyTypeString = "SFU"; break;
106: case Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Soho: familyTypeString = "SOHO"; break;
107: case Ia.Ngn.Cl.Model.Business.Nokia.Ont.FamilyType.Mdu: familyTypeString = "MDU"; break;
108: default: familyTypeString = string.Empty; break;
109: }
110:
111: return familyTypeString;
112: }
113:
114: ////////////////////////////////////////////////////////////////////////////
115:
116: /// <summary>
117: ///
118: /// </summary>
119: public static string OntPositionFromOntId(string ontId)
120: {
121: string rest, ontPosition, amsName;
122: int oltId, card, port, ont;
123:
124: oltId = int.Parse(ontId.Substring(0, 1 + 2 + 2 + 2 + 2)); // network id, site id, router id, odf id, olt id
125:
126: rest = Regex.Replace(ontId, "^" + oltId.ToString(), "");
127:
128: card = int.Parse(rest.Substring(4, 2));
129: port = int.Parse(rest.Substring(6, 2));
130: ont = int.Parse(rest.Substring(8, 2));
131:
132: amsName = Ia.Ngn.Cl.Model.Data.NetworkDesignDocument.AmsNameFromOltId(oltId);
133:
134: ontPosition = amsName + "-" + card + "-" + port + "-" + ont;
135:
136: return ontPosition;
137: }
138:
139: ////////////////////////////////////////////////////////////////////////////
140:
141: /// <summary>
142: ///
143: /// </summary>
144: public static bool IsValidSerialNumber(string serialNumber)
145: {
146: bool isValid;
147: string s;
148:
149: if (!string.IsNullOrEmpty(serialNumber))
150: {
151: if (serialNumber.Length == 12) // ALCLA0A23C74
152: {
153: s = serialNumber.ToUpper();
154:
155: if (s.Substring(0, 7) == "ALCLA0A")
156: {
157: s = s.Substring(4, 8);
158:
159: isValid = Ia.Cl.Model.Default.IsHex(s);
160: }
161: else isValid = false;
162: }
163: else isValid = false;
164: }
165: else isValid = false;
166:
167: return isValid;
168: }
169:
170: ////////////////////////////////////////////////////////////////////////////
171: ////////////////////////////////////////////////////////////////////////////
172: }
173:
174: ////////////////////////////////////////////////////////////////////////////
175: ////////////////////////////////////////////////////////////////////////////
176: }