data types and format

This commit is contained in:
Erik Frojdh 2019-01-21 14:43:24 +01:00
parent a4fec1e750
commit b200138730
4 changed files with 34 additions and 33 deletions

7
.clang-tidy Normal file
View File

@ -0,0 +1,7 @@
---
Checks: '*, -google-runtime-references, -hicpp-no-array-decay, -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -cppcoreguidelines-pro-bounds-pointer-arithmetic, -fuchsia*,-readability-else-after-return,-readability-avoid-const-params-in-decls,-hicpp-signed-bitwise,-cppcoreguidelines-pro-bounds-constant-array-index,-llvm-header-guard,-readability-static-accessed-through-instance,-google-readability-todo'
WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
...

View File

@ -11,6 +11,7 @@
#include "versionAPI.h" #include "versionAPI.h"
#include <arpa/inet.h> #include <arpa/inet.h>
#include <array>
#include <bitset> #include <bitset>
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
@ -5258,18 +5259,18 @@ int slsDetector::setCTBPatLoops(int level, int &start, int &stop, int &n) {
return ret; return ret;
} }
int slsDetector::setCTBPatWaitAddr(int level, int addr) { uint64_t slsDetector::setCTBPatWaitAddr(uint64_t level, uint64_t addr) {
int fnum = F_SET_CTB_PATTERN; int fnum = F_SET_CTB_PATTERN;
int ret = FAIL; int ret = FAIL;
int mode = 2; // sets loop uint64_t mode = 2; // sets loop
uint64_t args[3] = {(uint64_t)mode, (uint64_t)level, (uint64_t)addr}; uint64_t retval = -1;
uint64_t retval = -1; std::array<uint64_t, 3> args{mode, level, addr};
FILE_LOG(logDEBUG1) << "Setting CTB Wait Addr, " FILE_LOG(logDEBUG1) << "Setting CTB Wait Addr, "
"level: " "level: "
<< level << ", addr: 0x" << std::hex << addr << std::dec; << level << ", addr: 0x" << std::hex << addr << std::dec;
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); ret = thisDetectorControl->Client_Send(fnum, args.data(), sizeof(args), &retval, sizeof(retval));
disconnectControl(); disconnectControl();
// handle ret // handle ret
@ -5285,16 +5286,16 @@ int slsDetector::setCTBPatWaitAddr(int level, int addr) {
return retval; return retval;
} }
int slsDetector::setCTBPatWaitTime(int level, uint64_t t) { uint64_t slsDetector::setCTBPatWaitTime(uint64_t level, uint64_t t) {
int fnum = F_SET_CTB_PATTERN; int fnum = F_SET_CTB_PATTERN;
int ret = FAIL; int ret = FAIL;
int mode = 3; // sets loop uint64_t mode = 3; // sets loop
uint64_t args[3] = {(uint64_t)mode, (uint64_t)level, t}; uint64_t retval = -1; //TODO! is this what we want?
uint64_t retval = -1; std::array<uint64_t,3> args{mode, level, t};
FILE_LOG(logDEBUG1) << "Setting CTB Wait Time, level: " << level << ", t: " << t; FILE_LOG(logDEBUG1) << "Setting CTB Wait Time, level: " << level << ", t: " << t;
if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) { if (thisDetector->onlineFlag == ONLINE_FLAG && connectControl() == OK) {
ret = thisDetectorControl->Client_Send(fnum, args, sizeof(args), &retval, sizeof(retval)); ret = thisDetectorControl->Client_Send(fnum, args.data(), sizeof(args), &retval, sizeof(retval));
disconnectControl(); disconnectControl();
// handle ret // handle ret

View File

@ -1612,7 +1612,7 @@ public:
* @param addr wait address, -1 gets * @param addr wait address, -1 gets
* @returns actual value * @returns actual value
*/ */
int setCTBPatWaitAddr(int level, int addr=-1); uint64_t setCTBPatWaitAddr(uint64_t level, uint64_t addr=-1);
/** /**
* Sets the wait time in the CTB * Sets the wait time in the CTB
@ -1620,7 +1620,7 @@ public:
* @param t wait time, -1 gets * @param t wait time, -1 gets
* @returns actual value * @returns actual value
*/ */
int setCTBPatWaitTime(int level, uint64_t t=-1); uint64_t setCTBPatWaitTime(uint64_t level, uint64_t t=-1);
private: private:

View File

@ -12,38 +12,31 @@
/* /*
canceled SetupParameters() and varaibles intialized in the constructors' headers; canceled SetupParameters() and varaibles intialized in the constructors' headers;
defined SEND_REC_MAX_SIZE (for compatibilty with mythen (and possibly other) pure C servers (i would move it to the common header file) defined SEND_REC_MAX_SIZE (for compatibilty with mythen (and possibly other) pure C servers (i would move it to the common header file)
added #ifndef C_ONLY... to cutout class definition when including in pure C servers (can be removed if SEND_REC_MAX_SIZE is moved to the common header file) added #ifndef C_ONLY... to cutout class definition when including in pure C servers (can be removed if SEND_REC_MAX_SIZE is moved to the common header file)
defined private variables char hostname[1000] and int portno to store connection informations; defined private variables char hostname[1000] and int portno to store connection informations;
defined public functions int getHostname(char *name) and int getPortNumber() to retrieve connection informations defined public functions int getHostname(char *name) and int getPortNumber() to retrieve connection informations
added public function int getErrorStatus() returning 1 if socketDescriptor<0 added public function int getErrorStatus() returning 1 if socketDescriptor<0
remove exits in the constructors and replace them with socketDescriptor=-1 remove exits in the constructors and replace them with socketDescriptor=-1
replaced the argument of send/receive data with void (to avoid too much casting or compiler errors/warnings) replaced the argument of send/receive data with void (to avoid too much casting or compiler errors/warnings)
added a function which really does not close the socket between send/receive (senddataonly, receivedataonly) added a function which really does not close the socket between send/receive (senddataonly, receivedataonly)
*/ Modified by Anna on 31.10.2012 developed and
/* Modified by Anna on 31.10.2012 */
developed and
*/
#include "genericSocket.h" #include "genericSocket.h"
#define TCP_PACKET_SIZE 4096 #define TCP_PACKET_SIZE 4096
class MySocketTCP: public genericSocket { class MySocketTCP : public genericSocket {
public:
public: // sender (client): where to? ip
MySocketTCP(const char* const host_ip_or_name, unsigned short int const port_number): genericSocket(host_ip_or_name, port_number,TCP){setPacketSize(TCP_PACKET_SIZE);}; // sender (client): where to? ip MySocketTCP(const char *const host_ip_or_name, uint64_t port_number)
MySocketTCP(unsigned short int const port_number):genericSocket(port_number,TCP) {setPacketSize(TCP_PACKET_SIZE);}; // receiver (server) local no need for ip : genericSocket(host_ip_or_name, port_number, TCP) {
setPacketSize(TCP_PACKET_SIZE);
}
// receiver (server) local no need for ip
MySocketTCP(uint16_t port_number)
: genericSocket(port_number, TCP) {
setPacketSize(TCP_PACKET_SIZE);
}
virtual ~MySocketTCP(){}; virtual ~MySocketTCP(){};
}; };