line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Device::ProXR::RelayControl;
|
2
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
3
|
|
|
|
|
|
|
## :mode=perl:indentSize=2:tabSize=2:noTabs=true:
|
4
|
|
|
|
|
|
|
##****************************************************************************
|
5
|
|
|
|
|
|
|
##****************************************************************************
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Device::ProXR::RelayControl - A subclass of Device::ProXR object for relay
|
10
|
|
|
|
|
|
|
control.
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.04
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NOTES
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
* Before comitting this file to the repository, ensure Perl Critic can be
|
19
|
|
|
|
|
|
|
invoked at the HARSH [3] level with no errors
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Device::ProXR::RelayControl;
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $board = Device::ProXR::RelayControl->new(qq{COM2});
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$board->all_off;
|
28
|
|
|
|
|
|
|
$board->relay_on(1, 1);
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
##****************************************************************************
|
34
|
|
|
|
|
|
|
##****************************************************************************
|
35
|
1
|
|
|
1
|
|
421728
|
use Readonly;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
36
|
1
|
|
|
1
|
|
799
|
use Moo;
|
|
1
|
|
|
|
|
17361
|
|
|
1
|
|
|
|
|
9
|
|
37
|
|
|
|
|
|
|
## Moo enables strictures
|
38
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::RequireUseStrict)
|
39
|
|
|
|
|
|
|
## no critic (TestingAndDebugging::RequireUseWarnings)
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
extends 'Device::ProXR';
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
our $VERSION = "0.05";
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
##--------------------------------------------------------
|
46
|
|
|
|
|
|
|
## Symbolic constants
|
47
|
|
|
|
|
|
|
##--------------------------------------------------------
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
## Command to check 2-way communications
|
50
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_CMD_TEST_2WAY_COMMS => 0x21;
|
51
|
|
|
|
|
|
|
## Response to the check 2-way comms
|
52
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_MODE_RUN => 0x55;
|
53
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_MODE_CONFIG => 0x56;
|
54
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_MODE_LOCKDOWN => 0x57;
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
## The folowing commands are used for individual relays
|
57
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_CMD_BANK_DIRECTED_RELAY_OFF => 0x64;
|
58
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_CMD_BANK_DIRECTED_RELAY_ON => 0x6C;
|
59
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_CMD_BANK_DIRECTED_RELAY_STATUS => 0x74;
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
## The folowing commands are used for all relays in a specified bank
|
62
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_CMD_BANK_DIRECTED_STATUS => 0x7C;
|
63
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_CMD_BANK_DIRECTED_RELAY_ALL_OFF => 0x81;
|
64
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_CMD_BANK_DIRECTED_RELAY_ALL_ON => 0x82;
|
65
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_CMD_BANK_DIRECTED_RELAY_INVERT => 0x83;
|
66
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_CMD_BANK_DIRECTED_RELAY_MIRROR => 0x84;
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
## Response to ACKnowledge the command
|
69
|
|
|
|
|
|
|
Readonly::Scalar my $PROXR_RESP_ACK => 0x55;
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
##****************************************************************************
|
72
|
|
|
|
|
|
|
## Object Attributes
|
73
|
|
|
|
|
|
|
##****************************************************************************
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 ATTRIBUTES
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
##****************************************************************************
|
80
|
|
|
|
|
|
|
## Object Methods
|
81
|
|
|
|
|
|
|
##****************************************************************************
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 METHODS
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
##****************************************************************************
|
88
|
|
|
|
|
|
|
##****************************************************************************
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 get_mode()
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=over 2
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item B
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns the current mode of operation
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item B
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
NONE
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item B
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Value indicating run mode
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=back
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
111
|
|
|
|
|
|
|
sub get_mode
|
112
|
|
|
|
|
|
|
{
|
113
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
## Send the command
|
116
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_TEST_2WAY_COMMS);
|
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
return $self->get_response;
|
119
|
|
|
|
|
|
|
}
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
##****************************************************************************
|
122
|
|
|
|
|
|
|
##****************************************************************************
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 relay_on($relay)
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 relay_on($bank, $relay)
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over 2
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item B
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Turn on the relay
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item B
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
$bank - Bank number of the relay to control (1 based)
|
137
|
|
|
|
|
|
|
$relay - Relay number of the relay to control (0 based)
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item B
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
UNDEF on error (with last_error set)
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item B
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
If only one parameter is specified, it is treated as a 0 based relay number
|
146
|
|
|
|
|
|
|
and the bank is calculated as (relay / 8) + 1, and the relay within the bank
|
147
|
|
|
|
|
|
|
is caluclated as (relay % 8)
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=back
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
154
|
|
|
|
|
|
|
sub relay_on
|
155
|
|
|
|
|
|
|
{
|
156
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
157
|
0
|
|
|
|
|
|
my $bank = shift;
|
158
|
0
|
|
|
|
|
|
my $relay = shift;
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
## See if we just received 1 parameter
|
161
|
0
|
0
|
0
|
|
|
|
if (defined($bank) and (!defined($relay)))
|
162
|
|
|
|
|
|
|
{
|
163
|
|
|
|
|
|
|
## Convert this into bank and relay
|
164
|
0
|
|
|
|
|
|
$relay = $bank % 8;
|
165
|
0
|
|
|
|
|
|
$bank = int($bank / 8) + 1; ## Bank numbers are 1 based
|
166
|
|
|
|
|
|
|
}
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
## Validate parameters
|
169
|
0
|
0
|
|
|
|
|
return unless ($self->_valid_bank_and_relay($bank, $relay));
|
170
|
|
|
|
|
|
|
## Make sure bank != 0
|
171
|
0
|
0
|
|
|
|
|
unless ($bank)
|
172
|
|
|
|
|
|
|
{
|
173
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank parameter cannot be 0!});
|
174
|
0
|
|
|
|
|
|
return;
|
175
|
|
|
|
|
|
|
}
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
## Send the command
|
178
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_BANK_DIRECTED_RELAY_ON + $relay, $bank);
|
179
|
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
return $self->get_response;
|
181
|
|
|
|
|
|
|
}
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
##****************************************************************************
|
184
|
|
|
|
|
|
|
##****************************************************************************
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 relay_off($relay)
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 relay_off($bank, $relay)
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=over 2
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item B
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Turn off the relay of the specified bank
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=item B
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
$bank - Bank number of the relay to control (1 based)
|
199
|
|
|
|
|
|
|
$relay - Relay number of the relay to control (0 based)
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item B
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
UNDEF on error (with last_error set)
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item B
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
If only one parameter is specified, it is treated as a 0 based relay number
|
208
|
|
|
|
|
|
|
and the bank is calculated as (relay / 8) + 1, and the relay within the bank
|
209
|
|
|
|
|
|
|
is caluclated as (relay % 8)
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=back
|
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=cut
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
216
|
|
|
|
|
|
|
sub relay_off
|
217
|
|
|
|
|
|
|
{
|
218
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
219
|
0
|
|
|
|
|
|
my $bank = shift;
|
220
|
0
|
|
|
|
|
|
my $relay = shift;
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
## See if we just received 1 parameter
|
223
|
0
|
0
|
0
|
|
|
|
if (defined($bank) and (!defined($relay)))
|
224
|
|
|
|
|
|
|
{
|
225
|
|
|
|
|
|
|
## Convert this into bank and relay
|
226
|
0
|
|
|
|
|
|
$relay = $bank % 8;
|
227
|
0
|
|
|
|
|
|
$bank = int($bank/8);
|
228
|
|
|
|
|
|
|
}
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
## Validate parameters
|
231
|
0
|
0
|
|
|
|
|
return unless ($self->_valid_bank_and_relay($bank, $relay));
|
232
|
|
|
|
|
|
|
## Make sure bank != 0
|
233
|
0
|
0
|
|
|
|
|
unless ($bank)
|
234
|
|
|
|
|
|
|
{
|
235
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank parameter cannot be 0!});
|
236
|
0
|
|
|
|
|
|
return;
|
237
|
|
|
|
|
|
|
}
|
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
## Send the command
|
240
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_BANK_DIRECTED_RELAY_OFF + $relay, $bank);
|
241
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
return $self->get_response;
|
243
|
|
|
|
|
|
|
}
|
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
##****************************************************************************
|
246
|
|
|
|
|
|
|
##****************************************************************************
|
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head2 relay_status($bank, $relay)
|
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=over 2
|
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=item B
|
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Get the status of the relay of the specified bank
|
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=item B
|
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
$bank - Bank number of the relay to control
|
259
|
|
|
|
|
|
|
$relay - Relay number of the relay to control
|
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=item B
|
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
UNDEF on error (with last_error set)
|
264
|
|
|
|
|
|
|
0 == Relay is OFF
|
265
|
|
|
|
|
|
|
1 == Relay is ON
|
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=back
|
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=cut
|
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
272
|
|
|
|
|
|
|
sub relay_status
|
273
|
|
|
|
|
|
|
{
|
274
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
275
|
0
|
|
|
|
|
|
my $bank = shift;
|
276
|
0
|
|
|
|
|
|
my $relay = shift;
|
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
## Validate parameters
|
279
|
0
|
0
|
|
|
|
|
return unless ($self->_valid_bank_and_relay($bank, $relay));
|
280
|
|
|
|
|
|
|
## Make sure bank != 0
|
281
|
0
|
0
|
|
|
|
|
unless ($bank)
|
282
|
|
|
|
|
|
|
{
|
283
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank parameter cannot be 0!});
|
284
|
0
|
|
|
|
|
|
return;
|
285
|
|
|
|
|
|
|
}
|
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
## Send the command
|
288
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_BANK_DIRECTED_RELAY_STATUS + $relay, $bank);
|
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
## Get the response
|
291
|
0
|
|
|
|
|
|
my $resp = $self->get_response;
|
292
|
0
|
0
|
0
|
|
|
|
if (defined($resp) && length($resp))
|
293
|
|
|
|
|
|
|
{
|
294
|
0
|
|
|
|
|
|
return(ord(substr($resp, 0, 1)));
|
295
|
|
|
|
|
|
|
}
|
296
|
0
|
|
|
|
|
|
return;
|
297
|
|
|
|
|
|
|
}
|
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
##****************************************************************************
|
300
|
|
|
|
|
|
|
##****************************************************************************
|
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=head2 all_on()
|
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=over 2
|
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=item B
|
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
Turn on all relays on all banks
|
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=item B
|
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
NONE
|
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=item B
|
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
NONE
|
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=back
|
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
=cut
|
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
323
|
|
|
|
|
|
|
sub all_on
|
324
|
|
|
|
|
|
|
{
|
325
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
## Send the command
|
328
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_BANK_DIRECTED_RELAY_ALL_ON, 0);
|
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
## Return the response
|
331
|
0
|
|
|
|
|
|
return $self->get_response;
|
332
|
|
|
|
|
|
|
}
|
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
##****************************************************************************
|
336
|
|
|
|
|
|
|
##****************************************************************************
|
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=head2 all_off()
|
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
=over 2
|
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
=item B
|
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
Turn off all relays on all banks
|
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
=item B
|
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
NONE
|
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
=item B
|
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
NONE
|
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
=back
|
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
=cut
|
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
359
|
|
|
|
|
|
|
sub all_off
|
360
|
|
|
|
|
|
|
{
|
361
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
## Send the command
|
364
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_BANK_DIRECTED_RELAY_ALL_OFF, 0);
|
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
## Return the response
|
367
|
0
|
|
|
|
|
|
return $self->get_response;
|
368
|
|
|
|
|
|
|
}
|
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
##****************************************************************************
|
371
|
|
|
|
|
|
|
##****************************************************************************
|
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
=head2 bank_on($bank)
|
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=over 2
|
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
=item B
|
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
Turn on all relays on the specified bank
|
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=item B
|
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
$bank - Bank number of bank to control
|
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
=item B
|
386
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
NONE
|
388
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
=back
|
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
=cut
|
392
|
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
394
|
|
|
|
|
|
|
sub bank_on
|
395
|
|
|
|
|
|
|
{
|
396
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
397
|
0
|
|
|
|
|
|
my $bank = shift;
|
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
## Validate parameters
|
400
|
0
|
0
|
|
|
|
|
return unless ($self->_valid_bank($bank));
|
401
|
|
|
|
|
|
|
## Make sure bank != 0
|
402
|
0
|
0
|
|
|
|
|
unless ($bank)
|
403
|
|
|
|
|
|
|
{
|
404
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank parameter cannot be 0!});
|
405
|
0
|
|
|
|
|
|
return;
|
406
|
|
|
|
|
|
|
}
|
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
## Send the command
|
409
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_BANK_DIRECTED_RELAY_ALL_ON, $bank);
|
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
## Return the response
|
412
|
0
|
|
|
|
|
|
return $self->get_response;
|
413
|
|
|
|
|
|
|
}
|
414
|
|
|
|
|
|
|
|
415
|
|
|
|
|
|
|
##****************************************************************************
|
416
|
|
|
|
|
|
|
##****************************************************************************
|
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
=head2 bank_off($bank)
|
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=over 2
|
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
=item B
|
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
Turn off all relays on the specified bank
|
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=item B
|
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
$bank - Bank number of bank to control
|
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
=item B
|
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
NONE
|
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
=back
|
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
=cut
|
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
439
|
|
|
|
|
|
|
sub bank_off
|
440
|
|
|
|
|
|
|
{
|
441
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
442
|
0
|
|
|
|
|
|
my $bank = shift;
|
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
## Validate parameters
|
445
|
0
|
0
|
|
|
|
|
return unless ($self->_valid_bank($bank));
|
446
|
|
|
|
|
|
|
## Make sure bank != 0
|
447
|
0
|
0
|
|
|
|
|
unless ($bank)
|
448
|
|
|
|
|
|
|
{
|
449
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank parameter cannot be 0!});
|
450
|
0
|
|
|
|
|
|
return;
|
451
|
|
|
|
|
|
|
}
|
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
## Send the command
|
454
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_BANK_DIRECTED_RELAY_ALL_OFF, $bank);
|
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
## Return the response
|
457
|
0
|
|
|
|
|
|
return $self->get_response;
|
458
|
|
|
|
|
|
|
}
|
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
##****************************************************************************
|
461
|
|
|
|
|
|
|
##****************************************************************************
|
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
=head2 bank_invert($bank)
|
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=over 2
|
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
=item B
|
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
Invert the status of all relays on the specified bank
|
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
=item B
|
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
$bank - Bank number of bank to control
|
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
=item B
|
476
|
|
|
|
|
|
|
|
477
|
|
|
|
|
|
|
NONE
|
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
=back
|
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=cut
|
482
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
484
|
|
|
|
|
|
|
sub bank_invert
|
485
|
|
|
|
|
|
|
{
|
486
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
487
|
0
|
|
|
|
|
|
my $bank = shift;
|
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
## Validate parameters
|
490
|
0
|
0
|
|
|
|
|
return unless ($self->_valid_bank($bank));
|
491
|
|
|
|
|
|
|
## Make sure bank != 0
|
492
|
0
|
0
|
|
|
|
|
unless ($bank)
|
493
|
|
|
|
|
|
|
{
|
494
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank parameter cannot be 0!});
|
495
|
0
|
|
|
|
|
|
return;
|
496
|
|
|
|
|
|
|
}
|
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
## Send the command
|
499
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_BANK_DIRECTED_RELAY_INVERT, $bank);
|
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
## Return the response
|
502
|
0
|
|
|
|
|
|
return $self->get_response;
|
503
|
|
|
|
|
|
|
}
|
504
|
|
|
|
|
|
|
|
505
|
|
|
|
|
|
|
##****************************************************************************
|
506
|
|
|
|
|
|
|
##****************************************************************************
|
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
=head2 bank_reverse($bank)
|
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=over 2
|
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=item B
|
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
Reverse / mirror the status of all relays on the specified bank
|
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
=item B
|
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
$bank - Bank number of bank to control
|
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
=item B
|
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
NONE
|
523
|
|
|
|
|
|
|
|
524
|
|
|
|
|
|
|
=back
|
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
=cut
|
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
529
|
|
|
|
|
|
|
sub bank_reverse
|
530
|
|
|
|
|
|
|
{
|
531
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
532
|
0
|
|
|
|
|
|
my $bank = shift;
|
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
## Validate parameters
|
535
|
0
|
0
|
|
|
|
|
return unless ($self->_valid_bank($bank));
|
536
|
|
|
|
|
|
|
## Make sure bank != 0
|
537
|
0
|
0
|
|
|
|
|
unless ($bank)
|
538
|
|
|
|
|
|
|
{
|
539
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank parameter cannot be 0!});
|
540
|
0
|
|
|
|
|
|
return;
|
541
|
|
|
|
|
|
|
}
|
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
## Send the command
|
544
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_BANK_DIRECTED_RELAY_MIRROR, $bank);
|
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
## Return the response
|
547
|
0
|
|
|
|
|
|
return $self->get_response;
|
548
|
|
|
|
|
|
|
}
|
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
##****************************************************************************
|
551
|
|
|
|
|
|
|
##****************************************************************************
|
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
=head2 bank_status($bank)
|
554
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
=over 2
|
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
=item B
|
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
Return a byte with the statTurn on all relays on the specified bank
|
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
=item B
|
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
$bank - Bank number of bank to control
|
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=item B
|
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
SCALAR - Each bit represents relay 0-7 status
|
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
=back
|
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
=cut
|
572
|
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
574
|
|
|
|
|
|
|
sub bank_status
|
575
|
|
|
|
|
|
|
{
|
576
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
577
|
0
|
|
|
|
|
|
my $bank = shift;
|
578
|
|
|
|
|
|
|
|
579
|
|
|
|
|
|
|
## Validate parameters
|
580
|
0
|
0
|
|
|
|
|
return unless ($self->_valid_bank($bank));
|
581
|
|
|
|
|
|
|
## Make sure bank != 0
|
582
|
0
|
0
|
|
|
|
|
unless ($bank)
|
583
|
|
|
|
|
|
|
{
|
584
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank parameter cannot be 0!});
|
585
|
0
|
|
|
|
|
|
return;
|
586
|
|
|
|
|
|
|
}
|
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
## Send the command
|
589
|
0
|
|
|
|
|
|
$self->send_command($PROXR_CMD_BANK_DIRECTED_STATUS, $bank);
|
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
## Get the response
|
592
|
0
|
|
|
|
|
|
my $resp = $self->get_response;
|
593
|
0
|
0
|
0
|
|
|
|
if (defined($resp) && length($resp))
|
594
|
|
|
|
|
|
|
{
|
595
|
0
|
|
|
|
|
|
return(ord(substr($resp, 0, 1)));
|
596
|
|
|
|
|
|
|
}
|
597
|
0
|
|
|
|
|
|
return;
|
598
|
|
|
|
|
|
|
}
|
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
601
|
|
|
|
|
|
|
## @fn _valid_bank_and_relay($bank, $relay)
|
602
|
|
|
|
|
|
|
## @brief Returns TRUE value if bank AND relay are valid, or UNDEF if
|
603
|
|
|
|
|
|
|
## either bank OR relay is invalid
|
604
|
|
|
|
|
|
|
## @param $bank - Bank number
|
605
|
|
|
|
|
|
|
## @param $relay - Relay number
|
606
|
|
|
|
|
|
|
## @return UNDEF with error_message set if bank OR relay is invalid
|
607
|
|
|
|
|
|
|
## 1 if bank AND relay are valid
|
608
|
|
|
|
|
|
|
## @note
|
609
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
610
|
|
|
|
|
|
|
sub _valid_bank_and_relay
|
611
|
|
|
|
|
|
|
{
|
612
|
0
|
|
|
0
|
|
|
my $self = shift;
|
613
|
0
|
|
|
|
|
|
my $bank = shift;
|
614
|
0
|
|
|
|
|
|
my $relay = shift;
|
615
|
|
|
|
|
|
|
|
616
|
0
|
|
0
|
|
|
|
return ($self->_valid_bank($bank) && $self->_valid_relay($relay));
|
617
|
|
|
|
|
|
|
}
|
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
620
|
|
|
|
|
|
|
## @fn _valid_bank($bank)
|
621
|
|
|
|
|
|
|
## @brief Returns TRUE value if bank is valid, or UNDEF if bank is invalid
|
622
|
|
|
|
|
|
|
## @param $bank - Bank number
|
623
|
|
|
|
|
|
|
## @return UNDEF with error_message set if bank is invalid
|
624
|
|
|
|
|
|
|
## 1 if bank is valid
|
625
|
|
|
|
|
|
|
## @note
|
626
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
627
|
|
|
|
|
|
|
sub _valid_bank
|
628
|
|
|
|
|
|
|
{
|
629
|
0
|
|
|
0
|
|
|
my $self = shift;
|
630
|
0
|
|
|
|
|
|
my $bank = shift;
|
631
|
|
|
|
|
|
|
|
632
|
0
|
0
|
|
|
|
|
unless (defined($bank))
|
633
|
|
|
|
|
|
|
{
|
634
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank parameter missing!});
|
635
|
0
|
|
|
|
|
|
return;
|
636
|
|
|
|
|
|
|
}
|
637
|
0
|
0
|
|
|
|
|
unless ($bank =~ /\A\d+\Z/x)
|
638
|
|
|
|
|
|
|
{
|
639
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank must be a number!});
|
640
|
0
|
|
|
|
|
|
return;
|
641
|
|
|
|
|
|
|
}
|
642
|
0
|
0
|
0
|
|
|
|
if (($bank < 0) || ($bank > 255))
|
643
|
|
|
|
|
|
|
{
|
644
|
0
|
|
|
|
|
|
$self->_error_message(qq{Bank must be a number between 0 and 255!});
|
645
|
0
|
|
|
|
|
|
return;
|
646
|
|
|
|
|
|
|
}
|
647
|
|
|
|
|
|
|
|
648
|
0
|
|
|
|
|
|
return 1;
|
649
|
|
|
|
|
|
|
}
|
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
652
|
|
|
|
|
|
|
## @fn _valid_relay($relay)
|
653
|
|
|
|
|
|
|
## @brief Returns TRUE value if relay is valid, or UNDEF if relay is invalid
|
654
|
|
|
|
|
|
|
## @param $relay - Relay number
|
655
|
|
|
|
|
|
|
## @return UNDEF with error_message set if relay is invalid
|
656
|
|
|
|
|
|
|
## 1 if relay is valid
|
657
|
|
|
|
|
|
|
## @note
|
658
|
|
|
|
|
|
|
##----------------------------------------------------------------------------
|
659
|
|
|
|
|
|
|
sub _valid_relay
|
660
|
|
|
|
|
|
|
{
|
661
|
0
|
|
|
0
|
|
|
my $self = shift;
|
662
|
0
|
|
|
|
|
|
my $relay = shift;
|
663
|
|
|
|
|
|
|
|
664
|
0
|
0
|
|
|
|
|
unless (defined($relay))
|
665
|
|
|
|
|
|
|
{
|
666
|
0
|
|
|
|
|
|
$self->_error_message(qq{Relay parameter missing!});
|
667
|
0
|
|
|
|
|
|
return;
|
668
|
|
|
|
|
|
|
}
|
669
|
0
|
0
|
|
|
|
|
unless ($relay =~ /\A\d+\Z/x)
|
670
|
|
|
|
|
|
|
{
|
671
|
0
|
|
|
|
|
|
$self->_error_message(qq{Relay must be a number!});
|
672
|
0
|
|
|
|
|
|
return;
|
673
|
|
|
|
|
|
|
}
|
674
|
0
|
0
|
0
|
|
|
|
if (($relay < 0) || ($relay > 7))
|
675
|
|
|
|
|
|
|
{
|
676
|
0
|
|
|
|
|
|
$self->_error_message(qq{Relay must be a number between 0 and 7!});
|
677
|
0
|
|
|
|
|
|
return;
|
678
|
|
|
|
|
|
|
}
|
679
|
|
|
|
|
|
|
|
680
|
0
|
|
|
|
|
|
return 1;
|
681
|
|
|
|
|
|
|
}
|
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
##****************************************************************************
|
686
|
|
|
|
|
|
|
## Additional POD documentation
|
687
|
|
|
|
|
|
|
##****************************************************************************
|
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
=head1 AUTHOR
|
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
Paul Durden Ealabamapaul AT gmail.comE
|
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE
|
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
Copyright (C) 2015 by Paul Durden.
|
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
698
|
|
|
|
|
|
|
under the same terms as Perl itself.
|
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
=cut
|
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
1; ## End of module
|
703
|
|
|
|
|
|
|
__END__
|