MIDAS
Loading...
Searching...
No Matches
fevmemodules.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "midas.h"
#include "mvmestd.h"
#include "vmicvme.h"
#include "vmeio.h"
#include "v1190B.h"
#include "v792.h"
#include "vf48.h"
#include "v1729.h"
#include "experim.h"
Include dependency graph for fevmemodules.c:

Go to the source code of this file.

Macros

#define VF48_CODE
 
#define P_BOE   0x1
 
#define P_EOE   0x2
 
#define P_CLR   0x4
 
#define S_READOUT   0x8
 
#define S_RUNGATE   0x10
 
#define TRIG_LEVEL   (int) 1
 
#define INT_LEVEL   (int) 3
 
#define INT_VECTOR   (int) 0x16
 
#define N_ADC   100
 
#define N_TDC   100
 
#define N_PTS   5000
 
#define N_SCLR   4
 

Functions

INT frontend_init ()
 Frontend initialization.
 
INT frontend_exit ()
 Frontend exit.
 
INT begin_of_run (INT run_number, char *error)
 Begin of Run.
 
INT end_of_run (INT run_number, char *error)
 End of Run.
 
INT pause_run (INT run_number, char *error)
 Pause Run.
 
INT resume_run (INT run_number, char *error)
 Resume Run.
 
INT frontend_loop ()
 Frontend loop.
 
void interrupt_routine (void)
 
INT read_trigger_event (char *pevent, INT off)
 
INT read_scaler_event (char *pevent, INT off)
 Scaler event readout.
 
void register_cnaf_callback (int debug)
 
void seq_callback (INT hDB, INT hseq, void *info)
 
INT poll_event (INT source, INT count, BOOL test)
 Polling routine for events.
 
INT interrupt_configure (INT cmd, INT source, PTYPE adr)
 

Variables

int trig_level = 0
 
INT_INFO int_info
 
int myinfo = VME_INTERRUPT_SIGEVENT
 
charfrontend_name = "fevmemodules"
 The frontend name (client name) as seen by other MIDAS clients.
 
charfrontend_file_name = __FILE__
 The frontend file name, don't change it.
 
BOOL frontend_call_loop = FALSE
 frontend_loop is called periodically if this variable is TRUE
 
INT display_period = 000
 a frontend status page is displayed with this frequency in ms
 
INT max_event_size = 200000
 maximum event size produced by this frontend
 
INT max_event_size_frag = 5 * 1024 * 1024
 maximum event size for fragmented events (EQ_FRAGMENTED)
 
INT event_buffer_size = 10 * 100000
 buffer size to hold events
 
MVME_INTERFACEmyvme
 
int sRG = 0
 
int intflag = 0
 
int inRun = 0
 
int missed =0
 
int done =0
 
int stop_req =0
 
DWORD evlimit
 
DWORD VMEIO_BASE = 0x780000
 
DWORD VTDC0_BASE = 0xF10000
 
DWORD VADC0_BASE = 0x100000
 
DWORD VADC1_BASE = 0x200000
 
DWORD VADC2_BASE = 0x300000
 
DWORD VADC3_BASE = 0x400000
 
DWORD VLAM_BASE = 0x800000
 
DWORD VF48_BASE = 0xAF0000
 
DWORD V1729_BASE = 0x120000
 
HNDLE hDB
 main ODB handle
 
HNDLE hSet
 
TRIGGER_SETTINGS ts
 
BANK_LIST trigger_bank_list []
 
EQUIPMENT equipment []
 Main structure for midas equipment.
 
int vf48_error = 0
 

Macro Definition Documentation

◆ INT_LEVEL

#define INT_LEVEL   (int) 3

Definition at line 45 of file fevmemodules.c.

◆ INT_VECTOR

#define INT_VECTOR   (int) 0x16

Definition at line 46 of file fevmemodules.c.

◆ N_ADC

#define N_ADC   100

Definition at line 97 of file fevmemodules.c.

◆ N_PTS

#define N_PTS   5000

Definition at line 99 of file fevmemodules.c.

◆ N_SCLR

#define N_SCLR   4

Definition at line 105 of file fevmemodules.c.

◆ N_TDC

#define N_TDC   100

Definition at line 98 of file fevmemodules.c.

◆ P_BOE

#define P_BOE   0x1

Definition at line 36 of file fevmemodules.c.

◆ P_CLR

#define P_CLR   0x4

Definition at line 38 of file fevmemodules.c.

◆ P_EOE

#define P_EOE   0x2

Definition at line 37 of file fevmemodules.c.

◆ S_READOUT

#define S_READOUT   0x8

Definition at line 39 of file fevmemodules.c.

◆ S_RUNGATE

#define S_RUNGATE   0x10

Definition at line 40 of file fevmemodules.c.

◆ TRIG_LEVEL

#define TRIG_LEVEL   (int) 1

Definition at line 44 of file fevmemodules.c.

◆ VF48_CODE

#define VF48_CODE

Definition at line 19 of file fevmemodules.c.

Function Documentation

◆ begin_of_run()

INT begin_of_run ( INT  run_number,
char error 
)

Begin of Run.

Called every run start transition. Set equipment status in ODB, start acquisition on the modules.

Parameters
[in]run_numberNumber of the run being started
[out]errorCan be used to write a message string to midas.log

Definition at line 285 of file fevmemodules.c.

286{
287 int i, csr, status, size;
288 /* put here clear scalers etc. */
289
290 /* read Triggger settings */
291 size = sizeof(TRIGGER_SETTINGS);
292 if ((status = db_get_record (hDB, hSet, &ts, &size, 0)) != DB_SUCCESS)
293 return status;
294
295 // Set am to A24 non-privileged Data
297
298 // Set dmode to D32
300
301#if defined VTDC0_CODE
302 //-------- TDCs -------------------------------------------
303 // Check the TDC
305 printf("Firmware revision: 0x%x\n", csr);
306
307 // Set mode 1
309
310 if (ts.v1190.leresolution == 100)
312 else if (ts.v1190.leresolution == 200)
314 else if (ts.v1190.leresolution == 800)
316 else
317 temp = 3;
318 if (temp != 2)
320
321 // Adjust window width to 10us
322 // 10us == 0x18F
323 temp = (DWORD) abs(ts.v1190.windowwidth / 25e-9);
325
326 // Adjust offset width to 10us
327 // 10us == 0xE70
328 temp = ts.v1190.windowoffset / 25e-9;
329 temp = temp < 0 ? ((DWORD)temp&0xFFF): (DWORD) temp;
331
332 // Print Current status
333 printf("BOR : FELIXE V1190B settings\n");
335#endif
336
337#if defined V792_CODE
338 //-------- ADCs ------------------------------------------
339 printf("ADC0\n");
341 printf("ADC1\n");
343 printf("ADC2\n");
345 printf("ADC3\n");
347
348 /* Initialize the V792s ADC0 --*/
349 /* Load Threshold */
350 for (i=0;i<V792_MAX_CHANNELS;i+=2) {
351 printf("B Threshold[%i] = 0x%4.4x\t - ", i, ts.v792.threshold1[i]);
352 printf("Threshold[%i] = 0x%4.4x\n", i+1, ts.v792.threshold1[i+1]);
353 }
355
356 for (i=0;i<V792_MAX_CHANNELS;i+=2) {
357 printf("Threshold[%i] = 0x%4.4x\t - ", i, ts.v792.threshold1[i]);
358 printf("Threshold[%i] = 0x%4.4x\n", i+1, ts.v792.threshold1[i+1]);
359 }
360
363 printf("Data Ready ADC0: 0x%x\n", csr);
364
365 /* Initialize the V792s ADC1 --*/
366 /* Load Threshold */
367 v792_ThresholdWrite(myvme, VADC1_BASE, (WORD *)&(ts.v792.thresholds2));
370 printf("Data Ready ADC1: 0x%x\n", csr);
371
372 /* Initialize the V792s ADC2 --*/
373 /* Load Threshold */
374 v792_ThresholdWrite(myvme, VADC2_BASE, (WORD *)&(ts.v792.thresholds3));
377 printf("Data Ready ADC2: 0x%x\n", csr);
378
379 /* Initialize the V792s ADC3 --*/
380 /* Load Threshold */
381 v792_ThresholdWrite(myvme, VADC3_BASE, (WORD *)&(ts.v792.thresold4));
384 printf("Data Ready ADC3: 0x%x\n", csr);
385#endif
386
387
388#if defined V1729_CODE
389 //-------- 1/2 Gsps ADC (CAEN) -------------------------------------
390 // Set mode 3 (128 full range)
393
394 // Print Current status
396
397 // Start acquisition
399#endif
400
401#if defined VF48_CODE
402 //-------- 20..65 Msps ADC (Uni Montreal) -------------------------
403 /* Initialize the VF48 --*/
405
406 // Stop DAQ for seting up the parameters
408
411 printf("vf48: External trigger mode\n");
412 } else {
414 printf("vf48: Self triggering mode\n");
415 }
417 printf("CSR Buffer: 0x%x\n", csr);
418
419 // Segment Size
421 for (i=0;i<6;i++) {
422 printf("vf48: SegSize grp (%d) %i:%d\n", ts.vf48.segment_size
424 }
425
426 // Set Threshold high for external trigger, as the
427 // the self-trigger is always sending info to the collector
428 // and overwhelming the link. (max maybe 10 bits (0x3FF))
429 // Threshold
430 for (i=0;i<6;i++) {
432 printf("vf48: Trigger Threshold grp (%d) %i:%d\n", ts.vf48.trigger_threshold
434 }
435
436 // Set Threshold high for Hit detection
437 for (i=0;i<6;i++) {
439 printf("vf48: Hit Threshold grp (%d) %i:%d\n", ts.vf48.hit_threshold
441 }
442
443 // Active Channel Mask
444 for (i=0;i<6;i++){
446 printf("vf48: Active channel mask grp (%x) %i:0x%x\n", ts.vf48.active_channel_mask
448 }
449
450 // Raw Data Suppression
451 for (i=0;i<6;i++){
453 printf("vf48: Raw Data Suppress grp (%x) %i:0x%x\n", ts.vf48.raw_data_suppress
455 }
456
457 // Channel Suppress Enable
458 for (i=0;i<6;i++){
460 printf("vf48: Channel Suppression Enable grp (%x) %i:0x%x\n", ts.vf48.channel_suppress_enable
461 , i, 0x1 & vf48_ChSuppRead(myvme, VF48_BASE, i));
462 }
463
464 // Divisor
466 for (i=0;i<6;i++){
467 printf("vf48: Divisor grp (%x) %i:0x%x\n", ts.vf48.divisor
469 }
470
471 // PreTrigger
472 for (i=0;i<6;i++) {
474 printf("vf48: Pre Trigger grp %i:%d\n"
476 }
477
478 // Latency
479 for (i=0;i<6;i++) {
481 printf("vf48: Latency grp %i:%d\n"
483 }
484
485 // K-coef
486 for (i=0;i<6;i++) {
488 printf("vf48: K-coeff grp %i:%d\n"
490 }
491 // L-coef
492 for (i=0;i<6;i++) {
494 printf("vf48: L-coeff grp %i:%d\n"
496 }
497 // M-coef
498 for (i=0;i<6;i++) {
500 printf("vf48: M-coeff grp %i:%d\n"
502 }
503
504 // Polarity
505 for (i=0;i<6;i++) {
506 DWORD pat;
511 } else {
515 }
516 printf("vf48: Polarity grp %i:%d\n"
518 }
519
520 // Group Enable
522 printf("vf48: Group Enable :0x%x\n", vf48_GrpRead(myvme, VF48_BASE));
523
524 // Start ACQ for VF48
526#endif
527
528
529#if defined VMEIO_CODE
530 //-------- VMEIO (triumf board) ----------------------------------
531 // Set am to A24 non-privileged Data
533
534 // Set dmode to D32
536
537 // Set pulse mode
539#endif
540
541 //------ FINAL ACTIONS before BOR -----------
542 // Send Clear pulse
543 // vmeio_SyncWrite(myvme, VMEIO_BASE, P_CLR);
544
545 /* Reset Latch */
546
547 /********* commented out for other test purpose
548 vmeio_SyncWrite(myvme, VMEIO_BASE, P_EOE);
549
550 // Open run gate
551 vmeio_AsyncWrite(myvme, VMEIO_BASE, S_RUNGATE);
552
553 // Disable interrupt
554 mvme_write_value(myvme, VLAM_BASE+4, 0x0);
555
556 // Reset Latch
557 mvme_write_value(myvme, VLAM_BASE, 0x1);
558
559 // Clear pending interrupts
560 mvme_write_value(myvme, VLAM_BASE+8, 0x0);
561 // printf("Vector:0x%lx\n", (mvme_read_value(myvme, VLAM_BASE+0x8) & 0xFF));
562
563 // Enable interrupt
564 inRun = 1;
565 mvme_write_value(myvme, VLAM_BASE+4, inRun);
566 */
567
568 missed = 0; // for the v1729 missed trigger
569 printf("End of BOR\n");
570 return SUCCESS;
571}
DWORD VADC2_BASE
HNDLE hSet
DWORD VADC3_BASE
DWORD VADC0_BASE
int missed
DWORD VTDC0_BASE
DWORD VF48_BASE
TRIGGER_SETTINGS ts
#define P_EOE
DWORD VMEIO_BASE
DWORD VADC1_BASE
DWORD V1729_BASE
HNDLE hDB
main ODB handle
Definition mana.cxx:207
#define P_BOE
#define P_CLR
MVME_INTERFACE * myvme
#define DB_SUCCESS
Definition midas.h:631
unsigned short int WORD
Definition mcstd.h:49
unsigned int DWORD
Definition mcstd.h:51
#define SUCCESS
Definition mcstd.h:54
unsigned int EXPRT mvme_read_value(MVME_INTERFACE *vme, mvme_addr_t vme_addr)
int EXPRT mvme_set_dmode(MVME_INTERFACE *vme, int dmode)
int EXPRT mvme_set_am(MVME_INTERFACE *vme, int am)
#define MVME_DMODE_D32
Definition mvmestd.h:82
#define MVME_AM_A24_ND
Definition mvmestd.h:120
INT db_get_record(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT align)
Definition odb.cxx:11709
INT i
Definition mdump.cxx:32
#define DWORD
Definition mhdump.cxx:31
DWORD status
Definition odbhist.cxx:39
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
BOOL raw_data_suppress
Definition experim.h:34
BOOL external_trigger
Definition experim.h:30
struct TRIGGER_SETTINGS::@27 v792
INT active_channel_mask
Definition experim.h:36
INT group_bitwise_all_0x3f_
Definition experim.h:33
DWORD post_trigger
Definition experim.h:58
WORD threshold1[32]
Definition experim.h:47
struct TRIGGER_SETTINGS::@29 v1729
BOOL inverse_signal
Definition experim.h:31
struct TRIGGER_SETTINGS::@28 v1190
BOOL channel_suppress_enable
Definition experim.h:35
struct TRIGGER_SETTINGS::@26 vf48
INT trigger_threshold
Definition experim.h:37
static double e(void)
Definition tinyexpr.c:136
Here is the call graph for this function:

◆ end_of_run()

INT end_of_run ( INT  run_number,
char error 
)

End of Run.

Called every stop run transition. Set equipment status in ODB, stop acquisition on the modules.

Parameters
[in]run_numberNumber of the run being ended
[out]errorCan be used to write a message string to midas.log

Definition at line 574 of file fevmemodules.c.

575{
576 // Stop DAQ for seting up the parameters
578
579 done = 0;
580 stop_req = 0;
581 inRun = 0;
582 // Disable interrupt
584 trig_level = 0;
585 // Close run gate
587 return SUCCESS;
588}
int inRun
int stop_req
int done
int trig_level
DWORD VLAM_BASE
int EXPRT mvme_write_value(MVME_INTERFACE *vme, mvme_addr_t vme_addr, unsigned int value)
Here is the call graph for this function:

◆ frontend_exit()

INT frontend_exit ( void  )

Frontend exit.

Runs at frontend shutdown. Disconnect hardware and set equipment status in ODB

Returns
Midas status code

Definition at line 278 of file fevmemodules.c.

279{
280 return SUCCESS;
281}

◆ frontend_init()

INT frontend_init ( void  )

Frontend initialization.

Runs once at application startup. We initialize the hardware and optical interfaces and set the equipment status in ODB. We also lock the frontend to once physical cpu core.

Returns
Midas status code

Definition at line 233 of file fevmemodules.c.

234{
235 int size, status;
236 char set_str[80];
237
238 /* Book Setting space */
240
241 /* Map /equipment/Trigger/settings for the sequencer */
242 sprintf(set_str, "/Equipment/Trigger/Settings");
245 if (status != DB_SUCCESS)
246 cm_msg(MINFO,"FE","Key %s not found", set_str);
247
248 /* Enable hot-link on settings/ of the equipment */
249 size = sizeof(TRIGGER_SETTINGS);
250 if ((status = db_open_record(hDB, hSet, &ts, size, MODE_READ
252 return status;
253
254 // Open VME interface
255 status = mvme_open(&myvme, 0);
256
257 // Set am to A24 non-privileged Data
259
260 // Set dmode to D32
262
263#if defined V1729_CODE
264 // Collect Pedestals
266
267 // Do vernier calibration
269#endif
270
271 /* print message and return FE_ERR_HW if frontend should not be started */
272
273 return SUCCESS;
274}
#define TRIGGER_SETTINGS_STR(_name)
Definition experim.h:166
void seq_callback(INT hDB, INT hseq, void *info)
#define MINFO
Definition midas.h:560
#define MODE_READ
Definition midas.h:370
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
int EXPRT mvme_open(MVME_INTERFACE **vme, int idx)
INT db_open_record(HNDLE hDB, HNDLE hKey, void *ptr, INT rec_size, WORD access_mode, void(*dispatcher)(INT, INT, void *), void *info)
Definition odb.cxx:13291
std::string strcomb1(const char **list)
Definition odb.cxx:598
INT db_find_key(HNDLE hDB, HNDLE hKey, const char *key_name, HNDLE *subhKey)
Definition odb.cxx:4079
INT db_create_record(HNDLE hDB, HNDLE hKey, const char *orig_key_name, const char *init_str)
Definition odb.cxx:12800
Here is the call graph for this function:

◆ frontend_loop()

INT frontend_loop ( void  )

Frontend loop.

If frontend_call_loop is true, this routine gets called when the frontend is idle or once between every event.

Returns
Midas status code

Definition at line 621 of file fevmemodules.c.

622{
623 /* if frontend_call_loop is true, this routine gets called when
624 the frontend is idle or once between every event */
625 char str[128];
626
627 if (stop_req && done==0) {
628 db_set_value(hDB,0,"/logger/channels/0/Settings/Event limit", &evlimit, sizeof(evlimit), 1, TID_DWORD);
629 if (cm_transition(TR_STOP, 0, str, sizeof(str), ASYNC, FALSE) != CM_SUCCESS) {
630 cm_msg(MERROR, "VF48 Timeout", "cannot stop run: %s", str);
631 }
632 inRun = 0;
633 // Disable interrupt
635 done = 1;
636 cm_msg(MERROR, "VF48 Timeout","VF48 Stop requested");
637 }
638 return SUCCESS;
639}
#define FALSE
Definition cfortran.h:309
DWORD evlimit
INT cm_transition(INT transition, INT run_number, char *errstr, INT errstr_size, INT async_flag, INT debug_flag)
Definition midas.cxx:5286
#define CM_SUCCESS
Definition midas.h:582
#define MERROR
Definition midas.h:559
#define TR_STOP
Definition midas.h:406
#define TID_DWORD
Definition midas.h:336
INT db_set_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT num_values, DWORD type)
Definition odb.cxx:5261
char str[256]
Definition odbhist.cxx:33
Here is the call graph for this function:

◆ interrupt_configure()

INT interrupt_configure ( INT  cmd,
INT  source,
PTYPE  adr 
)

Definition at line 671 of file fevmemodules.c.

672{
673 int vec = 0;
674 switch (cmd) {
677 break;
680 break;
686 printf("Interrupt Attached to 0x%x for vector:0x%x\n", adr, vec&0xFF);
687 break;
689 printf("Interrupt Detach\n");
690 break;
691 }
692 return SUCCESS;
693}
int myinfo
#define INT_VECTOR
#define INT_LEVEL
#define CMD_INTERRUPT_ATTACH
Definition midas.h:822
#define CMD_INTERRUPT_DISABLE
Definition midas.h:821
#define CMD_INTERRUPT_ENABLE
Definition midas.h:820
#define CMD_INTERRUPT_DETACH
Definition midas.h:823
int EXPRT mvme_interrupt_attach(MVME_INTERFACE *mvme, int level, int vector, void(*isr)(int, void *, void *), void *info)
Here is the call graph for this function:

◆ interrupt_routine()

void interrupt_routine ( void  )
extern

◆ pause_run()

INT pause_run ( INT  run_number,
char error 
)

Pause Run.

Called every pause run transition.

Parameters
[in]run_numberNumber of the run being ended
[out]errorCan be used to write a message string to midas.log
Returns
Midas status code

Definition at line 591 of file fevmemodules.c.

592{
593 inRun = 0;
594 // Disable interrupt
596 trig_level = 0;
597 // Close run gate
599
600 return SUCCESS;
601}
Here is the call graph for this function:

◆ poll_event()

INT poll_event ( INT  source,
INT  count,
BOOL  test 
)

Polling routine for events.

Parameters
[in]sourceEvent source (LAM/IRQ)
[in]countLoop count for event polling timeout
[in]testflag used to time the polling
Returns
1 if event is available, 0 if done polling (no event). If test equals TRUE, don't return.

Definition at line 650 of file fevmemodules.c.

656{
657 int i;
658 int lam = 0;
659
660 for (i = 0; i < count; i++, lam++) {
662 if (lam)
663 if (!test)
664 return lam;
665 }
666
667 return 0;
668}
double count
Definition mdump.cxx:33
program test
Definition miniana.f:6
Here is the call graph for this function:

◆ read_scaler_event()

INT read_scaler_event ( char pevent,
INT  off 
)

Scaler event readout.

Placeholder.

Scaler event readout routine. Not used in this example.

Parameters
[in]peventPointer to event buffer
[in]offCaller info (unused here), see mfe.c
Returns
Size of the event

Definition at line 841 of file fevmemodules.c.

842{
843 DWORD *pdata;
844
845 /* init bank structure */
846 bk_init(pevent);
847
848 /* create SCLR bank */
849 bk_create(pevent, "SCLR", TID_DWORD, &pdata);
850
851 /* read scaler bank */
852 bk_close(pevent, pdata);
853
854 // return bk_size(pevent);
855 // Nothing to send for now
856 return 0;
857}
INT bk_close(void *event, void *pdata)
Definition midas.cxx:16780
void bk_init(void *event)
Definition midas.cxx:16406
void bk_create(void *event, const char *name, WORD type, void **pdata)
Definition midas.cxx:16561
Here is the call graph for this function:

◆ read_trigger_event()

INT read_trigger_event ( char pevent,
INT  off 
)


Definition at line 697 of file fevmemodules.c.

698{
699#if defined VADC0_CODE
700 DWORD *pdata;
701#endif
702#if defined VTDC0_CODE
703 DWORD *pdata;
704#endif
705#if defined VF48_CODE
706 DWORD *pdata;
707 int status, evtlength;
708#endif
709#if defined V1729_CODE
710 INT *pidata, timeout;
711 WORD data[20000];
712 INT nch, npt, nentry;
713#endif
714
715 evlimit = SERIAL_NUMBER(pevent);
716 // Timing Begin of Event
717 // vmeio_SyncWrite(myvme, VMEIO_BASE, P_BOE);
718 // Open READOUT State
719 // vmeio_AsyncWrite(myvme, VMEIO_BASE, (S_READOUT|S_RUNGATE));
720
721 // > THE LINE BELOW SHOULD BE HERE AND NOWHERE ELSE < !
722 bk_init32(pevent);
723
724#if defined VADC0_CODE
728 /* create structured ADC0 bank */
729 bk_create(pevent, "ADC0", TID_DWORD, &pdata);
731 /* Read Event */
733 pdata += nentry;
734 bk_close(pevent, pdata);
736#endif
737
738#if defined VADC1_CODE
740 /* create structured ADC1 bank */
741 bk_create(pevent, "ADC1", TID_DWORD, &pdata);
742 /* Read Event */
744 pdata += nentry;
745 bk_close(pevent, pdata);
746 // v792_EvtCntReset(myvme, VADC1_BASE);
747#endif
748
749#if defined VADC2_CODE
751 /* create structured ADC2 bank */
752 bk_create(pevent, "ADC2", TID_DWORD, &pdata);
753 /* Read Event */
755 pdata += nentry;
756 bk_close(pevent, pdata);
757#endif
758
759#if defined VADC3_CODE
761 /* create structured ADC3 bank */
762 bk_create(pevent, "ADC3", TID_DWORD, &pdata);
763 /* Read Event */
765 pdata += nentry;
766 bk_close(pevent, pdata);
767#endif
768
769#if defined VTDC0_CODE
771 /* create variable length TDC bank */
772 bk_create(pevent, "TDC0", TID_DWORD, &pdata);
773 /* Read Event */
775 pdata += nentry;
776 /* clear TDC */
777 // v1190_SoftClear(myvme, VTDC0_BASE);
778 bk_close(pevent, pdata);
779#endif
780
781#if defined VF48_CODE
783 /* create variable length WAVE bank */
784 bk_create(pevent, "WAVE", TID_DWORD, &pdata);
786 // printf("read vf48 evtlength:%d\n", evtlength);
787 pdata += (DWORD) evtlength;
788 bk_close(pevent, pdata);
789#endif
790
791#if defined V1729_CODE
793 timeout=20;
794 while(!v1729_isTrigger(myvme, V1729_BASE) && timeout) {
795 timeout--;
796 ss_sleep(1);
797 };
798 if (timeout == 0) {
799 printf("No Trigger evt#:%d missed:%d (%6.2f%%)\n", SERIAL_NUMBER(pevent)
800 , ++missed
801 , 100.*((float)missed/(float)SERIAL_NUMBER(pevent)));
802 }
803 npt = 2560;
804 nch = 4;
806 bk_create(pevent, "FWAV", TID_INT, &pidata);
807 *pidata++ = npt;
808 *pidata++ = data[7];
810 pidata += npt;
811 /*
812 *pidata++ = 0x10000 | npt;
813 v1729_OrderData(myvme, V1729_BASE, data, pidata, nch, 1, npt);
814 pidata += npt;
815 */
816 bk_close(pevent, pidata);
817
818 // Start acquisition
820#endif
821
823 // EOB
824 /*
825 vmeio_AsyncWrite(myvme, VMEIO_BASE, S_RUNGATE);
826 vmeio_SyncWrite(myvme, VMEIO_BASE, P_EOE);
827
828 // Reset Latch EOB
829 mvme_write_value(myvme, VLAM_BASE, 0x0); // Nim out
830 */
831
832 if (evtlength) {
833 // printf("evtlength: %d bk_size:%d\n", evtlength, bk_size(pevent));
834 return bk_size(pevent);
835 }
836 else
837 return 0;
838}
void bk_init32(void *event)
Definition midas.cxx:16469
INT bk_size(const void *event)
Definition midas.cxx:16495
#define TID_INT
Definition midas.h:338
INT ss_sleep(INT millisec)
Definition system.cxx:3628
void * data
Definition mana.cxx:268
int INT
Definition midas.h:129
#define SERIAL_NUMBER(e)
Definition midas.h:880
Here is the call graph for this function:

◆ register_cnaf_callback()

void register_cnaf_callback ( int  debug)

Definition at line 122 of file cnaf_callback.cxx.

122 {
124 /* register CNAF callback */
127}
INT cnaf_callback(INT index, void *prpc_param[])
static int cnaf_debug
INT cm_register_function(INT id, INT(*func)(INT, void **))
Definition midas.cxx:5790
#define RPC_CNAF16
Definition mrpc.h:125
#define RPC_CNAF24
Definition mrpc.h:126
BOOL debug
debug printouts
Definition mana.cxx:254
Here is the call graph for this function:

◆ resume_run()

INT resume_run ( INT  run_number,
char error 
)

Resume Run.

Called every resume run transition.

Parameters
[in]run_numberNumber of the run being ended
[out]errorCan be used to write a message string to midas.log
Returns
Midas status code

Definition at line 604 of file fevmemodules.c.

605{
607
608 // EOB Pulse
610
611 // Open run gate
613
614 // Enable interrupt
615 inRun = 1;
617 return SUCCESS;
618}
#define S_RUNGATE
#define TRIG_LEVEL
Here is the call graph for this function:

◆ seq_callback()

void seq_callback ( INT  hDB,
INT  hseq,
void info 
)

Definition at line 227 of file fevmemodules.c.

228{
229 printf("odb ... trigger settings touched\n");
230}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ display_period

INT display_period = 000

a frontend status page is displayed with this frequency in ms

Definition at line 66 of file fevmemodules.c.

◆ done

int done =0

Definition at line 82 of file fevmemodules.c.

◆ equipment

EQUIPMENT equipment[]

Main structure for midas equipment.

Definition at line 150 of file fevmemodules.c.

150 {
151
152 {"Trigger", /* equipment name */
153 {1, 0, /* event ID, trigger mask */
154 "SYSTEM", /* event buffer */
155#ifdef USE_INT
156 EQ_INTERRUPT, /* equipment type */
157#else
158 EQ_PERIODIC, // POLLED, /* equipment type */
159#endif
160 LAM_SOURCE(0, 0x0), /* event source crate 0, all stations */
161 "MIDAS", /* format */
162 TRUE, /* enabled */
163 RO_RUNNING, /* read only when running */
164 500, /* poll for 500ms */
165 0, /* stop run after this event limit */
166 0, /* number of sub events */
167 0, /* don't log history */
168 "", "", "",},
169 read_trigger_event, /* readout routine */
170 NULL, NULL,
172 }
173 ,
174
175 {"Scaler", /* equipment name */
176 {2, 0, /* event ID, trigger mask */
177 "SYSTEM", /* event buffer */
178 EQ_PERIODIC , /* equipment type */
179 0, /* event source */
180 "MIDAS", /* format */
181 FALSE, /* enabled */
182 RO_RUNNING | RO_TRANSITIONS | /* read when running and on transitions */
183 RO_ODB, /* and update ODB */
184 10000, /* read every 10 sec */
185 0, /* stop run after this event limit */
186 0, /* number of sub events */
187 0, /* log history */
188 "", "", "",},
189 read_scaler_event, /* readout routine */
190 },
191
192 {""}
193};
BANK_LIST trigger_bank_list[]
INT read_trigger_event(char *pevent, INT off)
INT read_scaler_event(char *pevent, INT off)
Scaler event readout.
#define RO_ODB
Definition midas.h:438
#define EQ_PERIODIC
Definition midas.h:414
#define EQ_INTERRUPT
Definition midas.h:416
#define RO_TRANSITIONS
Definition midas.h:434
#define RO_RUNNING
Definition midas.h:426
#define LAM_SOURCE(c, s)
Definition midas.h:469
#define TRUE
Definition midas.h:182

◆ event_buffer_size

INT event_buffer_size = 10 * 100000

buffer size to hold events

Definition at line 75 of file fevmemodules.c.

◆ evlimit

DWORD evlimit

Definition at line 83 of file fevmemodules.c.

◆ frontend_call_loop

BOOL frontend_call_loop = FALSE

frontend_loop is called periodically if this variable is TRUE

Definition at line 63 of file fevmemodules.c.

◆ frontend_file_name

char* frontend_file_name = __FILE__

The frontend file name, don't change it.

Definition at line 60 of file fevmemodules.c.

◆ frontend_name

char* frontend_name = "fevmemodules"

The frontend name (client name) as seen by other MIDAS clients.

Definition at line 58 of file fevmemodules.c.

◆ hDB

HNDLE hDB
extern

main ODB handle

Definition at line 207 of file mana.cxx.

◆ hSet

HNDLE hSet

Definition at line 101 of file fevmemodules.c.

◆ inRun

int inRun = 0

Definition at line 81 of file fevmemodules.c.

◆ int_info

INT_INFO int_info
extern

◆ intflag

int intflag = 0

Definition at line 80 of file fevmemodules.c.

◆ max_event_size

INT max_event_size = 200000

maximum event size produced by this frontend

Definition at line 69 of file fevmemodules.c.

◆ max_event_size_frag

INT max_event_size_frag = 5 * 1024 * 1024

maximum event size for fragmented events (EQ_FRAGMENTED)

Definition at line 72 of file fevmemodules.c.

◆ missed

int missed =0

Definition at line 81 of file fevmemodules.c.

◆ myinfo

Definition at line 48 of file fevmemodules.c.

◆ myvme

Definition at line 78 of file fevmemodules.c.

◆ sRG

int sRG = 0

Definition at line 79 of file fevmemodules.c.

◆ stop_req

int stop_req =0

Definition at line 82 of file fevmemodules.c.

◆ trig_level

int trig_level = 0

Definition at line 43 of file fevmemodules.c.

◆ trigger_bank_list

BANK_LIST trigger_bank_list[]
Initial value:
= {
{"ADC0", TID_DWORD, N_ADC, NULL}
,
{"ADC1", TID_DWORD, N_ADC, NULL}
,
{"ADC2", TID_DWORD, N_ADC, NULL}
,
{"ADC3", TID_DWORD, N_ADC, NULL}
,
{"TDC0", TID_DWORD, N_TDC, NULL}
,
{"WAVE", TID_DWORD, N_TDC, NULL}
,
{"FWAV", TID_DWORD, N_PTS, NULL}
,
{""}
,
}
#define N_PTS
#define N_TDC
#define N_ADC

Definition at line 123 of file fevmemodules.c.

123 {
124
125 /* online banks */
126 {"ADC0", TID_DWORD, N_ADC, NULL}
127 ,
128 {"ADC1", TID_DWORD, N_ADC, NULL}
129 ,
130 {"ADC2", TID_DWORD, N_ADC, NULL}
131 ,
132 {"ADC3", TID_DWORD, N_ADC, NULL}
133 ,
134 {"TDC0", TID_DWORD, N_TDC, NULL}
135 ,
136
137 {"WAVE", TID_DWORD, N_TDC, NULL}
138 ,
139 {"FWAV", TID_DWORD, N_PTS, NULL}
140 ,
141
142 {""}
143 ,
144};

◆ ts

Definition at line 102 of file fevmemodules.c.

◆ V1729_BASE

DWORD V1729_BASE = 0x120000

Definition at line 95 of file fevmemodules.c.

◆ VADC0_BASE

DWORD VADC0_BASE = 0x100000

Definition at line 88 of file fevmemodules.c.

◆ VADC1_BASE

DWORD VADC1_BASE = 0x200000

Definition at line 89 of file fevmemodules.c.

◆ VADC2_BASE

DWORD VADC2_BASE = 0x300000

Definition at line 90 of file fevmemodules.c.

◆ VADC3_BASE

DWORD VADC3_BASE = 0x400000

Definition at line 91 of file fevmemodules.c.

◆ VF48_BASE

DWORD VF48_BASE = 0xAF0000

Definition at line 94 of file fevmemodules.c.

◆ vf48_error

int vf48_error = 0

Definition at line 696 of file fevmemodules.c.

◆ VLAM_BASE

DWORD VLAM_BASE = 0x800000

Definition at line 93 of file fevmemodules.c.

◆ VMEIO_BASE

DWORD VMEIO_BASE = 0x780000

Definition at line 86 of file fevmemodules.c.

◆ VTDC0_BASE

DWORD VTDC0_BASE = 0xF10000

Definition at line 87 of file fevmemodules.c.