public function SetParamMinmax($exFlightId, $extParamCode, $extTplName, $extMin, $extMax)
 {
     $flightId = $exFlightId;
     $paramCode = $extParamCode;
     $tplName = $extTplName;
     $min = $extMin;
     $max = $extMax;
     $user = $this->_user->username;
     $Fl = new Flight();
     $flightInfo = $Fl->GetFlightInfo($flightId);
     $bruType = $flightInfo['bruType'];
     unset($Fl);
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($flightInfo['bruType']);
     $PSTTableName = $bruInfo['paramSetTemplateListTableName'];
     unset($Bru);
     $PSTempl = new PSTempl();
     $PSTempl->UpdateParamMinMax($PSTTableName, $tplName, $paramCode, $min, $max, $user);
     unset($PSTempl);
     return "ok";
 }
 public function copyTemplate($flightId, $oldName)
 {
     $Fl = new Flight();
     $flightInfo = $Fl->GetFlightInfo($flightId);
     unset($Fl);
     $bruType = $flightInfo['bruType'];
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($bruType);
     $tableName = $bruInfo['paramSetTemplateListTableName'];
     unset($Bru);
     $newName = date('Y-m-d') . '_' . $this->_user->username . '_' . $this->generateRandomString(3);
     $username = $this->_user->username;
     $PSTempl = new PSTempl();
     $tpl = $PSTempl->getTemplate($tableName, $oldName, $username);
     $PSTempl->createTemplate($newName, $tpl, $tableName, $username);
     unset($PSTempl);
     return 'ok';
 }
 public function CreateTemplate($extFlightId, $extParamsToAdd, $extTplName)
 {
     $flightId = $extFlightId;
     $paramsToAdd = $extParamsToAdd;
     $tplName = $extTplName;
     $Fl = new Flight();
     $flightInfo = $Fl->GetFlightInfo($flightId);
     $bruType = $flightInfo['bruType'];
     $apTableName = $flightInfo['apTableName'];
     $bpTableName = $flightInfo['bpTableName'];
     unset($Fl);
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($flightInfo['bruType']);
     $cycloApTableName = $bruInfo['gradiApTableName'];
     $cycloBpTableName = $bruInfo['gradiBpTableName'];
     $PSTTableName = $bruInfo['paramSetTemplateListTableName'];
     $paramsWithType = array();
     $Ch = new Channel();
     for ($i = 0; $i < count($paramsToAdd); $i++) {
         $paramInfo = $Bru->GetParamInfoByCode($cycloApTableName, $cycloBpTableName, $paramsToAdd[$i]);
         if (isset($paramInfo['paramType']) && $paramInfo['paramType'] == PARAM_TYPE_AP) {
             $apTableNameWithPrefix = $apTableName . "_" . $paramInfo['prefix'];
             $paramMinMax = $Ch->GetParamMinMax($apTableNameWithPrefix, $paramsToAdd[$i], $this->_user->username);
             $paramsWithType[PARAM_TYPE_AP][] = array('code' => $paramsToAdd[$i], 'min' => $paramMinMax['min'], 'max' => $paramMinMax['max']);
         } else {
             if (isset($paramInfo['paramType']) && $paramInfo['paramType'] == PARAM_TYPE_BP) {
                 $paramsWithType[PARAM_TYPE_BP][] = array('code' => $paramsToAdd[$i]);
             }
         }
     }
     unset($Bru);
     $PSTempl = new PSTempl();
     $PSTempl->DeleteTemplate($PSTTableName, $tplName, $this->_user->username);
     $PSTempl->CreateTplWithDistributedParams($PSTTableName, $tplName, $paramsWithType, $this->_user->username);
     unset($Ch);
     unset($PSTempl);
 }