, bError=> , nErrId=> , hFile=> ); IF NOT(fbFileOpen[0].bBusy) AND NOT(fbFileOpen[0].bError) THEN fbFileOpen[0](bExecute:= FALSE); iSeq := iSeq + 1; ELSIF fbFileOpen[0].bError THEN fbFileOpen[0](bExecute:= FALSE); iExceptionSeq := iSeq; iSeq := 999; END_IF 2: (* Open Destination file *) fbFileOpen[1](sNetId:= sFileTargetNetId, (* Access target id *) sPathName:= sFilePathDestination, (* Access Path *) nMode:= FOPEN_MODEBINARY OR FOPEN_MODEWRITE, (* Binary Format & Write Mode & Overrite contents *) ePath:= PATH_GENERIC, bExecute:= TRUE, tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> , hFile=> ); IF NOT(fbFileOpen[01].bBusy) AND NOT(fbFileOpen[1].bError) THEN fbFileOpen[1](bExecute:= FALSE); iSeq := iSeq + 1; ELSIF fbFileOpen[1].bError THEN fbFileOpen[1](bExecute:= FALSE); iExceptionSeq := iSeq; iSeq := 999; END_IF 3: (* Seek to Start position *) nGetSeeker := SIZEOF(PRG_DatFileCreat.DatHeader); (* Give File seeker position *) nPutSeeker := 0; (* Put seeker from 0 *) fbFileSeek[0](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[0].hFile, nSeekPos:= nGetSeeker, (* Seek to record start position *) eOrigin:= SEEK_SET, bExecute:= TRUE, tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> ); IF NOT(fbFileSeek[0].bBusy) AND NOT(fbFileSeek[0].bError) THEN fbFileSeek[0](bExecute:= FALSE); iSeq := 10; ELSIF fbFileSeek[0].bError THEN fbFileSeek[0](bExecute:= FALSE); iExceptionSeq := iSeq; iSeq := 999; END_IF 10: (* Get Data *) fbFileRead[0](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[0].hFile, pReadBuff:= ADR(GetBuffer), cbReadLen:= SIZEOF(PRG_DatFileCreat.DatAcqBlock), (* Get size = define sizeof(nAcquisitionBlock) *) bExecute:= TRUE, tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> , cbRead=> , bEOF=> ); IF NOT(fbFileRead[0].bBusy) AND NOT(fbFileRead[0].bError) THEN IF fbFileRead[0].cbRead <> fbFileRead[0].cbReadLen THEN (* Check for act read len mach or not *) fbFileRead[0](bExecute:= FALSE); iExceptionSeq := iSeq; iSeq := 888; ELSE fbFileRead[0](bExecute:= FALSE); iSeq := iSeq + 1; END_IF IF fbFileRead[0].bEOF THEN (* meet EoF of source file *) fbFileRead[0](bExecute:= FALSE); iSeq := 50; (* goto close sequence *) END_IF ELSIF fbFileRead[0].bError THEN fbFileRead[0](bExecute:= FALSE); iExceptionSeq := iSeq; iSeq := 999; END_IF 11: (* Decode Data into PutBuffer *) (* Decord layout = stAcquisitionData *) pPutPointer := ADR(PutBuffer); (* Reset pointer to begin *) FOR i := 0 TO nAcquisitionBlock BY 1 DO pMountAcuData := ADR(GetBuffer) + (i * SIZEOF(pMountAcuData^)); pPutPointer^ := DCTIME_TO_STRING(pMountAcuData^.nDcTimeStamp); (* First Info , DC TimeStamp *) pPutPointer^ := CONCAT(pPutPointer^ , ','); pPutPointer := pPutPointer + Len(pPutPointer^); (* Shift pointer to next Info *) pPutPointer^ := DINT_TO_STRING(pMountAcuData^.AIN0); (* Further Acq Data *) pPutPointer^ := CONCAT(pPutPointer^ , ','); pPutPointer := pPutPointer + Len(pPutPointer^); (* Shift pointer to next Info *) pPutPointer^ := DINT_TO_STRING(pMountAcuData^.AIN1); (* Further Acq Data *) pPutPointer^ := CONCAT(pPutPointer^ , ','); pPutPointer := pPutPointer + Len(pPutPointer^); (* Shift pointer to next Info *) pPutPointer^ := DINT_TO_STRING(pMountAcuData^.AIN2); (* Further Acq Data *) pPutPointer^ := CONCAT(pPutPointer^ , ','); pPutPointer := pPutPointer + Len(pPutPointer^); (* Shift pointer to next Info *) pPutPointer^ := DINT_TO_STRING(pMountAcuData^.AIN3); (* Further Acq Data *) pPutPointer^ := CONCAT(pPutPointer^ , ','); pPutPointer := pPutPointer + Len(pPutPointer^); (* Shift pointer to next Info *) pPutPointer^ := UINT_TO_STRING(pMountAcuData^.ADC_nSample); (* Further Acq Data *) pPutPointer^ := CONCAT(pPutPointer^ , ','); pPutPointer := pPutPointer + Len(pPutPointer^); (* Shift pointer to next Info *) pPutPointer^ := UINT_TO_STRING(pMountAcuData^.ECAT_IRQ_Counter); (* Further Acq Data *) pPutPointer^ := CONCAT(pPutPointer^ , ','); pPutPointer := pPutPointer + Len(pPutPointer^); (* Shift pointer to next Info *) pPutPointer^ := UINT_TO_STRING(pMountAcuData^.ECAT_SYNC0_Counter); (* Further Acq Data *) pPutPointer^ := CONCAT(pPutPointer^ , ','); pPutPointer := pPutPointer + Len(pPutPointer^); (* Shift pointer to next Info *) pPutPointer^ := UINT_TO_STRING(pMountAcuData^.ECAT_SYNC1_Counter); (* Further Acq Data *) pPutPointer^ := CONCAT(pPutPointer^ , '$0D'); pPutPointer^ := CONCAT(pPutPointer^ , '$0A'); pPutPointer := pPutPointer + Len(pPutPointer^); (* Shift pointer to next Info *) END_FOR nGetSeeker := nGetSeeker + SIZEOF(PRG_DatFileCreat.DatAcqBlock); //nPutSeeker := nPutSeeker + (pPutPointer - ADR(PutBuffer)); iSeq := iSeq + 1; 12: fbFileWrite[1](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[1].hFile, pWriteBuff:= ADR(PutBuffer), cbWriteLen:= pPutPointer - ADR(PutBuffer), bExecute:= TRUE, tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> , cbWrite=> ); IF NOT(fbFileWrite[1].bBusy) AND NOT(fbFileWrite[1].bError) THEN fbFileWrite[1](bExecute:= FALSE); nPutSeeker := nPutSeeker + (pPutPointer - ADR(PutBuffer)); iSeq := iSeq + 1; ELSIF fbFileWrite[1].bError THEN fbFileWrite[1](bExecute:= FALSE); iExceptionSeq := iSeq; iSeq := 999; END_IF 13: (* Seek both file *) fbFileSeek[0](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[0].hFile, nSeekPos:= nGetSeeker, (* Seek to record start position *) eOrigin:= SEEK_SET, bExecute:= TRUE, tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> ); fbFileSeek[1](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[1].hFile, nSeekPos:= nPutSeeker, (* Seek to record start position *) eOrigin:= SEEK_SET, bExecute:= TRUE, tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> ); IF (NOT(fbFileSeek[0].bBusy) AND NOT(fbFileSeek[0].bError)) AND (NOT(fbFileSeek[1].bBusy) AND NOT(fbFileSeek[1].bError)) THEN fbFileSeek[0](bExecute:= FALSE); fbFileSeek[1](bExecute:= FALSE); iSeq := 10; ELSIF fbFileSeek[0].bError OR fbFileSeek[1].bError THEN fbFileSeek[0](bExecute:= FALSE); fbFileSeek[1](bExecute:= FALSE); iExceptionSeq := iSeq; iSeq := 999; END_IF 50: fbFileClose[0](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[0].hFile, bExecute:= TRUE, tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> ); fbFileClose[1](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[1].hFile, bExecute:= TRUE, tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> ); IF (NOT(fbFileClose[0].bBusy) AND NOT(fbFileClose[0].bError)) AND (NOT(fbFileClose[1].bBusy) AND NOT(fbFileClose[1].bError)) THEN fbFileClose[0](bExecute:= FALSE); fbFileClose[1](bExecute:= FALSE); bBusy := FALSE; iSeq := iSeq + 1; ELSIF fbFileSeek[1].bError THEN fbFileClose[0](bExecute:= FALSE); fbFileClose[1](bExecute:= FALSE); iExceptionSeq := iSeq; iSeq := 999; END_IF 51: IF NOT(bExecute) THEN iSeq := 0; END_IF END_CASE (* fbFileOpen[0](sNetId:= sFileTargetNetId, (* Access target id *) sPathName:= sFilePathSource, (* Access Path *) nMode:= FOPEN_MODEBINARY OR FOPEN_MODEREAD, (* Binary Format & Read Mode *) ePath:= PATH_GENERIC, bExecute:= , tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> , hFile=> ); fbFileOpen[1](sNetId:= sFileTargetNetId, (* Access target id *) sPathName:= sFilePathDestination, (* Access Path *) nMode:= FOPEN_MODEBINARY OR FOPEN_MODEWRITE, (* Binary Format & Write Mode & Overrite contents *) ePath:= PATH_GENERIC, bExecute:= , tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> , hFile=> ); fbFileWrite[1](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[1].hFile, pWriteBuff:= ADR(PutBuffer), cbWriteLen:= , bExecute:= , tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> , cbWrite=> ); fbFileSeek[0](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[0].hFile, nSeekPos:= , (* Seek to record start position *) eOrigin:= SEEK_SET, bExecute:= , tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> ); fbFileSeek[1](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[1].hFile, nSeekPos:= , (* Seek to record start position *) eOrigin:= SEEK_SET, bExecute:= , tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> ); fbFileRead[0](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[0].hFile, pReadBuff:= ADR(GetBuffer), cbReadLen:= , (* Get size = define sizeof(nAcquisitionBlock) *) bExecute:= , tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> , cbRead=> , bEOF=> ); fbFileClose[0](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[0].hFile, bExecute:= , tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> ); fbFileClose[1](sNetId:= sFileTargetNetId, hFile:= fbFileOpen[1].hFile, bExecute:= , tTimeout:= DEFAULT_ADS_TIMEOUT, bBusy=> , bError=> , nErrId=> ); *) ]]>