示例#1
0
        public async Task <Boolean> RemovePresetAsync(string preseToken)
        {
            try
            {
                if (m_Presets == null)
                {
                    m_Presets = await readPTZPresetsAsync();

                    if (m_Presets == null)
                    {
                        return(false);
                    }
                }
                PTZPreset preset = getPTZByToken(preseToken);

                if (preset != null)
                {
                    await m_ptzClient.RemovePresetAsync(m_ProfileRefToken, preset.token);

                    return(true);
                }
                return(false);
            }

            catch (Exception ex)
            {
                m_ErrorMessage = ex.Message;
                throw new OnVifException("OnVifPTZController.RemovePresetAsync", ex);
                //               return false;
            }
        }
示例#2
0
        public async Task <Boolean> setPTZPresetAsync(string preseToken)
        {
            try
            {
                if (m_Presets == null)
                {
                    m_Presets = await readPTZPresetsAsync();

                    if (m_Presets == null)
                    {
                        return(false);
                    }
                }
                PTZPreset preset = getPTZByToken(preseToken);

                OnVifServices.OnvifPTZService.SetPresetRequest request = null;

                if (preset != null)
                {
                    request = new SetPresetRequest(m_ProfileRefToken, preset.Name, preset.token);
                }
                else
                {
                    string presettoken = getfreePresetToken();
                    string presetname  = getfreePresetName();
                    request = new SetPresetRequest(m_ProfileRefToken, presetname, presettoken);
                }

                if (request != null)
                {
                    SetPresetResponse presetResponse = await m_ptzClient.SetPresetAsync(request);

                    return(true);
                }
                return(false);
            }


            catch (Exception ex)
            {
                m_ErrorMessage = ex.Message;
                throw new OnVifException("OnVifPTZController.setPTZPresetAsync", ex);
                //             return false;
            }
        }