銆怌odesys銆戝疄鐜拌幏鍙栧綋鍓嶆椂闂达細澶┿佺銆佹绉掞紙婧愮爜锛夈-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 162|鍥炲: 0

銆怌odesys銆戝疄鐜拌幏鍙栧綋鍓嶆椂闂达細澶┿佺銆佹绉掞紙婧愮爜锛夈

[澶嶅埗閾炬帴]
  • TA鐨勬瘡鏃ュ績鎯
    鎱垫噿
    2017-11-9 20:49
  • 绛惧埌澶╂暟: 2 澶

    [LV.1]鍒濇潵涔嶅埌

    鍙戣〃浜 2024-11-6 20:22:07 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
    鑾峰彇褰撳墠绯荤粺鏃堕棿鐨勫悇绉嶆暟鍊硷紝鏂逛究璁板綍褰撳墠鏃堕棿鍙戠敓鏃堕棿銆
    //鑾峰彇褰撳墠鏃堕棿锛屽ぉ銆佺銆佹绉
    FUNCTION_BLOCK FB_GetTime
    VAR_INPUT
    END_VAR
    VAR_OUTPUT
         GetTimeMs:STRING;
         GetTimeS:STRING;
         GetTimeDay:STRING;
    END_VAR
    VAR
         stUTC_Timestamp : SysTime;
         stLocal_TimeStamp : SysTime;
         stdNow : SysTimeDate;
         Result : RTS_IEC_RESULT;
         dtNow : DATE_AND_TIME;
         todNow : TIME_OF_DAY;
         datToday  : DATE;
         str1,Str2:STRING;

         udiUtcTime             : UDINT;
         udiUtcTimeLocal     : UDINT;
         udiResult             : UDINT;
         DTTime                : DATE_AND_TIME;
         strTime                :STRING;
    END_VAR
    杩愯浠g爜
    (*-------------绮剧‘鍒版绉-----------------*)
    Result := SysTimeRtcHighResGet(stUTC_Timestamp); // ULINT#1528273494913
    Result := SysTimeRtcConvertHighResToLocal(stUTC_Timestamp, stdNow);
    Result := SysTimeRtcConvertDateToHighRes(stdNow, stLocal_TimeStamp); // ULINT#1528280694913
    dtNow := TO_DT(stLocal_TimeStamp / 1000 (* ms *)); // DT#2018-6-6-10:24:54
    todNow := TO_TOD(stLocal_TimeStamp MOD TO_ULINT(T#1D)); // TOD#10:24:54.913
    datToday := TO_DATE(dtNow); // D#2018-6-6
    str1:= TO_STRING(datToday);
    str1:=REPLACE(STR1:=str1,STR2:='',L:=2,P:=1);
    GetTimeDay:=str1;
    str2:= TO_STRING(todNow);
    str2:=REPLACE(STR1:=str2,STR2:='-',L:=4,P:=1);
    GetTimeMs:=CONCAT(str1,str2);
    (*-------------绮剧‘鍒扮-----------------*)
    (* Fetch the UTC time. *)//鑾峰彇UTC鏃堕棿  
    udiUtcTime := SysTimeRtcGet(udiResult);
    (* Convert the UTC time to local time. *) //灏哢TC鏃堕棿杞寲涓烘湰鍦版椂闂
    udiResult := SysTimeRtcConvertUtcToLocal(udiUtcTime, udiUtcTimeLocal);
    (* Convert the seconds from the local time in a Date and Time format.*)  
    //杞崲鏈湴鏃堕棿鏍煎紡  骞存湀鏃ユ椂鍒嗙
    DTTime := UDINT_TO_DT(udiUtcTimeLocal);
    strTime:=TO_STRING(DTTime);
    GetTimeS:=REPLACE(STR1:=strTime,STR2:='',L:=3,P:=1);
    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒
    鍥炲

    浣跨敤閬撳叿 涓炬姤

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

    鏈増绉垎瑙勫垯

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

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

    GMT+8, 2024-11-23 17:16 , Processed in 0.137222 second(s), 53 queries .

    閰峰痉缃

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

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