trigger.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 *
00004 *  Copyright (c) 2013 Boris Gromov, BioRobotics Lab at Korea Tech
00005 *  All rights reserved.
00006 *
00007 *  Redistribution and use in source and binary forms, with or without
00008 *  modification, are permitted provided that the following conditions
00009 *  are met:
00010 *
00011 *   * Redistributions of source code must retain the above copyright
00012 *     notice, this list of conditions and the following disclaimer.
00013 *   * Redistributions in binary form must reproduce the above
00014 *     copyright notice, this list of conditions and the following
00015 *     disclaimer in the documentation and/or other materials provided
00016 *     with the distribution.
00017 *   * Neither the name of the author nor other contributors may be
00018 *     used to endorse or promote products derived from this software
00019 *     without specific prior written permission.
00020 *
00021 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 *  POSSIBILITY OF SUCH DAMAGE.
00033 *********************************************************************/
00034 
00035 #ifndef _TRIGGER_H_
00036 #define _TRIGGER_H_
00037 
00038 #include <dc1394/dc1394.h>
00039 
00040 #include "camera1394stereo/Camera1394StereoConfig.h"
00041 typedef camera1394stereo::Camera1394StereoConfig Config;
00042 
00055 class Trigger
00056 {
00057 private:
00059   static const std::string trigger_mode_names_[DC1394_TRIGGER_MODE_NUM];
00061   static const std::string trigger_source_names_[DC1394_TRIGGER_SOURCE_NUM];
00063   static const std::string trigger_polarity_names_[DC1394_TRIGGER_ACTIVE_NUM];
00064 
00065   dc1394camera_t *camera_;
00066 
00067   dc1394trigger_mode_t triggerMode_;
00068   dc1394trigger_source_t triggerSource_;
00069   dc1394trigger_sources_t triggerSources_;
00070   dc1394trigger_polarity_t triggerPolarity_;
00071 
00072   dc1394switch_t externalTriggerPowerState_;
00073 
00074   bool findTriggerMode(std::string str);
00075   bool findTriggerSource(std::string str);
00076   bool findTriggerPolarity(std::string str);
00077   bool checkTriggerSource(dc1394trigger_source_t source);
00078 
00079 public:
00084   Trigger(dc1394camera_t *camera):
00085     camera_(camera), triggerSources_((dc1394trigger_sources_t){0}), externalTriggerPowerState_(DC1394_OFF)
00086   {};
00087 
00093   inline const std::string triggerModeName(dc1394trigger_mode_t mode)
00094   {
00095     if (mode >= DC1394_TRIGGER_MODE_MIN && mode <= DC1394_TRIGGER_MODE_MAX)
00096       return trigger_mode_names_[mode - DC1394_TRIGGER_MODE_MIN];
00097     else
00098       return "";
00099   }
00100 
00106   inline const std::string triggerSourceName(dc1394trigger_source_t source)
00107   {
00108     if (source >= DC1394_TRIGGER_SOURCE_MIN && source <= DC1394_TRIGGER_SOURCE_MAX)
00109       return trigger_source_names_[source - DC1394_TRIGGER_SOURCE_MIN];
00110     else
00111       return "";
00112   }
00113 
00119   inline const std::string triggerPolarityName(dc1394trigger_polarity_t polarity)
00120   {
00121     if (polarity >= DC1394_TRIGGER_ACTIVE_MIN && polarity <= DC1394_TRIGGER_ACTIVE_MAX)
00122       return trigger_polarity_names_[polarity - DC1394_TRIGGER_ACTIVE_MIN];
00123     else
00124       return "";
00125   }
00126 
00133   inline bool isPowered()
00134   {
00135     return (externalTriggerPowerState_ == DC1394_ON ? true : false);
00136   }
00137 
00138   bool enumSources(dc1394camera_t *camera, dc1394trigger_sources_t &sources);
00139   dc1394trigger_polarity_t getPolarity(dc1394camera_t *camera);
00140   bool setPolarity(dc1394camera_t *camera, dc1394trigger_polarity_t &polarity);
00141   dc1394switch_t getExternalTriggerPowerState(dc1394camera_t *camera);
00142   bool setExternalTriggerPowerState(dc1394camera_t *camera, dc1394switch_t &state);
00143   dc1394switch_t getSoftwareTriggerPowerState(dc1394camera_t *camera);
00144   bool setSoftwareTriggerPowerState(dc1394camera_t *camera, dc1394switch_t &state);
00145   dc1394trigger_mode_t getMode(dc1394camera_t *camera);
00146   bool setMode(dc1394camera_t *camera, dc1394trigger_mode_t &mode);
00147   dc1394trigger_source_t getSource(dc1394camera_t *camera);
00148   bool setSource(dc1394camera_t *camera, dc1394trigger_source_t &source);
00149 
00150   bool reconfigure(Config *newconfig);
00151   bool initialize(Config *newconfig);
00152 };
00153 
00154 #endif // _TRIGGER_H_


camera1394stereo
Author(s): Joan Pau Beltran
autogenerated on Thu Jun 6 2019 21:29:10