鍦–odesys鐢⊿T璇█鍩轰簬閾捐〃瀹炵幇鏍圠IFO鏁版嵁缁撴瀯璇︾粏璇存槑+浠g爜瀹炰緥-CODESYS璧勬簮涓嬭浇鍖-閰峰痉缃 - CoDeSys杞欢鏁欑▼涓嬭浇,CoDeSys宸ユ帶璧勮闂ㄦ埛
HSC6490-cn涓浗鍒堕狅紝涓浗鑺瘇
鏌ョ湅: 1130|鍥炲: 2

鍦–odesys鐢⊿T璇█鍩轰簬閾捐〃瀹炵幇鏍圠IFO鏁版嵁缁撴瀯璇︾粏璇存槑+浠g爜瀹炰緥

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

    [LV.1]鍒濇潵涔嶅埌

    鍙戣〃浜 2023-4-12 22:37:16 | 鏄剧ず鍏ㄩ儴妤煎眰 |闃呰妯″紡
    涓銆 鏍堝畾涔

    鏍堟槸涓绉嶅悗杩涘厛鍑(LIFO鈥斺攍ast in first out)绾挎ц〃,瀹冨彧鍏佽鍦ㄨ〃鐨勫悗绔紙tail锛夎繘琛屾彃鍏(push)鍜屽垹闄(pop)鎿嶄綔銆

    鍦–odesys鐢⊿T璇█鍩轰簬閾捐〃瀹炵幇鏍圠IFO鏁版嵁缁撴瀯璇︾粏璇存槑+浠g爜瀹炰緥-1.jpg


    鍦–odesys鐢⊿T璇█鍩轰簬閾捐〃瀹炵幇鏍圠IFO鏁版嵁缁撴瀯璇︾粏璇存槑+浠g爜瀹炰緥-2.gif


    浜屻佹爤瀹炵幇

    瀹炵幇鏍堬紝鎴戜滑鍙互浣跨敤鍗曞悜閾捐〃锛堥嗗悜锛夛紝閾捐〃涓殑姣忎釜缁撶偣涓嶄粎鍖呭惈鍊硷紝杩樺寘鍚摼鎺ュ埌涓婁竴涓粨鐐圭殑寮曠敤瀛楁銆傞氳繃杩欑鏂瑰紡锛屽崟閾捐〃灏嗘墍鏈夌粨鐐规寜椤哄簭缁勭粐璧锋潵銆傝摑鑹茬澶存樉绀哄崟涓摼鎺ュ垪琛ㄤ腑鐨勭粨鐐规槸濡備綍缁勫悎鍦ㄤ竴璧风殑

    鍦–odesys鐢⊿T璇█鍩轰簬閾捐〃瀹炵幇鏍圠IFO鏁版嵁缁撴瀯璇︾粏璇存槑+浠g爜瀹炰緥-3.png


    涓夈 鏍堣璁

    鎴戜滑鍒嗗埆閲囩敤c++鍜宑odesys涓璼t璇█杩涜瀹炵幇鍩轰簬閾捐〃鐨勬爤鎿嶄綔
    (1) C++ 璇█瀹炵幇

    鍔熻兘濡備笅
      Push(value) : 鍚戞爤椤舵彃鍏ヤ竴涓厓绱狅紝鎴愬姛杩斿洖truepop():鑾峰緱鏍堥《鍏冪礌骞跺脊鍑Empty(): 鍒ゆ柇鏍堟槸鍚︿负绌猴紝涓虹┖杩斿洖trueSize():鑾峰緱鏍堢殑鍏冪礌涓暟
    1. typedefint DataElement;//鐢ㄦ埛鑷畾涔夌殑鏁版嵁typedefstruct StackElement//鏍堝厓绱爗
    2.     DataElement  mdata;//鐢ㄦ埛鑷畾涔夌殑鏁版嵁
    3.     StackElement* Pre;//鎸囧悜涓嬩竴涓妭鐐箎StackElement;//閫氳繃閾捐〃瀹炵幇闃熷垪classListStack{public:ListStack(){};~ListStack(){};private:
    4.    
    5.     StackElement* pTail =0;//鏍堝熬鎸囬拡public:boolpush(DataElement _data){// 鐢宠涓涓粨鐐圭┖闂
    6.         StackElement* pTemp =(StackElement*)malloc(sizeof(StackElement));
    7.          pTemp->mdata = _data;// 鐢宠涓涓粨鐐圭┖闂
    8.          pTemp->Pre=0;// 缁撶偣鐨刵ext璁句负NULLif(Empty())// 鍒ゆ柇鏍堝熬鏄惁涓虹┖锛岀敤浜庣涓娆″叆闃焮
    9.              pTail = pTemp;}else{
    10.           pTemp->Pre = pTail;// 璁﹑Tail鎴愪负褰撳墠灏鹃儴鐨勪笂涓缁撶偣
    11.            pTail = pTemp;// 灏鹃儴鎸囬拡鎸囧悜pTemp}returntrue;}
    12.      DataElement pop(){
    13.     DataElement  mdata =0;if(Empty())return mdata ;if(pTail->Pre==0)// 鍒ゆ柇鏍堟槸鍚﹀氨1涓,濡傛灉鍙湁涓涓 锛岀Щ闄ゅ悗闃熷垪涓虹┖ {delete(pTail);//娓呴櫎绉婚櫎鐨勫唴瀛樼┖鍓
    14.             pTail =0;}else{
    15.           StackElement* pTemp = pTail;
    16.          pTail = pTail->Pre;//绉诲姩澶撮儴鎸囬拡delete(pTemp);//娓呴櫎绉婚櫎鐨勫唴瀛樼┖鍓峿returntrue;};//杩斿洖鑺傜偣涓暟intSize(){int iSize  =0;
    17.          StackElement* pTemp = pTail;while(pTemp !=0){
    18.              iSize = iSize +1;
    19.              pTemp = pTemp->Pre;}return iSize;}//鍒ゆ柇鏍堟槸鍚︿负绌篵oolEmpty(){if(pTail ==0)returntrue;elsereturnfalse;}}
    澶嶅埗浠g爜
    绀轰緥濡備笅

    鍦–odesys鐢⊿T璇█鍩轰簬閾捐〃瀹炵幇鏍圠IFO鏁版嵁缁撴瀯璇︾粏璇存槑+浠g爜瀹炰緥-4.jpg


    (2) Codesys 瀹炵幇

      缂栫▼杞欢锛 Codesys V3.5 SP17杩愯璁惧锛歅C鐢佃剳缂栫▼璇█锛 ST 鎺屾彙濡備綍鍒涘缓鍔ㄦ佹暟缁New鐨勪娇鐢紱浠ュ強鎸囬拡鐨勭伒娲讳娇鐢
    瀹氫箟缁撴瀯浣
    1. //鏍堟搷浣滅殑鏁版嵁
    2. TYPE ListStackElement :
    3. STRUCT
    4.         mData : BaseElement;
    5.         pPre : POINTER TO ListStackElement;
    6. END_STRUCT
    7. END_TYPE
    澶嶅埗浠g爜
    鍏朵腑 BaseElement 鏄竴涓埆鍚嶏紝鍏跺畾涔夊涓嬶紝杩欓噷BaseElement 鏄敤鎴疯嚜瀹氫箟鏁版嵁(姣斿缁撴瀯浣)锛岄噰鐢ㄥ埆鍚嶆槸鏂逛究鏇挎崲銆
    1. TYPE BaseElement : INT; END_TYPE
    澶嶅埗浠g爜
    瀹氫箟鍔熻兘鍧楋紙FUNCTION_BLOCK锛夛細 ListQueue锛屽疄鐜板涓嬪嚱鏁
      Push(value) : 鍚戞爤椤舵彃鍏ヤ竴涓厓绱狅紝鎴愬姛杩斿洖truepop():鑾峰緱鏍堥《鍏冪礌骞跺脊鍑Empty(): 鍒ゆ柇鏍堟槸鍚︿负绌猴紝涓虹┖杩斿洖trueSize():鑾峰緱鏍堢殑鍏冪礌涓暟
    绀轰緥濡備笅
    1. PROGRAM PLC_PRG
    2. VAR
    3.         t  : ListStack;
    4. END_VAR
    5. VAR
    6.         bInit :BOOL:= FALSE;
    7.         isize : INT;
    8.         ivar1: ARRAY[0..10] OF BaseElement;
    9. END_VAR
    澶嶅埗浠g爜
    1. IF bInit = FALSE THEN
    2.        
    3. bInit := TRUE;
    4. t.Push(11);//鍏ユ爤 锛岃繑鍥濼RUE
    5. t.Push(22);//鍏ユ爤 锛岃繑鍥濼RUE
    6. t.Push(33);//鍏ユ爤 锛岃繑鍥濼RUE
    7. isize := t.Size();//杩斿洖3
    8. ivar1[0]:= t.Pop();//杩斿洖33
    9. ivar1[1]:= t.Pop();//杩斿洖22
    10. END_IF
    澶嶅埗浠g爜
    鍦–odesys鐢⊿T璇█鍩轰簬閾捐〃瀹炵幇鏍圠IFO鏁版嵁缁撴瀯璇︾粏璇存槑+浠g爜瀹炰緥-5.jpg


    鍥涖 Codesys浠g爜涓嬭浇
    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒
    鍥炲

    浣跨敤閬撳叿 涓炬姤

    璇ョ敤鎴蜂粠鏈鍒

    鍙戣〃浜 2023-5-22 11:13:51 | 鏄剧ず鍏ㄩ儴妤煎眰
    鍏堢湅鐪嬶紝锛宩ldsjflsjfjlkjlkj
    +10
    涓嶈禐涓涓紵
    鎵撹祻榧撳姳涓涓嬶紒
    鎮ㄩ渶瑕佺櫥褰曞悗鎵嶅彲浠ュ洖甯 鐧诲綍 | 绔嬪嵆娉ㄥ唽 鏂版氮寰崥鐧婚檰

    鏈増绉垎瑙勫垯

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

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

    GMT+8, 2024-11-23 19:39 , Processed in 0.251545 second(s), 67 queries .

    閰峰痉缃

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

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