예제 #1
0
/*! \brief Allow other threads to have a go
 *
 * UNIX/Linux
 *
*/
void PMS_RelinquishTimeSlice(void)
{
#ifdef _POSIX_PRIORITY_SCHEDULING
#ifndef LIBuClibc
  int nError;
  if(sched_yield()!=0)
  {
    nError = errno;
    printf("sched_yield failed %d\n", nError);
  }
#else /* LIBuClibc */
 PMS_Delay(5);
 #endif
 #else /* _POSIX_PRIORITY_SCHEDULING */
  /* sleep zero does nothing, sleep (1ms) instead */
  PMS_Delay(1);
#endif
}
예제 #2
0
/**
 * \brief Wrapper for open input buffer
 *
 */
int Input_Buffer_OpenDataStream(void)
{
//ARUN's IF 0
  //dataInBuffer = (gps_hostbuf_p *)malloc(26);
  /* dataInBuffer = (char *)malloc(26);*/
  /*dataInBuffer = "Test Buffer Using New Code";*/
  
    dataInBuffer = NULL;
     /*************Call to gpsSinOpen*************************************************/
    
    host_inBuff = GPS_SinOpen(gps_client,job_hostid_in);
	if(host_inBuff)
	{
		printf("GPS_SinOpen : Successful\n");
	}
	else
	{
		printf("GPS_SinOpen : Failed\n");
	}
    PMS_Delay(200);	
	if(host_inBuff)
	{
		printf("GPS_SinOpen : host_inBuff Successful\n");
        if(host_inBuff->_HostBuf)
        dataInBuffer = host_inBuff->_HostBuf->buf;
	}

  /*************Call to gpsSoutOpen*************************************************/

    host_outBuff = GPS_SoutOpen(gps_client,job_hostid_out);
    if(host_outBuff)
	{
		printf("GPS_SoutOpen : Successful\n");
	}
	else
	{
		printf("GPS_SoutOpen : Failed\n");
	}
	
    if(host_inBuff)
    //if(dataInBuffer)
    {
      return TRUE;
    }
//endif //ARUN's ENDIF
  return FALSE;
}
예제 #3
0
/**
 * \brief Wrapper for open input buffer
 *
 */
int Input_Buffer_OpenDataStream(void)
{
  
    dataInBuffer = NULL;
     /*************Call to gpsSinOpen*************************************************/
    
    host_inBuff = GPS_SinOpen(gps_client,job_hostid_in);
	if(host_inBuff)
	{
		printf("GPS_SinOpen : Successful\n");
	}
	else
	{
		printf("GPS_SinOpen : Failed\n");
	}
    PMS_Delay(200);	
	if(host_inBuff)
	{
		printf("GPS_SinOpen : host_inBuff Successful\n");
        if(host_inBuff->_HostBuf)
        dataInBuffer = host_inBuff->_HostBuf->buf;
	}

  /*************Call to gpsSoutOpen*************************************************/

    host_outBuff = GPS_SoutOpen(gps_client,job_hostid_out);
    if(host_outBuff)
	{
		printf("GPS_SoutOpen : Successful\n");
	}
	else
	{
		printf("GPS_SoutOpen : Failed\n");
	}
	
    if(host_inBuff)
    {
      return TRUE;
    }
  return FALSE;
}
예제 #4
0
/**
 * \brief Hot folder search.
 */
int HotFolder_Search()
{
  unsigned int filesize, filesize_last;
  char szDir[MAX_PATH];
  char szExt[6];
  void *hFind;
  FILE *pFile;
  int fd, i;
  char *p;
  struct stat buf;
  int bRescan = 0;

  strcpy(szDir, g_pPMSHotFolderPath);
  strcat(szDir, "\\*");
  do {
    hFind = PMS_Initiate_DirectorySearch(szDir);
    /* Find the first file in the directory */
    if(PMS_Run_DirectorySearch(g_pPMSHotFolderPath, hFind, (char*)&aszHotFolderFiles[0]))
    {
      /* There is a file, lets wait until its size is stable */
      PMS_Stop_DirectorySearch(hFind);
      bRescan = 0;
      filesize = 0;
      bVirtualFile = FALSE;
      do {
        filesize_last = filesize;
        /* wait 1 second to see if the file is complete */
        PMS_Delay(1000);
        pFile = fopen(aszHotFolderFiles[0], "r");
        if(!pFile) { /* probably because of an OS delayed remove or user removed file since the dir scan */
          filesize_last = filesize;
          bRescan = TRUE;
          break;
        } else {
          fd = fileno(pFile);
          fstat(fd, &buf);
          filesize = buf.st_size;
          fclose(pFile);
        }
      } while (filesize != filesize_last);

      if(bRescan) {
        continue; /* restart do loop to rescan directory */
      }

      /* now save the file info and open the file for input to the rip */
      bActiveFile = TRUE;

      /* check for a raw image file as we need to send PJL code */
      p = (char *)aszHotFolderFiles + strlen(aszHotFolderFiles[0]) ;
      i = 0;
      while(p--)
      {
        if(*p == '.'){
          strcpy(szExt, p);
          break;
        }
        if(++i >= (sizeof(szExt)-1)){
          strcpy(szExt, ".none");
          break;
        }
      }
      for(i = 0; i < (int)strlen(szExt);i++)
      {
        szExt[i] = (char)tolower(szExt[i]);
      }

      if((strcmp(szExt, ".tiff") == 0) || (strcmp(szExt, ".tif") == 0) ||
         (strcmp(szExt, ".jpeg") == 0) || (strcmp(szExt, ".jpg") == 0) ||
         (strcmp(szExt, ".jfif") == 0) || (strcmp(szExt, ".jif") == 0))
      {
        /* set up the PJL wrapper to define the file for ripping */
        sprintf(FileBuffer,"%s@PJL SET IMAGEFILE=\"%s\"\n%s", PJLStart, aszHotFolderFiles[0], PJLEnterLanguageImage);
        pFileBuffer = FileBuffer;
        bVirtualFile = TRUE;
        return TRUE;
      }
      else
      {
        /* set up file for file input */
        pHotFolderFiles[0] = (char*)&aszHotFolderFiles[0];
        pHotFolderFiles[1] = (char*)&aszHotFolderFiles[1];

        /* Reuse the file input method functions to process the file found */
        aszJobNames = (char**)&pHotFolderFiles;
        nJobs = 1;
        File_InitDataStream();
        File_OpenDataStream();
        return TRUE;
      }
    } else {
      /* No file to process */
      bRescan = FALSE;
    }
  } while (bRescan);

  /* No file to process this time */
  return FALSE;
}
예제 #5
0
/**
 * \brief Block until an input module has a connection.
 *
 * \todo Currently there is no priority override setting on input modules, so in thoery if a job in the hot
 *       folder might not get a chance to run if there are many pending socket connections available.
 *
 */
int PMS_IM_WaitForInput() 
{
	struct input_modules *pMods;
	int bWaitingForJob = 1;
	int nResult;

	/* If there are no input modules then return */
	if(!l_ptModules) {
		return FALSE;
	}

	while(bWaitingForJob) {

		if(g_tJob.eTestPage)
			return TRUE;
#ifdef PMS_OIL_MERGE_DISABLE_JS
		bWaitingForJob = 0; /* Assume all modules are only tried to open once... file on command line etc.
				       If socket, or hot folder or any other input that waits for a job then it will get set again. */

		for(pMods = l_ptModules; pMods; pMods = pMods->pNext) {
			/* Get a job */
			if(pMods->tInput.pfnOpenDataStream) {
				nResult = (*pMods->tInput.pfnOpenDataStream)();
				if(nResult > 0) {
					l_ptActive = pMods; /* l_ptActive is the connected module until PMS_CloseDataStream */
					return TRUE;
				} else if(nResult < 0) {
					/* Don't try this module again... used for files on command, could be used for a once only folder (sd card or similar) */
					pMods->tInput.pfnOpenDataStream = NULL; /* \todo This could be a bit tidier */
				} else {
					bWaitingForJob = 1; /* Try again in a bit */
				}
			}
		}
		PMS_Delay(200); /* /todo Is this delay reasonable? */
#else
		if(g_jobAvailable==1)
		{
			bWaitingForJob = 1; /* Assume all modules are only tried to open once... file on command line etc.
					       If socket, or hot folder or any other input that waits for a job then it will get set again. */
			for(pMods = l_ptModules; pMods; pMods = pMods->pNext) {
				/* Get a job */
				if(pMods->tInput.pfnOpenDataStream) {
					nResult = (*pMods->tInput.pfnOpenDataStream)();
					if(nResult > 0) {
						l_ptActive = pMods; /* l_ptActive is the connected module until PMS_CloseDataStream */
						bWaitingForJob=0;
						return TRUE;
					} else if(nResult < 0) {
						/* Don't try this module again... used for files on command, could be used for a once only folder (sd card or similar) */
						pMods->tInput.pfnOpenDataStream = NULL; /* \todo This could be a bit tidier */
					} else {
						bWaitingForJob = 1; /* Try again in a bit */
					}
				}
			}
		}
		else
		{ 
			bWaitingForJob=1;
		}

		PMS_Delay(1); /* /todo Is this delay reasonable? */
#endif
	}

	return FALSE;
}
예제 #6
0
/**
 * \brief Simulates the output
 *
 * This routine simulates the movement of paper in the engine.
 * The first part of the loop determines if a sheet can be lifted from a paper tray,
 * the second part determines if the sheet has reached the output tray.
 */
void PMSOutput(void * dummy)
{
  PMS_TyPage *ThisPage = NULL;    /* pointer the the current page being checked */
  PMS_TyPage LastPage;            /* pointer the the last sheet that was picked up */
  PMS_TyPageList *tmpPageList;    /* local pagelist pointer */
  unsigned int uCurrentPageGap;   /* the gap between sheet pickup */
  unsigned int uLastPickUp;       /* the time the last sheet was pickup from inout tray */
  unsigned int  uPagesInMotion;   /* the number of sheets travelling in the system */

  UNUSED_PARAM(void *, dummy);

  uCurrentPageGap = 0;
  uLastPickUp = 0;
  uPagesInMotion = 0;
  g_eJobState = PMS_Waiting_For_Page;

  /* loop until the RIP has quit */
  while(g_eJobState != PMS_AllJobs_Completed)  /* pages in motion OR RIP active */
  {
    /* keep a local copy of the pagelist for local manipulation */
    tmpPageList = g_pstPageList;

    if(g_tSystemInfo.uUseEngineSimulator)
    {
      /* small delay to prevent total processor consumption */
      PMS_Delay(PAGECHECK_FREQUENCY);
    }
    else if(tmpPageList==NULL)
    {
      /* wait for a page to arrive */
      PMS_WaitOnSemaphore_Forever(g_semPageQueue);
    }

    /* walk through all the pages */
    while (tmpPageList!=NULL)
    {
      ThisPage = tmpPageList->pPage;
      if(g_tSystemInfo.uUseEngineSimulator)
        PMS_Delay(PAGECHECK_FREQUENCY);

      /* is there a page waiting to start travelling */
      if (ThisPage->eState==PMS_CHECKEDIN)
      {
        /* work out the gap between last page and this page */
        uCurrentPageGap = EngineGetInterpageGap(ThisPage, &LastPage);

        /* has enough time passed since the last sheet pickup */
        if(PMS_TimeInMilliSecs() > (uLastPickUp + uCurrentPageGap))
        {
          /* pick up sheet, mark as printing */
          ThisPage->eState = PMS_PRINTING;
          ThisPage->ulPickupTime = PMS_TimeInMilliSecs();
          ThisPage->ulOutputTime = ThisPage->ulPickupTime + EngineGetTravelTime(g_pstPageList->pPage);
          uPagesInMotion++;

          /* PMS_SHOW("Pickup Sheet: %d - output: %d\n", ThisPage->ulPickupTime, ThisPage->ulOutputTime); */

          /* record some stats about this page incase next page is different a requires a stall in paper path */
          LastPage.uTotalPlanes = ThisPage->uTotalPlanes;

          /* record pickup time in global */
          uLastPickUp = PMS_TimeInMilliSecs();
        }
        break;
      }

      /* check sheets that are printing */
      if (ThisPage->eState==PMS_PRINTING)
      {
        /* has a sheet reached output bin */
        if(PMS_TimeInMilliSecs() > (ThisPage->ulOutputTime))
        {
          /* print sheet */
          PrintPage(ThisPage);
          ThisPage->eState = PMS_COMPLETE;

          /* PMS_SHOW("Output Sheet: %d\n", PMS_TimeInMilliSecs()); */

          /* send page done at this point*/
          OIL_PageDone(ThisPage);

          /* remove sheet from system, RemovePage is protected against other threads */
          RemovePage(ThisPage);
          uPagesInMotion--;

          /* page list modified so break out and start again */
          break;
        }
      }

      /* move onto the next page */
      tmpPageList = tmpPageList->pNext;
    }

    if(uPagesInMotion == 0)
    {
        /* set the job state to indicate pms is waiting for next page. */
        g_eJobState = PMS_Waiting_For_Page;
    }
    else
    {
        /* set the job state to indicate pms has received a page and is processing it. */
        g_eJobState = PMS_Page_In_Progress;
    }

    /* if RIP has finished ripping and page list is empty means all jobs are printed */
    if((g_eRipState == PMS_Rip_Finished) && (g_pstPageList == NULL))
    {
      g_eJobState = PMS_AllJobs_Completed;
    }
  }
  return;
}