PIR Library  2
 All Classes Files Functions Variables Typedefs Macros Pages
manager.h
1 /*
2 
3 PIR-1/PIR-4 Driver v2
4 
5 Copyright (c) 2014, Promixis, LLC
6 All rights reserved.
7 
8 Redistribution and use in source and binary forms, with or
9 without modification, are permitted provided that the
10 following conditions are met:
11 
12 1. Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the following
14 disclaimer.
15 
16 2. Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials
19 provided with the distribution.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
26 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35 
36 */
37 
38 #ifndef MANAGER_H
39 #define MANAGER_H
40 
41 #include <string>
42 #include <list>
43 
44 #include "pirlib2.h"
45 #include "pir.h"
46 #include "pt.h"
47 
48 
52 class Manager
53 {
54 
55 public:
56 
57  typedef std::list<PIRPtr> PIRList;
58 
60  Manager(PIR_Settings * settings);
62  ~Manager();
64  bool init();
65 
74  bool sendCCF( const std::string & serial, const std::string ccf, unsigned char bitmask, unsigned char repeats );
75 
77  IPIRPtr findPIR( const std::string & serial );
78 
80  void checkDevices();
81 
83  bool learn( const std::string & serial );
85  bool cancelLearn( const std::string & serial );
86 
88  std::string pirList( PIR::Type type );
89 
90 private:
91  PIR_Settings m_Settings;
92  PIRList m_PIRList;
93  pthread_mutex_t m_Mutex;
94 
95  void closedCallback(const std::string & serial );
96  void addPIR( PIRPtr p );
97  PIRPtr findPIRLocked( const std::string & serial );
98 };
99 
100 #endif // MANAGER_H
Contains the PIR-1/PIR-4 objects currently available on the system.
Definition: manager.h:52
bool init()
Initialization, checkDevices is permformed at this point.
Definition: manager.cpp:217
bool cancelLearn(const std::string &serial)
cancels learning on the specified PIR-1
Definition: manager.cpp:90
bool sendCCF(const std::string &serial, const std::string ccf, unsigned char bitmask, unsigned char repeats)
Sends a CCF code.
Definition: manager.cpp:223
bool learn(const std::string &serial)
start learning on the specified PIR-1
Definition: manager.cpp:79
the Settings structure.
Definition: pirlib2.h:334
void checkDevices()
runs the PIR-1 / PIR-4 device detection routine. New devices may appear at this point.
Definition: manager.cpp:6
~Manager()
Destructor.
Definition: manager.cpp:209
IPIRPtr findPIR(const std::string &serial)
returns the PIR object for specific serial
Definition: manager.cpp:154
Manager(PIR_Settings *settings)
Constructor.
Definition: manager.cpp:188
std::string pirList(PIR::Type type)
returns a comma separated list of serial numbers of available PIR's with requested type...
Definition: manager.cpp:101