initial
This commit is contained in:
56
gateway.h
Normal file
56
gateway.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* gateway.h
|
||||
*
|
||||
* Created on: 26.10.2014
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
#ifndef GATEWAY_H_
|
||||
#define GATEWAY_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "SimpleModbusMaster.h"
|
||||
#include "Mudbus.h"
|
||||
|
||||
|
||||
const uint8_t TOTAL_NO_OF_PACKETS = 8;
|
||||
|
||||
const uint32_t MODBUS_BAUD = 1200;
|
||||
const uint16_t MODBUS_TIMEOUT = 10000;
|
||||
const uint16_t MODBUS_SCANRATE = 1000;
|
||||
const uint8_t MODBUS_RETRY_COUNT = 25;
|
||||
const uint8_t MODBUS_TX_ENABLE_PIN = 2;
|
||||
|
||||
const uint16_t CONNECTION_STATUS_OFFSET = 0;
|
||||
const uint16_t VALUE_STATUS_OFFSET = 0x100;
|
||||
|
||||
struct GatewayAssignment {
|
||||
uint8_t id;
|
||||
uint8_t function;
|
||||
uint16_t address;
|
||||
uint16_t data;
|
||||
uint16_t mudbusIndex;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Gateway {
|
||||
public:
|
||||
Gateway(Mudbus *mudbus) : m_mudbus(mudbus) {};
|
||||
void prepareAssignments();
|
||||
void begin();
|
||||
void exec();
|
||||
void show();
|
||||
void assign(uint8_t id, uint8_t function, uint16_t address, uint16_t data);
|
||||
void reactivate();
|
||||
private:
|
||||
Mudbus *m_mudbus;
|
||||
Packet m_packets[TOTAL_NO_OF_PACKETS];
|
||||
GatewayAssignment m_gatewayAssignments[TOTAL_NO_OF_PACKETS];
|
||||
|
||||
void assignPacket(uint8_t packetIdx, uint8_t id, uint8_t function, uint16_t address, uint16_t data, uint16_t mudbusIdx);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* GATEWAY_H_ */
|
Reference in New Issue
Block a user