| ";
//unit input name
$unitName = "unit_".$i;
//explode by '[u]'
$tlvArr = explode('[u]',$unitArr[$i]);
if(sizeof($tlvArr) <= 1 ){
echo "{$unitArr[$i]}";
continue;
}
//show Unit Name
echo "$tlvArr[0]";
echo " | ";
if($DEBUG) echo "$tlvArr[1]";
//explode by '-'
$offsetArr = explode('-',$tlvArr[1]);
$bgnOffsetArr = explode('.',$offsetArr[0]);
$bgnByte = $bgnOffsetArr[0];
$bgnBit = $bgnOffsetArr[1];
$endOffsetArr = explode('.',$offsetArr[1]);
$endByte = $endOffsetArr[0];
$endBit = $endOffsetArr[1];
$byteLen = $endByte - $bgnByte + 1;
$byteValue = substr($setValue,$bgnByte*2,$byteLen*2);
//--><-//$byteValue = strrev($byteValue);
if($DEBUG)
echo " byteValue = $byteValue";
$bitValue = '';
if($bgnBit > 0 ||$endBit < 7){
if($DEBUG) echo " $bgnBit > 0 ||$endBit < 7";
$bitValue = HexDec($byteValue);
$bitValue = DecBin($bitValue);
if($DEBUG) echo " bitValue = $bitValue";
$bitLen = $byteLen*8;//1 byte = 8 bit
$bitValue = omcStrFill($bitValue,$bitLen,'high','0');
if($DEBUG) echo " omcStrFill($bitValue,$bitLen,'high','0')";
$newBitValue='';
for($byteNum=$bgnByte;$byteNum<=$endByte;$byteNum++){
$tmpBitValue=substr($bitValue,($byteNum-$bgnByte)*8,8);
if($DEBUG) echo " $tmpBitValue=substr($bitValue,($byteNum-$bgnByte)*8,8)";
$tmpBitValue = strrev($tmpBitValue);
if($DEBUG) echo " $tmpBitValue = strrev($tmpBitValue)";
if($DEBUG) echo " bitValue = $bitValue";
$newBitValue=$newBitValue.$tmpBitValue;
}
$catBitLen = $endByte*8+$endBit - ($bgnByte*8 + $bgnBit) + 1; //1 byte = 8 bit
if($DEBUG) echo " bitValue = substr($newBitValue,$bgnBit,$catBitLen)";
$bitValue = substr($newBitValue,$bgnBit,$catBitLen);
$bitValue = strrev($bitValue);
if($DEBUG) echo " bitValue = $bitValue";
}
//explode by '[v]'
$valueArr = explode('[v]',$tlvArr[2]);
$typeAddTitleArr = explode('[t]',$valueArr[0]);
$operType = chop($typeAddTitleArr[0]);
$titleStr = chop($typeAddTitleArr[1]);
$valueArr[1] = chop($valueArr[1]);
if($DEBUG) echo " operType = $operType";
switch($operType){
case 'input'://
//explode by '-'
$defArr = explode('-',$valueArr[1]);
if($DEBUG) echo " defArr = $defArr[0],$defArr[1],$defArr[2]";
switch($defArr[0]){
case 'toDec':
if(strlen($bitValue) > 0){
$inputValue = BinDec($bitValue);
}else{
$inputValue = HexDec($byteValue);
}
break;
case 'keepDec':
$inputValue = $byteValue;
break;
case 'toHex':
echo " Error:toHex";
break;
case 'keepHex':
$inputValue = $byteValue;
break;
case 'toAscii':
$charValue = "";
if($bgnBit > 0 ||$endBit < 7){
echo " Error:toAscii";
exit(1);
}else{
$tmpLen=strlen($byteValue);
for($charCount=0;$charCount<$tmpLen;$charCount++){
$unitByte = substr($byteValue,$charCount,2);
$unitChar = chr(HexDec($unitByte)); // hex -> ascii
if($DEBUG) echo " unitChar=$unitChar";
$charValue .= $unitChar;
$charCount++;
}
$inputValue = $charValue;
$inputValue = trim($inputValue);//add by oven 2006-8-2 remvove dirty in Mozilla.
}
break;
default:
echo " Error:valueType=$defArr[0]";
break;
}
if($DEBUG)echo " inputValue = $inputValue";
switch($defArr[1]){
case 'high':
switch($defArr[2]){
case '0':
if($defArr[0] == 'toHex' || $defArr[0] == 'keepHex'){
//$inputValue = str_replace('0','',$inputValue);
}else if($defArr[0] == 'toAscii'){
for($ii=0;$ii$valueType == $nOctStr";
if($valueType == $nOctStr){
if($defArr[0] == 'toAscii'){
$inputLen = $byteLen;
}elseif($defArr[0] == 'toHex' || $defArr[0] == 'keepHex'){
$inputLen = $byteLen *2;
}else{
$inputLen = $byteLen *3;
}
echo "";
}else{
echo "";
echo "";
echo "";
echo "";
}
break;
case 'select':
if($valueType == $nOctStr){
if($bitValue != ''){
$selectValue = BinDec($bitValue);
}else{
$selectValue = HexDec($byteValue);
}
}else{
$selectValue=$byteValue;
}
if($DEBUG) echo " bitValue = $bitValue";
if($DEBUG) echo " selectValue = $selectValue";
if($DEBUG) echo " $valueType =?= $nOctStr(nOctStr)";
echo "";
break;
default: echo " Error:operType =|$operType|";
break;
}//end of switch(..)
//like:unitDef_1 = 1.0-2.0-select-keepHex-high-0 -->$tlvArr[1]-$operType-
if($operType == 'select'){ //select
if($valueType == $nOctStr){
$tempDef = $tlvArr[1].'-'.$operType.'-'.'toDec-high-0';
}else{
$tempDef = $tlvArr[1].'-'.$operType.'-'.'keepDec-high-0';
}
}else{
$tempDef = $tlvArr[1].'-'.$operType.'-'.$valueArr[1];
}
$tempDef = str_replace(" ", "", $tempDef);
$tempDef = chop($tempDef);
echo "\n ";
echo " | ";
}//end of for(..)
//parmmeter alias
/*
echo "";
echo "Alais:";
echo "";
echo " | ";
*/
echo "