Skip to content

Commit

Permalink
Merge branch 'developer' into dev/virtual_stop_server_start
Browse files Browse the repository at this point in the history
  • Loading branch information
thattil authored Sep 10, 2024
2 parents 4c1c5bb + 15e8c0d commit 02185b1
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 20 deletions.
4 changes: 2 additions & 2 deletions python/slsdet/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ def fpath(self):
Note
----
If path does not exist, it will try to create it.
If path does not exist and fwrite enabled, it will try to create it at start of acquisition.
Example
--------
Expand All @@ -1059,7 +1059,7 @@ def fpath(self, path):
@property
@element
def fwrite(self):
"""Enable or disable receiver file write. Default is enabled. """
"""Enable or disable receiver file write. Default is disabled. """
return self.getFileWrite()

@fwrite.setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,12 @@ int main(int argc, char *argv[]) {

int cf = 0;
int numberOfPackets=nrows/8;

#ifdef RECT
cout << "Should be rectangular but now it will crash! No data structure defined!" << endl;
#endif

#ifndef MOENCH04
moench03v2Data *decoder = new moench03v2Data(100);
moench03v2Data *decoder = new moench03v2Data(nrows/2);
cout << "MOENCH03!" << endl;
#endif

Expand Down Expand Up @@ -299,6 +298,7 @@ int main(int argc, char *argv[]) {
double *ped=new double[nx * ny];//, *ped1;
int pos,pos1;
//return 0;

if (pedfile.find(".raw") != std::string::npos) {
pos1=pedfile.rfind("/");
strcpy(froot,pedfile.substr(pos1).c_str());
Expand Down Expand Up @@ -336,9 +336,8 @@ int main(int argc, char *argv[]) {
}
filebin.close();
while (mt->isBusy()) {
;

}
;
}

sprintf(imgfname, "%s/%s_ped.tiff", outdir.c_str(),froot);
mt->writePedestal(imgfname);
Expand Down Expand Up @@ -463,7 +462,6 @@ int main(int argc, char *argv[]) {
}
} else {
cout << "bp " << ifr << " " << ff << " " << np << endl;
//break;
}
ff = -1;
}
Expand Down
4 changes: 2 additions & 2 deletions slsDetectorSoftware/generator/commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ settingspath:
arg_types: [ special::path ]

fpath:
help: "[path]\n\tDirectory where output data files are written in receiver. Default is '/'. \n\tIf path does not exist, it will try to create it."
help: "[path]\n\tDirectory where output data files are written in receiver. Default is '/'. \n\tIf path does not exist and fwrite enabled, it will try to create it at start of acquisition."
inherit_actions: STRING_COMMAND
actions:
GET:
Expand Down Expand Up @@ -985,7 +985,7 @@ findex:
input_types: [ uint64_t ]

fwrite:
help: "[0, 1]\n\tEnable or disable receiver file write. Default is 1."
help: "[0, 1]\n\tEnable or disable receiver file write. Default is 0."
inherit_actions: INTEGER_COMMAND_VEC_ID
actions:
GET:
Expand Down
5 changes: 3 additions & 2 deletions slsDetectorSoftware/generator/extended_commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3908,7 +3908,8 @@ fpath:
command_name: fpath
function_alias: fpath
help: "[path]\n\tDirectory where output data files are written in receiver. Default\
\ is '/'. \n\tIf path does not exist, it will try to create it."
\ is '/'. \n\tIf path does not exist and fwrite enabled, it will try to create\
\ it at start of acquisition."
infer_action: true
template: true
framecounter:
Expand Down Expand Up @@ -4101,7 +4102,7 @@ fwrite:
store_result_in_t: false
command_name: fwrite
function_alias: fwrite
help: "[0, 1]\n\tEnable or disable receiver file write. Default is 1."
help: "[0, 1]\n\tEnable or disable receiver file write. Default is 0."
infer_action: true
template: true
gaincaps:
Expand Down
5 changes: 3 additions & 2 deletions slsDetectorSoftware/include/sls/Detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,8 @@ class Detector {

Result<std::string> getFilePath(Positions pos = {}) const;

/** Default is "/"If path does not exist, it will try to create it */
/** Default is "/". If path does not exist and fwrite enabled, it will try
* to create it at start of acquisition. */
void setFilePath(const std::string &fpath, Positions pos = {});

Result<std::string> getFileNamePrefix(Positions pos = {}) const;
Expand All @@ -1025,7 +1026,7 @@ class Detector {

Result<bool> getFileWrite(Positions pos = {}) const;

/** default enabled */
/** default disabled */
void setFileWrite(bool value, Positions pos = {});

bool getMasterFileWrite() const;
Expand Down
4 changes: 2 additions & 2 deletions slsDetectorSoftware/src/Caller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5115,7 +5115,7 @@ std::string Caller::fpath(int action) {
os << "Command: fpath" << std::endl;
os << R"V0G0N([path]
Directory where output data files are written in receiver. Default is '/'.
If path does not exist, it will try to create it. )V0G0N"
If path does not exist and fwrite enabled, it will try to create it at start of acquisition. )V0G0N"
<< std::endl;
return os.str();
}
Expand Down Expand Up @@ -5372,7 +5372,7 @@ std::string Caller::fwrite(int action) {
if (action == slsDetectorDefs::HELP_ACTION) {
os << "Command: fwrite" << std::endl;
os << R"V0G0N([0, 1]
Enable or disable receiver file write. Default is 1. )V0G0N"
Enable or disable receiver file write. Default is 0. )V0G0N"
<< std::endl;
return os.str();
}
Expand Down
8 changes: 4 additions & 4 deletions slsReceiverSoftware/src/Implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,7 @@ void Implementation::setFileFormat(const fileFormat f) {
std::string Implementation::getFilePath() const { return filePath; }

void Implementation::setFilePath(const std::string &c) {
if (!c.empty()) {
mkdir_p(c); // throws if it can't create
filePath = c;
}
filePath = c;
LOG(logINFO) << "File path: " << filePath;
}

Expand Down Expand Up @@ -901,6 +898,9 @@ void Implementation::CreateUDPSockets() {

void Implementation::SetupWriter() {
try {
// check if folder exists and throw if it cant create
mkdir_p(filePath);
// create first files
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
std::ostringstream os;
os << filePath << "/" << fileName << "_d"
Expand Down
1 change: 1 addition & 0 deletions slsSupportLib/include/sls/ZmqSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class ZmqSocket {
/**
* Constructor for a server
* Creates socket, context and connects to server
* socket option: keep alive added
* @param portnumber port number
* @param ethip is the ip of the ethernet interface to stream zmq from
*/
Expand Down
26 changes: 26 additions & 0 deletions slsSupportLib/src/ZmqSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,32 @@ ZmqSocket::ZmqSocket(const uint16_t portnumber, const char *ethip)
sockfd.serverAddress = oss.str();
LOG(logDEBUG) << "zmq address: " << sockfd.serverAddress;

// Socket Options for keepalive
// enable TCP keepalive
int keepalive = 1;
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE, &keepalive, sizeof(keepalive))) {
PrintError();
throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE");
}
// set the number of keepalives before death
keepalive = 10;
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_CNT, &keepalive, sizeof(keepalive))) {
PrintError();
throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE_CNT");
}
// set the time before the first keepalive
keepalive = 60;
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_IDLE, &keepalive, sizeof(keepalive))) {
PrintError();
throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE_IDLE");
}
// set the interval between keepalives
keepalive = 1;
if (zmq_setsockopt(sockfd.socketDescriptor, ZMQ_TCP_KEEPALIVE_INTVL, &keepalive, sizeof(keepalive))) {
PrintError();
throw ZmqSocketError("Could set socket opt ZMQ_TCP_KEEPALIVE_INTVL");
}

// bind address
if (zmq_bind(sockfd.socketDescriptor, sockfd.serverAddress.c_str())) {
PrintError();
Expand Down

0 comments on commit 02185b1

Please sign in to comment.