コード例 #1
0
 /**
  * 关闭单个灯操作
  *
  * @param String $struct 表架参数 Example:struct = array("No" = "GN01","xNum"=>10,"yNum"=>5)
  * @param String $places
  * @param String $stype 类型 get(取表),put(挂表)
  * @return Boolean
  */
 public function trunoffSingle($struct, $place, $type)
 {
     //DEBUG
     if (true == STRUCT_DEBUG) {
         return true;
     }
     //如果表架没有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 turnoff single light:" . 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);
     $ycbk = new YCBK($this->address, $this->port, $this->com, $this->comToNetType);
     $index = AddressCover::singleNameToSerialNum($place, $structparm["xNum"], $structparm["yNum"]);
     $panel = substr($place, 4, 1);
     //操作硬件
     for ($i = 0; $i < $this->looptimes; $i++) {
         $ycbk->open();
         //获取表架使用情况
         $result = $ycbk->onlyOneUploadMeterLightOff($add, $panel, $index);
         $ycbk->close();
         if ($result) {
             break;
         }
         usleep($this->waittime);
     }
     if (!$result) {
         throw new Exception("关闭表架[" . $add . "]灯出错:" . $ycbk->getError(), 100300);
     }
     $this->setLogs($ycbk->getLogs());
     return true;
 }