trigger.h
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2013 Boris Gromov, BioRobotics Lab at Korea Tech
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the author nor other contributors may be
18 * used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 #ifndef _TRIGGER_H_
36 #define _TRIGGER_H_
37 
38 #include <dc1394/dc1394.h>
39 
40 #include "camera1394/Camera1394Config.h"
41 typedef camera1394::Camera1394Config Config;
42 
55 class Trigger
56 {
57 private:
59  static const std::string trigger_mode_names_[DC1394_TRIGGER_MODE_NUM];
61  static const std::string trigger_source_names_[DC1394_TRIGGER_SOURCE_NUM];
63  static const std::string trigger_polarity_names_[DC1394_TRIGGER_ACTIVE_NUM];
64 
65  dc1394camera_t *camera_;
66 
67  dc1394trigger_mode_t triggerMode_;
68  dc1394trigger_source_t triggerSource_;
69  dc1394trigger_sources_t triggerSources_;
70  dc1394trigger_polarity_t triggerPolarity_;
71 
73 
74  bool findTriggerMode(std::string str);
75  bool findTriggerSource(std::string str);
76  bool findTriggerPolarity(std::string str);
77  bool checkTriggerSource(dc1394trigger_source_t source);
78 
79 public:
84  Trigger(dc1394camera_t *camera):
85  camera_(camera), triggerSources_((dc1394trigger_sources_t){0}), externalTriggerPowerState_(DC1394_OFF)
86  {};
87 
93  inline const std::string triggerModeName(dc1394trigger_mode_t mode)
94  {
95  if (mode >= DC1394_TRIGGER_MODE_MIN && mode <= DC1394_TRIGGER_MODE_MAX)
96  return trigger_mode_names_[mode - DC1394_TRIGGER_MODE_MIN];
97  else
98  return "";
99  }
100 
106  inline const std::string triggerSourceName(dc1394trigger_source_t source)
107  {
108  if (source >= DC1394_TRIGGER_SOURCE_MIN && source <= DC1394_TRIGGER_SOURCE_MAX)
109  return trigger_source_names_[source - DC1394_TRIGGER_SOURCE_MIN];
110  else
111  return "";
112  }
113 
119  inline const std::string triggerPolarityName(dc1394trigger_polarity_t polarity)
120  {
121  if (polarity >= DC1394_TRIGGER_ACTIVE_MIN && polarity <= DC1394_TRIGGER_ACTIVE_MAX)
122  return trigger_polarity_names_[polarity - DC1394_TRIGGER_ACTIVE_MIN];
123  else
124  return "";
125  }
126 
133  inline bool isPowered()
134  {
135  return (externalTriggerPowerState_ == DC1394_ON ? true : false);
136  }
137 
138  bool enumSources(dc1394camera_t *camera, dc1394trigger_sources_t &sources);
139  dc1394trigger_polarity_t getPolarity(dc1394camera_t *camera);
140  bool setPolarity(dc1394camera_t *camera, dc1394trigger_polarity_t &polarity);
141  dc1394switch_t getExternalTriggerPowerState(dc1394camera_t *camera);
142  bool setExternalTriggerPowerState(dc1394camera_t *camera, dc1394switch_t &state);
143  dc1394switch_t getSoftwareTriggerPowerState(dc1394camera_t *camera);
144  bool setSoftwareTriggerPowerState(dc1394camera_t *camera, dc1394switch_t &state);
145  dc1394trigger_mode_t getMode(dc1394camera_t *camera);
146  bool setMode(dc1394camera_t *camera, dc1394trigger_mode_t &mode);
147  dc1394trigger_source_t getSource(dc1394camera_t *camera);
148  bool setSource(dc1394camera_t *camera, dc1394trigger_source_t &source);
149 
150  bool reconfigure(Config *newconfig);
151  bool initialize(Config *newconfig);
152 };
153 
154 #endif // _TRIGGER_H_
bool enumSources(dc1394camera_t *camera, dc1394trigger_sources_t &sources)
Definition: trigger.cpp:128
dc1394trigger_polarity_t triggerPolarity_
Definition: trigger.h:70
bool isPowered()
Definition: trigger.h:133
dc1394trigger_source_t triggerSource_
Definition: trigger.h:68
static const std::string trigger_source_names_[DC1394_TRIGGER_SOURCE_NUM]
driver parameter names, corresponding to DC1394 trigger sources
Definition: trigger.h:61
bool findTriggerSource(std::string str)
Definition: trigger.cpp:79
bool findTriggerPolarity(std::string str)
Definition: trigger.cpp:100
dc1394switch_t externalTriggerPowerState_
Definition: trigger.h:72
const std::string triggerPolarityName(dc1394trigger_polarity_t polarity)
Definition: trigger.h:119
static const std::string trigger_polarity_names_[DC1394_TRIGGER_ACTIVE_NUM]
driver parameter names, corresponding to DC1394 trigger sources
Definition: trigger.h:63
dc1394trigger_sources_t triggerSources_
Definition: trigger.h:69
bool setPolarity(dc1394camera_t *camera, dc1394trigger_polarity_t &polarity)
Definition: trigger.cpp:196
const std::string triggerModeName(dc1394trigger_mode_t mode)
Definition: trigger.h:93
dc1394switch_t getSoftwareTriggerPowerState(dc1394camera_t *camera)
Definition: trigger.cpp:281
const std::string triggerSourceName(dc1394trigger_source_t source)
Definition: trigger.h:106
dc1394trigger_polarity_t getPolarity(dc1394camera_t *camera)
Definition: trigger.cpp:159
dc1394switch_t getExternalTriggerPowerState(dc1394camera_t *camera)
Definition: trigger.cpp:236
camera1394::Camera1394Config Config
Definition: trigger.h:41
bool setMode(dc1394camera_t *camera, dc1394trigger_mode_t &mode)
Definition: trigger.cpp:346
bool reconfigure(Config *newconfig)
Definition: trigger.cpp:417
dc1394trigger_mode_t triggerMode_
Definition: trigger.h:67
static const std::string trigger_mode_names_[DC1394_TRIGGER_MODE_NUM]
driver parameter names, corresponding to DC1394 trigger modes
Definition: trigger.h:59
bool initialize(Config *newconfig)
Definition: trigger.cpp:508
Trigger(dc1394camera_t *camera)
Definition: trigger.h:84
bool setExternalTriggerPowerState(dc1394camera_t *camera, dc1394switch_t &state)
Definition: trigger.cpp:257
bool checkTriggerSource(dc1394trigger_source_t source)
Definition: trigger.cpp:115
bool findTriggerMode(std::string str)
Definition: trigger.cpp:52
bool setSoftwareTriggerPowerState(dc1394camera_t *camera, dc1394switch_t &state)
Definition: trigger.cpp:301
camera1394::Camera1394Config Config
Definition: driver1394.h:53
bool setSource(dc1394camera_t *camera, dc1394trigger_source_t &source)
Definition: trigger.cpp:391
dc1394trigger_mode_t getMode(dc1394camera_t *camera)
Definition: trigger.cpp:325
dc1394camera_t * camera_
Definition: trigger.h:65
dc1394trigger_source_t getSource(dc1394camera_t *camera)
Definition: trigger.cpp:370


camera1394
Author(s): Jack O'Quin, Ken Tossell, Patrick Beeson, Nate Koenig, Andrew Howard, Damien Douxchamps, Dan Dennedy
autogenerated on Mon Jun 10 2019 12:52:31