Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Time Operations
Answer
1/9/19 1:44 PM
Dear all!
I grep the execution time from a BPMN-Model Activity and want to add e.g. 10 seconds. Are there any time operations?

Kind Regards

RE: Time Operations
Answer
11/11/16 10:06 AM as a reply to Benedikt.
Dear Benedikt,
thanks for your question. There are specific operations that allow available that allow you to manipulate the time information in ADOxx. This functionality is implemented as PROCEDURES to enable modification where needed. Please find below both functions to convert the ADOxx time stamp (in the format "00:000:00:00:00") to seconds and back again. Any manipulation can then happen on the seconds value. These procedure can be globally loaded during startup and are then available for any further processing.

Please consider the following background information: these procedure operate on "company time" for hours per day and days per year. this value have to be set accordingly before running the PROCEDURES.

An example that operates on a static time-stamp (the retrieval from the attribute is not part of this example) can be found below:
 1# define OR get the input time stamp
 2SETL sInputTime: ("00:000:00:10:43")
 3# set working days per year and working hours per day
 4SETG wdpy:251
 5SETG whpd:7.7
 6# calculate seconds using the procedure below, the reference "calculatedSeconds" is set as an outome
 7ADOTIME_TO_SEC (sInputTime) seconds:calculatedSeconds
 8CC "AdoScript" INFOBOX ("The time above is in secs: " + STR calculatedSeconds)
 9
10# update the time in seconds (add 10 secs)
11SET newSeconds: (calculatedSeconds + 10)
12# convert back to ADOxx time stamp, the "newTimeExp" will be updated to hold the converted result
13SEC_TO_ADOTIME (newSeconds) timeexp:newTimeExp
14CC "AdoScript" INFOBOX ("The new ADOxx based time string is: " + newTimeExp)


 1#*************************************************************************************
 2#
 3PROCEDURE ADOTIME_TO_SEC string:timeexp seconds:reference
 4#
 5# transforming a TIME format string into the amount of seconds
 6#
 7# Input: <"00:000:00:00:00">   (string)
 8# Output:<0>                   (integer)
 9#
10# since this procedure evaluates the amount of seconds using
11# the company specific times, the following two variables have
12# to be specified using the values from the library attributes.
13# like this:
14#                                       
15# wdpy:251 # working days per year                     
16# whpd:7.7 # working hours per day                   
17#                                                      
18# For other purpose you may take the "normal" 360/24 duration
19# as well
20#*************************************************************************************
21
22{
23  SET years: (VAL(token(timeexp,0,":")))
24  SET days: (VAL(token(timeexp,1,":")))
25  SET hours: (VAL(token(timeexp,2,":")))
26  SET min: (VAL(token(timeexp,3,":")))
27  SET sec: (VAL(token(timeexp,4,":")))
28  SET seconds: (((((((((years)*wdpy)+(days))*whpd)+(hours))*60)+(min))*60)+(sec))
29}
30#*************************************************************************************




 1#*************************************************************************************
 2PROCEDURE SEC_TO_ADOTIME real:secexp timeexp:reference
 3#                                                                                  
 4# transforming an amount of seconds into a TIME format string          
 5#                                                                                  
 6# Input: <0>                   (real)                        
 7# Output:<"00:000:00:00:00">   (string)                        
 8#                                                                  
 9# since this procedure evaluates the amount of seconds using   
10# the company specific times, the following two variables have      
11# to be specified using the values from the library attributes.    
12# like this:                                                                   
13#                                                                      
14# wdpy:251 # working days per year                                 
15# whpd:7.7 # working hours per day                                 
16#                                                                           
17# For other purpose you may take the "normal" 360/24 duration      
18# as well                                                                                                               
19#*************************************************************************************
20{
21  SET timeexp: ("")
22  SET years: (floor(secexp/(60*60*whpd*wdpy)))
23  SET secexp: (secexp-(years*(60*60*whpd*wdpy)))
24  SET days: (floor(secexp/(60*60*whpd)))
25  SET secexp: (secexp-(days*(60*60*whpd)))
26  SET hours: (floor(secexp/(60*60)))
27  SET secexp: (secexp-(hours*(60*60)))
28  SET min: (floor(secexp/(60)))
29  SET secexp: (secexp-(min*(60)))
30  SET sec: (secexp)
31  SET push:0
32
33  IF (years <10)
34     {SET push:1}
35  SET pushit:1
36  WHILE (pushit <= push)
37  {
38    SET timeexp: (timeexp + "0")
39    SET pushit: (pushit+1)
40  }
41  SET timeexp: (timeexp + STR years+":")
42  SET push:0
43  IF (days < 100)
44  {
45    SET push:1
46    IF (days < 10)
47    {
48      SET push:2
49    }
50  }
51  SET pushit:1
52  WHILE (pushit <= push)
53  {
54    SET timeexp: (timeexp + "0")
55    SET pushit: (pushit+1)
56  } 
57  SET timeexp: (timeexp + STR days+":")
58  SET push:0
59  IF (hours < 10)
60     {SET push:1}
61  SET pushit:1
62  WHILE (pushit <= push)
63  {
64    SET timeexp: (timeexp + "0")
65    SET pushit: (pushit+1)
66  } 
67  SET timeexp: (timeexp + STR hours+":") 
68  SET push:0
69  IF (min < 10)
70     {SET push:1}
71  SET pushit:1
72  WHILE (pushit <= push)
73  {
74    SET timeexp: (timeexp + "0")
75    SET pushit: (pushit+1)
76  } 
77  SET timeexp: (timeexp + STR min+":") 
78  SET push:0
79  IF (sec < 10)
80     {SET push:1}
81  SET pushit:1
82  WHILE (pushit <= push)
83  {
84    SET timeexp: (timeexp + "0")
85    SET pushit: (pushit+1)
86  } 
87  SET timeexp: (timeexp + STR sec) 
88}
89#*************************************************************************************
Attachments: Procedure_ADOTIME_TO_SEC.asc (1.2k), Procedure_SEC_TO_ADOTIME.asc (2.9k)