예제 #1
0
/**
 * \brief OIL job exit function.
 *
 * This function is called to notify the RIP that a job has completed and
 * that the resources claimed by the job can now be freed.  It requires that
 * the system be in one of \c OIL_Sys_JobCancel, \c OIL_Sys_JobActive or
 * \c OIL_Sys_Inactive states when the function is entered.\n
 * This function:
 * \arg requests that the RIP end the current job;
 * \arg discards remaining pages in the job;
 * \arg cleans up any partial pages;
 * \arg deletes the job;
 * \arg configures the RIP according to the settings in the next job, if any, and
 * \arg places the system into the next requested state, if it is not already inactive.
 *
 * This function does not cause the RIP to exit.
 *
 * \param[in]   eNextState  The system state that is required by the end of the call.
 * \return      Returns TRUE if the post-job cleanup is successful and the OIL is
 *              placed in the requested state, FALSE otherwise.
 */
int JobExit(OIL_eTySystemState eNextState)
{
  char szJobName[OIL_MAX_JOBNAME_LENGTH];
  int GPSPlotCloseretval;
  int GPSSinCloseretval ;
  int GPSSoutCloseretval;
  int GPSSoutFlushretval;
  int GPSSoutWriteretval;
  long len,i;
  int fin = GPS_INTERP_FIN_NORMAL, uel_found=1;
  HQASSERT(OIL_Sys_JobCancel == g_SystemState.eCurrentState ||
           OIL_Sys_JobActive == g_SystemState.eCurrentState ||
           OIL_Sys_Inactive == g_SystemState.eCurrentState,
           "job_exit entered in invalid state");

  GG_SHOW(GG_SHOW_OIL, "JobExit:\n");

  /* release resources */
  while (g_ulGGtiming_pagecount != 0)
  {
    /* wait - until all the pages have been output */
    OIL_RelinquishTimeSlice();
  }
  /*  free(g_pstCurrentJob);  */

  {
    if (!SwLeJobEnd())
    {
      /* Report this error */
      GG_SHOW(GG_SHOW_OIL, "job_exit: Failed to finish job \n");
    }
  }

  if(OIL_Sys_Inactive != g_SystemState.eCurrentState)
  {
    g_SystemState.eCurrentState = eNextState;
  }

  /* At this point RIPping must have completed and oil should have received data for all pages from the RIP*/
  g_pstCurrentJob->eJobStatus = OIL_Job_RipDone;

  /* keep the jobname safe for use in timing log before deleting job */
  strcpy(szJobName, g_pstCurrentJob->szJobName);

  /* Wait for all pages to be removed */
  while(g_pstCurrentJob->pPage!=NULL)
  {
    OIL_RelinquishTimeSlice();
  }

  /* check for incomplete pages which can be a result of job cancel */
  if (g_pstCurrentPage)
  {
    DeleteOILPage(g_pstCurrentPage);
    g_pstCurrentPage = 0;
  }

  if(event_Cancel_flag == TRUE)
  {
  	gpsInterpNotifyState(&gps_client, GPS_INTERP_STATE_FLUSHING);
	gpsFrameCancel(&gps_client,gps_frameid);
	gpsPlotCancel(&gps_client, PlotSet_plotid);	
	fin = GPS_INTERP_FIN_CANCEL;
  }
  
#ifndef PMS_OIL_MERGE_DISABLE_JS

 /***********Call to gpsflush and gpswrite for buffer1***************************/
if(*buffer1!=NULL)
{
if(host_outBuff)
	{


GPSSoutFlushretval=GPS_SoutFlush(host_outBuff);
    if(GPSSoutFlushretval==0)
    {
    	printf("GPS_SoutFlush : Success\n");
	
    }
    else
    {
    	printf("GPS_SoutFlush : Failed\n");
    }
}

len=0;
for(i=0;buffer1[i]!='\0';i++)
len++;
printf(" 1 size of hostbuff = %d\n",sizeof(host_outBuff));
 GPSSoutWriteretval=GPS_SoutWrite(host_outBuff,buffer1,len,GPS_HOST_NONBLOCK);
    if(GPSSoutWriteretval >= 0)
    {
    	printf("GPS_SoutWrite : Success\n");
	
    }
    else
    {
    	printf("GPS_SoutWrite : Failed\n");
    }


}
/***********Call to gpsflush and gpswrite for buff2***************************/
if(*buffer2!=NULL)
{
if(host_outBuff)
	{

GPSSoutFlushretval=GPS_SoutFlush(host_outBuff);
    if(GPSSoutFlushretval==0)
    {
    	printf("GPS_SoutFlush : Success\n");
	
    }
    else
    {
    	printf("GPS_SoutFlush : Failed\n");
    }
}
printf(" 2 size of hostbuff = %d\n",sizeof(host_outBuff));
len=0;
for(i=0;buffer2[i]!='\0';i++)
len++;


 GPSSoutWriteretval=GPS_SoutWrite(host_outBuff,buffer2,len,GPS_HOST_NONBLOCK);
    if(GPSSoutWriteretval >= 0)
    {
    	printf("GPS_SoutWrite : Success\n");
	
    }
    else
    {
    	printf("GPS_SoutWrite : Failed\n");
    }


}

/***********Call to gpsflush and gpswrite for buff3***************************/


if(*buffer3!=NULL)
{
if(host_outBuff)
	{


GPSSoutFlushretval=GPS_SoutFlush(host_outBuff);
    if(GPSSoutFlushretval==0)
    {
    	printf("GPS_SoutFlush : Success\n");
	    }
    else
    {
    	printf("GPS_SoutFlush : Failed\n");
    }
}
printf(" 3 size of hostbuff = %d\n",sizeof(host_outBuff));


len=0;
for(i=0;buffer3[i]!='\0';i++)
len++;


 GPSSoutWriteretval=GPS_SoutWrite(host_outBuff,buffer3,len,GPS_HOST_NONBLOCK);
    if(GPSSoutWriteretval >= 0)
    {
    	printf("GPS_SoutWrite : Success\n");
	
    }
    else
    {
    	printf("GPS_SoutWrite : Failed\n");
    }

}

/***********Call to gpsflush and gpswrite for buff4***************************/
if(*buffer4!=NULL)
{
if(host_outBuff)
	{


GPSSoutFlushretval=GPS_SoutFlush(host_outBuff);
    if(GPSSoutFlushretval==0)
    {
    	printf("GPS_SoutFlush : Success\n");
	    }
    else
    {
    	printf("GPS_SoutFlush : Failed\n");
    }
}
printf(" 4 size of hostbuff = %d\n",sizeof(host_outBuff));

len=0;
for(i=0;buffer4[i]!='\0';i++)
len++;


 GPSSoutWriteretval=GPS_SoutWrite(host_outBuff,buffer4,len,GPS_HOST_NONBLOCK);
    if(GPSSoutWriteretval >= 0)
    {
    	printf("GPS_SoutWrite : Success\n");
		
    }
    else
    {
    	printf("GPS_SoutWrite : Failed\n");
    }


}
/***********Call to gpsflush and gpswrite for buff5***************************/

if(*buffer5!=NULL)
{
if(host_outBuff)
	{


GPSSoutFlushretval=GPS_SoutFlush(host_outBuff);
    if(GPSSoutFlushretval==0)
    {
    	printf("GPS_SoutFlush : Success\n");
    }
    else
    {
    	printf("GPS_SoutFlush : Failed\n");
    }
}
printf(" 5 size of hostbuff = %d\n",sizeof(host_outBuff));

len=0;
for(i=0;buffer5[i]!='\0';i++)
len++;


 GPSSoutWriteretval=GPS_SoutWrite(host_outBuff,buffer5,len,GPS_HOST_NONBLOCK);
    if(GPSSoutWriteretval >= 0)
    {
    	printf("GPS_SoutWrite : Success\n");
	
    }
    else
    {
    	printf("GPS_SoutWrite : Failed\n");
    }



}



 /***********Call to GpsPlotclose***************************/
/* AppendJob = True. Don't close the Output channel, next job uses same. 
   AppendJob = False. Close the Output channel, job ends here.
*/
if(AppendJob == 0)
{
  GPSPlotCloseretval = GPS_PlotClose(gps_client, PlotSet_plotid);
  if(GPSPlotCloseretval>=0)
  {
	printf("GPS_PlotClose : Success\n");
  }
  else
  {
	printf("GPS_PlotClose : Failed\n");
  }
  PlotSet_plotid = -1;
   /***********Call to GpsSinclose***************************/
  if (host_inBuff || host_outBuff)
  {

    GPSSinCloseretval=GPS_SinClose(host_inBuff);
    if(GPSSinCloseretval==0)
    {
		printf("GPS_SinClose : Success\n");
		host_inBuff = NULL;
    }
    else
    {
     	printf("GPS_SinClose : Failed\n");
    }
   /***********Call to GpsSoutclose***************************/

    GPSSoutCloseretval=GPS_SoutClose(host_outBuff);
    if(GPSSoutCloseretval==0)
    {
    	printf("GPS_SoutClose : Success\n");
		host_outBuff = NULL;
    }
    else
    {
    	printf("GPS_SoutClose : Failed\n");
    }

   /***********Call to GpsInterpfinishProcdata***************************/

    GPS_InterpFinishProcData(gps_client, 1, fin, uel_found);
  }
  else
  {
      gpsInterpFinishTestprint(gps_client, jobid);
  } 
   /*************Call to gpsInterpNotifyState()*************************************/
        GPS_InterpNotifyState(gps_client, GPS_INTERP_STATE_FLUSHING); // Review - it should be GPS_INTERP_STATE_IDLE ?
}
#endif
  /* Delete the job */
  DeleteOILJob(g_pstCurrentJob->uJobId);
  g_pstCurrentJob = NULL;

  /* Reconfigure the features */
  g_ConfigurableFeatures.g_ePaperSelectMode = g_NextJobConfiguration.g_ePaperSelectMode;
  g_ConfigurableFeatures.g_uGGShow = g_NextJobConfiguration.g_uGGShow;


  /* print out the timing data */
  if(g_bLogTiming)
  {
    GGglobal_timing_dumplog((unsigned char*)szJobName);
  }

  /* reset data for next job */
  GGglobal_timing(SW_TRACE_OIL_RESET, 0);

    current_pdlid=0;
    g_tJob.eTestPage = OIL_TESTPAGE_NONE;
  /* return TRUE if now in requested state */
  return (g_SystemState.eCurrentState == eNextState);
}
/**
 * \brief Submit a fully rendered page to the PMS.
 *
 * This function is called once the OIL page is completely rendered.  Before submitting 
 * the page to the PMS, various conditions are checked.  The page will not be submitted 
 * if it is outside the range of pages to be printed for the job, or if it a blank page 
 * and blank page suppression has been activated.  A page which is does not pass these
 * tests is deleted.
 *
 * If fewer planes have been created for the page than expected for the colorant family, blank
 * planes will be generated as required, or the job forced to monochrome in the case of a 
 * CMYK job with blank color planes, if this functionality has been activated.
 *
 * Finally, if the page is to be submitted to the PMS, the completed OIL page structure 
 * is used to create a PMS page, which is passed to PMS_CheckinPage().  If the page is 
 * not to be submitted to the PMS, then the page is deleted immediately as the PMS
 * will not call the OIL function to indicate that the page has been output.
 */
void SubmitPageToPMS(void)
{
  OIL_TyPage **ptLastPage;
#ifdef PMS_OIL_MERGE_DISABLE
  PMS_TyPage *ptPMSPage;
#endif
  int bSubmitPage = TRUE;
#ifndef PMS_OIL_MERGE_DISABLE_JS
   gps_pageinfo_t pageinfo;
 int    GPSFramePrintretval;

int FP_force=GPS_PRINT_NORMAL;
 int    FP_frameid=1;
#endif
#ifdef DIRECTPRINTPCLOUT
  PMS_TySystem ptPMSSysInfo;
#endif
  g_pstCurrentJob->uPagesParsed++;
#ifdef DIRECTPRINTPCLOUT
  PMS_GetSystemInfo(&ptPMSSysInfo , PMS_CurrentSettings);
  if((ptPMSSysInfo.eOutputType == PMS_DIRECT_PRINT) || (ptPMSSysInfo.eOutputType == PMS_DIRECT_PRINTXL))
  {
    GGglobal_timing(SW_TRACE_OIL_CHECKIN, 0);
    GGglobal_timing(SW_TRACE_OIL_PAGEDONE, 0);
    return;
  }
#endif
  OIL_ProbeLog(SW_TRACE_OIL_SUBMITPAGETOPMS, SW_TRACETYPE_ENTER, (intptr_t)g_pstCurrentJob->uPagesParsed);

#ifdef USE_PJL
  bSubmitPage = OIL_PjlShouldOutputPage(g_pstCurrentJob->uPagesParsed, g_pstCurrentJob);
#endif

#ifndef PMS_OIL_MERGE_DISABLE_JS
//   memset(&pageinfo, 0, sizeof(pageinfo));
#endif

  if (bSubmitPage)
  {
    if ((!g_pstCurrentPage) || (g_pstCurrentPage->nBlankPage == TRUE))
    {
      if (g_pstCurrentJob->bSuppressBlank == TRUE)
      {
        /* if blank pages are to be suppressed, then do not create the blank page. */
        bSubmitPage = FALSE;
      }
      else
      {
        /* we have no CurrentPage - because this is a blank page */
        GG_SHOW(GG_SHOW_OIL, "Blank page detected: create a blank page. \n ");
        g_pstCurrentPage = CreateOILBlankPage(g_pstCurrentPage, NULL);
        if(!g_pstCurrentPage)
        {
          /* There was some problem creating the blank page. Already would have been asserted */
          return;
        }
      }
    }
  }

  if (bSubmitPage)
  {
    g_pstCurrentPage->pstJob = g_pstCurrentJob;

    /* attach the page at the tail of the page list of current job */
    ptLastPage = &g_pstCurrentJob->pPage;
    while(*ptLastPage != NULL)
    {
        ptLastPage = (OIL_TyPage **)&(*ptLastPage)->pNext;
    }
    *ptLastPage = g_pstCurrentPage;
    g_pstCurrentJob->uPagesToPrint++;
    g_pstCurrentJob->uPagesInOIL++;

#ifdef PMS_OIL_MERGE_DISABLE
    /* create PMS page from the oil page */
    ptPMSPage = CreatePMSPage(g_pstCurrentPage);
    g_pstCurrentPage->ptPMSpage = ptPMSPage ;
#endif
    GGglobal_timing(SW_TRACE_OIL_CHECKIN, g_pstCurrentJob->uPagesToPrint);

    /* There is no data attached to the page structure when using the push band delivery
       methods. Instead the checksum is computed in the SubmitBandToPMS function above. */
    if(g_bPageChecksum && 
      (g_ConfigurableFeatures.eBandDeliveryType != OIL_PUSH_BAND) &&
      (g_ConfigurableFeatures.eBandDeliveryType != OIL_PUSH_BAND_DIRECT_SINGLE) &&
      (g_ConfigurableFeatures.eBandDeliveryType != OIL_PUSH_BAND_DIRECT_FRAME)
      )
    {
      uint8 *px;
      uint32 uBand;
      uint32 uColorant;
      uint32 uPageChecksum = 0;
      uint32 uBandSizeChecksum = 0;

      /* Record start of checksum calculation */
      OIL_ProbeLog(SW_TRACE_OIL_PAGECHECKSUM, SW_TRACETYPE_ENTER, (intptr_t)uPageChecksum);

      for(uColorant = 0; uColorant < OIL_MAX_PLANES_COUNT; uColorant++)
      {
#ifdef PMS_OIL_MERGE_DISABLE
        if(ptPMSPage->atPlane[uColorant].ePlaneColorant != PMS_INVALID_COLOURANT)
        {
          for(uBand = 0; uBand < ptPMSPage->atPlane[uColorant].uBandTotal; uBand++)
          {
            for(px = (uint8 *)ptPMSPage->atPlane[uColorant].atBand[uBand].pBandRaster; 
                px < (uint8 *)(ptPMSPage->atPlane[uColorant].atBand[uBand].pBandRaster + ptPMSPage->atPlane[uColorant].atBand[uBand].cbBandSize);
                px++)
            {
              uPageChecksum+=*px;
            }
            uBandSizeChecksum+=ptPMSPage->atPlane[uColorant].atBand[uBand].cbBandSize;
          }
        }
#else
        if(g_pstCurrentPage->atPlane[uColorant].ePlaneColorant != OIL_InvalidColor)
        {
          for(uBand = 0; uBand < g_pstCurrentPage->atPlane[uColorant].uBandTotal; uBand++)
          {
            for(px = (uint8 *)g_pstCurrentPage->atPlane[uColorant].atBand[uBand].pBandRaster; 
                px < (uint8 *)(g_pstCurrentPage->atPlane[uColorant].atBand[uBand].pBandRaster + g_pstCurrentPage->atPlane[uColorant].atBand[uBand].cbBandSize);
                px++)
            {
              uPageChecksum+=*px;
            }
            uBandSizeChecksum+=g_pstCurrentPage->atPlane[uColorant].atBand[uBand].cbBandSize;
          }
        }
#endif
      }

      GG_SHOW(GG_SHOW_CHECKSUM, "Raster checksum: %d, 0x%08X\n", g_pstCurrentJob->uPagesToPrint, uPageChecksum);
      GG_SHOW(GG_SHOW_CHECKSUM, "Band size checksum: %d, 0x%08X\n", g_pstCurrentJob->uPagesToPrint, uBandSizeChecksum);

      /* Record end of checksum calculation */
      OIL_ProbeLog(SW_TRACE_OIL_PAGECHECKSUM, SW_TRACETYPE_EXIT, (intptr_t)uPageChecksum);
      /* Record checksum value */
      OIL_ProbeLog(SW_TRACE_OIL_PAGECHECKSUM, SW_TRACETYPE_MARK, (intptr_t)uPageChecksum);
    }

    /* checkin the page */
#ifdef PMS_OIL_MERGE_DISABLE
    PMS_CheckinPage(ptPMSPage);
#else
#ifdef PMS_OIL_MERGE_DISABLE_JS
    PMS_CheckinPage(g_pstCurrentPage);
#else
    /*PMS_CheckinPage(ptPMSPage);*/
    /***************************Call to gpsFramePrint***********************************/

	GPSFramePrintretval = GPS_FramePrint(gps_client, FP_frameid, &pageinfo, FP_force);
	if(!GPSFramePrintretval)
	{
		printf("GPS_FramePrint : Success\n");
	}
	else
	{
		printf("GPS_FramePrint : Failed\n");
	}
#endif
#endif

    /* ready to start the page */
    GGglobal_timing(SW_TRACE_OIL_PAGESTART, 0);
  }
  else if (g_pstCurrentPage)
  {
    DeleteOILPage(g_pstCurrentPage);
    g_pstCurrentPage = NULL;
  }

  OIL_ProbeLog(SW_TRACE_OIL_SUBMITPAGETOPMS, SW_TRACETYPE_EXIT, (intptr_t)g_pstCurrentJob->uPagesParsed);
}