1 | //
|
---|
2 | // Program for testing bias cabling
|
---|
3 | //
|
---|
4 | //
|
---|
5 |
|
---|
6 | #include <stdio.h>
|
---|
7 | #include <ctype.h>
|
---|
8 | #include <sys/time.h>
|
---|
9 |
|
---|
10 | #include "dic.hxx"
|
---|
11 |
|
---|
12 | // Get configuration data
|
---|
13 | int main(int argc, const char* argv[]) {
|
---|
14 |
|
---|
15 | int Quadrant, Cable, Connector, Channel;
|
---|
16 | char Command[100];
|
---|
17 |
|
---|
18 | if (argc != 4) {
|
---|
19 | printf("Usage: %s <quadrant> <cable> <connector>\n", argv[0]);
|
---|
20 | exit(EXIT_FAILURE);
|
---|
21 | }
|
---|
22 |
|
---|
23 | Quadrant = atoi(argv[1]);
|
---|
24 | Cable = atoi(argv[2]);
|
---|
25 | Connector = atoi(argv[3]);
|
---|
26 |
|
---|
27 | if (Quadrant<0 || Quadrant>3 || Cable<0 || Cable>9 || Connector<0 || Connector>3) {
|
---|
28 | printf("Quadrant, cable or connector number out of range\n");
|
---|
29 | exit(EXIT_FAILURE);
|
---|
30 | }
|
---|
31 |
|
---|
32 | if (Quadrant==0 || Quadrant==2) Channel = Quadrant*80+Cable*8+Connector*2;
|
---|
33 | else {
|
---|
34 | if (Cable==8 || Cable==9) Channel = Quadrant*80+(Cable-8)*8+Connector*2;
|
---|
35 | if (Cable>=4 && Cable<=7) Channel = Quadrant*80+(Cable-2)*8+Connector*2;
|
---|
36 | if (Cable>=0 && Cable<=3) Channel = Quadrant*80+(Cable+6)*8+Connector*2;
|
---|
37 | }
|
---|
38 |
|
---|
39 | // Switch off all channel
|
---|
40 | DimClient::sendCommand("Bias/Command", "gs 0");
|
---|
41 |
|
---|
42 | // Switch on 4-fold patch
|
---|
43 | snprintf(Command, sizeof(Command), "channel %d 70", Channel);
|
---|
44 | DimClient::sendCommand("Bias/Command", Command);
|
---|
45 | printf("Switched on channel %d\n", Channel);
|
---|
46 | sleep(2);
|
---|
47 |
|
---|
48 | // Switch on 5-fold patch
|
---|
49 | Channel++;
|
---|
50 | snprintf(Command, sizeof(Command), "channel %d 70", Channel);
|
---|
51 | DimClient::sendCommand("Bias/Command", Command);
|
---|
52 | printf("Switched on channel %d\n", Channel);
|
---|
53 | sleep(2);
|
---|
54 |
|
---|
55 | // Switch of all channels
|
---|
56 | DimClient::sendCommand("Bias/Command", "gs 0");
|
---|
57 | printf("Switched off all channels\n");
|
---|
58 |
|
---|
59 | exit(EXIT_SUCCESS);
|
---|
60 |
|
---|
61 | }
|
---|