SimuArgsMgr.php 5.19 KB
<?php
/**
 * @class SimuArgsMgr
 * @version 
 * 
 */


  class SimuArgsMgr  {
    
      protected $paramID;
      protected $dataProducteur;
      protected $dom; 
      protected $simulatedRegion;
      
      function __construct() {			 		    		 

  }
      
/*****************************************************************
*                           PUBLIC FUNCTIONS
*****************************************************************/
    public function init($paramID){
      
      $this->paramID = $paramID;    
      if ((strncmp($this->paramID, "impex___", 8) === 0) || (strncmp($this->paramID, "spase___", 8) === 0)){  
	    $this->getDataProducteur();
	    $this->dom = new DomDocument("1.0");
	    $this->dom->load(USERWSDIR.'RemoteParams.xml'); 
	    if ($this->dataProducteur == 'FMI_GUMICS')
	      $this->simulatedRegion = 'Earth.Magnetosphere';
	    else
	      $this->getSimulatedRegion();
	}
    }
    
    protected function getDataProducteur(){
	if (strncmp($this->paramID, "impex___", 8) === 0)
	  $par =    str_replace ("impex___", "", $this->paramID);
	elseif (strncmp($this->paramID, "spase___", 8) === 0)
	  $par =    str_replace ("spase___IMPEX_NumericalOutput_", "", $this->paramID); 
    // TODO tests
	$tmp 		=  explode( '_', $par);  

	if ($tmp[0] == 'FMI') 
	  $this->dataProducteur = $tmp[0].'_'.$tmp[1];
        else 
	  $this->dataProducteur = $tmp[0];  
    }
    
    protected function getSimulatedRegion(){ 
	$param =  $this->dom->getElementById(trim($this->paramID)); 
	$parentID = $param->getAttribute('parentID');
	$dataSet = $this->dom->getElementById($parentID); 
	$this->simulatedRegion = $dataSet->getAttribute('SimulatedRegion');
	
    }
    
    protected function getMissionsBySimuRegion(){
      $missions = simplexml_load_file(missionXml);
      $missionsVal  = array();
        foreach($missions->Local->MissionID as $mission){
	    if (stripos ($mission['targets'], trim($this->simulatedRegion)) !== false ){
	      if ( !isset($mission['group']) || (isset($mission['group']) && $mission['group'] != 'TEST')) {
		$multypMissions  = array();
		if ($mission['missions'] != '') 
		    $multypMissions = explode(';',$mission['missions']);
		else 
		    $multypMissions[0] = (string)$mission;

		$missionsVal = array_merge($missionsVal,$multypMissions);
		}
	    }
	}
	sort($missionsVal);
	return $missionsVal;
    }
    
    public function makeSimuArgs(){
     if ($this->dataProducteur != 'CCMC'){
      $missions = $this->getMissionsBySimuRegion();
      
      if (count($missions) == 1) 
	  $grp[] = array("group" => "Satellite", "args" => array("value" => $missions[0]));
      elseif (count($missions) > 1){
	  foreach ($missions as $mission){
	    $miss[] = array ("arg" => $mission, "value" => $mission);
	  }
	  $grp[] = array("group" => "Satellite", "args" => $miss);
      }
    
      
	  switch ($this->dataProducteur){
	    case 'LATMOS':
	      $grp[] = array("group" => "ClockAngle", "args" => array("value" => "0"));
	      
	      break;
	    case 'SINP':
	       if ($this->simulatedRegion == 'Mercury.Magnetosphere'){
		  $grp[] = array("group" => "BD", "args" => array("value" => "-196.0"));
		  $grp[] = array("group" => "Flux", "args" => array("value" => "131.0"));
		  $grp[] = array("group" => "Rss", "args" => array("value" => "1.35"));
		  $grp[] = array("group" => "R2", "args" => array("value" => "1.32"));
		  $grp[] = array("group" => "DZ", "args" => array("value" => "0.0"));
		  $grp[] = array("group" => "IMF_Bx", "args" => array("value" => "0.0"));
		  $grp[] = array("group" => "IMF_By", "args" => array("value" => "0.0"));
		  $grp[] = array("group" => "IMF_Bz", "args" => array("value" => "0.0"));
	       }
	       elseif ($this->simulatedRegion == 'Saturn.Magnetosphere'){
		  $grp[] = array("group" => "BDC", "args" => array("value" => "3.0"));
		  $grp[] = array("group" => "BT", "args" => array("value" => "7.0"));
		  $grp[] = array("group" => "Rss", "args" => array("value" => "22.0"));
		  $grp[] = array("group" => "RD1", "args" => array("value" => "15.0"));
		  $grp[] = array("group" => "RD2", "args" => array("value" => "6.5"));
		  $grp[] = array("group" => "R2", "args" => array("value" => "18.0"));
		  $grp[] = array("group" => "IMF_Bx", "args" => array("value" => "0.0"));
		  $grp[] = array("group" => "IMF_By", "args" => array("value" => "0.0"));
		  $grp[] = array("group" => "IMF_Bz", "args" => array("value" => "0.0"));
	       }
	       elseif ($this->simulatedRegion == 'Jupiter.Magnetosphere'){
		  $grp[] = array("group" => "BDC", "args" => array("value" => "3.0"));
		  $grp[] = array("group" => "BT", "args" => array("value" => "7.0"));
		  $grp[] = array("group" => "Rss", "args" => array("value" => "22.0"));
		  $grp[] = array("group" => "RD1", "args" => array("value" => "15.0"));
		  $grp[] = array("group" => "RD2", "args" => array("value" => "6.5"));
		  $grp[] = array("group" => "R2", "args" => array("value" => "18.0"));
		  $grp[] = array("group" => "IMF_Bx", "args" => array("value" => "0.0"));
		  $grp[] = array("group" => "IMF_By", "args" => array("value" => "0.0"));
		  $grp[] = array("group" => "IMF_Bz", "args" => array("value" => "0.0"));
	       }
	      break;
	    case 'LESIA':
	      break;
	  }
      
      return $grp;
      }
      return;
    }
    
      
 }

?>