00001 #ifndef FCAM_F2_FLASH_H
00002 #define FCAM_F2_FLASH_H
00003
00004
00005 #include "../Flash.h"
00006 #include "PhidgetDevice.h"
00007 #include "../Time.h"
00008 #include <vector>
00009 #include <stdio.h>
00013 namespace FCam {
00014 namespace F2 {
00016 class Flash : public FCam::Flash {
00017 public:
00018
00023 Flash(int phidgetOutputIndex = 0);
00024 ~Flash();
00025
00026
00027 int minDuration() {return 0;}
00028 int maxDuration() {return 0;}
00029
00030
00031 float minBrightness() {return 0.0f;}
00032 float maxBrightness() {return 0.0f;}
00033
00034
00039 void fire(float brightness, int duration);
00041 int fireLatency() {return 127*1000;}
00043 void startStrobe();
00045 void stopStrobe();
00046
00047
00048 float getBrightness(Time) {return 0.0f;}
00049
00050
00051 float getBrightness(Time, Time) {return 0.0f;}
00052
00053 void tagFrame(FCam::Frame * f) {};
00054
00055 int latencyGuess;
00056
00058 class StrobeStartAction : public CopyableAction<StrobeStartAction> {
00059 public:
00061 StrobeStartAction(Flash *f);
00063 StrobeStartAction(Flash *f, int t);
00065 virtual void doAction();
00066 protected:
00068 Flash *flash;
00069 };
00071 class StrobeStopAction : public CopyableAction<StrobeStopAction> {
00072 public:
00074 StrobeStopAction(Flash *f);
00076 StrobeStopAction(Flash *f, int time);
00078 virtual void doAction();
00079 protected:
00081 Flash *flash;
00082 };
00083
00084
00085 private:
00088 class PhidgetFlash : public FCam::F2::PhidgetDevice {
00089 public:
00091 bool triggerFlash(int flashOutputIndex) {
00092 if (PhidgetDevice::phidgetsAvailable) {
00093 CPhidgetInterfaceKit_setOutputState(PhidgetDevice::ifKit, flashOutputIndex, true);
00094 CPhidgetInterfaceKit_setOutputState(PhidgetDevice::ifKit, flashOutputIndex, false);
00095 return true;
00096 } else {
00097 printf("Phidgets aren't available. The flash will not be fired.\n");
00098 return false;
00099 }
00100 }
00102 bool startStrobe(int flashOutputIndex) {
00103 if (PhidgetDevice::phidgetsAvailable) {
00104 CPhidgetInterfaceKit_setOutputState(PhidgetDevice::ifKit, flashOutputIndex, true);
00105 return true;
00106 } else {
00107 printf("Phidgets aren't available. The flash will not be fired.\n");
00108 return false;
00109 }
00110 }
00112 bool stopStrobe(int flashOutputIndex) {
00113 if (PhidgetDevice::phidgetsAvailable) {
00114 CPhidgetInterfaceKit_setOutputState(PhidgetDevice::ifKit, flashOutputIndex, false);
00115 return true;
00116 } else {
00117 printf("Phidgets aren't available. The flash will not be fired.\n");
00118 return false;
00119 }
00120 }
00121 };
00123 PhidgetFlash phidgetFlash;
00124 private:
00126 int phidgetIndex;
00127 private:
00128 void setDuration(int);
00129 void setBrightness(float);
00130
00131 struct FlashState {
00132 Time time;
00133 bool state;
00134 };
00135 };
00136 }
00137 }
00138
00139
00140 #endif