/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.baselibs;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;


/**
* This item class contains methods to set,get and validate the attributes of Cardiac Synchronization Sequence.
 */

public class CardiacSynchronizationSequenceItem extends Item
{
	

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * This constructor creates the item and internal code sequence macro with default TransferSyntax. 
	 */
	CardiacSynchronizationSequenceItem()
	{
		super();
	}

	/**
	 * This constructor creates the item and internal code sequence macro with default TransferSyntax .
	 * @param objITransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 */
	CardiacSynchronizationSequenceItem(ITransferSyntax objITransferSyntax)
	{
		super(objITransferSyntax);
	}

	/**
	 * This constructor creates CardiacSynchronizationSequenceItem with specified TransferSyntax and
	 * specified DictionaryReader
	 * @param objTransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 * @param objDictionaryReader specifies the DICOM Dictionary reader to be used 
	 */
	CardiacSynchronizationSequenceItem(ITransferSyntax objTransferSyntax, IDictionaryReader objDictionaryReader)
	{
		super(objTransferSyntax,objDictionaryReader);
	}
	
	/**
	 * Sets Nominal CardiacTrigger Delay Time.
	 * @param dblNominalCardiacTriggerDelayTime -double value of Unique identifier for the Study.
	 */
	public void setNominalCardiacTriggerDelayTime(double dblNominalCardiacTriggerDelayTime)
	{
		/* Accept the NominalCardiacTrigger Delay Time in double format of type FD.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0020,0x9153, dblNominalCardiacTriggerDelayTime,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0020,0x9153,DicomConstants.DCM_DT_FD, dblNominalCardiacTriggerDelayTime);

		addDataElement(objIDataElement);
	}

	

	/**
	 * Retrieves Unique identifier for the Study.
	 * @return double - value of Unique identifier for the Study.
	 */
	public double getNominalCardiacTriggerDelayTime()
	{
		Object objValue = getValue(0x0020,0x9241);
		if(objValue != null)
		return Double.parseDouble(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}

	/**
	 * Sets Actual Cardiac Trigger Delay Time.
	 * @param dblActualCardiacTriggerDelayTime -double value of Unique identifier for the Study.
	 */
	public void setActualCardiacTriggerDelayTime(double dblActualCardiacTriggerDelayTime)
	{
		/* Accept the ActualCardiacTrigger Delay Time in double format of type FD.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0020,0x9252, dblActualCardiacTriggerDelayTime,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0020,0x9252,DicomConstants.DCM_DT_FD, dblActualCardiacTriggerDelayTime);

		addDataElement(objIDataElement);
	}

	/**r
	 * Retrieves Unique identifier for the Study.
	 * @return double - value of Unique identifier for the Study.
	 */
	public double getActualCardiacTriggerDelayTime()
	{
		Object objValue = getValue(0x0020,0x9252);
		if(objValue != null)
			return Double.parseDouble(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}



	/**
	 * Sets Intervals Acquired.
	 * @param strIntervalsAcquired String value of Unique identifier for the Study.
	 */
	public void setIntervalsAcquired(String strIntervalsAcquired)
	{
		/* Accept the Intervals Acquired in string format of type IS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0018,0x1083, strIntervalsAcquired,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1083,DicomConstants.DCM_DT_IS, strIntervalsAcquired);

		addDataElement(objIDataElement);
	}

	/**r
	 * Retrieves Unique identifier for the Study.
	 * @return string - value of Unique identifier for the Study.
	 */
	public String[] getIntervalsAcquired()
	{
		Object objValue = getValue(0x0018,0x1083);
		if(objValue != null)
			return (String[])(objValue);
		return null;
	}

	/**
	 * Sets Heart Rate.
	 * @param strHeartRate- String value of Unique identifier for the Study.
	 */
	public void setHeartRate(String strHeartRate)
	{
		/* Accept the Heart Rate in string format of type IS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0018,0x1088, strHeartRate,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1088,DicomConstants.DCM_DT_IS, strHeartRate);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Unique identifier for the Study.
	 * @return string - value of Unique identifier for the Study.
	 */
	public String[] getHeartRate()
	{
		Object objValue = getValue(0x0018,0x1088);
		if(objValue != null)
			return (String[])(objValue);
		return null;
	}
	
	/**
	 * Sets R-R Interval Time Nominal.
	 * @param dblR-RIntervalTimeNominal- double value of Unique identifier for the Study.
	 */
	public void setRRIntervalTimeNominal(double dblRRIntervalTimeNominal)
	{
		/* Accept the R-R Interval Time Nominal in double format of type FD.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0020,0x9251, dblRRIntervalTimeNominal,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0020,0x9251,DicomConstants.DCM_DT_FD, dblRRIntervalTimeNominal);

		addDataElement(objIDataElement);
	}

	/**r
	 * Retrieves Unique identifier for the Study.
	 * @return double - value of Unique identifier for the Study.
	 */
	public double getRRIntervalTimeNominal()
	{
		Object objValue = getValue(0x0020,0x92511);
		if(objValue != null)
		 return Double.parseDouble(objValue.toString());
		 return DicomConstants.DCM_NO_VALUE;
	}

	/**
	 * Sets Low R-R Value.
	 * @param strLowR-RValue- String value of Unique identifier for the Study.
	 */
	public void setLowRRValue(String strLowRRValue)
	{
		/* Accept the Low R-R Value in string format of type IS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0018,0x1081, strLowRRValue,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1081,DicomConstants.DCM_DT_IS, strLowRRValue);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Unique identifier for the Study.
	 * @return string - value of Unique identifier for the Study.
	 */
	public String[] getLowRRValue()
	{
		Object objValue = getValue(0x0018,0x1081);
		if(objValue != null)
			return (String[])(objValue);
		return null;
	}


	/**
	 * Sets High R-R Value.
	 * @param strHighR-RValue -String value of Unique identifier for the Study.
	 */
	public void setHighRRValue(String strHighRRValue)
	{
		/* Accept the High R-R Value in string format of type IS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0018,0x1082, strHighRRValue,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0018,0x1082,DicomConstants.DCM_DT_IS, strHighRRValue);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves Unique identifier for the Study.
	 * @return string - value of Unique identifier for the Study.
	 */
	public String[] getHighRRValue()
	{
		Object objValue = getValue(0x0018,0x1082);
		if(objValue != null)
			return (String[])(objValue);
		return null;
	}
	
}

