コード例 #1
0
 /**
  * 数字地址转换为地址名称
  *
  * @param array $add array("A"=>array(),"B"=>array())
  * @param string $No 表架编号 例如:GN01
  * @param int $xNum  横向表位个数
  * @param int $yNum  纵向表位个数
  * @return array
  */
 public static function NumberToName($adds, $No, $xNum, $yNum)
 {
     $A = array();
     $B = array();
     //A
     for ($i = 0; $i < sizeof($adds["A"]); $i++) {
         $add = $adds["A"][$i];
         $place = $No . AddressCover::singleNumToName($add, "A", $xNum, $yNum);
         array_push($A, $place);
     }
     //B
     for ($i = 0; $i < sizeof($adds["B"]); $i++) {
         $add = $adds["A"][$i];
         $place = $No . AddressCover::singleNumToName($add, "B", $xNum, $yNum);
         array_push($B, $place);
     }
     $rtn["A"] = $A;
     $rtn["B"] = $B;
     return $rtn;
 }
コード例 #2
0
 /**
  * 查询以表架已经使用的表位
  * 参  数:表架
  * 返回值: Example: array(1=>array("A"=>"Y","B"="N"),2=>array("A"=>"N","B"="Y"))
  * 					"Y" 有表 ; "N" 无表
  */
 public function queryHave($struct)
 {
     //DEBUG
     if (true == STRUCT_DEBUG) {
         $result["A"] = array("GN01A0103");
         //$result["A"] = array("GN01A0101","GN01A0102","GN01A0103");
         $result["B"] = array();
         //$result["A"] = array("GN01A0101","GN01A0102","GN01A0301");
         //$result["B"] = array("GN01B0103","GN01B0309");
         return $result;
     }
     //如果表架没有xNum或者yNum,则获取
     if (!$struct["xNum"] || !$struct["yNum"]) {
         $structparm = $this->getStructparmBySingle($struct["No"]);
         if ($structparm) {
             $struct["xNum"] = $structparm["xNum"];
             $struct["yNum"] = $structparm["yNum"];
             $struct["comport"] = $structparm["comport"];
             $struct["hardadd"] = $structparm["hardadd"];
             $struct["ipaddress"] = $structparm["ipaddress"];
             $struct["delay"] = Session::get('structdelay');
         }
     }
     $this->setLogs("structparms of query:" . print_r($struct, true));
     $this->address = $struct["ipaddress"] ? $struct["ipaddress"] : $this->address;
     $this->com = $struct["comport"] ? $struct["comport"] : 'COM1';
     $add = $struct["hardadd"] ? $struct["hardadd"] : (int) substr($struct["No"], 2, 2);
     //system_out("address:".$this->address);
     //system_out("com:".$this->com);
     //system_out("hardadd:".$add);
     $ycbk = new YCBK($this->address, $this->port, $this->com, $this->comToNetType);
     $A = array();
     $B = array();
     //操作硬件
     $ycbk->close();
     for ($i = 0; $i < $this->looptimes; $i++) {
         $ycbk->open();
         //获取表架使用情况
         $result = $ycbk->querySwitchStatus($add);
         $ycbk->close();
         if ($result) {
             break;
         }
         usleep($this->waittime);
     }
     if (!$result) {
         throw new Exception("查询表架[" . $add . "]使用情况出错:" . $ycbk->getError(), 101);
     }
     for ($i = 1; $i < sizeof($result) + 1; $i++) {
         //A面
         if ($result[$i]["A"] == "Y") {
             $station = array();
             $tmp = $struct["No"] . AddressCover::singleNumToName($i, 'A', $struct["xNum"], $struct["yNum"]);
             array_push($A, $tmp);
         }
         //B面
         if ($result[$i]["B"] == "Y") {
             $station = array();
             $tmp = $struct["No"] . AddressCover::singleNumToName($i, 'B', $struct["xNum"], $struct["yNum"]);
             array_push($B, $tmp);
         }
     }
     $rtn["A"] = $A;
     $rtn["B"] = $B;
     Session::set($struct["No"], $result);
     $this->setLogs($ycbk->getLogs());
     return $rtn;
 }