JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
GreenMonster.cc
Go to the documentation of this file.
1
2#include "GreenMonster.h"
3
4//ClassImp(GreenMonster)
5
7{
8 fUseCrate[0]= kFALSE;
9 fCrateNames[0] = new TString("Qweak Injector");
10 fCrateNumbers[0] = Crate_CountingHouse;//injector crate
11
12 fUseCrate[1]= kFALSE;
13 fCrateNames[1] = new TString("Injector");
15
16 fUseCrate[2]= kFALSE;
17 fCrateNames[2] = new TString("Left Spect");
19
20 fUseCrate[3]= kFALSE;
21 fCrateNames[3] = new TString("Right Spect");
23
24
25 fUseCrate[4]= kTRUE;
26 fCrateNames[4] = new TString("Qw VME TS");
28
29
30}
31
34
36 // cfSockCliOpen(Crate_CountingHouse, 0);
37};
38
40 // cfSockCliClose();
41};
42
44 SCNCheckStatus(); // this call is actually an important initialization!
45 SCNCheckValues(); // this call is actually an important initialization!
46};
47
48
49
51
52 switch (id)
53 {
54 case SCN_INT_CLN:
55 {
56 // fStateRBtSCN[SCN_RADIO_NOT_BT]->SetState(kButtonUp);
57 // fStateRBtSCN[SCN_RADIO_CLN_BT]->SetState(kButtonDown);
58 statusSCN=id;
59 break;
60 }
61 case SCN_INT_NOT:
62 {
63 // fStateRBtSCN[SCN_RADIO_CLN_BT]->SetState(kButtonUp);
64 // fStateRBtSCN[SCN_RADIO_NOT_BT]->SetState(kButtonDown);
65 statusSCN=id;
66 break;
67 }
68 default:
69 std::cout << "ERROR: Unrecognized SCAN status flag" << std::endl;
70 }
71 return;
72}
73
74
76 struct greenRequest gRequest;
77 int command, par1, par2, command_type;
78 char *msgReq = "SCN status check";
79 char *reply = "Y";
80 Int_t iclean;
81
82 // printf("SCN Status =");
83 command_type = COMMAND_SCAN; gRequest.command_type = command_type;
84 command = SCAN_GET_STATUS; gRequest.command = command;
85 par1 = 0; gRequest.par1 = par1;
86 par2 = 0; gRequest.par2 = par2;
87 strcpy(gRequest.message,msgReq); gRequest.reply = reply;
88 if (GreenSockCommand(Crate_Qwvmets,&gRequest) == SOCK_OK) {
89 command = gRequest.command;
90 par1 = gRequest.par1;
91 par2 = gRequest.par2;
92 iclean=par1;
93 if (iclean != SCN_INT_CLN && iclean != SCN_INT_NOT) {
94 printf("UNKNOWN REPLY FOR SCN STATUS: %d ",iclean);
95 return kFALSE;
96 }
97 } else {
98 printf("ERROR accessing socket!");
99 return kFALSE;
100 }
101
102 // printf("% d %d\n",par1,par2);
103
104 SCNUpdateStatus(iclean);
105 return kTRUE;
106}
107
108void GreenMonster::SCNSetStatus(Int_t status) {
109 struct greenRequest gRequest;
110 int command, par1, par2, command_type;
111 char *msgReq = "SCN Status Change";
112 char *reply = "Y";
113
114 command_type = COMMAND_SCAN; gRequest.command_type = command_type;
115 command = SCAN_SET_STATUS; gRequest.command = command;
116 par1 = status; gRequest.par1 = par1;
117 par2 = 0; gRequest.par2 = par2;
118
119 if (fVerbose) std::cout << "Setting SCN status: " << par1 << std::endl;
120 strcpy(gRequest.message,msgReq); gRequest.reply = reply;
121
122 if (GreenSockCommand(Crate_Qwvmets,&gRequest) == SOCK_OK) {
123 if (fVerbose) printf("SCAN status change call is complete\n");
124 } else {
125 printf("ERROR accessing socket!");
126 return;
127 }
128 // check scan status
130}
131
132
133
134void GreenMonster::SCNSetValue(Int_t which, Int_t value) {
135 struct greenRequest gRequest;
136 int command, par1, par2, command_type;
137 char *msgReq = "Set SCN Data Value";
138 char *reply = "Y";
139
140 if (which==1) setpoint1SCN=value;
141 else if (which==2) setpoint2SCN=value;
142
143 if (fVerbose) std::cout << " writing new SCAN set point " << value
144 << " to data" << which <<std::endl;
145 //
146 // send set message for obj, value
147 //
148 command_type = COMMAND_SCAN; gRequest.command_type = command_type;
149 command = SCAN_SET_DATA; gRequest.command = command;
150 par1 = which; gRequest.par1 = par1;
151 par2 = value; gRequest.par2 = par2;
152 strcpy(gRequest.message,msgReq); gRequest.reply = reply;
153 if (GreenSockCommand(Crate_Qwvmets,&gRequest) == SOCK_OK) {
154 command = gRequest.command;
155 par1 = gRequest.par1;
156 par2 = gRequest.par2;
157 } else {
158 printf("ERROR accessing socket!");
159 return;
160 }
161 return;
162}
163
165 struct greenRequest gRequest;
166 int command, par1, par2, command_type;
167 char *msgReq = "Check SCN Data Value";
168 char *reply = "Y";
169 char buff[10];
170 int value;
171
172 //
173 command_type = COMMAND_SCAN; gRequest.command_type = command_type;
174 command = SCAN_GET_DATA; gRequest.command = command;
175 par1 = 1; gRequest.par1 = par1;
176 par2 = 0; gRequest.par2 = par2;
177 strcpy(gRequest.message,msgReq); gRequest.reply = reply;
178 if (GreenSockCommand(Crate_Qwvmets,&gRequest) == SOCK_OK) {
179 command = gRequest.command;
180 par1 = gRequest.par1;
181 par2 = gRequest.par2;
182 value = par2;
183 } else {
184 printf("ERROR accessing socket!");
185 return;
186 }
187
188 //
189 // get value from tent
190 //
191 setpoint1SCN=value;
192
193 // repeat for second data word
194
195 command_type = COMMAND_SCAN; gRequest.command_type = command_type;
196 command = SCAN_GET_DATA; gRequest.command = command;
197 par1 = 2; gRequest.par1 = par1;
198 par2 = 0; gRequest.par2 = par2;
199 strcpy(gRequest.message,msgReq); gRequest.reply = reply;
200 if (GreenSockCommand(Crate_Qwvmets,&gRequest) == SOCK_OK) {
201 command = gRequest.command;
202 par1 = gRequest.par1;
203 par2 = gRequest.par2;
204 value = par2;
205 } else {
206 printf("ERROR accessing socket!");
207 return;
208 }
209
210 //
211 // get value from tent
212 //
213 setpoint2SCN=value;
214
215 return;
216}
217
#define SCN_INT_NOT
#define SCN_INT_CLN
int GreenSockCommand(int crate_number, struct greenRequest *gRequest)
Definition cfSockCli.c:334
#define SOCK_OK
Definition cfSock.h:16
#define Crate_Injector
Definition GreenSock.h:25
#define Crate_RightSpect
Definition GreenSock.h:22
#define Crate_CountingHouse
Definition GreenSock.h:16
#define Crate_LeftSpect
Definition GreenSock.h:19
#define Crate_Qwvmets
Definition GreenSock.h:28
#define COMMAND_SCAN
#define SCAN_GET_DATA
#define SCAN_SET_STATUS
#define SCAN_SET_DATA
#define SCAN_GET_STATUS
void SCNUpdateStatus(Int_t)
void SCNCheckValues()
Int_t fCrateNumbers[5]
void SCNSetStatus(Int_t)
Bool_t SCNCheckStatus()
Bool_t fUseCrate[5]
void SCNSetValue(Int_t, Int_t)
TString * fCrateNames[5]
char message[GREEN_REQUEST_MSG_SIZE]
Definition GreenSock.h:37
long command_type
Definition GreenSock.h:32
char * reply
Definition GreenSock.h:36