Beispiel #1
0
pcp(char *source, char *destpath)
{
    char *srcBuf, *dstBuf;
    uint32_t srcSize,dataOffset,dstSize,dstDataOffset;
    char srcMd5sig[36],dstMd5sig[36];
    int status;

    if ((source == NULL) || (destpath == NULL))
    {
        printf("Usage:  pcp \"dev:source_filename\",\"dev:dest_filename\"\n");
        printf("        where 'dev' can be: ffs - controller flash, rsh - host, icat - iCAT ISFlash]\n");
        printf("   e.g. pcp \"rsh:/home/vnmr1/myfile.txt\",\"ffs:myfile.txt\"\n");
        printf("        pcp \"rsh:/home/vnmr1/myfile.txt\",\"icat:myfile.txt\"\n");
        printf("        pcp \"ffs:myfile.txt\",\"rsh:/home/vnmr1/myfile.txt\"\n");
        printf("        pcp \"icat:myfile.txt\",\"ffs:myfile.txt\"\n");
        printf("   Note some devices may not be available on all controllers\n\n");
        return(-1);
    }

    srcBuf = vsload(source, &srcSize, &dataOffset );
    // printf("pcp: src: '%s', size: %ld, offset: %ld, Buff: 0x%lx\n", source,srcSize,dataOffset,srcBuf);
    if (srcBuf == NULL)
    {
        printf("Copy failed.\n");
        return -1;
    }

    status = vswrite(destpath, (srcBuf + dataOffset), srcSize);
    // printf("pcp: status: %d, dst: '%s', size: %ld, offset: %ld, Buff: 0x%lx\n", status, destpath,srcSize,dataOffset,(srcBuf+dataOffset));
    if (status != 0)
    {
        free(srcBuf);
        printf("Copy failed.\n");
        return -1;
    }

    dstBuf = vsload(destpath, &dstSize, &dstDataOffset );
    // printf("pcp: vsload: dst: '%s', size: %ld, offset: %ld, Buff: 0x%lx\n", destpath,dstSize,dstDataOffset,dstBuf);
    if (dstBuf == NULL)
    {
        free(srcBuf);
        printf("Copy failed.\n");
        return -1;
    }
    calcMd5((srcBuf + dataOffset), srcSize, srcMd5sig);
    calcMd5((dstBuf+dstDataOffset), dstSize, dstMd5sig);
    // printf("MD5 src: '%s', dst: '%s'\n",srcMd5sig,dstMd5sig);
    if ( strcmp(srcMd5sig,dstMd5sig) != 0)
    {
        free(srcBuf);
        free(dstBuf);
        printf("Verification failed.\n");
        printf("Copy failed.\n");
        return -1;
    }
    printf("Copy Successful.\n");
    free(srcBuf);
    free(dstBuf);
    return 0;
}
Beispiel #2
0
static void ficlIcatFileWrite(ficlVm *vm)
{
  uint32_t len;
  char *buffer, md5[36];
  char filename[FICL_COUNTED_STRING_MAX];
  ficlCountedString *counted = (ficlCountedString *)filename;

  FICL_STACK_CHECK(vm->dataStack,2,0);
  len = ficlStackPopUnsigned(vm->dataStack);
  buffer = (char *) ficlStackPopPointer(vm->dataStack);
  calcMd5(buffer,len,md5);
  ficlVmGetString(vm, counted, '\n');
  writeIsfFile(FICL_COUNTED_STRING_GET_POINTER(*counted),md5,len,buffer,1);
}
Beispiel #3
0
static void ficlIcatPFileWrite(ficlVm *vm)
{
  uint32_t len;
  char *buffer, md5[36];
  uint32_t filename_len;
  char *filename;

  FICL_STACK_CHECK(vm->dataStack,2,0);
  filename_len = ficlStackPopUnsigned(vm->dataStack);
  filename = (char *) ficlStackPopPointer(vm->dataStack);
  len = ficlStackPopUnsigned(vm->dataStack);
  buffer = (char *) ficlStackPopPointer(vm->dataStack);
  calcMd5(buffer,len,md5);
  writeIsfFile(filename,md5,len,buffer,1);
}
Beispiel #4
0
isfmd5(char *filename)
{
    char md5sig[32 + 1];
    char *buffer;
    UINT32 len,offset;

    buffer = readIsfFile(filename, &len, &offset);
    if (buffer != NULL)
    {
       calcMd5((buffer + offset), len, md5sig);
       printf("%s  %s\n",md5sig,filename);
       free(buffer);
    }
    else
       printf("File '%s' not found.\n",filename);
}
Beispiel #5
0
/*
 * transfer an iCAT file from the controller's flash file system to the iCAT ISF
 * e.g. icat configuration files:  icat_config00.tbl, icat_config01.tbl, etc..
 *  GMB
 */
int transferFile2Icat( char *filename )
{
   char md5sig[32 + 1];
   char md5sig2[32 + 1];
   char name[36], md5[36];
   int result, ret, di;
   unsigned long size, nSize, sizeBytes, len;
   int tableIndex,dataOffset,status,OverWriteYes;;
   char *xferfileBuffer;
   char *pFileExtType;

   OverWriteYes = 1;

   size = getFFSize(filename);
   IPRINT2(-1,"transferFile2Icat: File: '%s', Bytes: %ld\n",filename,size);
   if (size < 1)   /* return file not present */
    return(0);

   // need this extra length (headersize) for the readback  verification step
   xferfileBuffer = (char*) malloc(size + getISFFileHeaderSize() + 4); 
   if ( (xferfileBuffer == NULL) )
   {
      errLogRet(LOGIT,debugInfo, " ****** System Memory Malloc failed\n");
      return(-1);
   }

   /* transfer FFS into buffer */
   result =  cpFF2Buf(filename,xferfileBuffer,&nSize);
   if (result < 0) 
   {
      errLogRet(LOGIT,debugInfo, " ****** Read from Flash FileSystem failed\n");
      free(xferfileBuffer);
      return(-1);
   }

   /* ---------------------------*/
   /* calc MD5 checksum signiture */
   calcMd5(xferfileBuffer, nSize, md5sig);

   IPRINT3(1,"transferFile2Icat: file: '%s', nSize: %ld, md5: '%s'\n",
               filename,nSize, md5sig);

   // determine if this file is a FPGA bitstream *.bit or configuration file *.tbl
   pFileExtType = (char*) strrchr(filename,'.') + 1;
   IPRINT1(1,"transferFile2Icat: File Ext Type: '%s'\n",pFileExtType);
   tableIndex = extractIndex(filename);
   IPRINT1(1,"transferFile2Icat: tableIndex; %ld\n", tableIndex);
   // =======================================================================
   // Configuration table transfers
   //
   if ( (strcmp("tbl",pFileExtType) == 0) )
   {
      // =======================================================================
      // read conf file header from iCAT flash
      // If the file already exists on icat ISFlash don't re-copy to ISFlash
      tableIndex = getConfigTableByName(filename);  // no longer use index encoded in name, just find it.
      IPRINT2(-11,"transferFile2Icat: filename: '%s', tableIndex: %d\n", filename, tableIndex);
      if (tableIndex != -1)  // -1 means didn't find this named file
      {
         result = readConfigTableHeader(tableIndex, name, md5, (int*) &sizeBytes);
         if (result != -1)   // -1 == invalid table index, no file present
         {
             IPRINT2(1,"transferFile2Icat: 2cp md5: '%s'\n\t\t\t\t\t\t vs present md5: '%s'\n",
                      md5sig,md5);      
             ret = strcmp(md5sig, md5);
             if (ret == 0) 
             {
                IPRINT(-1,"transferFile2Icat: File already Present on Icat ISFlash\n\n");
                free(xferfileBuffer);
                return(0);
             }
         }
      }
      // =======================================================================
      result = writeIsfFile(filename, md5sig, nSize, xferfileBuffer, OverWriteYes);
      memset(xferfileBuffer,0,nSize);

      // now read it back and confirm proper writing to iCAT ISF
      len = nSize;
      // relocate file, there is no guarentee that same index was used.
      tableIndex = getConfigTableByName(filename);  // no longer use index encoded in name, just find it.
      IPRINT2(-11,"transferFile2Icat: filename: '%s', tableIndex: %d\n", filename, tableIndex);
      result = readConfigTable(tableIndex, name, md5, (UINT32*) &len, xferfileBuffer, (int*) &dataOffset);
      IPRINT4(-12,"transferFile2Icat() name: '%s', md5: '%s', len: %ld, dataOffset: %ld\n",name,md5,len,dataOffset);
   
   }
   // =======================================================================
   // iCAT FPAG file transfers
   //
   else if ( (strcmp("bit",pFileExtType) == 0) && ((tableIndex >= -1) && (tableIndex <= 1)) )
   {
      IPRINT3(1,"transferFile2Icat() bitstream: '%s', md5: '%s', len: %ld \n",
              filename,md5sig,nSize);
      // =======================================================================
      // read conf file header from iCAT flash
      // If file already exist on icat ISFlash don't re-copy to ISFlash
      if (tableIndex == -1)
         tableIndex = 0;
      result = readIcatFPGAHeader(tableIndex,name, md5, (int*)  &sizeBytes);
      if (result != -1)   // -1 == invalid table index, no file present
      {
          IPRINT2(1,"transferFile2Icat: 2cp md5: '%s'\n\t\t\t\t\t\t vs preset md5: '%s'\n",
                md5sig,md5);      
          ret = strcmp(md5sig, md5);
          if (ret == 0) 
          {
             IPRINT(-1,"transferFile2Icat: File already Present on Icat ISFlash\n\n");
	     free(xferfileBuffer);
             return(0);
          }
      }
      // =======================================================================
      // transfer FPGA bit-stream

      result = writeIcatFPGA(tableIndex, filename, md5sig, nSize, xferfileBuffer);
      memset(xferfileBuffer,0,nSize);
      // now read it back confirm proper writing to iCAT ISF
      len = nSize;
      result = readIcatFPGA(tableIndex, name, md5, (UINT32*) &len, xferfileBuffer);
      dataOffset = 0;   
   }
   /* calc MD5 checksum signiture */
   calcMd5((xferfileBuffer + dataOffset), len, md5sig2);
   IPRINT3(1,"transferFile2Icat: file: '%s', written/read md5: '%s'\n\t\t\t\t\t\t\t vs '%s'\n",
          filename, md5sig, md5sig2);

   ret = strcmp(md5sig, md5sig2);
   if (ret != 0) 
   {
      char errmsg[256];
      // failure on Primary or Seconadary iCAT FPGA image, must mark failure via a small file
      if ( (strcmp("bit",pFileExtType) == 0)  )
      {
          // do not alter format of string prior to '\n'
          sprintf(errmsg,"iCAT_DNA: 0x%llx \nImage failed to copy.",iCAT_DNA);
          if ( (tableIndex >= -1) && (tableIndex <= 0) ) 
          {
             createFailFile("pri_imagecp.fail",  errmsg);
             // deleting primary image is probably un-necessary , it's just not going to boot anymore
          }
          else
          {
             createFailFile("sec_imagecp.fail",  errmsg);
             isffpgadel(); // deleted secondary image
          }
          errLogRet(LOGIT,debugInfo, "transferFile2Icat(): '%s' iCAT FPGA image copy, failed.\n",filename);
      }
      else if ( (strcmp("tbl",pFileExtType) == 0) && ((tableIndex >= 0) && (tableIndex < 6)) )
      {  // maybe moot since we don't copy tables any more to the ISF flash
         isftbldel(tableIndex);	// delete table that failed to copy
      }

      errLogRet(LOGIT,debugInfo, "transferFile2Icat():  ****** ERROR: MD5 Checksum do NOT match\n");
      errLogRet(LOGIT,debugInfo, "transferFile2Icat():  True MD5 - '%s'\n",md5sig);
      errLogRet(LOGIT,debugInfo, "transferFile2Icat():  Calc MD5 - '%s'\n",md5sig2);
      free(xferfileBuffer);
      return(-1);
   }
   IPRINT(-1,"Transfer Succesful\n\n");
   free(xferfileBuffer);
   return 0;
}
Beispiel #6
0
int vswrite(char *filepath, char *buffer, uint32_t size )
{
    char *filename;
    int result;

    if (strncmp(ICAT_DEV_PREFIX,filepath,sizeof(ICAT_DEV_PREFIX)-1) == 0)
    {
        char md5sig[36],prefix[36];
        char tmpname[36],tmpmd5[36];
        int rfType,index,prefixlen,preindex,inuse,maxNumFiles;
        int maxSize;
        uint32_t tmplen;
        char *colonptr;

        index = 0;
        rfType = execFunc("getRfType", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        if ( rfType != 1 )
        {
            printf("icat not available on this controller\n");
            return -1;
        }
        colonptr = strstr(filepath,":");
        prefixlen = (int) (colonptr - filepath);
        strncpy(prefix,filepath,prefixlen);
        prefix[prefixlen]=0;
        index = execFunc("extractIndex",prefix, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        filename = colonptr + 1;
        maxNumFiles = execFunc("getISFMaxNumFiles", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        maxNumFiles = (maxNumFiles == -1) ? 5 : maxNumFiles;
        // note: index for new FFS layout will be -1 since it's not specified.
        if (index < (maxNumFiles - 1))   // really only useful for old ISF FFS layout
        {
            maxSize = execFunc("getISFFileMaxSize", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
            if (size > maxSize)
            {
                printf("file: '%s', size: %ld, exceeds max: %ld for icat file\n",filename,size,maxSize);
                return -1;
            }
        }
        calcMd5(buffer, size, md5sig);
        // check if the given index already has an file entry
        // inuse = execFunc("readConfigTableHeader",index, tmpname, tmpmd5, &tmplen,NULL, NULL, NULL, NULL);

        // make sure this file name is unique, or over writting a present file
        preindex = execFunc("getConfigTableByName",filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
        // printf("vswrite-icat: preindex: %d\n",preindex);
        // printf("vswrite-icat: preindex: %d, inuse: %d\n",preindex,inuse);
        // if ((preindex != -1) || (inuse != -1))// name was found
        if (preindex != -1) // name was found
        {
            /*
            if ( (preindex != index) && (preindex != -1) ) // name exist but not for this index
            {
                printf("file: '%s', is not unique, this name is already used by index: %d\n",filename,preindex);
                printf("Copy aborted. \n");
                return(-1);
            }
            else  // over-writting
            */
            {
                char answer[32];
                int led_id, chars;
                led_id = ledOpen(fileno(stdin),fileno(stdout),10);
                /*
                if (inuse != -1) // the given index is already in use
                {
                    printf("Overwite file '%s' ? (y or n) ? ",tmpname);
                }
                else
                {
                    printf("Overwite file? (y or n) ? ");
                }
                */
                printf("Overwite file? (y or n) ? ");

                chars = ledRead(led_id,answer,sizeof(answer));
                // printf("answer: %d -  '%s'\n",chars,answer);
                if (answer[0] == 'y')
                {
                    // int writeIsfFile(char *name, char *md5, UINT32 len, char *buffer, int overwrite)
                    result = execFunc("writeIsfFile", filename, md5sig, size, buffer, 1 , NULL, NULL, NULL);
                    // result = execFunc("writeConfigTable", index, filename, md5sig, size, buffer, NULL, NULL, NULL);
                    // printf("icat:file: result: %d, '%s', index: %d, md5: '%s', size: %ld, buff: 0x%lx\n", result, filename,index,md5sig,size,buffer);
                }
                else
                {
                    printf("Copy aborted. \n");
                    return(-1);
                }
            }
        }
        else
        {
            result = execFunc("writeIsfFile", filename, md5sig, size, buffer, 0 , NULL, NULL, NULL);
            // result = execFunc("writeConfigTable", index, filename, md5sig, size, buffer, NULL, NULL, NULL);
            // printf("icat:file: result: %d, '%s', index: %d, md5: '%s', size: %ld, buff: 0x%lx\n", result, filename,index,md5sig,size,buffer);
        }
        if (result == -2)
            printf("file: '%s', size: %ld, exceeds max: %ld for icat file\n",filename,size,maxSize);
        else if (result == -3)
            printf("No space left for file of %ld bytes\n",size);
    }
    else if (strncmp(FLASH_DEV_PREFIX,filepath,sizeof(FLASH_DEV_PREFIX)-1) == 0)
    {
        FFSHANDLE fileHdl;
        unsigned int cnt;
        uint32_t errorcode;
        uint32_t bufCnt;

        filename = filepath+sizeof(FLASH_DEV_PREFIX)-1;

        // printf("ffs:filename: '%s'\n",filename);
        /*  Check if file already exist on flash */
        if ((fileHdl = vfOpenFile(filename)) != 0)
        {
            char answer[32];
            int led_id, chars;
            led_id = ledOpen(fileno(stdin),fileno(stdout),10);
            printf("Overwite file? (y or n) ? ");
            chars = ledRead(led_id,answer,sizeof(answer));
            // printf("answer: %d -  '%s'\n",chars,answer);
            if (answer[0] == 'y')
            {
                /*  Close and delete file */
                sysFlashRW();
                vfAbortFile(fileHdl);
                sysFlashRO();    /* Flash to Read Only, via EBC  */
            }
            else /* option == 0 */
            {
                /*  Close file */
                vfCloseFile(fileHdl);
                printf("Copy aborted. \n");
                return(-1);
            }
            ledClose(led_id);
        }
        /* make flash writable, other wise an exception is thrown */
        sysFlashRW();

        /*  Create the file from scratch */
        fileHdl = vfCreateFile(filename, -1, -1, -1);
        if (fileHdl == 0)
        {
            errorcode = vfGetLastError();
            if (errorcode)
                vfFfsResult(filename);
            sysFlashRO();    /* Set Flash to Read Only, via EBC  */
            return(-1);
        }
        // unsigned long vfWriteFile(FFSHANDLE, unsigned char *, unsigned long, unsigned long *);
        errorcode = vfWriteFile(fileHdl, buffer, size, &bufCnt);
        if (errorcode != 0)
        {
            errorcode = vfGetLastError();
            if (errorcode)
                vfFfsResult(filename);
            /*  Close and delete file */
            vfAbortFile(fileHdl);
            sysFlashRO();    /* Flash to Read Only, via EBC  */
            return(-1);
        }
        if ( (bufCnt != size) )
        {
            printf("Incomplete write to flash, only %ld bytes of %ld bytes written.\n",
                   (unsigned long) bufCnt,size);
            /*  Close and delete file */
            vfAbortFile(fileHdl);
            sysFlashRO();    /* Flash to Read Only, via EBC  */
            return(-1);
        }
        vfCloseFile(fileHdl);
        sysFlashRO();    /* Set Flash to Read Only, via EBC  */
        result = 0;

        // printf("ffs:file: result: %d, '%s', size: %ld, buffer: 0x%lx\n",result, filename,size,buffer);
    }
    else
    {
        int fd,bytes;
        if (strncmp(NFS_DEV_PREFIX,filepath,sizeof(NFS_DEV_PREFIX)-1) == 0)
            filename = filepath+sizeof(NFS_DEV_PREFIX)-1;
        else
            filename = filepath;

        // printf("rsh:file: '%s'\n",filename);

        /* First check to see if the file system is mounted and the file     */
        /* can be opened successfully.                                       */
        fd = open(filename, O_CREAT | O_RDWR, 0644);
        if (fd < 0)
        {
            printf("rsh: '%s' could not be created\n",filename);
            return(-1);
        }
        bytes = write(fd,buffer,size);
        if (bytes != bytes)
        {
            printf("Incomplete write to host, only %ld bytes of %ld bytes written.\n",
                   (unsigned long) bytes,(long) size);
            close(fd);
            /*  Close and delete file */
            unlink(filename);
            return(-1);
        }
        close(fd);
        // printf("rsh:file: '%s', size: %ld, buffer: 0x%lx\n",filename,bytes,buffer);
        result = 0;
    }
    return result;
}
Beispiel #7
0
void CRecogResultMgr::GetRecogResult()
{
	bool bHasElectOmr = false;
	Poco::JSON::Array snArry;
	Poco::JSON::Array omrArry;
	Poco::JSON::Array electOmrArry;
	std::stringstream jsnSnString;
	std::stringstream jsnOmrString;
	std::stringstream jsnElectOmrString;
	Poco::JSON::Array jsnPaperArry;
	PAPER_LIST::iterator itPaper = _pPapers->lPaper.begin();
	for (int i = 0; itPaper != _pPapers->lPaper.end(); itPaper++, i++)
	{
		if ((*itPaper)->strMd5Key.empty())
		{
			std::string strStudentInfo = _pPapers->strPapersName + "_" + (*itPaper)->strStudentInfo;
			std::string strStudentKey = calcMd5(strStudentInfo);
			(*itPaper)->strMd5Key = strStudentKey;
		}

		Poco::JSON::Object jsnPaperSN;
		Poco::JSON::Array jsnSnDetailArry;
		SNLIST::iterator itSn = (*itPaper)->lSnResult.begin();
		for (; itSn != (*itPaper)->lSnResult.end(); itSn++)
		{
			Poco::JSON::Object jsnSnItem;
			jsnSnItem.set("sn", (*itSn)->nItem);
			jsnSnItem.set("val", (*itSn)->nRecogVal);

			Poco::JSON::Object jsnSnPosition;
			RECTLIST::iterator itRect = (*itSn)->lSN.begin();
			for (; itRect != (*itSn)->lSN.end(); itRect++)
			{
				jsnSnPosition.set("x", itRect->rt.x);
				jsnSnPosition.set("y", itRect->rt.y);
				jsnSnPosition.set("w", itRect->rt.width);
				jsnSnPosition.set("h", itRect->rt.height);
			}
			jsnSnItem.set("position", jsnSnPosition);
			jsnSnDetailArry.add(jsnSnItem);
		}
		jsnPaperSN.set("examId", _pPapers->nExamID);
		jsnPaperSN.set("subjectId", _pPapers->nSubjectID);
		jsnPaperSN.set("userId", _pPapers->nUserId);
		jsnPaperSN.set("teacherId", _pPapers->nTeacherId);
		jsnPaperSN.set("zkzh", (*itPaper)->strSN);
		jsnPaperSN.set("papers", _pPapers->strPapersName);
		if ((*itPaper)->strSN != "")
			jsnPaperSN.set("doubt", 0);
		else
			jsnPaperSN.set("doubt", 1);
		jsnPaperSN.set("studentKey", (*itPaper)->strMd5Key);
		jsnPaperSN.set("detail", jsnSnDetailArry);

		snArry.add(jsnPaperSN);

		Poco::JSON::Object jsnPaperOMR;
		Poco::JSON::Array jsnOmrArry;
		OMRRESULTLIST::iterator itOmr = (*itPaper)->lOmrResult.begin();
		for (; itOmr != (*itPaper)->lOmrResult.end(); itOmr++)
		{
			Poco::JSON::Object jsnOmr;
			jsnOmr.set("th", itOmr->nTH);
			jsnOmr.set("type", itOmr->nSingle + 1);
			jsnOmr.set("value", itOmr->strRecogVal);
			jsnOmr.set("value2", itOmr->strRecogVal2);
			jsnOmr.set("doubt", itOmr->nDoubt);
			jsnOmr.set("pageId", itOmr->nPageId);
			Poco::JSON::Array jsnPositionArry;
			RECTLIST::iterator itRect = itOmr->lSelAnswer.begin();
			for (; itRect != itOmr->lSelAnswer.end(); itRect++)
			{
				Poco::JSON::Object jsnItem;
				char szVal[5] = { 0 };
				sprintf_s(szVal, "%c", itRect->nAnswer + 65);
				jsnItem.set("val", szVal);
				jsnItem.set("x", itRect->rt.x);
				jsnItem.set("y", itRect->rt.y);
				jsnItem.set("w", itRect->rt.width);
				jsnItem.set("h", itRect->rt.height);
				jsnPositionArry.add(jsnItem);
			}
			jsnOmr.set("position", jsnPositionArry);
			jsnOmrArry.add(jsnOmr);
		}
		jsnPaperOMR.set("omr", jsnOmrArry);
		jsnPaperOMR.set("examId", _pPapers->nExamID);
		jsnPaperOMR.set("subjectId", _pPapers->nSubjectID);
		jsnPaperOMR.set("userId", _pPapers->nUserId);
		jsnPaperOMR.set("teacherId", _pPapers->nTeacherId);
		jsnPaperOMR.set("zkzh", (*itPaper)->strSN);
		jsnPaperOMR.set("nOmrAnswerFlag", (*itPaper)->nStandardAnswer);
		jsnPaperOMR.set("papers", _pPapers->strPapersName);
		jsnPaperOMR.set("studentKey", (*itPaper)->strMd5Key);
		omrArry.add(jsnPaperOMR);

		if ((*itPaper)->lElectOmrResult.size() > 0)
		{
			bHasElectOmr = true;
			Poco::JSON::Object jsnPaperElectOmr;
			Poco::JSON::Array jsnElectOmrArry;
			ELECTOMR_LIST::iterator itElectOmr = (*itPaper)->lElectOmrResult.begin();
			for (; itElectOmr != (*itPaper)->lElectOmrResult.end(); itElectOmr++)
			{
				Poco::JSON::Object jsnElectOmr;
				jsnElectOmr.set("paperId", i + 1);
				jsnElectOmr.set("doubt", itElectOmr->nDoubt);
				jsnElectOmr.set("th", itElectOmr->sElectOmrGroupInfo.nGroupID);
				jsnElectOmr.set("allItems", itElectOmr->sElectOmrGroupInfo.nAllCount);
				jsnElectOmr.set("realItem", itElectOmr->sElectOmrGroupInfo.nRealCount);
				jsnElectOmr.set("value", itElectOmr->strRecogResult);
				Poco::JSON::Array jsnPositionArry;
				RECTLIST::iterator itRect = itElectOmr->lItemInfo.begin();
				for (; itRect != itElectOmr->lItemInfo.end(); itRect++)
				{
					Poco::JSON::Object jsnItem;
					char szVal[5] = { 0 };
					sprintf_s(szVal, "%c", itRect->nAnswer + 65);
					jsnItem.set("val", szVal);
					jsnItem.set("x", itRect->rt.x);
					jsnItem.set("y", itRect->rt.y);
					jsnItem.set("w", itRect->rt.width);
					jsnItem.set("h", itRect->rt.height);
					jsnPositionArry.add(jsnItem);
				}
				jsnElectOmr.set("position", jsnPositionArry);
				jsnElectOmrArry.add(jsnElectOmr);
			}
			jsnPaperElectOmr.set("electOmr", jsnElectOmrArry);		//选做题结果
			jsnPaperElectOmr.set("examId", _pPapers->nExamID);
			jsnPaperElectOmr.set("subjectId", _pPapers->nSubjectID);
			jsnPaperElectOmr.set("userId", _pPapers->nUserId);
			jsnPaperElectOmr.set("teacherId", _pPapers->nTeacherId);
			jsnPaperElectOmr.set("zkzh", (*itPaper)->strSN);
			jsnPaperElectOmr.set("papers", _pPapers->strPapersName);
			jsnPaperElectOmr.set("studentKey", (*itPaper)->strMd5Key);
			electOmrArry.add(jsnPaperElectOmr);
		}
	}
	snArry.stringify(jsnSnString, 0);
	_strSnResult = jsnSnString.str();
	omrArry.stringify(jsnOmrString, 0);
	_strOmrResult = jsnOmrString.str();
	_bHasElectOmr = bHasElectOmr;
	if (bHasElectOmr)
	{
		electOmrArry.stringify(jsnElectOmrString, 0);
		_strElectOmrResult = jsnElectOmrString.str();
	}
}