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, MA5878_16 = 7, MA5878_32 = 8, MA5878_48 = 9 };
  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:   
 119:                      case "MA5878-16": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_16; break;
 120:                      case "MA5878-32": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_32; break;
 121:                      case "MA5878-48": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_48; break;
 122:   
 123:                      default: equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.Undefined; break;
 124:                  }
 125:              }
 126:              else equipmentType = 0;
 127:   
 128:              return equipmentType;
 129:          }
 130:   
 131:          ////////////////////////////////////////////////////////////////////////////
 132:   
 133:          /// <summary>
 134:          /// 
 135:          /// </summary>
 136:          public static Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType FamilyTypeFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType)
 137:          {
 138:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType familyType;
 139:   
 140:              switch (equipmentType)
 141:              {
 142:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.HN8245Q_2: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu; break;
 143:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu; break;
 144:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_32: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 145:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_48: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 146:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 147:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_96: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 148:   
 149:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_16: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 150:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_32: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 151:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_48: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu; break;
 152:   
 153:                  default: familyType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Undefined; break;
 154:              }
 155:   
 156:              return familyType;
 157:          }
 158:   
 159:          ////////////////////////////////////////////////////////////////////////////
 160:   
 161:          /// <summary>
 162:          /// 
 163:          /// </summary>
 164:          public static Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType EquipmentTypeFromBoardPstnMainBoardVersionString(string mainBoardVersion)
 165:          {
 166:              // this will convert string format of MDU board type from board table format 
 167:              /*
 168:               * ASRB–32 pots
 169:               * ASPB—64 pots
 170:               * Main Board: H838ASPB    
 171:  IF MDU the user DEV name to read board SN and TYPE and put in Board
 172:  LST-BOARD::DEV=MDU-FNT-806-002,FN=0:CTAG::;
 173:  
 174:  
 175:     7340724 2018-10-24 11:26:42
 176:  M  CTAG COMPLD
 177:     EN=0   ENDESC=Succeeded.
 178:     blktag=1
 179:     blkcount=5
 180:     blktotal=5
 181:  
 182:  Board information of the device MDU-FNT-806-002
 183:  ---------------------------------------------------------------
 184:  DID     FN      SN      BT      BVER    BSTAT
 185:  7340724 0       0       Other   Main Board: H831CCUD     PCB           Version: H831CCUD VER C     Base     BIOS Version: 313     Software      Version: MA5616V800R015C00     CPLD         Version: (U1022)100     MAB           Version: 0000      SubBoard[0]:       PCB           Version: H831UP2A VER A       MAB           Version: 0001       SubBoard[1]:       PCB           Version: H836ASDA VER C       MAB           Version: 0001       APP           Version: 362(2014-8-7)      BIOS          Version: (U1)309      VoiceFile     Version: CHS 010       Normal
 186:  7340724 0       1       ETH     Board Name: H831EIUD     ---------------------------------------     PCB           Version: H831EIUD VER E     MAB           Version: 0001     CPLD          Version: (U8)100        Normal
 187:  7340724 0       2       ETH     Board Name: H831EIUD     ---------------------------------------     PCB           Version: H831EIUD VER E     MAB           Version: 0001     CPLD          Version: (U8)100        Normal
 188:  7340724 0       3       PSTN    Main Board: H838ASRB    ---------------------------------------    Pcb   Version: H838ASRB VER B    Mab   Version: 0000      Main CPU :     CPU   Version: (U300)STM32F103VD    APP   Version: 639(2015-1-31)    BIOS  Version: (U300)107    Normal
 189:  7340724 0       5       Other   --      Normal
 190:  ---------------------------------------------------------------
 191:  ;
 192:               */
 193:   
 194:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType;
 195:   
 196:              if (!string.IsNullOrEmpty(mainBoardVersion))
 197:              {
 198:                  switch (mainBoardVersion)
 199:                  {
 200:                      case "H838ASRB": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_32; break;
 201:                      case "H838ASPB": equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64; break;
 202:                      default: equipmentType = Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.Undefined; break;
 203:                  }
 204:              }
 205:              else equipmentType = 0;
 206:   
 207:              return equipmentType;
 208:          }
 209:   
 210:          ////////////////////////////////////////////////////////////////////////////
 211:   
 212:          /// <summary>
 213:          /// 
 214:          /// </summary>
 215:          public static string FamilyTypeStringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType)
 216:          {
 217:              string s;
 218:   
 219:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType familyType;
 220:   
 221:              familyType = FamilyTypeFromEquipmentType(equipmentType);
 222:   
 223:              s = familyType.ToString().ToUpper();
 224:   
 225:              return s;
 226:          }
 227:   
 228:          ////////////////////////////////////////////////////////////////////////////
 229:   
 230:          /// <summary>
 231:          /// 
 232:          /// </summary>
 233:          public static List<string> EquipmentTypeStringListFromFamilyType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType familyType)
 234:          {
 235:              List<string> equipmentTypeStringList;
 236:   
 237:              equipmentTypeStringList = new List<string>(10);
 238:   
 239:              switch (familyType)
 240:              {
 241:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Sfu:
 242:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.HN8245Q_2));
 243:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4));
 244:                      break;
 245:   
 246:                  case Ia.Ngn.Cl.Model.Business.Huawei.Ont.FamilyType.Mdu:
 247:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_32));
 248:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_48));
 249:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64));
 250:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_96));
 251:   
 252:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_16));
 253:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_32));
 254:                      equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_48));
 255:                      break;
 256:   
 257:                  default: equipmentTypeStringList.Add(StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.Undefined)); break;
 258:              }
 259:   
 260:              return equipmentTypeStringList;
 261:          }
 262:   
 263:          ////////////////////////////////////////////////////////////////////////////
 264:   
 265:          /// <summary>
 266:          /// 
 267:          /// </summary>
 268:          public static string StringFromEquipmentType(Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType equipmentType)
 269:          {
 270:              string equipmentTypeString;
 271:   
 272:              if (equipmentType != Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.Undefined)
 273:              {
 274:                  switch (equipmentType)
 275:                  {
 276:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.HN8245Q_2: equipmentTypeString = "HN8245Q-2"; break;
 277:                      //case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4: equipmentTypeString = "MA5672-4"; break;
 278:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5672_4: equipmentTypeString = "MA5672-G4P4"; break;
 279:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_32: equipmentTypeString = "MA5616-32"; break;
 280:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_48: equipmentTypeString = "MA5616-48"; break;
 281:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_64: equipmentTypeString = "5616"; break; //= "MA5616-64"; break;
 282:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5616_96: equipmentTypeString = "MA5616-96"; break;
 283:   
 284:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_16: equipmentTypeString = "MA5878-16"; break;
 285:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_32: equipmentTypeString = "MA5878-32"; break;
 286:                      case Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType.MA5878_48: equipmentTypeString = "MA5878-48"; break;
 287:   
 288:                      default: equipmentTypeString = string.Empty; break;
 289:                  }
 290:              }
 291:              else equipmentTypeString = string.Empty;
 292:   
 293:              return equipmentTypeString;
 294:          }
 295:   
 296:          /*
 297:          ////////////////////////////////////////////////////////////////////////////
 298:  
 299:          /// <summary>
 300:          ///
 301:          /// </summary>
 302:          public static string FamilyTypeFromId(int familyTypeId)
 303:          {
 304:              string s;
 305:              Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType familyType;
 306:  
 307:              familyType = (Ia.Ngn.Cl.Model.Business.Huawei.Ont.EquipmentType)familyTypeId;
 308:  
 309:              s = familyType.ToString().ToUpper();
 310:  
 311:              return s;
 312:          }
 313:          */
 314:   
 315:          ////////////////////////////////////////////////////////////////////////////
 316:   
 317:          /// <summary>
 318:          ///
 319:          /// </summary>
 320:          public static int SpecialIntegerParameterHandling(string parameterName, string parameterValue)
 321:          {
 322:              int i;
 323:   
 324:              if (parameterName == "AUTHTIMEOUT")
 325:              {
 326:                  // AUTHTIMEOUT
 327:                  // INTEGER
 328:                  // 1 - 168 Disable
 329:                  // 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.
 330:   
 331:                  parameterValue = parameterValue.Replace("Disable", "0");
 332:              }
 333:              else
 334:              {
 335:   
 336:              }
 337:   
 338:              i = int.Parse(parameterValue);
 339:   
 340:              return i;
 341:          }
 342:   
 343:          ////////////////////////////////////////////////////////////////////////////
 344:   
 345:          /// <summary>
 346:          ///
 347:          /// </summary>
 348:          public static bool IsValidSerialNumber(string serialNumber)
 349:          {
 350:              bool isValid;
 351:   
 352:              if (!string.IsNullOrEmpty(serialNumber))
 353:              {
 354:                  if (serialNumber.Length == 16) //485754432D08578D
 355:                  {
 356:                      isValid = Ia.Cl.Model.Default.IsHex(serialNumber);
 357:                  }
 358:                  else isValid = false;
 359:              }
 360:              else isValid = false;
 361:   
 362:              return isValid;
 363:          }
 364:   
 365:          ////////////////////////////////////////////////////////////////////////////
 366:          ////////////////////////////////////////////////////////////////////////////
 367:      }
 368:   
 369:      ////////////////////////////////////////////////////////////////////////////
 370:      ////////////////////////////////////////////////////////////////////////////
 371:  }