Blame view

php/RemoteDataCenter/makeOrbitsInfo.php 2.53 KB
55e11e13   Elena.Budnik   new global AMDAUP...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
/*
*   
*/
	function days2MonthDay($date)
	{
			list($year, $day, $hour, $min, $sec) = sscanf($date, "%04d%03d%02d%02d%02d");
			
			$newDate = date("Y-m-d\TH:i:s\Z",strtotime("+$day days",strtotime("$year-01-01 $hour:$min:$sec")));

			return $newDate;
	} 
    
	$AMDA_IHM = getenv('AMDA_IHM');
	//TBD should be one dir with AmdaUpdate [install] and config
2ce0aff1   Elena.Budnik   DD_WSDL defined i...
16
 //  define('WSDL','http://amda-dev.irap.omp.eu/BASE/DDService/dd.wsdl'); 
55e11e13   Elena.Budnik   new global AMDAUP...
17
18
19
20
21
22
23
24
25
   
	require_once $AMDA_IHM."/php/config.php";

	if (!file_exists(SimuTargetsXml))
		exit("ERROR : NO TargetsSimu FILE !!! Run makeProxy.php".PHP_EOL);
	
	$tr = array('_' => ':');
	
	try {
2ce0aff1   Elena.Budnik   DD_WSDL defined i...
26
		$client = new SoapClient(DD_WSDL);
55e11e13   Elena.Budnik   new global AMDAUP...
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
	}
	catch  (SoapFault $exception) {
		$msg = $exception->faultstring.PHP_EOL;                           
		exit($msg);
	}	
	  // Transform to HTML
	$xsl = new DomDocument("1.0");
	$xsl->load(XMLPATH.'orbitsInfo.xsl');

	$xslt = new XSLTProcessor();
	$xslt->importStylesheet($xsl); 
	
	$targetXml = simplexml_load_file(SimuTargetsXml);

	$targets = $targetXml->Target;
	
	foreach ($targets as $target) 
	{			
		if (!file_exists(RemoteData."$target.json"))
			exit("ERROR : NO $target.json FILE !!! Run makeOrbitsArgs.php".PHP_EOL);
		
		$infoFileName = "simu$target";
		$infoDom = new DomDocument("1.0");
		
		$root = $infoDom->createElement('target');
		$root->setAttribute('name', $target);
		$infoDom->appendChild($root);
		
		$orbits = json_decode(file_get_contents(RemoteData.$target.'.json'), true);
		
		foreach ($orbits as $missionGroup => $missions)
		{
			$missionGrpNode = $infoDom->createElement('missionGroup'); 
			$missionGrpNode->setAttribute('name', $missionGroup);
			$root->appendChild($missionGrpNode);
			
			foreach ($missions as $missionName => $mission)
			{			 
				$missionNode = $infoDom->createElement('mission');
				$missionNode->setAttribute('name', $missionName);
				$missionGrpNode->appendChild($missionNode);
				
				foreach ($mission as $ds => $param)
				{
					try {
						$res = $client->getStartStop(strtr($ds,$tr));
						$Time = explode("-",$res);
						$StartTime = days2MonthDay($Time[0]);
						$StopTime = days2MonthDay($Time[1]);
						$missionNode->appendChild($infoDom->createElement('start',$StartTime));
						$missionNode->appendChild($infoDom->createElement('stop',$StopTime));
					}
					catch  (SoapFault $exception) {
						$msg = $exception->faultstring.PHP_EOL;                           
						exit($msg);
					}				
				}		 
			}
		}
		// $infoDom->save($infoFileName.".xml");	
		$xslt->transformToURI($infoDom, 'file://'.HELPPATH.'simu/'.$infoFileName);
	}	
?>