Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Ont

Public general use code classes and xml files that we've compiled and used over the years:

Huawei's Ont support class of Next Generation Network'a (NGN's) business model.

   1:  using System;
   2:  using System.Collections.Generic;
   3:  using System.Linq;
   4:  using System.Web;
   5:  using System.Web.Security;
   6:  using System.Text.RegularExpressions;
   7:   
   8:  namespace Ia.Ngn.Cl.Model.Business.Huawei
   9:  {
  10:      ////////////////////////////////////////////////////////////////////////////
  11:   
  12:      /// <summary publish="true">
  13:      /// Huawei's Ont support class of Next Generation Network'a (NGN's) business model.
  14:      /// </summary>
  15:      /// 
  16:      /// <remarks> 
  17:      /// Copyright © 2016-2017 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  18:      ///
  19:      /// 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
  20:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  21:      ///
  22:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  23:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  24:      /// 
  25:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  26:      /// 
  27:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  28:      /// </remarks> 
  29:      public partial class Ont
  30:      {
  31:          /// <summary/>
  32:          public enum EquipmentType { Undefined = 0, HN8245Q_2 = 1, MA5672_4 = 2, MA5616_32 = 3, MA5616_48 = 6, MA5616_64 = 4, MA5616_96 = 5};
  33:   
  34:          public enum FamilyType { Undefined = 0, Sfu = 1, Soho = 2, Mdu = 3 };
  35:   
  36:          /// <summary/>
  37:          public Ont() { }
  38:   
  39:          ////////////////////////////////////////////////////////////////////////////
  40:   
  41:          /// <summary>
  42:          ///
  43:          /// </summary>
  44:          public static string OntId(/*int oltId, int fn, int sn, int pn,*/ string ponId, int ontSystemId)
  45:          {
  46:              /*
  47:               * Id: OLT_01 Id-Frame-Slot-Port-OnuID
  48:               * FN    SN   PN   ONTID
  49:               * 
  50:               * Dev: olt id
  51:               * Board: FN SN
  52:               * Port: FN SN PN
  53:               * Ont: FN SN PN ONTID
  54:               * 
  55:               * /// FN INTEGER 0-255 Indicates the subrack ID of the OLT. 
  56:               * /// SN INTEGER 0-35 Indicates the slot ID of the OLT. 
  57:               * /// PN INTEGER 0-63 Indicates the port ID of the OLT. 
  58:               * /// 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. 
  59:               */
  60:   
  61:              string id;//, ponId;
  62:   
  63:              //if (oltId > 0 && fn >= 0 && fn <= 255 && sn >= 0 && sn <= 35 && pn >= 0 && pn <= 63 && ontSystemId >= 0 && ontSystemId <= 255)
  64:              //{
  65:              // In our NGN network the missing RACK in EMS is 0, FN is always 0, and ontSystemId has max 2 digits
  66:   
  67:              //if (fn == 0 && ontSystemId <= 99)
  68:              //{
  69:              id = Ia.Ngn.Cl.Model.Business.Default.OntId(ponId, ontSystemId);
  70:              //}
  71:              //else
  72:              //{
  73:              //throw new System.ArgumentOutOfRangeException("fn, sn, pn, ontId", "fn, sn, pn, or ontId is out of range");
  74:              //}
  75:              //}
  76:              //else
  77:              //{
  78:              //throw new System.ArgumentOutOfRangeException("fn, sn, pn, ontId", "fn, sn, pn, or ontId is out of range");
  79:              //}
  80:   
  81:              return id;
  82:          }
  83:   
  84:          ////////////////////////////////////////////////////////////////////////////
  85:   
  86:          /// <summary>
  87:          /// 
  88:          /// </summary>
  89:          public static Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType EquipmentTypeFromString(string equipmentTypeString)
  90:          {
  91:              // this will convert string format of ONU type from both email submittals and from EMSONT EQUIPMENTID values from U2000
  92:   
  93:              // select count(EQUIPMENTID), EQUIPMENTID from EmsOnts group by EQUIPMENTID
  94:              /*
  95:  Count    Type
  96:  1        5878
  97:  11593    MA5672-G4P4
  98:  102        5616
  99:  4        245H
 100:  */
 101:   
 102:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType;
 103:   
 104:              if (!string.IsNullOrEmpty(equipmentTypeString))
 105:              {
 106:                  switch (equipmentTypeString)
 107:                  {
 108:                      case "HN8245Q-2": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.HN8245Q_2; break;
 109:                      case "MA5672-4": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4; break;
 110:                      case "MA5672-G4P4": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4; break;
 111:                      case "MA5616-32": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_32; break;
 112:                      case "MA5616-48": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_48; break;
 113:                      case "MA5616-64": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64; break;
 114:                      case "MA5616-96": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_96; break;
 115:   
 116:                      // 5878 and 5616 EQUIPMENTID types unknown to me
 117:                      case "5616": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64; break; // temp
 118:                      default: equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.Undefined; break;
 119:                  }
 120:              }
 121:              else equipmentType = 0;
 122:   
 123:              return equipmentType;
 124:          }
 125:   
 126:          ////////////////////////////////////////////////////////////////////////////
 127:   
 128:          /// <summary>
 129:          /// 
 130:          /// </summary>
 131:          public static Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType FamilyTypeFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType)
 132:          {
 133:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType familyType;
 134:   
 135:              switch (equipmentType)
 136:              {
 137:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.HN8245Q_2: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu; break;
 138:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu; break;
 139:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_32: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 140:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_48: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 141:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 142:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_96: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 143:                  default: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Undefined; break;
 144:              }
 145:   
 146:              return familyType;
 147:          }
 148:   
 149:          ////////////////////////////////////////////////////////////////////////////
 150:   
 151:          /// <summary>
 152:          /// 
 153:          /// </summary>
 154:          public static string FamilyTypeStringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType)
 155:          {
 156:              string s;
 157:   
 158:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType familyType;
 159:   
 160:              familyType = FamilyTypeFromEquipmentType(equipmentType);
 161:   
 162:              s = familyType.ToString().ToUpper();
 163:   
 164:              return s;
 165:          }
 166:   
 167:          ////////////////////////////////////////////////////////////////////////////
 168:   
 169:          /// <summary>
 170:          /// 
 171:          /// </summary>
 172:          public static List<string> EquipmentTypeStringListFromFamilyType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType familyType)
 173:          {
 174:              List<string> equipmentTypeStringList;
 175:   
 176:              equipmentTypeStringList = new List<string>(10);
 177:   
 178:              switch (familyType)
 179:              {
 180:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu:
 181:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.HN8245Q_2));
 182:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4));
 183:                      break;
 184:   
 185:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu:
 186:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_32));
 187:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_48));
 188:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64));
 189:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_96));
 190:                      break;
 191:   
 192:                  default: equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.Undefined)); break;
 193:              }
 194:   
 195:              return equipmentTypeStringList;
 196:          }
 197:   
 198:          ////////////////////////////////////////////////////////////////////////////
 199:   
 200:          /// <summary>
 201:          /// 
 202:          /// </summary>
 203:          public static string StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType)
 204:          {
 205:              string equipmentTypeString;
 206:   
 207:              if (equipmentType != Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.Undefined)
 208:              {
 209:                  switch (equipmentType)
 210:                  {
 211:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.HN8245Q_2: equipmentTypeString = "HN8245Q-2"; break;
 212:                      //case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4: equipmentTypeString = "MA5672-4"; break;
 213:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4: equipmentTypeString = "MA5672-G4P4"; break;
 214:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_32: equipmentTypeString = "MA5616-32"; break;
 215:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_48: equipmentTypeString = "MA5616-48"; break;
 216:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64: equipmentTypeString = "5616"; break; //= "MA5616-64"; break;
 217:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_96: equipmentTypeString = "MA5616-96"; break;
 218:                      default: equipmentTypeString = string.Empty; break;
 219:                  }
 220:              }
 221:              else equipmentTypeString = string.Empty;
 222:   
 223:              return equipmentTypeString;
 224:          }
 225:   
 226:          /*
 227:          ////////////////////////////////////////////////////////////////////////////
 228:  
 229:          /// <summary>
 230:          ///
 231:          /// </summary>
 232:          public static string FamilyTypeFromId(int familyTypeId)
 233:          {
 234:              string s;
 235:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType familyType;
 236:  
 237:              familyType = (Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType)familyTypeId;
 238:  
 239:              s = familyType.ToString().ToUpper();
 240:  
 241:              return s;
 242:          }
 243:          */
 244:   
 245:          ////////////////////////////////////////////////////////////////////////////
 246:   
 247:          /// <summary>
 248:          ///
 249:          /// </summary>
 250:          public static int SpecialIntegerParameterHandling(string parameterName, string parameterValue)
 251:          {
 252:              int i;
 253:   
 254:              if (parameterName == "AUTHTIMEOUT")
 255:              {
 256:                  // AUTHTIMEOUT
 257:                  // INTEGER
 258:                  // 1 - 168 Disable
 259:                  // Indicates the timeout period of the authentication. This parameter is valid only when the AUTH parameter is set to ONCE_ON.If you do not set this parameter, the value is returned as Disable in the output information.Unit: h.
 260:   
 261:                  parameterValue = parameterValue.Replace("Disable", "0");
 262:              }
 263:              else
 264:              {
 265:   
 266:              }
 267:   
 268:              i = int.Parse(parameterValue);
 269:   
 270:              return i;
 271:          }
 272:   
 273:          ////////////////////////////////////////////////////////////////////////////
 274:   
 275:          /// <summary>
 276:          ///
 277:          /// </summary>
 278:          public static bool IsValidSerialNumber(string serialNumber)
 279:          {
 280:              bool isValid;
 281:   
 282:              if (!string.IsNullOrEmpty(serialNumber))
 283:              {
 284:                  if (serialNumber.Length == 16) //485754432D08578D
 285:                  {
 286:                      isValid = Ia.Cl.Model.Default.IsHex(serialNumber);
 287:                  }
 288:                  else isValid = false;
 289:              }
 290:              else isValid = false;
 291:   
 292:              return isValid;
 293:          }
 294:   
 295:          ////////////////////////////////////////////////////////////////////////////
 296:          ////////////////////////////////////////////////////////////////////////////
 297:      }
 298:   
 299:      ////////////////////////////////////////////////////////////////////////////
 300:      ////////////////////////////////////////////////////////////////////////////
 301:  }