mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
Jf zeromq display (#644)
* modified ZmqSocket to expose the SO_RCVBUF and SO_SENDBUF parameters. Modified DataStreamer.cpp to change the SENDBUF to 1MB when HWL is <10. Modified Datastreamer.cpp so that when HWL is changed, socket is unbind/rebind. Added rebind to ZmqSocket.cpp. Changed slot UpdatePlot() in qdrawplot.h from privat tto public, added plot->UpdatePlot() after every axis range change, so the plots are updated immediatly and not at the next image. Added onlinedisp_zmq program which connects to the receiver ZMQ port and show images and histos. Compiled against ROOT 6.22/02. Added examples files. * added setbuffer size also for gui, moved hardcoded values to a macro, removed unnecessary return of ok or success, added actual zmq exception message to could not create sockets error * zmq: changing buffer size done within hwm --------- Co-authored-by: mozzanica <l_mozzanica@mpc2012.psi.ch> Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch>
This commit is contained in:
204
slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.h
Normal file
204
slsDetectorCalibration/jungfrauExecutables/onlinedisp_zmq.h
Normal file
@ -0,0 +1,204 @@
|
||||
|
||||
/**************************************************************************/
|
||||
/* Header files section needs cleanup */
|
||||
/**************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include "sls/ZmqSocket.h"
|
||||
|
||||
#include "sls/tiffIO.h"
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdlib.h> /* exit() */
|
||||
#include <string.h> /* memset(), memcpy() */
|
||||
#include <sys/utsname.h> /* uname() */
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h> /* socket(), bind(),
|
||||
listen(), accept() */
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h> /* fork(), write(), close() */
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <cmath>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#include <omp.h>
|
||||
#define NTHREADS 2
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <ctime> // time_t
|
||||
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using namespace sls;
|
||||
|
||||
#include "TCanvas.h"
|
||||
#include "TH1F.h"
|
||||
#include "TF1.h"
|
||||
#include "TH2F.h"
|
||||
#include "TMath.h"
|
||||
#include "TFile.h"
|
||||
#include "TStyle.h"
|
||||
#include "TSystem.h"
|
||||
#include "TTimer.h"
|
||||
#include "TProfile.h"
|
||||
#include "TColor.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <termios.h>
|
||||
#include <TApplication.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include "sls/ansi.h"
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x4
|
||||
|
||||
#define PI 3.14159265
|
||||
|
||||
#define FALSE 0
|
||||
#define OFFSET 0
|
||||
#define NBIN 500
|
||||
#define MIN_POS -500.5 // 400.5
|
||||
#define MAX_POS 3499.5 //-100.5
|
||||
|
||||
|
||||
#define NCH 524288
|
||||
// #define NCH 262144 in case of half_frames
|
||||
|
||||
char serverip[256];
|
||||
int portnum;
|
||||
FILE * sfilefd;
|
||||
|
||||
short* hchptr; // photon counted map "histogram"
|
||||
int value;
|
||||
float factor=1.84;
|
||||
int npacket=0;
|
||||
int totalnpacket=0;
|
||||
float vgamma;
|
||||
|
||||
struct sockaddr_in serveraddr;
|
||||
struct sockaddr_in clientaddr;
|
||||
struct in_addr inadr;
|
||||
struct hostent *server;
|
||||
|
||||
int i=0;
|
||||
int ipx=0;
|
||||
bool haveconnection;
|
||||
|
||||
|
||||
TStyle *gStyle;
|
||||
TApplication* rootapp;
|
||||
TCanvas *A2;
|
||||
TCanvas *A3;
|
||||
TCanvas *A4;
|
||||
TCanvas *A5;
|
||||
TCanvas *A6;
|
||||
|
||||
TH1I **hchip;
|
||||
TH2F **h4500chip;
|
||||
short image_data[NCH*2];
|
||||
short imaged[NCH*2];
|
||||
float fpeded[NCH*2];
|
||||
float fpedeG2d[NCH*2];
|
||||
float fpedeG1d[NCH*2];
|
||||
short ipeded[NCH*2];
|
||||
short pcimaged[NCH*2];
|
||||
|
||||
float fgaind[NCH*2];
|
||||
|
||||
|
||||
float adcpedecorr,adcpedecorrold;
|
||||
|
||||
bool gain_flag;
|
||||
bool bw_flag;
|
||||
bool fill2Ds;
|
||||
bool show2Ds;
|
||||
bool fill1Ds;
|
||||
bool pede_flag;
|
||||
bool dophotonmap;
|
||||
|
||||
int nx, ny;
|
||||
int nframes;
|
||||
int goout;
|
||||
int framesinstream;
|
||||
int ifp;
|
||||
float threshold;
|
||||
int phene;
|
||||
int adcvalue;
|
||||
int gain;
|
||||
int ichip;
|
||||
int frameIndex_old;
|
||||
|
||||
char pedefilename[128];
|
||||
int framenum,bunchid;
|
||||
|
||||
TH2F* his1000;
|
||||
TH2F* his2000;
|
||||
TH2F* his3000;
|
||||
TH2F* his4500;
|
||||
TH1I* hproj;
|
||||
TH1I* hchcum;
|
||||
|
||||
|
||||
using namespace std;
|
||||
void printhelp(void);
|
||||
void processifp(int ifp);
|
||||
void historeset(void);
|
||||
void SetRanges(void);
|
||||
void startsocket(void);
|
||||
void stopsocket(void);
|
||||
void axisreset(void);
|
||||
int kbhit(void);
|
||||
void myloop(void);
|
||||
void loadpede(void);
|
||||
void loadallpede(void);
|
||||
void loadgain(void);
|
||||
void nonblock(int state);
|
||||
void LoadPaletteFalse(void);
|
||||
void LoadPaletteBW(float);
|
||||
void Plot1DHistos(void);
|
||||
void Plot2DHistos(void);
|
||||
void savepede(void);
|
||||
void readpede(void);
|
||||
int findinterpoindex(int startindex);
|
||||
int findclumax(int startindex);
|
||||
void tryconnect(void) ;
|
||||
|
||||
#define NB_ENABLE 1
|
||||
#define NB_DISABLE 0
|
||||
char c;
|
||||
int HDraw_every;
|
||||
|
||||
|
||||
float oldh0xfirst,oldh0xlast;
|
||||
int idx;
|
||||
int GXPoffset,G1Poffset,G2Poffset;
|
||||
int ix,iy;
|
||||
int adcmin,adcmax;
|
||||
int pmmin,pmmax; //min/mnx for the photon map
|
||||
bool fixranges;
|
||||
|
||||
|
||||
sls::ZmqSocket *zmqSocket= NULL;
|
Reference in New Issue
Block a user