/*******************************************************************************
 *  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.services.pdu;

import java.util.EventObject;

import cdac.medinfo.sdk.dcm30_04.enums.EnumPDUType;




/**
 * This Class represents Service Event. The service event is fired when Service PDU is received by PDU Reader.
 */
public class ServiceEvent extends EventObject  
{

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1;

	/** The object of service pdu. */
	PDU objPDU = null;

	/** The enum value representing PDU type */
	EnumPDUType enumPDUType = null;

	/**
	 * Instantiates service event.
	 * @param source The object on which the Event initially occurred.
	 */
	public ServiceEvent(Object source)
	{
		super(source);
	}

	/**
	 * Gets the pdu type.
	 * @return EnumPDUType - the enum value representing pdu type.
	 */
	public EnumPDUType getEnumPDUType()
	{
		return enumPDUType;
	}

	/**
	 * Sets the pdu type.
	 * @param enumPDUType the enum value representing pdu type.
	 */
	public void setEnumPDUType(EnumPDUType enumPDUType)
	{
		this.enumPDUType = enumPDUType;
	}

	/**
	 * Gets the object of PDU.
	 * @return PDU - The object of PDU.
	 */
	public PDU getPDU() 
	{
		return objPDU;
	}

	/**
	 * Sets the PDU.
	 * @param objPDU Object of PDU.
	 */
	public void setPDU(PDU objPDU)
	{
		if(objPDU.getPDUType()== EnumPDUType.P_DATA_TF)
			this.objPDU = objPDU;
		enumPDUType = objPDU.getPDUType();
		// else Exception must be thrown i.e. not decided yet
	}
}
