Visio Timer Issue

Started by metuemre, June 20, 2016, 11:43:13 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

metuemre

Hi everyone,

I'm trying to design a simulation tool for our logic diagrams in visio. There is a function block called "Time Delay" which will give output of  boolean "1" if the input is boolean "1" for a certain period of time and  this time interval is  defined as TimerSP (Timer set point) in shape data as an integer.

I made a macro with timer function and I call it inside the "Time Delay" shape with CALLTHIS method if the Input of the Time Delay block is "1" and it works like a charm.

Problem starts if there are more than one Time Delay blocks that should work at the same time. In that case both "Time delay" shapes will call same macro at the same time but they don't. One timer wait for another timer to finish its work to start.

In order to overcome this issue, I thought I could use application.ontime method but couldn't find it in visio. It is available in Excel, Word or other office programs but not in Visio.

Please see my macro below. I dont know what can I do to run multiple "Time Delay" blocks at the same time. Any kind of help is appreciated

Private Sub TD_ON(shp As Visio.Shape)

Dim StartTime, EndTime, TimerSP, Elapsed
Dim value As Boolean

StartTime = Timer
value = shp.Cells("Prop.IN1.Value")
TimerSP = shp.Cells("Prop.TimeDelay.Value")
   
    If Not value Then
        StartTime = 0
        Elapsed = 0
        shp.Cells("Prop.Out.Value") = False
    Else
   
        Do While Timer < StartTime + TimerSP
            If Not value Then
            Exit Sub
            End If
        Loop
           
            EndTime = Timer
            Elapsed = EndTime - StartTime
            shp.Cells("Prop.Out.Value") = True
        End
    End If

End Sub



wapperdude

Couple of questions:
1)  Will those time blocks always have the start at the same delay?  If so, then your timer could establish start / stop global flags that each block can read.

2)  If only some times, then, it would seem if you might check for the timing coincidence, and set global flags.

3)  Use multiple timer blocks.  That way, there's no collision with the single timer block.  Also, avoids necessity for global flags, I think.  Perhaps, if block1 is running, it would make next request go to another timer block.  Sort of, sorry, this stall occupied, please use the next one (or wait).

Just some thoughts.

Visio VBA doesnot have application.ontime.

Wapperdude
Visio 2019 Pro