codesys璇诲彇csv鏂囦欢-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 348|鍥炲: 0

codesys璇诲彇csv鏂囦欢

[澶嶅埗閾炬帴]
  • TA鐨勬瘡鏃ュ績鎯
    寮蹇
    2017-11-20 22:07
  • 绛惧埌澶╂暟: 2 澶

    [LV.1]鍒濇潵涔嶅埌

    鍙戣〃浜 2024-8-9 23:39:07 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
    鏈杩戝湪椤圭洰閬囧埌浜嗛渶姹傦細瑕佹眰鑳藉浠ュ彲缂栬緫鏂囦欢鐨勬柟寮忎繚瀛樹袱鐧句釜杩愬姩鍜岀偣浣嶅埌浣嶅欢杩熸椂闂达紝鐒跺悗杩愬姩鎺у埗閫氳繃璇诲彇鏂囦欢鐨勬柟寮忓皢鐐逛綅璇诲嚭鏉ャ備竴涓偣浣嶄竴涓偣浣嶇殑鎵ц锛屾枃浠朵繚瀛樻柟寮忔渶濂戒负Excel琛ㄦ牸鏂瑰紡銆傛煡璇簡鐩稿叧璧勬枡浠ュ悗锛屽彂鐜癈odesys鏄敮鎸乧sv鏂囦欢璇诲啓鐨勶紝鑰屾伆濂紼xcel涔熷彲浠ユ墦寮csv鏂囦欢銆備簬鏄紝鎴戝紑濮嬩簡锛氭湰娆℃祴璇曠幆澧冨熀浜3.5.12寮鍙戠幆澧

    1銆侀鍏堬紝浣犻渶瑕佸紩鍏ヤ竴浜涘簱锛岀敤浜庤鍐欐枃浠舵祦

    29004529_66560a29495c665040.jpg

    2銆佸叾娆★紝浣犻渶瑕佹寚瀹氫綘瑕佽鍒版暟鎹牸寮忥紝渚嬪鎴戣璇籜锛孻锛孼1锛孼2锛孼3锛孶1锛孶2锛學aitTime銆備竴琛岄渶瑕佹湁杩欎簺鏁版嵁锛屾瘡涓暟鎹敤閫楀彿闅斿紑銆傚悓鏃跺湪棣栦綅娣诲姞1浣嶅崰浣嶆爣蹇椼傜敤鏉ュ尯鍒嗘暟鎹殑寮澶村拰缁撳熬銆傜ず渚嬶細1,101,301,1,2,3,4,5,1001$R$N锛堣繖涓氨鏄綘浼氳鍒扮殑鏁版嵁锛

    3銆佺壒鍒В閲婏紝$R$N鏄啓杩涘幓鏃跺欑殑鎹㈣绗︺傛病鏈夎繖涓棤娉曞疄鐜板湪Excel涓殑鎹㈣

    4銆佽鏂囦欢婧愮爜锛
    ----------------------------鍙橀噺澹版槑鍖哄煙------------------
    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    FUNCTION ReadFileToBuffer : BOOL
     VAR_INPUT
         strIniPath              :STRING;
         pBuffer                    :POINTER TO ARRAY[1..GVL.Cnst_MaxFileLine] OF STRING;
     END_VAR
     VAR
         hFile            :DWORD;
         dwFileSize        :DINT;
         strLine            :STRING;
         iLnCnt           :INT:=1;
         iFileLine        :INT;
         dwRead            :DWORD;
         STR                :STRING;(*璇诲埌鐨勫瓧绗︿覆*)
         iEndPos            :INT;
         dwFileCurPos    :DINT;(*褰撳墠鏂囦欢鍏夋爣浣嶇疆*)
     END_VAR


    ----------------------------杩愯浠g爜鍖哄煙------------------

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    hFile     :=SysFileOpen(FileName:=strIniPath,Mode:='r');
     dwFileCurPos:=0;
     IF (hFile =0) THEN
         ReadFileToBuffer:=FALSE;
            SysFileClose(hFile);
         RETURN;
     END_IFdwFileSize:=SysFileGetSize(FileName:=strIniPath);
     IF (dwFileSize=0)  THEN
         ReadFileToBuffer:=FALSE;
            SysFileClose(hFile);
         RETURN;
     END_IFWHILE(TRUE) DO
           IF  (*(NOT SysFileEOF(hFile)) OR*) dwFileCurPos<dwFileSize   THEN
             dwRead:=SysFileRead(File:=hFile,Buffer :=ADR(STR),60);
             iEndPos:=FIND(STR1:=STR,STR2:='$N');
             dwFileCurPos:=dwFileCurPos+iEndPos;
             SysFileSetPos(hFile,dwFileCurPos);
                  pBuffer^[iLnCnt]:=LEFT(STR,iEndPos);
             iLnCnt:=iLnCnt+1;
         ELSE
             SysFileClose(hFile);
             EXIT;
         END_IF
     END_WHILE
     ReadFileToBuffer:=TRUE;


    姝ら儴鍒嗕唬鐮佷細鎵ц涓涓繃绋嬶紝灏嗘寜琛屾暟鏂囦欢鍐呭鍏ㄩ儴璇诲彇鍒颁竴涓寚瀹氬埌鐨勫瓧绗︿覆锛屾瘡涓琛屼负涓涓瓧绗︿覆銆

    5銆佸洜姝わ紝鎴戜滑杩橀渶瑕侀氳繃涓涓柟娉曟潵鍒嗚В瀛楃涓叉潵鍙栨暟鎹

    ----------------------------鍙橀噺澹版槑鍖哄煙------------------

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    FUNCTION_BLOCK GetPointData
     VAR_INPUT
         BuffStr:STRING;
     END_VAR
     VAR_OUTPUT
         OutDutData:DUT_XYZ_WaitTime;
     END_VAR
     VAR
         str1:STRING :='1,101,301,1,2,3,4,5,1001$R$N';     ///娴嬭瘯鏁版嵁
         iStartPoint:INT;
         iEndPoint:INT;
         p,j:INT;
         listPoint:ARRAY [1..8] OF INT; //璁板綍閫楀彿浣嶇疆
     END_VAR


    ----------------------------杩愯浠g爜鍖哄煙------------------

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    iStartPoint:=FIND(BuffStr,'1');  //鑾峰彇璧峰浣嶇疆
     iEndPoint:=FIND(BuffStr,'$R');  //鑾峰彇鏁版嵁缁撴潫浣嶇疆
     //浠庡瓧绗︿綅缃1寮濮嬪惊鐜埌鏁版嵁缁撴潫浣嶇疆锛岄氳繃MID鏂规硶鑾峰緱姣忎竴涓楀彿浣嶇疆锛屽苟璁板綍鍒版暟缁勪腑銆
     j:=1;
     FOR p:=1 TO iEndPoint DO
         IF','=MID(BuffStr,1,p)THEN
         listPoint[j]:=p;
         j:=j+1;
         END_IF
         IF j>8 THEN
             EXIT;
         END_IF
     END_FOR
     //鎸夌収閫楀彿浣嶇疆鍙栧綋鍓嶉楀彿鍒颁笂涓涓楀彿涔嬮棿鐨勫瓧绗︿覆锛岃浆鎹负闀垮疄鏁扮被鍨嬫暟鎹
     OutDutData.X:=STRING_TO_LREAL( MID(BuffStr,(listPoint[2]-listPoint[1]-1),listPoint[1]+1));
     OutDutData.Y:=STRING_TO_LREAL( MID(BuffStr,(listPoint[3]-listPoint[2]-1),listPoint[2]+1));
     OutDutData.Z1:=STRING_TO_LREAL( MID(BuffStr,(listPoint[4]-listPoint[3]-1),listPoint[3]+1));
     OutDutData.Z2:=STRING_TO_LREAL( MID(BuffStr,(listPoint[5]-listPoint[4]-1),listPoint[4]+1));
     OutDutData.Z3:=STRING_TO_LREAL( MID(BuffStr,(listPoint[6]-listPoint[5]-1),listPoint[5]+1));
     OutDutData.U1:=STRING_TO_LREAL( MID(BuffStr,(listPoint[7]-listPoint[6]-1),listPoint[6]+1));
     OutDutData.U2:=STRING_TO_LREAL( MID(BuffStr,(listPoint[8]-listPoint[7]-1),listPoint[7]+1));
     //鏈鍚庝竴涓病鏈夐楀彿锛屼絾鏄湁鎹㈣鏍囧織锛屾墍浠ュ彇鎹㈣鏍囧織鍒颁笂涓涓楀彿涔嬪墠鐨勬暟鎹紝鍚岀悊杞寲
     OutDutData.WaitTime:=STRING_TO_INT( MID(BuffStr,(iEndPoint-listPoint[8]-1),listPoint[8]+1));


    6銆侀氳繃姝ラ5鐨勬柟娉曘傛垜浠彲浠ヤ紶涓涓瓧绗︿覆锛屼粠鑰屽緱鍒颁竴涓垜浠崗璁ソ鐨勬暟鎹泦鍚

    杩欐牱鎴戜滑鍦ㄤ富绋嬪簭涓紝杩欐牱璋冪敤锛屽嵆鍙緱鍒版兂瑕佺殑鍊间簡

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    Cnst_MaxFileLine                :INT:=1000;(*鏂囦欢鐨勬渶澶ц鏁*)
    IF ReadFileToBuffer(strFilePath,ADR(Buffer))THEN
             FOR i:=1 TO GVL.Cnst_MaxFileLine DO 
                 fb_GetData(BuffStr:=Buffer[i],OutDutData=>PointData[i]);
             END_FOR
             iIndex:=1;
         END_IF


    瀵逛簡锛屽埆蹇樹簡瀹氫箟浣犵殑鏁版嵁缁撴瀯浣擄細

    [AppleScript] 绾枃鏈煡鐪 澶嶅埗浠g爜
    TYPE DUT_XYZ_WaitTime :
     STRUCT
         X:LREAL;
         Y:LREAL;
         Z1:LREAL;
         Z2:LREAL;
         Z3:LREAL;
         U1:LREAL;
         U2:LREAL;
         WaitTime:INT;
     END_STRUCT
     END_TYPE


    濂戒簡銆傚氨鏄繖鏍凤紝绋嬪簭涓娇鐢ㄥ氨璋冪敤OutDutData鏁扮粍涓嬬殑鐩稿簲鐐逛綅鍗冲彲锛岀粰鐩稿簲鐨刋Y杩愬姩鐐逛綅璧嬪硷紝鍗冲彲杈炬垚鎯宠鐨勬晥鏋溿

    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒
    鍥炲

    浣跨敤閬撳叿 涓炬姤

    鎮ㄩ渶瑕佺櫥褰曞悗鎵嶅彲浠ュ洖甯 鐧诲綍 | 绔嬪嵆娉ㄥ唽 鏂版氮寰崥鐧婚檰

    鏈増绉垎瑙勫垯

    椤堕儴qrcode搴曢儴
    鍏虫敞閰峰痉缃戣闃呭彿锛岃幏鍙栨洿澶氳祫璁紒

    QQ|灏忛粦灞|鎵嬫満鐗|Archiver|閰峰痉璁哄潧 ( 鑻廔CP澶16065247鍙-1 )|缃戠珯鍦板浘

    GMT+8, 2024-11-23 19:35 , Processed in 0.162781 second(s), 60 queries .

    閰峰痉缃

    © 2001-2013 Hicodesys. 鎶鏈敮鎸 by 閰峰痉缃

    蹇熷洖澶 杩斿洖椤堕儴 杩斿洖鍒楄〃