0)?$TEST:0; //value Type $nInteger = 2; $nOctStr = 4; $nShowsize = '40%'; function omcGetObjDb($sysTypeNo){ $dbName = 'OBJ_'.$sysTypeNo; return($dbName); } function omcGetObjTbl($sysTypeNo,$tableType){ $dbName = 'OBJ_'.$sysTypeNo; $tableName = $dbName.'.paramConf'; return($tableName); } function omcStrFill($string,$defLen,$fillWay='high',$fillChar='0'){ if(strlen($string) <= $defLen){ $fillLen=$defLen - strlen($string); for($i=0;$i<$fillLen;$i++){ if($fillWay == 'low'){ $string = $string.$fillChar; }else{ $string = $fillChar.$string; } } return($string); }else{ echo "
Error in omcStrFill:the defLen < lengh of string!!"; echo "
defLen=$defLen and string=$string!!"; exit(); } } $sysConfTable = 'OMC_PUB.sysConf'; $sysTypeNo = (isset($sysTypeNo)?$sysTypeNo:0); $pubDb ='OMC_PUB'; $paramTable = 'param_99'; $objDb = omcGetObjDb($sysTypeNo); $paramConfTable = omcGetObjTbl($sysTypeNo,paramConf); $maxLevelNum = 10; if($DEBUG) echo "
$paramConfTable
"; if($DEBUG) echo "
aliasName=$aliasName
"; //---------------------- //选择语言版本 if($language == 'eng'){ $objNameField=name_2; $objSetField=setTemplate_2 ; //语种2 }else{ $objNameField=name_1; $objSetField=setTemplate_1 ; //语种1(默认语种) } //----------------------- //=======================Get value From submit=================== if($set == 'Set') { //sort by offset for($i=1;$i<=$unitNum;$i++) { $tmpDef = ${'unitDef_'.$i}; $tmpValue = ${'unit_'.$i}; if($DEBUG) echo "
tmpDef = $tmpDef"; $defArr[$i] = $tmpDef; $tmpDefArr = explode('-',$tmpDef); $sortArr[$i] = $tmpDefArr[0]; $valueArr[$i] = $tmpValue; } $lastValue = ''; $k = 0; asort($sortArr); for(reset($sortArr); $key = key($sortArr); next($sortArr)) { if($DEBUG) echo "
sortArr[$key] = {$sortArr[$key]}"; if($DEBUG) echo "
unitValue = {$valueArr[$key]}"; $unitValue = $valueArr[$key]; if($DEBUG) echo "
defArr[$key] = {$defArr[$key]}"; $unitDefArr = explode('-',$defArr[$key]); //例:0.0-0.7-input -toDec-high-0 if(sizeof($unitDefArr) <= 1) { if($DEBUG) echo "
nothing,just a name"; continue; } $bgnOffset = $unitDefArr[0]; $endOffset = $unitDefArr[1]; $operType = $unitDefArr[2]; $valueType = $unitDefArr[3]; $fillWay = $unitDefArr[4]; $fillChar = $unitDefArr[5]; $bgnOffsetArr = explode('.',$bgnOffset); $bgnByte = $bgnOffsetArr[0]; $bgnBit = $bgnOffsetArr[1]; $endOffsetArr = explode('.',$endOffset); $endByte = $endOffsetArr[0]; $endBit = $endOffsetArr[1]; $byteLen = $endByte - $bgnByte + 1; $byteValue = ''; if($DEBUG) echo "
valueType = $valueType"; switch($valueType){ case 'toDec': if($bgnBit > 0 ||$endBit < 7){ $bitLen = $byteLen*8 - $bgnBit - (7 - $endBit) ; //1 BYTE = 8 bit $bitValue = DecBin($unitValue); if($DEBUG) echo "
bitValue = $bitValue "; $bitValue = omcStrFill($bitValue,$bitLen,$fillWay,$fillChar); if($DEBUG) echo "
omcStrFill($bitValue,$bitLen,$fillWay,$fillChar)"; $bitValueArr[$k] = $bitValue; if($DEBUG) echo "
bitValueArr[$k] = {$bitValueArr[$k]}"; if($endBit == 7){//发现这个单元结束,并没有跨byte,这时需要组成一个byte值 $bitValue = ''; for($bitNo=0; $bitNo<=$k; $bitNo++){ if($DEBUG) echo "
bitValueArr[$bitNo] = {$bitValueArr[$bitNo]}"; $bitValue = $bitValueArr[$bitNo].$bitValue; } $k=0; if($DEBUG) echo "
bitValue = $bitValue"; $byteLen = strlen($bitValue) / 8; if($DEBUG) echo "
byteLen = $byteLen"; $byteValue = BinDec($bitValue); $byteValue = DecHex($byteValue); $strLen = $byteLen*2; if($DEBUG) echo "
omcStrFill($byteValue,$strLen,$fillWay,$fillChar)"; $byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar); }else{//否则,继续组合下一个bit组 $byteValue = ''; $k++; } }else{ $byteValue = DecHex($unitValue); $strLen = $byteLen*2; $byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar); if($DEBUG) echo "
omcStrFill($byteValue,$strLen,$fillWay,$fillChar)"; } if($DEBUG) echo "
byteValue = $byteValue"; break; case 'keepDec': //echo "
Error:keepDec"; $byteValue = $unitValue - 0; break; case 'toHex': echo "
Error:toHex"; break; case 'keepHex': if($bgnBit > 0 || $endBit < 7){//这里的处理不够全面,没有对=7的进行收尾 $byteValue = $unitValue; $strLen = $byteLen; $byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar); $bitValue = DecBin(HexDec($byteValue)); $byteValue=''; $bitLen = $byteLen*8 - $bgnBit - (7 - $endBit) ; //1 BYTE = 8 bit $bitValue = omcStrFill($bitValue,$bitLen,'high','0'); if($DEBUG) echo "
bitValue = $bitValue"; $bitValueArr[$k] = $bitValue; $k++; }else{ $k=0; $byteValue = $unitValue; $strLen = $byteLen*2; $byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar); if($DEBUG) echo "
omcStrFill($byteValue,$strLen,$fillWay,$fillChar)"; } break; case 'toAscii': if($bgnBit > 0 ||$endBit < 7){ echo "
Error:toAscii"; exit(1); }else{ $tmpLen=strlen($unitValue); for($i=0;$i<$tmpLen;$i++){ $unitChar = substr($unitValue,$i,1); $decValue = ord($unitChar); //ascii -> dec $byteValue .= DecHex($decValue); if(strlen($byteValue) < 2){ $byteValue = '0'.$byteValue; } } $strLen = $byteLen*2; $byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar); } break; default: echo "Error:Unknown valueType"; break; } if($DEBUG) echo "
byteValue = $byteValue "; //--><-//$lastValue = $byteValue.$lastValue; $lastValue = $lastValue.$byteValue; } if($DEBUG) echo "
lastValue = $lastValue "; $setValue = $lastValue; { $objWhereStr =getLevelWhere($objIdStr); $updSql = "UPDATE $paramTable SET initValue = '$setValue' WHERE $objWhereStr AND instanceNo = '$instanceNo' "; mysqli_query($pubConn,$updSql); echo mysqli_error($pubConn); } echo ""; exit(); }//end of if($set == 1) //=======================Show GUI ======================== ?>
" > setValue = $setValue ,inputName = $inputName"; if($objIdStr != NULL){ $objWhereStr =getLevelWhere($objIdStr); $objSql = "SELECT $objNameField,$objSetField,valueType,length,minValue,maxValue FROM $paramConfTable WHERE $objWhereStr"; $objResult = mysqli_query($pubConn ,$objSql); $objRows = @mysqli_fetch_array($objResult); $totalLen = $objRows[length]*2; $objName = $objRows[$objNameField]; $setTemplate = $objRows[$objSetField]; $valueType = $objRows[valueType]; $minValue = $objRows[minValue]; $maxValue = $objRows[maxValue]; {//get $setValue $paramTable = 'param_99'; $paramSql = " SELECT initValue FROM $paramTable WHERE $objWhereStr AND instanceNo = '$instanceNo' "; // echo "$paramSql"; $v_Result = mysqli_query($pubConn,$paramSql); $v_Row = mysqli_fetch_array($v_Result); $setValue = $v_Row[0]; } }else{ echo "ERROR!!:oid == NULL"; exit(); } /************************************** *objName *[unit]name[u]xx.xx-yy.yy[u]input[v]toDec-fillHigh-fillChar *[unit]name[u]xx.xx-yy.yy[u]select[v]value1[opt]desc1[v]value2[opt]desc2 *[remark] ***************************************/ //explode by '[remark]' $remarkArr = explode('[remark]',$setTemplate); $remark = $remarkArr[1]; //explode by '[unit]' $unitArr = explode('[unit]',$remarkArr[0]); //show instance's name echo ""; echo ""; echo ""; echo "
"; echo "ACN  "; echo ""; echo "

$strBack"; echo "

"; //show every one unit //--><-//$setValue = strrev($setValue); echo ""; echo ""; echo ""; echo ""; echo ""; for($i=1;$i"; }//end of for(..) //parmmeter alias /* echo ""; */ echo "
ParametersValue
"; //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')"; $bitValue = strrev($bitValue); $catBitLen = $endByte*8+$endBit - ($bgnByte*8+$bgnBit) + 1; //1 byte = 8 bit if($DEBUG) echo "
bitValue = substr($bitValue,$bgnBit,$catBitLen)"; $bitValue = substr($bitValue,$bgnBit,$catBitLen); $bitValue = strrev($bitValue); if($DEBUG) echo "
bitValue = $bitValue"; } //explode by '[v]' $valueArr = explode('[v]',$tlvArr[2]); $operType = chop($valueArr[0]); $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; } 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{ $inputValue = $inputValue - 0; } break; case 'E': echo "Error:high fill E"; break; default: break; } break; case 'low': if ("toAscii" != $defArr[0]) { switch($defArr[2]){ case '0': $inputValue = str_replace('00','',$inputValue); break; case 'E': $inputValue = str_replace('E','',$inputValue); break; default: break; } } break; default: break; } if($DEBUG) echo "
$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 ""; echo ""; }else{ //echo ""; 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 "";*/ $isSelected = 0; for($j=1;$jReserved Value";*/ echo "Reserved Value"; break; }elseif($defArr[0] == $selectValue){ /* echo "";*/ echo "$defArr[1]"; //echo "$defArr[0]"; $isSelected = 1; }/*else{ // echo ""; echo "$defArr[1]"; $defArr[1]; }*/ } if($isSelected ==0 && $j == sizeof($valueArr)){ echo ""; } 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 "
"; echo "Alais:"; echo ""; echo "
"; $unitNum = $i-1; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; //echo "\n"; $remark=nl2br($remark); //echo "

Remarks:
$remark

"; echo "
"; //=======================Test input field======================== if($TEST){ echo "
"; echo "
"; //--><--// $setValue = strrev($setValue); echo "Test Area
"; echo "Test Value:   "; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
"; } ?>