/** * @Route("/newDiodeRF", name="newDiodeRF") * @Template() */ public function newDiodeRFAction() { $post = $this->get('request')->request; $id = $post->get('id'); $formData = $post->get('formData'); $objF = json_decode($formData); $obj = $objF->diodeRFForm; $diode = new DiodeRF(); $diode->setParams($obj); $serviceDiode = $this->get('ikaros_diodeRFService'); $lambda = $serviceDiode->calculateLam($diode, $id); $serviceParts = $this->get('ikaros_partService'); $e = $serviceParts->setLams($lambda, $diode, $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' => $diode->getLabel(), 'Lam' => $diode->getLam(), 'PowerRated' => $diode->getPowerRated(), 'TempDissipation' => $diode->getTempDissipation(), 'TempPassive' => $diode->getTempPassive(), 'Application' => $diode->getApplication(), 'DiodeType' => $diode->getDiodeType(), 'Quality' => $diode->getQuality(), 'Environment' => $diode->getEnvironment(), 'idP' => $diode->getIDPart())), 200, array('Content-Type' => 'application/json; charset=utf-8')); }
public function calculateLam(DiodeRF $diode, $pcbID) { $sEnv = $diode->getEnvironment(); $piE = $this->systemService->getPiE(62, $sEnv); $pcb = $this->pcbService->getItem($pcbID); $system = $this->systemService->getItem($pcb->getSystemID()); $temp = $diode->getTempPassive() + $diode->getTempDissipation() + $system->getTemp(); $diode->setTemp($temp); $diodeType = $diode->getDiodeType(); $base = $this->getDiodeTypeValue($diodeType); $piQ = $this->getQualityValue($diode->getQuality(), $diodeType); $power = $diode->getPowerRated(); if ($diodeType == "PIN") { if ($power <= 0) { $piR = 2.4; } else { if ($power <= 10) { $piR = 0.5; } else { $piR = 0.326 * log($power) - 0.25; } } } else { $piR = 1; } if ($diodeType == "IMPATT") { $piT = exp(-5260 * (1 / ($temp + 273) - 1 / 298)); } else { $piT = exp(-2100 * (1 / ($temp + 273) - 1 / 298)); } $piA = $this->getApplicationValue($diode->getApplication()); $lambda = $base * $piT * $piA * $piR * $piQ * $piE * pow(10, -6); //$lambda = $piQ; return $lambda; }