public function calculateLam(RotDevElaps $rotElaps, $pcbID = -1) { $sEnv = $rotElaps->getEnvironment(); $piE = $this->systemService->getPiE(123, $sEnv); $type = $rotElaps->getDevType(); if ($type == "A.C.") { $base = 20; } else { if ($type == "Inverter Driven") { $base = 30; } else { $base = 80; } } $temp = $rotElaps->getTempOperational() / $rotElaps->getTempMax(); if ($temp <= 0.5) { $piT = 0.5; } else { if ($temp > 0.5 && $temp <= 0.6) { $piT = 0.6; } else { if ($temp > 0.6 && $temp <= 0.8) { $piT = 0.8; } else { $piT = 1; } } } $lambda = $base * $piT * $piE * pow(10, -6); return $lambda; }
/** * @Route("/newRotElaps", name="newRotElaps") * @Template() */ public function newRotElapsAction() { $post = $this->get('request')->request; $id = $post->get('id'); $formData = $post->get('formData'); $objF = json_decode($formData); $obj = $objF->rotDevElapsForm; $rotElaps = new RotDevElaps(); $rotElaps->setParams($obj); $service = $this->get('ikaros_rotDevElapsService'); $lambda = $service->calculateLam($rotElaps); $serviceParts = $this->get('ikaros_partService'); $e = $serviceParts->setLams($lambda, $rotElaps, $id); if ($e != "") { return new Response(json_encode(array('e' => $e)), 400, array('Content-Type' => 'application/json; charset=utf-8')); } return new Response(json_encode(array('Label' => $rotElaps->getLabel(), 'Lam' => $rotElaps->getLam(), 'DevType' => $rotElaps->getDevType(), 'Type' => $rotElaps->getType(), 'CasePart' => $rotElaps->getCasePart(), 'Environment' => $rotElaps->getEnvironment(), 'TempMax' => $rotElaps->getTempMax(), 'TempOperational' => $rotElaps->getTempOperational(), 'idP' => $rotElaps->getIDPart())), 200, array('Content-Type' => 'application/json; charset=utf-8')); }