00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef LOW_COMPJALOUSIECONTROLLER_H
00019 #define LOW_COMPJALOUSIECONTROLLER_H
00020
00021
00022 #include "LOW_component.h"
00023 #include "LOW_devDS2405.h"
00024 #include "LOW_thread_mutex.h"
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class LOW_compJalousieController : public LOW_component {
00037
00038
00039 public:
00040
00041
00042
00043
00044
00045
00046 class_DERIVE_FROM_EXCEPTION( compJalousieController_error, component_error);
00047
00048
00049
00050
00051
00052
00053
00054
00055 LOW_compJalousieController( const LOW_devDS2405 &inPowerControl, const LOW_devDS2405 &inDirectionControl,
00056 const float inClosingTime, const float inOpeningTime,
00057 const float inAngleClosingTime, const float inAngleOpeningTime);
00058
00059 ~LOW_compJalousieController();
00060
00061
00062
00063
00064 protected:
00065
00066
00067
00068
00069
00070
00071 class jcLock {
00072 public:
00073 inline jcLock( LOW_compJalousieController &inJCComp) : jcComp(inJCComp)
00074 {
00075 jcComp.__linkRecMutex->lock();
00076 };
00077 inline ~jcLock()
00078 {
00079 jcComp.__linkRecMutex->unlock();
00080 };
00081 protected:
00082 const LOW_compJalousieController &jcComp;
00083 };
00084
00085
00086
00087
00088 public:
00089
00090
00091
00092
00093
00094
00095 class manualMove : public jcLock {
00096
00097 public:
00098
00099
00100 manualMove( LOW_compJalousieController &inJCComp);
00101 ~manualMove();
00102
00103
00104
00105 void moveUp();
00106 void moveDown();
00107 void stopMove();
00108
00109
00110 protected:
00111 LOW_compJalousieController &jcComp;
00112 };
00113
00114
00115
00116
00117
00118
00119
00120
00121 void setPosition( float inPos, float inAngle);
00122
00123 float getClosingTime() const;
00124
00125 void setClosingTime( const float inClosingTime);
00126
00127 float getOpeningTime() const;
00128
00129 void setOpeningTime( const float inOpeningTime);
00130
00131 float getAngleClosingTime() const;
00132
00133 void setAngleClosingTime( const float inAngleClosingTime);
00134
00135 float getAngleOpeningTime() const;
00136
00137 void setAngleOpeningTime( const float inAngleOpeningTime);
00138
00139
00140
00141
00142
00143 void measureTransitionDelays();
00144
00145 void getTransitionDelays( unsigned int &outStop2upDelay, unsigned int &outUp2stopDelay,
00146 unsigned int &outStop2downDelay, unsigned int &outDown2stopDelay,
00147 unsigned int &outUp2downDelay, unsigned int &outDown2upDelay);
00148
00149 void setTransitionDelays( const unsigned int inStop2upDelay, const unsigned int inUp2stopDelay,
00150 const unsigned int inStop2downDelay, const unsigned int inDown2stopDelay,
00151 const unsigned int inUp2downDelay, const unsigned int inDown2upDelay);
00152
00153
00154
00155 protected:
00156
00157
00158
00159
00160
00161
00162 friend class manualMove;
00163 friend class jcLock;
00164
00165
00166
00167
00168
00169
00170
00171
00172 static const int fullMovementAdditionMillis = 500;
00173
00174
00175
00176
00177
00178
00179
00180
00181 const int jcSerialNum;
00182 const LOW_devDS2405 &powerControl;
00183 const LOW_devDS2405 &directionControl;
00184 float closingTime;
00185 float openingTime;
00186 float angleClosingTime;
00187 float angleOpeningTime;
00188 unsigned int stop2upDelay;
00189 unsigned int up2stopDelay;
00190 unsigned int stop2downDelay;
00191 unsigned int down2stopDelay;
00192 unsigned int up2downDelay;
00193 unsigned int down2upDelay;
00194 LOW_thread_mutex *__linkRecMutex;
00195
00196
00197
00198
00199
00200
00201
00202
00203 void moveUp();
00204
00205 void moveDown();
00206
00207 void stopMove();
00208
00209 void moveUpStop( const unsigned long inMillis);
00210
00211 void moveDownStop( const unsigned long inMillis);
00212
00213
00214
00215
00216 private:
00217
00218
00219
00220
00221
00222
00223 static int jcCounter;
00224
00225
00226
00227
00228
00229
00230
00231
00232 bool powerIsOn;
00233 bool directionIsDown;
00234
00235
00236
00237
00238
00239
00240
00241
00242 void setPowerOn();
00243
00244 void setPowerOff();
00245
00246 void setDirectionDown();
00247
00248 void setDirectionUp();
00249
00250 unsigned int averageMillis( const std::vector<unsigned int> &inVals);
00251 };
00252
00253 #endif