Exemplo n.º 1
0
        private bool StartPTZ(IVideoSourceConfig vsConfig, int index)
        {
            CLocalSystem.WriteDebugLog(string.Format("CHKPTZAction({0}).StartPTZ Begin...", Name));

            IPTZCtrl ptz = GetPTZCtrl(vsConfig);

            if (ptz != null)
            {
                if (System.Threading.Monitor.TryEnter(ptz))
                {
                    try
                    {
                        if (ptz.GotoPreset(index))
                        {
                            CLocalSystem.WriteDebugLog(string.Format("CHKPTZAction({0}).StartPTZ OK: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index));

                            int interval = PTZConfig.Interval;
                            if (interval > 0)
                            {
                                System.Threading.Thread.Sleep(interval);
                            }
                            return(true);
                        }
                        else
                        {
                            CLocalSystem.WriteErrorLog(string.Format("CHKPTZAction({0}).StartPTZ GOTO_PRESET Failed: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index));
                        }
                    }
                    catch (Exception e)
                    {
                        CLocalSystem.WriteErrorLog(string.Format("CHKPTZAction({0}).StartPTZ(PTZVSName={1}, Channel={2}, PresetIndex={3}) Exception: {4}", Name, vsConfig.Name, vsConfig.Channel, index, e));
                    }
                    finally
                    {
                        System.Threading.Monitor.Exit(ptz);
                    }
                }
                else
                {
                    CLocalSystem.WriteDebugLog(string.Format("CHKPTZAction({0}).StartPTZ TryEnter Failed: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index));
                }
            }
            else
            {
                CLocalSystem.WriteErrorLog(string.Format("CHKPTZAction({0}).StartPTZ GetHKPTZCtrl Failed: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index));
            }
            return(false);
        }
Exemplo n.º 2
0
        private bool StartPTZ(IVideoSourceConfig vsConfig, int index)
        {
            CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}).StartPTZ Begin...", Name));

            IPTZCtrl ptz = GetPTZCtrl(vsConfig.Channel);

            if (ptz != null)
            {
                if (ptz.GotoPreset(index))
                {
                    CLocalSystem.WriteDebugLog(string.Format("CPTZAction({0}).StartPTZ OK: PTZVSName={1}, Channel={2}, PresetIndex={3}", Name, vsConfig.Name, vsConfig.Channel, index));

                    int interval = PTZConfig.Interval;
                    if (interval > 0)
                    {
                        System.Threading.Thread.Sleep(interval);
                    }
                    return(true);
                }
            }
            return(false);
        }