Missed one file
[pierogi] / protocols / spaceprotocol.cpp
1 #include "spaceprotocol.h"
2
3 #include "pirrx51hardware.h"
4
5 SpaceProtocol::SpaceProtocol(
6   QObject *guiObject,
7   unsigned int index,
8   unsigned int zerop,
9   unsigned int zeros,
10   unsigned int onep,
11   unsigned int ones,
12   unsigned int headerp,
13   unsigned int headers,
14   unsigned int trailerp,
15   unsigned int gaps,
16   bool iclflag)
17   : PIRProtocol(guiObject, index, gaps, iclflag),
18     zeroPulse(zerop),
19     zeroSpace(zeros),
20     onePulse(onep),
21     oneSpace(ones),
22     headerPulse(headerp),
23     headerSpace(headers),
24     trailerPulse(trailerp)
25 {
26 }
27
28
29 int SpaceProtocol::pushBits(
30   const CommandSequence &bits,
31   PIRRX51Hardware &rx51device)
32 {
33   int duration = 0;
34   CommandSequence::const_iterator i = bits.begin();
35   while (i != bits.end())
36   {
37     if (*i)
38     {
39       // Send the pulse for "One":
40       rx51device.addPair(onePulse, oneSpace);
41       duration += (onePulse + oneSpace);
42     }
43     else
44     {
45       // Send the pulse for "Zero":
46       rx51device.addPair(zeroPulse, zeroSpace);
47       duration += (zeroPulse + zeroSpace);
48     }
49     ++i;
50   }
51
52   return duration;
53 }
54
55
56 int SpaceProtocol::pushReverseBits(
57   const CommandSequence &bits,
58   PIRRX51Hardware &rx51device)
59 {
60   int duration = 0;
61   CommandSequence::const_reverse_iterator i = bits.rbegin();
62   while (i != bits.rend())
63   {
64     if (*i)
65     {
66       // Send the pulse for "One":
67       rx51device.addPair(onePulse, oneSpace);
68       duration += (onePulse + oneSpace);
69     }
70     else
71     {
72       // Send the pulse for "Zero":
73       rx51device.addPair(zeroPulse, zeroSpace);
74       duration += (zeroPulse + zeroSpace);
75     }
76     ++i;
77   }
78
79   return duration;
80 }
81
82
83 int SpaceProtocol::pushInvertedBits(
84   const CommandSequence &bits,
85   PIRRX51Hardware &rx51device)
86 {
87   int duration = 0;
88   CommandSequence::const_iterator i = bits.begin();
89   while (i != bits.end())
90   {
91     if (*i)
92     {
93       // Send the pulse for "Zero":
94       rx51device.addPair(zeroPulse, zeroSpace);
95       duration += (zeroPulse + zeroSpace);
96     }
97     else
98     {
99       // Send the pulse for "One":
100       rx51device.addPair(onePulse, oneSpace);
101       duration += (onePulse + oneSpace);
102     }
103     ++i;
104   }
105
106   return duration;
107 }
108
109
110 int SpaceProtocol::pushInvertedReverseBits(
111   const CommandSequence &bits,
112   PIRRX51Hardware &rx51device)
113 {
114   int duration = 0;
115   CommandSequence::const_reverse_iterator i = bits.rbegin();
116   while (i != bits.rend())
117   {
118     if (*i)
119     {
120       // Send the pulse for "Zero":
121       rx51device.addPair(zeroPulse, zeroSpace);
122       duration += (zeroPulse + zeroSpace);
123     }
124     else
125     {
126       // Send the pulse for "One":
127       rx51device.addPair(onePulse, oneSpace);
128       duration += (onePulse + oneSpace);
129     }
130     ++i;
131   }
132
133   return duration;
134 }