MIDAS
Loading...
Searching...
No Matches
camacsrv.cxx File Reference
#include <stdio.h>
#include "midas.h"
#include "msystem.h"
#include "mcstd.h"
Include dependency graph for camacsrv.cxx:

Go to the source code of this file.

Functions

INT cnaf16 (DWORD cmd, DWORD b, DWORD c, DWORD n, DWORD a, DWORD f, WORD *pdata, DWORD *size, DWORD *x, DWORD *q)
 
INT cnaf24 (DWORD cmd, DWORD b, DWORD c, DWORD n, DWORD a, DWORD f, DWORD *pdata, DWORD *size, DWORD *x, DWORD *q)
 
INT rpc_dispatch (INT index, void *prpc_param[])
 
 main (int argc, char *argv[])
 

Variables

int debug
 debug printouts
 

Function Documentation

◆ cnaf16()

INT cnaf16 ( DWORD  cmd,
DWORD  b,
DWORD  c,
DWORD  n,
DWORD  a,
DWORD  f,
WORD pdata,
DWORD size,
DWORD x,
DWORD q 
)

Definition at line 21 of file camacsrv.cxx.

23{
24 INT i, count;
25 WORD *ptmp;
26
27 /* determine repeat count */
28 count = *size / sizeof(WORD); /* 16 bit */
29
30 switch (cmd) {
31 /*---- special commands ----*/
32
35 break;
38 break;
41 break;
44 break;
45
46 case CNAF_TEST:
47 break;
48
49 /*---- 16 bit ----*/
50
51 case CNAF:
52 for (i = 0; i < count; i++)
53 if (f < 16)
54 cam16i_q(c, n, a, f, pdata, (int *) x, (int *) q);
55 else
56 cam16o_q(c, n, a, f, pdata[i], (int *) x, (int *) q);
57 break;
58
59 case CNAF_nQ:
60 ptmp = pdata;
61 if (f < 16)
62 cam16i_rq(c, n, a, f, &ptmp, count);
63
64 /* return reduced return size */
65 *size = (int) ptmp - (int) pdata;
66 break;
67
68 default:
69 printf("cnaf: Unknown command 0x%X\n", cmd);
70 }
71
72 if (debug)
73 printf("cmd=%d c=%d n=%d a=%d f=%d d=%X x=%d q=%d\n", cmd, c, n, a, f, *pdata, *x,
74 *q);
75
76 return RPC_SUCCESS;
77}
int debug
debug printouts
Definition camacsrv.cxx:17
#define RPC_SUCCESS
Definition midas.h:698
EXTERNAL void EXPRT cam16i_q(const int c, const int n, const int a, const int f, WORD *d, int *x, int *q)
EXTERNAL void EXPRT cam_inhibit_set(const int c)
EXTERNAL void EXPRT cam_inhibit_clear(const int c)
EXTERNAL void EXPRT cam16o_q(const int c, const int n, const int a, const int f, WORD d, int *x, int *q)
EXTERNAL void EXPRT cam_crate_clear(const int c)
EXTERNAL void EXPRT cam16i_rq(const int c, const int n, const int a, const int f, WORD **d, const int r)
EXTERNAL void EXPRT cam_crate_zinit(const int c)
unsigned short int WORD
Definition mcstd.h:49
static std::string q(const char *s)
DWORD n[4]
Definition mana.cxx:247
double count
Definition mdump.cxx:33
INT i
Definition mdump.cxx:32
int INT
Definition midas.h:129
#define CNAF_INHIBIT_SET
Definition midas.h:494
#define CNAF_TEST
Definition midas.h:498
#define CNAF_CRATE_ZINIT
Definition midas.h:497
#define CNAF
Definition midas.h:491
#define CNAF_CRATE_CLEAR
Definition midas.h:496
#define CNAF_nQ
Definition midas.h:492
#define CNAF_INHIBIT_CLEAR
Definition midas.h:495
TH1X EXPRT * h1_book(const char *name, const char *title, int bins, double min, double max)
Definition rmidas.h:24
char c
Definition system.cxx:1310
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cnaf24()

INT cnaf24 ( DWORD  cmd,
DWORD  b,
DWORD  c,
DWORD  n,
DWORD  a,
DWORD  f,
DWORD pdata,
DWORD size,
DWORD x,
DWORD q 
)

Definition at line 81 of file camacsrv.cxx.

83{
84 INT i, count;
85 DWORD *ptmp;
86
87 /* determine repeat count */
88 count = *size / sizeof(DWORD); /* 24 bit */
89
90 switch (cmd) {
91 case CNAF:
92 for (i = 0; i < count; i++)
93 if (f < 16)
94 cam24i_q(c, n, a, f, pdata, (int *) x, (int *) q);
95 else
96 cam24o_q(c, n, a, f, pdata[i], (int *) x, (int *) q);
97 break;
98
99 case CNAF_nQ:
100 ptmp = pdata;
101 if (f < 16)
102 cam24i_rq(c, n, a, f, &ptmp, count);
103
104 /* return reduced return size */
105 *size = (int) ptmp - (int) pdata;
106 break;
107
108 default:
109 printf("cnaf: Unknown command 0x%X\n", cmd);
110 }
111
112 if (debug)
113 printf("cmd=%d c=%d n=%d a=%d f=%d d=%X x=%d q=%d\n", cmd, c, n, a, f, *pdata, *x,
114 *q);
115
116 return RPC_SUCCESS;
117}
EXTERNAL void EXPRT cam24o_q(const int c, const int n, const int a, const int f, DWORD d, int *x, int *q)
EXTERNAL void EXPRT cam24i_q(const int c, const int n, const int a, const int f, DWORD *d, int *x, int *q)
EXTERNAL void EXPRT cam24i_rq(const int c, const int n, const int a, const int f, DWORD **d, const int r)
unsigned int DWORD
Definition mcstd.h:51
#define DWORD
Definition mhdump.cxx:31
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

main ( int  argc,
char argv[] 
)

Definition at line 145 of file camacsrv.cxx.

146{
147 INT status, port;
148
149 port = 1750;
151 if (status != RPC_SUCCESS) {
152 printf("Cannot start server\n");
153 return 1;
154 }
155 if (argc > 1) {
156 debug = 1;
157 printf("CAMAC server started (debugging mode)\n");
158 } else {
159 debug = 0;
160 printf("CAMAC server started\n");
161 }
162
167
168 cam_init();
169
170 while (cm_yield(1000) != RPC_SHUTDOWN);
171
173
174 return 0;
175}
INT rpc_dispatch(INT index, void *prpc_param[])
Definition camacsrv.cxx:121
INT cm_yield(INT millisec)
Definition midas.cxx:5642
#define RPC_SHUTDOWN
Definition midas.h:707
EXTERNAL int EXPRT cam_init(void)
RPC_LIST * rpc_get_internal_list(INT flag)
Definition mrpc.cxx:716
#define RPC_CNAF16
Definition mrpc.h:125
INT rpc_register_server(int port, int *plsock, int *pport)
Definition midas.cxx:14538
INT rpc_register_functions(const RPC_LIST *new_list, RPC_HANDLER func)
Definition midas.cxx:11827
INT rpc_server_shutdown(void)
Definition midas.cxx:16183
INT rpc_register_function(INT id, INT(*func)(INT, void **))
Definition midas.cxx:11897
#define RPC_CNAF24
Definition mrpc.h:126
DWORD status
Definition odbhist.cxx:39
Here is the call graph for this function:

◆ rpc_dispatch()

INT rpc_dispatch ( INT  index,
void prpc_param[] 
)

Definition at line 121 of file camacsrv.cxx.

122{
123 INT status;
124
125 switch (index) {
126 case RPC_CNAF16:
127 status = cnaf16(CDWORD(0), CDWORD(1), CDWORD(2), CDWORD(3), CDWORD(4),
128 CDWORD(5), CPWORD(6), CPDWORD(7), CPDWORD(8), CPDWORD(9));
129 break;
130
131 case RPC_CNAF24:
132 status = cnaf24(CDWORD(0), CDWORD(1), CDWORD(2), CDWORD(3), CDWORD(4),
133 CDWORD(5), CPDWORD(6), CPDWORD(7), CPDWORD(8), CPDWORD(9));
134 break;
135
136 default:
137 cm_msg(MERROR, "rpc_dispatch", "received unrecognized command");
138 }
139
140 return status;
141}
INT cnaf24(DWORD cmd, DWORD b, DWORD c, DWORD n, DWORD a, DWORD f, DWORD *pdata, DWORD *size, DWORD *x, DWORD *q)
Definition camacsrv.cxx:81
INT cnaf16(DWORD cmd, DWORD b, DWORD c, DWORD n, DWORD a, DWORD f, WORD *pdata, DWORD *size, DWORD *x, DWORD *q)
Definition camacsrv.cxx:21
#define MERROR
Definition midas.h:559
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
Definition midas.cxx:915
INT index
Definition mana.cxx:271
#define CDWORD(_i)
Definition midas.h:1631
#define CPWORD(_i)
Definition midas.h:1626
#define CPDWORD(_i)
Definition midas.h:1632
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ debug

int debug

debug printouts

Definition at line 17 of file camacsrv.cxx.