public void Tick()
{
try
{
//time since last tick
var ts = new TimeSpan(Helper.Now.Ticks - _lastRun);
_lastRun = Helper.Now.Ticks;
_secondCountNew = ts.Milliseconds / 1000.0;
if (Micobject.schedule.active)
{
if (CheckSchedule()) goto skip;
}
if (!IsEnabled) goto skip;
SoundDetected = SoundRecentlyDetected;
if (FlashCounter > DateTime.MinValue)
{
double iFc = (FlashCounter - Helper.Now).TotalSeconds;
if (SoundDetected)
{
InactiveRecord = 0;
if (Micobject.alerts.mode != "nosound" &&
(Micobject.detector.recordondetect || Micobject.detector.recordonalert))
{
var cc = CameraControl;
if (cc != null)
cc.InactiveRecord = 0;
}
}
if (iFc < 9)
SoundDetected = false;
if (iFc < 1)
{
UpdateFloorplans(false);
FlashCounter = DateTime.MinValue;
}
}
_tickThrottle += _secondCountNew;
if (_tickThrottle > 1 && IsEnabled) //every second
{
if (CheckReconnect()) goto skip;
CheckReconnectInterval(_tickThrottle);
CheckDisconnect();
if (Recording && !SoundDetected && !ForcedRecording)
{
InactiveRecord += _tickThrottle;
}
if (_levels!=null)
{
CheckVLCTimeStamp();
}
if (Helper.HasFeature(Enums.Features.Recording))
{
CheckRecord();
}
_tickThrottle = 0;
}
CheckAlert(_secondCountNew);
skip:
;
}
catch (Exception ex)
{
ErrorHandler?.Invoke(ex.Message);
}
if (_requestRefresh)
{
_requestRefresh = false;
Invalidate();
}
}