Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clean-libraries
Commits
803884f4
Commit
803884f4
authored
Nov 06, 2006
by
Rinus Plasmeijer
Browse files
date and time tasks added - MJP
parent
08a94a8e
Changes
5
Hide whitespace changes
Inline
Side-by-side
libraries/htmlGEC/htmlButtons.dcl
View file @
803884f4
...
...
@@ -14,7 +14,8 @@ derive gerda (,), (,,), (,,,), (<->), <|>, HtmlDate, HtmlTime, DisplayMode, But
instance
toBool
CheckBox
,
Button
,
RadioButton
// True if checkbox checked, button pressed
instance
toInt
PullDownMenu
// Current index in pull down list
instance
toString
PullDownMenu
// Corresponding element in pull down list
instance
==
PasswordBox
instance
==
PasswordBox
,
HtmlDate
,
HtmlTime
instance
<
HtmlDate
,
HtmlTime
// lay out
::
<->
a
b
=
(<->)
infixl
5
a
b
// place b to the left of a
...
...
@@ -49,4 +50,4 @@ instance == PasswordBox
::
HtmlDate
=
Date
Int
Int
Int
// Day Month Year
::
HtmlTime
=
Time
Int
Int
Int
// Hours Minutes Seconds
getTimeAndDate
::
!*
HSt
->
*(!
HtmlTime
,!
HtmlDate
,!*
HSt
)
getTimeAndDate
::
!*
HSt
->
*(!
(!
HtmlTime
,!
HtmlDate
)
,!*
HSt
)
libraries/htmlGEC/htmlButtons.icl
View file @
803884f4
...
...
@@ -322,13 +322,13 @@ mkBimapEditor inIDataId {map_to,map_from} hst
import
StdTime
getTimeAndDate
::
!*
HSt
->
*(!
HtmlTime
,!
HtmlDate
,!*
HSt
)
getTimeAndDate
::
!*
HSt
->
*(!
(!
HtmlTime
,!
HtmlDate
)
,!*
HSt
)
getTimeAndDate
hst
#
(
time
,
hst
)
=
accWorldHSt
getCurrentTime
hst
#
htmltime
=
Time
time
.
hours
time
.
minutes
time
.
seconds
#
(
date
,
hst
)
=
accWorldHSt
getCurrentDate
hst
#
htmldate
=
Date
date
.
day
date
.
month
date
.
year
=
(
htmltime
,
htmldate
,
hst
)
=
(
(
htmltime
,
htmldate
)
,
hst
)
gForm
{|
TextArea
|}
(
init
,
formid
)
hst
#
(
cntr
,
hst
)
=
CntrHSt
hst
...
...
@@ -416,3 +416,27 @@ where
instance
==
PasswordBox
where
(==)
(
PasswordBox
psw1
)
(
PasswordBox
psw2
)
=
psw1
==
psw2
instance
==
HtmlTime
where
(==)
(
Time
hrs0
min0
sec0
)
(
Time
hrs1
min1
sec1
)
=
hrs0
==
hrs1
&&
min0
==
min1
&&
sec0
==
sec1
instance
<
HtmlTime
where
(<)
(
Time
hrs0
min0
sec0
)
(
Time
hrs1
min1
sec1
)
|
hrs0
<
hrs1
=
True
|
hrs0
==
hrs1
&&
min0
<
min1
=
True
|
hrs0
==
hrs1
&&
min0
==
min1
&&
sec0
<
sec1
=
True
=
False
instance
==
HtmlDate
where
(==)
(
Date
day0
month0
year0
)
(
Date
day1
month1
year1
)
=
day0
==
day1
&&
month0
==
month1
&&
year0
==
year1
instance
<
HtmlDate
where
(<)
(
Date
day0
month0
year0
)
(
Date
day1
month1
year1
)
|
year0
<
year1
=
True
|
year0
==
year1
&&
month0
<
month1
=
True
|
year0
==
year1
&&
month0
==
month1
&&
day0
<
day1
=
True
=
False
libraries/htmlGEC/htmlFormData.dcl
View file @
803884f4
...
...
@@ -4,7 +4,7 @@ definition module htmlFormData
// (c) 2005 - MJP
import
htmlDataDef
import
StdMaybe
,
StdBool
import
StdMaybe
,
StdBool
,
htmlHandler
::
FormId
d
// properties one has to assign to any form
=
{
id
::
!
String
// id *uniquely* identifying the form
...
...
@@ -52,8 +52,8 @@ import StdMaybe, StdBool
,
form
::
[
BodyTag
]
// html code to create the form, representing view domain (look)
}
::
InIDataId
d
// Often used combination
:==
(
Init
,
FormId
d
)
::
InIDataId
d
:==
(
Init
,
FormId
d
)
// Often used parameter of iData editors
::
IDataFun
a
:==
St
*
HSt
(
Form
a
)
// Often used iData HSt State transition functions
// **** easy creation of FormId's ****
...
...
libraries/htmlGEC/htmlTask.dcl
View file @
803884f4
...
...
@@ -7,73 +7,92 @@ import StdHtml
::
*
TSt
// task state
::
Task
a
:==
St
*
TSt
a
// an interactive task
::
IDataFun
a
:==
St
*
HSt
(
Form
a
)
// an iData Form
/* Initiating the iTask library:
startTask :: start function for iTasks
*/
startTask
::
(
Task
a
)
*
HSt
->
([
BodyTag
],
HSt
)
|
iData
a
/*
startTask :: start function for iTasks
/* Promote any TSt state transition function to an iTask:
mkTask :: function will only be called when it is its turn to be activated
Also needed for defining recursive tasks
*/
mkTask
::
(*
TSt
->
*(
a
,*
TSt
))
->
(
Task
a
)
|
iData
a
/* Sequential Tasks:
STask :: a Sequential iTask
STask_button :: do corresponding iTask when button pressed
STasks :: do all iTasks one after another, task completed when all done
CTask_button :: Choose one iTask from list, depending on button pressed
CTask_pdmenu :: Choose one iTask from list, depending on pulldownmenu item selected
MCTask_ckbox :: Multiple Choice of iTasks, depending on marked checkboxes
PCTask2 :: do both iTasks in any order (paralel), task completed and ends as soon as first one done
PCTasks :: do all iTasks in any order (paralel), task completed and ends as soon as first one done
PTask2 :: do both iTasks in any order (paralel), task completed when both done
PTasks :: do all iTasks in any order (paralel), task completed when all done
PMilestoneTasks :: do all iTasks in any order (paralel), task completed (but not ended) as soon as first one done
returnTask :: return the value and show it, no IO action from the user required
returnVF :: return the value and show the code, no IO action from the user required
returnV :: return the value, no IO action from the user required
returnF :: add html code
appIData :: lift iData editors to iTask domain
mkTask :: promote TSt state function to an iTask, i.e. task will only be called when it is its turn to be activated
Needed for defining recursive tasks
mkRTask :: Remote Task: split indicated task in two tasks: a calling task and a receiving task
the caller will wait until the receiver has completed the task
mkRTaskCall :: as mkRTask, but the caller will provide input for the remote task
mkRDynTaskCall :: a remote task is set up, but the task that is created will be determined dynamically !
BE CAREFUL: static dynamics are used here, will work only for one exectable.
*/
startTask
::
(
Task
a
)
*
HSt
->
([
BodyTag
],
HSt
)
|
iData
a
mkTask
::
(*
TSt
->
*(
a
,*
TSt
))
->
(
Task
a
)
|
iData
a
STask
::
String
a
->
(
Task
a
)
|
iData
a
STask_button
::
String
(
Task
a
)
->
(
Task
a
)
|
iData
a
STasks
::
[(
String
,
Task
a
)]
->
(
Task
[
a
])
|
iData
a
/* Choose one Task out of n:
CTask_button :: Choose one iTask from list, depending on button pressed
CTask_pdmenu :: Choose one iTask from list, depending on pulldownmenu item selected
*/
CTask_button
::
[(
String
,
Task
a
)]
->
(
Task
a
)
|
iData
a
CTask_pdmenu
::
[(
String
,
Task
a
)]
->
(
Task
a
)
|
iData
a
/* Choose m Tasks out of n:
MCTask_ckbox :: Multiple Choice of iTasks, depending on marked checkboxes
*/
MCTask_ckbox
::
[(
String
,
Task
a
)]
->
(
Task
[
a
])
|
iData
a
/* Do m Tasks parallel / interleaved and FINISH as soon as SOME Task completes:
PCTask2 :: do both iTasks in any order, task completed and ends as soon as first one done
PCTasks :: do all iTasks in any order, task completed and ends as soon as first one done
*/
PCTask2
::
(
Task
a
,
Task
a
)
->
(
Task
a
)
|
iData
a
PCTasks
::
[(
String
,
Task
a
)]
->
(
Task
a
)
|
iData
a
/* Do Tasks parallel / interleaved and FINISH when ALL Tasks done:
PTask2 :: do both iTasks in any order (paralel), task completed when both done
PTasks :: do all iTasks in any order (paralel), task completed when all done
PMilestoneTasks :: do all iTasks in any order (paralel), task completed when all done
but continue with next task as soon as SOME Task completes
*/
PTask2
::
(
Task
a
,
Task
b
)
->
(
Task
(
a
,
b
))
|
iData
a
&
iData
b
PTasks
::
[(
String
,
Task
a
)]
->
(
Task
[
a
])
|
iData
a
PMilestoneTasks
::
[(
String
,
Task
a
)]
->
(
Task
[
a
])
|
iData
a
/* Tasks that do not require IO actions from the user:
returnV :: return the value
returnTask :: return the value and show it
returnVF :: return the value and show the Html code specified
returnF :: add html code
*/
returnV
::
a
->
(
Task
a
)
|
iData
a
returnTask
::
a
->
(
Task
a
)
|
iData
a
returnVF
::
a
[
BodyTag
]
->
(
Task
a
)
|
iData
a
returnV
::
a
->
(
Task
a
)
|
iData
a
returnF
::
[
BodyTag
]
->
TSt
->
TSt
appIData
::
(
IDataFun
a
)
->
(
Task
a
)
|
iData
a
/* Setting up communication channels between users:
mkRTask :: Remote Task: split indicated task in two tasks: a calling task and a receiving task
the caller will wait until the receiver has completed the task
mkRTaskCall :: as mkRTask, but the caller will provide input for the remote task
mkRDynTaskCall :: a remote task is set up, but the task that is created will be determined dynamically !
BE CAREFUL: static dynamics are used here, will work only for one exectable.
*/
mkRTask
::
String
(
Task
a
)
*
TSt
->
((
Task
a
,
Task
a
),*
TSt
)
|
iData
a
mkRTaskCall
::
String
b
(
b
->
Task
a
)
*
TSt
->
((
b
->
Task
a
,
Task
a
),*
TSt
)
|
iData
a
&
iData
b
mkRDynTaskCall
::
String
a
*
TSt
->
(((
Task
a
)
->
(
Task
a
),
Task
a
),*
TSt
)
|
iData
a
/* Time and Date management:
waitForTimeTask :: Task is done when time has come
waitForDateTask :: Task is done when date has come
*/
waitForTimeTask
::
HtmlTime
->
(
Task
HtmlTime
)
waitForDateTask
::
HtmlDate
->
(
Task
HtmlDate
)
/* Lifting iData domain to iTask domain
appIData :: lift iData editors to iTask domain
appHSt :: lift HSt domain to TSt domain
*/
appIData
::
(
IDataFun
a
)
->
(
Task
a
)
|
iData
a
appHSt
::
(
HSt
->
(
a
,
HSt
))
TSt
->
(
a
,
TSt
)
libraries/htmlGEC/htmlTask.icl
View file @
803884f4
...
...
@@ -344,6 +344,28 @@ where
defaulttask
=
STask
"DefaultTask"
a
// time and date related tasks
waitForTimeTask
::
HtmlTime
->
(
Task
HtmlTime
)
waitForTimeTask
time
=
\
tst
->
mkTask
waitForTimeTask`
tst
where
waitForTimeTask`
tst
=:((
i
,
myturn
,
html
),
hst
)
#
taskId
=
"Stask_"
<+++
mkTaskNr
i
#
(
taskdone
,
hst
)
=
mkStoreForm
(
Init
,
sFormId
taskId
(
False
,
time
))
id
hst
// remember time
#
((
currtime
,_),
hst
)
=
getTimeAndDate
hst
|
currtime
<
time
=
(
time
,((
i
,
True
,
html
<|.|>
[
Txt
(
"Waiting for time "
):[
toHtml
time
]]),
hst
))
=
(
time
,((
i
,
myturn
,
html
),
hst
))
waitForDateTask
::
HtmlDate
->
(
Task
HtmlDate
)
waitForDateTask
date
=
\
tst
->
mkTask
waitForDateTask`
tst
where
waitForDateTask`
tst
=:((
i
,
myturn
,
html
),
hst
)
#
taskId
=
"Stask_"
<+++
mkTaskNr
i
#
(
taskdone
,
hst
)
=
mkStoreForm
(
Init
,
sFormId
taskId
(
False
,
date
))
id
hst
// remember date
#
((_,
currdate
),
hst
)
=
getTimeAndDate
hst
|
currdate
<
date
=
(
date
,((
i
,
True
,
html
<|.|>
[
Txt
(
"Waiting for date "
):[
toHtml
date
]]),
hst
))
=
(
date
,((
i
,
myturn
,
html
),
hst
))
// utility section
...
...
@@ -358,6 +380,11 @@ where
#
(
idata
,
hst
)
=
idatafun
hst
#
(_,((
i
,
adone
,
ahtml
),
hst
))
=
STask
"Done"
Niks
((
i
,
True
,[]),
hst
)
=
(
idata
.
value
,((
i
,
adone
,
html
<|.|>
if
adone
idata
.
form
(
idata
.
form
<|.|>
ahtml
)),
hst
))
appHSt
::
(
HSt
->
(
a
,
HSt
))
TSt
->
(
a
,
TSt
)
appHSt
hstfun
tst
=:((
i
,
myturn
,
html
),
hst
)
#
(
a
,
hst
)
=
hstfun
hst
=
(
a
,((
i
,
myturn
,
html
),
hst
))
// debugging code
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment