public int HandleOp(IWebHostEnvironment hostEnv, COp rcop) { try { using (PtzCamera ptzCam = new PtzCamera()) { int MaxDelay = 0; var cop = Add(rcop); if (cop == COp.None) { return(6000); } while (cop != COp.None) { //Debug.WriteLine("CamOps.HandleOp " + (int)cop); var delay = ptzCam.ExecuteOp(hostEnv, cop); if (delay > MaxDelay) { MaxDelay = delay; } cop = Delete(); } // Give time for Camera to move. Delay can be adjusted ptzCam.Logout(); return(MaxDelay); } } catch { return(0); } }
public COp Add(COp cop) { lock (_qLock) { try { bool _qEmpty = _queue.Count == 0; //Debug.WriteLine("CamOps.Add to Queue " + (int)cop); _queue.Enqueue(cop); //Debug.WriteLine("VCamOps.Add returning " + ((_qEmpty) ? (int)cop : (int)COp.None)); return((_qEmpty) ? cop : COp.None); // Indicate what if anything to execute COp now } catch { return(COp.None); } } }
public int ExecuteOp(IWebHostEnvironment hostEnv, COp cop) { if ((cop == COp.None) || (cop == COp.Refresh)) { return(0); } if ((int)cop <= 99) { return(GetPresetPicture(hostEnv, (int)cop)); } if (cop == PtzCamera.COp.ToggleLight) { return(ToggleLight()); } if (cop == PtzCamera.COp.TurnOnAlarm) { return(TurnOnAlarm(10)); } return(GetPtzPicture(hostEnv, (int)cop)); }