00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef BlinkingBackLED_h_DEFINED
00013 #define BlinkingBackLED_h_DEFINED
00014
00015 #include <OPENR/OObject.h>
00016 #include <OPENR/OSubject.h>
00017 #include <OPENR/OObserver.h>
00018 #include "def.h"
00019
00020 enum BlinkingBackLEDState {
00021 BBLS_IDLE,
00022 BBLS_START,
00023 BBLS_WHITE0to255_COLOR0,
00024 BBLS_WHITE255_COLOR0to255,
00025 BBLS_WHITE255to0_COLOR255,
00026 BBLS_WHITE0_COLOR255to0,
00027 BBLS_WHITE0_COLOR0
00028 };
00029
00030 enum LED3Result {
00031 LED3_CONT,
00032 LED3_FINISH
00033 };
00034
00035 static const char* const LED3_LOCATOR[] = {
00036 "PRM:/lu-LED3:lu",
00037 "PRM:/lv-LED3:lv",
00038 "PRM:/lw-LED3:lw",
00039 "PRM:/lx-LED3:lx",
00040 "PRM:/ly-LED3:ly",
00041 "PRM:/lz-LED3:lz"
00042 };
00043
00044 class BlinkingBackLED : public OObject {
00045 public:
00046 BlinkingBackLED();
00047 virtual ~BlinkingBackLED() {}
00048
00049 OSubject* subject[numOfSubject];
00050 OObserver* observer[numOfObserver];
00051
00052 virtual OStatus DoInit (const OSystemEvent& event);
00053 virtual OStatus DoStart (const OSystemEvent& event);
00054 virtual OStatus DoStop (const OSystemEvent& event);
00055 virtual OStatus DoDestroy(const OSystemEvent& event);
00056
00057 void Ready(const OReadyEvent& event);
00058
00059 private:
00060 void OpenPrimitives();
00061 void NewCommandVectorData();
00062
00063 LED3Result White0to255_Color0();
00064 LED3Result White255_Color0to255();
00065 LED3Result White255to0_Color255();
00066 LED3Result White0_Color255to0();
00067 LED3Result White0_Color0();
00068 void SetWhiteLED3Value(RCRegion* rgn, int level, int slope);
00069 void SetColorLED3Value(RCRegion* rgn, int level, int slope);
00070 void SetWhiteLED3Value(RCRegion* rgn, sword intensity);
00071 void SetColorLED3Value(RCRegion* rgn, sword intensity);
00072 RCRegion* FindFreeRegion();
00073
00074 static const size_t NUM_LEDS = 6;
00075 static const size_t NUM_COMMAND_VECTOR = 2;
00076 static const int MAX_LEVEL = 15;
00077 static const int POSITIVE_SLOPE = 1;
00078 static const int NEGATIVE_SLOPE = -1;
00079
00080 BlinkingBackLEDState blinkingLEDState;
00081 OPrimitiveID ledID[NUM_LEDS];
00082 RCRegion* region[NUM_COMMAND_VECTOR];
00083 };
00084
00085 #endif // BlinkingBackLED_h_DEFINED