LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
readerunit.hpp
Go to the documentation of this file.
1
7#ifndef LOGICALACCESS_READERUNIT_HPP
8#define LOGICALACCESS_READERUNIT_HPP
9
10#include <stdint.h>
11#include <boost/property_tree/ptree_fwd.hpp>
12#include <memory>
13#include <string>
14#include <vector>
20#define PLUGINOBJECT_MAXLEN 64
21
22namespace logicalaccess
23{
24class Chip;
25class Profile;
26class ReaderCardAdapter;
27class DataTransport;
28class CardsFormatComposite;
29class ReaderFormatComposite;
30class ReaderProvider;
31
40class LLA_CORE_API ReaderUnit : public XmlSerializable,
41 public std::enable_shared_from_this<ReaderUnit>
42{
43 public:
44 using XmlSerializable::serialize;
45 using XmlSerializable::unSerialize;
46
50 explicit ReaderUnit(std::string rpt);
51
55 virtual ~ReaderUnit();
56
61 std::string getRPType() const;
62
67 virtual ByteVector getPingCommand() const;
68
78 virtual bool waitInsertion(unsigned int maxwait) = 0;
79
91 virtual bool waitInsertion(const ByteVector &identifier, unsigned int maxwait);
92
101 virtual bool waitRemoval(unsigned int maxwait) = 0;
102
107 virtual bool isConnected() = 0;
108
113 std::string getCardType() const
114 {
115 return d_card_type;
116 }
117
122 virtual void setCardType(std::string cardType) = 0;
123
129 virtual std::shared_ptr<Chip> createChip(std::string type);
130
137 virtual std::shared_ptr<Chip> createChip(std::string type,
138 const ByteVector &identifier);
139
145 virtual ByteVector getNumber(std::shared_ptr<Chip> chip);
146
151 virtual std::shared_ptr<Chip> getSingleChip() = 0;
152
157 virtual std::vector<std::shared_ptr<Chip>> getChipList() = 0;
158
165 virtual ByteVector getNumber(std::shared_ptr<Chip> chip,
166 std::shared_ptr<CardsFormatComposite> composite);
167
175 static uint64_t getFormatedNumber(const ByteVector &number, int padding);
176
182 static std::string getFormatedNumber(const ByteVector &number);
183
191 virtual bool connect() = 0;
192
198 virtual bool reconnect(int action = 0)
199 {
200 (void)action;
201 return true;
202 }
203
207 virtual void disconnect() = 0;
208
213 virtual bool connectToReader() = 0;
214
218 virtual void disconnectFromReader() = 0;
219
224 virtual std::string getName() const = 0;
225
230 virtual std::string getConnectedName()
231 {
232 return getName();
233 }
234
239 virtual std::shared_ptr<ReaderUnitConfiguration> getConfiguration();
240
245 virtual void setConfiguration(std::shared_ptr<ReaderUnitConfiguration> config);
246
251 virtual std::shared_ptr<ReaderCardAdapter> getDefaultReaderCardAdapter();
252
257 virtual void
258 setDefaultReaderCardAdapter(std::shared_ptr<ReaderCardAdapter> defaultRca);
259
264 virtual std::shared_ptr<DataTransport> getDataTransport() const;
265
270 virtual void setDataTransport(std::shared_ptr<DataTransport> dataTransport);
271
276 virtual std::string getReaderSerialNumber() = 0;
277
282 std::string getDefaultXmlNodeName() const override;
283
288 void serialize(boost::property_tree::ptree &node) override;
289
294 void unSerialize(boost::property_tree::ptree &node) override;
295
302 void unSerialize(boost::property_tree::ptree &node,
303 const std::string &rootNode) override;
304
309 std::shared_ptr<ReaderProvider> getReaderProvider() const
310 {
311 return d_readerProvider.lock();
312 }
313
318 void setReaderProvider(std::weak_ptr<ReaderProvider> provider)
319 {
320 d_readerProvider = provider;
321 }
322
327 virtual std::shared_ptr<LCDDisplay> getLCDDisplay();
328
333 virtual void setLCDDisplay(std::shared_ptr<LCDDisplay> d);
334
339 virtual std::shared_ptr<LEDBuzzerDisplay> getLEDBuzzerDisplay();
340
345 virtual void setLEDBuzzerDisplay(std::shared_ptr<LEDBuzzerDisplay> lbd);
346
352 virtual void setCardTechnologies(const TechnoBitset &bitset);
353
359 virtual TechnoBitset getCardTechnologies();
360
370 virtual TechnoBitset getPossibleCardTechnologies();
371
379 virtual ReaderServicePtr getService(const ReaderServiceType &type);
380
381 protected:
386
390 std::string d_card_type;
391
395 std::weak_ptr<ReaderProvider> d_readerProvider;
396
400 std::shared_ptr<ReaderUnitConfiguration> d_readerUnitConfig;
401
405 std::shared_ptr<Chip> d_insertedChip;
406
410 std::shared_ptr<LCDDisplay> d_lcdDisplay;
411
415 std::shared_ptr<LEDBuzzerDisplay> d_ledBuzzerDisplay;
416
425 virtual std::shared_ptr<ResultChecker> createDefaultResultChecker() const;
426
436 virtual std::shared_ptr<CardProbe> createCardProbe();
437
438 private:
442 std::shared_ptr<ReaderCardAdapter> d_defaultReaderCardAdapter;
443
447 std::shared_ptr<DataTransport> d_dataTransport;
448};
449}
450
451#endif
The card types.
Definition: readerunit.hpp:42
virtual void setCardType(std::string cardType)=0
Set the forced card type.
std::string d_readerProviderType
The associated reader provider type for the reader unit configuration.
Definition: readerunit.hpp:385
std::string getCardType() const
Get the forced card type.
Definition: readerunit.hpp:113
std::weak_ptr< ReaderProvider > d_readerProvider
The associated reader provider for the reader unit.
Definition: readerunit.hpp:395
std::shared_ptr< DataTransport > d_dataTransport
The data transport layer.
Definition: readerunit.hpp:447
virtual bool connectToReader()=0
Connect to the reader. Implicit connection on first command sent.
virtual std::string getName() const =0
Get the reader unit name.
virtual void disconnectFromReader()=0
Disconnect from reader.
virtual bool connect()=0
Connect to the card.
std::shared_ptr< ReaderUnitConfiguration > d_readerUnitConfig
The reader unit configuration.
Definition: readerunit.hpp:400
virtual bool reconnect(int action=0)
Reconnect to the card with the currently active share mode on the same reader.
Definition: readerunit.hpp:198
virtual std::string getReaderSerialNumber()=0
Get a string hexadecimal representation of the reader serial number.
virtual std::string getConnectedName()
Get the connected reader unit name.
Definition: readerunit.hpp:230
virtual bool waitInsertion(unsigned int maxwait)=0
Wait for a card insertion.
std::string d_card_type
The forced card type.
Definition: readerunit.hpp:390
std::shared_ptr< LCDDisplay > d_lcdDisplay
The inserted chip.
Definition: readerunit.hpp:410
virtual void disconnect()=0
Disconnect from the card.
std::shared_ptr< ReaderCardAdapter > d_defaultReaderCardAdapter
The default reader/card adapter.
Definition: readerunit.hpp:442
std::shared_ptr< LEDBuzzerDisplay > d_ledBuzzerDisplay
The inserted chip.
Definition: readerunit.hpp:415
std::shared_ptr< Chip > d_insertedChip
The inserted chip.
Definition: readerunit.hpp:405
virtual std::shared_ptr< Chip > getSingleChip()=0
Get the first and/or most accurate chip found.
virtual bool isConnected()=0
Check if the card is connected.
std::shared_ptr< ReaderProvider > getReaderProvider() const
Get the associated reader provider.
Definition: readerunit.hpp:309
void setReaderProvider(std::weak_ptr< ReaderProvider > provider)
Set the associated reader provider.
Definition: readerunit.hpp:318
virtual bool waitRemoval(unsigned int maxwait)=0
Wait for a card removal.
virtual std::vector< std::shared_ptr< Chip > > getChipList()=0
Get chip available in the RFID rang.
A Xml Serializable base class. Add Xml serialization to a class.
Definition: xmlserializable.hpp:54
std::vector< uint8_t > ByteVector
Definition: lla_fwd.hpp:80
Definition: asn1.hpp:9
ReaderServiceType
Definition: reader_service.hpp:10
uint32_t TechnoBitset
Definition: techno.hpp:25
std::shared_ptr< ReaderService > ReaderServicePtr
Definition: lla_fwd.hpp:67