174 lines
6.7 KiB
Plaintext
174 lines
6.7 KiB
Plaintext
; --------------------------------------------------------------------------------
|
|
; @Title: Example for dialog with automatic update timer
|
|
; @Description:
|
|
; An internal update timer is started within a dialog which
|
|
; does some automated update within the dialog
|
|
; see line 108 for UPDATE dialog command
|
|
; Main working routine is at label "fnHandleUpdate"
|
|
; This script uses the debugger command B::Var to create and handle an array of
|
|
; strings representing user defined icons for continuous looping purpose.
|
|
; @Keywords: practice, dialog, update, var
|
|
; @Author: SME
|
|
; @Copyright: (C) 1989-2021 Lauterbach GmbH, licensed for use with TRACE32(R) only
|
|
; --------------------------------------------------------------------------------
|
|
; $Id: dialog_update.cmm 18691 2021-12-15 18:51:36Z rweiss $
|
|
|
|
; --------------------------------------------------------------------------------
|
|
; Checks IF dialog already running then clear and restart
|
|
; (This demo cannot be started twice)
|
|
; --------------------------------------------------------------------------------
|
|
|
|
IF WINdow.EXIST(UpdateDlg)
|
|
WinCLEAR UpdateDlg
|
|
|
|
; --------------------------------------------------------------------------------
|
|
; Dialog Definition
|
|
;
|
|
WinPOS ,,,,,, UpdateDlg
|
|
DIALOG
|
|
( ; For activating PRACTICE macro expansion inside a DIALOG definition
|
|
; two prerequisites have to be fulfilled (ide_ref.pdf):
|
|
; 1. "(&" instead of "(" must be used
|
|
; 2. "(&" must begin in the first column of the line
|
|
; here we do not need macro expansion
|
|
|
|
HEADER "UPDATE Demo"
|
|
|
|
; Define width of dialog by printing an empty text: width is 25. units.
|
|
; x y w h
|
|
POS 0. , 25. 0.
|
|
TEXT ""
|
|
;
|
|
; Update routine running state display
|
|
;
|
|
POS 0.5 0. 22. 3.
|
|
BOX "Update Timer"
|
|
POS 0.75 1. 2.5 1.
|
|
WHEELY: DYNAMIC "[:empty]"
|
|
POS 4. 1. 16. 1.
|
|
TEXT "running"
|
|
;
|
|
; Display Progress
|
|
; box, text, bar, start and stop
|
|
;
|
|
POS 0.5 2. 22. 5.
|
|
BOX "Progress Bar"
|
|
|
|
POS 1.25 3. 18. 1.
|
|
PROGTEXT: DYNTEXT "0%"
|
|
|
|
POS 1.25 4. 20. 0.75
|
|
PROGBAR: BAR
|
|
|
|
POS 1.25 5. 9.5 1.25
|
|
BTN_START: BUTTON "[:go] Start" "&UpdateState=""start"""
|
|
|
|
POS 11.5 5. 9.75 1.25
|
|
BTN_STOP: BUTTON "[:brk] Stop" "&UpdateState=""stop"""
|
|
|
|
INIT
|
|
(
|
|
DIALOG.STORAGE.define &UpdateState &Progress &WheelIndex &SpinningWheel
|
|
; &UpdateState: State of the statemaschine
|
|
&UpdateState="init"
|
|
; &Progress: Progressbar percentage display
|
|
&Progress=0.
|
|
; &WheelIndex: Index and icons to display the spinning wheel
|
|
&WheelIndex=0
|
|
; &SpinningWheel: comma separates list of all icons needed for the spinning wheel
|
|
&SpinningWheel="\
|
|
[=AVjT7ATDt0F40L3lq1z$l$Uz$UKIEl$1tE0x1QV38XV2@20X0800d00z3jSCyhRFh085],\
|
|
[=AVjT7ATDt0l70z0lk0zgl$Uz$UKIt$3xU0z33tV34KdVH0M2Z088111082V40R1G4H61e],\
|
|
[=AVjT7AzDt0l70z3l$1z$l$Uz$UKIdz3dU0t33uV34GdVH0F2V00811128HVp1R1KZn4hH],\
|
|
[=AVjT7AzDt0l70z3l$1z$l$Uz$UKIElq1NC041vV34GF1510G040000J1$iSCyhRJhdK2],\
|
|
[=AVjT7AzDt0l70z3l$1z$l$Uz$UKItk2xA0z03uV34GdVH0F2V008111882Z4lS1GaH6hH],\
|
|
[=AVjT7ATDt0l70z3l$1z$l$Uz$UKItk2xA0z03tV34GdVH0F2V008111882Z4lS1G5H6hH],\
|
|
[=AVjT7ATDt0l70z3l$1z$l$Uz$UKIElq1NC041wV34GF1510G040000J1$iSCyhRFhdK2],\
|
|
[=AVjT7ATDt0l70z3l$1z$l$Uz$UKIdz3dU0t33tV34GdVH0F2V00811128HVp1R1K4n4hH],\
|
|
[=AVjT7AzDt0l70z0lk0zgl$Uz$UKIt$3xU0z33uV34KdVH0M2Z088111082V40R1GZH61e],\
|
|
[=AVjT7AzDt0F40L3lq1z$l$Uz$UKIEl$1tE0x1PV38XV2@20X0800d00z3jSCyhRJh085],\
|
|
[=AVjT7AzDt0l70t3Vz1f$l$Uz$UKIt$3xU0z33uV3JGdVH7FHV028111082V40R1GZn41e],\
|
|
[=AVjT7ATDt0l70t3Vz1f$l$Uz$UKIt$3xU0z33tV3JGdVH7FHV028111082V40R1G4n41e]"
|
|
)
|
|
|
|
;
|
|
; handle [X] button and Escape
|
|
;
|
|
CLOSE "&UpdateState=""exit"""
|
|
;
|
|
; This starts the update timer and call fnHandleUpdate every 100ms
|
|
; Currently we cannot trigger faster than 100ms cause internal
|
|
; mainloop prohibits this
|
|
;
|
|
UPDATE "GOSUB OnUpdate" 100ms
|
|
|
|
SUBROUTINE fnSpinWheel
|
|
(
|
|
DIALOG.Set WHEELY STRing.TRIM(STRing.SPLIT("&SpinningWheel",",",&WheelIndex))
|
|
&WheelIndex=&WheelIndex+1.
|
|
IF (&WheelIndex>11.)
|
|
&WheelIndex=0.
|
|
RETURN
|
|
)
|
|
SUBROUTINE OnUpdate
|
|
(
|
|
GOSUB fnSpinWheel
|
|
IF "&UpdateState"=="wait"
|
|
(
|
|
; just sit and wait until started
|
|
)
|
|
ELSE IF "&UpdateState"=="init"
|
|
(
|
|
; initialize then wait until restarted
|
|
|
|
; preset buttons
|
|
DIALOG.Enable BTN_START
|
|
DIALOG.Disable BTN_STOP
|
|
; start counting on update
|
|
&UpdateState="wait"
|
|
)
|
|
ELSE IF "&UpdateState"=="start"
|
|
(
|
|
; start updating then run
|
|
|
|
; toggle buttons
|
|
DIALOG.Disable BTN_START
|
|
DIALOG.Enable BTN_STOP
|
|
; start counting on update
|
|
&UpdateState="run"
|
|
)
|
|
ELSE IF "&UpdateState"=="stop"
|
|
(
|
|
; stop updating then wait
|
|
|
|
; toggle buttons
|
|
DIALOG.Enable BTN_START
|
|
DIALOG.Disable BTN_STOP
|
|
; next state
|
|
&UpdateState="wait"
|
|
)
|
|
ELSE IF "&UpdateState"=="run"
|
|
(
|
|
; update progressbar and stay here
|
|
|
|
LOCAL &tmp
|
|
|
|
&Progress=&Progress+5.
|
|
IF (&Progress>100.)
|
|
&Progress=0.
|
|
|
|
&tmp=FORMAT.DECIMAL(1,&Progress)
|
|
; set progress-text
|
|
DIALOG.Set PROGTEXT "&tmp"+"%"
|
|
; set progress-bar
|
|
DIALOG.Set PROGBAR &Progress
|
|
)
|
|
ELSE IF "&UpdateState"=="exit"
|
|
(
|
|
DIALOG.END
|
|
)
|
|
)
|
|
)
|
|
|
|
ENDDO
|