<?php
/*********************************************************      
Create:
        
Function: CSU status
Invoke: header.inc  
Author: Li Long
Date: 2004-5-27

Modification:
[No.1]
Name£ºCui Ticun         
Time£º2005-5-20  
Description£ºAdd the HWaddr of E1 card
*********************************************************/  
require("../../inc/header.inc");
$helpId = "1.2.1";
?>
<script LANGUAGE="JavaScript">  
function get_fresh(flag){      
	var base_url,url,y; 
	base_url='<?php echo "$PHP_SELF?sys_id=$sys_id&backpage=$backpage";?>';
	x = document.body.scrollLeft;
	y = document.body.scrollTop;
	url=base_url+'&scroll_y='+y;
	if(flag) {
		window.location=url;
	}
    Timer = setTimeout("get_fresh(1)",10000);
}
</script>   
<?php
if($scroll_y > 0){
	echo "<body topmargin=\"5\" leftmargin=\"12\" onLoad='get_fresh(0);self.scrollBy(0,$scroll_y)'>";
}else{
	echo "<body topmargin=\"5\" leftmargin=\"12\" onLoad='get_fresh(0);'>";
}
$DEBUG = 0;
$db = $omc_db;
$dueDate = date("Y-m-d H:i:s",mktime(date("H"),date("i"),date("s")-$heatbeat_overtime,date("m"),date("d"),date("Y")));

//==test
//echo "heatbeat_overtime:$heatbeat_overtime<br>";
//$url_temp=$_SERVER["REQUEST_URI"];
//echo "This page URL:$url_temp<br>";
//echo "backpage:$backpage<br>";
/******************************8KE1 status*************************/
$sysTypeNo_1 = 150;
$sysType = "8KE1";
$sysTypeNo = omc_sys_type2code($sysType);
$sysNo = omc_sys_id_info($sys_id,sys_num);
$subSysNo = omc_sys_id_info($sys_id,subsys_num);
$sysId = $sysType."_".$sysNo."_".$subSysNo;

$sysTypeNo_2= 112;

//begin bit
$ver_bgn	=	18;	//version
$typ_bgn	=	21;	//subsys type
$ins_bgn	=	22;	//e1 installed
$inl_bgn	=   23; //e1 layer2 installed
$phy_bgn	=	24;	//e1 layer1(physical layer)
$tra_bgn	=	25;	//e1 layer2(transport layer)
$can_bgn	=	26;	//echo canceller status
$cpu_bgn	=	27;	//cpu loading
$loc_bgn	=	28;	//lock status
$fre_bgn	=	29;	//frequency
$pow_bgn	=	30;	//power card and master clock
$pra_bgn	=	31; //E1 FRAMER status
$ch_bgn		=	31; 
$att_bgn	=	39;

$HWaddr_bgn	=	17;

//subsys type
$arrayType=array(
		array('num' => '0',  'remark' => 'SS7',		'color' => '#0000FF'),
		array('num' => '1',  'remark' => 'ISDN',	'color' => '#0000FF'),
		array('num' => '2',  'remark' => 'PCR',		'color' => '#0000FF')
);

//e1 install
$arrayIns=array(
		array('num' => '0',  'remark' => '--',		'color' => '#000000'),
		array('num' => '1',  'remark' => 'Y',		'color' => '#0000FF')
);

//e1 layer1
$arrayPhy=array(
		array('num' => '0',  'remark' => 'Y',		'color' => '#0000FF'),
		array('num' => '1',  'remark' => 'N',		'color' => '#FF0000'),
		array('num' => '2',  'remark' => '--',		'color' => '#000000')
);

//e1 layer2
$arrayTra=array(
		array('num' => '0',  'remark' => 'N',		'color' => '#FF0000'),
		array('num' => '1',  'remark' => 'Y',		'color' => '#0000FF'),
		array('num' => '2',  'remark' => '--',		'color' => '#000000')
);

//echo canceller status
$arrayCan=array(
		array('num' => '0',  'remark' => '--',		'color' => '#000000'),
		array('num' => '1',  'remark' => 'Y',		'color' => '#0000FF')
);

//lock status
$arrayLock=array(
		array('num' => '0',  'remark' => 'Init',	'color' => '#0000FF'),
		array('num' => '1',  'remark' => 'Search',	'color' => '#0000FF'),
		array('num' => '2',  'remark' => 'Locked',	'color' => '#0000FF'),
		array('num' => '3',  'remark' => 'Threshold',	'color' => '#0000FF'),
		array('num' => '4',  'remark' => 'Adjust',	'color' => '#0000FF'),
		array('num' => '5',  'remark' => 'Hold over',	'color' => '#0000FF'),
		array('num' => '6',  'remark' => 'Stop At 0ppm',	'color' => '#0000FF'),
		array('num' => '7',  'remark' => 'Idle',	'color' => '#0000FF')
);

//master clock
$arrayMaster=array(
		array('num' => '0',  'remark' => 'Slave',		'color' => '#0000FF'),
		array('num' => '1',  'remark' => 'Master',		'color' => '#0000FF')
);
if($clear){
	$delSql = " Delete FROM OMC_PUB.sysStat 
			WHERE 
			(sysTypeNo='$sysTypeNo' OR sysTypeNo='$sysTypeNo_1') AND (sysNo='0' OR sysNo='1')
		  ";
	//echo "<br>delSql=$delSql";
	$delRes = @mysqli_query($pubConn,$delSql);
	echo mysqli_error($pubConn);

	$delSql = " Delete FROM OMC_PUB.sysStat 
			WHERE 
			sysTypeNo='$sysTypeNo_2'
		  ";
	//echo "<br>delSql=$delSql";
	$delRes = @mysqli_query($pubConn,$delSql);
	echo mysqli_error($pubConn);
	
	$delSql = " Delete FROM OMC_PUB.sysInfo where sysTypeNo!='500'";
	//echo "<br>delSql=$delSql";
	$delRes = @mysqli_query($pubConn,$delSql);
	echo mysqli_error($pubConn);
}


$selSql = " SELECT sysTypeNo,sysNo,subSysNo,detailStat,updateTime FROM OMC_PUB.sysStat 
			WHERE 
			(sysTypeNo='$sysTypeNo' OR sysTypeNo='$sysTypeNo_1')  AND (sysNo='0' OR sysNo='1')
		  ";
if($DEBUG) 
	echo "<br>selSql=$selSql";
$selRes = @mysqli_query($pubConn,$selSql);
$selRow = @mysqli_fetch_array($selRes);
echo mysqli_error($pubConn);

do{
    $sysTypeNo = $selRow[sysTypeNo];
	$sysNo = $selRow[sysNo];
	$subSysNo = $selRow[subSysNo];
	$hex_mes = $selRow[detailStat];
	if($DEBUG) echo "<br>hex_mes=$hex_mes";

	if(!$selRow)
		break;
	
	if($selRow)
		$showArr[$sysNo][$subSysNo] = 1;

	$refreshTime[$sysNo][$subSysNo][0] = $selRow[updateTime];
	if($refreshTime[$sysNo][$subSysNo][0] > $dueDate){
		$refreshTime[$sysNo][$subSysNo][1] = "#0000FF";
	}else{
		$refreshTime[$sysNo][$subSysNo][1] = "#FF0000";
		$noBasicStatus[$sysNo][$subSysNo]=1;
	}

	$bin_mes='';
	for($i=0;$i<strlen($hex_mes);$i++){
		$sig_hex_mes=substr($hex_mes,$i,1);
		$sig_dec_mes=HexDec($sig_hex_mes);
		$sig_bin_mes=DecBin($sig_dec_mes);
		$sig_bin_mes=omc_keep_length($sig_bin_mes,0,4);
		$bin_mes.=$sig_bin_mes;
	}
	
	if($DEBUG)echo "<br>bin_mes=$bin_mes";

	//version
	$bin_ver_0=substr($bin_mes,$ver_bgn*8,8);
	$dec_ver_0=BinDec($bin_ver_0);
	
	$bin_ver_1=substr($bin_mes,($ver_bgn+1)*8,8);
	$dec_ver_1=BinDec($bin_ver_1);
	$dec_ver_1=omc_keep_length($dec_ver_1,0,2);

	$bin_ver_2=substr($bin_mes,($ver_bgn+2)*8,8);
	$dec_ver_2=BinDec($bin_ver_2);
	$dec_ver_2=omc_keep_length($dec_ver_2,0,2);

	$versionArr[$sysNo][$subSysNo][0] = $version = $dec_ver_0.".".$dec_ver_1.".".$dec_ver_2;
	$versionArr[$sysNo][$subSysNo][1] = $color_version = "#0000FF";
	$verNum[$sysNo] = $subSysNo;
	//echo "version:$version<hr>";
	if($DEBUG) echo "<br>verNum[$sysNo]=$verNum[$sysNo]";
	if($DEBUG) 
		echo "<br>versionArr[$sysNo][$subSysNo][0]={$versionArr[$sysNo][$subSysNo][0]}";

	//subsys type
	$bin_typ = substr($bin_mes,$typ_bgn*8,8);
	$subTypeArr[$sysNo][$subSysNo][0] = $dec_typ = BinDec($bin_typ);
	if($DEBUG) echo "<br>subTypeArr[$sysNo][$subSysNo][0] = {$subTypeArr[$sysNo][$subSysNo][0]}";

	//e1 install
	for($i=0;$i<8;$i++){
		$bin_ins=substr($bin_mes,$ins_bgn*8+7-$i,1);
		$eInstallArr[$sysNo][$subSysNo][$i]=BinDec($bin_ins);
		if($DEBUG) 
		    echo "<br>eInstallArr[$sysNo][$subSysNo][$i]={$eInstallArr[$sysNo][$subSysNo][$i]}";
	}


	//e1 layer2 install
	for($i=0;$i<8;$i++)
	{
		$bin_inl=substr($bin_mes,$inl_bgn*8+7-$i,1);
		$eL2InsArr[$sysNo][$subSysNo][$i]=BinDec($bin_inl);
		if($DEBUG) 
		    echo "<br>eL2InsArr[$sysNo][$subSysNo][$i]={$eL2InsArr[$sysNo][$subSysNo][$i]}";
	}

	//e1 layer1
	for($i=0;$i<8;$i++){
		$bin_phy=substr($bin_mes,$phy_bgn*8+7-$i,1);
		$eL1StatusArr[$sysNo][$subSysNo][$i] = BinDec($bin_phy);
		if($DEBUG) 
		    echo "<br>eL1StatusArr[$sysNo][$subSysNo][$i]={$eL1StatusArr[$sysNo][$subSysNo][$i]}";
		if($eInstallArr[$sysNo][$subSysNo][$i] == 0){
			$eL1StatusArr[$sysNo][$subSysNo][$i]=2;
		}

		if($eL1StatusArr[$sysNo][$subSysNo][$i] == 1){
			$noBasicStatus[$sysNo][$subSysNo]=1;
		}
	}

	//e1 layer2
	for($i=0;$i<8;$i++) {
		$bin_tra=substr($bin_mes,$tra_bgn*8+7-$i,1);
		$eL2StatusArr[$sysNo][$subSysNo][$i]=BinDec($bin_tra);
		if($eInstallArr[$sysNo][$subSysNo][$i] == 0 || $eL2InsArr[$sysNo][$subSysNo][$i] == 0){
			$eL2StatusArr[$sysNo][$subSysNo][$i]=2;
		}
		if($DEBUG) 
		   echo "<br>eL2StatusArr[$sysNo][$subSysNo][$i]={$eL2StatusArr[$sysNo][$subSysNo][$i]}";
		if($eL2StatusArr[$sysNo][$subSysNo][$i] == 0){
			$noBasicStatus[$sysNo][$subSysNo]=1;
		}
	
	}

	//echo canceller status
	for($i=0;$i<8;$i++){
		$bin_can=substr($bin_mes,$can_bgn*8+7-$i,1);
		$canStatusArr[$sysNo][$subSysNo][$i]=BinDec($bin_can);
		if($eInstallArr[$sysNo][$subSysNo][$i] == 0){
			$canStatusArr[$sysNo][$subSysNo][$i] = 0;
		}
		if($DEBUG) echo "<br>canStatusArr[$sysNo][$subSysNo][$i]={$canStatusArr[$sysNo][$subSysNo][$i]}";
	}

	//cpu loading
	$bin_cpu=substr($bin_mes,$cpu_bgn*8,8);
	$dec_cpu=BinDec($bin_cpu);
	if($DEBUG) echo "<br>dec_cpu=$dec_cpu";

	$cpu_load=change2point($dec_cpu/126);
	if($cpu_load>100){
		$cpu_load=100;
	}
	elseif($cpu_load<0){
		$cpu_load=0;
	}
	if($DEBUG) echo "<br>cpu_load=$cpu_load";
	
	if($cpu_load>90){
		$noBasicStatus[$sysNo][$subSysNo] = 1;
		$cpuLoadArr[$sysNo][$subSysNo][1] = "#FF0000";
	}else{
		$cpuLoadArr[$sysNo][$subSysNo][1] = "#0000FF";
	}
	$cpuLoadArr[$sysNo][$subSysNo][0] = $cpu_load."%";
	$bin_loc = substr($bin_mes,$loc_bgn*8,8);
	$lockStatusArr[$sysNo][$subSysNo] = BinDec($bin_loc);
	if($DEBUG) echo "<br>lockStatusArr[$sysNo][$subSysNo]={$lockStatusArr[$sysNo][$subSysNo]}";

	//frequency
	$bin_fre=substr($bin_mes,$fre_bgn*8,8);
	$dec_fre=BinDec($bin_fre);
	$freqArr[$sysNo][$subSysNo][0] = omc_keep_length($dec_fre,0,3);
	if($dec_loc==7){
		$freqArr[$sysNo][$subSysNo][0] = '--';
		$freqArr[$sysNo][$subSysNo][1] = "#000000";
	}else{
		$freqArr[$sysNo][$subSysNo][1] = "#0000FF";
	}
	if($DEBUG) echo "<br>freqArr[$sysNo][$subSysNo][0]={$freqArr[$sysNo][$subSysNo][0]}";

	//master clock
	//echo "bin_mes:$bin_mes<br>";
	$bin_mas = substr($bin_mes,$pow_bgn*8+7,1);
	$masClockArr[$sysNo][$subSysNo] = BinDec($bin_mas);
	if($DEBUG) echo "<br>masClockArr[$sysNo][$subSysNo]=$masClockArr[$sysNo][$subSysNo]";

	if($sysTypeNo == '150')
	{
		$pcrcArr[$sysNo][$subSysNo] = 1;
		
		$chNum = $subSysNo*8;
		for($i=0;$i<8;$i++)
		{
			$chArr[$sysNo][$chNum+$i] = HexDec(substr($hex_mes,($ch_bgn+$i)*2,2));
			if($DEBUG) echo "<br>chArr[$sysNo][$chNum+$i]={$chArr[$sysNo][$chNum+$i]}";
			$attArr[$sysNo][$chNum+$i] = HexDec(substr($hex_mes,($att_bgn+$i)*2,2));
			if($DEBUG) echo "<br>attArr[$sysNo][$chNum+$i]={$attArr[$sysNo][$chNum+$i]}";
		}
	}

}while($selRow = @mysqli_fetch_array($selRes));

$selSql = " SELECT sysTypeNo,sysNo,subSysNo,detailStat,updateTime FROM OMC_PUB.sysStat 
			WHERE 
			sysTypeNo='$sysTypeNo_2'
		  ";
if($DEBUG) 
    echo "<br>selSql=$selSql";
$selRes = @mysqli_query($pubConn,$selSql);
$selRow = @mysqli_fetch_array($selRes);
echo mysqli_error($pubConn);

do{
	$sysTypeNo = $selRow[sysTypeNo];
	$sysNo = $selRow[sysNo];
	$subSysNo = $selRow[subSysNo];
	$hex_mes = $selRow[detailStat];
	if($DEBUG) echo "<br>hex_mes=$hex_mes";

	if(!$selRow)
		break;
	
	if($selRow)
		$HWaddrArr[$sysNo][$subSysNo] = substr($hex_mes,$HWaddr_bgn*2,12);
}while($selRow = @mysqli_fetch_array($selRes));


/******************************MSC status*************************/
$sysType = $DEFAULT_SYS;
$sysTypeNo = omc_sys_type2code($sysType);
$sysNo = omc_sys_id_info($sysId,sys_num);
$subSysNo = omc_sys_id_info($sysId,subsys_num);
$sysId = $sysType."_".$sysNo."_".$subSysNo;

$array_main_server_status=array(
				array('num'=> '0','remark' => $strNormal,		'color' => '#0000FF'),
				array('num'=> '1','remark' => $strRestart,		'color' => '#0000FF'),
				array('num'=> '2','remark' => $strInitialize,	'color' => '#0000FF'),
				array('num'=> '3','remark' => $strSuspend,		'color' => '#0000FF'),
				array('num'=> '4','remark' => $strStop,			'color' => '#FF0000')
);

//E1 status
$arrayDefineStatus=array(
				array('num'=> '0','remark' => 'TUP',		'color' => '#0000FF'),
				array('num'=> '1','remark' => 'ISUP',		'color' => '#0000FF'),
				array('num'=> '2','remark' => 'AIF',		'color' => '#0000FF'),
				array('num'=> '3','remark' => 'ISDN NT',	'color' => '#0000FF'),
				array('num'=> '4','remark' => 'ISDN LT',	'color' => '#0000FF'),
				array('num'=> '5','remark' => 'CI-CNF',		'color' => '#0000FF'),
				array('num'=> '6','remark' => 'CI-INT',		'color' => '#0000FF'),
				array('num'=> '7','remark' => '--',			'color' => '#FF0000')
);

//begin bit
$msc_bgn_byt=19;
if($DEBUG)echo "<br>msc_len_dec=$msc_len_dec";

$selSql = " SELECT sysNo,subSysNo,detailStat,updateTime FROM OMC_PUB.sysStat 
			WHERE 
			sysTypeNo='$sysTypeNo' AND (sysNo='0' OR sysNo='1')
		  ";
if($DEBUG)
  echo "<br>selSql=$selSql";
$selRes = @mysqli_query($pubConn,$selSql);
$selRow = @mysqli_fetch_array($selRes);
echo mysqli_error($pubConn);

do
{
	$sysNo = $selRow[sysNo];
	$subSysNo = $selRow[subSysNo];
	$hex_mes = $selRow[detailStat];
	if($DEBUG) echo "<br>hex_mes=$hex_mes";
	
	if(!$selRow)
		break;
	
	$bin_mes='';
	for($i=0;$i<strlen($hex_mes);$i++){
		$sig_hex_mes=substr($hex_mes,$i,1);
		$sig_dec_mes=HexDec($sig_hex_mes);
		$sig_bin_mes=DecBin($sig_dec_mes);
		$sig_bin_mes=omc_keep_length($sig_bin_mes,0,4);
		$bin_mes.=$sig_bin_mes;
	}
	
	if($DEBUG)echo "<br>bin_mes=$bin_mes";

	//Field01(3bytes,18-20):Version Information
	$version_0=substr($hex_mes,($msc_bgn_byt+1)*2,2);

	$version_1=substr($hex_mes,($msc_bgn_byt+2)*2,2);
	$version_1=omc_keep_length($version_1,0,2);

	$version_2=substr($hex_mes,($msc_bgn_byt+3)*2,2);
	$version_2=omc_keep_length($version_2,0,2);
	
	$mscVersionArr[$sysNo][$subSysNo]=$version_0.".".$version_1.".".$version_2;
	if($DEBUG)
	    echo "<br>mscVersionArr[$sysNo][$subSysNo]={$mscVersionArr[$sysNo][$subSysNo]}";


	//main server status£¨0/1/2/3/4=normal/restart/initialize/suspend/stop£©
	$hex_main_server_status=substr($hex_mes,($msc_bgn_byt+4)*2,2);
	$serStatArr[$sysNo][$subSysNo] = HexDec($hex_main_server_status);
	if($DEBUG)echo "<br>serStatArr[$sysNo][$subSysNo]={$serStatArr[$sysNo][$subSysNo]}";


	for($i=0;$i<128;$i++)
	{
		if($DEBUG)echo "<br>i=$i";
		$BinStatus=substr($bin_mes,($msc_bgn_byt+24)*8+$i*8,3);
		$DecStatus=BinDec($BinStatus);
		if($DEBUG)echo "<br>DecStatus=$DecStatus";

		$BinAttribute=substr($bin_mes,($msc_bgn_byt+24)*8+$i*8+3,5);
		$DecAttribute=BinDec($BinAttribute);
		if($DEBUG)echo "<br>DecAttribute=$DecAttribute";

		$arrayDefineE1[$sysNo][$subSysNo][$i][0]=$arrayDefineStatus[$DecStatus][remark];
		$arrayDefineE1[$sysNo][$subSysNo][$i][1]=$arrayDefineStatus[$DecStatus][color];
		if($arrayDefineE1[$sysNo][$subSysNo][$i][0]=='--'){
			$arrayDefineE1[$sysNo][$subSysNo][$i][2]='--';
			$arrayDefineE1[$sysNo][$subSysNo][$i][3]='#000000';
		}else{
			$arrayDefineE1[$sysNo][$subSysNo][$i][2]=$DecAttribute;
			$arrayDefineE1[$sysNo][$subSysNo][$i][3]='#0000FF';
		}
		if($DEBUG) echo "<br>arrayDefineE1[$sysNo][$subSysNo][$i][0]={$arrayDefineE1[$sysNo][$subSysNo][$i][0]}";
		if($DEBUG) echo "<br>arrayDefineE1[$sysNo][$subSysNo][$i][2]={$arrayDefineE1[$sysNo][$subSysNo][$i][2]}";
	}

}while($selRow = @mysqli_fetch_array($selRes));


?>
<base target="contents">
<?php
echo "<table border=\"0\" width=\"100%\">";
echo "<tr>";
echo "<td width=\"50%\">";
if($backpage=='overview')
	echo "Configuration > <a href=\"../../element/overview/overview.php\">Network</a> >  $strServer";
else
	echo "$strSysStatus > $strCentralOffice > MSC-CSC";
echo "</td>";
echo "<td width=\"50%\" align=\"right\" title=\"Help\">";
showHelp($helpId);
echo "</td>";
echo "</tr>";
echo "</table>";

echo "<table border=\"0\" width=100%>";  
echo "<tr>";  
echo "<td>";  
echo "<td>";
if($backpage=='overview')
	echo "<p align=\"right\"><a href=\"../../element/overview/overview.php\" target=\"contents\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
else
	echo "<p align=\"right\"><a href=\"$returnRoute\" target=\"contents\"><img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo "<a href=\"$PHP_SLEF?clear=1\" target=\"_self\"><img align=absBottom border=0 src=\"../../images/delete.gif\" width=\"14\" height=\"14\">$strClear</a>";

echo "</p>";      
echo "</td>";    
echo "</tr>";   
echo "</table>";

echo "<table border=\"0\" width=100%>";
	echo "<tr>";
		echo "<td width=49%><p align=\"center\"><font color=\"#0000FF\" size=\"2\">CSC0-8K E1/T1 Card  $strStatusInfo</font></p></td>";
		echo "<td width=2%>&nbsp;</td>";
		echo "<td width=49%><p align=\"center\"><font color=\"#0000FF\" size=\"2\">CSC1-8K E1/T1 Card $strStatusInfo</font></p></td>";
	echo "</tr>";

	//<!--		START::show csc 0 and csc 1 main status	-->
	echo "<tr>";
		//<!--			left CSC 0 status		-->
		echo "<td width=49% height=\"1\">";
			echo "<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\"  bordercolordark=\"#FFFFFF\">"; 
				echo "<tr bgcolor=\"#E6E6E6\">";
					echo "<td width=2%>ID</td>";
					echo "<td width=5%>$strBasicStatus</td>";
					echo "<td width=17%>$strRefreshTime</td>";
					echo "<td width=9%>Clock/Sync</td>";
					echo "<td width=7%>Version</td>";
					echo "<td width=9%>HWaddr</td>";
				echo "</tr>";
				for($i=0;$i<16;$i++)
				{
					$showId = omc_keep_length($i,0,2);
					echo "<tr><td>$showId</td>";
					if($showArr[0][$i]){
						echo "<td>";
						if($noBasicStatus[0][$i])
							echo "<font color=\"#FF0000\">N</font>";
						else
							echo "<font color=\"#0000FF\">Y</font>";
						echo "</td>";

						echo "<td>";
						if($showArr[0][$i])
							echo "<font color=\"{$refreshTime[0][$i][1]}\">{$refreshTime[0][$i][0]}</font>";
						echo "</td>";
					
						echo "<td>";
						echo "<font color=\"{$arrayMaster[$masClockArr[0][$i]][color]}\">{$arrayMaster[$masClockArr[0][$i]][remark]}/{$arrayLock[$lockStatusArr[0][$i]][remark]}</font>";
						echo "</td>";

						echo "<td>";
						echo "<font color=\"{$arrayLock[$lockStatusArr[0][$i]][color]}\">{$versionArr[0][$i][0]}</font>";
						echo "</td>";
						
						if($HWaddrArr[0][$i])
							echo "<td><font color=\"#0000FF\">{$HWaddrArr[0][$i][0]}{$HWaddrArr[0][$i][1]}:{$HWaddrArr[0][$i][2]}{$HWaddrArr[0][$i][3]}:{$HWaddrArr[0][$i][4]}{$HWaddrArr[0][$i][5]}:{$HWaddrArr[0][$i][6]}{$HWaddrArr[0][$i][7]}:{$HWaddrArr[0][$i][8]}{$HWaddrArr[0][$i][9]}:{$HWaddrArr[0][$i][10]}{$HWaddrArr[0][$i][11]}</font></td>";
						else
							echo "<td>--</td>";
					}else{
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
					}
					echo "</tr>";
				}		
			echo "</table>";
		echo "</td>";

		//<!--			Center space		-->
		echo "<td width=2%>&nbsp;</td>";
		
		//<!--			Right CSC 1 status		-->
		echo "<td width=49% height=\"1\">"; 
			echo "<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\"  bordercolordark=\"#FFFFFF\">"; 
				echo "<tr bgcolor=\"#E6E6E6\">";
					echo "<td width=2%>ID</td>";
					echo "<td width=5%>$strBasicStatus</td>";
					echo "<td width=17%>$strRefreshTime</td>";
					echo "<td width=9%>Clock/Sync</td>";
					echo "<td width=7%>Version</td>";
					echo "<td width=9%>HWaddr</td>";
				echo "</tr>";
				for($i=0;$i<16;$i++)
				{
					$showId = omc_keep_length($i,0,2);
					echo "<tr><td>$showId</td>";
					if($showArr[1][$i]){
						echo "<td>";
						if($noBasicStatus[1][$i])
							echo "<font color=\"#FF0000\">N</font>";
						else
							echo "<font color=\"#0000FF\">Y</font>";
						echo "</td>";

						echo "<td>";
						if($showArr[1][$i])
							echo "<font color=\"{$refreshTime[1][$i][1]}\">{$refreshTime[1][$i][0]}</font>";
						echo "</td>";
					
						echo "<td>";
						echo "<font color=\"{$arrayMaster[$masClockArr[1][$i]][color]}\">";
						echo "{$arrayMaster[$masClockArr[1][$i]][remark]}/{$arrayLock[$lockStatusArr[1][$i]][remark]}</font>";
						echo "</td>";

						echo "<td>";
						echo "<font color=\"{$arrayLock[$lockStatusArr[1][$i]][color]}\">{$versionArr[1][$i][0]}</font>";
						echo "</td>";

						if($HWaddrArr[1][$i])
							echo "<td><font color=\"#0000FF\">{$HWaddrArr[1][$i][0]}{$HWaddrArr[1][$i][1]}:{$HWaddrArr[1][$i][2]}{$HWaddrArr[1][$i][3]}:{$HWaddrArr[1][$i][4]}{$HWaddrArr[1][$i][5]}:{$HWaddrArr[1][$i][6]}{$HWaddrArr[1][$i][7]}:{$HWaddrArr[1][$i][8]}{$HWaddrArr[1][$i][9]}:{$HWaddrArr[1][$i][10]}{$HWaddrArr[1][$i][11]}</font></td>";
						else
							echo "<td>--</td>";
					}else{
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
					}
					echo "</tr>";
				}		
			echo "</table>";
		echo "</td>";
	echo "</tr>";
	//<!--		END::show csc 0 and csc 1 main status	-->

	echo "<tr>";
		echo "<td width=49%><p align=\"center\"><font color=\"#0000FF\" size=\"2\">$strPane0Status</font></p></td>";
		echo "<td width=2%>&nbsp;</td>";
		echo "<td width=49%><p align=\"center\"><font color=\"#0000FF\" size=\"2\">$strPane1Status</font></td>";
	echo "</tr>";      
    
	//<!--		START::show csc 0 and csc 1 e1 details	-->
	echo "<tr>";
		//<!--			left CSC 0 details		-->
		echo "<td width=49%>"; 
			echo "<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\"  bordercolordark=\"#FFFFFF\">"; 
				for($i=0;$i<128;$i++)
				{
					if($i % 8 == 0)
					{	
						echo "<tr bgcolor=\"#C0C0C0\">"; 
						echo "<td width=6%>Slot</td>";
						echo "<td width=6%>Port</td>";
						echo "<td width=6% title=\"Enable\">EN</td>";
						echo "<td width=6% title=\"Physical layer\">L1</td>";
						echo "<td width=6% title=\"Transport\">L2</td>";
						echo "<td width=6% title=\"Echo canceller\">EC</td>";
						echo "<td width=6% title=\"Channel\">CH</td>";
						echo "<td width=7% title=\"Port type\">TY</td>";
						echo "</tr>";
					}
					
					$slotNum = floor($i/8);
					$portNum = $i%8;
					echo "<tr>"; 
					echo "<td>$slotNum</td>";
					echo "<td>$portNum</td>";
					if($showArr[0][$slotNum]){
						echo "<td title=\"Enable\"><font color=\"{$arrayIns[$eInstallArr[0][$slotNum][$portNum]][color]}\">{$arrayIns[$eInstallArr[0][$slotNum][$portNum]][remark]}</font></td>";
						echo "<td title=\"Physical layer\"><font color=\"{$arrayPhy[$eL1StatusArr[0][$slotNum][$portNum]][color]}\">{$arrayPhy[$eL1StatusArr[0][$slotNum][$portNum]][remark]}</font></td>";
						echo "<td title=\"Physical layer\"><font color=\"{$arrayTra[$eL2StatusArr[0][$slotNum][$portNum]][color]}\">{$arrayTra[$eL2StatusArr[0][$slotNum][$portNum]][remark]}</font></td>";
						echo "<td title=\"Physical layer\"><font color=\"{$arrayCan[$canStatusArr[0][$slotNum][$portNum]][color]}\">{$arrayCan[$canStatusArr[0][$slotNum][$portNum]][remark]}</font></td>";
						//echo "<td title=\"Crc4\">--</td>";
						if(strlen($chArr[0][$i]) > 0)
							echo "<td title=\"Channel\"><font color=\"#0000FF\">{$chArr[0][$i]}</font></td>";
						elseif(isset($arrayDefineE1[0][0][$i][2]))
							echo "<td title=\"Channel\"><font color=\"{$arrayDefineE1[0][0][$i][3]}\">{$arrayDefineE1[0][0][$i][2]}</font></td>";
						else
							echo "<td>--</td>";
						
						if($attArr[0][$i] < 7 && strlen($attArr[0][$i]) > 0)
							echo "<td title=\"Port type\"><font color=\"{$arrayDefineStatus[$attArr[0][$i]][color]}\">{$arrayDefineStatus[$attArr[0][$i]][remark]}</font></td>";
						elseif(isset($arrayDefineE1[0][0][$i][0]))
							echo "<td title=\"Port type\"><font color=\"{$arrayDefineE1[0][0][$i][1]}\">{$arrayDefineE1[0][0][$i][0]}</font></td>";
						else
							echo "<td>--</td>";
					}else{
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
					}
					echo "</tr>";
				}
			echo "</table>";    
		echo "</td>";

		//<!--			Central space		-->
		echo "<td width=2%></td>";
		
		//<!--			Right CSC 1 status		-->
		echo "<td width=49%>";   
			echo "<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\" bordercolor=\"#666666\"  bordercolordark=\"#FFFFFF\">"; 
				for($i=0;$i<128;$i++){
					if($i % 8 == 0){	
						echo "<tr bgcolor=\"#C0C0C0\">"; 
						echo "<td width=6%>Slot</td>";
						echo "<td width=6%>Port</td>";
						echo "<td width=6% title=\"Enable\">EN</td>";
						echo "<td width=6% title=\"Physical layer\">L1</td>";
						echo "<td width=6% title=\"Transport\">L2</td>";
						echo "<td width=6% title=\"Echo canceller\">EC</td>";
						echo "<td width=6% title=\"Channel\">CH</td>";
						echo "<td width=7% title=\"Port type\">TY</td>";
						echo "</tr>";
					}
					
					$slotNum = floor($i/8);
					$portNum = $i%8;
					echo "<tr>"; 
					echo "<td>$slotNum</td>";
					echo "<td>$portNum</td>";
					if($showArr[1][$slotNum]){
						echo "<td title=\"Enable\"><font color=\"{$arrayIns[$eInstallArr[1][$slotNum][$portNum]][color]}\">{$arrayIns[$eInstallArr[1][$slotNum][$portNum]][remark]}</font></td>";
						echo "<td title=\"Physical layer\"><font color=\"{$arrayPhy[$eL1StatusArr[1][$slotNum][$portNum]][color]}\">{$arrayPhy[$eL1StatusArr[1][$slotNum][$portNum]][remark]}</font></td>";
						echo "<td title=\"Physical layer\"><font color=\"{$arrayTra[$eL2StatusArr[1][$slotNum][$portNum]][color]}\">{$arrayTra[$eL2StatusArr[1][$slotNum][$portNum]][remark]}</font></td>";
						echo "<td title=\"Physical layer\"><font color=\"{$arrayCan[$canStatusArr[1][$slotNum][$portNum]][color]}\">{$arrayCan[$canStatusArr[1][$slotNum][$portNum]][remark]}</font></td>";
						if(strlen($chArr[1][$i]) > 0)
							echo "<td title=\"Channel\"><font color=\"#0000FF\">{$chArr[1][$i]}</font></td>";
						elseif(isset($arrayDefineE1[1][0][$i][2]))
							echo "<td title=\"Channel\"><font color=\"{$arrayDefineE1[1][0][$i][3]}\">{$arrayDefineE1[1][0][$i][2]}</font></td>";
						else
							echo "<td>--</td>";
						
						if($attArr[1][$i] < 7 && strlen($attArr[1][$i]) > 0 )
							echo "<td title=\"Port type\"><font color=\"{$arrayDefineStatus[$attArr[1][$i]][color]}\">{$arrayDefineStatus[$attArr[1][$i]][remark]}</font></td>";
						elseif(isset($arrayDefineE1[1][0][$i][0]))
							echo "<td title=\"Port type\"><font color=\"{$arrayDefineE1[1][0][$i][1]}\">{$arrayDefineE1[1][0][$i][0]}</font></td>";
						else
							echo "<td>--</td>";
					}else{
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
						echo "<td>--</td>";
					}
					echo "</tr>";

				}
			echo "</table>";    
		echo "</td>";
	echo "</tr>";
	//<!--		END::show csc 0 and csc 1 e1 details	-->
echo "</table>";

echo "<table border=\"0\" width=100%>";  
	echo "<tr>";  
		echo "<td>";  
		echo "<p><nobr>$strRemark:&nbsp;&nbsp;";
		echo "<font color=\"#0000FF\">Y</font> = $strNormal, &nbsp; &nbsp;";
		echo "<font color=#FF0000>N</font> = $strAbnormal,&nbsp; &nbsp;-- = $strNothing.</nobr>";
		echo "</td>";     
		echo "<td>";              
		echo "<p align=\"right\"><a href=\"$returnRoute\" target=\"contents\">";
		echo "<img align=absBottom border=0 src=\"../../images/left.gif\" width=\"14\" height=\"14\">$strBack</a>";
		echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		echo "<a href=\"$PHP_SLEF?clear=1\" target=\"_self\">";
		echo "<img align=absBottom border=0 src=\"../../images/delete.gif\" width=\"14\" height=\"14\">$strClear</a>";
		echo "</p>";      
		echo "</td>";    
	echo "</tr>";   
echo "</table>";
echo "<input type=\"hidden\" name=\"backpage\" value=\"$backpage\"";
?>
</body>
</html>
