1234567891011121314151617181920212223242526272829303132 |
- #ifndef S7__PLC__H
- #define S7__PLC__H
- #include <s7_client.h>
- #include <mutex>
- #include <iostream>
- class S7PLC
- {
- public:
- #define HTON(T) ((T) << 8) | ((T) >> 8)
- protected:
- bool bConnected_;
- std::mutex mutex_;
- TSnap7Client client_;
- public:
- S7PLC();
- ~S7PLC();
- bool connect(std::string ip);
- bool getConnection();
- bool ReadShorts(int DBNumber,int start,int size,short* pdata);
- bool WriteShorts(int DBNumber,int start,int size,short* pdata);
- void disconnect();
- private:
- bool read_dbs(int DBNumber,int start,int size,void* pdata);
- bool write_dbs(int DBNumber,int start,int size,void* pdata);
- void reverse_byte(void* pdata,int num_byte,void* out);
- };
- #endif // !S7__PLC__H
|