/*******************************************************************************
 *  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.dicommodel.modules;



import cdac.medinfo.sdk.dcm30_04.baselibs.Tag;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataSet;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITag;
import cdac.medinfo.sdk.dcm30_04.enums.EnumAnodeTargetMaterial;
import cdac.medinfo.sdk.dcm30_04.enums.EnumExposureControlMode;
import cdac.medinfo.sdk.dcm30_04.enums.EnumExposureStatus;
import cdac.medinfo.sdk.dcm30_04.enums.EnumRectificationType;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidModuleException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
import cdac.medinfo.sdk.dcm30_04.utils.SingleCollection;

/**
 \* This module describes the attributes related to generation of X-rays during the acquisition of an X-Ray image.
 */
public class XRayGenerationModule extends Module  
{

 
 /**
  * The obj single collection.
  */
 public static ISingleCollection<ITag> objSingleCollection = null;
	 

	static
	{
		objSingleCollection = new SingleCollection<ITag>();
		objSingleCollection.add(new Tag(0x0018,0x0060));
		objSingleCollection.add(new Tag(0x0018,0x1151));
		objSingleCollection.add(new Tag(0x0018,0x1152));
		objSingleCollection.add(new Tag(0x0018,0x1153));
		objSingleCollection.add(new Tag(0x0018,0x1156));
		objSingleCollection.add(new Tag(0x0018,0x1190));
		objSingleCollection.add(new Tag(0x0018,0x1191));
		objSingleCollection.add(new Tag(0x0018,0x7060));
		objSingleCollection.add(new Tag(0x0018,0x7062));
		objSingleCollection.add(new Tag(0x0018,0x7064));
		objSingleCollection.add(new Tag(0x0018,0x7065));
		objSingleCollection.add(new Tag(0x0018,0x8151));
	}

	/**
	 * Instantiates a new x ray generation module.
	 * 
	 * @param objIDataSet the obj i data set
	 */
	public XRayGenerationModule(IDataSet objIDataSet)
	{
		super(objIDataSet);
	}

	/**
	 * This method validates each Attribute in the Module according to the Type
	 * of the Attribute.Attributes are of 5 types.
	 * Type 1,Type 2 are Mandatory:
	 * Mandatory Attributes have to present in the Module.
	 * Type 1C,2C are Conditional:
	 * Conditional Attributes' presence depend on a condition.
	 * If the condition is satisfied the Attribute has to be present.
	 * Type 3 are Optional
	 * Optional Attributes can be added as and when required.
	 * 
	 * @return boolean - returns validation status as success or failure
	 * 
	 * @throws InvalidModuleException - If validation of Module fails
	 */
	public boolean validateModule() throws InvalidModuleException
	{
		/*
		 * All attributes in thie module are optional.
		 */
		return true;
	}

	/**
	 * Sets Peak kilo voltage output of the x-ray generator used.
	 * 
	 * @param strKVP String value of KVP.
	 */
	public void setKVP(String strKVP)
	{
		/* Accept Peak kilo voltage output of the x-ray generator used.
		 * in String format of type DS.
		 * 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 Hash Map
		 */
		addDataElement(0x0018, 0x0060, DicomConstants.DCM_DT_DS, strKVP);
	}

	/**
	 * Retrieves Peak kilo voltage output of the x-ray generator used.
	 * 
	 * @return String - String value of KVP.
	 */
	public String getKVP()
	{
		Object objValue = getValue(0x0018,0x0060);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets X-Ray Tube Current in MilliA.
	 * 
	 * @param strXRayTubeCurrent the str x ray tube current
	 */
	public void setXRayTubeCurrent(String strXRayTubeCurrent)
	{
		/* Accept X-Ray Tube Current 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 Hash Map
		 */
		addDataElement(0x0018, 0x1151, DicomConstants.DCM_DT_IS, strXRayTubeCurrent);
	}

	/**
	 * Retrieves X-Ray Tube Current in mA.
	 * 
	 * @return String - String value of X-Ray Tube Current
	 */
	public String getXRayTubeCurrent()
	{
		Object objValue = getValue(0x0018,0x1151);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets X-Ray Tube Current in MicroA.
	 * 
	 * @param strXRayTubeCurrentInuA the str x ray tube current in micro a
	 */
	public void setXRayTubeCurrentInuA(String strXRayTubeCurrentInuA)
	{
		/* Accept X-Ray Tube Current In Micro A in String format of type DS.
		 * 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 Hash Map
		 */
		addDataElement(0x0018, 0x8151, DicomConstants.DCM_DT_DS, strXRayTubeCurrentInuA);
	}

	/**
	 * Retrieves X-Ray Tube Current in MicroA.
	 * 
	 * @return  String - String value of X-Ray Tube Current in MicroA
	 */
	public String getXRayTubeCurrentInuA()
	{
		Object objValue = getValue(0x0018,0x8151);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets duration of X-Ray exposure in msec.
	 * 
	 * @param strExposureTime the str exposure time
	 */
	public void setExposureTime(String strExposureTime)
	{
		/* Accept Exposure Time 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 Hash Map
		 */
		addDataElement(0x0018, 0x1150, DicomConstants.DCM_DT_IS, strExposureTime);
	}

	/**
	 * Retrieves duration of X-Ray exposure in msec.
	 * 
	 * @return  String - String value of Exposure Time
	 */
	public String getExposureTime()
	{
		Object objValue = getValue(0x0018,0x1150);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets duration of X-Ray exposure in Micro Sec.
	 * 
	 * @param strExposureTimeInuS the str exposure time in micro s
	 */
	public void setExposureTimeInuS(String strExposureTimeInuS)
	{
		/* Accept Exposure Time 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 Hash Map
		 */
		addDataElement(0x0018, 0x8150, DicomConstants.DCM_DT_IS, strExposureTimeInuS);
	}

	/**
	 * Retrieves duration of X-Ray exposure in msec.
	 * 
	 * @return  String - String value of Exposure Time in micro sec
	 */
	public String getExposureTimeInuS()
	{
		Object objValue = getValue(0x0018,0x8150);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the exposure expressed in mAs, for example calculated from Exposure Time
	 * and X-ray Tube Current.
	 * 
	 * @param strExposure String value of The exposure expressed in mAs
	 */
	public void setExposure(String strExposure)
	{
		/*Accept The exposure expressed in mAs 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 Hash Map
		 */
		addDataElement(0x0018, 0x1152, DicomConstants.DCM_DT_IS, strExposure);
	}

	/**
	 * Retrieves exposure expressed in mAs, for example calculated from Exposure Time.
	 * 
	 * @return String - String value of Exposure
	 */
	public String getExposure()
	{
		Object objValue = getValue(0x0018,0x1152);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets the exposure expressed in Micro As, for example calculated from Exposure Time
	 * and X-ray Tube Current.
	 * 
	 * @param strExposureInuAs :String value of The exposure expressed in mAs
	 */
	public void setExposureInuAs(String strExposureInuAs)
	{
		/*Accept The exposure expressed in MicroAs 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 Hash Map
		 */
		addDataElement(0x0018, 0x1153, DicomConstants.DCM_DT_IS, strExposureInuAs);
	}

	/**
	 * Retrieves the exposure expressed in Micro As.
	 * 
	 * @return String - String value of Exposure in Micro As
	 */
	public String getExposureInuAs()
	{
		Object objValue = getValue(0x0018,0x1153);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets type of exposure control.
	 * Defined Terms:MANUAL,AUTOMATIC.
	 * 
	 * @param enumExposureControlMode - enum value of Exposure Control Mode.
	 */
	public void setExposureControlMode(EnumExposureControlMode enumExposureControlMode)
	{
		/*Accept The exposure Control Mode in String format of type CS.
		 * 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 Hash Map
		 */
		addDataElement(0x0018, 0x7060, DicomConstants.DCM_DT_IS, enumExposureControlMode.getValue());
	}

	/**
	 * Retrieves the type of exposure control.
	 * 
	 * @return String - String value of Exposure Control Mode.
	 */
	public String getExposureControlMode()
	{
		Object objValue = getValue(0x0018,0x7060);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets text description of the mechanism of exposure control.
	 * May describe the number and type of exposure sensors or position of the
	 * sensitive area of the imaging detector.
	 * 
	 * @param strExposureControlModeDescription - String value of Exposure Control Mode Description
	 */
	public void setExposureControlModeDescription(String strExposureControlModeDescription)
	{
		/*Accept The exposure Control Mode Description in String format of type LT.
		 * 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 Hash Map
		 */
		addDataElement(0x0018, 0x7062, DicomConstants.DCM_DT_LT, strExposureControlModeDescription);
	}

	/**
	 * Retrieves text description of the mechanism of exposure control.
	 * 
	 * @return String - String value of Exposure Control Mode Description
	 */
	public String getExposureControlModeDescription()
	{
		Object objValue = getValue(0x0018,0x7062);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets whether the exposure was normally completed or not.
	 * Defined Terms: NORMAL, ABORTED.
	 * 
	 * @param enumExposureStatus - enum value of Exposure Status.
	 */
	public void setExposureStatus(EnumExposureStatus enumExposureStatus)
	{
		/*Accept The Exposure Status in String format of type CS.
		 * 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 Hash Map
		 */
		addDataElement(0x0018, 0x7064, DicomConstants.DCM_DT_CS, enumExposureStatus.getValue());
	}

	/**
	 * Retrieves whether the exposure was normally completed or not.
	 * 
	 * @return String - String value of Exposure Control Mode Description
	 */
	public String getExposureStatus()
	{
		Object objValue = getValue(0x0018,0x7064);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets nominal percentage phototimer setting, where a more positive value indicates
	 * greater exposure and a more negative value indicates less exposure.
	 * 
	 * @param strPhototimerSetting - String value of Phototimer Setting.
	 */
	public void setPhototimerSetting(String strPhototimerSetting)
	{
		/*Accept The Phototimer Setting in String format of type DS.
		 * 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 Hash Map
		 */
		addDataElement(0x0018, 0x7065, DicomConstants.DCM_DT_DS, strPhototimerSetting);
	}

	/**
	 * Retrieves nominal percentage phototimer setting, where a more positive value indicates
	 * greater exposure and a more negative value indicates less exposure.
	 * 
	 * @return String - String value of Phototimer Setting.
	 */
	public String getPhototimerSetting()
	{
		Object objValue = getValue(0x0018,0x7065);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets size of the focal spot in mm. For devices with variable focal spot or multiple focal
	 * spots, small dimension followed by large dimension.
	 * 
	 * @param arrStrFocalSpots - String array of Focal Spot(s) values.
	 */
	public void setFocalSpots(String[] arrStrFocalSpots)
	{
		/*Accept the Focal Spot(s) in String Array format of type PN.
		 * Read the Transfer Syntax and check to create ImplicitDE or ExplicitDE .
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Hash Map
		 */
		addDataElement(0x0018, 0x1190, DicomConstants.DCM_DT_DS, arrStrFocalSpots);
	}

	/**
	 * Retrieves size of the focal spot in mm.
	 * 
	 * @return String[] - String array of Focal Spot(s) values.
	 */
	public String[] getFocalSpots()
	{

		Object objValue = getValue(0x0018,0x1190);
		if(objValue != null)
			return (String[])objValue;
		return null;
	}

	/**
	 * Sets the primary material in the anode of the X-Ray source. Defined Terms: TUNGSTEN,MOLYBDENUM,RHODIUM.
	 * 
	 * @param enumAnodeTargetMaterial - enum value of the primary material in the anode of the X-Ray source.
	 */
	public void setAnodeTargetMaterial(EnumAnodeTargetMaterial enumAnodeTargetMaterial)
	{
		/* Accept Organ Exposed in String format of type CS.
		 * 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 Hash Map
		 */
		addDataElement(0x0018,0x1191, DicomConstants.DCM_DT_CS, enumAnodeTargetMaterial.getValue());
	}

	/**
	 * Retrieves primary material in the anode of the X-Ray source.
	 * 
	 * @return String - String value of Organ Dose.
	 */
	public String getAnodeTargetMaterial()
	{
		Object objValue = getValue(0x0018,0x1191);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * Sets type of rectification used in the X-Ray generator.Defined Terms:SINGLE PHASE,THREE PHASE,CONST POTENTIAL,
	 * 
	 * @param enumRectificationType - Enum value of Rectification Type.
	 */
	public void setRectificationType(EnumRectificationType enumRectificationType)
	{
		/* Accept Rectification Type in String format of type CS.
		 * 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 Hash Map
		 */
		addDataElement(0x0018,0x1156, DicomConstants.DCM_DT_CS, enumRectificationType.getValue());
	}

	/**
	 * Retrieves type of rectification used in the X-Ray generator.
	 * 
	 * @return String - String value of Rectification Type.
	 */
	public String getRectificationType()
	{
		Object objValue = getValue(0x0018,0x1156);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	
	/**
	 * Sets Generator ID
	 * @param strGeneratorID String value of Generator ID
	 */
	public void setGeneratorID(String strGeneratorID)
	{
		/* Accept the Generator ID in String format of type LO.
		 * 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
		 */

		addDataElement(0x0018,0x1005, DicomConstants.DCM_DT_LO,strGeneratorID);
	}

	/**
	 * Return user-defined label identifier for Generator ID
	 * @return String - value of Generator ID
	 */
	public String getGeneratorID()
	{
		Object objValue = getValue(0x0018,0x1005);
		if(objValue != null)
			return objValue.toString();
		return null;
	}

	/**
	 * This method returns the custom collection containing the list of DataElements belonging to the
	 * X-Ray Generation Module specified by DICOM Standard.
	 * 
	 * @return collection - custom collection containing the list of DataElements belonging to the X-Ray Generation Module
	 */
	public ISingleCollection<ITag> getVectorOfKeys()
	{
		return objSingleCollection;
	}
}
