On the basis of XSample_56 examples () and XSample_14 () xdemo.exe eXPress ++ developed function, for display of a stage of process with very exact adaptive forecasting of time of execution.
Type of a window of display of a stage of process and forecast of time of execution:
At first it is necessary for use of this function:
- to declare variables;
- to define the top limit of number of events in process;
- to measure time of the beginning of process;
- to organize a display and progress-bar window.
Code: Select all
LOCAL GetList := {}, oMainDlg
LOCAL oProgress, oDialog, lOk := .t., oButton, nEvent, mp1, mp2, oXbp
PUBLIC oSay1, oSay2, oSay3, oSay4, oSay5, oSay6, oSay7, oSay8, oSay9, oSay10, Mess98, Mess99
Code: Select all
// Подготовка данных для отображения графического прогресс-бар
// Определить значение Wsego
DIRCHANGE(M_ApplsPath+"\OldAppls") // Перейти в папку с БД старой модели
CLOSE ALL
USE Object EXCLUSIVE NEW;N_Obj = RECCOUNT()
USE Priz_ob EXCLUSIVE NEW;N_Pro = RECCOUNT()
USE Priz_per EXCLUSIVE NEW;N_Prp = RECCOUNT()
USE ObInfZag EXCLUSIVE NEW;N_Zag = RECCOUNT() // БД используется 2 раза
USE ObInfKpr EXCLUSIVE NEW;N_Kpr = RECCOUNT()
Wsego = N_Obj + N_Pro + N_Prp + 2*N_Zag + N_Kpr // Задание максимальной величины параметра Time
Time_Progress = 0
Code: Select all
// Прошло секунд с начала процесса
// Процесс может идти больше суток, поэтому для определения
// во всех случаях вычисляется время, прошедшее с начала года
T_Mess1 = "Начало: "+TIME() // Начало
Sec_1 = (DOY(DATE())-1)*86400+SECONDS()
Code: Select all
// Отображение стадии исполнения. Будет написано прямо в окне Progress-bar
@ 0,0 DCGROUP oGroup1 CAPTION 'Стадии исполнения процесса' FONT "6.Helv" SIZE 105,7.5 ;
PARENT oTabPage1
@ 9,0 DCGROUP oGroup2 CAPTION 'Прогноз времени исполнения' FONT "6.Helv" SIZE 105,5.5 ;
PARENT oTabPage2
s = 1
@s++,1 DCSAY "" SAYSIZE 100 SAYOBJECT oSay1 FONT "10.Helv"
@s++,1 DCSAY "" SAYSIZE 100 SAYOBJECT oSay2 FONT "10.Helv"
@s++,1 DCSAY "" SAYSIZE 100 SAYOBJECT oSay3 FONT "10.Helv"
@s++,1 DCSAY "" SAYSIZE 100 SAYOBJECT oSay4 FONT "10.Helv"
@s++,1 DCSAY "" SAYSIZE 100 SAYOBJECT oSay5 FONT "10.Helv"
@s++,1 DCSAY "" SAYSIZE 100 SAYOBJECT oSay6 FONT "10.Helv"
s++
@s++,1 DCSAY "" SAYSIZE 100 SAYOBJECT oSay7 FONT "10.HelvBold"
s++
@0.2+s++,1 DCSAY "" SAYSIZE 100 SAYOBJECT oSay98 FONT "8.Courier Bold" COLOR GRA_CLR_BLUE
@1.5+s ,1 DCSAY "" SAYSIZE 100 SAYOBJECT oSay99 FONT "8.Courier Bold" COLOR GRA_CLR_BLUE
@s ,1 DCPROGRESS oProgress ;
SIZE 95,1.5 ;
PERCENT ;
EVERY INT(Wsego/100) ; // Кол-во обновлений изображения
MAXCOUNT Wsego ;
COLOR GRA_CLR_CYAN // Цвет полосы
@s++,97 DCPUSHBUTTON CAPTION '&Cancel' ;
ACTION {||lOk:=.f.} OBJECT oButton ;
SIZE 7,1.5
DCREAD GUI ;
TITLE '5.1. Конвертер приложения из старого стандарта БД в новый' ;
PARENT @oDialog ;
FIT ;
EXIT ;
MODAL
oDialog:show()
Then there are the cycles corresponding to stages or steps of execution of process with the address from a body of a cycle to offered function. One of such цаклов is brought below.
Code: Select all
// Конвертирование БД классификационных шкал и градаций
oSay1:SetCaption("Шаг 1-й из 6. Конвертирование БД классификационных шкал и градаций")
CLOSE ALL
DIRCHANGE(M_NewAppl) // Перейти в папку с БД новой модели
USE Classes EXCLUSIVE;ZAP
DIRCHANGE(M_ApplsPath+"\OldAppls") // Перейти в папку с БД старой модели
USE Object EXCLUSIVE NEW
DBGOTOP()
DO WHILE .NOT. EOF()
M_Kod = Kod
M_Name = Name
DIRCHANGE(M_NewAppl) // Перейти в папку с БД новой модели
SELECT Classes
APPEND BLANK
REPLACE Kod_clas WITH M_Kod
REPLACE Name WITH M_Name
DIRCHANGE(M_ApplsPath+"\OldAppls") // Перейти в папку с БД старой модели
SELECT Object
DBSKIP(1)
Time_Progress (++Time_Progress, Wsego, oProgress, lOk )
ENDDO
oSay1:SetCaption(oSay1:caption+" - Готово ")
And at last initial code of the function:
Code: Select all
***********************************************************************************************************
****** Графический прогресс-бар (на основе примера XSample_14() xdemo.exe)
***********************************************************************************************************
STATIC FUNCTION Time_Progress (Time_Progress, Wsego, oProgress, lOk )
LOCAL nMaxCount := Wsego
x = Time_Progress
** Отображение занимает очень много времени, поэтому
** Если Wsego > 100
** показывать прогресс не для всех х, а только для таких,
** которые нацело делятся на Wsego/100
IF x < 100 .OR. (x+1) = Wsego // Всегда показывать прогресс в начале и конце
ELSE // и для малого числа событий: Wsego < 100
Wsego100 = ROUND(Wsego/100,0)
IF Wsego100 > 1 .AND. (x+1) <> Wsego100*INT((x+1)/Wsego100)
RETURN NIL
ENDIF
ENDIF
*** Индикация времени исполнения
***** Процесс может идти больше суток, поэтому для определения
***** во всех случаях вычисляется время, прошедшее с начала года
* T_Mess1 = "Начало: "+TIME() // Начало
***** Прошло секунд с начала процесса
PUBLIC T_Mess2 := "ch:mi:se"
Sec_2 = (DOY(DATE())-1)*86400+SECONDS() - Sec_1
ch2 = INT(Sec_2/3600) && Часы
mm2 = INT(Sec_2/60)-ch2*60 && Минуты
cc2 = Sec_2-ch2*3600-mm2*60 && Секунды
T_Mess2 = "Прошло: "+ALLTRIM(STRTRAN(T_Mess2,"ch",STR(ch2,15)))
T_Mess2 = STRTRAN(T_Mess2,"mi",STRTRAN(STR(mm2,2)," ","0"))
T_Mess2 = STRTRAN(T_Mess2,"se",STRTRAN(STR(cc2,2)," ","0"))
*@19,2 SAY T_Mess2+" всего: "+ALLTRIM(STR(Sec_2,17))+" сек."
PUBLIC T_Mess3 := "ch:mi:se" // Осталось
Sec_3 = Sec_2*Wsego/x && Прогн.длит.исп. в секундах
ch3 = INT(Sec_3/3600) && Часы
mm3 = INT(Sec_3/60)-ch3*60 && Минуты
cc3 = Sec_3-ch3*3600-mm3*60 && Секунды
T_Mess3 = ALLTRIM(STRTRAN(T_Mess3,"ch",STR(ch3,15)))
T_Mess3 = STRTRAN(T_Mess3,"mi",STRTRAN(STR(mm3,2)," ","0"))
T_Mess3 = STRTRAN(T_Mess3,"se",STRTRAN(STR(cc3,2)," ","0"))
*@20,2 SAY T_Mess3+" всего: "+ALLTRIM(STR(Sec_3,17))+" сек."
PUBLIC T_Mess4 := "ch:mi:se" // Окончание
Sec_4 = Sec_1 + Sec_3 - (DOY(DATE())-1)*86400
ch4 = INT(Sec_4/3600) && Часы
mm4 = INT(Sec_4/60)-ch4*60 && Минуты
cc4 = Sec_4-ch4*3600-mm4*60 && Секунды
T_Mess4 = "Окончание: "+ALLTRIM(STRTRAN(T_Mess4,"ch",STR(ch4,15)))
T_Mess4 = STRTRAN(T_Mess4,"mi",STRTRAN(STR(mm4,2)," ","0"))
T_Mess4 = STRTRAN(T_Mess4,"se",STRTRAN(STR(cc4,2)," ","0"))
*@21,2 SAY T_Mess4+" всего: "+ALLTRIM(STR(Sec_4,17))+" сек.с нач.суток"
PUBLIC T_Mess5 := "Средн.время обработки 1-го объекта: ch:mi:se"
Sec_5 = Sec_2/x
ch5 = INT(Sec_5/3600) && Часы
mm5 = INT(Sec_5/60)-ch5*60 && Минуты
cc5 = Sec_5-ch5*3600-mm5*60 && Секунды
T_Mess5 = ALLTRIM(STRTRAN(T_Mess5,"ch",STR(ch5,15)))
T_Mess5 = STRTRAN(T_Mess5,"mi",STRTRAN(STR(mm5,2)," ","0"))
T_Mess5 = STRTRAN(T_Mess5,"se",STRTRAN(STR(cc5,2)," ","0"))
*@22,2 SAY T_Mess5+" всего: "+ALLTRIM(STR(Sec_5,17))+" сек."
PUBLIC T_Mess6 := "ch:mi:se" // Осталось
Sec_6 = Sec_3 - Sec_2
ch6 = INT(Sec_6/3600) && Часы
mm6 = INT(Sec_6/60)-ch6*60 && Минуты
cc6 = Sec_6-ch6*3600-mm6*60 && Секунды
T_Mess6 = "Осталось: "+ALLTRIM(STRTRAN(T_Mess6,"ch",STR(ch6,15)))
T_Mess6 = STRTRAN(T_Mess6,"mi",STRTRAN(STR(mm6,2)," ","0"))
T_Mess6 = STRTRAN(T_Mess6,"se",STRTRAN(STR(cc6,2)," ","0"))
*@23,2 SAY T_Mess6+" всего: "+ALLTRIM(STR(Sec_6,17))+" сек."
Mess98 = T_Mess1+SPACE(95-LEN(T_Mess1)-LEN(T_Mess4))+T_Mess4 // Начало, окончание (прогноз)
oSay98:SetCaption(Mess98);oSay98:SetCaption(oSay98:caption)
Mess99 = T_Mess2+SPACE(95-LEN(T_Mess2)-LEN(T_Mess6))+T_Mess6 // Прошло, осталось (прогноз)
oSay99:SetCaption(Mess99);oSay99:SetCaption(oSay99:caption)
DC_GetProgress( oProgress, Time_Progress ) // Отображение графического Progress-bar
DC_AppEvent( @lOk, 0, .01 )
RETURN lOk
End:
Code: Select all
oSay7:SetCaption("КОНВЕРТИРОВАНИЕ ПРИЛОЖЕНИЯ ИЗ СТАРОГО СТАНДАРТА БД В НОВЫЙ ЗАВЕРШЕНО УСПЕШНО!!!")
oSay7:SetCaption(oSay7:caption)
oButton:SetCaption('&Ok') // Деструктурирование окна отображения графического Progress-bar
DC_AppEvent( @lOk )
oDialog:Destroy()
Is once again glad to express huge gratitude to Roger. With support of such old old salt, as Roger, the farthest and risky transatlantic swimming looks as the most fascinating sea cruise on a fine high-speed clipper under all sails.
(Update: 02.07.12 )