1 /* 2 * brazildriver.h 3 * 4 * Public header file for the test driver. 5 */ 6 7 /* 8 * Copyright (C) 2015-20XX Wagner Popov 9 * 10 * This program is free software; you can redistribute it and/or 11 * modify it under the terms of version 2 of the GNU General 12 * Public License as published by the Free Software Foundation. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public 20 * License along with this program; if not, write to the Free 21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 22 * MA 02110-1335, USA. 23 */ 24 25 #ifndef _BRAZILDRIVER_H 26 #define _BRAZILDRIVER_H 27 28 #include "brazilmodel.h" 29 30 class BrazilUpsDriver: public UpsDriver 31 { 32 public: 33 BrazilUpsDriver(UPSINFO *ups); ~BrazilUpsDriver()34 virtual ~BrazilUpsDriver() {} 35 Factory(UPSINFO * ups)36 static UpsDriver *Factory(UPSINFO *ups) 37 { return new BrazilUpsDriver(ups); } 38 39 virtual bool get_capabilities(); 40 virtual bool read_volatile_data(); 41 virtual bool read_static_data(); 42 virtual bool check_state(); 43 virtual bool refresh(); 44 virtual bool Open(); 45 virtual bool Close(); 46 virtual bool setup(); 47 virtual bool shutdown(); 48 virtual bool kill_power(); 49 virtual int getEventsStr(char **events); 50 51 virtual bool programmation(bool turnoff, unsigned int turnoff_minutes, bool turnon, unsigned int turnon_minutes); 52 virtual bool turnLineOn(bool turnon); 53 virtual bool turnOutputOn(bool turnon); 54 virtual bool shutdownAuto(); 55 virtual bool turnContinueMode(); 56 57 BrazilModelAbstract *model; 58 59 protected: 60 61 void send(unsigned char *cmd, int size); 62 char *strBuffer(unsigned char* buffer, int len); 63 private: 64 65 int ReadData(bool getevents); 66 67 struct termios _oldtio; 68 struct termios _newtio; 69 70 time_t _received; 71 unsigned char _buffer[BrazilModelAbstract::BUFFERLEN]; // Buffer 72 unsigned int _bufnxt; // position off next char in buffer to be written 73 unsigned int _buffst; // position off first char in buffer 74 75 bool _autosetup; 76 77 void bufferAdd(unsigned char c); 78 void bufferDel(unsigned int len); 79 unsigned int bufferLen(); 80 unsigned char *bufferGet(); 81 82 void setIOCtlRecv(); 83 void setIOCtlSend(); 84 85 static const char *printBits(size_t const size, void const * const ptr); 86 }; 87 88 89 #endif /* _BRAZIL_DRIVER_H */ 90