簡體   English   中英

KRL:我想使用 KRC4 平板電腦的狀態鍵發送輸出

[英]KRL: I want to use the Status Keys of the KRC4 Tablet to send outputs

我已經有了我的代碼,如果我錯了,請糾正我。 但是代碼不是我的問題...我不知道在 KRC4 界面中的何處以及如何使用它不能那樣工作。 我從來沒有在 KRL 上過編程課程,所以我錯過了使用我的代碼的基本步驟。 代碼:

DEF StatusKey()

;FOLD +> Status Key detection
; check if status key is pressed

  $FLAG[11]=is_key_pressed(14)
  $FLAG[12]=is_key_pressed(15)
  $FLAG[13]=is_key_pressed(16)
  $FLAG[14]=is_key_pressed(17)

; detect rising edge of the button press
; by comparing current and remembered state

  $FLAG[1] = $FLAG[11] AND NOT $FLAG[15]
  $FLAG[2] = $FLAG[12] AND NOT $FLAG[16]
  $FLAG[3] = $FLAG[13] AND NOT $FLAG[17]
  $FLAG[4] = $FLAG[14] AND NOT $FLAG[18]

; remember previous state of the button

  $FLAG[15]=$FLAG[11]
  $FLAG[16]=$FLAG[12]
  $FLAG[17]=$FLAG[13]
  $FLAG[18]=$FLAG[14]

;ENDFOLD

;FOLD +> Status Key control
; allow status keys to control some outputs
; but only if in T1 and drives are enables

IF $T1 AND $PERI_RDY AND $USER_SAF AND NOT $PRO_ACT THEN
 
; for momentary state change (toggle) use flags 1..4

  IF $FLAG[1] THEN
    $OUT[1] = True
  ENDIF

  IF $FLAG[2] THEN
    $OUT[1] = False
  ENDIF

; for continuous outputs use flags 11..14  

  ; $OUT[1] = $FLAG[11] ; already used for output 1
  ; $OUT[2] = $FLAG[12] ; already used for output 1
  ; $OUT[3] = $FLAG[13]
  ; $OUT[4] = $FLAG[14] 

ENDIF

;ENDFOLD
END

您需要將其放在 *.sub 中,以便循環評估。 如果您不想移動代碼,也可以從提交中調用 statuskey()。

請記住不要在 sps.sub 中放置等待或類似內容

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM