1 /* Copyright (C) 2012 Eduard Timotei Budulea 2 Copyright (C) 2013 Roy R. Rankin 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 #ifndef ROM1W_H 18 #define ROM1W_H 19 #ifndef IN_MODULE 20 #define IN_MODULE 21 #endif 22 23 #include "bit1w.h" 24 #include "src/value.h" 25 26 class ROMCodeAttribute; 27 28 class Rom1W : public LowLevel1W { 29 private: 30 virtual void gotReset(); 31 virtual NextAction gotBitStart(); 32 virtual void readBit(bool value); bit_remaining()33 virtual int bit_remaining() { return bitRemaining;} is_reading()34 virtual bool is_reading() { return isReading;} 35 36 bool isSelected; 37 bool isReady; 38 ROMCodeAttribute *attr_ROMCode; 39 40 virtual void doneBits() = 0; 41 virtual void resetEngine() = 0; isAlarm()42 virtual bool isAlarm() { return false;} 43 44 protected: 45 int bitRemaining; 46 bool isReading; 47 guint64 poll_break; 48 unsigned char octetBuffer[64]; 49 50 private: 51 52 NextAction (Rom1W::*romState)(); 53 54 NextAction readRomCommand(); 55 NextAction readRom(); 56 NextAction matchRom(); 57 NextAction searchRom(); 58 NextAction deviceData(); 59 NextAction ignoreData(); 60 NextAction statusPoll(); 61 62 virtual void callback(); 63 64 public: 65 Rom1W(const char *name, const char *desc); 66 ~Rom1W(); 67 static unsigned char calculateCRC8(const unsigned char *buffer, int bufferLen); 68 void set_status_poll(guint64 delay); 69 }; 70 71 #endif 72