1 #ifndef _RTS_SYSTEMS_H_
2 #define _RTS_SYSTEMS_H_
32 #define TRG_BSMD_BIT 2
34 #define TRG_FTPC_BIT 3
38 #define TRG_SSD_BIT 5 // used to be RICH
40 #define TRG_BTOW_BIT 6
41 #define TRG_EMC_BIT TRG_BTOW_BIT // use "BTOW"
44 #define TRG_FP2_BIT TRG_FPD_BIT // same bit as for older FPD
46 #define TRG_ETOW_BIT 8
47 #define TRG_EEC_BIT TRG_ETOW_BIT // use "ETOW"
49 #define TRG_ESMD_BIT 9
51 #define TRG_PMD_BIT 10
55 #define TRG_CTB_BIT 14 // does not have a LIVE bit
57 #define TRG_BBC_BIT 15 // does not have a LIVE bit
69 #define TCD_SVT_CD 13 // SVT's cable driver slot
71 #define TCD_BSMD 15 //
73 #define TCD_BTOW 17 //
74 #define TCD_FTPC 18 //
77 #define TCD_VPD 21 // Tonko,March07,instead of: TPC's cable driver slot
79 #define TCD_HFT TCD_TPC // for now HFT uses TPC TCD???
80 #define TCD_TPX TCD_TPC // 2007: TPX uses TCP
146 #define LOCALHOST_NODE 0
148 #define ERROR_NODE 0xFFFF
157 #define TPC_ID TPC_SYSTEM
160 #define SVT_ID SVT_SYSTEM
163 #define TOF_ID TOF_SYSTEM
166 #define BTOW_SYSTEM 3
167 #define BTOW_ID BTOW_SYSTEM
172 #define FPD_ID FPD_SYSTEM
175 #define FTP_ID FTP_SYSTEM
179 #define EXT_ID EXT_SYSTEM
183 #define RIC_ID RIC_SYSTEM
186 #define TRG_ID TRG_SYSTEM
189 #define L3_ID L3_SYSTEM
192 #define SC_ID SC_SYSTEM
195 #define EXT2_SYSTEM 11
196 #define EXT2_ID EXT2_SYSTEM
198 #define PMD_SYSTEM 12
199 #define PMD_ID PMD_SYSTEM
201 #define SSD_SYSTEM 13
202 #define SSD_ID SSD_SYSTEM
205 #define ETOW_SYSTEM 14
206 #define ETOW_ID ETOW_SYSTEM
208 #define DAQ_SYSTEM 15
209 #define DAQ_ID DAQ_SYSTEM
210 #define RTS_SYSTEM DAQ_SYSTEM
213 #define FP2_SYSTEM 16
214 #define FP2_ID FP2_SYSTEM
217 #define PP_ID PP_SYSTEM
219 #define BSMD_SYSTEM 18
220 #define BSMD_ID BSMD_SYSTEM
222 #define ESMD_SYSTEM 19
223 #define ESMD_ID ESMD_SYSTEM
225 #define TPX_SYSTEM 20
226 #define TPX_ID TPX_SYSTEM
228 #define HFT_SYSTEM 21
229 #define HFT_ID HFT_SYSTEM
231 #define RTS_NUM_SYSTEMS 22
233 #define PP_SEQE_INSTANCE 1
234 #define PP_SEQW_INSTANCE 2
235 #define PP_TRG_INSTANCE 3
236 #define PP_TEST_INSTANCE 4
242 #define TRG_L1_SUBSYS 1
243 #define TRG_L2_SUBSYS 2
255 #ifndef RTS_PROJECT_PP
256 #define DAQMAN_INSTANCE 1
259 #define BB_INSTANCE 2
261 #ifndef RTS_PROJECT_PP
262 #define EVP_INSTANCE 3
266 #define BDB_INSTANCE 4 // we'll keep the BDB controller's node_id the same...
268 #define BB2_INSTANCE 5
270 #define EVB_INSTANCE BB_INSTANCE
271 #define EVB02_INSTANCE BB2_INSTANCE
272 #define RC_CLIENT_INSTANCE 14
273 #define CLIENT_INSTANCE 15
276 #ifdef RTS_PROJECT_PP
277 #define DAQMAN_INSTANCE BB_INSTANCE
278 #define EVP_INSTANCE BB_INSTANCE
281 #define TRG_INSTANCE 1
282 #define TRG_L1_INSTANCE 2
283 #define TRG_L2_INSTANCE 3
284 #define TRG_TCD_INSTANCE 4
285 #define TRG_RCC_INSTANCE 5
286 #define TRG_CTB_INSTANCE 6
288 #define TRG_SCALER48_INSTANCE 7
289 #define TRG_MIX_INSTANCE 8
290 #define TRG_BC1_INSTANCE 9
291 #define TRG_BCE_INSTANCE 10
292 #define TRG_BCW_INSTANCE 11
293 #define TRG_SCALER_INSTANCE 12
294 #define TRG_BBC_INSTANCE 13
295 #define TRG_FPE_INSTANCE 14
296 #define TRG_FMS_INSTANCE 15
297 #define TRG_L0_INSTANCE 16 // Tonko. Feb25,03
298 #define TRG_QT1_INSTANCE 17
299 #define TRG_QT2_INSTANCE 18
300 #define TRG_QT3_INSTANCE 19
301 #define TRG_QT4_INSTANCE 20
303 #define L3EVP_INSTANCE 1
304 #define L3DISP_INSTANCE 2
317 #define EVB_NODES(x) ((DAQ_SYSTEM<<12) | (EVB_SUBSYS<<8) | (x))
318 #define GB_NODES(x) ((DAQ_SYSTEM<<12) | (GB_SUBSYS<<8 ) | (x))
319 #define GB_NODE GB_NODES(1)
322 #define BB_NODE ((DAQ_SYSTEM<<12) | BB_INSTANCE)
324 #ifdef RTS_PROJECT_PP
326 #define DAQMAN_NODE BB_NODE
327 #define EVP_NODE BB_NODE
328 #define BB2_NODE BB_NODE
332 #define DAQMAN_NODE ((DAQ_SYSTEM<<12) | DAQMAN_INSTANCE)
333 #define EVP_NODE ((DAQ_SYSTEM<<12) | EVP_INSTANCE)
334 #define BB2_NODE ((DAQ_SYSTEM<<12) | BB2_INSTANCE)
339 #define RC_NODE DAQMAN_NODE
340 #define LOG_NODE DAQMAN_NODE
341 #define MON_NODE DAQMAN_NODE
344 #define RC_CLIENT_NODE ((DAQ_SYSTEM<<12) | RC_CLIENT_INSTANCE)
345 #define CLIENT_NODE ((DAQ_SYSTEM<<12) | CLIENT_INSTANCE)
352 #define EVB_NODE EVB_NODES(1)
355 #define BDB_NODE ((DAQ_SYSTEM<<12) | BDB_INSTANCE) // old GB...
358 #define RIC01_NODE ((RIC_SYSTEM<<12) | 1)
359 #define RIC02_NODE ((RIC_SYSTEM<<12) | 2)
360 #define RIC_NODE RIC01_NODE
362 #define TOF01_NODE ((TOF_SYSTEM<<12) | 1) // DAQ end
363 #define TOF02_NODE ((TOF_SYSTEM<<12) | 2) // Platform
364 #define TOF03_NODE ((TOF_SYSTEM<<12) | 3) // new, test node
365 #define TOF_NODE TOF01_NODE
366 #define TOF_NODES ((TOF_SYSTEM<<12) | (x)) // shorthand
368 #define FPD01_NODE ((FPD_SYSTEM<<12) | 1)
369 #define FPD02_NODE ((FPD_SYSTEM<<12) | 2)
370 #define FPD_NODE FPD01_NODE
372 #define FPD_DEST_HOST "gb.daq.bnl.local"
373 #define FPD_PORT 5211
376 #define TPC_NODES(x) ((TPC_SYSTEM<<12) | (x))
378 #define FTP_NODES(x) ((FTP_SYSTEM<<12) | (x))
380 #define SVT_NODES(x) ((SVT_SYSTEM<<12) | (x))
385 #define BTOW_NODE ((BTOW_SYSTEM<<12) | 1)
387 #define BSMD_NODE ((EXT_SYSTEM<<12)|(BSMD_SYSTEM<<4)|1)
388 #define BSMD_NODES(x) ((EXT_SYSTEM<<12)|(BSMD_SYSTEM<<4) | (x))
390 #define BPRE_NODE ((BTOW_SYSTEM<<12) | 2)
393 #define PMD01_NODE ((EXT_SYSTEM<<12)|(PMD_SYSTEM<<4) | 1)
394 #define PMD02_NODE ((EXT_SYSTEM<<12)|(PMD_SYSTEM<<4) | 2)
395 #define PMD03_NODE ((EXT_SYSTEM<<12)|(PMD_SYSTEM<<4) | 3)
396 #define PMD_NODES(x) ((EXT_SYSTEM<<12)|(PMD_SYSTEM<<4) | (x))
398 #define PMD_NODE PMD03_NODE
400 #define PMD_DEST_HOST "gb.daq.bnl.local"
401 #define PMD_PORT_1 5201
402 #define PMD_PORT_2 5202 // becomes 5202 soon!
404 #define SSD01_NODE ((EXT_SYSTEM<<12)|(SSD_SYSTEM<<4) | 1)
405 #define SSD_NODE SSD01_NODE
408 #define FP201_NODE ((EXT_SYSTEM<<12)|(FP2_SYSTEM<<4) | 1)
409 #define FP2_NODE FP201_NODE
413 #define ETOW_NODE ((EXT_SYSTEM<<12)|(ETOW_SYSTEM<<4)|1)
414 #define ESMD_NODE ((EXT_SYSTEM<<12)|(ESMD_SYSTEM<<4)|1)
418 #define L3_NODES(x) ((L3_SYSTEM<<12) | (SL3_SUBSYS<<8) | (x))
419 #define SL3_NODES(x) ((L3_SYSTEM<<12) | (SL3_SUBSYS<<8) | (x))
420 #define GL3_NODES(x) ((L3_SYSTEM<<12) | (GL3_SUBSYS<<8) | (x))
421 #define L3EVP_NODE ((L3_SYSTEM<<12) | 1)
422 #define L3DISP_NODE ((L3_SYSTEM<<12) | 2)
423 #define GL3_NODE GL3_NODES(1)
426 #define TRG_NODE ((TRG_SYSTEM<<12) | TRG_INSTANCE)
427 #define TRG_L1_NODE ((TRG_SYSTEM<<12) | TRG_L1_INSTANCE)
429 #define TRG_L2_NODE ((TRG_SYSTEM<<12) | (TRG_L2_SUBSYS<<8) | (1))
430 #define TRG_TCD_NODE ((TRG_SYSTEM<<12) | TRG_TCD_INSTANCE)
431 #define TRG_RCC_NODE ((TRG_SYSTEM<<12) | TRG_RCC_INSTANCE)
432 #define TRG_CTB_NODE ((TRG_SYSTEM<<12) | TRG_CTB_INSTANCE)
433 #define TRG_L1_NODES(x) ((TRG_SYSTEM<<12) | (TRG_L1_SUBSYS<<8) | (x))
434 #define TRG_L2_NODES(x) ((TRG_SYSTEM<<12) | (TRG_L2_SUBSYS<<8) | (x))
435 #define TRG_MIX_NODE ((TRG_SYSTEM<<12) | TRG_MIX_INSTANCE)
436 #define TRG_BC1_NODE ((TRG_SYSTEM<<12) | TRG_BC1_INSTANCE)
437 #define TRG_BCE_NODE ((TRG_SYSTEM<<12) | TRG_BCE_INSTANCE)
438 #define TRG_BCW_NODE ((TRG_SYSTEM<<12) | TRG_BCW_INSTANCE)
439 #define TRG_SCALER_NODE ((TRG_SYSTEM<<12) | TRG_SCALER_INSTANCE)
440 #define TRG_BBC_NODE ((TRG_SYSTEM<<12) | TRG_BBC_INSTANCE)
441 #define TRG_FPE_NODE ((TRG_SYSTEM<<12) | TRG_FPE_INSTANCE)
442 #define TRG_FMS_NODE ((TRG_SYSTEM<<12) | TRG_FMS_INSTANCE)
443 #define TRG_L0_NODE ((TRG_SYSTEM<<12) | TRG_L0_INSTANCE) // Tonko, Feb25,03
444 #define TRG_QT1_NODE ((TRG_SYSTEM<<12) | TRG_QT1_INSTANCE)
445 #define TRG_QT2_NODE ((TRG_SYSTEM<<12) | TRG_QT2_INSTANCE)
446 #define TRG_QT3_NODE ((TRG_SYSTEM<<12) | TRG_QT3_INSTANCE)
447 #define TRG_QT4_NODE ((TRG_SYSTEM<<12) | TRG_QT4_INSTANCE)
449 #define TRG_SCALER48_NODE ((TRG_SYSTEM<<12) | TRG_SCALER48_INSTANCE)
452 #define TDI_NODE ((TRG_SYSTEM<<12) | TRG_TDI_INSTANCE)
454 #define L201_NODE TRG_L2_NODES(1)
457 #define SC_NODE ((SC_SYSTEM<<12) | 1)
460 #define PP_SEQE_NODE ((EXT_SYSTEM<<12) | ((PP_SYSTEM)<<4) | PP_SEQE_INSTANCE)
463 #define PP_SEQ1_NODE PP_SEQE_NODE
465 #define PP_SEQW_NODE ((EXT_SYSTEM<<12) | ((PP_SYSTEM)<<4) | PP_SEQW_INSTANCE)
467 #define PP_SEQ2_NODE PP_SEQW_NODE
469 #define PP_TRG_NODE ((EXT_SYSTEM<<12) | ((PP_SYSTEM)<<4) | PP_TRG_INSTANCE)
470 #define PP_TEST_NODE ((EXT_SYSTEM<<12) | ((PP_SYSTEM)<<4) | PP_TEST_INSTANCE)
473 #define PP_NODES(x) ((EXT_SYSTEM<<12) | ((PP_SYSTEM)<<4) | (x))
475 #define TPX_NODES(x) ((EXT2_SYSTEM<<12) | ((TPX_SYSTEM)<<7) | (x))
476 #define HFT_NODES(x) ((EXT2_SYSTEM<<12) | ((HFT_SYSTEM)<<7) | (x))
479 extern inline const char *rts2name(
int rts_id)
525 extern inline int rts2det(
int ix)
549 extern inline int rts2tcd(
int rts)
551 static const int map[32] = {
584 extern inline int tcd2rts(
int tcd)
586 static int map[32] = {
627 extern inline u_int grp2rts_mask(
int grp)
633 if(grp & (1<<TPC_GRP)) {
634 ret = (1<<TPC_SYSTEM) | (1<<SVT_SYSTEM) | (1<<FTP_SYSTEM) | (1<<TOF_SYSTEM) | (1<<TPX_SYSTEM) | (1<<HFT_SYSTEM) | (1<<PP_SYSTEM);
636 if(grp & (1<<SSD_GRP)) {
637 ret |= (1<<SSD_SYSTEM) ;
639 if(grp & (1<<PMD_GRP)) {
640 ret |= (1<<PMD_SYSTEM) ;
642 if(grp & (1<<ETOW_GRP)) {
643 ret |= (1<<ETOW_SYSTEM) ;
645 if(grp & (1<<ESMD_GRP)) {
646 ret |= (1<<ESMD_SYSTEM) ;
648 if(grp & (1<<BTOW_GRP)) {
649 ret |= (1<<BTOW_SYSTEM) ;
651 if(grp & (1<<BSMD_GRP)) {
652 ret |= (1<<BSMD_SYSTEM) ;
654 if(grp & (1<<FPD_GRP)) {
655 ret |= (1<<FPD_SYSTEM) ;
662 extern inline int rts2grp(
int rts)
673 case SSD_ID:
return SSD_GRP;
674 case FPD_ID:
return FPD_GRP;
675 case FP2_ID:
return FPD_GRP;
676 case BTOW_ID:
return BTOW_GRP;
677 case BSMD_ID:
return BSMD_GRP;
678 case ETOW_ID:
return ETOW_GRP;
679 case ESMD_ID:
return ESMD_GRP;
680 case PMD_ID:
return PMD_GRP;
681 case TPX_ID:
return TPC_GRP;
682 case HFT_ID:
return TPC_GRP;
695 extern inline int GET_NODE(
int sys,
int subsys,
int inst)
699 if((sys <= 10) || (sys==15)) {
700 node = (sys<<12) | (subsys<<8) | (inst);
703 node = (EXT_SYSTEM << 12) | (sys<<4) | (inst);
706 node = (EXT2_SYSTEM << 12) | (sys<<7) | (inst);
712 extern inline int GET_SYSTEM(
unsigned short node)
715 id = (node & 0xf000) >> 12;
717 if(
id == EXT_SYSTEM)
return (node & 0x03f0) >> 4;
718 if(
id == EXT2_SYSTEM)
return (node & 0x0f80) >> 7;
722 extern inline int GET_INSTANCE(
unsigned short node)
726 id = (node & 0xf000) >> 12;
727 if(
id == EXT_SYSTEM)
return node & 0xf;
728 if(
id == EXT2_SYSTEM)
return node & 0x7f;
732 extern inline int GET_SUBSYSTEM(
unsigned short node)
734 int id = (node & 0xf000) >> 12;
736 if(
id == EXT_SYSTEM)
return 0;
737 if(
id == EXT2_SYSTEM)
return 0;
738 return (node & 0x0300) >> 8;
741 #define GET_NODE_PRE_APR2002(sys,subsys,inst) ((sys<<12) | (subsys<<8) | (inst))
742 #define GET_SYSTEM_PRE_APR2002(x) (((x) >> 12) & 0xf)
743 #define GET_INSTANCE_PRE_APR2002(x) ((x) & 0xff)
744 #define GET_SUBSYSTEM_PRE_APR2002(x) (((x) >> 8) & 0x3)
746 #define GET_ROUTE(x) (((x) >> 10) & 0x3)