//******************************************************************************* //* Copyright (c) 2008-2014 Synchrotron SOLEIL //* All rights reserved. This program and the accompanying materials //* are made available under the terms of the GNU Lesser Public License v3 //* which accompanies this distribution, and is available at //* http://www.gnu.org/licenses/lgpl.html //****************************************************************************** //****************************************************************************************** // // // september 13, 2004 : Header file for the communication in socket mode // // with a Lecroy scope (avaiable for all models) // // // author : X.Elattaoui // // SocketLecroy.h: interface for the socket class. // //****************************************************************************************** #ifndef _SocketLecroy_H #define _SocketLecroy_H //- necessary includes #ifdef WIN32 #include <winsock2.h> #endif #include "SocketException.h" //////////////////////////////////////////////////////////////////// // // SocketLecroy :: DEFINITION // //////////////////////////////////////////////////////////////////// //- Structure of the command Header typedef struct { unsigned char bEOI_Flag; unsigned char reserved[3]; int iLength; } TCP_HEADER; //- Constants definitions //----------------------------------------------- const int SERVER_PORT = 1861; //- It's the same port number for all Lecroy scope's. const int EOI_FLAG = 0x01; const int SRQ_FLAG = 0x08; const int CLEAR_FLAG = 0x10; const int LOCKOUT_FLAG= 0x20; const int REMOTE_FLAG = 0x40; const int DATA_FLAG = 0x80; const int TCP_MINIMUM_PACKET_SIZE = 64; class SocketLecroy { private: SocketLecroy(); //- just one instance of SocketLecroy must be done for all waveforms of a same Lecroy device ~SocketLecroy(); static SocketLecroy* SL_instance; //- ptr on the SocketLecroy instance public: static SocketLecroy* get_instance(void); static void delete_instance(SocketLecroy*); void TCP_WriteDevice (char *buf, int length,bool eoi_flag) throw (lecroy::SocketException); //- send a cmd to the device void TCP_ReadDevice (char *buf, int length, int* nb_byte_received) throw (lecroy::SocketException); //- read the device replie void TCP_Connect (char *ip_address) throw (lecroy::SocketException); //- build TCP/IP connection void TCP_Disconnect (void) throw (lecroy::SocketException); //- disconnect the device void TCP_ClearDevice (void) throw (lecroy::SocketException); //- disconnect and reconnect the device }; #endif // _SocketLecroy_H