ParamGetLocalBaseParamNodeClass.php 2.61 KB
<?php

define ("PARAMGETLOCALBASEPARAM_NAME", "param");
define ("PARAMGETLOCALBASEPARAM_ID",   "id");
define ("PARAMGETLOCALBASEPARAM_MINSAMPLING", "minSampling");
define ("PARAMGETLOCALBASEPARAM_MAXSAMPLING", "maxSampling");
define ("PARAMGETLOCALBASEPARAM_TYPE", "type");
define ("PARAMGETLOCALBASEPARAM_SIZE", "size");
define ("PARAMGETLOCALBASEPARAM_CALIB", "clb");
define ("PARAMGETLOCALBASEPARAM_CALIBNAME", "name");


/**
 * @class ParamGetLocalBaseParamNodeClass
 * @brief Definition of a Local parameter
 * @details
*/
class ParamGetLocalBaseParamNodeClass extends NodeClass
{
	public function __construct()
	{
		parent::__construct(PARAMGETLOCALBASEPARAM_NAME);
	}

	public function setId($id)
	{
		$this->setAttribute(PARAMGETLOCALBASEPARAM_ID, $id);
	}
	
	public function getId()
	{
		return $this->getAttribute(PARAMGETLOCALBASEPARAM_ID);
	}

	public function setMinSampling($minSampling)
	{
		$this->setAttribute(PARAMGETLOCALBASEPARAM_MINSAMPLING, $minSampling);
	}
	
	public function setMaxSampling($maxSampling)
	{
		$this->setAttribute(PARAMGETLOCALBASEPARAM_MAXSAMPLING, $maxSampling);
	}
	
	public function setParameterType($parameterType)
	{	
		$this->setAttribute(PARAMGETLOCALBASEPARAM_TYPE, strtolower($parameterType));
	}
	
	public function setParameterSize($parameterSize)
	{	
		$this->setAttribute(PARAMGETLOCALBASEPARAM_SIZE, $parameterSize);
	}
	
	public function addCalibInfo($calibInfo = "")
	{
		if ($this->calibInfoExist($calibInfo))
			return NULL;
	
		$node = new NodeClass(PARAMGETLOCALBASEPARAM_CALIB);
		$node->setAttribute(PARAMGETLOCALBASEPARAM_CALIBNAME,$calibInfo);
		$this->addChild($node);
		
		return $node;
	}
	
	public function calibInfoExist($calibInfo)
	{
		$calibNodes = $this->getChildrenByName(PARAMGETLOCALBASEPARAM_CALIB);
	
		foreach ($calibNodes as $calibNode)
		if ($calibNode->getAttribute(PARAMGETLOCALBASEPARAM_CALIBNAME) == $calibInfo)
			return true;
	
		return false;
	}
	
	public function loadFromNode($xmlNode)
	{
		$this->setId($this->getXmlNodeAttribute($xmlNode, PARAMGETLOCALBASEPARAM_ID));
		
		$this->setMinSampling($this->getXmlNodeAttribute($xmlNode, PARAMGETLOCALBASEPARAM_MINSAMPLING));
		
		$this->setMaxSampling($this->getXmlNodeAttribute($xmlNode, PARAMGETLOCALBASEPARAM_MAXSAMPLING));
		
		$this->setParameterType($this->getXmlNodeAttribute($xmlNode, PARAMGETLOCALBASEPARAM_TYPE));
		
		$this->setParameterSize($this->getXmlNodeAttribute($xmlNode, PARAMGETLOCALBASEPARAM_SIZE));
		
		foreach ($this->getXmlNodeChildrenByTagName($xmlNode, PARAMGETLOCALBASEPARAM_CALIB) as $calibXmlNode) {
			$this->addCalibInfo($this->getXmlNodeAttribute($xmlNode, PARAMGETLOCALBASEPARAM_CALIBNAME));
		}
	}
}

?>