codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 1037|鍥炲: 0

codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜

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

    [LV.1]鍒濇潵涔嶅埌

    鍙戣〃浜 2023-4-12 22:54:35 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
    涓銆佷袱绉嶆寚閽

    1銆 this 鏄嚜韬殑涓涓璞★紝浠h〃瀵硅薄鏈韩锛屽彲浠ョ悊瑙d负锛氭寚鍚戝璞℃湰韬殑涓涓寚閽堛

      褰㈠弬涓庢垚鍛樺悕瀛楅噸鍚嶏紝鐢 this 鏉ュ尯鍒

      codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-1.png

      codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-2.png

    2銆乻uper 鍙互鐞嗚В涓烘槸鎸囧悜鑷繁瓒咃紙鐖讹級绫诲璞$殑涓涓寚閽堬紝鑰岃繖涓秴绫绘寚鐨勬槸绂昏嚜宸辨渶杩戠殑涓涓埗绫

      super 璁块棶鐖剁被鐨勬柟娉曘佸睘鎬э紱super鏄笉鑳借闂埗绫籶rivate淇グ鐨勫彉閲忓拰鏂规硶鐨勶紝鍥犱负杩欎釜鍙睘浜庣埗绫荤殑鍐呴儴鎴愬憳銆

      codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-3.png

    3銆

      this^()super^() 浠g爜瀛愩佺埗瀹炰緥鍔熻兘鍧楃殑涓诲嚱鏁帮紱

    鈥嬧
    浜屻 鎺ュ彛鐨勪粙缁-INTERFACE

    1銆佸畾涔

    鎺ュ彛鏄竴涓崗璁佽鑼冿紱渚嬪鐢垫簮鎻掑骇鎺ュ彛锛屽畠灏辨槸涓涓鑼冿紝涓浗鍒跺畾鐨勬彃搴ф爣鍑嗭紱
    codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-4.png


    姣忎釜鍘傚鎻掑骇鐨勭敓浜ф妧鏈佸伐鑹洪兘涓嶄竴鏍枫傛彃搴х殑鍐呴儴瀹炵幇瀵逛簬鐢靛櫒鏉ヨ鏄畬鍏ㄥ睆钄界殑锛涗絾浠讳綍鍘傚鍙鎸夌収鎻掑骇鏍囧噯鍒朵綔锛屾垜浠殑鐢靛櫒灏辫兘姝e父浣跨敤銆
    2銆佹帴鍙d紭鐐

    鎺ュ彛鍜屽疄鐜板垎绂伙紝鏂逛究鍒嗗伐鍗忎綔銆佸簲瀵瑰彉鍖栨с佹祴璇曟柟渚匡紱
      鍒嗗伐鍗忎綔锛堣蒋浠跺紑鍙戯級锛氭湁浜嗘帴鍙f爣鍑嗭紝鍙互璁╃數婧愭彃搴у拰鐢靛櫒涓嶅悓鐨勪汉鏉ュ畬鎴愶紝鍒嗗紑娴嬭瘯锛屾渶鍚庢柟渚跨殑鏁村悎鍦ㄤ竴璧搴斿鍙樺寲鎬锛 鏈変簡鎺ュ彛鏍囧噯锛屽彲浠ユ柟渚挎洿鎹笉鍚屽巶瀹剁殑鐢垫簮鎻掑骇锛岃屼笉褰卞搷鐢靛櫒鐨勪娇鐢紱涔熷氨鏄彲浠ユ柟渚挎洿鎹㈠疄鐜版帴鍙g殑绫伙紱娴嬭瘯鏂逛究 鏈変簡鎺ュ彛鏍囧噯锛屽彲浠ュ崟鐙祴璇曟瘡涓ā鍧楋紝鍑忓皯鍏朵粬鍥犵礌鐨勫共鎵帮紱
    3銆乧odesys 鎺ュ彛涓句緥

    瑕佹帶鍒朵竴涓酱鍓嶈繘鍚庨杩愬姩锛岄渶瑕佺敤鍒扮數鏈猴紝闇瑕佸紑鍙戝墠杩 鍚庨鍔熻兘
    锛1锛 瀹氫箟鐢垫満鐨勪竴涓帴鍙o紝閲岄潰澹版槑鐐瑰姩鍓嶈繘銆佸悗閫鐨勬柟娉曪紱

    codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-5.png



    锛2锛変娇鐢 涓婅堪Driver鎺ュ彛 瀹氫箟鍙拌揪鐢垫満鍔熻兘鍧楋紝骞跺疄鐜扮偣鍔ㄥ墠杩涖佸悗閫鐨勬柟娉
    1. FUNCTION_BLOCK PUBLIC Driver_Delta IMPLEMENTS Driver
    澶嶅埗浠g爜
    codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-6.png



    锛3锛変娇鐢ㄤ笂杩癉river鎺ュ彛 瀹氫箟涓夋磱鐢垫満鍔熻兘鍧楋紝骞跺疄鐜扮偣鍔ㄥ墠杩涖佸悗閫鐨勬柟娉
    1. FUNCTION_BLOCK PUBLIC Driver_SANYO IMPLEMENTS Driver
    澶嶅埗浠g爜
    codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-7.png



    (4) 鍚庨潰杩樻湁寰堝鍘傚鐨勭數鏈猴紝灏变笉涓 涓 涓句緥锛屾湁浜嗙粺涓鐨勬帴鍙o紝涓嶇浠涔堝巶瀹剁殑鐢垫満锛岀洿鎺ョ粺涓璋冪敤杩涜鎿嶄綔灏卞ソ
    渚嬪瀹氫箟涓涓搷浣滅數鏈虹殑鍑芥暟
    1. FUNCTION DriveForwad : BOOL
    2. VAR_INPUT
    3.         m_dirver :Driver;//澹版槑鐢垫満鎺ュ彛鍙橀噺锛屼笉绠′粈涔堝巶瀹剁殑鐢垫満锛岀敤缁熶竴鐨勮緭鍏ュ弬鏁
    4. END_VAR
    5. VAR
    6. END_VAR
    澶嶅埗浠g爜
    1. m_dirver.JogForward();
    澶嶅埗浠g爜
    鍦ㄧ▼搴忎腑杩涜搴旂敤
    1. PROGRAM PLC_PRG
    2. VAR
    3.   m_Driver_Delta:         Driver_Delta;//鍙拌揪
    4.   m_Driver_SANYO:   Driver_SANYO;//涓夋磱
    5. END_VAR
    澶嶅埗浠g爜
    1. DriveForward(Driver_Delta);DriveForward(Driver_SANYO);//鍏朵粬鐢垫満绛夌瓑
    澶嶅埗浠g爜

    涓夈佸姛鑳藉潡瀹炵幇澶氭

    1銆佸鎬佸畾涔

    鍚屼竴涓嚱鏁版帴鍙o紝瀹炵幇涓嶅悓鐨勫姛鑳斤紱
    姣斿鏈夊姩鐗╋紙Animal锛変箣绫诲埆锛圕lass锛夛紝鑰屼笖鐢卞姩鐗╃户鎵垮嚭绫诲埆楦★紙Chicken锛夊拰绫诲埆鐙楋紙Dog锛夛紝骞跺鍚屼竴婧愯嚜绫诲埆鍔ㄧ墿锛堢埗绫伙級涔嬩竴娑堟伅鏈変笉鍚岀殑鍝嶅簲锛屽绫诲埆鍔ㄧ墿鏈夆滃彨()鈥濅箣鍔ㄤ綔锛岃岀被鍒浮浼氣滃暭鍙()鈥濓紝绫诲埆鐙楀垯浼氣滃悹鍙()鈥濓紝鍒欑О涔嬩负澶氭
    2銆佸鎬佸畾涔夊疄鐜板鎬佹湁涓変釜蹇呰鏉′欢锛氱户鎵裤侀噸鍐欍佸悜涓婅浆鍨嬨

      缁ф壙锛氬湪澶氭佷腑蹇呴』瀛樺湪鏈夌户鎵垮叧绯荤殑瀛愮被鍜岀埗绫汇閲嶅啓锛氬瓙绫诲鐖剁被涓煇浜涙柟娉曡繘琛岄噸鏂板畾涔夛紝鍦ㄨ皟鐢ㄨ繖浜涙柟娉曟椂灏变細璋冪敤瀛愮被鐨勬柟娉曘鍚戜笂杞瀷锛氬湪澶氭佷腑闇瑕佸皢瀛愮被鐨勫紩鐢ㄨ祴缁欑埗绫诲璞★紝鍙湁杩欐牱璇ュ紩鐢ㄦ墠鑳藉鍏峰鐖剁被璋冪敤瀛愮被鐨勬柟娉曘
    3銆乧odesys涓句緥

    锛1锛夊畾涔変竴涓姩鐗╁姛鑳藉潡锛堢埗绫伙級锛屾湁涓涓 鈥滃彨锛堬級鈥濈殑鍔ㄤ綔
    1. FUNCTION_BLOCK PUBLIC Animal
    澶嶅埗浠g爜
    codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-8.png



    锛2锛夊畾涔変竴涓户鎵垮姩鐗╃殑鐚姛鑳藉潡锛屽疄鐜 鈥滃彨锛堬級鈥濈殑鍔ㄤ綔
    1. FUNCTION_BLOCK cat EXTENDS Animal
    澶嶅埗浠g爜
    codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-9.png



    锛3锛夊畾涔変竴涓户鎵垮姩鐗╃殑鐙楀姛鑳藉潡锛屽疄鐜 鈥滃彨锛堬級鈥濈殑鍔ㄤ綔
    1. FUNCTION_BLOCK dog EXTENDS Animal
    澶嶅埗浠g爜
    codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-10.png



    锛4锛夋垜浠惉涓涓嬪彨澹帮紝涓嶅悓鐨勫姩鐗╋紝鍙涓涓緭鍏ュ弬鏁板氨鍙互锛
    codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-11.png



    锛5锛夎繍琛岀粨鏋
    codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-12.jpg


    codesys 闈㈠悜瀵硅薄鍒嗘瀽 浜-13.jpg




    缁ф壙锛 Codesys瀛愮被缁ф壙鐖剁被鐨勬柟娉曪紝灞炴э紝鍔ㄤ綔(private鍙互缁ф壙锛屽彧鏄病鏈夎闂潈闄)
    澶氭侊細Codesys鍙敮鎸佺函铏氬嚱鏁(鍙0鏄庯紝涓嶅疄鐜帮級锛岀函铏氬睘鎬,鏈夌函铏氬嚱鏁扮殑鍔熻兘鍧楀彨鍋氱函铏氱被锛屼笉鑳藉疄渚嬪寲锛岄氳繃鎸囬拡鐨勬柟寮忓疄鐜板鎬
    缁ф壙鍜屽鎬侀兘鏄瓙绫荤殑璁块棶鏉冮檺鐨勯棶棰橈紝瑕佸績涓湁琛紝涓嶈娣锋穯
    銆傘傘傘傘傘傘傘傘傘傘傘傘傘
    銆-------------------------------------銆
    銆 銆 銆 銆 銆----------------------銆
    銆 銆-------- 銆----------------------銆
    銆 銆-------- 銆 ---------------------銆
    銆 銆傘 銆 銆-----------------------銆
    銆-------------------------------------銆
    銆傘傘傘傘傘傘傘傘傘傘傘傘傘
      鎺ュ彛锛歝odesys鎺ュ彛灏辨槸鍙湁绾櫄鍑芥暟鐨凢B锛屾帴鍙h櫧鐒朵笉鑳藉畾涔夋寚閽堬紝浣嗘槸瀹氫箟鎺ュ彛瀵硅薄鍏跺唴閮ㄥ氨鏄竴涓寚閽堬紝濡傛灉澶氬皯涓帴鍙e嚱鏁版垨鑰呭睘鎬э紝鎺ュ彛瀵硅薄寮杈熺殑鍐呭瓨绌洪棿涓鏍凤紝绫讳技鍒悕锛涘綋鎶婁竴涓瓙绫昏祴鍊肩粰鎺ュ彛瀵硅薄鐨勬椂鍊欙紝鍏跺疄鏄惂瀛愮被鐨勬寚閽堢粰鎺ュ彛瀵硅薄锛
    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒
    鍥炲

    浣跨敤閬撳叿 涓炬姤

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

    鏈増绉垎瑙勫垯

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

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

    GMT+8, 2024-11-23 19:36 , Processed in 0.157743 second(s), 59 queries .

    閰峰痉缃

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

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