31 #ifndef IPHYSICALINTERFACE_H_ 32 #define IPHYSICALINTERFACE_H_ 34 #include "../IEvents.h" 36 #include "../Managers/FileDescriptorManager.h" 37 #include "../IQueue.h" 43 #include <condition_variable> 76 virtual bool onPacketReceived(std::string &senderID, std::shared_ptr<Packet> packet) = 0;
89 virtual void sendPacket(std::shared_ptr<Packet> packet) = 0;
95 virtual void setup(int32_t userID, int32_t groupID,
bool setPermissions) {}
110 QueueEntry(
const std::shared_ptr<Packet> &packet) { this->packet = packet; };
112 std::shared_ptr<Packet> packet;
137 std::function<void(int32_t familyId, const std::string &interfaceId, const BaseLib::PVariable &packet)>
_rawPacketEvent;
142 void processQueueEntry(int32_t index, std::shared_ptr<BaseLib::IQueueEntry> &entry)
override;
144 virtual void openGPIO(uint32_t index,
bool readOnly);
147 virtual bool getGPIO(uint32_t index);
149 virtual void setGPIOPermission(uint32_t index, int32_t userID, int32_t groupID,
bool readOnly);
virtual void setGPIOPermission(uint32_t index, int32_t userID, int32_t groupID, bool readOnly)
Definition: IPhysicalInterface.cpp:267
virtual bool setGPIOEdge(uint32_t index, GPIOEdge::Enum edge)
Definition: IPhysicalInterface.cpp:386
void setRawPacketEvent(std::function< void(int32_t familyId, const std::string &interfaceId, const BaseLib::PVariable &packet)> value)
Definition: IPhysicalInterface.h:106
Enum
Definition: IPhysicalInterface.h:66
virtual int64_t lastPacketSent()
Definition: IPhysicalInterface.h:93
std::shared_ptr< FileDescriptor > _fileDescriptor
Definition: IPhysicalInterface.h:124
std::shared_ptr< PhysicalInterfaceSettings > _settings
Definition: IPhysicalInterface.h:117
virtual int32_t getAddress()
Definition: IPhysicalInterface.h:102
virtual void getGPIOPath(uint32_t index)
Definition: IPhysicalInterface.cpp:177
This is the base library main class.
Definition: BaseLib.h:95
virtual bool isNetworkDevice()
Definition: IPhysicalInterface.h:101
QueueEntry(const std::shared_ptr< Packet > &packet)
Definition: IPhysicalInterface.h:110
virtual void exportGPIO(uint32_t index)
Definition: IPhysicalInterface.cpp:325
Definition: IPhysicalInterface.h:65
virtual void setup(int32_t userID, int32_t groupID, bool setPermissions)
Definition: IPhysicalInterface.h:95
virtual uint32_t responseDelay()
Definition: IPhysicalInterface.h:92
virtual bool setGPIODirection(uint32_t index, GPIODirection::Enum direction)
Definition: IPhysicalInterface.cpp:356
Definition: IPhysicalInterface.h:56
int32_t _familyId
Definition: IPhysicalInterface.h:116
virtual std::string getType()
Definition: IPhysicalInterface.h:96
Definition: BaseLib.cpp:34
virtual void setGPIO(uint32_t index, bool value)
Definition: IPhysicalInterface.cpp:250
virtual bool gpioDefined(uint32_t)
Definition: IPhysicalInterface.cpp:305
IPhysicalInterface(BaseLib::SharedObjects *baseLib, int32_t familyId)
Definition: IPhysicalInterface.cpp:40
virtual std::string getFirmwareVersion()
Definition: IPhysicalInterface.h:99
std::atomic_bool _updateMode
Definition: IPhysicalInterface.h:129
virtual ~IPhysicalInterface()
Definition: IPhysicalInterface.cpp:55
Definition: IPhysicalInterface.h:74
virtual void stopListening()
Definition: IPhysicalInterface.cpp:85
std::map< uint32_t, std::shared_ptr< FileDescriptor > > _gpioDescriptors
Definition: IPhysicalInterface.h:125
void processQueueEntry(int32_t index, std::shared_ptr< BaseLib::IQueueEntry > &entry) override
Definition: IPhysicalInterface.cpp:102
Definition: IPhysicalInterface.h:108
PVariable value
Definition: UiElements.h:217
virtual bool isDefault()
Definition: IPhysicalInterface.h:100
std::shared_ptr< Variable > PVariable
Definition: PhysicalInterfaceSettings.h:41
std::thread _listenThread
Definition: IPhysicalInterface.h:118
int64_t _maxPacketProcessingTime
Definition: IPhysicalInterface.h:128
virtual void startListening()
Definition: IPhysicalInterface.cpp:76
std::atomic< int64_t > _lastPacketSent
Definition: IPhysicalInterface.h:126
virtual std::string getSerialNumber()
Definition: IPhysicalInterface.h:98
std::atomic_bool _lifetickState
Definition: IPhysicalInterface.h:131
virtual void openGPIO(uint32_t index, bool readOnly)
Definition: IPhysicalInterface.cpp:166
virtual void closeGPIO(uint32_t index)
Definition: IPhysicalInterface.cpp:220
Definition: IPhysicalInterface.h:61
std::atomic< int64_t > _lifetickTime
Definition: IPhysicalInterface.h:130
This class implements a queue after the producer-consumer paradigm.
Definition: IQueue.h:52
std::string _lockfile
Definition: IPhysicalInterface.h:121
virtual int64_t lastPacketReceived()
Definition: IPhysicalInterface.h:94
virtual void sendPacket(std::shared_ptr< Packet > packet)=0
int32_t familyId
Definition: Licensing.h:380
std::atomic< int64_t > _lastPacketReceived
Definition: IPhysicalInterface.h:127
virtual void setDevicePermission(int32_t userID, int32_t groupID)
Definition: IPhysicalInterface.cpp:145
std::function< void(int32_t familyId, const std::string &interfaceId, const BaseLib::PVariable &packet)> _rawPacketEvent
Definition: IPhysicalInterface.h:137
virtual void enableUpdateMode()
Definition: IPhysicalInterface.cpp:94
virtual void saveSettingToDatabase(std::string setting, std::string &value)
Definition: IPhysicalInterface.cpp:416
virtual std::string getID()
Definition: IPhysicalInterface.h:97
std::thread _callbackThread
Definition: IPhysicalInterface.h:119
Enum
Definition: IPhysicalInterface.h:59
Definition: IPhysicalInterface.h:60
std::string _ipAddress
Definition: IPhysicalInterface.h:135
std::mutex _sendMutex
Definition: IPhysicalInterface.h:122
virtual bool lifetick()
Definition: IPhysicalInterface.cpp:62
virtual bool isOpen()
Definition: IPhysicalInterface.h:91
virtual bool getGPIO(uint32_t index)
Definition: IPhysicalInterface.cpp:231
std::string _hostname
Definition: IPhysicalInterface.h:134
int32_t _myAddress
Definition: IPhysicalInterface.h:133
BaseLib::SharedObjects * _bl
Definition: IPhysicalInterface.h:115
std::atomic_bool _stopped
Definition: IPhysicalInterface.h:123
std::atomic_bool _stopCallbackThread
Definition: IPhysicalInterface.h:120
virtual std::string getIpAddress()
Definition: IPhysicalInterface.h:103
Definition: IPhysicalInterface.h:67
virtual bool gpioOpen(uint32_t)
Definition: IPhysicalInterface.cpp:315
virtual std::string getHostname()
Definition: IPhysicalInterface.h:104
Definition: IPhysicalInterface.h:68
Definition: IPhysicalInterface.h:58
virtual void disableUpdateMode()
Definition: IPhysicalInterface.cpp:98
virtual void raisePacketReceived(std::shared_ptr< Packet > packet)
Definition: IPhysicalInterface.cpp:135