/** * 数字地址转换为地址名称 * * @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; }
/** * 关闭单个灯操作 * * @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; }