public function calculateLam(Resistor $res, $pcbID)
 {
     $pcb = $this->pcbService->getItem($pcbID);
     $system = $this->systemService->getItem($pcb->getSystemID());
     $sysTemp = $system->getTemp();
     $res->setTemp($sysTemp + $res->getDPTemp() + $res->getPassiveTemp());
     $material = $this->getResMaterialByShortcut($res->getMaterial());
     $base = $material['Lamb'];
     $piT_tab = $material['FactorT'];
     $piS_tab = intval($material['FactorS']);
     $temp = $res->getTemp();
     $piT = exp(-1 * $piT_tab / (8.617000000000001 * 1.0E-5) * (1 / ($temp + 273) - 1 / 298));
     $pDiss = $res->getDissipationPower();
     $s_pom = $pDiss / $res->getMaxPower();
     switch ($piS_tab) {
         case 0:
             $piS = 1;
             break;
         case 1:
             $piS = 0.71 * exp(1.1 * $s_pom);
             break;
         case 2:
             $piS = 0.54 * exp(2.04 * $s_pom);
             break;
     }
     $piP = pow($pDiss, 0.39);
     $piQ = $res->getQuality();
     $sEnv = $res->getEnvironment();
     $piE = $this->systemService->getPiE(91, $sEnv);
     $lambda = $base * $piT * $piP * $piS * $piQ * $piE * pow(10, -6);
     return $lambda;
 }
 /**
  * @Route("/newResistor", name="newResistorAjax")
  * @Template()
  */
 public function newResistorAjaxAction()
 {
     $post = $this->get('request')->request;
     $id = $post->get('id');
     $formData = $post->get('formData');
     $objF = json_decode($formData);
     $obj = $objF->resistorForm;
     $res = new Resistor();
     $res->setParams($obj);
     $serviceResistor = $this->get('ikaros_resistorService');
     $servicePart = $this->get('ikaros_partService');
     //$e = $service->setLams($res, $id);
     $lambda = $serviceResistor->calculateLam($res, $id);
     $e = $servicePart->setLams($lambda, $res, $id);
     $qualR = $serviceResistor->getResQuality($res->getQuality());
     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' => $res->getLabel(), 'Lam' => $res->getLam(), 'Value' => $res->getValue(), 'MaxPower' => $res->getMaxPower(), 'DissipationPower' => $res->getDissipationPower(), 'DPTemp' => $res->getDPTemp(), 'PassiveTemp' => $res->getPassiveTemp(), 'Material' => $res->getMaterial(), 'Quality' => $qualR, 'Environment' => $res->getEnvironment(), 'idP' => $res->getIDPart())), 200, array('Content-Type' => 'application/json; charset=utf-8'));
 }