/*******************************************************************************
 *  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.cservices.withoutdb.testcases.defaultscp;


import java.io.IOException;


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

import cdac.medinfo.sdk.dcm30_04.services.cstore.scp.CStoreSCP;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;

/**
 * This class tests a Stand Alone CStore SCP.
 * "Stand Alone" means that the User is required to write a minimal set of code to create C-Store SCP
 * Once the required parameters are given to the CStoreSCP object and is started , it is 
 * capable of accepting connection, negotiation association and creating appropriate response(AssociateAC or Reject)
 * processing CStore Request and sending DIMSE Response for the same, processing Release Request and sending Release Response.
 * If User wants to handle the request sending scenarios by his/her code 
 * then please refer to sample code "TestCStoreSCP.java".
 */
public class CStore_SCP_Standalone 
{
	/**
	 * This function starts C-Store SCP.
	 * @throws IOException Signals if IO Operation fails.
	 */
	public void doCStore() throws IOException
	{
		/*
		 * Create CStore SCP.
		 */
		CStoreSCP objCStoreSCP = CStoreSCP.createInstance();

		/*
		 * Start C-Store SCP.
		 */
		objCStoreSCP.start("SDK",9000);
	}

	public static void main(String[] args)
	{
		try
		{
			DicomConfig objDicomConfig = DicomConfig.createInstance();

			//enable logging,specify the path of the directory where log files are created.
			//User can specify any directory in place of 'c:\DCM_Logs'.
			//If no directory is defined by user to create logs then it is created in User Temp DIR.
			objDicomConfig.enableLogging(EnumLoggingLevel.INFO, "C:\\DCM_Logs");

			/*
			 * Creates CStore_SCP_Standalone and Start C-Store Server.
			 */
			CStore_SCP_Standalone objCStoreSCPTest = new CStore_SCP_Standalone();

			//do C-Store SCP.
			objCStoreSCPTest.doCStore();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
}
