Skip to content
Snippets Groups Projects
Commit a631e8ea authored by Jonathan Hanks's avatar Jonathan Hanks
Browse files

First cut at removing the EDCU, as it is replaced by the

external dcu model.
parent 5b8601b9
No related branches found
No related tags found
No related merge requests found
......@@ -95,7 +95,6 @@ add_executable(daqd_shmem
circ.cc
framesend.cc
gdsmutex.cc
edcu.cc
epicsServer.cc
exServer.cc
exScalarPV.cc
......
......@@ -456,60 +456,6 @@ CommandLine: /* Nothing */
//iocsh($4);
}
//free($4);
#endif
}
| STATUS EPICS DCU OptionalIntnum {
#if EPICS_EDCU == 1
AUTH_CHECK(((my_lexer *)lexer));
ostream *yyout = ((my_lexer *)lexer)->get_yyout ();
if (daqd.edcu1.running) {
*yyout << daqd.edcu1.num_chans << " channels" << endl;
*yyout << daqd.edcu1.con_chans << " connected" << endl;
*yyout << daqd.edcu1.num_chans - daqd.edcu1.con_chans << " disconnected" << endl;
*yyout << daqd.edcu1.con_events << " connection events processed" << endl;
*yyout << daqd.edcu1.val_events << " value change events processed" << endl;
if ($4) {
int total_disco = 0;
int total_bad_bad = 0;
for (int i = 0 ; i < daqd.edcu1.num_chans; i++) {
if (daqd.edcu1.channel_status[i]) {
total_disco++;
*yyout << daqd.channels[daqd.edcu1.fidx + i]. name << endl;
if (daqd.edcu1.channel_status[i] != 0xbad) {
*yyout << "ERROR: status value is " << daqd.edcu1.channel_status[i] << endl;
total_bad_bad++;
}
}
}
*yyout << "Total " << total_disco << " disconnected." << endl;
if (total_bad_bad) *yyout << "Total " << total_bad_bad << " have invalid (not 0xbad) status value" << endl;
}
}
#endif
}
| START EPICS DCU {
#if EPICS_EDCU == 1
AUTH_CHECK(((my_lexer *)lexer));
ostream *yyout = ((my_lexer *)lexer)->get_yyout ();
if (daqd.edcu1.running) {
*yyout << "EDCU already running" << endl;
} else {
int num_epics_channels = 0;
for (int i = 0; i < daqd.num_channels; i++)
if (IS_EPICS_DCU(daqd.channels [i].dcu_id)) {
if (!num_epics_channels) daqd.edcu1.fidx = i;
num_epics_channels++;
}
if (!num_epics_channels) {
*yyout << "`start epics dcu': there are no epics channels configured" << endl;
system_log(1, "edcu was not started; no channels configured");
} else {
daqd.edcu1.num_chans = num_epics_channels;
if (! daqd.start_edcu (yyout)) {
system_log(1, "edcu started");
} else exit (1);
}
}
#endif
}
| STATUS DCU {
......
......@@ -1266,33 +1266,6 @@ daqd_c::start_main (int pmain_buffer_size, ostream *yyout)
return 0;
}
/// Start Epics DCU thread.
int
daqd_c::start_edcu (ostream *yyout)
{
// error message buffer
char errmsgbuf[80];
pthread_attr_t attr;
pthread_attr_init (&attr);
pthread_attr_setstacksize (&attr, daqd.thread_stack_size);
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
// pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
int err_no;
if (err_no = pthread_create (&edcu1.tid, &attr,
(void *(*)(void *))edcu1.edcu_static,
(void *) &edcu1)) {
strerror_r(err_no, errmsgbuf, sizeof(errmsgbuf));
pthread_attr_destroy (&attr);
system_log(1, "EDCU pthread_create() err=%s", errmsgbuf);
return 1;
}
pthread_attr_destroy (&attr);
DEBUG(2, cerr << "EDCU thread created; tid=" << edcu1.tid << endl);
edcu1.running = 1;
return 0;
}
/// Start Epics IOC server. This one serves the daqd status Epics channels.
int
daqd_c::start_epics_server (ostream *yyout, char *prefix, char *prefix1, char *prefix2)
......@@ -1470,9 +1443,6 @@ void daqd_c::initialize_vmpic(unsigned char **_move_buf, int *_vmic_pv_len, put_
move_addr->start[cur_dcu] = vmic_pv [vmic_pv_len].src_pvec_addr;
}
if (IS_EPICS_DCU(channels [i].dcu_id)) {
vmic_pv [vmic_pv_len].src_status_addr = edcu1.channel_status + i;
} else
if (IS_EXC_DCU(channels [i].dcu_id)) {
/* The AWG DCUs are using older data format with status word included in front of the data */
vmic_pv [vmic_pv_len].src_status_addr = (unsigned int *)(vmic_pv[vmic_pv_len].src_pvec_addr - 4);
......
......@@ -59,7 +59,6 @@ using namespace std;
#include "../../src/include/param.h"
#include "parameter_set.hh"
#include "edcu.hh"
#include "epicsServer.hh"
#include "epics_pvs.hh"
......@@ -199,7 +198,6 @@ class daqd_c {
num_channel_groups (0),
num_epics_channels (0),
edcu1 (0),
epics1 (),
num_gds_channels (0),
......@@ -329,7 +327,6 @@ class daqd_c {
/// The producer thread object.
producer producer1;
edcu edcu1;
epicsServer epics1;
/* Some generic consumer data --
......@@ -375,7 +372,6 @@ class daqd_c {
int start_main (int, ostream *);
int start_producer (ostream *);
int start_frame_saver (ostream *, int science);
int start_edcu (ostream *);
int start_epics_server (ostream *, char *, char *, char *);
parameter_set &parameters() { return _params; }
......
#include <config.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <errno.h>
#include <time.h>
#include <assert.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <signal.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <limits.h>
#include <string.h>
#include <iostream>
#include <fstream>
#include "epics_pvs.hh"
using namespace std;
#include "circ.hh"
#include "daqd.hh"
#include "sing_list.hh"
extern daqd_c daqd;
#if __GNUC__ >= 3
extern long int altzone;
#endif
#if EPICS_EDCU==1
#include "cadef.h"
void connectCallback(struct connection_handler_args args) {
unsigned int *channel_status = (unsigned int *)ca_puser(args.chid);
*channel_status = (args.op == CA_OP_CONN_UP? 0: 0xbad);
if (args.op == CA_OP_CONN_UP) daqd.edcu1.con_chans++; else daqd.edcu1.con_chans--;
daqd.edcu1.con_events++;
PV::set_pv(PV::PV_EDCU_CHANS, daqd.edcu1.num_chans);
PV::set_pv(PV::PV_EDCU_CONN_CHANS, daqd.edcu1.con_chans);
}
void subscriptionHandler(struct event_handler_args args) {
// system_log(1, "Epics Value Change callback for channel %d", (int)args.usr);
daqd.edcu1.val_events++;
if (args.status != ECA_NORMAL) {
//system_log(1, "ECA Abnormal status=%d", args.status);
return;
}
if (args.type == DBR_FLOAT) {
float val = *((float *)args.dbr);
float *channel_value = (float *)args.usr;
*channel_value = val;
} else {
// system_log(1, "args.type=%d", args.type);
}
}
void *
edcu::edcu_main ()
{
// Set thread parameters
daqd_c::set_thread_priority("EDCU","dqedcu",0,0);
ca_context_create(ca_enable_preemptive_callback);
for (int i = fidx; i < (fidx + num_chans); i++) {
chid chid1;
int status = ca_create_channel(daqd.channels[i].name, connectCallback,
(void *)&(daqd.edcu1.channel_status[i]), 0, &chid1);
status = ca_create_subscription(DBR_FLOAT, 0, chid1, DBE_VALUE,
subscriptionHandler,
(void *)&(daqd.edcu1.channel_value[i]), 0);
}
system_log(1, "EDCU has %d channels configured; first=%d\n", num_chans, fidx);
return (void*)0;
}
#endif /* if EPICS_EDCU != 1 */
#ifndef EDCU_HH
#define EDCU_HH
/// Epics data Collection
class edcu {
public:
edcu (int a) : fidx (0), num_chans (0), running (0),
con_chans (0), con_events(0), val_events(0) {
for (int i = 0; i < MAX_CHANNELS; i++) {
#ifdef USE_BROADCAST
channel_status[i] = 0; ///< For now set the status to good
#else
channel_status[i] = 0xbad;
#endif
channel_value[i] = 0.0;
}
};
void *edcu_main ();
static void *edcu_static (void *a) { return ((edcu *)a) -> edcu_main ();};
unsigned int num_chans; ///< Number of epics channels configured
unsigned int fidx; ///< Index to the first epics channel in daqd.channels[]
unsigned int con_chans; ///< Number of channels connected
unsigned int con_events; ///< Counter of all connection/disconnection events processed
unsigned int val_events; ///< Counter of all value change events processed
pthread_t tid;
bool running;
/// Producer picks up 32 bit data from here (IMPORTANT: do not use memcpy()!)
/// Epics connect/disconnect callback writing in this array
unsigned int channel_status[MAX_CHANNELS];
/// Epics value change callback is writing into this array
float channel_value[MAX_CHANNELS];
};
#endif
......@@ -370,15 +370,7 @@ void *producer::frame_writer() {
dcuSeenLastCycle[j] = true;
read_dest = dcu_move_addresses.start[j];
long read_size = daqd.dcuDAQsize[0][j];
if (IS_EPICS_DCU(j)) {
memcpy((void *)read_dest,
(char *)(daqd.edcu1.channel_value + daqd.edcu1.fidx),
read_size);
daqd.dcuStatus[0][j] = 0;
read_dest += read_size;
} else if (IS_MYRINET_DCU(j)) {
if (IS_MYRINET_DCU(j)) {
dcu_cycle = i % DAQ_NUM_DATA_BLOCKS;
// dcu_cycle = gmDaqIpc[j].cycle;
......@@ -603,34 +595,6 @@ void *producer::frame_writer() {
// receivers
prop.dcu_data[j].status =
daqd.dcuStatus[0 /* IFO */][j] & ~0x8000;
} else
// EDCU is "attached" to H1, not H2
if (j == DCU_ID_EDCU && ifo == 0) {
// See if the EDCU thread is running and assign status
if (0x0 == (prop.dcu_data[j].status =
daqd.edcu1.running ? 0x0 : 0xbad)) {
// If running calculate the CRC
// memcpy(read_dest, (char *)(daqd.edcu1.channel_value +
// daqd.edcu1.fidx), daqd.dcuSize[ifo][j]);
unsigned int bytes = daqd.dcuSize[0][DCU_ID_EDCU];
unsigned char *cp =
move_buf; // The EDCU data is in front
unsigned long crc = 0;
while (bytes--) {
crc = (crc << 8) ^
crctab[((crc >> 24) ^ *(cp++)) & 0xFF];
}
bytes = daqd.dcuDAQsize[0][DCU_ID_EDCU];
while (bytes > 0) {
crc = (crc << 8) ^
crctab[((crc >> 24) ^ bytes) & 0xFF];
bytes >>= 8;
}
crc = ~crc & 0xFFFFFFFF;
prop.dcu_data[j].crc = crc;
}
} else {
prop.dcu_data[j + ifo * DCU_COUNT].crc = ipc->bp[cblk].crc;
prop.dcu_data[j + ifo * DCU_COUNT].status =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment