init web ems all
This commit is contained in:
735
wxc2_omc/configuration/tabParamConfiguration/handleOpaquePara.php
Executable file
735
wxc2_omc/configuration/tabParamConfiguration/handleOpaquePara.php
Executable file
@@ -0,0 +1,735 @@
|
||||
<?php
|
||||
/*********************************************************
|
||||
<20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>:
|
||||
<20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ֶ<EFBFBD>opaque<75><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺͱ<C4BA><CDB1><EFBFBD>
|
||||
|
||||
<20><><EFBFBD>ù<EFBFBD>ϵ:<3A><><EFBFBD><EFBFBD>: header.inc
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
|
||||
<20><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>:
|
||||
|
||||
<20><><EFBFBD><EFBFBD>ֵ:
|
||||
|
||||
<20><><EFBFBD><EFBFBD>:
|
||||
|
||||
<EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD>:
|
||||
NO.1
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
ʱ<EFBFBD><EFBFBD>:
|
||||
<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>:
|
||||
*********************************************************/
|
||||
require("../../inc/header.inc");
|
||||
$DEBUG = 0;
|
||||
|
||||
function getNameByOID_handle($sysTypeNo,$oidwhere)
|
||||
{
|
||||
$tb="OBJ_".$sysTypeNo.".paramConf";
|
||||
$sqlstr="select name_2 from $tb where $oidwhere";
|
||||
$res = @mysqli_query($objDbConn,$sqlstr);
|
||||
$row = @mysqli_fetch_array($res);
|
||||
return $row[name_2];
|
||||
}
|
||||
$canwrite_flag=checkWritePrivilege();
|
||||
|
||||
$settedColor ="blue";
|
||||
$notSettedColor ="#008000";
|
||||
$inputBkgrdColor = "#E7FEFD";
|
||||
$saveBkgrdColor ="#F3F77D";
|
||||
$waitingBkgrdColor = "red";
|
||||
$sysId=$_REQUEST['sysId'];
|
||||
$oidStr=$_REQUEST['oidStr'];
|
||||
$instanceNo=$_REQUEST['instanceNo'];
|
||||
$spanId=$_REQUEST['spanId'];
|
||||
$unitNum=$_REQUEST['unitNum'];
|
||||
$sysIdArr = explode('_',$sysId);
|
||||
$sysTypeNo = $sysIdArr[0];
|
||||
$sysNo = $sysIdArr[1];
|
||||
$subSysNo = $sysIdArr[2];
|
||||
$objDb = 'OBJ_'.$sysTypeNo;
|
||||
$objDbConn = mysqli_connect($OMC_server[0]['host'],$OMC_server[0]['user'],$OMC_server[0]['password'],$objDb);
|
||||
|
||||
$paraConfTable = $objDb.'.paramConf';
|
||||
|
||||
if(checkIndependSystem($sysTypeNo))//Plat
|
||||
$paraTable=$objDb.".param_".$sysNo;
|
||||
else
|
||||
$paraTable=$objDb.".param_99";
|
||||
|
||||
$levelWhere=getLevelWhere($oidStr);
|
||||
$paraSql="SELECT * FROM $paraTable WHERE $levelWhere AND instanceNo=$instanceNo";
|
||||
if(0)
|
||||
echo "<br>paraSql=$paraSql";
|
||||
$paraResult=mysqli_query($objDbConn,$paraSql);
|
||||
$paraRows=@mysqli_fetch_array($paraResult);
|
||||
|
||||
$setValue=$paraRows['initValue'];
|
||||
$readValue=$paraRows['readValue'];
|
||||
if($DEBUG)
|
||||
echo "<br>setValue=$setValue";
|
||||
|
||||
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 "<br>Error in omcStrFill:the defLen < lengh of string!!";
|
||||
echo "<br>defLen=$defLen and string=$string!!";
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------
|
||||
//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD>汾
|
||||
if($language == 'eng'){
|
||||
$objNameField='name_2';
|
||||
$objSetField='setTemplate_2' ; //<2F><><EFBFBD><EFBFBD>2
|
||||
}else{
|
||||
$objNameField='name_1';
|
||||
$objSetField='setTemplate_1' ; //<2F><><EFBFBD><EFBFBD>1(Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
}
|
||||
//-----------------------
|
||||
|
||||
//=======================Get value From submit===================
|
||||
$set=$_POST['set'];
|
||||
if($set == 'Set'){
|
||||
//sort by offset
|
||||
$unitNum = $_POST['unitNum'];
|
||||
echo"unitNum=$unitNum";
|
||||
for($i=1;$i<=$unitNum;$i++){
|
||||
//$tmpDef = ${'unitDef_'.$i};
|
||||
$tmpDef = $_POST['unitDef_'.$i];
|
||||
$tmpValue = $_POST['unit_'.$i];
|
||||
|
||||
//$tmpValue = ${'unit_'.$i};
|
||||
if($DEBUG) echo "<br>tmpDef = $tmpDef";
|
||||
$defArr[$i] = $tmpDef;
|
||||
$tmpDefArr=explode('-',$tmpDef);
|
||||
$sortArr[$i] = $tmpDefArr[0];
|
||||
$valueArr[$i] = $tmpValue;
|
||||
}
|
||||
echo "tmpDef=$tmpDef<br>";
|
||||
|
||||
$lastValue = '';
|
||||
$k = 0;
|
||||
asort($sortArr);
|
||||
for(reset($sortArr); $key = key($sortArr); next($sortArr)){
|
||||
if($DEBUG) echo "<br>sortArr[$key] = {$sortArr[$key]}";
|
||||
if($DEBUG) echo "<br>unitValue = {$valueArr[$key]}";
|
||||
$unitValue = $valueArr[$key];
|
||||
if($DEBUG) echo "<br>defArr[$key] = {$defArr[$key]}";
|
||||
$unitDefArr = explode('-',$defArr[$key]); //<2F><>:0.0-0.7-input -toDec-high-0
|
||||
if(sizeof($unitDefArr) <= 1){
|
||||
if($DEBUG) echo "<br>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 "<br>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 "<br>bitValue = $bitValue ";
|
||||
$bitValue = omcStrFill($bitValue,$bitLen,$fillWay,$fillChar);
|
||||
if($DEBUG) echo "<br>omcStrFill($bitValue,$bitLen,$fillWay,$fillChar)";
|
||||
$bitValueArr[$k] = $bitValue;
|
||||
if($DEBUG) echo "<br>bitValueArr[$k] = {$bitValueArr[$k]}";
|
||||
if($endBit == 7){//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>п<EFBFBD>byte<74><65><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>byteֵ
|
||||
$bitValue = '';
|
||||
for($bitNo=0; $bitNo<=$k; $bitNo++){
|
||||
if($DEBUG) echo "<br>bitValueArr[$bitNo] = {$bitValueArr[$bitNo]}";
|
||||
$bitValue = $bitValueArr[$bitNo].$bitValue;
|
||||
}
|
||||
$k=0;
|
||||
if($DEBUG) echo "<br>bitValue = $bitValue";
|
||||
$byteLen = strlen($bitValue) / 8;
|
||||
if($DEBUG) echo "<br>byteLen = $byteLen";
|
||||
$byteValue = BinDec($bitValue);
|
||||
$byteValue = DecHex($byteValue);
|
||||
$strLen = $byteLen*2;
|
||||
if($DEBUG) echo "<br>omcStrFill($byteValue,$strLen,$fillWay,$fillChar)";
|
||||
$byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar);
|
||||
}else{//<2F><><EFBFBD><EFBFBD><F2A3ACBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>bit<69><74>
|
||||
$byteValue = '';
|
||||
$k++;
|
||||
}
|
||||
}else{
|
||||
$byteValue = DecHex($unitValue);
|
||||
$strLen = $byteLen*2;
|
||||
$byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar);
|
||||
if($DEBUG) echo "<br>omcStrFill($byteValue,$strLen,$fillWay,$fillChar)";
|
||||
}
|
||||
if($DEBUG) echo "<br>byteValue = $byteValue";
|
||||
break;
|
||||
case 'keepDec':
|
||||
//echo "<br>Error:keepDec";
|
||||
$byteValue = $unitValue - 0;
|
||||
break;
|
||||
case 'toHex':
|
||||
echo "<br>Error:toHex";
|
||||
break;
|
||||
case 'keepHex':
|
||||
if($bgnBit > 0 || $endBit < 7){//<2F><><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>,û<>ж<EFBFBD>=7<>Ľ<EFBFBD><C4BD><EFBFBD><EFBFBD><EFBFBD>β
|
||||
$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 "<br>bitValue = $bitValue";
|
||||
$bitValueArr[$k] = $bitValue;
|
||||
$k++;
|
||||
}else{
|
||||
$k=0;
|
||||
$byteValue = $unitValue;
|
||||
$strLen = $byteLen*2;
|
||||
$byteValue = omcStrFill($byteValue,$strLen,$fillWay,$fillChar);
|
||||
if($DEBUG) echo "<br>omcStrFill($byteValue,$strLen,$fillWay,$fillChar)";
|
||||
}
|
||||
break;
|
||||
case 'toAscii':
|
||||
if($bgnBit > 0 ||$endBit < 7){
|
||||
echo "<br>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;
|
||||
case 'toLatitude':
|
||||
//feake show 4byte
|
||||
if($unitValue>90)
|
||||
{
|
||||
$unitValue=90;
|
||||
/**************************************************/
|
||||
echo "\n<script language=\"JavaScript\">\n";
|
||||
echo "alert('The value must be -90.00 to 90.00');\n";
|
||||
echo "</script>\n";
|
||||
/***************************************************/
|
||||
}
|
||||
if($unitValue<-90)
|
||||
{
|
||||
$unitValue=-90;
|
||||
/**************************************************/
|
||||
echo "\n<script language=\"JavaScript\">\n";
|
||||
echo "alert('The value must be -90.00 to 90.00');\n";
|
||||
echo "</script>\n";
|
||||
/***************************************************/
|
||||
}
|
||||
$byteValue=$unitValue*pow(2,23)/90;
|
||||
$byteValue=ceil($byteValue);
|
||||
$byteValue=dechex($byteValue);
|
||||
$byteValue=omcStrFill($byteValue,8,'high','0');
|
||||
break;
|
||||
case 'toLongitude':
|
||||
if($unitValue>180)
|
||||
{
|
||||
$unitValue=180;
|
||||
/**************************************************/
|
||||
echo "\n<script language=\"JavaScript\">\n";
|
||||
echo "alert('The value must be -180.00 to 180.00');\n";
|
||||
echo "</script>\n";
|
||||
/***************************************************/
|
||||
}
|
||||
if($unitValue<-180)
|
||||
{
|
||||
$unitValue=-180;
|
||||
/**************************************************/
|
||||
echo "\n<script language=\"JavaScript\">\n";
|
||||
echo "alert('The value must be -180.00 to 180.00');\n";
|
||||
echo "</script>\n";
|
||||
/***************************************************/
|
||||
}
|
||||
$byteValue=$unitValue*pow(2,24)/360;
|
||||
$byteValue=ceil($byteValue);
|
||||
$byteValue=dechex($byteValue);
|
||||
$byteValue=omcStrFill($byteValue,8,'high','0');
|
||||
break;
|
||||
default:
|
||||
echo "Error:Unknown valueType";
|
||||
break;
|
||||
}
|
||||
if($DEBUG) echo "<br>byteValue = $byteValue ";
|
||||
//--><-//$lastValue = $byteValue.$lastValue;
|
||||
$lastValue = $lastValue.$byteValue;
|
||||
}
|
||||
$lastValue=strtoupper($lastValue);
|
||||
if($DEBUG) echo "<br>lastValue = $lastValue ";
|
||||
$updateSql="UPDATE $paraTable SET initValue='$lastValue' WHERE $levelWhere AND instanceNo=$instanceNo";
|
||||
if($DEBUG)echo "<br>updateSql=$updateSql";
|
||||
mysqli_query($objDbConn,$updateSql);
|
||||
|
||||
|
||||
|
||||
if($lastValue==$readValue)
|
||||
{
|
||||
$returnColor= $settedColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
$returnColor= $notSettedColor;
|
||||
|
||||
$oidwhere=getLevelWhere(substr($oidStr,0,strlen($oidStr)-2));
|
||||
$tableName=getNameByOID_handle($sysTypeNo,$oidwhere);
|
||||
$tableName=str_replace("Entry","",$tableName);
|
||||
$sysName=getSystemNameBySysTypeNo($sysTypeNo);
|
||||
|
||||
$fieldName=getNameByOID_handle($sysTypeNo,$levelWhere);
|
||||
$log="Change $sysName $tableName's $fieldName, ".$readValue." -> ".$lastValue;
|
||||
|
||||
insertLog($log);
|
||||
//$handle=fopen("/tmp/test.txt","a");
|
||||
//fwrite($handle,$log);
|
||||
//fwrite($handle,"\n");
|
||||
//fclose($handle);
|
||||
}
|
||||
if(!$DEBUG){
|
||||
echo "tmpDef=$tmpDef";
|
||||
//discard the postfix E
|
||||
if(strstr($tmpDef,"keepHex-low"))
|
||||
{
|
||||
$oidwhere=getLevelWhere($oidStr);
|
||||
echo"$oidwhere<br>";
|
||||
|
||||
$sql="select setTemplate_2 from OBJ_$sysTypeNo.paramConf where $oidwhere ";
|
||||
echo"<br>$sql";
|
||||
$res=@mysqli_query($objDbConn,$sql);
|
||||
$row=@mysqli_fetch_array($res);
|
||||
$split=explode("[unit]",$row[0]);
|
||||
$tmplen=sizeof($split);
|
||||
//only one unit
|
||||
//if($tmplen == 2)
|
||||
{
|
||||
$split2=explode("keepHex-low-",$row[0]);
|
||||
$repl=substr($split2[1],0,1);
|
||||
$lastValue=str_replace($repl," ",$lastValue);
|
||||
}
|
||||
}
|
||||
if(strlen(trim($lastValue))<=0)
|
||||
$lastValue="--";
|
||||
|
||||
echo "<script LANGUAGE=\"JavaScript\">";
|
||||
$innerHTML="<a style=\'color:$returnColor\'>$lastValue</a>";
|
||||
echo "\n window.opener.document.getElementById('$spanId').innerHTML='$innerHTML';";
|
||||
if($DEBUG) exit();
|
||||
echo "\n window.opener.document.getElementById('$spanId').focus();";
|
||||
echo "\n window.close();";
|
||||
echo "\n </script>";
|
||||
exit();
|
||||
}else{
|
||||
echo "<br>lastValue = $lastValue ";
|
||||
}
|
||||
}//end of if($set == 1)
|
||||
|
||||
//=======================Show GUI ========================
|
||||
?>
|
||||
<body>
|
||||
<script LANGUAGE="JavaScript">
|
||||
function checkInt(term){
|
||||
var checkOK = "0123456789";
|
||||
var checkStr = term.value;
|
||||
var allValid = true;
|
||||
var termName = term.name;
|
||||
var minValue = eval("document.confForm."+termName+"_min.value");
|
||||
var maxValue = eval("document.confForm."+termName+"_max.value");
|
||||
var oldValue = eval("document.confForm."+termName+"_old.value");
|
||||
//alert(minValue+'<'+term.value+'<'+maxValue);
|
||||
for (i = 0; i < checkStr.length; i++){
|
||||
ch = checkStr.charAt(i);
|
||||
for (j = 0; j < checkOK.length; j++){
|
||||
if (ch == checkOK.charAt(j))
|
||||
break;
|
||||
}
|
||||
if (j == checkOK.length){
|
||||
allValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!allValid){
|
||||
var errAlert="parameter Must be a dec number!";
|
||||
alert(errAlert);
|
||||
term.value=oldValue;
|
||||
term.focus();
|
||||
return (false);
|
||||
}
|
||||
|
||||
if((minValue - term.value) > 0){
|
||||
var errAlert="Too little!";
|
||||
alert(errAlert);
|
||||
term.value=oldValue;
|
||||
term.focus();
|
||||
return (false);
|
||||
}
|
||||
if((term.value - maxValue) > 0){
|
||||
var errAlert="Too Big!";
|
||||
alert(errAlert);
|
||||
term.value=oldValue;
|
||||
term.focus();
|
||||
return (false);
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<form method="POST" name="confForm" action="<?php echo"$PHP_SELF";?>" >
|
||||
<?php
|
||||
$objSql = "SELECT $objNameField,$objSetField,valueType,minValue,`maxValue` FROM $paraConfTable WHERE $levelWhere";
|
||||
if(0)
|
||||
echo "objSql=$objSql";
|
||||
$objResult = mysqli_query($objDbConn ,$objSql);
|
||||
$objRows = @mysqli_fetch_array($objResult);
|
||||
$objName = $objRows[$objNameField];
|
||||
$setTemplate = $objRows[$objSetField];
|
||||
$valueType = $objRows[valueType];
|
||||
$minValue = $objRows[minValue];
|
||||
$maxValue = $objRows[maxValue];
|
||||
|
||||
/**************************************
|
||||
*[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]);
|
||||
// echo "<pre>";
|
||||
// echo print_r( $unitArr);
|
||||
// echo "</pre>";
|
||||
//echo sizeof( $unitArr);
|
||||
|
||||
//show every one unit
|
||||
//$setValue = strrev($setValue);
|
||||
if($DEBUG){
|
||||
echo "<table border=\"1\" cellpadding=\"0\" cellspacing=\"2\" width=\"100%\">";
|
||||
}else{
|
||||
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\" width=\"100%\">";
|
||||
}
|
||||
|
||||
for($i=1;$i<sizeof($unitArr);$i++){
|
||||
echo "\n <tr><td width=\"10%\" valign=middle><nobr>";
|
||||
//unit input name
|
||||
$unitName = "unit_".$i;
|
||||
|
||||
//explode by '[u]'
|
||||
$tlvArr = explode('[u]',$unitArr[$i]);
|
||||
if(sizeof($tlvArr) <= 1 ){
|
||||
echo "<u><b>{$unitArr[$i]}</b></u>";
|
||||
continue;
|
||||
}
|
||||
|
||||
//show Unit Name
|
||||
echo "$tlvArr[0]";
|
||||
echo " </nobr></td><td>";
|
||||
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 "<br>byteValue = $byteValue";
|
||||
$bitValue = '';
|
||||
if($bgnBit > 0 ||$endBit < 7){
|
||||
if($DEBUG) echo "<br>$bgnBit > 0 ||$endBit < 7";
|
||||
$bitValue = HexDec($byteValue);
|
||||
$bitValue = DecBin($bitValue);
|
||||
if($DEBUG) echo "<br>bitValue = $bitValue";
|
||||
$bitLen = $byteLen*8;//1 byte = 8 bit
|
||||
$bitValue = omcStrFill($bitValue,$bitLen,'high','0');
|
||||
if($DEBUG) echo "<br>omcStrFill($bitValue,$bitLen,'high','0')";
|
||||
|
||||
$bitValue = strrev($bitValue);
|
||||
$catBitLen = $endByte*8+$endBit - ($bgnByte*8+$bgnBit) + 1; //1 byte = 8 bit
|
||||
if($DEBUG) echo "<br>bitValue = substr($bitValue,$bgnBit,$catBitLen)";
|
||||
$bitValue = substr($bitValue,$bgnBit,$catBitLen);
|
||||
$bitValue = strrev($bitValue);
|
||||
if($DEBUG) echo "<br>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 "<br>operType = $operType";
|
||||
switch($operType){
|
||||
case 'input'://
|
||||
//explode by '-'
|
||||
$defArr = explode('-',$valueArr[1]);
|
||||
if($DEBUG) echo "<br>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 "<br>Error:toHex";
|
||||
break;
|
||||
case 'keepHex':
|
||||
$inputValue = $byteValue;
|
||||
break;
|
||||
case 'toAscii':
|
||||
$charValue = "";
|
||||
if($bgnBit > 0 ||$endBit < 7){
|
||||
echo "<br>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 "<br>unitChar=$unitChar";
|
||||
$charValue .= $unitChar;
|
||||
$charCount++;
|
||||
}
|
||||
$inputValue = $charValue;
|
||||
$inputValue = trim($inputValue);//add by oven 2006-8-2 remvove dirty in Mozilla.
|
||||
}
|
||||
break;
|
||||
case 'toLatitude':
|
||||
//feake edit float
|
||||
if($byteValue[0]=='F' || $byteValue[0]=='f')
|
||||
{
|
||||
$tmp=hexdec($byteValue)-1;
|
||||
$orgbin=decbin($tmp);
|
||||
$lastbin="";
|
||||
for($ii=0;$ii<strlen($orgbin);$ii++)
|
||||
{
|
||||
if($orgbin[$ii] == '0')
|
||||
$lastbin=$lastbin."1";
|
||||
else
|
||||
$lastbin=$lastbin."0";
|
||||
}
|
||||
$last=bindec($lastbin);
|
||||
$last=-$last;
|
||||
}
|
||||
else
|
||||
$last=hexdec($byteValue);
|
||||
$inputValue=$last*90/pow(2,23);
|
||||
if(strlen($inputValue)>8)
|
||||
$inputValue=substr($inputValue,0,8);
|
||||
|
||||
if($inputValue > 90 || $inputValue < -90)
|
||||
{
|
||||
/**************************************************/
|
||||
echo "\n<script language=\"JavaScript\">\n";
|
||||
echo "alert('The value must be -90.00 to 90.00');\n";
|
||||
echo "</script>\n";
|
||||
/***************************************************/
|
||||
}
|
||||
break;
|
||||
case 'toLongitude':
|
||||
if($byteValue[0]=='F' || $byteValue[0]=='f')
|
||||
{
|
||||
$tmp=hexdec($byteValue)-1;
|
||||
$orgbin=decbin($tmp);
|
||||
$lastbin="";
|
||||
for($ii=0;$ii<strlen($orgbin);$ii++)
|
||||
{
|
||||
if($orgbin[$ii] == '0')
|
||||
$lastbin=$lastbin."1";
|
||||
else
|
||||
$lastbin=$lastbin."0";
|
||||
}
|
||||
$last=bindec($lastbin);
|
||||
$last=-$last;
|
||||
}
|
||||
else
|
||||
$last=hexdec($byteValue);
|
||||
$inputValue=$last*360/pow(2,24);
|
||||
if(strlen($inputValue)>8)
|
||||
$inputValue=substr($inputValue,0,8);
|
||||
|
||||
if($inputValue > 180 || $inputValue < -180)
|
||||
{
|
||||
/**************************************************/
|
||||
echo "\n<script language=\"JavaScript\">\n";
|
||||
echo "alert('The value must be -180.00 to 180.00');\n";
|
||||
echo "</script>\n";
|
||||
/***************************************************/
|
||||
}
|
||||
break;
|
||||
default:
|
||||
echo "<br>Error:valueType=$defArr[0]";
|
||||
break;
|
||||
}
|
||||
if($DEBUG)echo "<br>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<strlen($inputValue);$ii++){
|
||||
if($inputValue[$ii]=='0')
|
||||
$inputValue[$ii]='';
|
||||
else
|
||||
break;
|
||||
}
|
||||
}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($defArr[0] == 'toAscii'){
|
||||
$inputLen = $byteLen;
|
||||
}elseif($defArr[0] == 'toHex' || $defArr[0] == 'keepHex'){
|
||||
$inputLen = $byteLen *2;
|
||||
}else{
|
||||
$inputLen = $byteLen *3;
|
||||
}
|
||||
$size=$byteLen*3;
|
||||
if($defArr[0] == 'toHex' || $defArr[0] == 'keepHex')
|
||||
echo "<input type=\"text\" size=\"$size\" maxLength =\"$inputLen\" name=\"$unitName\" value=\"$inputValue\" class=\"text\">";
|
||||
else
|
||||
echo "<input type=\"text\" size=\"$inputLen\" maxLength =\"$inputLen\" name=\"$unitName\" value=\"$inputValue\" class=\"text\">";
|
||||
|
||||
break;
|
||||
case 'select':
|
||||
if($bitValue != ''){
|
||||
$selectValue = BinDec($bitValue);
|
||||
}else{
|
||||
$selectValue = HexDec($byteValue);
|
||||
}
|
||||
|
||||
if($DEBUG)
|
||||
echo "<br>bitValue = $bitValue";
|
||||
if($DEBUG) echo "<br>selectValue = $selectValue";
|
||||
|
||||
echo "<select size=\"1\" name=\"$unitName\">";
|
||||
$isSelected = 0;
|
||||
for($j=1;$j<sizeof($valueArr);$j++){
|
||||
//explode by '[opt]'
|
||||
$defArr = explode('[opt]',$valueArr[$j]);
|
||||
if(sizeof($defArr) < 2){
|
||||
echo "<option value=\"$selectValue\" selected>Reserved Value</option>";
|
||||
break;
|
||||
}elseif($defArr[0] == $selectValue){
|
||||
echo "<option value=\"$defArr[0]\" selected>$defArr[1]</option>";
|
||||
$isSelected = 1;
|
||||
}else{
|
||||
echo "<option value=\"$defArr[0]\">$defArr[1]</option>";
|
||||
}
|
||||
}
|
||||
|
||||
if($isSelected ==0 && $j == sizeof($valueArr)){
|
||||
echo "<option value=\"$selectValue\" selected>Undefined Value</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
break;
|
||||
default: echo "<br>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
|
||||
$tempDef = $tlvArr[1].'-'.$operType.'-'.'toDec-high-0';
|
||||
}else{
|
||||
$tempDef = $tlvArr[1].'-'.$operType.'-'.$valueArr[1];
|
||||
}
|
||||
$tempDef = str_replace(" ", "", $tempDef);
|
||||
$tempDef = chop($tempDef);
|
||||
echo "\n <input type=\"hidden\" name=\"unitDef_$i\" value=\"$tempDef\">";
|
||||
echo "</td></tr>";
|
||||
}//end of for(..)
|
||||
|
||||
echo "</table>";
|
||||
|
||||
$remark=nl2br($remark);
|
||||
echo "<br><b>Remarks:</b><br>$remark<br><br>";
|
||||
$unitNum = $i-1;
|
||||
echo "\n<input type=\"hidden\" name=\"unitNum\" value=\"$unitNum\">";
|
||||
echo "\n<input type=\"hidden\" name=\"sysId\" value=\"$sysId\">";
|
||||
echo "\n<input type=\"hidden\" name=\"oidStr\" value=\"$oidStr\">";
|
||||
echo "\n<input type=\"hidden\" name=\"instanceNo\" value=\"$instanceNo\">";
|
||||
echo "\n<input type=\"hidden\" name=\"spanId\" value=\"$spanId\">";
|
||||
|
||||
if($canwrite_flag)
|
||||
{
|
||||
echo "\n<input type=\"submit\" name=\"set\" value = \"Set\">";
|
||||
echo "\n<input type=\"reset\" name=\"Reset\" value =\"Reset\">";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "\n<input type=\"submit\" disabled name=\"set\" value = \"Set\">";
|
||||
echo "\n<input type=\"reset\" disabled name=\"Reset\" value =\"Reset\">";
|
||||
}
|
||||
echo "</Form>";
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user