fuzzy results with timescaledata


E

Emile

Using timescalevalues, funny things can happen

In code below you see a difference in time in date1 and date2 of 20 minutes.

Calculating pjResourceTimescaledRemainingAvailability gives strange results;
higher members of resulting collection gives an "unexpected error", making it
impossible to read out lower indexes of the array. If the difference is for
example 2 minutes, there is no problem. What is causing this en how to solve
this ? Of course there is always a workaround, but there must be an
explanation for this behaviour of timescaledata. The resource has no tasks to
do. The same occurs using pjResourceTimescaledWorkAvailability. If date1 and
date2 are identical, also funny things happen. .count seems to have a limit
(try 55 when the resolution is minutes).

Dim TSV As TimeScaleValues

Dim date1 As Date
Dim date2 As Date
Dim L As Long

date1 = DateSerial(2007, 8, 13) + TimeSerial(10, 0, 0)
date2 = DateSerial(2007, 8, 13) + TimeSerial(10, 20, 0)


Set TSV = ActiveProject.Resources(1).TimeScaleData( _
StartDate:=CStr(date1), _
EndDate:=CStr(date2), _
Type:=pjResourceTimescaledRemainingAvailability_



TimeScaleUnit:=pjTimescaleMinutes, _

Count:=1)
'calculate total
For n = 1 To TSV.Count

L = L + Val(tsvN(n).Value)

Next n
 
Ad

Advertisements

E

Emile

-Same results if data1 and data2 are variants and when leaving out cstr()

-maximum membercount of resulting collection seems to be 10 (more gives
"unexpected error" in the valueproperty of members 11+. This means that when
using the minutescale and count 1, only a difference of 10 minutes can be
calculated.
 
E

Emile

Yes it should (I stripped de code for this example, overlooked this one), thx.
It does not solve the problem though.

The strange things is that the TimeScaleValues gives errors in the
value-property when the index is above 10. if you should pass the result to
an TimeScaleValue-object, it will still mess it up.
 
R

Rod Gill

What happens if you use:

Dim TSVs As TimeScaleValues
Dim TSV As TimeScaleValue
Dim date1 As Date
Dim date2 As Date
Dim L As Long

date1 = DateSerial(2007, 8, 13) + TimeSerial(10, 0, 0)
date2 = DateSerial(2007, 8, 13) + TimeSerial(10, 20, 0)


Set TSVs = ActiveProject.Resources(1).TimeScaleData( _
StartDate:=CStr(date1), _
EndDate:=CStr(date2), _
Type:=pjResourceTimescaledRemainingAvailability_
TimeScaleUnit:=pjTimescaleMinutes, Count:=1)
'calculate total
For Each Tsv in TSVs
L = L + Val(tsv.Value)
Next


--

Rod Gill
Project MVP

Project VBA Book, for details visit:
http://www.projectvbabook.com

NEW!! Web based VBA training course delivered by me. For details visit:
http://projectservertraining.com/learning/index.aspx
 
E

Emile

Hi Rod,

The same happens.

TSVs gives 20 items, above index 10 with "unexpected errors (...) " as value.

The TSV blocks when it reaches this item.

If there is another way to get the total (without the for..next) it would
be also ok. Changing the .count in 20 gives just one TSVs-item, but then
problems occur caused by 'rounding' the start en end dates to the resolution
of .count, so this would not be appropiate in any timescale. By the way,
changing the timescaleunit (hours for example) gives similar problems with
other .count values.
 
Ad

Advertisements

E

Emile

Hi Rod,

Dim date1 en date2 as date,
values are 20 minutes as a difference (but it could be any date-value and
timescale)

date1 = dateserial(2007,8,13) + timeserial(10,0,0)
date2 = dateserial(2007,8,13) + timeserial(10,20,0)

in the project we want to know if any resourcetime is available in this
timewindow

dim tsv as timescalevalues
set tsv = activeproject.resources(1).timescaledata(Startdate:=date1,
Enddate:=date2, _

Type:=pjResourceTimescaledRemainingAvailability, _
Timescaleunit:=pjTimescaleMinutes, _
Count:=1)

if you observe the itemcollection of the tsv-object in the localswindow
you'll find that
any item with index > 10 has the value (in the localswindow): <An unexpected
error occured with the method.>

..Start is ok (gives a value), following the .count * timescale resolution.

If you take for example date1 date2 with a 20 hour difference as as
timescaleunit pjTimeScaleHours you'll get the same effects.

Asking for any tsv().value in the Immediatewindow will give 1004 :An
unexpected error occured with the method

it is possible to pass through the tsv() to a timescalevalue obejct, , but
it will result in 1004 again.

This means that we only can use 10 times the timescale * count as maximum
gap between date1 and date2. Changing the .count gives rounding problems and
also has it limitations:
..count can be 50 as max so i cannot easy workaround it by do a .count =
datediff("m",date1,date2), if we forget about the roundingoff issue.

It seems impossible of just give the amount of minutes between 2 random
moments, only when you accept rough rounded data, without a workaround.

Sub ABC()

dim date1 as date
dim date2 as date
dim tsv as timescalevalues

date1 = dateserial(2007,8,13) + timeserial(10,0,0)\
date2 = dateserial(2007,8,13) + timeserial(10,20,0)

set tsv = activeproject.resources(1).timescaledata(Startdate:=date1,
Enddate:=date2, _

Type:=pjResourceTimescaledRemainingAvailability, _
Timescaleunit:=pjTimescaleMinutes, _
Count:=1)

'look at the locals, try to read the value of tsv(11) ... tsv(20) int he
immediatewindow

'read out values, can be done with for...next or for each, it wil not work
for any n, as long tsv.count > 10

for n = 1 to tsv.count
'something that reads tsv(n) or timescalevalue = tsv(n), then read out
timescale
next n

end sub
 
Ad

Advertisements

E

Emile

Anybody found another approach to avoid the limitations of timescaledata ?

thx in advance,
rgds
Emile.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top