i am writing some simulator programme and at some point some event is triggered for example, a sensor fails, So when a sensor fails i want to start a timer for this sensor which inreement until time T to offset the fail state.
i have 72 sensors and i can have more sensors failing so i can not assign a timer control for each if so i think i will have to put 72 timers.
in short -i have 72 sensors
-an randomly selected sensor can fail
- when it fails i give it a random time to come off the fail state (offset)
-timer for this bay to start counting towards offset time
- sensor to come off the fail state when counter reaches the offset time.
-****my problem is i have more than a bay which can fail so how can i have each bay that fails get tracked by a timer***
'[AS] 6/4/2009 occassionaly a sensor fails Private Sub tmrRandomSensorFailure_Timer() Dim intbay As Integer Dim intIdletime As Integer mintFailTimer = mintFailTimer + 1 If mintFailTimer = mintNextFailTime Then mintMyValue = Int((100 * Rnd) + 1) 'get a random number between 1 and 100 ' If mintMyValue <= mintFailRate Then ' if the randomly selected number falls under failrate then cause a sensor failure mintMyValue = Int((72 * Rnd) + 1) ' pick a bay between 0 and 72 at random cboBayStatus(mintMyValue - 1).ListIndex = 0 ' set this combo to sensor failure intbay = mintMyValue ' this is the bay set to fail state intIdletime = mintFailTime + (Int(-mintOffsetTime * Rnd) + mintOffsetTime) ' time for which the bay is goin to remain in fail state marrBayTrack(intbay) = intIdletime ' save the idle time in an array position which matches its bay marrCounter(intbay) = marrCounter(intbay) + 1 '******* Call cmdSetState_Click ' Set the bay to sensor failure mintNextFailTime = Int((mintSFMax - mintSFmin + 1) * Rnd) + mintSFmin ' determine the next random time a sensor is gonna fail ' End If mintFailTimer = 0 ' reset the timer and wait for the next fail time End If End Sub