mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-13 06:39:31 +01:00
replaced old logger
This commit is contained in:
@@ -1,18 +1,13 @@
|
||||
#include "logger.h"
|
||||
#include "logger2.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
int main() {
|
||||
|
||||
//compare old and new
|
||||
std::cout << "Compare output between old and new:\n";
|
||||
FILE_LOG(logINFO) << "Old message";
|
||||
LOG(logINFO) << "New message";
|
||||
FILE_LOG(logERROR) << "Old error";
|
||||
LOG(logERROR) << "New error";
|
||||
FILE_LOG(logWARNING) << "Old warning";
|
||||
LOG(logWARNING) << "New warning";
|
||||
LOG(logINFO) << "Some info message";
|
||||
LOG(logERROR) << "This is an error";
|
||||
LOG(logWARNING) << "While this is only a warning";
|
||||
|
||||
//Logging level can be configure at runtime
|
||||
std::cout << "\n\n";
|
||||
|
||||
@@ -35,7 +35,7 @@ qCloneWidget::~qCloneWidget() {
|
||||
void qCloneWidget::SetupWidgetWindow(QString title) {
|
||||
|
||||
std::string winTitle = std::string("Snapshot:") + std::to_string(id) +
|
||||
std::string(" - ") + NowTime();
|
||||
std::string(" - ") + sls::Logger::Timestamp();
|
||||
setWindowTitle(QString(winTitle.c_str()));
|
||||
|
||||
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
@@ -97,7 +97,7 @@ void qCloneWidget::SavePlot() {
|
||||
QString fName = filePath + QString('/') + fileName + QString("_clone") +
|
||||
QString("%1").arg(id) + QString("_acq") +
|
||||
QString("%1").arg(acqIndex) + QString(".png");
|
||||
FILE_LOG(logINFO) << "Saving Clone:" << fName.toAscii().constData();
|
||||
LOG(logINFO) << "Saving Clone:" << fName.toAscii().constData();
|
||||
// save
|
||||
QImage img(centralwidget->size().width(), centralwidget->size().height(),
|
||||
QImage::Format_RGB32);
|
||||
@@ -113,13 +113,13 @@ void qCloneWidget::SavePlot() {
|
||||
qDefs::Message(qDefs::INFORMATION,
|
||||
"The SnapShot has been successfully saved",
|
||||
"qCloneWidget::SavePlot");
|
||||
FILE_LOG(logINFO) << "The SnapShot has been successfully saved";
|
||||
LOG(logINFO) << "The SnapShot has been successfully saved";
|
||||
} else {
|
||||
qDefs::Message(
|
||||
qDefs::WARNING,
|
||||
"Attempt to save snapshot failed.\n Formats: .png, .jpg, .xpm.",
|
||||
"qCloneWidget::SavePlot");
|
||||
FILE_LOG(logWARNING) << "Attempt to save snapshot failed";
|
||||
LOG(logWARNING) << "Attempt to save snapshot failed";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void qDacWidget::SetDetectorIndex(int id) {
|
||||
}
|
||||
|
||||
void qDacWidget::GetDac() {
|
||||
FILE_LOG(logDEBUG) << "Getting Dac " << index;
|
||||
LOG(logDEBUG) << "Getting Dac " << index;
|
||||
|
||||
disconnect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
|
||||
try {
|
||||
@@ -56,7 +56,7 @@ void qDacWidget::GetDac() {
|
||||
|
||||
void qDacWidget::SetDac() {
|
||||
int val = (int)spinDac->value();
|
||||
FILE_LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data()
|
||||
LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data()
|
||||
<< " : " << val;
|
||||
|
||||
try {
|
||||
@@ -70,7 +70,7 @@ void qDacWidget::SetDac() {
|
||||
}
|
||||
|
||||
void qDacWidget::GetAdc() {
|
||||
FILE_LOG(logDEBUG) << "Getting ADC " << index;
|
||||
LOG(logDEBUG) << "Getting ADC " << index;
|
||||
|
||||
try {
|
||||
auto retval = det->getTemperature(index, {detectorIndex}).squash(-1);
|
||||
|
||||
@@ -57,7 +57,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
case 'f':
|
||||
fname = optarg;
|
||||
FILE_LOG(logDEBUG)
|
||||
LOG(logDEBUG)
|
||||
<< long_options[option_index].name << " " << optarg;
|
||||
break;
|
||||
|
||||
@@ -71,7 +71,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
case 'v':
|
||||
tempval = APIGUI;
|
||||
FILE_LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
|
||||
LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
|
||||
<< std::hex << tempval << ")";
|
||||
return 0;
|
||||
|
||||
@@ -87,7 +87,7 @@ int main(int argc, char **argv) {
|
||||
"i. Default: 0. Required \n" +
|
||||
"\t only when more than one multi "
|
||||
"detector object is needed.\n\n";
|
||||
FILE_LOG(logERROR) << help_message;
|
||||
LOG(logERROR) << help_message;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ void qDetectorMain::SetUpWidgetWindow() {
|
||||
|
||||
// plot setup
|
||||
plot = new qDrawPlot(dockWidgetPlot, det.get());
|
||||
FILE_LOG(logDEBUG) << "DockPlot ready";
|
||||
LOG(logDEBUG) << "DockPlot ready";
|
||||
dockWidgetPlot->setWidget(plot);
|
||||
|
||||
// tabs setup
|
||||
@@ -185,7 +185,7 @@ void qDetectorMain::SetUpWidgetWindow() {
|
||||
|
||||
// mode setup - to set up the tabs initially as disabled, not in form so
|
||||
// done here
|
||||
FILE_LOG(logINFO)
|
||||
LOG(logINFO)
|
||||
<< "Dockable Mode: 0, Debug Mode: 0, Expert Mode: 0, Developer Mode: "
|
||||
<< isDeveloper;
|
||||
tabs->setTabEnabled(DEBUGGING, false);
|
||||
@@ -246,7 +246,7 @@ void qDetectorMain::SetUpDetector(const std::string& config_file, int multiID) {
|
||||
<< sls::ToString(det->getDetectorType().squash()) << " - "
|
||||
<< det->getHostname();
|
||||
std::string title = os.str();
|
||||
FILE_LOG(logINFO) << title;
|
||||
LOG(logINFO) << title;
|
||||
setWindowTitle(QString(title.c_str()));
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ void qDetectorMain::Initialization() {
|
||||
|
||||
void qDetectorMain::LoadConfigFile(const std::string& config_file) {
|
||||
|
||||
FILE_LOG(logINFO) << "Loading config file at start up:" << config_file;
|
||||
LOG(logINFO) << "Loading config file at start up:" << config_file;
|
||||
|
||||
struct stat st_buf;
|
||||
QString file = QString(config_file.c_str());
|
||||
@@ -299,7 +299,7 @@ void qDetectorMain::LoadConfigFile(const std::string& config_file) {
|
||||
"following file does not exist:</nobr><br><nobr>") +
|
||||
config_file,
|
||||
"qDetectorMain::LoadConfigFile");
|
||||
FILE_LOG(logWARNING) << "Config file does not exist";
|
||||
LOG(logWARNING) << "Config file does not exist";
|
||||
}
|
||||
// not a file
|
||||
else if (!S_ISREG(st_buf.st_mode)) {
|
||||
@@ -310,7 +310,7 @@ void qDetectorMain::LoadConfigFile(const std::string& config_file) {
|
||||
"file is not a recognized file format:</nobr><br><nobr>") +
|
||||
config_file,
|
||||
"qDetectorMain::LoadConfigFile");
|
||||
FILE_LOG(logWARNING) << "File not recognized";
|
||||
LOG(logWARNING) << "File not recognized";
|
||||
} else {
|
||||
try {
|
||||
det->loadConfig(config_file);
|
||||
@@ -327,7 +327,7 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
if (action == actionDebug) {
|
||||
enable = actionDebug->isChecked();
|
||||
tabs->setTabEnabled(DEBUGGING, enable);
|
||||
FILE_LOG(logINFO) << "Debug Mode: " << qDefs::stringEnable(enable);
|
||||
LOG(logINFO) << "Debug Mode: " << qDefs::stringEnable(enable);
|
||||
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
tabs->setTabEnabled(ADVANCED, enable);
|
||||
actionLoadTrimbits->setVisible(enable &&
|
||||
detType == slsDetectorDefs::EIGER);
|
||||
FILE_LOG(logINFO) << "Expert Mode: " << qDefs::stringEnable(enable);
|
||||
LOG(logINFO) << "Expert Mode: " << qDefs::stringEnable(enable);
|
||||
}
|
||||
|
||||
// Set DockableMode
|
||||
@@ -350,7 +350,7 @@ void qDetectorMain::EnableModes(QAction *action) {
|
||||
dockWidgetPlot->setFloating(false);
|
||||
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
||||
}
|
||||
FILE_LOG(logINFO) << "Dockable Mode: " << qDefs::stringEnable(enable);
|
||||
LOG(logINFO) << "Dockable Mode: " << qDefs::stringEnable(enable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
|
||||
try {
|
||||
|
||||
if (action == actionLoadConfiguration) {
|
||||
FILE_LOG(logDEBUG) << "Loading Configuration";
|
||||
LOG(logDEBUG) << "Loading Configuration";
|
||||
QString fName = QString(det->getFilePath().squash("/tmp/").c_str());
|
||||
fName = QFileDialog::getOpenFileName(
|
||||
this, tr("Load Detector Configuration"), fName,
|
||||
@@ -372,13 +372,13 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
|
||||
"The Configuration Parameters have been "
|
||||
"configured successfully.",
|
||||
"qDetectorMain::ExecuteUtilities");
|
||||
FILE_LOG(logINFO)
|
||||
LOG(logINFO)
|
||||
<< "Configuration Parameters loaded successfully";
|
||||
}
|
||||
}
|
||||
|
||||
else if (action == actionLoadParameters) {
|
||||
FILE_LOG(logDEBUG) << "Loading Parameters";
|
||||
LOG(logDEBUG) << "Loading Parameters";
|
||||
QString fName = QString(det->getFilePath().squash("/tmp/").c_str());
|
||||
fName = QFileDialog::getOpenFileName(
|
||||
this, tr("Load Measurement Setup"), fName,
|
||||
@@ -391,14 +391,14 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
|
||||
"The Detector Parameters have been "
|
||||
"configured successfully.",
|
||||
"qDetectorMain::ExecuteUtilities");
|
||||
FILE_LOG(logINFO) << "Parameters loaded successfully";
|
||||
LOG(logINFO) << "Parameters loaded successfully";
|
||||
}
|
||||
}
|
||||
|
||||
else if (action == actionLoadTrimbits) {
|
||||
QString fName =
|
||||
QString((det->getSettingsPath().squash("/tmp/")).c_str());
|
||||
FILE_LOG(logDEBUG) << "Loading Trimbits";
|
||||
LOG(logDEBUG) << "Loading Trimbits";
|
||||
// so that even nonexisting files can be selected
|
||||
QFileDialog *fileDialog = new QFileDialog(
|
||||
this, tr("Load Detector Trimbits"), fName,
|
||||
@@ -413,7 +413,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
|
||||
qDefs::Message(qDefs::INFORMATION,
|
||||
"The Trimbits have been loaded successfully.",
|
||||
"qDetectorMain::ExecuteUtilities");
|
||||
FILE_LOG(logINFO) << "Trimbits loaded successfully";
|
||||
LOG(logINFO) << "Trimbits loaded successfully";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -437,7 +437,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
|
||||
|
||||
void qDetectorMain::ExecuteHelp(QAction *action) {
|
||||
if (action == actionAbout) {
|
||||
FILE_LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, "
|
||||
LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, "
|
||||
"Gotthard, Gotthard2 and Moench detectors";
|
||||
|
||||
std::string guiVersion = std::to_string(APIGUI);
|
||||
@@ -472,7 +472,7 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
|
||||
}
|
||||
|
||||
void qDetectorMain::Refresh(int index) {
|
||||
FILE_LOG(logDEBUG) << "Refresh Main Tab";
|
||||
LOG(logDEBUG) << "Refresh Main Tab";
|
||||
|
||||
if (!tabs->isTabEnabled(index))
|
||||
tabs->setCurrentIndex((index++) < (tabs->count() - 1) ? index
|
||||
@@ -511,14 +511,14 @@ void qDetectorMain::Refresh(int index) {
|
||||
}
|
||||
|
||||
void qDetectorMain::ResizeMainWindow(bool b) {
|
||||
FILE_LOG(logDEBUG1) << "Resizing Main Window: height:" << height();
|
||||
LOG(logDEBUG1) << "Resizing Main Window: height:" << height();
|
||||
|
||||
// undocked from the main window
|
||||
if (b) {
|
||||
// sets the main window height to a smaller maximum to get rid of space
|
||||
setMaximumHeight(height() - heightPlotWindow - 9);
|
||||
dockWidgetPlot->setMinimumHeight(0);
|
||||
FILE_LOG(logINFO) << "Undocking from main window";
|
||||
LOG(logINFO) << "Undocking from main window";
|
||||
} else {
|
||||
setMaximumHeight(QWIDGETSIZE_MAX);
|
||||
// the minimum for plot will be set when the widget gets resized
|
||||
@@ -546,7 +546,7 @@ void qDetectorMain::resizeEvent(QResizeEvent *event) {
|
||||
}
|
||||
|
||||
void qDetectorMain::EnableTabs(bool enable) {
|
||||
FILE_LOG(logDEBUG) << "qDetectorMain::EnableTabs";
|
||||
LOG(logDEBUG) << "qDetectorMain::EnableTabs";
|
||||
|
||||
// normal tabs
|
||||
tabs->setTabEnabled(DATAOUTPUT, enable);
|
||||
|
||||
@@ -16,7 +16,7 @@ qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector)
|
||||
: QWidget(parent), det(detector) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logINFO) << "Plots ready";
|
||||
LOG(logINFO) << "Plots ready";
|
||||
}
|
||||
|
||||
qDrawPlot::~qDrawPlot() {
|
||||
@@ -50,7 +50,7 @@ void qDrawPlot::SetupWidgetWindow() {
|
||||
pixelMask = ((1 << 14) - 1);
|
||||
gainMask = (3 << 14);
|
||||
gainOffset = 14;
|
||||
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
|
||||
LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
|
||||
<< ", Gain Mask:" << gainMask
|
||||
<< ", Gain Offset:" << std::dec << gainOffset;
|
||||
break;
|
||||
@@ -58,7 +58,7 @@ void qDrawPlot::SetupWidgetWindow() {
|
||||
pixelMask = ((1 << 12) - 1);
|
||||
gainMask = (3 << 12);
|
||||
gainOffset = 12;
|
||||
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
|
||||
LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
|
||||
<< ", Gain Mask:" << gainMask
|
||||
<< ", Gain Offset:" << std::dec << gainOffset;
|
||||
break;
|
||||
@@ -113,8 +113,8 @@ void qDrawPlot::SetupPlots() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
FILE_LOG(logINFO) << "nPixelsX:" << nPixelsX;
|
||||
FILE_LOG(logINFO) << "nPixelsY:" << nPixelsY;
|
||||
LOG(logINFO) << "nPixelsX:" << nPixelsX;
|
||||
LOG(logINFO) << "nPixelsY:" << nPixelsY;
|
||||
|
||||
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
widgetStatistics->hide();
|
||||
@@ -287,12 +287,12 @@ void qDrawPlot::Select1dPlot(bool enable) {
|
||||
}
|
||||
|
||||
void qDrawPlot::SetPlotTitlePrefix(QString title) {
|
||||
FILE_LOG(logINFO) << "Setting Title to " << title.toAscii().constData();
|
||||
LOG(logINFO) << "Setting Title to " << title.toAscii().constData();
|
||||
plotTitlePrefix = title;
|
||||
}
|
||||
|
||||
void qDrawPlot::SetXAxisTitle(QString title) {
|
||||
FILE_LOG(logINFO) << "Setting X Axis Title to "
|
||||
LOG(logINFO) << "Setting X Axis Title to "
|
||||
<< title.toAscii().constData();
|
||||
if (is1d) {
|
||||
xTitle1d = title;
|
||||
@@ -302,7 +302,7 @@ void qDrawPlot::SetXAxisTitle(QString title) {
|
||||
}
|
||||
|
||||
void qDrawPlot::SetYAxisTitle(QString title) {
|
||||
FILE_LOG(logINFO) << "Setting Y Axis Title to "
|
||||
LOG(logINFO) << "Setting Y Axis Title to "
|
||||
<< title.toAscii().constData();
|
||||
if (is1d) {
|
||||
yTitle1d = title;
|
||||
@@ -312,19 +312,19 @@ void qDrawPlot::SetYAxisTitle(QString title) {
|
||||
}
|
||||
|
||||
void qDrawPlot::SetZAxisTitle(QString title) {
|
||||
FILE_LOG(logINFO) << "Setting Z Axis Title to "
|
||||
LOG(logINFO) << "Setting Z Axis Title to "
|
||||
<< title.toAscii().constData();
|
||||
zTitle2d = title;
|
||||
}
|
||||
|
||||
void qDrawPlot::SetXYRangeChanged(bool disable, double *xy, bool *isXY) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "XY Range has changed";
|
||||
LOG(logINFO) << "XY Range has changed";
|
||||
xyRangeChanged = true;
|
||||
std::copy(xy, xy + 4, xyRange);
|
||||
std::copy(isXY, isXY + 4, isXYRange);
|
||||
|
||||
FILE_LOG(logDEBUG) << "Setting Disable zoom to " << std::boolalpha
|
||||
LOG(logDEBUG) << "Setting Disable zoom to " << std::boolalpha
|
||||
<< disable << std::noboolalpha;
|
||||
disableZoom = disable;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ double qDrawPlot::GetYMaximum() {
|
||||
}
|
||||
|
||||
void qDrawPlot::SetDataCallBack(bool enable) {
|
||||
FILE_LOG(logINFO) << "Setting data call back to " << std::boolalpha
|
||||
LOG(logINFO) << "Setting data call back to " << std::boolalpha
|
||||
<< enable << std::noboolalpha;
|
||||
if (enable) {
|
||||
isPlot = true;
|
||||
@@ -377,7 +377,7 @@ void qDrawPlot::SetDataCallBack(bool enable) {
|
||||
}
|
||||
|
||||
void qDrawPlot::SetBinary(bool enable, int from, int to) {
|
||||
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling")
|
||||
LOG(logINFO) << (enable ? "Enabling" : "Disabling")
|
||||
<< " Binary output from " << from << " to " << to;
|
||||
binaryFrom = from;
|
||||
binaryTo = to;
|
||||
@@ -385,13 +385,13 @@ void qDrawPlot::SetBinary(bool enable, int from, int to) {
|
||||
}
|
||||
|
||||
void qDrawPlot::SetPersistency(int val) {
|
||||
FILE_LOG(logINFO) << "Setting Persistency to " << val;
|
||||
LOG(logINFO) << "Setting Persistency to " << val;
|
||||
persistency = val;
|
||||
}
|
||||
|
||||
void qDrawPlot::SetLines(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Lines to " << std::boolalpha << enable
|
||||
LOG(logINFO) << "Setting Lines to " << std::boolalpha << enable
|
||||
<< std::noboolalpha;
|
||||
isLines = enable;
|
||||
for (int i = 0; i < nHists; ++i) {
|
||||
@@ -402,7 +402,7 @@ void qDrawPlot::SetLines(bool enable) {
|
||||
|
||||
void qDrawPlot::SetMarkers(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Markers to " << std::boolalpha << enable
|
||||
LOG(logINFO) << "Setting Markers to " << std::boolalpha << enable
|
||||
<< std::noboolalpha;
|
||||
isMarkers = enable;
|
||||
for (int i = 0; i < nHists; ++i) {
|
||||
@@ -413,76 +413,76 @@ void qDrawPlot::SetMarkers(bool enable) {
|
||||
|
||||
void qDrawPlot::Set1dLogY(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Log Y to " << std::boolalpha << enable
|
||||
LOG(logINFO) << "Setting Log Y to " << std::boolalpha << enable
|
||||
<< std::noboolalpha;
|
||||
plot1d->SetLogY(enable);
|
||||
}
|
||||
|
||||
void qDrawPlot::SetInterpolate(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Interpolate to " << std::boolalpha << enable
|
||||
LOG(logINFO) << "Setting Interpolate to " << std::boolalpha << enable
|
||||
<< std::noboolalpha;
|
||||
plot2d->SetInterpolate(enable);
|
||||
}
|
||||
|
||||
void qDrawPlot::SetContour(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Countour to " << std::boolalpha << enable
|
||||
LOG(logINFO) << "Setting Countour to " << std::boolalpha << enable
|
||||
<< std::noboolalpha;
|
||||
plot2d->SetContour(enable);
|
||||
}
|
||||
|
||||
void qDrawPlot::SetLogz(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Log Z to " << std::boolalpha << enable
|
||||
LOG(logINFO) << "Setting Log Z to " << std::boolalpha << enable
|
||||
<< std::noboolalpha;
|
||||
plot2d->SetLogz(enable, isZRange[0], isZRange[1], zRange[0], zRange[1]);
|
||||
}
|
||||
|
||||
void qDrawPlot::SetPedestal(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Pedestal";
|
||||
LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Pedestal";
|
||||
isPedestal = enable;
|
||||
resetPedestal = true;
|
||||
}
|
||||
|
||||
void qDrawPlot::RecalculatePedestal() {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logDEBUG) << "Recalculating Pedestal";
|
||||
LOG(logDEBUG) << "Recalculating Pedestal";
|
||||
resetPedestal = true;
|
||||
}
|
||||
|
||||
void qDrawPlot::SetAccumulate(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Accumulation";
|
||||
LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Accumulation";
|
||||
isAccumulate = enable;
|
||||
resetAccumulate = true;
|
||||
}
|
||||
|
||||
void qDrawPlot::ResetAccumulate() {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logDEBUG) << "Resetting Accumulation";
|
||||
LOG(logDEBUG) << "Resetting Accumulation";
|
||||
resetAccumulate = true;
|
||||
}
|
||||
|
||||
void qDrawPlot::DisplayStatistics(bool enable) {
|
||||
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling")
|
||||
LOG(logINFO) << (enable ? "Enabling" : "Disabling")
|
||||
<< " Statistics Display";
|
||||
displayStatistics = enable;
|
||||
}
|
||||
|
||||
void qDrawPlot::SetNumDiscardBits(int value) {
|
||||
FILE_LOG(logINFO) << "Setting number of bits to discard: " << value;
|
||||
LOG(logINFO) << "Setting number of bits to discard: " << value;
|
||||
numDiscardBits = value;
|
||||
}
|
||||
|
||||
void qDrawPlot::EnableGainPlot(bool enable) {
|
||||
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Gain Plot";
|
||||
LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Gain Plot";
|
||||
hasGainData = enable;
|
||||
}
|
||||
|
||||
void qDrawPlot::SetSaveFileName(QString val) {
|
||||
FILE_LOG(logDEBUG) << "Setting Clone/Save File Name to "
|
||||
LOG(logDEBUG) << "Setting Clone/Save File Name to "
|
||||
<< val.toAscii().constData();
|
||||
fileSaveName = val;
|
||||
}
|
||||
@@ -496,7 +496,7 @@ void qDrawPlot::ClonePlot() {
|
||||
SlsQt2DPlot *clonegainplot2D = nullptr;
|
||||
|
||||
if (is1d) {
|
||||
FILE_LOG(logDEBUG) << "Cloning 1D Image";
|
||||
LOG(logDEBUG) << "Cloning 1D Image";
|
||||
cloneplot1D = new SlsQt1DPlot();
|
||||
cloneplot1D->setFont(
|
||||
QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
@@ -538,7 +538,7 @@ void qDrawPlot::ClonePlot() {
|
||||
h->Attach(clonegainplot1D);
|
||||
}
|
||||
} else {
|
||||
FILE_LOG(logDEBUG) << "Cloning 2D Image";
|
||||
LOG(logDEBUG) << "Cloning 2D Image";
|
||||
cloneplot2D = new SlsQt2DPlot();
|
||||
cloneplot2D->setFont(
|
||||
QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
@@ -618,7 +618,7 @@ void qDrawPlot::SavePlot() {
|
||||
}
|
||||
|
||||
void qDrawPlot::GetStatistics(double &min, double &max, double &sum) {
|
||||
FILE_LOG(logDEBUG) << "Calculating Statistics";
|
||||
LOG(logDEBUG) << "Calculating Statistics";
|
||||
double *array = data2d;
|
||||
int size = nPixelsX * nPixelsY;
|
||||
if (is1d) {
|
||||
@@ -645,7 +645,7 @@ void qDrawPlot::DetachHists() {
|
||||
}
|
||||
|
||||
void qDrawPlot::StartAcquisition() {
|
||||
FILE_LOG(logDEBUG) << "Starting Acquisition in qDrawPlot";
|
||||
LOG(logDEBUG) << "Starting Acquisition in qDrawPlot";
|
||||
progress = 0;
|
||||
currentFrame = 0;
|
||||
boxPlot->setTitle("Old Plot");
|
||||
@@ -669,22 +669,22 @@ void qDrawPlot::StartAcquisition() {
|
||||
}
|
||||
|
||||
emit StartAcquireSignal();
|
||||
FILE_LOG(logDEBUG) << "End of Starting Acquisition in qDrawPlot";
|
||||
LOG(logDEBUG) << "End of Starting Acquisition in qDrawPlot";
|
||||
}
|
||||
|
||||
void qDrawPlot::AcquireThread() {
|
||||
FILE_LOG(logDEBUG) << "Acquire Thread";
|
||||
LOG(logDEBUG) << "Acquire Thread";
|
||||
std::string mess;
|
||||
try {
|
||||
det->acquire();
|
||||
} catch (const std::exception &e) {
|
||||
mess = std::string(e.what());
|
||||
}
|
||||
FILE_LOG(logINFO) << "Acquisition Finished";
|
||||
LOG(logINFO) << "Acquisition Finished";
|
||||
// exception in acquire will not call acquisition finished call back, so
|
||||
// handle it
|
||||
if (!mess.empty()) {
|
||||
FILE_LOG(logERROR) << "Acquisition Finished with an exception: "
|
||||
LOG(logERROR) << "Acquisition Finished with an exception: "
|
||||
<< mess;
|
||||
qDefs::ExceptionMessage("Acquire unsuccessful.", mess,
|
||||
"qDrawPlot::AcquireFinished");
|
||||
@@ -699,7 +699,7 @@ void qDrawPlot::AcquireThread() {
|
||||
CATCH_DISPLAY("Could not stop receiver.", "qDrawPlot::AcquireFinished");
|
||||
emit AbortSignal();
|
||||
}
|
||||
FILE_LOG(logDEBUG) << "End of Acquisition Finished";
|
||||
LOG(logDEBUG) << "End of Acquisition Finished";
|
||||
}
|
||||
|
||||
void qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress,
|
||||
@@ -707,13 +707,13 @@ void qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress,
|
||||
void *this_pointer) {
|
||||
((qDrawPlot *)this_pointer)
|
||||
->AcquisitionFinished(currentProgress, detectorStatus);
|
||||
FILE_LOG(logDEBUG) << "Acquisition Finished Call back successful";
|
||||
LOG(logDEBUG) << "Acquisition Finished Call back successful";
|
||||
}
|
||||
|
||||
void qDrawPlot::GetDataCallBack(detectorData *data, uint64_t frameIndex,
|
||||
uint32_t subFrameIndex, void *this_pointer) {
|
||||
((qDrawPlot *)this_pointer)->GetData(data, frameIndex, subFrameIndex);
|
||||
FILE_LOG(logDEBUG) << "Get Data Call back successful";
|
||||
LOG(logDEBUG) << "Get Data Call back successful";
|
||||
}
|
||||
|
||||
void qDrawPlot::AcquisitionFinished(double currentProgress,
|
||||
@@ -728,9 +728,9 @@ void qDrawPlot::AcquisitionFinished(double currentProgress,
|
||||
"Current Detector Status: ") +
|
||||
status + std::string(".</nobr>"),
|
||||
"qDrawPlot::AcquisitionFinished");
|
||||
FILE_LOG(logERROR) << "Acquisition finished [Status: ERROR]";
|
||||
LOG(logERROR) << "Acquisition finished [Status: ERROR]";
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Acquisition finished [ Status:" << status
|
||||
LOG(logINFO) << "Acquisition finished [ Status:" << status
|
||||
<< ", Progress: " << currentProgress << " ]";
|
||||
}
|
||||
emit AcquireFinishedSignal();
|
||||
@@ -739,7 +739,7 @@ void qDrawPlot::AcquisitionFinished(double currentProgress,
|
||||
void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
||||
uint32_t subFrameIndex) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logDEBUG) << "* GetData Callback *" << std::endl
|
||||
LOG(logDEBUG) << "* GetData Callback *" << std::endl
|
||||
<< " frame index: " << frameIndex << std::endl
|
||||
<< " sub frame index: "
|
||||
<< (((int)subFrameIndex == -1) ? (int)-1 : subFrameIndex)
|
||||
@@ -758,7 +758,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
||||
progress = (int)data->progressIndex;
|
||||
currentAcqIndex = data->fileIndex;
|
||||
currentFrame = frameIndex;
|
||||
FILE_LOG(logDEBUG) << "[ Progress:" << progress
|
||||
LOG(logDEBUG) << "[ Progress:" << progress
|
||||
<< ", Frame:" << currentFrame << " ]";
|
||||
|
||||
// 2d (only image, not gain data, not pedestalvals),
|
||||
@@ -767,7 +767,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
||||
static_cast<int>(nPixelsY) != data->ny)) {
|
||||
nPixelsX = data->nx;
|
||||
nPixelsY = data->ny;
|
||||
FILE_LOG(logINFO) << "Change in Detector Shape:\n\tnPixelsX:"
|
||||
LOG(logINFO) << "Change in Detector Shape:\n\tnPixelsX:"
|
||||
<< nPixelsX << " nPixelsY:" << nPixelsY;
|
||||
|
||||
delete[] data2d;
|
||||
@@ -819,7 +819,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
||||
}
|
||||
// calculate the pedestal value
|
||||
if (pedestalCount == NUM_PEDESTAL_FRAMES) {
|
||||
FILE_LOG(logINFO) << "Pedestal Calculated after "
|
||||
LOG(logINFO) << "Pedestal Calculated after "
|
||||
<< NUM_PEDESTAL_FRAMES << " frames";
|
||||
for (unsigned int px = 0; px < nPixels; ++px)
|
||||
tempPedestalVals[px] =
|
||||
@@ -836,7 +836,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
|
||||
}
|
||||
delete[] rawData;
|
||||
|
||||
FILE_LOG(logDEBUG) << "End of Get Data";
|
||||
LOG(logDEBUG) << "End of Get Data";
|
||||
emit UpdateSignal();
|
||||
}
|
||||
|
||||
@@ -1112,7 +1112,7 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
|
||||
|
||||
void qDrawPlot::UpdatePlot() {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logDEBUG) << "Update Plot";
|
||||
LOG(logDEBUG) << "Update Plot";
|
||||
|
||||
boxPlot->setTitle(plotTitle);
|
||||
if (is1d) {
|
||||
@@ -1132,5 +1132,5 @@ void qDrawPlot::UpdatePlot() {
|
||||
widgetStatistics->hide();
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "End of Update Plot";
|
||||
LOG(logDEBUG) << "End of Update Plot";
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ qTabAdvanced::qTabAdvanced(QWidget *parent, sls::Detector *detector,
|
||||
: QWidget(parent), det(detector), plot(p) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Advanced ready";
|
||||
LOG(logDEBUG) << "Advanced ready";
|
||||
}
|
||||
|
||||
qTabAdvanced::~qTabAdvanced() {}
|
||||
@@ -119,7 +119,7 @@ void qTabAdvanced::Initialization() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::PopulateDetectors() {
|
||||
FILE_LOG(logDEBUG) << "Populating detectors";
|
||||
LOG(logDEBUG) << "Populating detectors";
|
||||
disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetDetector()));
|
||||
disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this,
|
||||
@@ -142,7 +142,7 @@ void qTabAdvanced::PopulateDetectors() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetControlPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting control port ";
|
||||
LOG(logDEBUG) << "Getting control port ";
|
||||
disconnect(spinControlPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetControlPort(int)));
|
||||
|
||||
@@ -158,7 +158,7 @@ void qTabAdvanced::GetControlPort() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetStopPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting stop port";
|
||||
LOG(logDEBUG) << "Getting stop port";
|
||||
disconnect(spinStopPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetStopPort(int)));
|
||||
|
||||
@@ -174,7 +174,7 @@ void qTabAdvanced::GetStopPort() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetDetectorUDPIP() {
|
||||
FILE_LOG(logDEBUG) << "Getting Detector UDP IP";
|
||||
LOG(logDEBUG) << "Getting Detector UDP IP";
|
||||
disconnect(dispDetectorUDPIP, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetDetectorUDPIP()));
|
||||
|
||||
@@ -191,7 +191,7 @@ void qTabAdvanced::GetDetectorUDPIP() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetDetectorUDPMAC() {
|
||||
FILE_LOG(logDEBUG) << "Getting Detector UDP MAC";
|
||||
LOG(logDEBUG) << "Getting Detector UDP MAC";
|
||||
disconnect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetDetectorUDPMAC()));
|
||||
|
||||
@@ -208,7 +208,7 @@ void qTabAdvanced::GetDetectorUDPMAC() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetCltZMQPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting Client ZMQ port";
|
||||
LOG(logDEBUG) << "Getting Client ZMQ port";
|
||||
disconnect(spinZMQPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetCltZMQPort(int)));
|
||||
|
||||
@@ -224,7 +224,7 @@ void qTabAdvanced::GetCltZMQPort() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetCltZMQIP() {
|
||||
FILE_LOG(logDEBUG) << "Getting Client ZMQ IP";
|
||||
LOG(logDEBUG) << "Getting Client ZMQ IP";
|
||||
disconnect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP()));
|
||||
|
||||
try {
|
||||
@@ -238,7 +238,7 @@ void qTabAdvanced::GetCltZMQIP() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrHostname() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver Hostname";
|
||||
LOG(logDEBUG) << "Getting Receiver Hostname";
|
||||
disconnect(dispRxrHostname, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRxrHostname()));
|
||||
|
||||
@@ -254,7 +254,7 @@ void qTabAdvanced::GetRxrHostname() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrTCPPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver TCP port";
|
||||
LOG(logDEBUG) << "Getting Receiver TCP port";
|
||||
disconnect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetRxrTCPPort(int)));
|
||||
|
||||
@@ -270,7 +270,7 @@ void qTabAdvanced::GetRxrTCPPort() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrUDPPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver UDP port";
|
||||
LOG(logDEBUG) << "Getting Receiver UDP port";
|
||||
disconnect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetRxrUDPPort(int)));
|
||||
|
||||
@@ -287,7 +287,7 @@ void qTabAdvanced::GetRxrUDPPort() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrUDPIP() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver UDP IP";
|
||||
LOG(logDEBUG) << "Getting Receiver UDP IP";
|
||||
disconnect(dispRxrUDPIP, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRxrUDPIP()));
|
||||
|
||||
@@ -302,7 +302,7 @@ void qTabAdvanced::GetRxrUDPIP() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrUDPMAC() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver UDP MAC";
|
||||
LOG(logDEBUG) << "Getting Receiver UDP MAC";
|
||||
disconnect(dispRxrUDPMAC, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRxrUDPMAC()));
|
||||
|
||||
@@ -319,7 +319,7 @@ void qTabAdvanced::GetRxrUDPMAC() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrZMQPort() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver ZMQ port";
|
||||
LOG(logDEBUG) << "Getting Receiver ZMQ port";
|
||||
disconnect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetRxrZMQPort(int)));
|
||||
|
||||
@@ -335,7 +335,7 @@ void qTabAdvanced::GetRxrZMQPort() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetRxrZMQIP() {
|
||||
FILE_LOG(logDEBUG) << "Getting Receiver ZMQ IP";
|
||||
LOG(logDEBUG) << "Getting Receiver ZMQ IP";
|
||||
disconnect(dispRxrZMQIP, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetRxrZMQIP()));
|
||||
|
||||
@@ -349,7 +349,7 @@ void qTabAdvanced::GetRxrZMQIP() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetDetector() {
|
||||
FILE_LOG(logDEBUG) << "Set Detector: "
|
||||
LOG(logDEBUG) << "Set Detector: "
|
||||
<< comboDetector->currentText().toAscii().data();
|
||||
|
||||
GetControlPort();
|
||||
@@ -366,11 +366,11 @@ void qTabAdvanced::SetDetector() {
|
||||
GetRxrZMQPort();
|
||||
GetRxrZMQIP();
|
||||
|
||||
FILE_LOG(logDEBUG) << det->printRxConfiguration();
|
||||
LOG(logDEBUG) << det->printRxConfiguration();
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetControlPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Control Port:" << port;
|
||||
LOG(logINFO) << "Setting Control Port:" << port;
|
||||
try {
|
||||
det->setControlPort(port, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -379,7 +379,7 @@ void qTabAdvanced::SetControlPort(int port) {
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetStopPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Stop Port:" << port;
|
||||
LOG(logINFO) << "Setting Stop Port:" << port;
|
||||
try {
|
||||
det->setStopPort(port, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -389,7 +389,7 @@ void qTabAdvanced::SetStopPort(int port) {
|
||||
|
||||
void qTabAdvanced::SetDetectorUDPIP() {
|
||||
std::string s = dispDetectorUDPIP->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s;
|
||||
LOG(logINFO) << "Setting Detector UDP IP:" << s;
|
||||
try {
|
||||
det->setSourceUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -400,7 +400,7 @@ void qTabAdvanced::SetDetectorUDPIP() {
|
||||
|
||||
void qTabAdvanced::SetDetectorUDPMAC() {
|
||||
std::string s = dispDetectorUDPMAC->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s;
|
||||
LOG(logINFO) << "Setting Detector UDP MAC:" << s;
|
||||
try {
|
||||
det->setSourceUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -410,7 +410,7 @@ void qTabAdvanced::SetDetectorUDPMAC() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetCltZMQPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port;
|
||||
LOG(logINFO) << "Setting Client ZMQ Port:" << port;
|
||||
try {
|
||||
det->setClientZmqPort(port, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -421,7 +421,7 @@ void qTabAdvanced::SetCltZMQPort(int port) {
|
||||
|
||||
void qTabAdvanced::SetCltZMQIP() {
|
||||
std::string s = dispZMQIP->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s;
|
||||
LOG(logINFO) << "Setting Client ZMQ IP:" << s;
|
||||
try {
|
||||
det->setClientZmqIp(sls::IpAddr{s}, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -431,7 +431,7 @@ void qTabAdvanced::SetCltZMQIP() {
|
||||
|
||||
void qTabAdvanced::SetRxrHostname() {
|
||||
std::string s = dispZMQIP->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s;
|
||||
LOG(logINFO) << "Setting Receiver Hostname:" << s;
|
||||
try {
|
||||
det->setRxHostname(s, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -443,7 +443,7 @@ void qTabAdvanced::SetRxrHostname() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetRxrTCPPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port;
|
||||
LOG(logINFO) << "Setting Receiver TCP Port:" << port;
|
||||
try {
|
||||
det->setRxPort(port, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -453,7 +453,7 @@ void qTabAdvanced::SetRxrTCPPort(int port) {
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetRxrUDPPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port;
|
||||
LOG(logINFO) << "Setting Receiver UDP Port:" << port;
|
||||
try {
|
||||
det->setRxPort(port, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -464,7 +464,7 @@ void qTabAdvanced::SetRxrUDPPort(int port) {
|
||||
|
||||
void qTabAdvanced::SetRxrUDPIP() {
|
||||
std::string s = dispRxrUDPIP->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s;
|
||||
LOG(logINFO) << "Setting Receiver UDP IP:" << s;
|
||||
try {
|
||||
det->setDestinationUDPIP(sls::IpAddr{s},
|
||||
{comboDetector->currentIndex()});
|
||||
@@ -475,7 +475,7 @@ void qTabAdvanced::SetRxrUDPIP() {
|
||||
|
||||
void qTabAdvanced::SetRxrUDPMAC() {
|
||||
std::string s = dispRxrUDPMAC->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
|
||||
LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
|
||||
try {
|
||||
det->setDestinationUDPMAC(sls::MacAddr{s},
|
||||
{comboDetector->currentIndex()});
|
||||
@@ -486,7 +486,7 @@ void qTabAdvanced::SetRxrUDPMAC() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetRxrZMQPort(int port) {
|
||||
FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port;
|
||||
LOG(logINFO) << "Setting Receiver ZMQ Port:" << port;
|
||||
try {
|
||||
det->setRxZmqPort(port, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -497,7 +497,7 @@ void qTabAdvanced::SetRxrZMQPort(int port) {
|
||||
|
||||
void qTabAdvanced::SetRxrZMQIP() {
|
||||
std::string s = dispRxrZMQIP->text().toAscii().constData();
|
||||
FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
|
||||
LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
|
||||
try {
|
||||
det->setRxZmqIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
|
||||
}
|
||||
@@ -506,7 +506,7 @@ void qTabAdvanced::SetRxrZMQIP() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetROI() {
|
||||
FILE_LOG(logDEBUG) << "Getting ROI";
|
||||
LOG(logDEBUG) << "Getting ROI";
|
||||
try {
|
||||
slsDetectorDefs::ROI roi =
|
||||
det->getROI({comboReadout->currentIndex()})[0];
|
||||
@@ -517,11 +517,11 @@ void qTabAdvanced::GetROI() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::ClearROI() {
|
||||
FILE_LOG(logINFO) << "Clearing ROI";
|
||||
LOG(logINFO) << "Clearing ROI";
|
||||
spinXmin->setValue(-1);
|
||||
spinXmax->setValue(-1);
|
||||
SetROI();
|
||||
FILE_LOG(logDEBUG) << "ROIs cleared";
|
||||
LOG(logDEBUG) << "ROIs cleared";
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetROI() {
|
||||
@@ -531,7 +531,7 @@ void qTabAdvanced::SetROI() {
|
||||
roi.xmax = spinXmax->value();
|
||||
|
||||
// set roi
|
||||
FILE_LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax
|
||||
LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax
|
||||
<< "]";
|
||||
try {
|
||||
det->setROI(roi, {comboReadout->currentIndex()});
|
||||
@@ -543,7 +543,7 @@ void qTabAdvanced::SetROI() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetAllTrimbits() {
|
||||
FILE_LOG(logDEBUG) << "Getting all trimbits value";
|
||||
LOG(logDEBUG) << "Getting all trimbits value";
|
||||
disconnect(spinSetAllTrimbits, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetAllTrimbits()));
|
||||
|
||||
@@ -559,7 +559,7 @@ void qTabAdvanced::GetAllTrimbits() {
|
||||
|
||||
void qTabAdvanced::SetAllTrimbits() {
|
||||
int value = spinSetAllTrimbits->value();
|
||||
FILE_LOG(logINFO) << "Setting all trimbits:" << value;
|
||||
LOG(logINFO) << "Setting all trimbits:" << value;
|
||||
|
||||
try {
|
||||
det->setAllTrimbits(value);
|
||||
@@ -569,7 +569,7 @@ void qTabAdvanced::SetAllTrimbits() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetNumStoragecells() {
|
||||
FILE_LOG(logDEBUG) << "Getting number of additional storage cells";
|
||||
LOG(logDEBUG) << "Getting number of additional storage cells";
|
||||
disconnect(spinNumStoragecells, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetNumStoragecells(int)));
|
||||
|
||||
@@ -586,7 +586,7 @@ void qTabAdvanced::GetNumStoragecells() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::SetNumStoragecells(int value) {
|
||||
FILE_LOG(logINFO) << "Setting number of additional stoarge cells: "
|
||||
LOG(logINFO) << "Setting number of additional stoarge cells: "
|
||||
<< value;
|
||||
try {
|
||||
det->setNumberOfAdditionalStorageCells(value);
|
||||
@@ -597,7 +597,7 @@ void qTabAdvanced::SetNumStoragecells(int value) {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetSubExposureTime() {
|
||||
FILE_LOG(logDEBUG) << "Getting sub exposure time";
|
||||
LOG(logDEBUG) << "Getting sub exposure time";
|
||||
disconnect(spinSubExpTime, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(SetSubExposureTime()));
|
||||
disconnect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
@@ -621,7 +621,7 @@ void qTabAdvanced::SetSubExposureTime() {
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(
|
||||
spinSubExpTime->value(),
|
||||
static_cast<qDefs::timeUnit>(comboSubExpTimeUnit->currentIndex())));
|
||||
FILE_LOG(logINFO)
|
||||
LOG(logINFO)
|
||||
<< "Setting sub frame acquisition time to " << timeNS.count() << " ns"
|
||||
<< "/" << spinSubExpTime->value()
|
||||
<< qDefs::getUnitString(
|
||||
@@ -636,7 +636,7 @@ void qTabAdvanced::SetSubExposureTime() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::GetSubDeadTime() {
|
||||
FILE_LOG(logDEBUG) << "Getting sub dead time";
|
||||
LOG(logDEBUG) << "Getting sub dead time";
|
||||
disconnect(spinSubDeadTime, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(SetSubDeadTime()));
|
||||
disconnect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
@@ -661,7 +661,7 @@ void qTabAdvanced::SetSubDeadTime() {
|
||||
spinSubDeadTime->value(),
|
||||
static_cast<qDefs::timeUnit>(comboSubDeadTimeUnit->currentIndex())));
|
||||
|
||||
FILE_LOG(logINFO)
|
||||
LOG(logINFO)
|
||||
<< "Setting sub frame dead time to " << timeNS.count() << " ns"
|
||||
<< "/" << spinSubDeadTime->value()
|
||||
<< qDefs::getUnitString(
|
||||
@@ -675,7 +675,7 @@ void qTabAdvanced::SetSubDeadTime() {
|
||||
}
|
||||
|
||||
void qTabAdvanced::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Advanced Tab";
|
||||
LOG(logDEBUG) << "**Updating Advanced Tab";
|
||||
|
||||
// trimming
|
||||
if (tab_trimming->isEnabled()) {
|
||||
@@ -701,5 +701,5 @@ void qTabAdvanced::Refresh() {
|
||||
GetSubDeadTime();
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "**Updated Advanced Tab";
|
||||
LOG(logDEBUG) << "**Updated Advanced Tab";
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@
|
||||
#include <QString>
|
||||
#include <string>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector)
|
||||
: QWidget(parent), det(detector), btnGroupRate(nullptr) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "DataOutput ready";
|
||||
LOG(logDEBUG) << "DataOutput ready";
|
||||
}
|
||||
|
||||
qTabDataOutput::~qTabDataOutput() { delete btnGroupRate; }
|
||||
@@ -80,7 +82,7 @@ void qTabDataOutput::Initialization() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::PopulateDetectors() {
|
||||
FILE_LOG(logDEBUG) << "Populating detectors";
|
||||
LOG(logDEBUG) << "Populating detectors";
|
||||
|
||||
comboDetector->clear();
|
||||
comboDetector->addItem("All");
|
||||
@@ -93,7 +95,7 @@ void qTabDataOutput::PopulateDetectors() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::EnableBrowse() {
|
||||
FILE_LOG(logDEBUG) << "Getting browse enable";
|
||||
LOG(logDEBUG) << "Getting browse enable";
|
||||
try {
|
||||
btnOutputBrowse->setEnabled(false); // exception default
|
||||
std::string rxHostname =
|
||||
@@ -123,7 +125,7 @@ void qTabDataOutput::EnableBrowse() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetFileWrite() {
|
||||
FILE_LOG(logDEBUG) << "Getting file write enable";
|
||||
LOG(logDEBUG) << "Getting file write enable";
|
||||
try {
|
||||
boxFileWriteEnabled->setEnabled(true); // exception default
|
||||
auto retval = det->getFileWrite().tsquash(
|
||||
@@ -134,7 +136,7 @@ void qTabDataOutput::GetFileWrite() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetFileName() {
|
||||
FILE_LOG(logDEBUG) << "Getting file name";
|
||||
LOG(logDEBUG) << "Getting file name";
|
||||
try {
|
||||
auto retval = det->getFileNamePrefix().tsquash(
|
||||
"File name is inconsistent for all detectors.");
|
||||
@@ -145,7 +147,7 @@ void qTabDataOutput::GetFileName() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetOutputDir() {
|
||||
FILE_LOG(logDEBUG) << "Getting file path";
|
||||
LOG(logDEBUG) << "Getting file path";
|
||||
disconnect(dispOutputDir, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetOutputDir()));
|
||||
try {
|
||||
@@ -160,7 +162,7 @@ void qTabDataOutput::GetOutputDir() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::BrowseOutputDir() {
|
||||
FILE_LOG(logDEBUG) << "Browsing output directory";
|
||||
LOG(logDEBUG) << "Browsing output directory";
|
||||
QString directory = QFileDialog::getExistingDirectory(
|
||||
this, tr("Choose Output Directory "), dispOutputDir->text());
|
||||
if (!directory.isEmpty())
|
||||
@@ -169,7 +171,7 @@ void qTabDataOutput::BrowseOutputDir() {
|
||||
|
||||
void qTabDataOutput::SetOutputDir() {
|
||||
QString path = dispOutputDir->text();
|
||||
FILE_LOG(logDEBUG) << "Setting output directory to "
|
||||
LOG(logDEBUG) << "Setting output directory to "
|
||||
<< path.toAscii().constData();
|
||||
|
||||
// empty
|
||||
@@ -177,7 +179,7 @@ void qTabDataOutput::SetOutputDir() {
|
||||
qDefs::Message(qDefs::WARNING,
|
||||
"Invalid Output Path. Must not be empty.",
|
||||
"qTabDataOutput::SetOutputDir");
|
||||
FILE_LOG(logWARNING) << "Invalid Output Path. Must not be empty.";
|
||||
LOG(logWARNING) << "Invalid Output Path. Must not be empty.";
|
||||
GetOutputDir();
|
||||
} else {
|
||||
// chop off trailing '/'
|
||||
@@ -197,7 +199,7 @@ void qTabDataOutput::SetOutputDir() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetFileFormat() {
|
||||
FILE_LOG(logDEBUG) << "Getting File Format";
|
||||
LOG(logDEBUG) << "Getting File Format";
|
||||
disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetFileFormat(int)));
|
||||
try {
|
||||
@@ -219,7 +221,7 @@ void qTabDataOutput::GetFileFormat() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::SetFileFormat(int format) {
|
||||
FILE_LOG(logINFO) << "Setting File Format to "
|
||||
LOG(logINFO) << "Setting File Format to "
|
||||
<< comboFileFormat->currentText().toAscii().data();
|
||||
try {
|
||||
det->setFileFormat(static_cast<slsDetectorDefs::fileFormat>(
|
||||
@@ -230,7 +232,7 @@ void qTabDataOutput::SetFileFormat(int format) {
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetFileOverwrite() {
|
||||
FILE_LOG(logDEBUG) << "Getting File Over Write Enable";
|
||||
LOG(logDEBUG) << "Getting File Over Write Enable";
|
||||
disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetOverwriteEnable(bool)));
|
||||
try {
|
||||
@@ -246,7 +248,7 @@ void qTabDataOutput::GetFileOverwrite() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::SetOverwriteEnable(bool enable) {
|
||||
FILE_LOG(logINFO) << "Setting File Over Write Enable to " << enable;
|
||||
LOG(logINFO) << "Setting File Over Write Enable to " << enable;
|
||||
try {
|
||||
det->setFileOverWrite(enable);
|
||||
}
|
||||
@@ -256,7 +258,7 @@ void qTabDataOutput::SetOverwriteEnable(bool enable) {
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetTenGigaEnable() {
|
||||
FILE_LOG(logDEBUG) << "Getting 10GbE enable";
|
||||
LOG(logDEBUG) << "Getting 10GbE enable";
|
||||
disconnect(chkTenGiga, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetTenGigaEnable(bool)));
|
||||
try {
|
||||
@@ -271,7 +273,7 @@ void qTabDataOutput::GetTenGigaEnable() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::SetTenGigaEnable(bool enable) {
|
||||
FILE_LOG(logINFO) << "Setting 10GbE to " << enable;
|
||||
LOG(logINFO) << "Setting 10GbE to " << enable;
|
||||
try {
|
||||
det->setTenGiga(enable);
|
||||
}
|
||||
@@ -281,7 +283,7 @@ void qTabDataOutput::SetTenGigaEnable(bool enable) {
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetRateCorrection() {
|
||||
FILE_LOG(logDEBUG) << "Getting Rate Correction";
|
||||
LOG(logDEBUG) << "Getting Rate Correction";
|
||||
disconnect(chkRate, SIGNAL(toggled(bool)), this,
|
||||
SLOT(EnableRateCorrection()));
|
||||
disconnect(btnGroupRate, SIGNAL(buttonClicked(int)), this,
|
||||
@@ -313,7 +315,7 @@ void qTabDataOutput::EnableRateCorrection() {
|
||||
SetRateCorrection();
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logINFO) << "Disabling Rate correction";
|
||||
LOG(logINFO) << "Disabling Rate correction";
|
||||
// disable
|
||||
try {
|
||||
det->setRateCorrection(sls::ns(0));
|
||||
@@ -332,14 +334,14 @@ void qTabDataOutput::SetRateCorrection() {
|
||||
// custom dead time
|
||||
if (radioCustomDeadtime->isChecked()) {
|
||||
int64_t deadtime = spinCustomDeadTime->value();
|
||||
FILE_LOG(logINFO)
|
||||
LOG(logINFO)
|
||||
<< "Setting Rate Correction with custom dead time: "
|
||||
<< deadtime;
|
||||
det->setRateCorrection(sls::ns(deadtime));
|
||||
}
|
||||
// default dead time
|
||||
else {
|
||||
FILE_LOG(logINFO)
|
||||
LOG(logINFO)
|
||||
<< "Setting Rate Correction with default dead time";
|
||||
det->setDefaultRateCorrection();
|
||||
}
|
||||
@@ -350,7 +352,7 @@ void qTabDataOutput::SetRateCorrection() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetSpeed() {
|
||||
FILE_LOG(logDEBUG) << "Getting Speed";
|
||||
LOG(logDEBUG) << "Getting Speed";
|
||||
disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSpeed(int)));
|
||||
try {
|
||||
@@ -364,7 +366,7 @@ void qTabDataOutput::GetSpeed() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::SetSpeed(int speed) {
|
||||
FILE_LOG(logINFO) << "Setting Speed to "
|
||||
LOG(logINFO) << "Setting Speed to "
|
||||
<< comboEigerClkDivider->currentText().toAscii().data();
|
||||
;
|
||||
try {
|
||||
@@ -375,7 +377,7 @@ void qTabDataOutput::SetSpeed(int speed) {
|
||||
}
|
||||
|
||||
void qTabDataOutput::GetFlags() {
|
||||
FILE_LOG(logDEBUG) << "Getting readout flags";
|
||||
LOG(logDEBUG) << "Getting readout flags";
|
||||
disconnect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetFlags()));
|
||||
try {
|
||||
@@ -396,7 +398,7 @@ void qTabDataOutput::SetFlags() {
|
||||
auto mode =
|
||||
comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false;
|
||||
try {
|
||||
FILE_LOG(logINFO)
|
||||
LOG(logINFO)
|
||||
<< "Setting Readout Flags to "
|
||||
<< comboEigerParallelFlag->currentText().toAscii().data();
|
||||
det->setParallelMode(mode);
|
||||
@@ -406,7 +408,7 @@ void qTabDataOutput::SetFlags() {
|
||||
}
|
||||
|
||||
void qTabDataOutput::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating DataOutput Tab";
|
||||
LOG(logDEBUG) << "**Updating DataOutput Tab";
|
||||
|
||||
EnableBrowse();
|
||||
GetFileWrite();
|
||||
@@ -425,5 +427,5 @@ void qTabDataOutput::Refresh() {
|
||||
GetFlags();
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "**Updated DataOutput Tab";
|
||||
LOG(logDEBUG) << "**Updated DataOutput Tab";
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector)
|
||||
lblDetectorSoftware(nullptr) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Debugging ready";
|
||||
LOG(logDEBUG) << "Debugging ready";
|
||||
}
|
||||
|
||||
qTabDebugging::~qTabDebugging() {
|
||||
@@ -47,7 +47,7 @@ void qTabDebugging::Initialization() {
|
||||
}
|
||||
|
||||
void qTabDebugging::PopulateDetectors() {
|
||||
FILE_LOG(logDEBUG) << "Populating detectors";
|
||||
LOG(logDEBUG) << "Populating detectors";
|
||||
|
||||
comboDetector->clear();
|
||||
auto res = det->getHostname();
|
||||
@@ -57,7 +57,7 @@ void qTabDebugging::PopulateDetectors() {
|
||||
}
|
||||
|
||||
void qTabDebugging::GetDetectorStatus() {
|
||||
FILE_LOG(logDEBUG) << "Getting Status";
|
||||
LOG(logDEBUG) << "Getting Status";
|
||||
|
||||
try {
|
||||
std::string status = sls::ToString(
|
||||
@@ -69,7 +69,7 @@ void qTabDebugging::GetDetectorStatus() {
|
||||
}
|
||||
|
||||
void qTabDebugging::GetInfo() {
|
||||
FILE_LOG(logDEBUG) << "Getting Readout Info";
|
||||
LOG(logDEBUG) << "Getting Readout Info";
|
||||
|
||||
// open info in a new popup
|
||||
QFrame *popup1 = new QFrame(this, Qt::Popup | Qt::SubWindow);
|
||||
@@ -190,7 +190,7 @@ void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
|
||||
}
|
||||
|
||||
void qTabDebugging::TestDetector() {
|
||||
FILE_LOG(logINFO) << "Testing Readout";
|
||||
LOG(logINFO) << "Testing Readout";
|
||||
|
||||
try {
|
||||
QString moduleName = "Module";
|
||||
@@ -208,7 +208,7 @@ void qTabDebugging::TestDetector() {
|
||||
det->executeFirmwareTest({comboDetector->currentIndex()});
|
||||
message.append(QString("<nobr>%1 Firmware: PASS</nobr><br>")
|
||||
.arg(moduleName));
|
||||
FILE_LOG(logINFO) << "Detector Firmware Test: Pass";
|
||||
LOG(logINFO) << "Detector Firmware Test: Pass";
|
||||
}
|
||||
CATCH_DISPLAY("Firmware test failed.",
|
||||
"qTabDebugging::TestDetector")
|
||||
@@ -220,7 +220,7 @@ void qTabDebugging::TestDetector() {
|
||||
det->executeBusTest({comboDetector->currentIndex()});
|
||||
message.append(
|
||||
QString("<nobr>%1 Bus: PASS</nobr><br>").arg(moduleName));
|
||||
FILE_LOG(logINFO) << "Detector Bus Test: Pass";
|
||||
LOG(logINFO) << "Detector Bus Test: Pass";
|
||||
}
|
||||
CATCH_DISPLAY("Bus test failed.", "qTabDebugging::TestDetector")
|
||||
}
|
||||
@@ -234,7 +234,7 @@ void qTabDebugging::TestDetector() {
|
||||
}
|
||||
|
||||
void qTabDebugging::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Debugging Tab";
|
||||
LOG(logDEBUG) << "**Updating Debugging Tab";
|
||||
GetDetectorStatus();
|
||||
FILE_LOG(logDEBUG) << "**Updated Debugging Tab";
|
||||
LOG(logDEBUG) << "**Updated Debugging Tab";
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ qTabDeveloper::qTabDeveloper(QWidget *parent, sls::Detector *detector)
|
||||
: QWidget(parent), det(detector) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Developer ready";
|
||||
LOG(logDEBUG) << "Developer ready";
|
||||
}
|
||||
|
||||
qTabDeveloper::~qTabDeveloper() {}
|
||||
@@ -295,7 +295,7 @@ void qTabDeveloper::Initialization() {
|
||||
}
|
||||
|
||||
void qTabDeveloper::PopulateDetectors() {
|
||||
FILE_LOG(logDEBUG) << "Populating detectors";
|
||||
LOG(logDEBUG) << "Populating detectors";
|
||||
|
||||
comboDetector->clear();
|
||||
comboDetector->addItem("All");
|
||||
@@ -312,7 +312,7 @@ void qTabDeveloper::GetHighVoltage() {
|
||||
// not enabled for eiger
|
||||
if (!comboHV->isVisible() && !spinHV->isVisible())
|
||||
return;
|
||||
FILE_LOG(logDEBUG) << "Getting High Voltage";
|
||||
LOG(logDEBUG) << "Getting High Voltage";
|
||||
disconnect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
|
||||
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetHighVoltage()));
|
||||
@@ -368,7 +368,7 @@ void qTabDeveloper::GetHighVoltage() {
|
||||
void qTabDeveloper::SetHighVoltage() {
|
||||
int val = (comboHV->isVisible() ? comboHV->currentText().toInt()
|
||||
: spinHV->value());
|
||||
FILE_LOG(logINFO) << "Setting high voltage:" << val;
|
||||
LOG(logINFO) << "Setting high voltage:" << val;
|
||||
|
||||
try {
|
||||
det->setHighVoltage({comboDetector->currentIndex() - 1});
|
||||
@@ -594,7 +594,7 @@ qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
||||
}
|
||||
|
||||
void qTabDeveloper::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Developer Tab\n";
|
||||
LOG(logDEBUG) << "**Updating Developer Tab\n";
|
||||
for (const auto &it : dacWidgets) {
|
||||
it->SetDetectorIndex(comboDetector->currentIndex() - 1);
|
||||
}
|
||||
@@ -602,5 +602,5 @@ void qTabDeveloper::Refresh() {
|
||||
it->SetDetectorIndex(comboDetector->currentIndex() - 1);
|
||||
}
|
||||
GetHighVoltage();
|
||||
FILE_LOG(logDEBUG) << "**Updated Developer Tab";
|
||||
LOG(logDEBUG) << "**Updated Developer Tab";
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ qTabMeasurement::qTabMeasurement(QWidget *parent, sls::Detector *detector,
|
||||
: QWidget(parent), det(detector), plot(p), progressTimer(nullptr) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Measurement ready";
|
||||
LOG(logDEBUG) << "Measurement ready";
|
||||
}
|
||||
|
||||
qTabMeasurement::~qTabMeasurement() { delete progressTimer; }
|
||||
@@ -133,7 +133,7 @@ void qTabMeasurement::ShowTriggerDelay() {
|
||||
bool showTrigger = true;
|
||||
if (det->getDetectorType().squash() == slsDetectorDefs::GOTTHARD2) {
|
||||
try {
|
||||
FILE_LOG(logDEBUG) << "Getting burst mode";
|
||||
LOG(logDEBUG) << "Getting burst mode";
|
||||
auto retval = det->getBurstMode().tsquash(
|
||||
"Inconsistent burst mode for all detectors.");
|
||||
// burst mode and auto timing mode
|
||||
@@ -181,7 +181,7 @@ void qTabMeasurement::SetupTimingMode() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::EnableWidgetsforTimingMode() {
|
||||
FILE_LOG(logDEBUG) << "Enabling Widgets for Timing Mode";
|
||||
LOG(logDEBUG) << "Enabling Widgets for Timing Mode";
|
||||
|
||||
// default
|
||||
lblNumFrames->setEnabled(false);
|
||||
@@ -266,7 +266,7 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetTimingMode() {
|
||||
FILE_LOG(logDEBUG) << "Getting timing mode";
|
||||
LOG(logDEBUG) << "Getting timing mode";
|
||||
disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetTimingMode(int)));
|
||||
try {
|
||||
@@ -296,7 +296,7 @@ void qTabMeasurement::GetTimingMode() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::SetTimingMode(int val) {
|
||||
FILE_LOG(logINFO) << "Setting timing mode:"
|
||||
LOG(logINFO) << "Setting timing mode:"
|
||||
<< comboTimingMode->currentText().toAscii().data();
|
||||
try {
|
||||
det->setTimingMode(static_cast<slsDetectorDefs::timingMode>(val));
|
||||
@@ -307,12 +307,12 @@ void qTabMeasurement::SetTimingMode(int val) {
|
||||
}
|
||||
|
||||
void qTabMeasurement::SetNumMeasurements(int val) {
|
||||
FILE_LOG(logINFO) << "Setting Number of Measurements to " << val;
|
||||
LOG(logINFO) << "Setting Number of Measurements to " << val;
|
||||
numMeasurements = val;
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetNumFrames() {
|
||||
FILE_LOG(logDEBUG) << "Getting number of frames";
|
||||
LOG(logDEBUG) << "Getting number of frames";
|
||||
disconnect(spinNumFrames, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetNumFrames(int)));
|
||||
try {
|
||||
@@ -327,7 +327,7 @@ void qTabMeasurement::GetNumFrames() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::SetNumFrames(int val) {
|
||||
FILE_LOG(logINFO) << "Setting number of frames to " << val;
|
||||
LOG(logINFO) << "Setting number of frames to " << val;
|
||||
try {
|
||||
det->setNumberOfFrames(val);
|
||||
}
|
||||
@@ -337,7 +337,7 @@ void qTabMeasurement::SetNumFrames(int val) {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetNumTriggers() {
|
||||
FILE_LOG(logDEBUG) << "Getting number of triggers";
|
||||
LOG(logDEBUG) << "Getting number of triggers";
|
||||
disconnect(spinNumTriggers, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetNumTriggers(int)));
|
||||
try {
|
||||
@@ -352,7 +352,7 @@ void qTabMeasurement::GetNumTriggers() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::SetNumTriggers(int val) {
|
||||
FILE_LOG(logINFO) << "Setting number of triggers to " << val;
|
||||
LOG(logINFO) << "Setting number of triggers to " << val;
|
||||
try {
|
||||
det->setNumberOfTriggers(val);
|
||||
}
|
||||
@@ -362,7 +362,7 @@ void qTabMeasurement::SetNumTriggers(int val) {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetNumBursts() {
|
||||
FILE_LOG(logDEBUG) << "Getting number of bursts";
|
||||
LOG(logDEBUG) << "Getting number of bursts";
|
||||
disconnect(spinNumBursts, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetNumBursts(int)));
|
||||
try {
|
||||
@@ -377,7 +377,7 @@ void qTabMeasurement::GetNumBursts() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::SetNumBursts(int val) {
|
||||
FILE_LOG(logINFO) << "Setting number of bursts to " << val;
|
||||
LOG(logINFO) << "Setting number of bursts to " << val;
|
||||
try {
|
||||
det->setNumberOfBursts(val);
|
||||
}
|
||||
@@ -387,7 +387,7 @@ void qTabMeasurement::SetNumBursts(int val) {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetNumSamples() {
|
||||
FILE_LOG(logDEBUG) << "Getting number of samples";
|
||||
LOG(logDEBUG) << "Getting number of samples";
|
||||
disconnect(spinNumSamples, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetNumSamples(int)));
|
||||
try {
|
||||
@@ -402,7 +402,7 @@ void qTabMeasurement::GetNumSamples() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::SetNumSamples(int val) {
|
||||
FILE_LOG(logINFO) << "Setting number of samples to " << val;
|
||||
LOG(logINFO) << "Setting number of samples to " << val;
|
||||
try {
|
||||
det->setNumberOfAnalogSamples(val);
|
||||
}
|
||||
@@ -412,7 +412,7 @@ void qTabMeasurement::SetNumSamples(int val) {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetExposureTime() {
|
||||
FILE_LOG(logDEBUG) << "Getting exposure time";
|
||||
LOG(logDEBUG) << "Getting exposure time";
|
||||
disconnect(spinExpTime, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(SetExposureTime()));
|
||||
disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
@@ -437,7 +437,7 @@ void qTabMeasurement::GetExposureTime() {
|
||||
void qTabMeasurement::SetExposureTime() {
|
||||
auto val = spinExpTime->value();
|
||||
auto unit = static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex());
|
||||
FILE_LOG(logINFO) << "Setting exposure time to " << val << " "
|
||||
LOG(logINFO) << "Setting exposure time to " << val << " "
|
||||
<< qDefs::getUnitString(unit);
|
||||
try {
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
|
||||
@@ -450,7 +450,7 @@ void qTabMeasurement::SetExposureTime() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetAcquisitionPeriod() {
|
||||
FILE_LOG(logDEBUG) << "Getting acquisition period";
|
||||
LOG(logDEBUG) << "Getting acquisition period";
|
||||
disconnect(spinPeriod, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(SetAcquisitionPeriod()));
|
||||
disconnect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
@@ -475,7 +475,7 @@ void qTabMeasurement::GetAcquisitionPeriod() {
|
||||
void qTabMeasurement::SetAcquisitionPeriod() {
|
||||
auto val = spinPeriod->value();
|
||||
auto unit = static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex());
|
||||
FILE_LOG(logINFO) << "Setting acquisition period to " << val << " "
|
||||
LOG(logINFO) << "Setting acquisition period to " << val << " "
|
||||
<< qDefs::getUnitString(unit);
|
||||
try {
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
|
||||
@@ -488,7 +488,7 @@ void qTabMeasurement::SetAcquisitionPeriod() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::CheckAcqPeriodGreaterThanExp() {
|
||||
FILE_LOG(logDEBUG) << "Checking period >= exptime";
|
||||
LOG(logDEBUG) << "Checking period >= exptime";
|
||||
bool error = false;
|
||||
if (lblPeriod->isEnabled()) {
|
||||
auto exptimeNS = qDefs::getNSTime(std::make_pair(
|
||||
@@ -515,7 +515,7 @@ void qTabMeasurement::CheckAcqPeriodGreaterThanExp() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetDelay() {
|
||||
FILE_LOG(logDEBUG) << "Getting delay";
|
||||
LOG(logDEBUG) << "Getting delay";
|
||||
disconnect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay()));
|
||||
disconnect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetDelay()));
|
||||
@@ -536,7 +536,7 @@ void qTabMeasurement::GetDelay() {
|
||||
void qTabMeasurement::SetDelay() {
|
||||
auto val = spinDelay->value();
|
||||
auto unit = static_cast<qDefs::timeUnit>(comboDelayUnit->currentIndex());
|
||||
FILE_LOG(logINFO) << "Setting delay to " << val << " "
|
||||
LOG(logINFO) << "Setting delay to " << val << " "
|
||||
<< qDefs::getUnitString(unit);
|
||||
try {
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
|
||||
@@ -547,7 +547,7 @@ void qTabMeasurement::SetDelay() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetBurstPeriod() {
|
||||
FILE_LOG(logDEBUG) << "Getting Burst Period";
|
||||
LOG(logDEBUG) << "Getting Burst Period";
|
||||
disconnect(spinBurstPeriod, SIGNAL(valueChanged(double)), this,
|
||||
SLOT(SetBurstPeriod()));
|
||||
disconnect(comboBurstPeriodUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
@@ -572,7 +572,7 @@ void qTabMeasurement::SetBurstPeriod() {
|
||||
auto val = spinBurstPeriod->value();
|
||||
auto unit =
|
||||
static_cast<qDefs::timeUnit>(comboBurstPeriodUnit->currentIndex());
|
||||
FILE_LOG(logINFO) << "Setting burst period to " << val << " "
|
||||
LOG(logINFO) << "Setting burst period to " << val << " "
|
||||
<< qDefs::getUnitString(unit);
|
||||
try {
|
||||
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
|
||||
@@ -584,7 +584,7 @@ void qTabMeasurement::SetBurstPeriod() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetFileWrite() {
|
||||
FILE_LOG(logDEBUG) << "Getting File Write Enable";
|
||||
LOG(logDEBUG) << "Getting File Write Enable";
|
||||
disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool)));
|
||||
try {
|
||||
dispFileName->setEnabled(true); // default, even when exception
|
||||
@@ -603,7 +603,7 @@ void qTabMeasurement::GetFileWrite() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::SetFileWrite(bool val) {
|
||||
FILE_LOG(logINFO) << "Set File Write to " << val;
|
||||
LOG(logINFO) << "Set File Write to " << val;
|
||||
try {
|
||||
det->setFileWrite(val);
|
||||
dispFileName->setEnabled(val);
|
||||
@@ -616,7 +616,7 @@ void qTabMeasurement::SetFileWrite(bool val) {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetFileName() {
|
||||
FILE_LOG(logDEBUG) << "Getting file name prefix";
|
||||
LOG(logDEBUG) << "Getting file name prefix";
|
||||
disconnect(dispFileName, SIGNAL(editingFinished()), this,
|
||||
SLOT(SetFileName()));
|
||||
try {
|
||||
@@ -631,7 +631,7 @@ void qTabMeasurement::GetFileName() {
|
||||
|
||||
void qTabMeasurement::SetFileName() {
|
||||
std::string val = std::string(dispFileName->text().toAscii().constData());
|
||||
FILE_LOG(logINFO) << "Setting File Name Prefix:" << val;
|
||||
LOG(logINFO) << "Setting File Name Prefix:" << val;
|
||||
try {
|
||||
det->setFileNamePrefix(val);
|
||||
}
|
||||
@@ -643,7 +643,7 @@ void qTabMeasurement::SetFileName() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetRunIndex() {
|
||||
FILE_LOG(logDEBUG) << "Getting Acquisition File index";
|
||||
LOG(logDEBUG) << "Getting Acquisition File index";
|
||||
disconnect(spinIndex, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetRunIndex(int)));
|
||||
try {
|
||||
@@ -657,7 +657,7 @@ void qTabMeasurement::GetRunIndex() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::SetRunIndex(int val) {
|
||||
FILE_LOG(logINFO) << "Setting Acquisition File Index to " << val;
|
||||
LOG(logINFO) << "Setting Acquisition File Index to " << val;
|
||||
try {
|
||||
det->setAcquisitionIndex(val);
|
||||
}
|
||||
@@ -667,7 +667,7 @@ void qTabMeasurement::SetRunIndex(int val) {
|
||||
}
|
||||
|
||||
void qTabMeasurement::GetStartingFrameNumber() {
|
||||
FILE_LOG(logDEBUG) << "Getting Starting Frame Number";
|
||||
LOG(logDEBUG) << "Getting Starting Frame Number";
|
||||
disconnect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetStartingFrameNumber(int)));
|
||||
try {
|
||||
@@ -682,7 +682,7 @@ void qTabMeasurement::GetStartingFrameNumber() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::SetStartingFrameNumber(int val) {
|
||||
FILE_LOG(logINFO) << "Setting Starting frame number to " << val;
|
||||
LOG(logINFO) << "Setting Starting frame number to " << val;
|
||||
try {
|
||||
det->setStartingFrameNumber(val);
|
||||
}
|
||||
@@ -692,14 +692,14 @@ void qTabMeasurement::SetStartingFrameNumber(int val) {
|
||||
}
|
||||
|
||||
void qTabMeasurement::ResetProgress() {
|
||||
FILE_LOG(logDEBUG) << "Resetting progress";
|
||||
LOG(logDEBUG) << "Resetting progress";
|
||||
lblCurrentFrame->setText("0");
|
||||
lblCurrentMeasurement->setText("0");
|
||||
progressBar->setValue(0);
|
||||
}
|
||||
|
||||
void qTabMeasurement::UpdateProgress() {
|
||||
FILE_LOG(logDEBUG) << "Updating progress";
|
||||
LOG(logDEBUG) << "Updating progress";
|
||||
progressBar->setValue(plot->GetProgress());
|
||||
lblCurrentFrame->setText(QString::number(plot->GetCurrentFrameIndex()));
|
||||
lblCurrentMeasurement->setText(QString::number(currentMeasurement));
|
||||
@@ -741,7 +741,7 @@ void qTabMeasurement::StartAcquisition() {
|
||||
}
|
||||
}
|
||||
|
||||
FILE_LOG(logINFOBLUE) << "Starting Acquisition";
|
||||
LOG(logINFOBLUE) << "Starting Acquisition";
|
||||
plot->SetRunning(true);
|
||||
isAcquisitionStopped = false;
|
||||
currentMeasurement = 0;
|
||||
@@ -753,7 +753,7 @@ void qTabMeasurement::StartAcquisition() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::StopAcquisition() {
|
||||
FILE_LOG(logINFORED) << "Stopping Acquisition";
|
||||
LOG(logINFORED) << "Stopping Acquisition";
|
||||
try {
|
||||
isAcquisitionStopped = true;
|
||||
det->stopDetector();
|
||||
@@ -765,13 +765,13 @@ void qTabMeasurement::StopAcquisition() {
|
||||
void qTabMeasurement::AcquireFinished() {
|
||||
// to catch only once (if abort acquire also calls acq finished call back)
|
||||
if (!btnStart->isEnabled()) {
|
||||
FILE_LOG(logDEBUG) << "Acquire Finished";
|
||||
LOG(logDEBUG) << "Acquire Finished";
|
||||
UpdateProgress();
|
||||
GetRunIndex();
|
||||
if (startingFnumImplemented) {
|
||||
GetStartingFrameNumber();
|
||||
}
|
||||
FILE_LOG(logDEBUG) << "Measurement " << currentMeasurement
|
||||
LOG(logDEBUG) << "Measurement " << currentMeasurement
|
||||
<< " finished";
|
||||
// next measurement if acq is not stopped
|
||||
if (!isAcquisitionStopped &&
|
||||
@@ -791,7 +791,7 @@ void qTabMeasurement::AcquireFinished() {
|
||||
}
|
||||
|
||||
void qTabMeasurement::AbortAcquire() {
|
||||
FILE_LOG(logINFORED) << "Abort Acquire";
|
||||
LOG(logINFORED) << "Abort Acquire";
|
||||
isAcquisitionStopped = true;
|
||||
AcquireFinished();
|
||||
}
|
||||
@@ -806,7 +806,7 @@ void qTabMeasurement::Enable(bool enable) {
|
||||
}
|
||||
|
||||
void qTabMeasurement::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Measurement Tab";
|
||||
LOG(logDEBUG) << "**Updating Measurement Tab";
|
||||
|
||||
if (!plot->GetIsRunning()) {
|
||||
GetTimingMode();
|
||||
@@ -835,5 +835,5 @@ void qTabMeasurement::Refresh() {
|
||||
ResetProgress();
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "**Updated Measurement Tab";
|
||||
LOG(logDEBUG) << "**Updated Measurement Tab";
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
qTabMessages::qTabMessages(QWidget *parent) : QWidget(parent) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Messages ready";
|
||||
LOG(logDEBUG) << "Messages ready";
|
||||
}
|
||||
|
||||
qTabMessages::~qTabMessages() {
|
||||
@@ -74,7 +74,7 @@ void qTabMessages::ExecuteCommand() {
|
||||
|
||||
QString command = param.at(0);
|
||||
param.removeFirst();
|
||||
FILE_LOG(logINFO) << "Executing Command:[" << command.toAscii().constData()
|
||||
LOG(logINFO) << "Executing Command:[" << command.toAscii().constData()
|
||||
<< "] with Arguments:["
|
||||
<< param.join(" ").toAscii().constData() << "]";
|
||||
|
||||
@@ -92,14 +92,14 @@ void qTabMessages::AppendOutput() {
|
||||
result.replace("\n", "<br>");
|
||||
dispLog->append(QString("<font color = \"DarkBlue\">") + result +
|
||||
QString("</font>"));
|
||||
FILE_LOG(logDEBUG) << "Command executed successfully";
|
||||
LOG(logDEBUG) << "Command executed successfully";
|
||||
PrintNextLine();
|
||||
}
|
||||
|
||||
void qTabMessages::AppendError() {
|
||||
dispLog->append(QString("<font color = \"Red\">") + process->errorString() +
|
||||
QString("</font>"));
|
||||
FILE_LOG(logERROR) << "Error executing command";
|
||||
LOG(logERROR) << "Error executing command";
|
||||
PrintNextLine();
|
||||
}
|
||||
|
||||
@@ -118,9 +118,9 @@ void qTabMessages::SaveLog() {
|
||||
std::string("The Log has been successfully saved to ") +
|
||||
fName.toAscii().constData();
|
||||
qDefs::Message(qDefs::INFORMATION, mess, "TabMessages::SaveLog");
|
||||
FILE_LOG(logINFO) << mess;
|
||||
LOG(logINFO) << mess;
|
||||
} else {
|
||||
FILE_LOG(logWARNING) << "Attempt to save log file failed: "
|
||||
LOG(logWARNING) << "Attempt to save log file failed: "
|
||||
<< fName.toAscii().constData();
|
||||
qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.",
|
||||
"qTabMessages::SaveLog");
|
||||
@@ -131,7 +131,7 @@ void qTabMessages::SaveLog() {
|
||||
|
||||
void qTabMessages::ClearLog() {
|
||||
dispLog->clear();
|
||||
FILE_LOG(logINFO) << "Log Cleared";
|
||||
LOG(logINFO) << "Log Cleared";
|
||||
PrintNextLine();
|
||||
dispCommand->setFocus();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p)
|
||||
: QWidget(parent), det(detector), plot(p), is1d(false) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Plot ready";
|
||||
LOG(logDEBUG) << "Plot ready";
|
||||
}
|
||||
|
||||
qTabPlot::~qTabPlot() { delete btnGroupPlotType; }
|
||||
@@ -188,7 +188,7 @@ void qTabPlot::Initialization() {
|
||||
}
|
||||
|
||||
void qTabPlot::Select1DPlot(bool enable) {
|
||||
FILE_LOG(logDEBUG) << "Selecting " << (enable ? "1" : "2") << "D Plot";
|
||||
LOG(logDEBUG) << "Selecting " << (enable ? "1" : "2") << "D Plot";
|
||||
is1d = enable;
|
||||
box1D->setEnabled(enable);
|
||||
box2D->setEnabled(!enable);
|
||||
@@ -209,9 +209,9 @@ void qTabPlot::Select1DPlot(bool enable) {
|
||||
void qTabPlot::SetPlot() {
|
||||
bool plotEnable = false;
|
||||
if (radioNoPlot->isChecked()) {
|
||||
FILE_LOG(logINFO) << "Setting Plot Type: No Plot";
|
||||
LOG(logINFO) << "Setting Plot Type: No Plot";
|
||||
} else if (radioDataGraph->isChecked()) {
|
||||
FILE_LOG(logINFO) << "Setting Plot Type: Datagraph";
|
||||
LOG(logINFO) << "Setting Plot Type: Datagraph";
|
||||
plotEnable = true;
|
||||
}
|
||||
boxFrequency->setEnabled(plotEnable);
|
||||
@@ -232,7 +232,7 @@ void qTabPlot::SetPlot() {
|
||||
}
|
||||
|
||||
void qTabPlot::Set1DPlotOptionsRight() {
|
||||
FILE_LOG(logDEBUG) << "1D Options Right";
|
||||
LOG(logDEBUG) << "1D Options Right";
|
||||
int i = stackedWidget1D->currentIndex();
|
||||
if (i == (stackedWidget1D->count() - 1))
|
||||
stackedWidget1D->setCurrentIndex(0);
|
||||
@@ -243,7 +243,7 @@ void qTabPlot::Set1DPlotOptionsRight() {
|
||||
}
|
||||
|
||||
void qTabPlot::Set1DPlotOptionsLeft() {
|
||||
FILE_LOG(logDEBUG) << "1D Options Left";
|
||||
LOG(logDEBUG) << "1D Options Left";
|
||||
int i = stackedWidget1D->currentIndex();
|
||||
if (i == 0)
|
||||
stackedWidget1D->setCurrentIndex(stackedWidget1D->count() - 1);
|
||||
@@ -254,7 +254,7 @@ void qTabPlot::Set1DPlotOptionsLeft() {
|
||||
}
|
||||
|
||||
void qTabPlot::Set2DPlotOptionsRight() {
|
||||
FILE_LOG(logDEBUG) << "2D Options Right";
|
||||
LOG(logDEBUG) << "2D Options Right";
|
||||
int i = stackedWidget2D->currentIndex();
|
||||
if (i == (stackedWidget2D->count() - 1))
|
||||
stackedWidget2D->setCurrentIndex(0);
|
||||
@@ -265,7 +265,7 @@ void qTabPlot::Set2DPlotOptionsRight() {
|
||||
}
|
||||
|
||||
void qTabPlot::Set2DPlotOptionsLeft() {
|
||||
FILE_LOG(logDEBUG) << "2D Options Left";
|
||||
LOG(logDEBUG) << "2D Options Left";
|
||||
int i = stackedWidget2D->currentIndex();
|
||||
if (i == 0)
|
||||
stackedWidget2D->setCurrentIndex(stackedWidget2D->count() - 1);
|
||||
@@ -276,7 +276,7 @@ void qTabPlot::Set2DPlotOptionsLeft() {
|
||||
}
|
||||
|
||||
void qTabPlot::EnablePersistency(bool enable) {
|
||||
FILE_LOG(logINFO) << "Superimpose " << (enable ? "enabled" : "disabled");
|
||||
LOG(logINFO) << "Superimpose " << (enable ? "enabled" : "disabled");
|
||||
lblPersistency->setEnabled(enable);
|
||||
spinPersistency->setEnabled(enable);
|
||||
if (enable)
|
||||
@@ -289,7 +289,7 @@ void qTabPlot::SetBinary() {
|
||||
bool binary1D = chkBinary->isChecked();
|
||||
bool binary2D = chkBinary_2->isChecked();
|
||||
if (is1d) {
|
||||
FILE_LOG(logINFO) << "Binary Plot "
|
||||
LOG(logINFO) << "Binary Plot "
|
||||
<< (binary1D ? "enabled" : "disabled");
|
||||
lblFrom->setEnabled(binary1D);
|
||||
lblTo->setEnabled(binary1D);
|
||||
@@ -297,7 +297,7 @@ void qTabPlot::SetBinary() {
|
||||
spinTo->setEnabled(binary1D);
|
||||
plot->SetBinary(binary1D, spinFrom->value(), spinTo->value());
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Binary Plot "
|
||||
LOG(logINFO) << "Binary Plot "
|
||||
<< (binary2D ? "enabled" : "disabled");
|
||||
lblFrom_2->setEnabled(binary2D);
|
||||
lblTo_2->setEnabled(binary2D);
|
||||
@@ -308,7 +308,7 @@ void qTabPlot::SetBinary() {
|
||||
}
|
||||
|
||||
void qTabPlot::GetGapPixels() {
|
||||
FILE_LOG(logDEBUG) << "Getting gap pixels";
|
||||
LOG(logDEBUG) << "Getting gap pixels";
|
||||
disconnect(chkGapPixels, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetGapPixels(bool)));
|
||||
try {
|
||||
@@ -322,7 +322,7 @@ void qTabPlot::GetGapPixels() {
|
||||
}
|
||||
|
||||
void qTabPlot::SetGapPixels(bool enable) {
|
||||
FILE_LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
|
||||
LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
|
||||
try {
|
||||
det->setRxAddGapPixels(enable);
|
||||
}
|
||||
@@ -331,7 +331,7 @@ void qTabPlot::SetGapPixels(bool enable) {
|
||||
}
|
||||
|
||||
void qTabPlot::SetTitles() {
|
||||
FILE_LOG(logDEBUG) << "Setting Plot Titles";
|
||||
LOG(logDEBUG) << "Setting Plot Titles";
|
||||
disconnect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
disconnect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
disconnect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
@@ -393,7 +393,7 @@ void qTabPlot::SetTitles() {
|
||||
}
|
||||
|
||||
void qTabPlot::SetXRange() {
|
||||
FILE_LOG(logDEBUG) << "Enable X axis range";
|
||||
LOG(logDEBUG) << "Enable X axis range";
|
||||
|
||||
if (chkAspectRatio->isChecked()) {
|
||||
MaintainAspectRatio(static_cast<int>(slsDetectorDefs::Y));
|
||||
@@ -403,7 +403,7 @@ void qTabPlot::SetXRange() {
|
||||
}
|
||||
|
||||
void qTabPlot::SetYRange() {
|
||||
FILE_LOG(logDEBUG) << "Enable Y axis range";
|
||||
LOG(logDEBUG) << "Enable Y axis range";
|
||||
|
||||
if (chkAspectRatio->isChecked()) {
|
||||
MaintainAspectRatio(static_cast<int>(slsDetectorDefs::X));
|
||||
@@ -421,7 +421,7 @@ void qTabPlot::CheckAspectRatio() {
|
||||
}
|
||||
|
||||
void qTabPlot::SetXYRange() {
|
||||
FILE_LOG(logDEBUG) << "Set XY Range";
|
||||
LOG(logDEBUG) << "Set XY Range";
|
||||
bool disablezoom = false;
|
||||
bool isRange[4]{false, false, false, false};
|
||||
double xyRange[4]{0, 0, 0, 0};
|
||||
@@ -434,7 +434,7 @@ void qTabPlot::SetXYRange() {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (chkVal[i] && !dispVal[i].isEmpty()) {
|
||||
double val = dispVal[i].toDouble();
|
||||
FILE_LOG(logDEBUG)
|
||||
LOG(logDEBUG)
|
||||
<< "Setting "
|
||||
<< qDefs::getRangeAsString(static_cast<qDefs::range>(i))
|
||||
<< " to " << val;
|
||||
@@ -449,7 +449,7 @@ void qTabPlot::SetXYRange() {
|
||||
}
|
||||
|
||||
void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
FILE_LOG(logDEBUG) << "Maintaining Aspect Ratio";
|
||||
LOG(logDEBUG) << "Maintaining Aspect Ratio";
|
||||
|
||||
disconnect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(SetXRange()));
|
||||
disconnect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(SetXRange()));
|
||||
@@ -482,7 +482,7 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
ranges[qDefs::YMAX] = plot->GetYMaximum();
|
||||
double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
|
||||
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
|
||||
FILE_LOG(logDEBUG) << "Ideal Aspect ratio: " << idealAspectratio
|
||||
LOG(logDEBUG) << "Ideal Aspect ratio: " << idealAspectratio
|
||||
<< " for x(" << ranges[qDefs::XMIN] << " - "
|
||||
<< ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN]
|
||||
<< " - " << ranges[qDefs::YMAX] << ")";
|
||||
@@ -494,7 +494,7 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
ranges[qDefs::YMAX] = dispYMax->text().toDouble();
|
||||
double currentAspectRatio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
|
||||
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
|
||||
FILE_LOG(logDEBUG) << "Current Aspect ratio: " << currentAspectRatio
|
||||
LOG(logDEBUG) << "Current Aspect ratio: " << currentAspectRatio
|
||||
<< " for x(" << ranges[qDefs::XMIN] << " - "
|
||||
<< ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN]
|
||||
<< " - " << ranges[qDefs::YMAX] << ")";
|
||||
@@ -519,14 +519,14 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
if (newval <= plot->GetXMaximum()) {
|
||||
ranges[qDefs::XMAX] = newval;
|
||||
dispXMax->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New XMax: " << newval;
|
||||
LOG(logDEBUG) << "New XMax: " << newval;
|
||||
} else {
|
||||
newval = ranges[qDefs::XMAX] -
|
||||
(idealAspectratio *
|
||||
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]));
|
||||
ranges[qDefs::XMIN] = newval;
|
||||
dispXMin->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New XMin: " << newval;
|
||||
LOG(logDEBUG) << "New XMin: " << newval;
|
||||
}
|
||||
}
|
||||
// adjust y
|
||||
@@ -537,14 +537,14 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
|
||||
if (newval <= plot->GetYMaximum()) {
|
||||
ranges[qDefs::YMAX] = newval;
|
||||
dispYMax->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New YMax: " << newval;
|
||||
LOG(logDEBUG) << "New YMax: " << newval;
|
||||
} else {
|
||||
newval = ranges[qDefs::YMAX] -
|
||||
((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
|
||||
idealAspectratio);
|
||||
ranges[qDefs::YMIN] = newval;
|
||||
dispYMin->setText(QString::number(newval));
|
||||
FILE_LOG(logDEBUG) << "New YMax: " << newval;
|
||||
LOG(logDEBUG) << "New YMax: " << newval;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -569,19 +569,19 @@ void qTabPlot::SetZRange() {
|
||||
|
||||
if (isZRange[0] && !dispZMin->text().isEmpty()) {
|
||||
double val = dispZMin->text().toDouble();
|
||||
FILE_LOG(logDEBUG) << "Setting zmin to " << val;
|
||||
LOG(logDEBUG) << "Setting zmin to " << val;
|
||||
zRange[0] = val;
|
||||
}
|
||||
if (isZRange[1] && !dispZMax->text().isEmpty()) {
|
||||
double val = dispZMax->text().toDouble();
|
||||
FILE_LOG(logDEBUG) << "Setting zmax to " << val;
|
||||
LOG(logDEBUG) << "Setting zmax to " << val;
|
||||
zRange[1] = val;
|
||||
}
|
||||
plot->SetZRange(zRange, isZRange);
|
||||
}
|
||||
|
||||
void qTabPlot::GetStreamingFrequency() {
|
||||
FILE_LOG(logDEBUG) << "Getting Streaming Frequency";
|
||||
LOG(logDEBUG) << "Getting Streaming Frequency";
|
||||
disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetStreamingFrequency()));
|
||||
disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this,
|
||||
@@ -639,10 +639,10 @@ void qTabPlot::SetStreamingFrequency() {
|
||||
stackedTimeInterval->setCurrentIndex(comboFrequency->currentIndex());
|
||||
try {
|
||||
if (frequency) {
|
||||
FILE_LOG(logINFO) << "Setting Streaming Frequency to " << freqVal;
|
||||
LOG(logINFO) << "Setting Streaming Frequency to " << freqVal;
|
||||
det->setRxZmqFrequency(freqVal);
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " "
|
||||
LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " "
|
||||
<< qDefs::getUnitString(timeUnit);
|
||||
auto timeMS = qDefs::getMSTime(std::make_pair(timeVal, timeUnit));
|
||||
det->setRxZmqTimer(timeMS.count());
|
||||
@@ -654,7 +654,7 @@ void qTabPlot::SetStreamingFrequency() {
|
||||
}
|
||||
|
||||
void qTabPlot::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Plot Tab";
|
||||
LOG(logDEBUG) << "**Updating Plot Tab";
|
||||
|
||||
if (!plot->GetIsRunning()) {
|
||||
boxPlotType->setEnabled(true);
|
||||
@@ -687,5 +687,5 @@ void qTabPlot::Refresh() {
|
||||
chkGapPixels->setEnabled(false);
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << "**Updated Plot Tab";
|
||||
LOG(logDEBUG) << "**Updated Plot Tab";
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector)
|
||||
: QWidget(parent), det(detector) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Settings ready";
|
||||
LOG(logDEBUG) << "Settings ready";
|
||||
}
|
||||
|
||||
qTabSettings::~qTabSettings() {}
|
||||
@@ -93,7 +93,7 @@ void qTabSettings::SetupDetectorSettings() {
|
||||
item[(int)G4_LOWGAIN]->setEnabled(true);
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
|
||||
LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
|
||||
qDefs::Message(qDefs::CRITICAL,
|
||||
"Unknown detector type. Exiting GUI.",
|
||||
"qTabSettings::SetupDetectorSettings");
|
||||
@@ -120,7 +120,7 @@ void qTabSettings::Initialization() {
|
||||
}
|
||||
|
||||
void qTabSettings::GetSettings() {
|
||||
FILE_LOG(logDEBUG) << "Getting settings";
|
||||
LOG(logDEBUG) << "Getting settings";
|
||||
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(SetSettings(int)));
|
||||
try {
|
||||
@@ -151,7 +151,7 @@ void qTabSettings::SetSettings(int index) {
|
||||
// settings
|
||||
auto val = static_cast<slsDetectorDefs::detectorSettings>(index);
|
||||
try {
|
||||
FILE_LOG(logINFO) << "Setting Settings to " << sls::ToString(val);
|
||||
LOG(logINFO) << "Setting Settings to " << sls::ToString(val);
|
||||
det->setSettings(val);
|
||||
}
|
||||
CATCH_HANDLE("Could not set settings.", "qTabSettings::SetSettings", this,
|
||||
@@ -163,7 +163,7 @@ void qTabSettings::SetSettings(int index) {
|
||||
}
|
||||
|
||||
void qTabSettings::GetDynamicRange() {
|
||||
FILE_LOG(logDEBUG) << "Getting dynamic range";
|
||||
LOG(logDEBUG) << "Getting dynamic range";
|
||||
disconnect(comboDynamicRange, SIGNAL(activated(int)), this,
|
||||
SLOT(SetDynamicRange(int)));
|
||||
try {
|
||||
@@ -195,7 +195,7 @@ void qTabSettings::GetDynamicRange() {
|
||||
}
|
||||
|
||||
void qTabSettings::SetDynamicRange(int index) {
|
||||
FILE_LOG(logINFO) << "Setting dynamic range to "
|
||||
LOG(logINFO) << "Setting dynamic range to "
|
||||
<< comboDynamicRange->currentText().toAscii().data();
|
||||
try {
|
||||
switch (index) {
|
||||
@@ -222,7 +222,7 @@ void qTabSettings::SetDynamicRange(int index) {
|
||||
}
|
||||
|
||||
void qTabSettings::GetThresholdEnergy() {
|
||||
FILE_LOG(logDEBUG) << "Getting theshold energy";
|
||||
LOG(logDEBUG) << "Getting theshold energy";
|
||||
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this,
|
||||
SLOT(SetThresholdEnergy(int)));
|
||||
try {
|
||||
@@ -237,7 +237,7 @@ void qTabSettings::GetThresholdEnergy() {
|
||||
}
|
||||
|
||||
void qTabSettings::SetThresholdEnergy(int index) {
|
||||
FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
|
||||
LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
|
||||
try {
|
||||
det->setThresholdEnergy(index);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ void qTabSettings::SetThresholdEnergy(int index) {
|
||||
}
|
||||
|
||||
void qTabSettings::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Settings Tab";
|
||||
LOG(logDEBUG) << "**Updating Settings Tab";
|
||||
|
||||
if (comboSettings->isEnabled()) {
|
||||
GetSettings();
|
||||
@@ -261,5 +261,5 @@ void qTabSettings::Refresh() {
|
||||
if (spinThreshold->isEnabled())
|
||||
GetThresholdEnergy();
|
||||
|
||||
FILE_LOG(logDEBUG) << "**Updated Settings Tab";
|
||||
LOG(logDEBUG) << "**Updated Settings Tab";
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,13 +25,13 @@ int i2c_open(const char* file,unsigned int addr){
|
||||
//device file
|
||||
int fd = open( file, O_RDWR );
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Warning: Unable to open file %s\n",file));
|
||||
LOG(logERROR, ("Warning: Unable to open file %s\n",file));
|
||||
return -1;
|
||||
}
|
||||
|
||||
//device address
|
||||
if( ioctl( fd, I2C_SLAVE, addr&0x7F ) < 0 ) {
|
||||
FILE_LOG(logERROR, ("Warning: Unable to set slave address:0x%x \n",addr));
|
||||
LOG(logERROR, ("Warning: Unable to set slave address:0x%x \n",addr));
|
||||
return -2;
|
||||
}
|
||||
return fd;
|
||||
@@ -45,17 +45,17 @@ int i2c_read(){
|
||||
|
||||
unsigned char buf = reg;
|
||||
if (write(fd, &buf, 1)!= 1){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to write read request to register %d\n", reg));
|
||||
LOG(logERROR, ("Warning: Unable to write read request to register %d\n", reg));
|
||||
return -1;
|
||||
}
|
||||
//read and update value (but old value read out)
|
||||
if(read(fd, &buf, 1) != 1){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
return -2;
|
||||
}
|
||||
//read again to read the updated value
|
||||
if(read(fd, &buf, 1) != 1){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
|
||||
return -2;
|
||||
}
|
||||
close(fd);
|
||||
@@ -76,7 +76,7 @@ int i2c_write(unsigned int value){
|
||||
buf[0] = reg;
|
||||
buf[1] = val;
|
||||
if (write(fd, buf, 2) != 2) {
|
||||
FILE_LOG(logERROR, ("Warning: Unable to write %d to register %d\n",val, reg));
|
||||
LOG(logERROR, ("Warning: Unable to write %d to register %d\n",val, reg));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -92,10 +92,10 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
int fd = open(PORTNAME, O_RDWR | O_NOCTTY | O_SYNC);
|
||||
if(fd < 0){
|
||||
FILE_LOG(logERROR, ("Warning: Unable to open port %s\n", PORTNAME));
|
||||
LOG(logERROR, ("Warning: Unable to open port %s\n", PORTNAME));
|
||||
return -1;
|
||||
}
|
||||
FILE_LOG(logINFO, ("opened port at %s\n",PORTNAME));
|
||||
LOG(logINFO, ("opened port at %s\n",PORTNAME));
|
||||
|
||||
struct termios serial_conf;
|
||||
// reset structure
|
||||
@@ -110,17 +110,17 @@ int main(int argc, char* argv[]) {
|
||||
serial_conf.c_lflag = ICANON;
|
||||
// flush input
|
||||
if(tcflush(fd, TCIOFLUSH) < 0){
|
||||
FILE_LOG(logERROR, ("Warning: error form tcflush %d\n", errno));
|
||||
LOG(logERROR, ("Warning: error form tcflush %d\n", errno));
|
||||
return 0;
|
||||
}
|
||||
// set new options for the port, TCSANOW:changes occur immediately without waiting for data to complete
|
||||
if(tcsetattr(fd, TCSANOW, &serial_conf) < 0){
|
||||
FILE_LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(tcsetattr(fd, TCSAFLUSH, &serial_conf) < 0){
|
||||
FILE_LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -130,25 +130,25 @@ int main(int argc, char* argv[]) {
|
||||
char buffer[BUFFERSIZE];
|
||||
memset(buffer,0,BUFFERSIZE);
|
||||
buffer[BUFFERSIZE-1] = '\n';
|
||||
FILE_LOG(logINFO, ("Ready...\n"));
|
||||
LOG(logINFO, ("Ready...\n"));
|
||||
|
||||
|
||||
while(ret != GOODBYE){
|
||||
memset(buffer,0,BUFFERSIZE);
|
||||
n = read(fd,buffer,BUFFERSIZE);
|
||||
FILE_LOG(logDEBUG1, ("Received %d Bytes\n", n));
|
||||
FILE_LOG(logINFO, ("Got message: '%s'\n",buffer));
|
||||
LOG(logDEBUG1, ("Received %d Bytes\n", n));
|
||||
LOG(logINFO, ("Got message: '%s'\n",buffer));
|
||||
|
||||
switch(buffer[0]){
|
||||
case '\0':
|
||||
FILE_LOG(logINFO, ("Got Start (Detector restart)\n"));
|
||||
LOG(logINFO, ("Got Start (Detector restart)\n"));
|
||||
break;
|
||||
case 's':
|
||||
FILE_LOG(logINFO, ("Got Start \n"));
|
||||
LOG(logINFO, ("Got Start \n"));
|
||||
break;
|
||||
case 'p':
|
||||
if (!sscanf(&buffer[1],"%d",&ival)){
|
||||
FILE_LOG(logERROR, ("Warning: cannot scan voltage value\n"));
|
||||
LOG(logERROR, ("Warning: cannot scan voltage value\n"));
|
||||
break;
|
||||
}
|
||||
// ok/ fail
|
||||
@@ -158,9 +158,9 @@ int main(int argc, char* argv[]) {
|
||||
strcpy(buffer,"fail ");
|
||||
else
|
||||
strcpy(buffer,"success ");
|
||||
FILE_LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
FILE_LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
@@ -173,17 +173,17 @@ int main(int argc, char* argv[]) {
|
||||
else
|
||||
strcpy(buffer,"success ");
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
FILE_LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
FILE_LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
LOG(logINFO, ("Sending: '%s'\n",buffer));
|
||||
LOG(logDEBUG1, ("Sent %d Bytes\n", n));
|
||||
//value
|
||||
memset(buffer,0,BUFFERSIZE);
|
||||
buffer[BUFFERSIZE-1] = '\n';
|
||||
if(ival >= 0){
|
||||
FILE_LOG(logINFO, ("Sending: '%d'\n",ival));
|
||||
LOG(logINFO, ("Sending: '%d'\n",ival));
|
||||
sprintf(buffer,"%d ",ival);
|
||||
n = write(fd, buffer, BUFFERSIZE);
|
||||
FILE_LOG(logINFO, ("Sent %d Bytes\n", n));
|
||||
}else FILE_LOG(logERROR, ("%s\n",buffer));
|
||||
LOG(logINFO, ("Sent %d Bytes\n", n));
|
||||
}else LOG(logERROR, ("%s\n",buffer));
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
@@ -191,7 +191,7 @@ int main(int argc, char* argv[]) {
|
||||
ret = GOODBYE;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown Command. buffer:'%s'\n",buffer));
|
||||
LOG(logERROR, ("Unknown Command. buffer:'%s'\n",buffer));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ unsigned int BebInfo_GetSrcPort(struct BebInfo* bebInfo, int ten_gig) {return te
|
||||
|
||||
|
||||
void BebInfo_Print(struct BebInfo* bebInfo) {
|
||||
FILE_LOG(logINFO, (
|
||||
LOG(logINFO, (
|
||||
"%d) Beb Info:\n"
|
||||
"\tSerial Add: 0x%x\n"
|
||||
"\tMAC 1GbE: %s\n"
|
||||
@@ -133,7 +133,7 @@ void Beb_Beb(int id) {
|
||||
|
||||
if (!Beb_InitBebInfos()) exit(1);
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Printing Beb infos:\n"));
|
||||
LOG(logDEBUG1, ("Printing Beb infos:\n"));
|
||||
unsigned int i;
|
||||
for(i=1;i<bebInfoSize;i++) BebInfo_Print(&beb_infos[i]);
|
||||
|
||||
@@ -157,12 +157,12 @@ void Beb_GetModuleConfiguration(int* master, int* top, int* normal) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
} else {
|
||||
//read data
|
||||
ret = Beb_Read32(csp0base, MODULE_CONFIGURATION_MASK);
|
||||
FILE_LOG(logDEBUG1, ("Module Configuration OK\n"));
|
||||
FILE_LOG(logDEBUG1, ("Beb: value =0x%x\n",ret));
|
||||
LOG(logDEBUG1, ("Module Configuration OK\n"));
|
||||
LOG(logDEBUG1, ("Beb: value =0x%x\n",ret));
|
||||
if (ret&TOP_BIT_MASK) {
|
||||
*top = 1;
|
||||
Beb_top = 1;
|
||||
@@ -215,7 +215,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_COUNTER_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Delay read counter fail\n"));
|
||||
LOG(logERROR, ("Delay read counter fail\n"));
|
||||
return;
|
||||
} else {
|
||||
//read data first time
|
||||
@@ -227,7 +227,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
r_framepktMsbcounter = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
FILE_LOG(logDEBUG1, ("\nLeft\n"
|
||||
LOG(logDEBUG1, ("\nLeft\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
@@ -245,7 +245,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
while(1) {
|
||||
maxtimer = MAX(MAX(l_txndelaycounter,l_framedelaycounter),MAX(r_txndelaycounter,r_framedelaycounter));
|
||||
maxtimer /= 100;
|
||||
FILE_LOG(logDEBUG1, ("Will wait for %d us\n",maxtimer));
|
||||
LOG(logDEBUG1, ("Will wait for %d us\n",maxtimer));
|
||||
usleep(maxtimer);
|
||||
|
||||
//read new values
|
||||
@@ -257,7 +257,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
r_framepktMsbcounter_new = Beb_Read32(csp0base, addr_r_framepktMsbcounter);
|
||||
r_txndelaycounter_new = Beb_Read32(csp0base, addr_r_txndelaycounter);
|
||||
r_framedelaycounter_new = Beb_Read32(csp0base, addr_r_framedelaycounter);
|
||||
FILE_LOG(logDEBUG1, ("\nLeft\n"
|
||||
LOG(logDEBUG1, ("\nLeft\n"
|
||||
"FramepacketLsbcounter: %d\n"
|
||||
"FramepacketMsbcounter: %d\n"
|
||||
"Txndelaycounter:%d\n"
|
||||
@@ -288,7 +288,7 @@ void Beb_EndofDataSend(int tengiga) {
|
||||
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("Detector has sent all data\n"));
|
||||
LOG(logINFO, ("Detector has sent all data\n"));
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
@@ -310,14 +310,14 @@ int Beb_SetMasterViaSoftware() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Master FAIL\n"));
|
||||
LOG(logERROR, ("Set Master FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
|
||||
value|=MASTER_BIT;
|
||||
value|=OVERWRITE_HARDWARE_BIT;
|
||||
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value);
|
||||
if (newval!=value) {
|
||||
FILE_LOG(logERROR, ("Could not set Master via Software\n"));
|
||||
LOG(logERROR, ("Could not set Master via Software\n"));
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
@@ -343,14 +343,14 @@ int Beb_SetSlaveViaSoftware() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Slave FAIL\n"));
|
||||
LOG(logERROR, ("Set Slave FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
|
||||
value&=~MASTER_BIT;
|
||||
value|=OVERWRITE_HARDWARE_BIT;
|
||||
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value);
|
||||
if (newval!=value) {
|
||||
FILE_LOG(logERROR, ("Could not set Slave via Software\n"));
|
||||
LOG(logERROR, ("Could not set Slave via Software\n"));
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
@@ -371,11 +371,11 @@ int Beb_Activate(int enable) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Deactivate FAIL\n"));
|
||||
LOG(logERROR, ("Deactivate FAIL\n"));
|
||||
} else {
|
||||
if (enable > -1) {
|
||||
value = Beb_Read32(csp0base, MASTERCONFIG_OFFSET);
|
||||
FILE_LOG(logINFO, ("Deactivate register value before:%d\n",value));
|
||||
LOG(logINFO, ("Deactivate register value before:%d\n",value));
|
||||
if (enable)
|
||||
value&=~DEACTIVATE_BIT;
|
||||
else
|
||||
@@ -384,9 +384,9 @@ int Beb_Activate(int enable) {
|
||||
int newval = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,value);
|
||||
if (newval!=value) {
|
||||
if (enable) {
|
||||
FILE_LOG(logERROR, ("Could not activate via Software\n"));
|
||||
LOG(logERROR, ("Could not activate via Software\n"));
|
||||
} else {
|
||||
FILE_LOG(logERROR, ("Could not deactivate via Software\n"));
|
||||
LOG(logERROR, ("Could not deactivate via Software\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -396,9 +396,9 @@ int Beb_Activate(int enable) {
|
||||
else ret = 1;
|
||||
if (enable == -1) {
|
||||
if (ret) {
|
||||
FILE_LOG(logINFOBLUE, ("Detector is active. Register value:%d\n", value));
|
||||
LOG(logINFOBLUE, ("Detector is active. Register value:%d\n", value));
|
||||
} else {
|
||||
FILE_LOG(logERROR, ("Detector is deactivated! Register value:%d\n", value));
|
||||
LOG(logERROR, ("Detector is deactivated! Register value:%d\n", value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ int Beb_Set32bitOverflow(int val) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set overflow flag in 32 bit mode. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set overflow flag in 32 bit mode. FAIL\n"));
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
@@ -459,7 +459,7 @@ int Beb_GetTenGigaFlowControl() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get ten giga flow control. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get ten giga flow control. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@@ -471,13 +471,13 @@ int Beb_GetTenGigaFlowControl() {
|
||||
}
|
||||
|
||||
int Beb_SetTenGigaFlowControl(int value) {
|
||||
FILE_LOG(logINFO, ("Setting ten giga flow control to %d\n", value));
|
||||
LOG(logINFO, ("Setting ten giga flow control to %d\n", value));
|
||||
value = value == 0 ? 0 : 1;
|
||||
u_int32_t offset = FLOW_REG_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set ten giga flow control. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set ten giga flow control. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
// reset bit
|
||||
@@ -499,7 +499,7 @@ int Beb_GetTransmissionDelayFrame() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get transmission delay frame. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get transmission delay frame. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@@ -509,16 +509,16 @@ int Beb_GetTransmissionDelayFrame() {
|
||||
}
|
||||
|
||||
int Beb_SetTransmissionDelayFrame(int value) {
|
||||
FILE_LOG(logINFO, ("Setting transmission delay frame to %d\n", value));
|
||||
LOG(logINFO, ("Setting transmission delay frame to %d\n", value));
|
||||
if (value < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid transmission delay frame value %d\n", value));
|
||||
LOG(logERROR, ("Invalid transmission delay frame value %d\n", value));
|
||||
return 0;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_FRAME_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set transmission delay frame. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set transmission delay frame. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
Beb_Write32(csp0base, offset, value);
|
||||
@@ -532,7 +532,7 @@ int Beb_GetTransmissionDelayLeft() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get transmission delay left. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get transmission delay left. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@@ -542,16 +542,16 @@ int Beb_GetTransmissionDelayLeft() {
|
||||
}
|
||||
|
||||
int Beb_SetTransmissionDelayLeft(int value) {
|
||||
FILE_LOG(logINFO, ("Setting transmission delay left to %d\n", value));
|
||||
LOG(logINFO, ("Setting transmission delay left to %d\n", value));
|
||||
if (value < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid transmission delay left value %d\n", value));
|
||||
LOG(logERROR, ("Invalid transmission delay left value %d\n", value));
|
||||
return 0;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_LEFT_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set transmission delay left. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set transmission delay left. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
Beb_Write32(csp0base, offset, value);
|
||||
@@ -565,7 +565,7 @@ int Beb_GetTransmissionDelayRight() {
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to get transmission delay right. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to get transmission delay right. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
u_int32_t retval = Beb_Read32(csp0base, offset);
|
||||
@@ -575,16 +575,16 @@ int Beb_GetTransmissionDelayRight() {
|
||||
}
|
||||
|
||||
int Beb_SetTransmissionDelayRight(int value) {
|
||||
FILE_LOG(logINFO, ("Setting transmission delay right to %d\n", value));
|
||||
LOG(logINFO, ("Setting transmission delay right to %d\n", value));
|
||||
if (value < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid transmission delay right value %d\n", value));
|
||||
LOG(logERROR, ("Invalid transmission delay right value %d\n", value));
|
||||
return 0;
|
||||
}
|
||||
u_int32_t offset = TXM_DELAY_RIGHT_OFFSET;
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd <= 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set transmission delay right. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set transmission delay right. FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
Beb_Write32(csp0base, offset, value);
|
||||
@@ -617,12 +617,12 @@ int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val) {
|
||||
break;
|
||||
|
||||
|
||||
default: FILE_LOG(logERROR, ("Unrecognized mode in network parameter: %d\n",mode)); return -1;
|
||||
default: LOG(logERROR, ("Unrecognized mode in network parameter: %d\n",mode)); return -1;
|
||||
}
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Could not read register to set network parameter. FAIL\n"));
|
||||
LOG(logERROR, ("Could not read register to set network parameter. FAIL\n"));
|
||||
return -1;
|
||||
} else {
|
||||
if (val > -1) {
|
||||
@@ -655,11 +655,11 @@ int Beb_ResetToHardwareSettings() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Reset to Hardware Settings FAIL\n"));
|
||||
LOG(logERROR, ("Reset to Hardware Settings FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Write32(csp0base, MASTERCONFIG_OFFSET,0);
|
||||
if (value) {
|
||||
FILE_LOG(logERROR, ("Could not reset to hardware settings\n"));
|
||||
LOG(logERROR, ("Could not reset to hardware settings\n"));
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
@@ -682,11 +682,11 @@ u_int32_t Beb_GetFirmwareRevision() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_VERSION);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Firmware Revision Read FAIL\n"));
|
||||
LOG(logERROR, ("Firmware Revision Read FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, FIRMWARE_VERSION_OFFSET);
|
||||
if (!value) {
|
||||
FILE_LOG(logERROR, ("Firmware Revision Number does not exist in this version\n"));
|
||||
LOG(logERROR, ("Firmware Revision Number does not exist in this version\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -706,11 +706,11 @@ u_int32_t Beb_GetFirmwareSoftwareAPIVersion() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_VERSION);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Firmware Software API Version Read FAIL\n"));
|
||||
LOG(logERROR, ("Firmware Software API Version Read FAIL\n"));
|
||||
} else {
|
||||
value = Beb_Read32(csp0base, FIRMWARESOFTWARE_API_OFFSET);
|
||||
if (!value) {
|
||||
FILE_LOG(logERROR, ("Firmware Software API Version does not exist in this version\n"));
|
||||
LOG(logERROR, ("Firmware Software API Version does not exist in this version\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -731,14 +731,14 @@ void Beb_ResetFrameNumber() {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_SYS_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Reset Frame Number FAIL\n"));
|
||||
LOG(logERROR, ("Reset Frame Number FAIL\n"));
|
||||
} else {
|
||||
//write a 1
|
||||
Beb_Write32(csp0base, FRAME_NUM_RESET_OFFSET, 1);
|
||||
usleep(100000); //100ms
|
||||
//write a 0
|
||||
Beb_Write32(csp0base, FRAME_NUM_RESET_OFFSET, 0);
|
||||
FILE_LOG(logINFO, ("Frame Number Reset OK\n"));
|
||||
LOG(logINFO, ("Frame Number Reset OK\n"));
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
@@ -764,7 +764,7 @@ int Beb_InitBebInfos() {//file name at some point
|
||||
|
||||
int i0=Beb_detid,i1=0;
|
||||
if (Beb_GetBebInfoIndex(i0)) {
|
||||
FILE_LOG(logERROR, ("cant add beb. adding beb %d, beb number %d already added.\n",Beb_detid, i0));
|
||||
LOG(logERROR, ("cant add beb. adding beb %d, beb number %d already added.\n",Beb_detid, i0));
|
||||
exit(0);
|
||||
}
|
||||
struct BebInfo b1;
|
||||
@@ -798,7 +798,7 @@ int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac
|
||||
/******* if (!i) return 0;****************************/ //i must be greater than 0, zero is the global send
|
||||
BebInfo_SetHeaderInfo(&beb_infos[i],ten_gig,src_mac,src_ip,src_port);
|
||||
|
||||
FILE_LOG(logINFO, ("Printing Beb info number (%d) :\n",i));
|
||||
LOG(logINFO, ("Printing Beb info number (%d) :\n",i));
|
||||
BebInfo_Print(&beb_infos[i]);
|
||||
|
||||
return 1;
|
||||
@@ -813,7 +813,7 @@ int Beb_CheckSourceStuffBebInfo() {
|
||||
if (!Beb_SetHeaderData(
|
||||
BebInfo_GetBebNumber(&beb_infos[i]),0,"00:00:00:00:00:00","10.0.0.1",20000)||
|
||||
!Beb_SetHeaderData(BebInfo_GetBebNumber(&beb_infos[i]),1,"00:00:00:00:00:00","10.0.0.1",20000)) {
|
||||
FILE_LOG(logINFO, ("Error in BebInfo for module number %d.\n",BebInfo_GetBebNumber(&beb_infos[i])));
|
||||
LOG(logINFO, ("Error in BebInfo for module number %d.\n",BebInfo_GetBebNumber(&beb_infos[i])));
|
||||
BebInfo_Print(&beb_infos[i]);
|
||||
return 0;
|
||||
}
|
||||
@@ -826,10 +826,10 @@ unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb) {
|
||||
unsigned int i;
|
||||
for(i=1;i<bebInfoSize;i++)
|
||||
if (beb_numb==BebInfo_GetBebNumber(&beb_infos[i])) {
|
||||
FILE_LOG(logDEBUG1, ("*****found beb index:%d, for beb number:%d\n",i,beb_numb));
|
||||
LOG(logDEBUG1, ("*****found beb index:%d, for beb number:%d\n",i,beb_numb));
|
||||
return i;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("*****Returning 0\n"));
|
||||
LOG(logDEBUG1, ("*****Returning 0\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -841,7 +841,7 @@ int Beb_WriteTo(unsigned int index) {
|
||||
return 1;
|
||||
|
||||
if (index>=bebInfoSize) {
|
||||
FILE_LOG(logERROR, ("WriteTo index error.\n"));
|
||||
LOG(logERROR, ("WriteTo index error.\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -886,7 +886,7 @@ int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header
|
||||
|
||||
int fd = Beb_open(&csp0base,bram_phy_addr);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set up UDP Header FAIL\n"));
|
||||
LOG(logERROR, ("Set up UDP Header FAIL\n"));
|
||||
} else {
|
||||
//read data
|
||||
memcpy(csp0base+header_number*16, &udp_header, sizeof(udp_header));
|
||||
@@ -932,18 +932,18 @@ int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char*
|
||||
*/
|
||||
|
||||
if (!Beb_SetMAC(src_mac,&(udp_header.src_mac[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Source MAC to %s\n",src_mac));
|
||||
LOG(logINFO, ("Setting Source MAC to %s\n",src_mac));
|
||||
if (!Beb_SetIP(src_ip,&(udp_header.src_ip[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Source IP to %s\n",src_ip));
|
||||
LOG(logINFO, ("Setting Source IP to %s\n",src_ip));
|
||||
if (!Beb_SetPortNumber(src_port,&(udp_header.src_port[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Source port to %d\n",src_port));
|
||||
LOG(logINFO, ("Setting Source port to %d\n",src_port));
|
||||
|
||||
if (!Beb_SetMAC(dst_mac,&(udp_header.dst_mac[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Destination MAC to %s\n",dst_mac));
|
||||
LOG(logINFO, ("Setting Destination MAC to %s\n",dst_mac));
|
||||
if (!Beb_SetIP(dst_ip,&(udp_header.dst_ip[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Destination IP to %s\n",dst_ip));
|
||||
LOG(logINFO, ("Setting Destination IP to %s\n",dst_ip));
|
||||
if (!Beb_SetPortNumber(dst_port,&(udp_header.dst_port[0]))) return 0;
|
||||
FILE_LOG(logINFO, ("Setting Destination port to %d\n",dst_port));
|
||||
LOG(logINFO, ("Setting Destination port to %d\n",dst_port));
|
||||
|
||||
|
||||
Beb_AdjustIPChecksum(&udp_header);
|
||||
@@ -968,7 +968,7 @@ int Beb_SetMAC(char* mac, uint8_t* dst_ptr) {
|
||||
char *pch = strtok (macVal,":");
|
||||
while (pch != NULL) {
|
||||
if (strlen(pch)!=2) {
|
||||
FILE_LOG(logERROR, ("Error: in mac address -> %s\n",macVal));
|
||||
LOG(logERROR, ("Error: in mac address -> %s\n",macVal));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -987,7 +987,7 @@ int Beb_SetIP(char* ip, uint8_t* dst_ptr) {
|
||||
char *pch = strtok (ipVal,".");
|
||||
while (pch != NULL) {
|
||||
if (((i!=3) && ((strlen(pch)>3) || (strlen(pch)<1))) || ((i==3)&&((strlen(pch)<1) || (strlen(pch) > 3)))) {
|
||||
FILE_LOG(logERROR, ("Error: in ip address -> %s\n",ipVal));
|
||||
LOG(logERROR, ("Error: in ip address -> %s\n",ipVal));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1050,11 +1050,11 @@ int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, i
|
||||
|
||||
|
||||
Beb_send_data[1] = 0x62000000 | (!stop_read_when_fifo_empty) << 27 | (ten_gig==1) << 24 | packet_size << 14 | dst_number << 8 | npackets;
|
||||
FILE_LOG(logDEBUG1, ("Beb_send_data[1]:%X\n",Beb_send_data[1]));
|
||||
LOG(logDEBUG1, ("Beb_send_data[1]:%X\n",Beb_send_data[1]));
|
||||
Beb_send_data[2] = 0;
|
||||
|
||||
Beb_SwapDataFun(0,2,&(Beb_send_data[1]));
|
||||
FILE_LOG(logDEBUG1, ("Beb_send_data[1] Swapped:%X\n",Beb_send_data[1]));
|
||||
LOG(logDEBUG1, ("Beb_send_data[1] Swapped:%X\n",Beb_send_data[1]));
|
||||
|
||||
if (Beb_activated) {
|
||||
if (!Beb_WriteTo(i)) return 0;
|
||||
@@ -1085,7 +1085,7 @@ int Beb_StopAcquisition()
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_CMD_GENERATOR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Beb Stop Acquisition FAIL\n"));
|
||||
LOG(logERROR, ("Beb Stop Acquisition FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
//find value
|
||||
@@ -1098,7 +1098,7 @@ int Beb_StopAcquisition()
|
||||
Beb_Write32(csp0base, (LEFT_OFFSET + STOP_ACQ_OFFSET),(valuel&(~STOP_ACQ_BIT)));
|
||||
Beb_Write32(csp0base, (RIGHT_OFFSET + STOP_ACQ_OFFSET),(valuer&(~STOP_ACQ_BIT)));
|
||||
|
||||
FILE_LOG(logINFO, ("Beb Stop Acquisition OK\n"));
|
||||
LOG(logINFO, ("Beb Stop Acquisition OK\n"));
|
||||
//close file pointer
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
@@ -1116,7 +1116,7 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
unsigned int nl = Beb_readNLines;
|
||||
unsigned int npackets = (nl * maxnp) / maxnl;
|
||||
if ((nl * maxnp) % maxnl) {
|
||||
FILE_LOG(logERROR, ("Read N Lines is incorrect. Switching to Full Image Readout\n"));
|
||||
LOG(logERROR, ("Read N Lines is incorrect. Switching to Full Image Readout\n"));
|
||||
npackets = maxnp;
|
||||
}
|
||||
int in_two_requests = (npackets > MAX_PACKETS_PER_REQUEST) ? 1 : 0;
|
||||
@@ -1126,8 +1126,8 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
unsigned int header_size = 4; //4*64 bits
|
||||
unsigned int packet_size = ten_gig ? 0x200 : 0x80; // 4k or 1k packets
|
||||
|
||||
FILE_LOG(logDEBUG1, ("----Beb_RequestNImages Start----\n"));
|
||||
FILE_LOG(logINFO, ("beb_number:%d, ten_gig:%d,dst_number:%d, npackets:%d, "
|
||||
LOG(logDEBUG1, ("----Beb_RequestNImages Start----\n"));
|
||||
LOG(logINFO, ("beb_number:%d, ten_gig:%d,dst_number:%d, npackets:%d, "
|
||||
"Beb_bit_mode:%d, header_size:%d, nimages:%d, test_just_send_out_packets_no_wait:%d\n",
|
||||
beb_number, ten_gig, dst_number, npackets, Beb_bit_mode, header_size,
|
||||
nimages, test_just_send_out_packets_no_wait));
|
||||
@@ -1138,13 +1138,13 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_CMD_GENERATOR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Beb Request N Images FAIL\n"));
|
||||
LOG(logERROR, ("Beb Request N Images FAIL\n"));
|
||||
return 0;
|
||||
} else {
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < 10; i++)
|
||||
FILE_LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
}
|
||||
// Generating commands
|
||||
u_int32_t send_header_command = 0x62000000 | (!test_just_send_out_packets_no_wait) << 27 | (ten_gig==1) << 24 | header_size << 14 | 0;
|
||||
@@ -1152,8 +1152,8 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < 10; i++)
|
||||
FILE_LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
FILE_LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4))));
|
||||
LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
}
|
||||
//"0x20 << 8" is dst_number (0x00 for left, 0x20 for right)
|
||||
//Left
|
||||
@@ -1181,12 +1181,12 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < 10; i++)
|
||||
FILE_LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4)))); //*(ptrl+i));
|
||||
FILE_LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
LOG(logDEBUG1, ("%X\n",Beb_Read32(csp0base, (LEFT_OFFSET + i*4)))); //*(ptrl+i));
|
||||
LOG(logDEBUG1, ("%d\n",in_two_requests));
|
||||
}
|
||||
Beb_close(fd,csp0base);
|
||||
|
||||
FILE_LOG(logDEBUG1, ("----Beb_RequestNImages----\n"));
|
||||
LOG(logDEBUG1, ("----Beb_RequestNImages----\n"));
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -1194,7 +1194,7 @@ int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_nu
|
||||
|
||||
|
||||
int Beb_Test(unsigned int beb_number) {
|
||||
FILE_LOG(logINFO, ("Testing module number: %d\n",beb_number));
|
||||
LOG(logINFO, ("Testing module number: %d\n",beb_number));
|
||||
|
||||
|
||||
//int SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, string dst_mac, string dst_ip, unsigned int dst_port) {
|
||||
@@ -1202,14 +1202,14 @@ int Beb_Test(unsigned int beb_number) {
|
||||
|
||||
unsigned int index = Beb_GetBebInfoIndex(beb_number);
|
||||
if (!index) {
|
||||
FILE_LOG(logERROR, ("Error beb number (%d)not in list????\n",beb_number));
|
||||
LOG(logERROR, ("Error beb number (%d)not in list????\n",beb_number));
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int i;
|
||||
for(i=0;i<64;i++) {
|
||||
if (!Beb_SetUpUDPHeader(beb_number,0,i,"60:fb:42:f4:e3:d2","129.129.205.186",22000+i)) {
|
||||
FILE_LOG(logERROR, ("Error setting up header table....\n"));
|
||||
LOG(logERROR, ("Error setting up header table....\n"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1217,7 +1217,7 @@ int Beb_Test(unsigned int beb_number) {
|
||||
// SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty=1);
|
||||
for(i=0;i<64;i++) {
|
||||
if (!Beb_SendMultiReadRequest(beb_number,i%3+1,0,i,1,0,1)) {
|
||||
FILE_LOG(logERROR, ("Error requesting data....\n"));
|
||||
LOG(logERROR, ("Error requesting data....\n"));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1237,7 +1237,7 @@ int Beb_GetBebFPGATemp()
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_SYSMON_0_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
LOG(logERROR, ("Module Configuration FAIL\n"));
|
||||
} else {
|
||||
//read data
|
||||
ret = Beb_Read32(csp0base, FPGA_TEMP_OFFSET);
|
||||
@@ -1255,11 +1255,11 @@ void Beb_SetDetectorNumber(uint32_t detid) {
|
||||
return;
|
||||
|
||||
uint32_t swapid = Beb_swap_uint16(detid);
|
||||
//FILE_LOG(logINFO, "detector id %d swapped %d\n", detid, swapid));
|
||||
//LOG(logINFO, "detector id %d swapped %d\n", detid, swapid));
|
||||
u_int32_t* csp0base=0;
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
return;
|
||||
} else {
|
||||
uint32_t value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
||||
@@ -1267,24 +1267,24 @@ void Beb_SetDetectorNumber(uint32_t detid) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
||||
if ((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) {
|
||||
FILE_LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
}
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
||||
value &= UDP_HEADER_X_MSK; // to keep previous x value
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
||||
if ((value & UDP_HEADER_ID_MSK) != ((swapid << UDP_HEADER_ID_OFST) & UDP_HEADER_ID_MSK)) {
|
||||
FILE_LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector ID FAIL\n"));
|
||||
}
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
FILE_LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid));
|
||||
LOG(logINFO, ("Detector id %d set in UDP Header\n\n", detid));
|
||||
}
|
||||
|
||||
int Beb_SetQuad(int value) {
|
||||
if (value < 0)
|
||||
return OK;
|
||||
FILE_LOG(logINFO, ("Setting Quad to %d in Beb\n", value));
|
||||
LOG(logINFO, ("Setting Quad to %d in Beb\n", value));
|
||||
Beb_quadEnable = (value == 0 ? 0 : 1);
|
||||
return Beb_SetDetectorPosition(Beb_positions);
|
||||
}
|
||||
@@ -1300,7 +1300,7 @@ int* Beb_GetDetectorPosition() {
|
||||
int Beb_SetDetectorPosition(int pos[]) {
|
||||
if (!Beb_activated)
|
||||
return OK;
|
||||
FILE_LOG(logINFO, ("Got Position values %d %d...\n", pos[0],pos[1]));
|
||||
LOG(logINFO, ("Got Position values %d %d...\n", pos[0],pos[1]));
|
||||
|
||||
// save positions
|
||||
Beb_positions[0] = pos[0];
|
||||
@@ -1321,7 +1321,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
//open file pointer
|
||||
int fd = Beb_open(&csp0base,XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Detector Position FAIL\n"));
|
||||
LOG(logERROR, ("Set Detector Position FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
uint32_t value = 0;
|
||||
@@ -1333,7 +1333,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_LEFT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_LEFT_OFST);
|
||||
if ((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set row position for left port\n"));
|
||||
LOG(logERROR, ("Could not set row position for left port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
// x right
|
||||
@@ -1343,7 +1343,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_A_RIGHT_OFST, value | ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_A_RIGHT_OFST);
|
||||
if ((value & UDP_HEADER_X_MSK) != ((posval << UDP_HEADER_X_OFST) & UDP_HEADER_X_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set row position for right port\n"));
|
||||
LOG(logERROR, ("Could not set row position for right port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
@@ -1356,7 +1356,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_B_LEFT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_B_LEFT_OFST);
|
||||
if ((value & UDP_HEADER_Y_MSK) != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set column position for left port\n"));
|
||||
LOG(logERROR, ("Could not set column position for left port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
@@ -1367,7 +1367,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_B_RIGHT_OFST, value | ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK));
|
||||
value = Beb_Read32(csp0base, UDP_HEADER_B_RIGHT_OFST);
|
||||
if ((value & UDP_HEADER_Y_MSK) != ((posval << UDP_HEADER_Y_OFST) & UDP_HEADER_Y_MSK)) {
|
||||
FILE_LOG(logERROR, ("Could not set column position for right port\n"));
|
||||
LOG(logERROR, ("Could not set column position for right port\n"));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
@@ -1376,7 +1376,7 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
if (ret == OK) {
|
||||
FILE_LOG(logINFO, ("Position set to...\n"
|
||||
LOG(logINFO, ("Position set to...\n"
|
||||
"\tLeft: [%d, %d]\n"
|
||||
"\tRight:[%d, %d]\n",
|
||||
posLeft[0], posLeft[1], posRight[0], posRight[1]));
|
||||
@@ -1390,12 +1390,12 @@ int Beb_SetStartingFrameNumber(uint64_t value) {
|
||||
Beb_deactivatedStartFrameNumber = value;
|
||||
return OK;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Setting start frame number: %llu\n", (long long unsigned int)value));
|
||||
LOG(logINFO, ("Setting start frame number: %llu\n", (long long unsigned int)value));
|
||||
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Start Frame Number FAIL\n"));
|
||||
LOG(logERROR, ("Set Start Frame Number FAIL\n"));
|
||||
return FAIL;
|
||||
}
|
||||
// since the read is not implemented in firmware yet
|
||||
@@ -1407,7 +1407,7 @@ int Beb_SetStartingFrameNumber(uint64_t value) {
|
||||
Beb_Write32(csp0base, UDP_HEADER_FRAME_NUMBER_MSB_OFST, (valueInFirmware >> 32) & (0xffffffff));
|
||||
Beb_close(fd,csp0base);
|
||||
|
||||
FILE_LOG(logINFO, ("Going to reset Frame Number\n"));
|
||||
LOG(logINFO, ("Going to reset Frame Number\n"));
|
||||
Beb_ResetFrameNumber();
|
||||
return OK;
|
||||
}
|
||||
@@ -1418,11 +1418,11 @@ int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Getting start frame number\n"));
|
||||
LOG(logDEBUG1, ("Getting start frame number\n"));
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_COUNTER_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Get Start Frame Number FAIL\n"));
|
||||
LOG(logERROR, ("Get Start Frame Number FAIL\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -1440,7 +1440,7 @@ int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable) {
|
||||
|
||||
Beb_close(fd,csp0base);
|
||||
if (left1g != right1g) {
|
||||
FILE_LOG(logERROR, ("Retrieved inconsistent frame numbers from 1g left %llu and right %llu\n",
|
||||
LOG(logERROR, ("Retrieved inconsistent frame numbers from 1g left %llu and right %llu\n",
|
||||
(long long int)left1g, (long long int)right1g));
|
||||
*retval = (left1g > right1g) ? left1g : right1g; // give max to set it to when stopping acq & different value
|
||||
return -2; // to differentiate between failed address mapping
|
||||
@@ -1461,7 +1461,7 @@ int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable) {
|
||||
++right10g; // increment for firmware
|
||||
|
||||
if (left10g != right10g) {
|
||||
FILE_LOG(logERROR, ("Retrieved inconsistent frame numbers from `0g left %llu and right %llu\n",
|
||||
LOG(logERROR, ("Retrieved inconsistent frame numbers from `0g left %llu and right %llu\n",
|
||||
(long long int)left10g, (long long int)right10g));
|
||||
*retval = (left10g > right10g) ? left10g : right10g; // give max to set it to when stopping acq & different value
|
||||
return -2; // to differentiate between failed address mapping
|
||||
@@ -1484,15 +1484,15 @@ int Beb_open(u_int32_t** csp0base, u_int32_t offset) {
|
||||
|
||||
int fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
if (fd == -1) {
|
||||
FILE_LOG(logERROR, ("\nCan't find /dev/mem!\n"));
|
||||
LOG(logERROR, ("\nCan't find /dev/mem!\n"));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1, ("/dev/mem opened\n"));
|
||||
LOG(logDEBUG1, ("/dev/mem opened\n"));
|
||||
*csp0base = (u_int32_t*)mmap(0, BEB_MMAP_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, offset);
|
||||
if (*csp0base == MAP_FAILED) {
|
||||
FILE_LOG(logERROR, ("\nCan't map memmory area!!\n"));
|
||||
LOG(logERROR, ("\nCan't map memmory area!!\n"));
|
||||
fd = -1;
|
||||
}
|
||||
else FILE_LOG(logDEBUG1, ("CSP0 mapped %p\n",(void*)*csp0base));
|
||||
else LOG(logDEBUG1, ("CSP0 mapped %p\n",(void*)*csp0base));
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -55,7 +55,7 @@ void Feb_Interface_SendCompleteList(unsigned int n,unsigned int* list) {
|
||||
int Feb_Interface_WriteTo(unsigned int ch) {
|
||||
if (ch>0xfff) return 0;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("FIW ch %d\n", ch));
|
||||
LOG(logDEBUG1, ("FIW ch %d\n", ch));
|
||||
|
||||
Feb_Interface_send_data_raw[0] = 0x8fff0000;
|
||||
if (Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0;
|
||||
@@ -176,7 +176,7 @@ int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num, unsign
|
||||
start_address &= 0x3fff;
|
||||
nwrites &= 0x3ff;
|
||||
if (!nwrites||nwrites>Feb_Interface_send_buffer_size-2) {
|
||||
FILE_LOG(logERROR, ("invalid nwrites:%d\n",nwrites));
|
||||
LOG(logERROR, ("invalid nwrites:%d\n",nwrites));
|
||||
return 0;
|
||||
}//*d-1026
|
||||
|
||||
|
||||
@@ -8,18 +8,18 @@
|
||||
|
||||
|
||||
void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr) {
|
||||
FILE_LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n"));
|
||||
LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n"));
|
||||
ll->ll_fifo_base=0;
|
||||
ll->ll_fifo_ctrl_reg=0;
|
||||
if (Local_Init(ll,ll_fifo_badr)) {
|
||||
Local_Reset(ll);
|
||||
FILE_LOG(logDEBUG1, ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll)));
|
||||
} else FILE_LOG(logERROR, ("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr));
|
||||
LOG(logDEBUG1, ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll)));
|
||||
} else LOG(logERROR, ("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr));
|
||||
}
|
||||
|
||||
|
||||
void Local_LocalLinkInterface(struct LocalLinkInterface* ll) {
|
||||
FILE_LOG(logDEBUG1, ("Initializing new memory\n"));
|
||||
LOG(logDEBUG1, ("Initializing new memory\n"));
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ int Local_Reset(struct LocalLinkInterface* ll) {
|
||||
|
||||
int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask) {
|
||||
ll->ll_fifo_ctrl_reg |= rst_mask;
|
||||
FILE_LOG(logDEBUG1, ("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg));
|
||||
LOG(logDEBUG1, ("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg));
|
||||
|
||||
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
|
||||
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg);
|
||||
@@ -90,9 +90,9 @@ int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buf
|
||||
last_word = (buffer_len-1)/4;
|
||||
word_ptr = (unsigned int *)buffer;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base));
|
||||
LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base));
|
||||
for (i=0; i < buffer_len/4; i++)
|
||||
FILE_LOG(logDEBUG1, ("%.8X ",*(((unsigned *) buffer)+i)));
|
||||
LOG(logDEBUG1, ("%.8X ",*(((unsigned *) buffer)+i)));
|
||||
|
||||
while (words_send <= last_word)
|
||||
{
|
||||
@@ -101,7 +101,7 @@ int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buf
|
||||
status = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
|
||||
if ((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0) vacancy = 1;
|
||||
if (vacancy == 0) {
|
||||
FILE_LOG(logERROR, ("Fifo full!\n"));
|
||||
LOG(logERROR, ("Fifo full!\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
volatile unsigned int fifo_val;
|
||||
int sof = 0;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("LL Read - If: %X - Data: ",ll->ll_fifo_base));
|
||||
LOG(logDEBUG1, ("LL Read - If: %X - Data: ",ll->ll_fifo_base));
|
||||
|
||||
word_ptr = (unsigned int *)buffer;
|
||||
do
|
||||
@@ -162,7 +162,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
{
|
||||
if ( (buffer_len >> 2) > buffer_ptr)
|
||||
{
|
||||
FILE_LOG(logDEBUG1, ("%.8X ", fifo_val));
|
||||
LOG(logDEBUG1, ("%.8X ", fifo_val));
|
||||
word_ptr[buffer_ptr++] = fifo_val; //write to buffer
|
||||
}
|
||||
else
|
||||
@@ -174,7 +174,7 @@ int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
if (status & PLB_LL_FIFO_STATUS_LL_EOF)
|
||||
{
|
||||
len = (buffer_ptr << 2) -3 + ( (status & PLB_LL_FIFO_STATUS_LL_REM)>>PLB_LL_FIFO_STATUS_LL_REM_SHIFT );
|
||||
FILE_LOG(logDEBUG1, ("Len: %d\n",len));
|
||||
LOG(logDEBUG1, ("Len: %d\n",len));
|
||||
buffer_ptr = 0;
|
||||
return len;
|
||||
}
|
||||
@@ -207,11 +207,11 @@ int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buff
|
||||
|
||||
do{
|
||||
len = Local_Read(ll,rec_buff_len,rec_buffer);
|
||||
FILE_LOG(logDEBUG1, ("receive length: %i\n",len));
|
||||
LOG(logDEBUG1, ("receive length: %i\n",len));
|
||||
|
||||
if (len > 0) {
|
||||
rec_buffer[len]=0;
|
||||
FILE_LOG(logINFO, ("%s\n", (char*) rec_buffer));
|
||||
LOG(logINFO, ("%s\n", (char*) rec_buffer));
|
||||
}
|
||||
} while(len > 0);
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ void basictests() {
|
||||
initCheckDone = 0;
|
||||
memset(initErrorMessage, 0, MAX_STR_LENGTH);
|
||||
#ifdef VIRTUAL
|
||||
FILE_LOG(logINFOBLUE, ("************ EIGER Virtual Server *****************\n\n"));
|
||||
LOG(logINFOBLUE, ("************ EIGER Virtual Server *****************\n\n"));
|
||||
#endif
|
||||
uint32_t ipadd = getDetectorIP();
|
||||
uint64_t macadd = getDetectorMAC();
|
||||
@@ -116,7 +116,7 @@ void basictests() {
|
||||
int64_t sw_fw_apiversion = getFirmwareAPIVersion();
|
||||
int64_t client_sw_apiversion = getClientServerAPIVersion();
|
||||
|
||||
FILE_LOG(logINFOBLUE, ("**************** EIGER Server *********************\n\n"
|
||||
LOG(logINFOBLUE, ("**************** EIGER Server *********************\n\n"
|
||||
"Detector IP Addr:\t\t 0x%x\n"
|
||||
"Detector MAC Addr:\t\t 0x%llx\n"
|
||||
|
||||
@@ -150,7 +150,7 @@ void basictests() {
|
||||
//cant read versions
|
||||
if (!fwversion || !sw_fw_apiversion) {
|
||||
strcpy(initErrorMessage, "Cant read versions from FPGA. Please update firmware.\n");
|
||||
FILE_LOG(logERROR, (initErrorMessage));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ void basictests() {
|
||||
"Please update detector software (min. %lld) to be compatible with this firmware.\n",
|
||||
(long long int)sw_fw_apiversion,
|
||||
(long long int)REQUIRED_FIRMWARE_VERSION);
|
||||
FILE_LOG(logERROR, (initErrorMessage));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
@@ -172,11 +172,11 @@ void basictests() {
|
||||
"Please update firmware (min. %lld) to be compatible with this server.\n",
|
||||
(long long int)fwversion,
|
||||
(long long int)REQUIRED_FIRMWARE_VERSION);
|
||||
FILE_LOG(logERROR, (initErrorMessage));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Compatibility - success\n"));
|
||||
LOG(logINFO, ("Compatibility - success\n"));
|
||||
}
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ u_int64_t getDetectorMAC() {
|
||||
//increment by 1 for 10g
|
||||
if (send_to_ten_gig)
|
||||
res++;
|
||||
//FILE_LOG(logINFO, ("mac:%llx\n",res));
|
||||
//LOG(logINFO, ("mac:%llx\n",res));
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ u_int32_t getDetectorIP() {
|
||||
}
|
||||
strcpy(output,temp);
|
||||
sscanf(output, "%x", &res);
|
||||
//FILE_LOG(logINFO, ("ip:%x\n",res));
|
||||
//LOG(logINFO, ("ip:%x\n",res));
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -312,10 +312,10 @@ void initControlServer() {
|
||||
if (Feb_Control_OpenSerialCommunication())
|
||||
;// Feb_Control_CloseSerialCommunication();
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
|
||||
LOG(logDEBUG1, ("Control server: FEB Initialization done\n"));
|
||||
Beb_Beb(detid);
|
||||
Beb_SetDetectorNumber(getDetectorNumber());
|
||||
FILE_LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
|
||||
LOG(logDEBUG1, ("Control server: BEB Initialization done\n"));
|
||||
|
||||
setupDetector();
|
||||
// activate (if it gets ip) (later FW will deactivate at startup)
|
||||
@@ -340,7 +340,7 @@ void initStopServer() {
|
||||
Feb_Interface_FebInterface();
|
||||
Feb_Control_FebControl();
|
||||
Feb_Control_Init(master,top,normal,getDetectorNumber());
|
||||
FILE_LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||
LOG(logDEBUG1, ("Stop server: FEB Initialization done\n"));
|
||||
// activate (if it gets ip) (later FW will deactivate at startup)
|
||||
// also needed for stop server for status
|
||||
if (getDetectorIP() != 0) {
|
||||
@@ -368,7 +368,7 @@ void getModuleConfiguration() {
|
||||
#else
|
||||
normal = 1;
|
||||
#endif
|
||||
FILE_LOG(logINFOBLUE, ("Module: %s %s %s\n",
|
||||
LOG(logINFOBLUE, ("Module: %s %s %s\n",
|
||||
(top ? "TOP" : "BOTTOM"),
|
||||
(master ? "MASTER" : "SLAVE"),
|
||||
(normal ? "NORMAL" : "SPECIAL")));
|
||||
@@ -379,7 +379,7 @@ void getModuleConfiguration() {
|
||||
int *n=&normal;
|
||||
Beb_GetModuleConfiguration(m,t,n);
|
||||
if (isControlServer) {
|
||||
FILE_LOG(logINFOBLUE, ("Module: %s %s %s\n",
|
||||
LOG(logINFOBLUE, ("Module: %s %s %s\n",
|
||||
(top ? "TOP" : "BOTTOM"),
|
||||
(master ? "MASTER" : "SLAVE"),
|
||||
(normal ? "NORMAL" : "SPECIAL")));
|
||||
@@ -392,7 +392,7 @@ void getModuleConfiguration() {
|
||||
pclose(sysFile);
|
||||
sscanf(output,"%u",&detid);
|
||||
if (isControlServer) {
|
||||
FILE_LOG(logINFOBLUE, ("Detector ID: %u\n\n", detid));
|
||||
LOG(logINFOBLUE, ("Detector ID: %u\n\n", detid));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -402,15 +402,15 @@ void getModuleConfiguration() {
|
||||
/* set up detector */
|
||||
|
||||
void allocateDetectorStructureMemory() {
|
||||
FILE_LOG(logINFO, ("This Server is for 1 Eiger half module (250k)\n\n"));
|
||||
LOG(logINFO, ("This Server is for 1 Eiger half module (250k)\n\n"));
|
||||
|
||||
//Allocation of memory
|
||||
detectorModules = malloc(sizeof(sls_detector_module));
|
||||
detectorChans = malloc(NCHIP*NCHAN*sizeof(int));
|
||||
detectorDacs = malloc(NDAC*sizeof(int));
|
||||
FILE_LOG(logDEBUG1, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules));
|
||||
FILE_LOG(logDEBUG1, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans));
|
||||
FILE_LOG(logDEBUG1, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs));
|
||||
LOG(logDEBUG1, ("modules from 0x%x to 0x%x\n",detectorModules, detectorModules));
|
||||
LOG(logDEBUG1, ("chans from 0x%x to 0x%x\n",detectorChans, detectorChans));
|
||||
LOG(logDEBUG1, ("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs));
|
||||
(detectorModules)->dacs = detectorDacs;
|
||||
(detectorModules)->chanregs = detectorChans;
|
||||
(detectorModules)->ndac = NDAC;
|
||||
@@ -435,19 +435,19 @@ void setupDetector() {
|
||||
|
||||
allocateDetectorStructureMemory();
|
||||
//set dacs
|
||||
FILE_LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
{
|
||||
int i = 0;
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for(i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i,defaultvals[i],0);
|
||||
if ((detectorModules)->dacs[i] != defaultvals[i]) {
|
||||
FILE_LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], (detectorModules)->dacs[i]));
|
||||
LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], (detectorModules)->dacs[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FILE_LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||
LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||
//setting default measurement parameters
|
||||
setNumFrames(DEFAULT_NUM_FRAMES);
|
||||
setExpTime(DEFAULT_EXPTIME);
|
||||
@@ -476,7 +476,7 @@ void setupDetector() {
|
||||
#ifndef VIRTUAL
|
||||
Feb_Control_CheckSetup();
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1, ("Setup detector done\n\n"));
|
||||
LOG(logDEBUG1, ("Setup detector done\n\n"));
|
||||
}
|
||||
|
||||
|
||||
@@ -512,13 +512,13 @@ int readRegister(uint32_t offset, uint32_t* retval) {
|
||||
int setDynamicRange(int dr) {
|
||||
#ifdef VIRTUAL
|
||||
if (dr > 0) {
|
||||
FILE_LOG(logINFO, ("Setting dynamic range: %d\n", dr));
|
||||
LOG(logINFO, ("Setting dynamic range: %d\n", dr));
|
||||
eiger_dynamicrange = dr;
|
||||
}
|
||||
return eiger_dynamicrange;
|
||||
#else
|
||||
if (dr > 0) {
|
||||
FILE_LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
|
||||
LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
|
||||
if (Feb_Control_SetDynamicRange(dr)) {
|
||||
|
||||
//EigerSetBitMode(dr);
|
||||
@@ -527,7 +527,7 @@ int setDynamicRange(int dr) {
|
||||
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
|
||||
if (Beb_SetUpTransferParameters(dr))
|
||||
eiger_dynamicrange = dr;
|
||||
else FILE_LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
else LOG(logERROR, ("Could not set bit mode in the back end\n"));
|
||||
}
|
||||
}
|
||||
//make sure back end and front end have the same bit mode
|
||||
@@ -574,7 +574,7 @@ int getOverFlowMode() {
|
||||
|
||||
void setStoreInRamMode(int mode) {
|
||||
mode = (mode == 0 ? 0 : 1);
|
||||
FILE_LOG(logINFO, ("Setting Store in Ram mode to %d\n", mode));
|
||||
LOG(logINFO, ("Setting Store in Ram mode to %d\n", mode));
|
||||
eiger_storeinmem = mode;
|
||||
}
|
||||
|
||||
@@ -608,7 +608,7 @@ int getStartingFrameNumber(uint64_t* retval) {
|
||||
|
||||
void setNumFrames(int64_t val) {
|
||||
if (val > 0) {
|
||||
FILE_LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetNExposures((unsigned int)val * eiger_ntriggers)) {
|
||||
eiger_nexposures = val;
|
||||
@@ -631,7 +631,7 @@ int64_t getNumFrames() {
|
||||
|
||||
void setNumTriggers(int64_t val) {
|
||||
if (val > 0) {
|
||||
FILE_LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetNExposures((unsigned int)val * eiger_nexposures)) {
|
||||
eiger_ntriggers = val;
|
||||
@@ -652,7 +652,7 @@ int64_t getNumTriggers() {
|
||||
}
|
||||
|
||||
int setExpTime(int64_t val) {
|
||||
FILE_LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
Feb_Control_SetExposureTime(val/(1E9));
|
||||
#else
|
||||
@@ -670,7 +670,7 @@ int64_t getExpTime() {
|
||||
}
|
||||
|
||||
int setPeriod(int64_t val) {
|
||||
FILE_LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
Feb_Control_SetExposurePeriod(val/(1E9));
|
||||
#else
|
||||
@@ -688,7 +688,7 @@ int64_t getPeriod() {
|
||||
}
|
||||
|
||||
int setSubExpTime(int64_t val) {
|
||||
FILE_LOG(logINFO, ("Setting subexptime %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting subexptime %lld ns\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
// calculate subdeadtime before settings subexptime
|
||||
int64_t subdeadtime = Feb_Control_GetSubFramePeriod() - Feb_Control_GetSubFrameExposureTime();
|
||||
@@ -713,14 +713,14 @@ int64_t getSubExpTime() {
|
||||
}
|
||||
|
||||
int setDeadTime(int64_t val) {
|
||||
FILE_LOG(logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting subdeadtime %lld ns\n", (long long int)val));
|
||||
#ifndef VIRTUAL
|
||||
// get subexptime
|
||||
int64_t subexptime = Feb_Control_GetSubFrameExposureTime();
|
||||
#else
|
||||
int64_t subexptime = eiger_virtual_subexptime * 10;
|
||||
#endif
|
||||
FILE_LOG(logINFO, ("Setting sub period (subdeadtime(%lld)): %lldns\n",
|
||||
LOG(logINFO, ("Setting sub period (subdeadtime(%lld)): %lldns\n",
|
||||
(long long int)subexptime,
|
||||
(long long int)val),
|
||||
(long long int)(val + subexptime));
|
||||
@@ -771,7 +771,7 @@ int64_t getMeasuredSubPeriod() {
|
||||
int setModule(sls_detector_module myMod, char* mess) {
|
||||
|
||||
|
||||
FILE_LOG(logINFO, ("Setting module with settings %d\n",myMod.reg));
|
||||
LOG(logINFO, ("Setting module with settings %d\n",myMod.reg));
|
||||
|
||||
// settings
|
||||
setSettings( (enum detectorSettings)myMod.reg);
|
||||
@@ -781,9 +781,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
if (detectorModules) {
|
||||
if (copyModule(detectorModules,&myMod) == FAIL) {
|
||||
sprintf(mess, "Could not copy module\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@@ -791,9 +791,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
// iodelay
|
||||
if (setIODelay(myMod.iodelay)!= myMod.iodelay) {
|
||||
sprintf(mess, "Could not set module. Could not set iodelay %d\n", myMod.iodelay);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -803,7 +803,7 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
else {
|
||||
// (loading a random trim file) (dont return fail)
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
}
|
||||
|
||||
// dacs
|
||||
@@ -813,9 +813,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
setDAC((enum DACINDEX)i, myMod.dacs[i] , 0);
|
||||
if (myMod.dacs[i] != (detectorModules)->dacs[i]) {
|
||||
sprintf(mess, "Could not set module. Could not set dac %d\n", i);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@@ -823,9 +823,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
// trimbits
|
||||
#ifndef VIRTUAL
|
||||
if (myMod.nchan == 0) {
|
||||
FILE_LOG(logINFO, ("Setting module without trimbits\n"));
|
||||
LOG(logINFO, ("Setting module without trimbits\n"));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Setting module with trimbits\n"));
|
||||
LOG(logINFO, ("Setting module with trimbits\n"));
|
||||
//includ gap pixels
|
||||
unsigned int tt[263680];
|
||||
int iy, ichip, ix, ip = 0, ich = 0;
|
||||
@@ -844,9 +844,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
//set trimbits
|
||||
if (!Feb_Control_SetTrimbits(Feb_Control_GetModuleNumber(), tt)) {
|
||||
sprintf(mess, "Could not set module. Could not set trimbits\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@@ -859,9 +859,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
setRateCorrection(0);
|
||||
sprintf(mess,"Cannot set module. Cannot set Rate correction. "
|
||||
"No default tau provided. Deactivating Rate Correction\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@@ -872,9 +872,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
int64_t retvalTau = setRateCorrection(myMod.tau);
|
||||
if (myMod.tau != retvalTau) {
|
||||
sprintf(mess, "Cannot set module. Could not set rate correction\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
FILE_LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@@ -923,7 +923,7 @@ enum detectorSettings setSettings(enum detectorSettings sett) {
|
||||
return thisSettings;
|
||||
}if (sett != GET_SETTINGS)
|
||||
thisSettings = sett;
|
||||
FILE_LOG(logINFO, ("Settings: %d\n", thisSettings));
|
||||
LOG(logINFO, ("Settings: %d\n", thisSettings));
|
||||
return thisSettings;
|
||||
}
|
||||
|
||||
@@ -939,13 +939,13 @@ enum detectorSettings getSettings() {
|
||||
/* parameters - threshold */
|
||||
|
||||
int getThresholdEnergy() {
|
||||
FILE_LOG(logDEBUG1, ("Getting Threshold energy\n"));
|
||||
LOG(logDEBUG1, ("Getting Threshold energy\n"));
|
||||
return eiger_photonenergy;
|
||||
}
|
||||
|
||||
|
||||
int setThresholdEnergy(int ev) {
|
||||
FILE_LOG(logINFO, ("Setting threshold energy:%d\n",ev));
|
||||
LOG(logINFO, ("Setting threshold energy:%d\n",ev));
|
||||
if (ev >= 0)
|
||||
eiger_photonenergy = ev;
|
||||
return getThresholdEnergy();
|
||||
@@ -962,7 +962,7 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
if (val < 0)
|
||||
return;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, (mV ? "mV" : "dac units")));
|
||||
LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, (mV ? "mV" : "dac units")));
|
||||
|
||||
if (ind == E_VTHRESHOLD) {
|
||||
setDAC(E_VCMP_LL, val, mV);
|
||||
@@ -975,7 +975,7 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
|
||||
// validate index
|
||||
if (ind < 0 || ind >= NDAC) {
|
||||
FILE_LOG(logERROR, ("\tDac index %d is out of bounds (0 to %d)\n", ind, NDAC - 1));
|
||||
LOG(logERROR, ("\tDac index %d is out of bounds (0 to %d)\n", ind, NDAC - 1));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1013,24 +1013,24 @@ int getDAC(enum DACINDEX ind, int mV) {
|
||||
(ret[1]==ret[2])&&
|
||||
(ret[2]==ret[3]) &&
|
||||
(ret[3]==ret[4])) {
|
||||
FILE_LOG(logINFO, ("\tvthreshold match\n"));
|
||||
LOG(logINFO, ("\tvthreshold match\n"));
|
||||
return ret[0];
|
||||
} else {
|
||||
FILE_LOG(logERROR, ("\tvthreshold mismatch vcmp_ll:%d vcmp_lr:%d vcmp_rl:%d vcmp_rr:%d vcp:%d\n",
|
||||
LOG(logERROR, ("\tvthreshold mismatch vcmp_ll:%d vcmp_lr:%d vcmp_rl:%d vcmp_rr:%d vcp:%d\n",
|
||||
ret[0],ret[1],ret[2],ret[3], ret[4]));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mV) {
|
||||
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac\n",ind, (detectorModules)->dacs[ind]));
|
||||
LOG(logDEBUG1, ("Getting DAC %d : %d dac\n",ind, (detectorModules)->dacs[ind]));
|
||||
return (detectorModules)->dacs[ind];
|
||||
}
|
||||
int voltage = -1;
|
||||
// dac units to voltage
|
||||
ConvertToDifferentRange(LTC2620_MIN_VAL, LTC2620_MAX_VAL, DAC_MIN_MV, DAC_MAX_MV,
|
||||
(detectorModules)->dacs[ind], &voltage);
|
||||
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac (%d mV)\n",ind, (detectorModules)->dacs[ind], voltage));
|
||||
LOG(logDEBUG1, ("Getting DAC %d : %d dac (%d mV)\n",ind, (detectorModules)->dacs[ind], voltage));
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@@ -1072,7 +1072,7 @@ int getADC(enum ADCINDEX ind) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("Temperature %s: %f°C\n", tempnames[ind], (double)retval/1000.00));
|
||||
LOG(logINFO, ("Temperature %s: %f°C\n", tempnames[ind], (double)retval/1000.00));
|
||||
|
||||
return retval;
|
||||
#endif
|
||||
@@ -1106,13 +1106,13 @@ int setHighVoltage(int val) {
|
||||
|
||||
// get
|
||||
if (!Feb_Control_GetHighVoltage(&eiger_highvoltage)) {
|
||||
FILE_LOG(logERROR, ("Could not read high voltage\n"));
|
||||
LOG(logERROR, ("Could not read high voltage\n"));
|
||||
return -3;
|
||||
}
|
||||
|
||||
// tolerance of 5
|
||||
if (abs(eiger_theo_highvoltage-eiger_highvoltage) > HIGH_VOLTAGE_TOLERANCE) {
|
||||
FILE_LOG(logINFO, ("High voltage still ramping: %d\n", eiger_highvoltage));
|
||||
LOG(logINFO, ("High voltage still ramping: %d\n", eiger_highvoltage));
|
||||
return eiger_highvoltage;
|
||||
}
|
||||
return eiger_theo_highvoltage;
|
||||
@@ -1146,10 +1146,10 @@ void setTiming( enum timingMode arg) {
|
||||
ret = 3;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
|
||||
LOG(logERROR, ("Unknown timing mode %d\n", arg));
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
|
||||
LOG(logDEBUG1, ("Setting Triggering Mode: %d\n", (int)ret));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetTriggerMode(ret,1))
|
||||
#endif
|
||||
@@ -1168,7 +1168,7 @@ enum timingMode getTiming() {
|
||||
case 3:
|
||||
return GATED;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown trigger mode found %d\n", eiger_triggermode));
|
||||
LOG(logERROR, ("Unknown trigger mode found %d\n", eiger_triggermode));
|
||||
return GET_TIMING_MODE;
|
||||
}
|
||||
}
|
||||
@@ -1186,7 +1186,7 @@ int configureMAC() {
|
||||
int destport = udpDetails.dstport;
|
||||
int destport2 = udpDetails.dstport2;
|
||||
|
||||
FILE_LOG(logINFO, ("Configuring MAC\n"));
|
||||
LOG(logINFO, ("Configuring MAC\n"));
|
||||
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, sourcemac);
|
||||
@@ -1194,7 +1194,7 @@ int configureMAC() {
|
||||
getIpAddressinString(src_ip, sourceip);
|
||||
getIpAddressinString(dst_ip, destip);
|
||||
|
||||
FILE_LOG(logINFO, (
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
@@ -1209,13 +1209,13 @@ int configureMAC() {
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d, port2:%d)\n", cDestIp, destport, destport2));
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d, port2:%d)\n", cDestIp, destport, destport2));
|
||||
if (setUDPDestinationDetails(0, cDestIp, destport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (setUDPDestinationDetails(1, cDestIp, destport2) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port2\n"));
|
||||
LOG(logERROR, ("could not set udp destination IP and port2\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
@@ -1227,13 +1227,13 @@ int configureMAC() {
|
||||
if (!top)
|
||||
dst_port = destport2;
|
||||
|
||||
FILE_LOG(logINFO, ("\tDest Port : %d\n", dst_port));
|
||||
LOG(logINFO, ("\tDest Port : %d\n", dst_port));
|
||||
|
||||
int i=0;
|
||||
/* for(i=0;i<32;i++) { modified for Aldo*/
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
|
||||
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) {
|
||||
FILE_LOG(logDEBUG1, ("\tset up left ok\n"));
|
||||
LOG(logDEBUG1, ("\tset up left ok\n"));
|
||||
} else {
|
||||
return FAIL;
|
||||
}
|
||||
@@ -1243,12 +1243,12 @@ int configureMAC() {
|
||||
dst_port = destport2;
|
||||
if (!top)
|
||||
dst_port = destport;
|
||||
FILE_LOG(logINFO, ("\tDest Port : %d\n",dst_port));
|
||||
LOG(logINFO, ("\tDest Port : %d\n",dst_port));
|
||||
|
||||
/*for(i=0;i<32;i++) {*//** modified for Aldo*/
|
||||
if (Beb_SetBebSrcHeaderInfos(beb_num,send_to_ten_gig,src_mac,src_ip,src_port) &&
|
||||
Beb_SetUpUDPHeader(beb_num,send_to_ten_gig,header_number+i,dst_mac,dst_ip, dst_port)) {
|
||||
FILE_LOG(logDEBUG1, (" set up right ok\n"));
|
||||
LOG(logDEBUG1, (" set up right ok\n"));
|
||||
} else {
|
||||
return FAIL;
|
||||
}
|
||||
@@ -1344,7 +1344,7 @@ int getReadNLines() {
|
||||
|
||||
int enableTenGigabitEthernet(int val) {
|
||||
if (val!=-1) {
|
||||
FILE_LOG(logINFO, ("Setting 10Gbe: %d\n", (val > 0) ? 1 : 0));
|
||||
LOG(logINFO, ("Setting 10Gbe: %d\n", (val > 0) ? 1 : 0));
|
||||
if (val>0)
|
||||
send_to_ten_gig = 1;
|
||||
else
|
||||
@@ -1359,11 +1359,11 @@ int enableTenGigabitEthernet(int val) {
|
||||
/* eiger specific - iodelay, pulse, rate, temp, activate, delay nw parameter */
|
||||
int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
if (ind != RUN_CLK) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index: %d\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index: %d\n", ind));
|
||||
return FAIL;
|
||||
}
|
||||
if (val >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting Read out Speed: %d\n", val));
|
||||
LOG(logINFO, ("Setting Read out Speed: %d\n", val));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetReadoutSpeed(val))
|
||||
#endif
|
||||
@@ -1374,7 +1374,7 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
|
||||
int getClockDivider(enum CLKINDEX ind) {
|
||||
if (ind != RUN_CLK) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index: %d\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index: %d\n", ind));
|
||||
return FAIL;
|
||||
}
|
||||
return eiger_readoutspeed;
|
||||
@@ -1382,7 +1382,7 @@ int getClockDivider(enum CLKINDEX ind) {
|
||||
|
||||
int setIODelay(int val) {
|
||||
if (val!=-1) {
|
||||
FILE_LOG(logDEBUG1, ("Setting IO Delay: %d\n",val));
|
||||
LOG(logDEBUG1, ("Setting IO Delay: %d\n",val));
|
||||
#ifndef VIRTUAL
|
||||
if (Feb_Control_SetIDelays(Feb_Control_GetModuleNumber(),val))
|
||||
#endif
|
||||
@@ -1394,7 +1394,7 @@ int setIODelay(int val) {
|
||||
|
||||
int setCounterBit(int val) {
|
||||
if (val!=-1) {
|
||||
FILE_LOG(logINFO, ("Setting Counter Bit: %d\n",val));
|
||||
LOG(logINFO, ("Setting Counter Bit: %d\n",val));
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_counter_bit = val;
|
||||
#else
|
||||
@@ -1458,10 +1458,10 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
//same setting
|
||||
if ((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)) {
|
||||
if (eiger_dynamicrange == 32) {
|
||||
FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
(long long int)tau_in_nsec,(long long int)ratetable_period_in_nsec));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
(long long int)tau_in_nsec,(long long int)ratetable_period_in_nsec));
|
||||
}
|
||||
}
|
||||
@@ -1475,7 +1475,7 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
}
|
||||
//activating rate correction
|
||||
eiger_virtual_ratecorrection_variable = 1;
|
||||
FILE_LOG(logINFO, ("Rate Correction Value set to %lld ns\n",(long long int)eiger_virtual_ratetable_tau_in_ns));
|
||||
LOG(logINFO, ("Rate Correction Value set to %lld ns\n",(long long int)eiger_virtual_ratetable_tau_in_ns));
|
||||
|
||||
return eiger_virtual_ratetable_tau_in_ns;
|
||||
#else
|
||||
@@ -1504,10 +1504,10 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
//same setting
|
||||
if ((tau_in_nsec == custom_tau_in_nsec) && (ratetable_period_in_nsec == actual_period)) {
|
||||
if (dr == 32) {
|
||||
FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same subexptime %lldns\n",
|
||||
tau_in_nsec,ratetable_period_in_nsec));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
LOG(logINFO, ("Rate Table already created before: Same Tau %lldns, Same exptime %lldns\n",
|
||||
tau_in_nsec,ratetable_period_in_nsec));
|
||||
}
|
||||
}
|
||||
@@ -1515,14 +1515,14 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
|
||||
else {
|
||||
int ret = Feb_Control_SetRateCorrectionTau(custom_tau_in_nsec);
|
||||
if (ret<=0) {
|
||||
FILE_LOG(logERROR, ("Rate correction failed. Deactivating rate correction\n"));
|
||||
LOG(logERROR, ("Rate correction failed. Deactivating rate correction\n"));
|
||||
Feb_Control_SetRateCorrectionVariable(0);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
//activating rate correction
|
||||
Feb_Control_SetRateCorrectionVariable(1);
|
||||
FILE_LOG(logINFO, ("Rate Correction Value set to %lld ns\n", (long long int)Feb_Control_Get_RateTable_Tau_in_nsec()));
|
||||
LOG(logINFO, ("Rate Correction Value set to %lld ns\n", (long long int)Feb_Control_Get_RateTable_Tau_in_nsec()));
|
||||
Feb_Control_PrintCorrectedValues();
|
||||
|
||||
return Feb_Control_Get_RateTable_Tau_in_nsec();
|
||||
@@ -1543,7 +1543,7 @@ int getDefaultSettingsTau_in_nsec() {
|
||||
|
||||
void setDefaultSettingsTau_in_nsec(int t) {
|
||||
default_tau_from_file = t;
|
||||
FILE_LOG(logINFO, ("Default tau set to %d\n", default_tau_from_file));
|
||||
LOG(logINFO, ("Default tau set to %d\n", default_tau_from_file));
|
||||
}
|
||||
|
||||
int64_t getCurrentTau() {
|
||||
@@ -1572,7 +1572,7 @@ void setExternalGating(int enable[]) {
|
||||
int setAllTrimbits(int val) {
|
||||
#ifndef VIRTUAL
|
||||
if (!Feb_Control_SaveAllTrimbitsTo(val)) {
|
||||
FILE_LOG(logERROR, ("Could not set all trimbits\n"));
|
||||
LOG(logERROR, ("Could not set all trimbits\n"));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
@@ -1583,7 +1583,7 @@ int setAllTrimbits(int val) {
|
||||
}
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("All trimbits have been set to %d\n", val));
|
||||
LOG(logINFO, ("All trimbits have been set to %d\n", val));
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1599,7 +1599,7 @@ int getAllTrimbits() {
|
||||
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO, ("Value of all Trimbits: %d\n", value));
|
||||
LOG(logINFO, ("Value of all Trimbits: %d\n", value));
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -1711,7 +1711,7 @@ int setTransmissionDelayRight(int value) {
|
||||
|
||||
int prepareAcquisition() {
|
||||
#ifndef VIRTUAL
|
||||
FILE_LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit()));
|
||||
LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit()));
|
||||
Feb_Control_PrepareForAcquisition();
|
||||
#endif
|
||||
return OK;
|
||||
@@ -1728,15 +1728,15 @@ int startStateMachine() {
|
||||
if(createUDPSocket(1) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
eiger_virtual_status = 1;
|
||||
eiger_virtual_stop = 0;
|
||||
if (pthread_create(&eiger_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
FILE_LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
eiger_virtual_status = 0;
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO ,("Virtual Acquisition started\n"));
|
||||
LOG(logINFO ,("Virtual Acquisition started\n"));
|
||||
return OK;
|
||||
#else
|
||||
|
||||
@@ -1744,21 +1744,21 @@ int startStateMachine() {
|
||||
//get the DAQ toggle bit
|
||||
prev_flag = Feb_Control_AcquisitionStartedBit();
|
||||
|
||||
FILE_LOG(logINFO, ("Going to start acquisition\n"));
|
||||
LOG(logINFO, ("Going to start acquisition\n"));
|
||||
Feb_Control_StartAcquisition();
|
||||
|
||||
if (!eiger_storeinmem) {
|
||||
FILE_LOG(logINFO, ("requesting images right after start\n"));
|
||||
LOG(logINFO, ("requesting images right after start\n"));
|
||||
ret = startReadOut();
|
||||
}
|
||||
|
||||
//wait for acquisition start
|
||||
if (ret == OK) {
|
||||
if (!Feb_Control_WaitForStartedFlag(5000, prev_flag)) {
|
||||
FILE_LOG(logERROR, ("Acquisition did not FILE_LOG(logERROR ouble reading register\n"));
|
||||
LOG(logERROR, ("Acquisition did not LOG(logERROR ouble reading register\n"));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("Acquisition started\n"));
|
||||
LOG(logINFOGREEN, ("Acquisition started\n"));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -1779,7 +1779,7 @@ void* start_timer(void* arg) {
|
||||
int numPacketsPerFrame = (tgEnable ? 4 : 16) * dr;
|
||||
int npixelsx = 256 * 2 * bytesPerPixel;
|
||||
int databytes = 256 * 256 * 2 * bytesPerPixel;
|
||||
FILE_LOG(logINFO, (" dr:%f\n bytesperpixel:%d\n tgenable:%d\n datasize:%d\n packetsize:%d\n numpackes:%d\n npixelsx:%d\n databytes:%d\n",
|
||||
LOG(logINFO, (" dr:%f\n bytesperpixel:%d\n tgenable:%d\n datasize:%d\n packetsize:%d\n numpackes:%d\n npixelsx:%d\n databytes:%d\n",
|
||||
dr, bytesPerPixel, tgEnable, datasize, packetsize, numPacketsPerFrame, npixelsx, databytes));
|
||||
|
||||
|
||||
@@ -1855,7 +1855,7 @@ void* start_timer(void* arg) {
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
@@ -1873,7 +1873,7 @@ void* start_timer(void* arg) {
|
||||
closeUDPSocket(1);
|
||||
|
||||
eiger_virtual_status = 0;
|
||||
FILE_LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
@@ -1882,13 +1882,13 @@ void* start_timer(void* arg) {
|
||||
|
||||
|
||||
int stopStateMachine() {
|
||||
FILE_LOG(logINFORED, ("Going to stop acquisition\n"));
|
||||
LOG(logINFORED, ("Going to stop acquisition\n"));
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_stop = 0;
|
||||
return OK;
|
||||
#else
|
||||
if ((Feb_Control_StopAcquisition() != STATUS_IDLE) || (!Beb_StopAcquisition()) ) {
|
||||
FILE_LOG(logERROR, ("failed to stop acquisition\n"));
|
||||
LOG(logERROR, ("failed to stop acquisition\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -1914,7 +1914,7 @@ int softwareTrigger() {
|
||||
|
||||
int startReadOut() {
|
||||
|
||||
FILE_LOG(logINFO, ("Requesting images...\n"));
|
||||
LOG(logINFO, ("Requesting images...\n"));
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#else
|
||||
@@ -1945,10 +1945,10 @@ int startReadOut() {
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (eiger_virtual_status == 0) {
|
||||
FILE_LOG(logINFO, ("Status: IDLE\n"));
|
||||
LOG(logINFO, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Status: RUNNING...\n"));
|
||||
LOG(logINFO, ("Status: RUNNING...\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#else
|
||||
@@ -1956,13 +1956,13 @@ enum runStatus getRunStatus() {
|
||||
int i = Feb_Control_AcquisitionInProgress();
|
||||
switch (i) {
|
||||
case STATUS_ERROR:
|
||||
FILE_LOG(logERROR, ("Status: ERROR reading status register\n"));
|
||||
LOG(logERROR, ("Status: ERROR reading status register\n"));
|
||||
return ERROR;
|
||||
case STATUS_IDLE:
|
||||
FILE_LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
default:
|
||||
FILE_LOG(logINFOBLUE, ("Status: RUNNING...\n"));
|
||||
LOG(logINFOBLUE, ("Status: RUNNING...\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
|
||||
@@ -1978,22 +1978,22 @@ void readFrame(int *ret, char *mess) {
|
||||
while(eiger_virtual_status == 1){
|
||||
usleep(500);
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||
LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||
return;
|
||||
#else
|
||||
|
||||
if (Feb_Control_WaitForFinishedFlag(5000) == STATUS_ERROR) {
|
||||
FILE_LOG(logERROR, ("Waiting for finished flag\n"));
|
||||
LOG(logERROR, ("Waiting for finished flag\n"));
|
||||
*ret = FAIL;
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("Acquisition finished\n"));
|
||||
LOG(logINFOGREEN, ("Acquisition finished\n"));
|
||||
|
||||
if (eiger_storeinmem) {
|
||||
FILE_LOG(logINFO, ("requesting images after storing in memory\n"));
|
||||
LOG(logINFO, ("requesting images after storing in memory\n"));
|
||||
if (startReadOut() == FAIL) {
|
||||
strcpy(mess,"Could not execute read image requests\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
*ret = (int)FAIL;
|
||||
return;
|
||||
}
|
||||
@@ -2001,7 +2001,7 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
//wait for detector to send
|
||||
Beb_EndofDataSend(send_to_ten_gig);
|
||||
FILE_LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
|
||||
LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2020,7 +2020,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
int idac, ichan;
|
||||
int ret=OK;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Copying module\n"));
|
||||
LOG(logDEBUG1, ("Copying module\n"));
|
||||
|
||||
if (srcMod->serialnumber>=0) {
|
||||
|
||||
@@ -2028,16 +2028,16 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
}
|
||||
//no trimbit feature
|
||||
if (destMod->nchan && ((srcMod->nchan)>(destMod->nchan))) {
|
||||
FILE_LOG(logINFO, ("Number of channels of source is larger than number of channels of destination\n"));
|
||||
LOG(logINFO, ("Number of channels of source is larger than number of channels of destination\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if ((srcMod->ndac)>(destMod->ndac)) {
|
||||
FILE_LOG(logINFO, ("Number of dacs of source is larger than number of dacs of destination\n"));
|
||||
LOG(logINFO, ("Number of dacs of source is larger than number of dacs of destination\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1, ("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac));
|
||||
FILE_LOG(logDEBUG1, ("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan));
|
||||
LOG(logDEBUG1, ("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac));
|
||||
LOG(logDEBUG1, ("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan));
|
||||
destMod->ndac=srcMod->ndac;
|
||||
destMod->nchip=srcMod->nchip;
|
||||
destMod->nchan=srcMod->nchan;
|
||||
@@ -2049,7 +2049,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
destMod->tau=srcMod->tau;
|
||||
if (srcMod->eV>=0)
|
||||
destMod->eV=srcMod->eV;
|
||||
FILE_LOG(logDEBUG1, ("Copying register %x (%x)\n",destMod->reg,srcMod->reg ));
|
||||
LOG(logDEBUG1, ("Copying register %x (%x)\n",destMod->reg,srcMod->reg ));
|
||||
|
||||
if (destMod->nchan!=0) {
|
||||
for (ichan=0; ichan<(srcMod->nchan); ichan++) {
|
||||
@@ -2057,7 +2057,7 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
|
||||
*((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan);
|
||||
}
|
||||
}
|
||||
else FILE_LOG(logINFO, ("Not Copying trimbits\n"));
|
||||
else LOG(logINFO, ("Not Copying trimbits\n"));
|
||||
|
||||
for (idac=0; idac<(srcMod->ndac); idac++) {
|
||||
if (*((srcMod->dacs)+idac)>=0) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -54,20 +54,20 @@ void basictests() {
|
||||
initCheckDone = 0;
|
||||
memset(initErrorMessage, 0, MAX_STR_LENGTH);
|
||||
#ifdef VIRTUAL
|
||||
FILE_LOG(logINFOBLUE, ("******** Mythen3 Virtual Server *****************\n"));
|
||||
LOG(logINFOBLUE, ("******** Mythen3 Virtual Server *****************\n"));
|
||||
if (mapCSP0() == FAIL) {
|
||||
strcpy(initErrorMessage,
|
||||
"Could not map to memory. Dangerous to continue.\n");
|
||||
FILE_LOG(logERROR, (initErrorMessage));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
}
|
||||
return;
|
||||
#else
|
||||
FILE_LOG(logINFOBLUE, ("************ Mythen3 Server *********************\n"));
|
||||
LOG(logINFOBLUE, ("************ Mythen3 Server *********************\n"));
|
||||
if (mapCSP0() == FAIL) {
|
||||
strcpy(initErrorMessage,
|
||||
"Could not map to memory. Dangerous to continue.\n");
|
||||
FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ void basictests() {
|
||||
if ((!debugflag) && ((checkType() == FAIL) || (testFpga() == FAIL)|| (testBus() == FAIL))) {
|
||||
strcpy(initErrorMessage,
|
||||
"Could not pass basic tests of FPGA and bus. Dangerous to continue.\n");
|
||||
FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ void basictests() {
|
||||
int64_t client_sw_apiversion = getClientServerAPIVersion();
|
||||
uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN;
|
||||
|
||||
FILE_LOG(logINFOBLUE, ("*************************************************\n"
|
||||
LOG(logINFOBLUE, ("*************************************************\n"
|
||||
"Hardware Version:\t\t 0x%x\n"
|
||||
|
||||
"Detector IP Addr:\t\t 0x%x\n"
|
||||
@@ -117,11 +117,11 @@ void basictests() {
|
||||
|
||||
|
||||
//cant read versions
|
||||
FILE_LOG(logINFO, ("Testing Firmware-software compatibility:\n"));
|
||||
LOG(logINFO, ("Testing Firmware-software compatibility:\n"));
|
||||
if(!fwversion || !sw_fw_apiversion){
|
||||
strcpy(initErrorMessage,
|
||||
"Cant read versions from FPGA. Please update firmware.\n");
|
||||
FILE_LOG(logERROR, (initErrorMessage));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ void basictests() {
|
||||
"Please update detector software (min. 0x%llx) to be compatible with this firmware.\n",
|
||||
(long long int)sw_fw_apiversion,
|
||||
(long long int)requiredFirmwareVersion);
|
||||
FILE_LOG(logERROR, (initErrorMessage));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
@@ -145,11 +145,11 @@ void basictests() {
|
||||
"Please update firmware (min. 0x%llx) to be compatible with this server.\n",
|
||||
(long long int)fwversion,
|
||||
(long long int)requiredFirmwareVersion);
|
||||
FILE_LOG(logERROR, (initErrorMessage));
|
||||
LOG(logERROR, (initErrorMessage));
|
||||
initError = FAIL;
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Compatibility - success\n"));
|
||||
LOG(logINFO, ("Compatibility - success\n"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ int checkType() {
|
||||
#endif
|
||||
u_int32_t type = ((bus_r(FPGA_VERSION_REG) & DETECTOR_TYPE_MSK) >> DETECTOR_TYPE_OFST);
|
||||
if (type != MYTHEN3){
|
||||
FILE_LOG(logERROR, ("This is not a Mythen3 firmware (read %d, expected %d)\n", type, MYTHEN3));
|
||||
LOG(logERROR, ("This is not a Mythen3 firmware (read %d, expected %d)\n", type, MYTHEN3));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -171,15 +171,15 @@ int testFpga() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
FILE_LOG(logINFO, ("Testing FPGA:\n"));
|
||||
LOG(logINFO, ("Testing FPGA:\n"));
|
||||
|
||||
//fixed pattern
|
||||
int ret = OK;
|
||||
volatile u_int32_t val = bus_r(FIX_PATT_REG);
|
||||
if (val == FIX_PATT_VAL) {
|
||||
FILE_LOG(logINFO, ("Fixed pattern: successful match 0x%08x\n",val));
|
||||
LOG(logINFO, ("Fixed pattern: successful match 0x%08x\n",val));
|
||||
} else {
|
||||
FILE_LOG(logERROR, ("Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n", val, FIX_PATT_VAL));
|
||||
LOG(logERROR, ("Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n", val, FIX_PATT_VAL));
|
||||
ret = FAIL;
|
||||
}
|
||||
return ret;
|
||||
@@ -189,7 +189,7 @@ int testBus() {
|
||||
#ifdef VIRTUAL
|
||||
return OK;
|
||||
#endif
|
||||
FILE_LOG(logINFO, ("Testing Bus:\n"));
|
||||
LOG(logINFO, ("Testing Bus:\n"));
|
||||
|
||||
int ret = OK;
|
||||
u_int32_t addr = DTA_OFFSET_REG;
|
||||
@@ -199,7 +199,7 @@ int testBus() {
|
||||
for (i = 0; i < times; ++i) {
|
||||
bus_w(addr, i * 100);
|
||||
if (i * 100 != bus_r(addr)) {
|
||||
FILE_LOG(logERROR, ("Mismatch! Wrote 0x%x, read 0x%x\n",
|
||||
LOG(logERROR, ("Mismatch! Wrote 0x%x, read 0x%x\n",
|
||||
i * 100, bus_r(addr)));
|
||||
ret = FAIL;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ int testBus() {
|
||||
bus_w(addr, 0);
|
||||
|
||||
if (ret == OK) {
|
||||
FILE_LOG(logINFO, ("Successfully tested bus %d times\n", times));
|
||||
LOG(logINFO, ("Successfully tested bus %d times\n", times));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ u_int32_t getDetectorIP(){
|
||||
}
|
||||
strcpy(output,temp);
|
||||
sscanf(output, "%x", &res);
|
||||
//FILE_LOG(logINFO, ("ip:%x\n",res);
|
||||
//LOG(logINFO, ("ip:%x\n",res);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ void initStopServer() {
|
||||
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
if (mapCSP0() == FAIL) {
|
||||
FILE_LOG(logERROR, ("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
LOG(logERROR, ("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ void initStopServer() {
|
||||
/* set up detector */
|
||||
|
||||
void setupDetector() {
|
||||
FILE_LOG(logINFO, ("This Server is for 1 Mythen3 module \n"));
|
||||
LOG(logINFO, ("This Server is for 1 Mythen3 module \n"));
|
||||
|
||||
clkFrequency[READOUT_C0] = DEFAULT_READOUT_C0;
|
||||
clkFrequency[READOUT_C1] = DEFAULT_READOUT_C1;
|
||||
@@ -380,7 +380,7 @@ void setupDetector() {
|
||||
|
||||
int setDefaultDacs() {
|
||||
int ret = OK;
|
||||
FILE_LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
LOG(logINFOBLUE, ("Setting Default Dac values\n"));
|
||||
{
|
||||
int i = 0;
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
@@ -397,7 +397,7 @@ void cleanFifos() {
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
FILE_LOG(logINFO, ("Clearing Acquisition Fifos\n"));
|
||||
LOG(logINFO, ("Clearing Acquisition Fifos\n"));
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_CLR_ACQSTN_FIFO_MSK);
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ void resetCore() {
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
FILE_LOG(logINFO, ("Resetting Core\n"));
|
||||
LOG(logINFO, ("Resetting Core\n"));
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_CRE_RST_MSK);
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ void resetPeripheral() {
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
FILE_LOG(logINFO, ("Resetting Peripheral\n"));
|
||||
LOG(logINFO, ("Resetting Peripheral\n"));
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PRPHRL_RST_MSK);
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ int setDynamicRange(int dr){
|
||||
regval = CONFIG_DYNAMIC_RANGE_24_VAL;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Invalid dynamic range %d\n", dr));
|
||||
LOG(logERROR, ("Invalid dynamic range %d\n", dr));
|
||||
return -1;
|
||||
}
|
||||
// set it
|
||||
@@ -456,7 +456,7 @@ int setDynamicRange(int dr){
|
||||
case CONFIG_DYNAMIC_RANGE_24_VAL:
|
||||
return 32;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Invalid dynamic range %d read back\n", regval >> CONFIG_DYNAMIC_RANGE_OFST));
|
||||
LOG(logERROR, ("Invalid dynamic range %d read back\n", regval >> CONFIG_DYNAMIC_RANGE_OFST));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -466,7 +466,7 @@ int setDynamicRange(int dr){
|
||||
|
||||
void setNumFrames(int64_t val) {
|
||||
if (val > 0) {
|
||||
FILE_LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
|
||||
set64BitReg(val, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
|
||||
}
|
||||
}
|
||||
@@ -477,7 +477,7 @@ int64_t getNumFrames() {
|
||||
|
||||
void setNumTriggers(int64_t val) {
|
||||
if (val > 0) {
|
||||
FILE_LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting number of triggers %lld\n", (long long int)val));
|
||||
set64BitReg(val, SET_CYCLES_LSB_REG, SET_CYCLES_MSB_REG);
|
||||
}
|
||||
}
|
||||
@@ -488,10 +488,10 @@ int64_t getNumTriggers() {
|
||||
|
||||
int setExpTime(int64_t val) {
|
||||
if (val < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid exptime: %lld ns\n", (long long int)val));
|
||||
LOG(logERROR, ("Invalid exptime: %lld ns\n", (long long int)val));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val));
|
||||
val *= (1E-9 * clkFrequency[SYSTEM_C0]);
|
||||
setPatternWaitTime(0, val);
|
||||
|
||||
@@ -510,10 +510,10 @@ int64_t getExpTime() {
|
||||
|
||||
int setPeriod(int64_t val) {
|
||||
if (val < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid period: %lld ns\n", (long long int)val));
|
||||
LOG(logERROR, ("Invalid period: %lld ns\n", (long long int)val));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting period %lld ns\n", (long long int)val));
|
||||
val *= (1E-9 * FIXED_PLL_FREQUENCY);
|
||||
set64BitReg(val, SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG);
|
||||
|
||||
@@ -537,7 +537,7 @@ void setCounterMask(uint32_t arg) {
|
||||
countermask = arg;
|
||||
// convert mask into number of counters (until firmware converts to mask)
|
||||
int ncounters = __builtin_popcount(countermask);
|
||||
FILE_LOG(logINFO, ("Setting number of counters to %d\n", ncounters));
|
||||
LOG(logINFO, ("Setting number of counters to %d\n", ncounters));
|
||||
uint32_t val = 0;
|
||||
switch (ncounters) {
|
||||
case 1:
|
||||
@@ -553,7 +553,7 @@ void setCounterMask(uint32_t arg) {
|
||||
uint32_t addr = CONFIG_REG;
|
||||
bus_w(addr, bus_r(addr) &~ CONFIG_COUNTER_ENA_MSK);
|
||||
bus_w(addr, bus_r(addr) | val);
|
||||
FILE_LOG(logDEBUG, ("Config Reg: 0x%x\n", bus_r(addr)));
|
||||
LOG(logDEBUG, ("Config Reg: 0x%x\n", bus_r(addr)));
|
||||
}
|
||||
|
||||
uint32_t getCounterMask() {
|
||||
@@ -592,10 +592,10 @@ uint32_t getCounterMask() {
|
||||
|
||||
int setDelayAfterTrigger(int64_t val) {
|
||||
if (val < 0) {
|
||||
FILE_LOG(logERROR, ("Invalid delay after trigger: %lld ns\n", (long long int)val));
|
||||
LOG(logERROR, ("Invalid delay after trigger: %lld ns\n", (long long int)val));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Setting delay after trigger %lld ns\n", (long long int)val));
|
||||
LOG(logINFO, ("Setting delay after trigger %lld ns\n", (long long int)val));
|
||||
val *= (1E-9 * FIXED_PLL_FREQUENCY);
|
||||
set64BitReg(val, SET_TRIGGER_DELAY_LSB_REG, SET_TRIGGER_DELAY_MSB_REG);
|
||||
|
||||
@@ -649,11 +649,11 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
}
|
||||
|
||||
char* dac_names[] = {DAC_NAMES};
|
||||
FILE_LOG(logDEBUG1, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind], val, (mV ? "mV" : "dac units")));
|
||||
LOG(logDEBUG1, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind], val, (mV ? "mV" : "dac units")));
|
||||
|
||||
int dacval = val;
|
||||
#ifdef VIRTUAL
|
||||
FILE_LOG(logINFO, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind], val, (mV ? "mV" : "dac units")));
|
||||
LOG(logINFO, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dac_names[ind], val, (mV ? "mV" : "dac units")));
|
||||
if (!mV) {
|
||||
dacValues[ind] = val;
|
||||
}
|
||||
@@ -670,12 +670,12 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
|
||||
int getDAC(enum DACINDEX ind, int mV) {
|
||||
if (!mV) {
|
||||
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac\n",ind, dacValues[ind]));
|
||||
LOG(logDEBUG1, ("Getting DAC %d : %d dac\n",ind, dacValues[ind]));
|
||||
return dacValues[ind];
|
||||
}
|
||||
int voltage = -1;
|
||||
LTC2620_D_DacToVoltage(dacValues[ind], &voltage);
|
||||
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac (%d mV)\n",ind, dacValues[ind], voltage));
|
||||
LOG(logDEBUG1, ("Getting DAC %d : %d dac (%d mV)\n",ind, dacValues[ind], voltage));
|
||||
return voltage;
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ int setHighVoltage(int val){
|
||||
|
||||
// setting hv
|
||||
if (val >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
||||
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
||||
DAC6571_Set(val);
|
||||
highvoltage = val;
|
||||
}
|
||||
@@ -709,15 +709,15 @@ void setTiming( enum timingMode arg){
|
||||
if(arg != GET_TIMING_MODE){
|
||||
switch (arg) {
|
||||
case AUTO_TIMING:
|
||||
FILE_LOG(logINFO, ("Set Timing: Auto\n"));
|
||||
LOG(logINFO, ("Set Timing: Auto\n"));
|
||||
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) & ~EXT_SIGNAL_MSK);
|
||||
break;
|
||||
case TRIGGER_EXPOSURE:
|
||||
FILE_LOG(logINFO, ("Set Timing: Trigger\n"));
|
||||
LOG(logINFO, ("Set Timing: Trigger\n"));
|
||||
bus_w(EXT_SIGNAL_REG, bus_r(EXT_SIGNAL_REG) | EXT_SIGNAL_MSK);
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Unknown timing mode %d\n", arg));
|
||||
LOG(logERROR, ("Unknown timing mode %d\n", arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -742,17 +742,17 @@ int configureMAC() {
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, dstport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
FILE_LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
|
||||
FILE_LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(srcip>>24)&0xff,(srcip>>16)&0xff,(srcip>>8)&0xff,(srcip)&0xff, srcip));
|
||||
FILE_LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((srcmac>>40)&0xFF),
|
||||
(unsigned int)((srcmac>>32)&0xFF),
|
||||
(unsigned int)((srcmac>>24)&0xFF),
|
||||
@@ -760,11 +760,11 @@ int configureMAC() {
|
||||
(unsigned int)((srcmac>>8)&0xFF),
|
||||
(unsigned int)((srcmac>>0)&0xFF),
|
||||
(long long unsigned int)srcmac));
|
||||
FILE_LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n", srcport, srcport));
|
||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n", srcport, srcport));
|
||||
|
||||
FILE_LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff, dstip));
|
||||
FILE_LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((dstmac>>40)&0xFF),
|
||||
(unsigned int)((dstmac>>32)&0xFF),
|
||||
(unsigned int)((dstmac>>24)&0xFF),
|
||||
@@ -772,7 +772,7 @@ int configureMAC() {
|
||||
(unsigned int)((dstmac>>8)&0xFF),
|
||||
(unsigned int)((dstmac>>0)&0xFF),
|
||||
(long long unsigned int)dstmac));
|
||||
FILE_LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",dstport, dstport));
|
||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",dstport, dstport));
|
||||
|
||||
// start addr
|
||||
uint32_t addr = BASE_UDP_RAM;
|
||||
@@ -846,7 +846,7 @@ void calcChecksum(udp_header* udp) {
|
||||
sum = (sum & 0xffff) + (sum >> 16);// Fold 32-bit sum to 16 bits
|
||||
long int checksum = sum & 0xffff;
|
||||
checksum += UDP_IP_HEADER_LENGTH_BYTES;
|
||||
FILE_LOG(logINFO, ("\tIP checksum is 0x%lx\n",checksum));
|
||||
LOG(logINFO, ("\tIP checksum is 0x%lx\n",checksum));
|
||||
udp->ip_checksum = checksum;
|
||||
}
|
||||
|
||||
@@ -863,7 +863,7 @@ int setDetectorPosition(int pos[]) {
|
||||
bus_w(addr, (bus_r(addr) &~COORD_ROW_MSK) | ((value << COORD_ROW_OFST) & COORD_ROW_MSK));
|
||||
valueRead = ((bus_r(addr) & COORD_ROW_MSK) >> COORD_ROW_OFST);
|
||||
if (valueRead != value) {
|
||||
FILE_LOG(logERROR, ("Could not set row. Set %d, read %d\n", value, valueRead));
|
||||
LOG(logERROR, ("Could not set row. Set %d, read %d\n", value, valueRead));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
@@ -872,12 +872,12 @@ int setDetectorPosition(int pos[]) {
|
||||
bus_w(addr, (bus_r(addr) &~COORD_COL_MSK) | ((value << COORD_COL_OFST) & COORD_COL_MSK));
|
||||
valueRead = ((bus_r(addr) & COORD_COL_MSK) >> COORD_COL_OFST);
|
||||
if (valueRead != value) {
|
||||
FILE_LOG(logERROR, ("Could not set column. Set %d, read %d\n", value, valueRead));
|
||||
LOG(logERROR, ("Could not set column. Set %d, read %d\n", value, valueRead));
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
if (ret == OK) {
|
||||
FILE_LOG(logINFO, ("\tPosition set to [%d, %d]\n", detPos[X], detPos[Y]));
|
||||
LOG(logINFO, ("\tPosition set to [%d, %d]\n", detPos[X], detPos[Y]));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -892,18 +892,18 @@ int* getDetectorPosition() {
|
||||
uint64_t readPatternWord(int addr) {
|
||||
// error (handled in tcp)
|
||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||
FILE_LOG(logERROR, ("Cannot get Pattern - Word. Invalid addr 0x%x. "
|
||||
LOG(logERROR, ("Cannot get Pattern - Word. Invalid addr 0x%x. "
|
||||
"Should be between 0 and 0x%x\n", addr, MAX_PATTERN_LENGTH));
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, (" Reading Pattern Word (addr:0x%x)\n", addr));
|
||||
LOG(logINFO, (" Reading Pattern Word (addr:0x%x)\n", addr));
|
||||
uint32_t reg_lsb = PATTERN_STEP0_LSB_REG + addr * REG_OFFSET * 2; // the first word in RAM as base plus the offset of the word to write (addr)
|
||||
uint32_t reg_msb = PATTERN_STEP0_MSB_REG + addr * REG_OFFSET * 2;
|
||||
|
||||
// read value
|
||||
uint64_t retval = get64BitReg(reg_lsb, reg_msb);
|
||||
FILE_LOG(logDEBUG1, (" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int) retval));
|
||||
LOG(logDEBUG1, (" Word(addr:0x%x) retval: 0x%llx\n", addr, (long long int) retval));
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -915,18 +915,18 @@ uint64_t writePatternWord(int addr, uint64_t word) {
|
||||
|
||||
// error (handled in tcp)
|
||||
if (addr < 0 || addr >= MAX_PATTERN_LENGTH) {
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern - Word. Invalid addr 0x%x. "
|
||||
LOG(logERROR, ("Cannot set Pattern - Word. Invalid addr 0x%x. "
|
||||
"Should be between 0 and 0x%x\n", addr, MAX_PATTERN_LENGTH));
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr, (long long int) word));
|
||||
LOG(logINFO, ("Setting Pattern Word (addr:0x%x, word:0x%llx)\n", addr, (long long int) word));
|
||||
uint32_t reg_lsb = PATTERN_STEP0_LSB_REG + addr * REG_OFFSET * 2; // the first word in RAM as base plus the offset of the word to write (addr)
|
||||
uint32_t reg_msb = PATTERN_STEP0_MSB_REG + addr * REG_OFFSET * 2;
|
||||
|
||||
// write word
|
||||
set64BitReg(word, reg_lsb, reg_msb);
|
||||
FILE_LOG(logDEBUG1, (" Wrote word. PatternIn Reg: 0x%llx\n", get64BitReg(reg_lsb, reg_msb)));
|
||||
LOG(logDEBUG1, (" Wrote word. PatternIn Reg: 0x%llx\n", get64BitReg(reg_lsb, reg_msb)));
|
||||
|
||||
return readPatternWord(addr);
|
||||
}
|
||||
@@ -935,7 +935,7 @@ int setPatternWaitAddress(int level, int addr) {
|
||||
|
||||
// error (handled in tcp)
|
||||
if (addr >= MAX_PATTERN_LENGTH) {
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern Wait Address. Invalid addr 0x%x. "
|
||||
LOG(logERROR, ("Cannot set Pattern Wait Address. Invalid addr 0x%x. "
|
||||
"Should be between 0 and 0x%x\n", addr, MAX_PATTERN_LENGTH));
|
||||
return -1;
|
||||
}
|
||||
@@ -961,20 +961,20 @@ int setPatternWaitAddress(int level, int addr) {
|
||||
mask = PATTERN_WAIT_2_ADDR_MSK;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern Wait Address. Invalid level 0x%x. "
|
||||
LOG(logERROR, ("Cannot set Pattern Wait Address. Invalid level 0x%x. "
|
||||
"Should be between 0 and 2.\n", level));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set
|
||||
if (addr >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting Pattern Wait Address (level:%d, addr:0x%x)\n", level, addr));
|
||||
LOG(logINFO, ("Setting Pattern Wait Address (level:%d, addr:0x%x)\n", level, addr));
|
||||
bus_w(reg, ((addr << offset) & mask));
|
||||
}
|
||||
|
||||
// get
|
||||
uint32_t regval = ((bus_r(reg) & mask) >> offset);
|
||||
FILE_LOG(logDEBUG1, (" Wait Address retval (level:%d, addr:0x%x)\n", level, regval));
|
||||
LOG(logDEBUG1, (" Wait Address retval (level:%d, addr:0x%x)\n", level, regval));
|
||||
return regval;
|
||||
}
|
||||
|
||||
@@ -996,20 +996,20 @@ uint64_t setPatternWaitTime(int level, uint64_t t) {
|
||||
regm = PATTERN_WAIT_TIMER_2_MSB_REG;
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern Wait Time. Invalid level %d. "
|
||||
LOG(logERROR, ("Cannot set Pattern Wait Time. Invalid level %d. "
|
||||
"Should be between 0 and 2.\n", level));
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set
|
||||
if ((int64_t)t >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting Pattern Wait Time (level:%d, t:%lld)\n", level, (long long int)t));
|
||||
LOG(logINFO, ("Setting Pattern Wait Time (level:%d, t:%lld)\n", level, (long long int)t));
|
||||
set64BitReg(t, regl, regm);
|
||||
}
|
||||
|
||||
// get
|
||||
uint64_t regval = get64BitReg(regl, regm);
|
||||
FILE_LOG(logDEBUG1, (" Wait Time retval (level:%d, t:%lld)\n", level, (long long int)regval));
|
||||
LOG(logDEBUG1, (" Wait Time retval (level:%d, t:%lld)\n", level, (long long int)regval));
|
||||
return regval;
|
||||
}
|
||||
|
||||
@@ -1017,7 +1017,7 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
|
||||
// (checked at tcp)
|
||||
if (*startAddr >= MAX_PATTERN_LENGTH || *stopAddr >= MAX_PATTERN_LENGTH) {
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern Loop, Address (startaddr:0x%x, stopaddr:0x%x) must be "
|
||||
LOG(logERROR, ("Cannot set Pattern Loop, Address (startaddr:0x%x, stopaddr:0x%x) must be "
|
||||
"less than 0x%x\n",
|
||||
*startAddr, *stopAddr, MAX_PATTERN_LENGTH));
|
||||
}
|
||||
@@ -1065,7 +1065,7 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
break;
|
||||
default:
|
||||
// already checked at tcp interface
|
||||
FILE_LOG(logERROR, ("Cannot set Pattern loop. Invalid level %d. "
|
||||
LOG(logERROR, ("Cannot set Pattern loop. Invalid level %d. "
|
||||
"Should be between -1 and 2.\n", level));
|
||||
*startAddr = 0;
|
||||
*stopAddr = 0;
|
||||
@@ -1076,7 +1076,7 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
if (level >= 0) {
|
||||
// set iteration
|
||||
if (*nLoop >= 0) {
|
||||
FILE_LOG(logINFO, ("Setting Pattern Loop (level:%d, nLoop:%d)\n",
|
||||
LOG(logINFO, ("Setting Pattern Loop (level:%d, nLoop:%d)\n",
|
||||
level, *nLoop));
|
||||
bus_w(nLoopReg, *nLoop);
|
||||
}
|
||||
@@ -1086,20 +1086,20 @@ void setPatternLoop(int level, int *startAddr, int *stopAddr, int *nLoop) {
|
||||
// set
|
||||
if (*startAddr >= 0 && *stopAddr >= 0) {
|
||||
// writing start and stop addr
|
||||
FILE_LOG(logINFO, ("Setting Pattern Loop (level:%d, startaddr:0x%x, stopaddr:0x%x)\n",
|
||||
LOG(logINFO, ("Setting Pattern Loop (level:%d, startaddr:0x%x, stopaddr:0x%x)\n",
|
||||
level, *startAddr, *stopAddr));
|
||||
bus_w(addr, ((*startAddr << startOffset) & startMask) | ((*stopAddr << stopOffset) & stopMask));
|
||||
FILE_LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
|
||||
LOG(logDEBUG1, ("Addr:0x%x, val:0x%x\n", addr, bus_r(addr)));
|
||||
}
|
||||
|
||||
// get
|
||||
else {
|
||||
*startAddr = ((bus_r(addr) & startMask) >> startOffset);
|
||||
FILE_LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read startAddr:0x%x)\n",
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Start Address (level:%d, Read startAddr:0x%x)\n",
|
||||
level, *startAddr));
|
||||
|
||||
*stopAddr = ((bus_r(addr) & stopMask) >> stopOffset);
|
||||
FILE_LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read stopAddr:0x%x)\n",
|
||||
LOG(logDEBUG1, ("Getting Pattern Loop Stop Address (level:%d, Read stopAddr:0x%x)\n",
|
||||
level, *stopAddr));
|
||||
}
|
||||
}
|
||||
@@ -1121,27 +1121,27 @@ uint64_t getPatternBitMask() {
|
||||
}
|
||||
|
||||
int checkDetectorType() {
|
||||
FILE_LOG(logINFO, ("Checking type of module\n"));
|
||||
LOG(logINFO, ("Checking type of module\n"));
|
||||
FILE* fd = fopen(TYPE_FILE_NAME, "r");
|
||||
if (fd == NULL) {
|
||||
FILE_LOG(logERROR, ("Could not open file %s to get type of the module attached\n", TYPE_FILE_NAME));
|
||||
LOG(logERROR, ("Could not open file %s to get type of the module attached\n", TYPE_FILE_NAME));
|
||||
return -1;
|
||||
}
|
||||
char buffer[MAX_STR_LENGTH];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
fread (buffer, MAX_STR_LENGTH, sizeof(char), fd);
|
||||
if (strlen(buffer) == 0) {
|
||||
FILE_LOG(logERROR, ("Could not read file %s to get type of the module attached\n", TYPE_FILE_NAME));
|
||||
LOG(logERROR, ("Could not read file %s to get type of the module attached\n", TYPE_FILE_NAME));
|
||||
return -1;
|
||||
}
|
||||
int type = atoi(buffer);
|
||||
if (type > TYPE_NO_MODULE_STARTING_VAL) {
|
||||
FILE_LOG(logERROR, ("No Module attached! Expected %d for Mythen, got %d\n", TYPE_MYTHEN3_MODULE_VAL, type));
|
||||
LOG(logERROR, ("No Module attached! Expected %d for Mythen, got %d\n", TYPE_MYTHEN3_MODULE_VAL, type));
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (abs(type - TYPE_MYTHEN3_MODULE_VAL) > TYPE_TOLERANCE) {
|
||||
FILE_LOG(logERROR, ("Wrong Module attached! Expected %d for Mythen3, got %d\n", TYPE_MYTHEN3_MODULE_VAL, type));
|
||||
LOG(logERROR, ("Wrong Module attached! Expected %d for Mythen3, got %d\n", TYPE_MYTHEN3_MODULE_VAL, type));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
@@ -1150,11 +1150,11 @@ int checkDetectorType() {
|
||||
int powerChip (int on){
|
||||
if(on != -1){
|
||||
if(on){
|
||||
FILE_LOG(logINFO, ("Powering chip: on\n"));
|
||||
LOG(logINFO, ("Powering chip: on\n"));
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_PWR_CHIP_MSK);
|
||||
}
|
||||
else{
|
||||
FILE_LOG(logINFO, ("Powering chip: off\n"));
|
||||
LOG(logINFO, ("Powering chip: off\n"));
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_PWR_CHIP_MSK);
|
||||
}
|
||||
}
|
||||
@@ -1165,19 +1165,19 @@ int powerChip (int on){
|
||||
|
||||
int setPhase(enum CLKINDEX ind, int val, int degrees) {
|
||||
if (ind < 0 || ind >= NUM_CLOCKS) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index %d to set phase\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index %d to set phase\n", ind));
|
||||
return FAIL;
|
||||
}
|
||||
char* clock_names[] = {CLK_NAMES};
|
||||
FILE_LOG(logINFOBLUE, ("Setting %s clock (%d) phase to %d %s\n", clock_names[ind], ind, val, degrees == 0 ? "" : "degrees"));
|
||||
LOG(logINFOBLUE, ("Setting %s clock (%d) phase to %d %s\n", clock_names[ind], ind, val, degrees == 0 ? "" : "degrees"));
|
||||
int maxShift = getMaxPhase(ind);
|
||||
// validation
|
||||
if (degrees && (val < 0 || val > 359)) {
|
||||
FILE_LOG(logERROR, ("\tPhase outside limits (0 - 359°C)\n"));
|
||||
LOG(logERROR, ("\tPhase outside limits (0 - 359°C)\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (!degrees && (val < 0 || val > maxShift - 1)) {
|
||||
FILE_LOG(logERROR, ("\tPhase outside limits (0 - %d phase shifts)\n", maxShift - 1));
|
||||
LOG(logERROR, ("\tPhase outside limits (0 - %d phase shifts)\n", maxShift - 1));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -1186,14 +1186,14 @@ int setPhase(enum CLKINDEX ind, int val, int degrees) {
|
||||
if (degrees) {
|
||||
ConvertToDifferentRange(0, 359, 0, maxShift - 1, val, &valShift);
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("\tphase shift: %d (degrees/shift: %d)\n", valShift, val));
|
||||
LOG(logDEBUG1, ("\tphase shift: %d (degrees/shift: %d)\n", valShift, val));
|
||||
|
||||
int relativePhase = valShift - clkPhase[ind];
|
||||
FILE_LOG(logDEBUG1, ("\trelative phase shift: %d (Current phase: %d)\n", relativePhase, clkPhase[ind]));
|
||||
LOG(logDEBUG1, ("\trelative phase shift: %d (Current phase: %d)\n", relativePhase, clkPhase[ind]));
|
||||
|
||||
// same phase
|
||||
if (!relativePhase) {
|
||||
FILE_LOG(logINFO, ("\tNothing to do in Phase Shift\n"));
|
||||
LOG(logINFO, ("\tNothing to do in Phase Shift\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1212,7 +1212,7 @@ int setPhase(enum CLKINDEX ind, int val, int degrees) {
|
||||
|
||||
int getPhase(enum CLKINDEX ind, int degrees) {
|
||||
if (ind < 0 || ind >= NUM_CLOCKS) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index %d to get phase\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index %d to get phase\n", ind));
|
||||
return -1;
|
||||
}
|
||||
if (!degrees)
|
||||
@@ -1225,7 +1225,7 @@ int getPhase(enum CLKINDEX ind, int degrees) {
|
||||
|
||||
int getMaxPhase(enum CLKINDEX ind) {
|
||||
if (ind < 0 || ind >= NUM_CLOCKS) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index %d to get max phase\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index %d to get max phase\n", ind));
|
||||
return -1;
|
||||
}
|
||||
int vcofreq = getVCOFrequency(ind);
|
||||
@@ -1233,7 +1233,7 @@ int getMaxPhase(enum CLKINDEX ind) {
|
||||
int ret = ((double)vcofreq / (double)clkFrequency[ind]) * maxshiftstep;
|
||||
|
||||
char* clock_names[] = {CLK_NAMES};
|
||||
FILE_LOG(logDEBUG1, ("\tMax Phase Shift (%s): %d (Clock: %d Hz, VCO:%d Hz)\n",
|
||||
LOG(logDEBUG1, ("\tMax Phase Shift (%s): %d (Clock: %d Hz, VCO:%d Hz)\n",
|
||||
clock_names[ind], ret, clkFrequency[ind], vcofreq));
|
||||
|
||||
return ret;
|
||||
@@ -1241,13 +1241,13 @@ int getMaxPhase(enum CLKINDEX ind) {
|
||||
|
||||
int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval) {
|
||||
if (ind < 0 || ind >= NUM_CLOCKS) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index %d to validate phase in degrees\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index %d to validate phase in degrees\n", ind));
|
||||
return FAIL;
|
||||
}
|
||||
if (val == -1) {
|
||||
return OK;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("validating phase in degrees for clk %d\n", (int)ind));
|
||||
LOG(logDEBUG1, ("validating phase in degrees for clk %d\n", (int)ind));
|
||||
int maxShift = getMaxPhase(ind);
|
||||
// convert degrees to shift
|
||||
int valShift = 0;
|
||||
@@ -1264,7 +1264,7 @@ int validatePhaseinDegrees(enum CLKINDEX ind, int val, int retval) {
|
||||
|
||||
int getFrequency(enum CLKINDEX ind) {
|
||||
if (ind < 0 || ind >= NUM_CLOCKS) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index %d to get frequency\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index %d to get frequency\n", ind));
|
||||
return -1;
|
||||
}
|
||||
return clkFrequency[ind];
|
||||
@@ -1272,7 +1272,7 @@ int getFrequency(enum CLKINDEX ind) {
|
||||
|
||||
int getVCOFrequency(enum CLKINDEX ind) {
|
||||
if (ind < 0 || ind >= NUM_CLOCKS) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index %d to get vco frequency\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index %d to get vco frequency\n", ind));
|
||||
return -1;
|
||||
}
|
||||
int pllIndex = (int)(ind >= SYSTEM_C0 ? SYSTEM_PLL : READOUT_PLL);
|
||||
@@ -1285,7 +1285,7 @@ int getMaxClockDivider() {
|
||||
|
||||
int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
if (ind < 0 || ind >= NUM_CLOCKS) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index %d to set clock divider\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index %d to set clock divider\n", ind));
|
||||
return FAIL;
|
||||
}
|
||||
if (val < 2 || val > getMaxClockDivider()) {
|
||||
@@ -1296,7 +1296,7 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
int currentdiv = vcofreq / (int)clkFrequency[ind];
|
||||
int newfreq = vcofreq / val;
|
||||
|
||||
FILE_LOG(logINFO, ("\tSetting %s clock (%d) divider from %d (%d Hz) to %d (%d Hz). \n\t(Vcofreq: %d Hz)\n", clock_names[ind], ind, currentdiv, clkFrequency[ind], val, newfreq, vcofreq));
|
||||
LOG(logINFO, ("\tSetting %s clock (%d) divider from %d (%d Hz) to %d (%d Hz). \n\t(Vcofreq: %d Hz)\n", clock_names[ind], ind, currentdiv, clkFrequency[ind], val, newfreq, vcofreq));
|
||||
|
||||
// Remembering old phases in degrees
|
||||
int oldPhases[NUM_CLOCKS];
|
||||
@@ -1312,7 +1312,7 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
int clkIndex = (int)(ind >= SYSTEM_C0 ? ind - SYSTEM_C0 : ind);
|
||||
ALTERA_PLL_C10_SetOuputFrequency (pllIndex, clkIndex, newfreq);
|
||||
clkFrequency[ind] = newfreq;
|
||||
FILE_LOG(logINFO, ("\t%s clock (%d) divider set to %d (%d Hz)\n", clock_names[ind], ind, val, clkFrequency[ind]));
|
||||
LOG(logINFO, ("\t%s clock (%d) divider set to %d (%d Hz)\n", clock_names[ind], ind, val, clkFrequency[ind]));
|
||||
|
||||
// phase is reset by pll (when setting output frequency)
|
||||
if (ind >= READOUT_C0) {
|
||||
@@ -1330,7 +1330,7 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
for (i = 0; i < NUM_CLOCKS; ++i) {
|
||||
int currPhaseDeg = getPhase(i, 1);
|
||||
if (oldPhases[i] != currPhaseDeg) {
|
||||
FILE_LOG(logINFO, ("\tCorrecting %s clock (%d) phase from %d to %d degrees\n", clock_names[i], i, currPhaseDeg, oldPhases[i]));
|
||||
LOG(logINFO, ("\tCorrecting %s clock (%d) phase from %d to %d degrees\n", clock_names[i], i, currPhaseDeg, oldPhases[i]));
|
||||
setPhase(i, oldPhases[i], 1);
|
||||
}
|
||||
}
|
||||
@@ -1340,7 +1340,7 @@ int setClockDivider(enum CLKINDEX ind, int val) {
|
||||
|
||||
int getClockDivider(enum CLKINDEX ind) {
|
||||
if (ind < 0 || ind >= NUM_CLOCKS) {
|
||||
FILE_LOG(logERROR, ("Unknown clock index %d to get clock divider\n", ind));
|
||||
LOG(logERROR, ("Unknown clock index %d to get clock divider\n", ind));
|
||||
return -1;
|
||||
}
|
||||
return (getVCOFrequency(ind) / (int)clkFrequency[ind]);
|
||||
@@ -1354,25 +1354,25 @@ int startStateMachine(){
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
// set status to running
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
FILE_LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
return OK;
|
||||
#endif
|
||||
FILE_LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
cleanFifos();
|
||||
|
||||
//start state machine
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STRT_ACQSTN_MSK);
|
||||
|
||||
FILE_LOG(logINFO, ("Status Register: %08x\n",bus_r(STATUS_REG)));
|
||||
LOG(logINFO, ("Status Register: %08x\n",bus_r(STATUS_REG)));
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1440,7 +1440,7 @@ void* start_timer(void* arg) {
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
|
||||
// calculate time left in period
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
@@ -1460,52 +1460,52 @@ void* start_timer(void* arg) {
|
||||
closeUDPSocket(0);
|
||||
// set status to idle
|
||||
virtual_status = 0;
|
||||
FILE_LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int stopStateMachine(){
|
||||
FILE_LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
return OK;
|
||||
#endif
|
||||
//stop state machine
|
||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STP_ACQSTN_MSK);
|
||||
FILE_LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
||||
LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
||||
return OK;
|
||||
}
|
||||
|
||||
enum runStatus getRunStatus(){
|
||||
#ifdef VIRTUAL
|
||||
if(virtual_status == 0){
|
||||
FILE_LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
}else{
|
||||
FILE_LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1, ("Getting status\n"));
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
uint32_t retval = bus_r(PAT_STATUS_REG);
|
||||
FILE_LOG(logINFO, ("Status Register: %08x\n",retval));
|
||||
LOG(logINFO, ("Status Register: %08x\n",retval));
|
||||
|
||||
enum runStatus s;
|
||||
|
||||
//running
|
||||
if (retval & PAT_STATUS_RUN_BUSY_MSK) {
|
||||
if (retval & PAT_STATUS_WAIT_FOR_TRGGR_MSK) {
|
||||
FILE_LOG(logINFOBLUE, ("Status: WAITING\n"));
|
||||
LOG(logINFOBLUE, ("Status: WAITING\n"));
|
||||
s = WAITING;
|
||||
} else {
|
||||
if (retval & PAT_STATUS_DLY_BFRE_TRGGR_MSK) {
|
||||
FILE_LOG(logINFO, ("Status: Delay before Trigger\n"));
|
||||
LOG(logINFO, ("Status: Delay before Trigger\n"));
|
||||
} else if (retval & PAT_STATUS_DLY_AFTR_TRGGR_MSK) {
|
||||
FILE_LOG(logINFO, ("Status: Delay after Trigger\n"));
|
||||
LOG(logINFO, ("Status: Delay after Trigger\n"));
|
||||
}
|
||||
FILE_LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
s = RUNNING;
|
||||
}
|
||||
}
|
||||
@@ -1514,16 +1514,16 @@ enum runStatus getRunStatus(){
|
||||
else {
|
||||
// stopped or error
|
||||
if (retval & PAT_STATUS_FIFO_FULL_MSK) {
|
||||
FILE_LOG(logINFOBLUE, ("Status: STOPPED\n")); //FIFO FULL??
|
||||
LOG(logINFOBLUE, ("Status: STOPPED\n")); //FIFO FULL??
|
||||
s = STOPPED;
|
||||
} else if (retval & PAT_STATUS_CSM_BUSY_MSK) {
|
||||
FILE_LOG(logINFOBLUE, ("Status: READ MACHINE BUSY\n"));
|
||||
LOG(logINFOBLUE, ("Status: READ MACHINE BUSY\n"));
|
||||
s = TRANSMITTING;
|
||||
} else if (!retval) {
|
||||
FILE_LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
s = IDLE;
|
||||
} else {
|
||||
FILE_LOG(logERROR, ("Status: Unknown status %08x\n", retval));
|
||||
LOG(logERROR, ("Status: Unknown status %08x\n", retval));
|
||||
s = ERROR;
|
||||
}
|
||||
}
|
||||
@@ -1538,7 +1538,7 @@ void readFrame(int *ret, char *mess) {
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||
LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||
return;
|
||||
#endif
|
||||
|
||||
@@ -1547,9 +1547,9 @@ void readFrame(int *ret, char *mess) {
|
||||
int64_t retval = getNumFramesLeft() + 1;
|
||||
|
||||
if ( retval > 0) {
|
||||
FILE_LOG(logERROR, ("No data and run stopped: %lld frames left\n",(long long int)retval));
|
||||
LOG(logERROR, ("No data and run stopped: %lld frames left\n",(long long int)retval));
|
||||
} else {
|
||||
FILE_LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
|
||||
LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1558,7 +1558,7 @@ u_int32_t runBusy() {
|
||||
return virtual_status;
|
||||
#endif
|
||||
u_int32_t s = (bus_r(PAT_STATUS_REG) & PAT_STATUS_RUN_BUSY_MSK);
|
||||
//FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||
//LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5
|
||||
|
||||
#define ERROR_MSG_LENGTH 1000
|
||||
|
||||
#define FILE_LOG(lvl, fmt, ...) \
|
||||
#define LOG(lvl, fmt, ...) \
|
||||
if (lvl > FILELOG_MAX_LEVEL); \
|
||||
else {char* temp = FILELOG_BuildLog fmt; FILELOG_PrintLog(lvl, temp);free(temp);}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ uint32_t AD7689_DigMask = 0x0;
|
||||
int AD7689_DigOffset = 0x0;
|
||||
|
||||
void AD7689_SetDefines(uint32_t reg, uint32_t roreg, uint32_t cmsk, uint32_t clkmsk, uint32_t dmsk, int dofst) {
|
||||
FILE_LOG(logDEBUG, ("AD7689: reg:0x%x roreg:0x%x cmsk:0x%x clkmsk:0x%x dmsk:0x%x dofst:%d\n",
|
||||
LOG(logDEBUG, ("AD7689: reg:0x%x roreg:0x%x cmsk:0x%x clkmsk:0x%x dmsk:0x%x dofst:%d\n",
|
||||
reg, roreg, cmsk, clkmsk, dmsk, dofst));
|
||||
AD7689_Reg = reg;
|
||||
AD7689_ROReg = roreg;
|
||||
@@ -100,13 +100,13 @@ void AD7689_Disable() {
|
||||
}
|
||||
|
||||
void AD7689_Set(uint32_t codata) {
|
||||
FILE_LOG(logINFO, ("\tSetting ADC SPI Register. Writing 0x%08x to Config Reg\n", codata));
|
||||
LOG(logINFO, ("\tSetting ADC SPI Register. Writing 0x%08x to Config Reg\n", codata));
|
||||
serializeToSPI(AD7689_Reg, codata, AD7689_CnvMask, AD7689_ADC_CFG_NUMBITS,
|
||||
AD7689_ClkMask, AD7689_DigMask, AD7689_DigOffset, 1);
|
||||
}
|
||||
|
||||
uint16_t AD7689_Get() {
|
||||
FILE_LOG(logINFO, ("\tGetting ADC SPI Register.\n"));
|
||||
LOG(logINFO, ("\tGetting ADC SPI Register.\n"));
|
||||
return (uint16_t)serializeFromSPI(AD7689_Reg, AD7689_CnvMask, AD7689_ADC_DATA_NUMBITS,
|
||||
AD7689_ClkMask, AD7689_DigMask, AD7689_ROReg, 1);
|
||||
}
|
||||
@@ -135,11 +135,11 @@ int AD7689_GetTemperature() {
|
||||
ConvertToDifferentRange(0, AD7689_INT_MAX_STEPS,
|
||||
AD7689_INT_REF_MIN_MV, AD7689_INT_REF_MAX_MV,
|
||||
regval, &retval);
|
||||
FILE_LOG(logDEBUG1, ("voltage read for temp: %d mV\n", retval));
|
||||
LOG(logDEBUG1, ("voltage read for temp: %d mV\n", retval));
|
||||
|
||||
// value in °C
|
||||
double tempValue = AD7689_TMP_C_FOR_1_MV * (double)retval;
|
||||
FILE_LOG(logINFO, ("\ttemp read : %f °C (%d unit)\n", tempValue, regval));
|
||||
LOG(logINFO, ("\ttemp read : %f °C (%d unit)\n", tempValue, regval));
|
||||
|
||||
return tempValue;
|
||||
|
||||
@@ -148,7 +148,7 @@ int AD7689_GetTemperature() {
|
||||
int AD7689_GetChannel(int ichan) {
|
||||
// filter channels val
|
||||
if (ichan < 0 || ichan >= AD7689_NUM_CHANNELS) {
|
||||
FILE_LOG(logERROR, ("Cannot get slow adc channel. "
|
||||
LOG(logERROR, ("Cannot get slow adc channel. "
|
||||
"%d out of bounds (0 to %d)\n", ichan, AD7689_NUM_CHANNELS - 1));
|
||||
return -1;
|
||||
}
|
||||
@@ -179,15 +179,15 @@ int AD7689_GetChannel(int ichan) {
|
||||
AD7689_INT_REF_MIN_MV, AD7689_INT_REF_MAX_MV,
|
||||
regval, &retval);*/
|
||||
|
||||
FILE_LOG(logINFO, ("\tvoltage read for chan %d: %d uV (regVal: %d)\n", ichan, retval, regval));
|
||||
LOG(logINFO, ("\tvoltage read for chan %d: %d uV (regVal: %d)\n", ichan, retval, regval));
|
||||
return retval;
|
||||
}
|
||||
|
||||
void AD7689_Configure(){
|
||||
FILE_LOG(logINFOBLUE, ("Configuring AD7689 (Slow ADCs): \n"));
|
||||
LOG(logINFOBLUE, ("Configuring AD7689 (Slow ADCs): \n"));
|
||||
|
||||
// from power up, 3 invalid conversions
|
||||
FILE_LOG(logINFO, ("\tConfiguring %d x due to invalid conversions from power up\n", AD7689_NUM_INVALID_CONVERSIONS));
|
||||
LOG(logINFO, ("\tConfiguring %d x due to invalid conversions from power up\n", AD7689_NUM_INVALID_CONVERSIONS));
|
||||
int i = 0;
|
||||
for (i = 0; i < AD7689_NUM_INVALID_CONVERSIONS; ++i) {
|
||||
AD7689_Set(
|
||||
|
||||
@@ -124,40 +124,40 @@ void AD9252_Set(int addr, int val) {
|
||||
|
||||
u_int32_t codata;
|
||||
codata = val + (addr << 8);
|
||||
FILE_LOG(logINFO, ("\tSetting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr));
|
||||
LOG(logINFO, ("\tSetting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr));
|
||||
serializeToSPI(AD9252_Reg, codata, AD9252_CsMask, AD9252_ADC_NUMBITS,
|
||||
AD9252_ClkMask, AD9252_DigMask, AD9252_DigOffset, 0);
|
||||
}
|
||||
|
||||
void AD9252_Configure(){
|
||||
FILE_LOG(logINFOBLUE, ("Configuring ADC9252:\n"));
|
||||
LOG(logINFOBLUE, ("Configuring ADC9252:\n"));
|
||||
|
||||
//power mode reset
|
||||
FILE_LOG(logINFO, ("\tPower mode reset\n"));
|
||||
LOG(logINFO, ("\tPower mode reset\n"));
|
||||
AD9252_Set(AD9252_POWER_MODE_REG, AD9252_INT_RESET_VAL);
|
||||
|
||||
//power mode chip run
|
||||
FILE_LOG(logINFO, ("\tPower mode chip run\n"));
|
||||
LOG(logINFO, ("\tPower mode chip run\n"));
|
||||
AD9252_Set(AD9252_POWER_MODE_REG, AD9252_INT_CHIP_RUN_VAL);
|
||||
|
||||
// binary offset
|
||||
FILE_LOG(logINFO, ("\tBinary offset\n"));
|
||||
LOG(logINFO, ("\tBinary offset\n"));
|
||||
AD9252_Set(AD9252_OUT_MODE_REG, AD9252_OUT_BINARY_OFST_VAL);
|
||||
|
||||
//output clock phase
|
||||
#ifdef GOTTHARDD
|
||||
FILE_LOG(logINFO, ("\tOutput clock phase is at default: 180\n"));
|
||||
LOG(logINFO, ("\tOutput clock phase is at default: 180\n"));
|
||||
#else
|
||||
FILE_LOG(logINFO, ("\tOutput clock phase: 60\n"));
|
||||
LOG(logINFO, ("\tOutput clock phase: 60\n"));
|
||||
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_60_VAL);
|
||||
#endif
|
||||
|
||||
// lvds-iee reduced , binary offset
|
||||
FILE_LOG(logINFO, ("\tLvds-iee reduced, binary offset\n"));
|
||||
LOG(logINFO, ("\tLvds-iee reduced, binary offset\n"));
|
||||
AD9252_Set(AD9252_OUT_MODE_REG, AD9252_OUT_LVDS_IEEE_VAL);
|
||||
|
||||
// all devices on chip to receive next command
|
||||
FILE_LOG(logINFO, ("\tAll devices on chip to receive next command\n"));
|
||||
LOG(logINFO, ("\tAll devices on chip to receive next command\n"));
|
||||
AD9252_Set(AD9252_DEV_IND_2_REG,
|
||||
AD9252_CHAN_H_MSK | AD9252_CHAN_G_MSK | AD9252_CHAN_F_MSK | AD9252_CHAN_E_MSK);
|
||||
AD9252_Set(AD9252_DEV_IND_1_REG,
|
||||
@@ -165,13 +165,13 @@ void AD9252_Configure(){
|
||||
AD9252_CLK_CH_DCO_MSK | AD9252_CLK_CH_IFCO_MSK);
|
||||
|
||||
// no test mode
|
||||
FILE_LOG(logINFO, ("\tNo test mode\n"));
|
||||
LOG(logINFO, ("\tNo test mode\n"));
|
||||
AD9252_Set(AD9252_TEST_MODE_REG, AD9252_TST_OFF_VAL);
|
||||
|
||||
#ifdef TESTADC
|
||||
FILE_LOG(logINFOBLUE, ("Putting ADC in Test Mode!\n");
|
||||
LOG(logINFOBLUE, ("Putting ADC in Test Mode!\n");
|
||||
// mixed bit frequency test mode
|
||||
FILE_LOG(logINFO, ("\tMixed bit frequency test mode\n"));
|
||||
LOG(logINFO, ("\tMixed bit frequency test mode\n"));
|
||||
AD9252_Set(AD9252_TEST_MODE_REG, AD9252_TST_MXD_BT_FRQ_VAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ int AD9257_GetVrefVoltage(int mV) {
|
||||
case 4:
|
||||
return 2000;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("Could not convert Adc Vpp from mode to mV\n"));
|
||||
LOG(logERROR, ("Could not convert Adc Vpp from mode to mV\n"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -190,7 +190,7 @@ int AD9257_SetVrefVoltage(int val, int mV) {
|
||||
break;
|
||||
// validation for mV
|
||||
default:
|
||||
FILE_LOG(logERROR, ("mv:%d doesnt exist\n", val));
|
||||
LOG(logERROR, ("mv:%d doesnt exist\n", val));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@@ -198,19 +198,19 @@ int AD9257_SetVrefVoltage(int val, int mV) {
|
||||
// validation for mode
|
||||
switch(mode) {
|
||||
case 0:
|
||||
FILE_LOG(logINFO, ("Setting ADC Vref to 1.0 V (Mode:%d)\n", mode));
|
||||
LOG(logINFO, ("Setting ADC Vref to 1.0 V (Mode:%d)\n", mode));
|
||||
break;
|
||||
case 1:
|
||||
FILE_LOG(logINFO, ("Setting ADC Vref to 1.14 V (Mode:%d)\n", mode));
|
||||
LOG(logINFO, ("Setting ADC Vref to 1.14 V (Mode:%d)\n", mode));
|
||||
break;
|
||||
case 2:
|
||||
FILE_LOG(logINFO, ("Setting ADC Vref to 1.33 V (Mode:%d)\n", mode));
|
||||
LOG(logINFO, ("Setting ADC Vref to 1.33 V (Mode:%d)\n", mode));
|
||||
break;
|
||||
case 3:
|
||||
FILE_LOG(logINFO, ("Setting ADC Vref to 1.6 V (Mode:%d)\n", mode));
|
||||
LOG(logINFO, ("Setting ADC Vref to 1.6 V (Mode:%d)\n", mode));
|
||||
break;
|
||||
case 4:
|
||||
FILE_LOG(logINFO, ("Setting ADC Vref to 2.0 V (Mode:%d)\n", mode));
|
||||
LOG(logINFO, ("Setting ADC Vref to 2.0 V (Mode:%d)\n", mode));
|
||||
break;
|
||||
default:
|
||||
return FAIL;
|
||||
@@ -225,32 +225,32 @@ void AD9257_Set(int addr, int val) {
|
||||
|
||||
u_int32_t codata;
|
||||
codata = val + (addr << 8);
|
||||
FILE_LOG(logINFO, ("\tSetting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr));
|
||||
LOG(logINFO, ("\tSetting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr));
|
||||
serializeToSPI(AD9257_Reg, codata, AD9257_CsMask, AD9257_ADC_NUMBITS,
|
||||
AD9257_ClkMask, AD9257_DigMask, AD9257_DigOffset, 0);
|
||||
}
|
||||
|
||||
void AD9257_Configure(){
|
||||
FILE_LOG(logINFOBLUE, ("Configuring ADC9257:\n"));
|
||||
LOG(logINFOBLUE, ("Configuring ADC9257:\n"));
|
||||
|
||||
//power mode reset
|
||||
FILE_LOG(logINFO, ("\tPower mode reset\n"));
|
||||
LOG(logINFO, ("\tPower mode reset\n"));
|
||||
AD9257_Set(AD9257_POWER_MODE_REG, AD9257_INT_RESET_VAL);
|
||||
|
||||
//power mode chip run
|
||||
FILE_LOG(logINFO, ("\tPower mode chip run\n"));
|
||||
LOG(logINFO, ("\tPower mode chip run\n"));
|
||||
AD9257_Set(AD9257_POWER_MODE_REG, AD9257_INT_CHIP_RUN_VAL);
|
||||
|
||||
// binary offset, lvds-iee reduced
|
||||
FILE_LOG(logINFO, ("\tBinary offset, Lvds-ieee reduced\n"));
|
||||
LOG(logINFO, ("\tBinary offset, Lvds-ieee reduced\n"));
|
||||
AD9257_Set(AD9257_OUT_MODE_REG, AD9257_OUT_BINARY_OFST_VAL | AD9257_OUT_LVDS_IEEE_VAL);
|
||||
|
||||
//output clock phase
|
||||
FILE_LOG(logINFO, ("\tOutput clock phase: 180\n"));
|
||||
LOG(logINFO, ("\tOutput clock phase: 180\n"));
|
||||
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_180_VAL);
|
||||
|
||||
// all devices on chip to receive next command
|
||||
FILE_LOG(logINFO, ("\tAll devices on chip to receive next command\n"));
|
||||
LOG(logINFO, ("\tAll devices on chip to receive next command\n"));
|
||||
AD9257_Set(AD9257_DEV_IND_2_REG,
|
||||
AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK);
|
||||
|
||||
@@ -260,21 +260,21 @@ void AD9257_Configure(){
|
||||
|
||||
// vref
|
||||
#ifdef GOTTHARDD
|
||||
FILE_LOG(logINFO, ("\tVref default at 2.0\n"));
|
||||
LOG(logINFO, ("\tVref default at 2.0\n"));
|
||||
AD9257_SetVrefVoltage(AD9257_VREF_DEFAULT_VAL, 0);
|
||||
#else
|
||||
FILE_LOG(logINFO, ("\tVref 1.33\n"));
|
||||
LOG(logINFO, ("\tVref 1.33\n"));
|
||||
AD9257_SetVrefVoltage(AD9257_VREF_1_33_VAL, 0);
|
||||
#endif
|
||||
|
||||
// no test mode
|
||||
FILE_LOG(logINFO, ("\tNo test mode\n"));
|
||||
LOG(logINFO, ("\tNo test mode\n"));
|
||||
AD9257_Set(AD9257_TEST_MODE_REG, AD9257_TST_OFF_VAL);
|
||||
|
||||
#ifdef TESTADC
|
||||
FILE_LOG(logINFOBLUE, ("Putting ADC in Test Mode!\n");
|
||||
LOG(logINFOBLUE, ("Putting ADC in Test Mode!\n");
|
||||
// mixed bit frequency test mode
|
||||
FILE_LOG(logINFO, ("\tMixed bit frequency test mode\n"));
|
||||
LOG(logINFO, ("\tMixed bit frequency test mode\n"));
|
||||
AD9257_Set(AD9257_TEST_MODE_REG, AD9257_TST_MXD_BT_FRQ_VAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -113,22 +113,22 @@ void ALTERA_PLL_SetDefines(uint32_t creg, uint32_t preg, uint32_t rprmsk, uint32
|
||||
#endif
|
||||
|
||||
void ALTERA_PLL_ResetPLL () {
|
||||
FILE_LOG(logINFO, ("Resetting only PLL\n"));
|
||||
LOG(logINFO, ("Resetting only PLL\n"));
|
||||
|
||||
FILE_LOG(logDEBUG2, ("pllrstmsk:0x%x\n", ALTERA_PLL_Cntrl_PLLRstMask));
|
||||
LOG(logDEBUG2, ("pllrstmsk:0x%x\n", ALTERA_PLL_Cntrl_PLLRstMask));
|
||||
|
||||
bus_w(ALTERA_PLL_Cntrl_Reg, bus_r(ALTERA_PLL_Cntrl_Reg) | ALTERA_PLL_Cntrl_PLLRstMask);
|
||||
FILE_LOG(logDEBUG2, ("Set PLL Reset mSk: ALTERA_PLL_Cntrl_Reg:0x%x\n", bus_r(ALTERA_PLL_Cntrl_Reg)));
|
||||
LOG(logDEBUG2, ("Set PLL Reset mSk: ALTERA_PLL_Cntrl_Reg:0x%x\n", bus_r(ALTERA_PLL_Cntrl_Reg)));
|
||||
|
||||
usleep(ALTERA_PLL_WAIT_TIME_US);
|
||||
|
||||
bus_w(ALTERA_PLL_Cntrl_Reg, bus_r(ALTERA_PLL_Cntrl_Reg) & ~ALTERA_PLL_Cntrl_PLLRstMask);
|
||||
FILE_LOG(logDEBUG2, ("UnSet PLL Reset mSk: ALTERA_PLL_Cntrl_Reg:0x%x\n", bus_r(ALTERA_PLL_Cntrl_Reg)));
|
||||
LOG(logDEBUG2, ("UnSet PLL Reset mSk: ALTERA_PLL_Cntrl_Reg:0x%x\n", bus_r(ALTERA_PLL_Cntrl_Reg)));
|
||||
|
||||
}
|
||||
|
||||
void ALTERA_PLL_ResetPLLAndReconfiguration () {
|
||||
FILE_LOG(logINFO, ("Resetting PLL and Reconfiguration\n"));
|
||||
LOG(logINFO, ("Resetting PLL and Reconfiguration\n"));
|
||||
|
||||
bus_w(ALTERA_PLL_Cntrl_Reg, bus_r(ALTERA_PLL_Cntrl_Reg) | ALTERA_PLL_Cntrl_RcnfgPrmtrRstMask | ALTERA_PLL_Cntrl_PLLRstMask);
|
||||
usleep(ALTERA_PLL_WAIT_TIME_US);
|
||||
@@ -136,7 +136,7 @@ void ALTERA_PLL_ResetPLLAndReconfiguration () {
|
||||
}
|
||||
|
||||
void ALTERA_PLL_SetPllReconfigReg(uint32_t reg, uint32_t val, int useSecondWRMask) {
|
||||
FILE_LOG(logDEBUG1, ("Setting PLL Reconfig Reg, reg:0x%x, val:0x%x, useSecondWRMask:%d)\n", reg, val, useSecondWRMask));
|
||||
LOG(logDEBUG1, ("Setting PLL Reconfig Reg, reg:0x%x, val:0x%x, useSecondWRMask:%d)\n", reg, val, useSecondWRMask));
|
||||
|
||||
uint32_t wrmask = ALTERA_PLL_Cntrl_WrPrmtrMask;
|
||||
#ifdef JUNGFRAUD
|
||||
@@ -145,38 +145,38 @@ void ALTERA_PLL_SetPllReconfigReg(uint32_t reg, uint32_t val, int useSecondWRMas
|
||||
}
|
||||
#endif
|
||||
|
||||
FILE_LOG(logDEBUG2, ("pllparamreg:0x%x pllcontrolreg:0x%x addrofst:%d addrmsk:0x%x wrmask:0x%x\n",
|
||||
LOG(logDEBUG2, ("pllparamreg:0x%x pllcontrolreg:0x%x addrofst:%d addrmsk:0x%x wrmask:0x%x\n",
|
||||
ALTERA_PLL_Param_Reg, ALTERA_PLL_Cntrl_Reg, ALTERA_PLL_Cntrl_AddrOfst, ALTERA_PLL_Cntrl_AddrMask, wrmask));
|
||||
|
||||
// set parameter
|
||||
bus_w(ALTERA_PLL_Param_Reg, val);
|
||||
FILE_LOG(logDEBUG2, ("Set Parameter: ALTERA_PLL_Param_Reg:0x%x\n", bus_r(ALTERA_PLL_Param_Reg)));
|
||||
LOG(logDEBUG2, ("Set Parameter: ALTERA_PLL_Param_Reg:0x%x\n", bus_r(ALTERA_PLL_Param_Reg)));
|
||||
usleep(ALTERA_PLL_WAIT_TIME_US);
|
||||
|
||||
// set address
|
||||
bus_w(ALTERA_PLL_Cntrl_Reg, (reg << ALTERA_PLL_Cntrl_AddrOfst) & ALTERA_PLL_Cntrl_AddrMask);
|
||||
FILE_LOG(logDEBUG2, ("Set Address: ALTERA_PLL_Cntrl_Reg:0x%x\n", bus_r(ALTERA_PLL_Cntrl_Reg)));
|
||||
LOG(logDEBUG2, ("Set Address: ALTERA_PLL_Cntrl_Reg:0x%x\n", bus_r(ALTERA_PLL_Cntrl_Reg)));
|
||||
usleep(ALTERA_PLL_WAIT_TIME_US);
|
||||
|
||||
//write parameter
|
||||
bus_w(ALTERA_PLL_Cntrl_Reg, bus_r(ALTERA_PLL_Cntrl_Reg) | wrmask);
|
||||
FILE_LOG(logDEBUG2, ("Set WR bit: ALTERA_PLL_Cntrl_Reg:0x%x\n", bus_r(ALTERA_PLL_Cntrl_Reg)));
|
||||
LOG(logDEBUG2, ("Set WR bit: ALTERA_PLL_Cntrl_Reg:0x%x\n", bus_r(ALTERA_PLL_Cntrl_Reg)));
|
||||
|
||||
usleep(ALTERA_PLL_WAIT_TIME_US);
|
||||
|
||||
bus_w(ALTERA_PLL_Cntrl_Reg, bus_r(ALTERA_PLL_Cntrl_Reg) & ~wrmask);
|
||||
FILE_LOG(logDEBUG2, ("Unset WR bit: ALTERA_PLL_Cntrl_Reg:0x%x\n", bus_r(ALTERA_PLL_Cntrl_Reg)));
|
||||
LOG(logDEBUG2, ("Unset WR bit: ALTERA_PLL_Cntrl_Reg:0x%x\n", bus_r(ALTERA_PLL_Cntrl_Reg)));
|
||||
|
||||
usleep(ALTERA_PLL_WAIT_TIME_US);
|
||||
}
|
||||
|
||||
void ALTERA_PLL_SetPhaseShift(int32_t phase, int clkIndex, int pos) {
|
||||
FILE_LOG(logINFO, ("\tWriting PLL Phase Shift\n"));
|
||||
LOG(logINFO, ("\tWriting PLL Phase Shift\n"));
|
||||
uint32_t value = (((phase << ALTERA_PLL_SHIFT_NUM_SHIFTS_OFST) & ALTERA_PLL_SHIFT_NUM_SHIFTS_MSK) |
|
||||
((clkIndex << ALTERA_PLL_SHIFT_CNT_SELECT_OFST) & ALTERA_PLL_SHIFT_CNT_SELECT_MSK) |
|
||||
(pos ? ALTERA_PLL_SHIFT_UP_DOWN_POS_VAL : ALTERA_PLL_SHIFT_UP_DOWN_NEG_VAL));
|
||||
|
||||
FILE_LOG(logDEBUG1, ("C%d phase word:0x%08x\n", clkIndex, value));
|
||||
LOG(logDEBUG1, ("C%d phase word:0x%08x\n", clkIndex, value));
|
||||
|
||||
int useSecondWR = 0;
|
||||
#ifdef JUNGFRAUD
|
||||
@@ -190,12 +190,12 @@ void ALTERA_PLL_SetPhaseShift(int32_t phase, int clkIndex, int pos) {
|
||||
}
|
||||
|
||||
void ALTERA_PLL_SetModePolling() {
|
||||
FILE_LOG(logINFO, ("\tSetting Polling Mode\n"));
|
||||
LOG(logINFO, ("\tSetting Polling Mode\n"));
|
||||
ALTERA_PLL_SetPllReconfigReg(ALTERA_PLL_MODE_REG, ALTERA_PLL_MODE_PLLNG_MD_VAL, 0);
|
||||
}
|
||||
|
||||
int ALTERA_PLL_SetOuputFrequency (int clkIndex, int pllVCOFreqMhz, int value) {
|
||||
FILE_LOG(logDEBUG1, ("C%d: Setting output frequency to %d (pllvcofreq: %dMhz)\n", clkIndex, value, pllVCOFreqMhz));
|
||||
LOG(logDEBUG1, ("C%d: Setting output frequency to %d (pllvcofreq: %dMhz)\n", clkIndex, value, pllVCOFreqMhz));
|
||||
|
||||
// calculate output frequency
|
||||
float total_div = (float)pllVCOFreqMhz / (float)value;
|
||||
@@ -210,14 +210,14 @@ int ALTERA_PLL_SetOuputFrequency (int clkIndex, int pllVCOFreqMhz, int value) {
|
||||
++high_count;
|
||||
odd_division = 1;
|
||||
}
|
||||
FILE_LOG(logINFO, ("\tC%d: Low:%d, High:%d, Odd:%d\n", clkIndex, low_count, high_count, odd_division));
|
||||
LOG(logINFO, ("\tC%d: Low:%d, High:%d, Odd:%d\n", clkIndex, low_count, high_count, odd_division));
|
||||
|
||||
// command to set output frequency
|
||||
uint32_t val = (((low_count << ALTERA_PLL_C_COUNTER_LW_CNT_OFST) & ALTERA_PLL_C_COUNTER_LW_CNT_MSK) |
|
||||
((high_count << ALTERA_PLL_C_COUNTER_HGH_CNT_OFST) & ALTERA_PLL_C_COUNTER_HGH_CNT_MSK) |
|
||||
((odd_division << ALTERA_PLL_C_COUNTER_ODD_DVSN_OFST) & ALTERA_PLL_C_COUNTER_ODD_DVSN_MSK) |
|
||||
((clkIndex << ALTERA_PLL_C_COUNTER_SLCT_OFST) & ALTERA_PLL_C_COUNTER_SLCT_MSK));
|
||||
FILE_LOG(logDEBUG1, ("C%d word:0x%08x\n", clkIndex, val));
|
||||
LOG(logDEBUG1, ("C%d word:0x%08x\n", clkIndex, val));
|
||||
|
||||
// write frequency (post-scale output counter C)
|
||||
ALTERA_PLL_SetPllReconfigReg(ALTERA_PLL_C_COUNTER_REG, val, 0);
|
||||
|
||||
@@ -76,10 +76,10 @@ int ALTERA_PLL_C10_GetMaxPhaseShiftStepsofVCO() {
|
||||
}
|
||||
|
||||
void ALTERA_PLL_C10_Reconfigure(int pllIndex) {
|
||||
FILE_LOG(logINFO, ("\tReconfiguring PLL %d\n", pllIndex));
|
||||
LOG(logINFO, ("\tReconfiguring PLL %d\n", pllIndex));
|
||||
|
||||
// write anything to base address to start reconfiguring
|
||||
FILE_LOG(logDEBUG1, ("\tWriting 1 to base address 0x%x to start reconfiguring\n", ALTERA_PLL_C10_BaseAddress[pllIndex]));
|
||||
LOG(logDEBUG1, ("\tWriting 1 to base address 0x%x to start reconfiguring\n", ALTERA_PLL_C10_BaseAddress[pllIndex]));
|
||||
bus_w_csp1(ALTERA_PLL_C10_BaseAddress[pllIndex], 0x1);
|
||||
usleep(ALTERA_PLL_C10_WAIT_TIME_US);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ void ALTERA_PLL_C10_Reconfigure(int pllIndex) {
|
||||
void ALTERA_PLL_C10_ResetPLL (int pllIndex) {
|
||||
uint32_t resetreg = ALTERA_PLL_C10_Reset_Reg[pllIndex];
|
||||
uint32_t resetmsk = ALTERA_PLL_C10_Reset_Msk[pllIndex];
|
||||
FILE_LOG(logINFO, ("Resetting PLL %d\n", pllIndex));
|
||||
LOG(logINFO, ("Resetting PLL %d\n", pllIndex));
|
||||
bus_w_csp1(resetreg, bus_r_csp1(resetreg) | resetmsk);
|
||||
|
||||
usleep(ALTERA_PLL_C10_WAIT_TIME_US);
|
||||
@@ -95,7 +95,7 @@ void ALTERA_PLL_C10_ResetPLL (int pllIndex) {
|
||||
|
||||
|
||||
void ALTERA_PLL_C10_SetPhaseShift(int pllIndex, int clkIndex, int phase, int pos) {
|
||||
FILE_LOG(logINFO, ("\tC%d: Writing PLL %d Phase Shift [phase:%d, pos dir:%d]\n", clkIndex, pllIndex, phase, pos));
|
||||
LOG(logINFO, ("\tC%d: Writing PLL %d Phase Shift [phase:%d, pos dir:%d]\n", clkIndex, pllIndex, phase, pos));
|
||||
|
||||
uint32_t addr = ALTERA_PLL_C10_BaseAddress[pllIndex] + (ALTERA_PLL_C10_PHASE_SHIFT_BASE_REG + (int)clkIndex) * ALTERA_PLL_C10_Reg_offset;
|
||||
int maxshifts = ALTERA_PLL_C10_MAX_SHIFTS_PER_OPERATION;
|
||||
@@ -105,7 +105,7 @@ void ALTERA_PLL_C10_SetPhaseShift(int pllIndex, int clkIndex, int phase, int pos
|
||||
int phaseToDo = (phase > maxshifts) ? maxshifts : phase;
|
||||
uint32_t value = (((phaseToDo << ALTERA_PLL_C10_SHIFT_NUM_SHIFTS_OFST) & ALTERA_PLL_C10_SHIFT_NUM_SHIFTS_MSK) |
|
||||
(pos ? ALTERA_PLL_C10_SHIFT_UP_DOWN_POS_VAL : ALTERA_PLL_C10_SHIFT_UP_DOWN_NEG_VAL));
|
||||
FILE_LOG(logDEBUG1, ("\t[addr:0x%x, phaseTodo:%d phaseleft:%d phase word:0x%08x]\n", addr, phaseToDo, phase, value));
|
||||
LOG(logDEBUG1, ("\t[addr:0x%x, phaseTodo:%d phaseleft:%d phase word:0x%08x]\n", addr, phaseToDo, phase, value));
|
||||
bus_w_csp1(addr, value);
|
||||
|
||||
ALTERA_PLL_C10_Reconfigure(pllIndex);
|
||||
@@ -116,7 +116,7 @@ void ALTERA_PLL_C10_SetPhaseShift(int pllIndex, int clkIndex, int phase, int pos
|
||||
|
||||
void ALTERA_PLL_C10_SetOuputFrequency (int pllIndex, int clkIndex, int value) {
|
||||
int pllVCOFreqHz = ALTERA_PLL_C10_VCO_FREQ[pllIndex];
|
||||
FILE_LOG(logDEBUG1, ("\tC%d: Setting output frequency for pll %d to %d (pllvcofreq: %dHz)\n", clkIndex, pllIndex, value, pllVCOFreqHz));
|
||||
LOG(logDEBUG1, ("\tC%d: Setting output frequency for pll %d to %d (pllvcofreq: %dHz)\n", clkIndex, pllIndex, value, pllVCOFreqHz));
|
||||
|
||||
// calculate output frequency
|
||||
float total_div = (float)pllVCOFreqHz / (float)value;
|
||||
@@ -131,14 +131,14 @@ void ALTERA_PLL_C10_SetOuputFrequency (int pllIndex, int clkIndex, int value) {
|
||||
++high_count;
|
||||
odd_division = 1;
|
||||
}
|
||||
FILE_LOG(logINFO, ("\tC%d: Low:%d, High:%d, Odd:%d\n", clkIndex, low_count, high_count, odd_division));
|
||||
LOG(logINFO, ("\tC%d: Low:%d, High:%d, Odd:%d\n", clkIndex, low_count, high_count, odd_division));
|
||||
|
||||
// command to set output frequency
|
||||
uint32_t addr = ALTERA_PLL_C10_BaseAddress[pllIndex] + (ALTERA_PLL_C10_C_COUNTER_BASE_REG + (int)clkIndex) * ALTERA_PLL_C10_Reg_offset;
|
||||
uint32_t val = (((low_count << ALTERA_PLL_C10_C_COUNTER_LW_CNT_OFST) & ALTERA_PLL_C10_C_COUNTER_LW_CNT_MSK) |
|
||||
((high_count << ALTERA_PLL_C10_C_COUNTER_HGH_CNT_OFST) & ALTERA_PLL_C10_C_COUNTER_HGH_CNT_MSK) |
|
||||
((odd_division << ALTERA_PLL_C10_C_COUNTER_ODD_DVSN_OFST) & ALTERA_PLL_C10_C_COUNTER_ODD_DVSN_MSK));
|
||||
FILE_LOG(logDEBUG1, ("\t[addr:0x%x, word:0x%08x]\n", addr, val));
|
||||
LOG(logDEBUG1, ("\t[addr:0x%x, word:0x%08x]\n", addr, val));
|
||||
|
||||
// write frequency
|
||||
bus_w_csp1(addr, val);
|
||||
|
||||
@@ -20,7 +20,7 @@ char ASIC_Driver_DriverFileName[MAX_STR_LENGTH];
|
||||
|
||||
|
||||
void ASIC_Driver_SetDefines(char* driverfname) {
|
||||
FILE_LOG(logINFOBLUE, ("Configuring ASIC Driver to %s\n", driverfname));
|
||||
LOG(logINFOBLUE, ("Configuring ASIC Driver to %s\n", driverfname));
|
||||
memset(ASIC_Driver_DriverFileName, 0, MAX_STR_LENGTH);
|
||||
strcpy(ASIC_Driver_DriverFileName, driverfname);
|
||||
}
|
||||
@@ -28,14 +28,14 @@ void ASIC_Driver_SetDefines(char* driverfname) {
|
||||
int ASIC_Driver_Set (int index, int length, char* buffer) {
|
||||
char fname[MAX_STR_LENGTH];
|
||||
sprintf(fname, "%s%d", ASIC_Driver_DriverFileName, index + 1);
|
||||
FILE_LOG(logDEBUG2, ("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname));
|
||||
LOG(logDEBUG2, ("\t[chip index: %d, length: %d, fname: %s]\n", index, length, fname));
|
||||
{
|
||||
FILE_LOG(logDEBUG2, ("\t[values: \n"));
|
||||
LOG(logDEBUG2, ("\t[values: \n"));
|
||||
int i;
|
||||
for (i = 0; i < length; ++i) {
|
||||
FILE_LOG(logDEBUG2, ("\t%d: 0x%02hhx\n", i, buffer[i]));
|
||||
LOG(logDEBUG2, ("\t%d: 0x%02hhx\n", i, buffer[i]));
|
||||
}
|
||||
FILE_LOG(logDEBUG2, ("\t]\n"));
|
||||
LOG(logDEBUG2, ("\t]\n"));
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
@@ -43,7 +43,7 @@ int ASIC_Driver_Set (int index, int length, char* buffer) {
|
||||
#endif
|
||||
int fd=open(fname, O_RDWR);
|
||||
if (fd == -1) {
|
||||
FILE_LOG(logERROR, ("Could not open file %s for writing to control ASIC (%d)\n", fname, index));
|
||||
LOG(logERROR, ("Could not open file %s for writing to control ASIC (%d)\n", fname, index));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ int ASIC_Driver_Set (int index, int length, char* buffer) {
|
||||
// transfer command
|
||||
int status = ioctl(fd, SPI_IOC_MESSAGE(1), &transfer);
|
||||
if (status < 0) {
|
||||
FILE_LOG(logERROR, ("Could not send command to ASIC\n"));
|
||||
LOG(logERROR, ("Could not send command to ASIC\n"));
|
||||
perror("SPI_IOC_MESSAGE");
|
||||
close(fd);
|
||||
return FAIL;
|
||||
|
||||
@@ -15,14 +15,14 @@ int DAC6571_HardMaxVoltage = 0;
|
||||
char DAC6571_DriverFileName[MAX_STR_LENGTH];
|
||||
|
||||
void DAC6571_SetDefines(int hardMaxV, char* driverfname) {
|
||||
FILE_LOG(logINFOBLUE, ("Configuring High Voltage to %s (hard max: %dV)\n", driverfname, hardMaxV));
|
||||
LOG(logINFOBLUE, ("Configuring High Voltage to %s (hard max: %dV)\n", driverfname, hardMaxV));
|
||||
DAC6571_HardMaxVoltage = hardMaxV;
|
||||
memset(DAC6571_DriverFileName, 0, MAX_STR_LENGTH);
|
||||
strcpy(DAC6571_DriverFileName, driverfname);
|
||||
}
|
||||
|
||||
int DAC6571_Set (int val) {
|
||||
FILE_LOG(logDEBUG1, ("Setting high voltage to %d\n", val));
|
||||
LOG(logDEBUG1, ("Setting high voltage to %d\n", val));
|
||||
if (val < 0)
|
||||
return FAIL;
|
||||
|
||||
@@ -34,12 +34,12 @@ int DAC6571_Set (int val) {
|
||||
DAC6571_MIN_DAC_VAL, DAC6571_MAX_DAC_VAL,
|
||||
val, &dacvalue);
|
||||
|
||||
FILE_LOG(logINFO, ("\t%dV (dacval %d)\n", val, dacvalue));
|
||||
LOG(logINFO, ("\t%dV (dacval %d)\n", val, dacvalue));
|
||||
|
||||
//open file
|
||||
FILE* fd=fopen(DAC6571_DriverFileName,"w");
|
||||
if (fd==NULL) {
|
||||
FILE_LOG(logERROR, ("Could not open file %s for writing to set high voltage\n", DAC6571_DriverFileName));
|
||||
LOG(logERROR, ("Could not open file %s for writing to set high voltage\n", DAC6571_DriverFileName));
|
||||
return FAIL;
|
||||
}
|
||||
//convert to string, add 0 and write to file
|
||||
|
||||
@@ -101,8 +101,8 @@ uint32_t I2C_Transfer_Command_Fifo_Reg = 0x0;
|
||||
void I2C_ConfigureI2CCore(uint32_t creg, uint32_t sreg,
|
||||
uint32_t rreg, uint32_t rlvlreg,
|
||||
uint32_t slreg, uint32_t shreg, uint32_t sdreg, uint32_t treg) {
|
||||
FILE_LOG(logINFO, ("\tConfiguring I2C Core for %d kbps:\n", I2C_DATA_RATE_KBPS));
|
||||
FILE_LOG(logDEBUG1,("controlreg,:0x%x, statusreg,:0x%x, "
|
||||
LOG(logINFO, ("\tConfiguring I2C Core for %d kbps:\n", I2C_DATA_RATE_KBPS));
|
||||
LOG(logDEBUG1,("controlreg,:0x%x, statusreg,:0x%x, "
|
||||
"rxrdatafiforeg: 0x%x, rxdatafifocountreg,:0x%x, "
|
||||
"scllow,:0x%x, sclhighreg,:0x%x, sdaholdreg,:0x%x, transfercmdreg,:0x%x\n",
|
||||
creg, sreg, rreg, rlvlreg, slreg, shreg, sdreg, treg));
|
||||
@@ -128,54 +128,54 @@ void I2C_ConfigureI2CCore(uint32_t creg, uint32_t sreg,
|
||||
// convert to us, then to clock (defined in blackfin.h)
|
||||
uint32_t sdaDataHoldCount = ((sdaDataHoldTimeNs / 1000.00) * I2C_CLOCK_MHZ);
|
||||
|
||||
FILE_LOG(logINFO, ("\tSetting SCL Low Period: %d ns (%d clocks)\n", sclLowPeriodNs, sclLowPeriodCount));
|
||||
LOG(logINFO, ("\tSetting SCL Low Period: %d ns (%d clocks)\n", sclLowPeriodNs, sclLowPeriodCount));
|
||||
bus_w(I2C_Scl_Low_Count_Reg, bus_r(I2C_Scl_Low_Count_Reg) |
|
||||
((sclLowPeriodCount << I2C_SCL_LOW_COUNT_PERIOD_OFST) & I2C_SCL_LOW_COUNT_PERIOD_MSK));
|
||||
FILE_LOG(logDEBUG1, ("SCL Low reg:0x%x\n", bus_r(I2C_Scl_Low_Count_Reg)));
|
||||
LOG(logDEBUG1, ("SCL Low reg:0x%x\n", bus_r(I2C_Scl_Low_Count_Reg)));
|
||||
|
||||
FILE_LOG(logINFO, ("\tSetting SCL High Period: %d ns (%d clocks)\n", sclLowPeriodNs, sclLowPeriodCount));
|
||||
LOG(logINFO, ("\tSetting SCL High Period: %d ns (%d clocks)\n", sclLowPeriodNs, sclLowPeriodCount));
|
||||
bus_w(I2C_Scl_High_Count_Reg, bus_r(I2C_Scl_High_Count_Reg) |
|
||||
((sclLowPeriodCount << I2C_SCL_HIGH_COUNT_PERIOD_OFST) & I2C_SCL_HIGH_COUNT_PERIOD_MSK));
|
||||
FILE_LOG(logDEBUG1, ("SCL High reg:0x%x\n", bus_r(I2C_Scl_High_Count_Reg)));
|
||||
LOG(logDEBUG1, ("SCL High reg:0x%x\n", bus_r(I2C_Scl_High_Count_Reg)));
|
||||
|
||||
FILE_LOG(logINFO, ("\tSetting SDA Hold Time: %d ns (%d clocks)\n", sdaDataHoldTimeNs, sdaDataHoldCount));
|
||||
LOG(logINFO, ("\tSetting SDA Hold Time: %d ns (%d clocks)\n", sdaDataHoldTimeNs, sdaDataHoldCount));
|
||||
bus_w(I2C_Sda_Hold_Reg, bus_r(I2C_Sda_Hold_Reg) |
|
||||
((sdaDataHoldCount << I2C_SDA_HOLD_COUNT_PERIOD_OFST) & I2C_SDA_HOLD_COUNT_PERIOD_MSK));
|
||||
FILE_LOG(logDEBUG1, ("SDA Hold reg:0x%x\n", bus_r(I2C_Sda_Hold_Reg)));
|
||||
LOG(logDEBUG1, ("SDA Hold reg:0x%x\n", bus_r(I2C_Sda_Hold_Reg)));
|
||||
|
||||
FILE_LOG(logINFO, ("\tEnabling core and bus speed to fast (up to 400 kbps)\n"));
|
||||
LOG(logINFO, ("\tEnabling core and bus speed to fast (up to 400 kbps)\n"));
|
||||
bus_w(I2C_Control_Reg, bus_r(I2C_Control_Reg) |
|
||||
I2C_CTRL_ENBLE_CORE_MSK | I2C_CTRL_BUS_SPEED_FAST_400_VAL);// fixme: (works?)
|
||||
FILE_LOG(logDEBUG1, ("Control reg:0x%x\n", bus_r(I2C_Control_Reg)));
|
||||
LOG(logDEBUG1, ("Control reg:0x%x\n", bus_r(I2C_Control_Reg)));
|
||||
//The INA226 supports the transmission protocol for fast mode (1 kHz to 400 kHz) and high-speed mode (1 kHz to 2.94 MHz).
|
||||
}
|
||||
|
||||
uint32_t I2C_Read(uint32_t devId, uint32_t addr) {
|
||||
FILE_LOG(logDEBUG2, (" ================================================\n"));
|
||||
FILE_LOG(logDEBUG2, (" Reading from I2C device 0x%x and reg 0x%x\n", devId, addr));
|
||||
LOG(logDEBUG2, (" ================================================\n"));
|
||||
LOG(logDEBUG2, (" Reading from I2C device 0x%x and reg 0x%x\n", devId, addr));
|
||||
// device Id mask
|
||||
uint32_t devIdMask = ((devId << I2C_TFR_CMD_ADDR_OFST) & I2C_TFR_CMD_ADDR_MSK);
|
||||
FILE_LOG(logDEBUG2, (" devId:0x%x\n", devIdMask));
|
||||
LOG(logDEBUG2, (" devId:0x%x\n", devIdMask));
|
||||
|
||||
// write I2C ID
|
||||
bus_w(I2C_Transfer_Command_Fifo_Reg, (devIdMask & ~(I2C_TFR_CMD_RW_MSK)));
|
||||
FILE_LOG(logDEBUG2, (" write devID and R/-W:0x%x\n", (devIdMask & ~(I2C_TFR_CMD_RW_MSK))));
|
||||
LOG(logDEBUG2, (" write devID and R/-W:0x%x\n", (devIdMask & ~(I2C_TFR_CMD_RW_MSK))));
|
||||
|
||||
// write register addr
|
||||
bus_w(I2C_Transfer_Command_Fifo_Reg, addr);
|
||||
FILE_LOG(logDEBUG2, (" write addr:0x%x\n", addr));
|
||||
LOG(logDEBUG2, (" write addr:0x%x\n", addr));
|
||||
|
||||
// repeated start with read (repeated start needed here because it was in write operation mode earlier, for the device ID)
|
||||
bus_w(I2C_Transfer_Command_Fifo_Reg, (devIdMask | I2C_TFR_CMD_RPTD_STRT_MSK | I2C_TFR_CMD_RW_READ_VAL));
|
||||
FILE_LOG(logDEBUG2, (" repeated start:0x%x\n", (devIdMask | I2C_TFR_CMD_RPTD_STRT_MSK | I2C_TFR_CMD_RW_READ_VAL)));
|
||||
LOG(logDEBUG2, (" repeated start:0x%x\n", (devIdMask | I2C_TFR_CMD_RPTD_STRT_MSK | I2C_TFR_CMD_RW_READ_VAL)));
|
||||
|
||||
// continue reading
|
||||
bus_w(I2C_Transfer_Command_Fifo_Reg, 0x0);
|
||||
FILE_LOG(logDEBUG2, (" continue reading:0x%x\n", 0x0));
|
||||
LOG(logDEBUG2, (" continue reading:0x%x\n", 0x0));
|
||||
|
||||
// stop reading
|
||||
bus_w(I2C_Transfer_Command_Fifo_Reg, I2C_TFR_CMD_STOP_MSK);
|
||||
FILE_LOG(logDEBUG2, (" stop reading:0x%x\n", I2C_TFR_CMD_STOP_MSK));
|
||||
LOG(logDEBUG2, (" stop reading:0x%x\n", I2C_TFR_CMD_STOP_MSK));
|
||||
|
||||
// read value
|
||||
uint32_t retval = 0;
|
||||
@@ -185,56 +185,56 @@ uint32_t I2C_Read(uint32_t devId, uint32_t addr) {
|
||||
int status = 1;
|
||||
while(status) {
|
||||
status = bus_r(I2C_Status_Reg) & I2C_STATUS_BUSY_MSK;
|
||||
FILE_LOG(logDEBUG2, (" status:%d\n", status));
|
||||
LOG(logDEBUG2, (" status:%d\n", status));
|
||||
usleep(0);
|
||||
}
|
||||
// get rx fifo level (get number of bytes to be received)
|
||||
int level = bus_r(I2C_Rx_Data_Fifo_Level_Reg);
|
||||
FILE_LOG(logDEBUG2, (" level:%d\n", level));
|
||||
LOG(logDEBUG2, (" level:%d\n", level));
|
||||
|
||||
int iloop = level - 1;
|
||||
|
||||
// level bytes to read, read 1 byte at a time
|
||||
for (iloop = level - 1; iloop >= 0; --iloop) {
|
||||
u_int16_t byte = bus_r(I2C_Rx_Data_Fifo_Reg) & I2C_RX_DATA_FIFO_RXDATA_MSK;
|
||||
FILE_LOG(logDEBUG2, (" byte nr %d:0x%x\n", iloop, byte));
|
||||
LOG(logDEBUG2, (" byte nr %d:0x%x\n", iloop, byte));
|
||||
// push by 1 byte at a time
|
||||
retval |= (byte << (8 * iloop));
|
||||
}
|
||||
FILE_LOG(logDEBUG2, (" retval:0x%x\n", retval));
|
||||
FILE_LOG(logDEBUG2, (" ================================================\n"));
|
||||
LOG(logDEBUG2, (" retval:0x%x\n", retval));
|
||||
LOG(logDEBUG2, (" ================================================\n"));
|
||||
return retval;
|
||||
}
|
||||
|
||||
void I2C_Write(uint32_t devId, uint32_t addr, uint16_t data) {
|
||||
FILE_LOG(logDEBUG2, (" ================================================\n"));
|
||||
FILE_LOG(logDEBUG2, (" Writing to I2C (Device:0x%x, reg:0x%x, data:%d)\n", devId, addr, data));
|
||||
LOG(logDEBUG2, (" ================================================\n"));
|
||||
LOG(logDEBUG2, (" Writing to I2C (Device:0x%x, reg:0x%x, data:%d)\n", devId, addr, data));
|
||||
// device Id mask
|
||||
uint32_t devIdMask = ((devId << I2C_TFR_CMD_ADDR_OFST) & I2C_TFR_CMD_ADDR_MSK);
|
||||
FILE_LOG(logDEBUG2, (" devId:0x%x\n", devId));
|
||||
LOG(logDEBUG2, (" devId:0x%x\n", devId));
|
||||
|
||||
// write I2C ID
|
||||
bus_w(I2C_Transfer_Command_Fifo_Reg, (devIdMask & ~(I2C_TFR_CMD_RW_MSK)));
|
||||
FILE_LOG(logDEBUG2, (" write devID and R/-W:0x%x\n", (devIdMask & ~(I2C_TFR_CMD_RW_MSK))));
|
||||
LOG(logDEBUG2, (" write devID and R/-W:0x%x\n", (devIdMask & ~(I2C_TFR_CMD_RW_MSK))));
|
||||
|
||||
// write register addr
|
||||
bus_w(I2C_Transfer_Command_Fifo_Reg, addr);
|
||||
FILE_LOG(logDEBUG2, (" write addr:0x%x\n", addr));
|
||||
LOG(logDEBUG2, (" write addr:0x%x\n", addr));
|
||||
|
||||
// do not do the repeated start as it is already in write operation mode (else it wont work)
|
||||
|
||||
uint8_t msb = (uint8_t)((data & 0xFF00) >> 8);
|
||||
uint8_t lsb = (uint8_t)(data & 0x00FF);
|
||||
FILE_LOG(logDEBUG2, (" msb:0x%02x, lsb:0x%02x\n", msb, lsb));
|
||||
LOG(logDEBUG2, (" msb:0x%02x, lsb:0x%02x\n", msb, lsb));
|
||||
|
||||
// writing data MSB
|
||||
bus_w(I2C_Transfer_Command_Fifo_Reg, ((msb << I2C_TFR_CMD_DATA_FR_WR_OFST) & I2C_TFR_CMD_DATA_FR_WR_MSK));
|
||||
FILE_LOG(logDEBUG2, (" write msb:0x%02x\n", ((msb << I2C_TFR_CMD_DATA_FR_WR_OFST) & I2C_TFR_CMD_DATA_FR_WR_MSK)));
|
||||
LOG(logDEBUG2, (" write msb:0x%02x\n", ((msb << I2C_TFR_CMD_DATA_FR_WR_OFST) & I2C_TFR_CMD_DATA_FR_WR_MSK)));
|
||||
|
||||
// writing data LSB and stop writing bit
|
||||
bus_w(I2C_Transfer_Command_Fifo_Reg, ((lsb << I2C_TFR_CMD_DATA_FR_WR_OFST) & I2C_TFR_CMD_DATA_FR_WR_MSK) | I2C_TFR_CMD_STOP_MSK);
|
||||
FILE_LOG(logDEBUG2, (" write lsb and stop writing:0x%x\n", ((lsb << I2C_TFR_CMD_DATA_FR_WR_OFST) & I2C_TFR_CMD_DATA_FR_WR_MSK) | I2C_TFR_CMD_STOP_MSK));
|
||||
FILE_LOG(logDEBUG2, (" ================================================\n"));
|
||||
LOG(logDEBUG2, (" write lsb and stop writing:0x%x\n", ((lsb << I2C_TFR_CMD_DATA_FR_WR_OFST) & I2C_TFR_CMD_DATA_FR_WR_MSK) | I2C_TFR_CMD_STOP_MSK));
|
||||
LOG(logDEBUG2, (" ================================================\n"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,21 +63,21 @@ int INA226_Calibration_Register_Value = 0;
|
||||
void INA226_ConfigureI2CCore(double rOhm, uint32_t creg, uint32_t sreg,
|
||||
uint32_t rreg, uint32_t rlvlreg,
|
||||
uint32_t slreg, uint32_t shreg, uint32_t sdreg, uint32_t treg) {
|
||||
FILE_LOG(logINFOBLUE, ("Configuring INA226\n"));
|
||||
FILE_LOG(logDEBUG1, ("Shunt ohm resistor: %f\n", rOhm));
|
||||
LOG(logINFOBLUE, ("Configuring INA226\n"));
|
||||
LOG(logDEBUG1, ("Shunt ohm resistor: %f\n", rOhm));
|
||||
INA226_Shunt_Resistor_Ohm = rOhm;
|
||||
|
||||
I2C_ConfigureI2CCore(creg, sreg, rreg, rlvlreg, slreg, shreg, sdreg, treg);
|
||||
}
|
||||
|
||||
void INA226_CalibrateCurrentRegister(uint32_t deviceId) {
|
||||
FILE_LOG(logINFO, ("Calibrating Current Register for Device ID: 0x%x\n", deviceId));
|
||||
LOG(logINFO, ("Calibrating Current Register for Device ID: 0x%x\n", deviceId));
|
||||
// get calibration value based on shunt resistor
|
||||
uint16_t calVal = ((uint16_t)INA226_getCalibrationValue(INA226_Shunt_Resistor_Ohm)) & INA226_CALIBRATION_MSK;
|
||||
FILE_LOG(logINFO, ("\tCalculated calibration reg value: 0x%0x (%d)\n", calVal, calVal));
|
||||
LOG(logINFO, ("\tCalculated calibration reg value: 0x%0x (%d)\n", calVal, calVal));
|
||||
|
||||
calVal = ((double)calVal / INA226_CALIBRATION_CURRENT_TOLERANCE) + 0.5;
|
||||
FILE_LOG(logINFO, ("\tRealculated (for tolerance) calibration reg value: 0x%0x (%d)\n", calVal, calVal));
|
||||
LOG(logINFO, ("\tRealculated (for tolerance) calibration reg value: 0x%0x (%d)\n", calVal, calVal));
|
||||
INA226_Calibration_Register_Value = calVal;
|
||||
|
||||
// calibrate current register
|
||||
@@ -86,71 +86,71 @@ void INA226_CalibrateCurrentRegister(uint32_t deviceId) {
|
||||
// read back calibration register
|
||||
int retval = I2C_Read(deviceId, INA226_CALIBRATION_REG);
|
||||
if (retval != calVal) {
|
||||
FILE_LOG(logERROR, ("Cannot set calibration register for I2C. Set 0x%x, read 0x%x\n", calVal, retval));
|
||||
LOG(logERROR, ("Cannot set calibration register for I2C. Set 0x%x, read 0x%x\n", calVal, retval));
|
||||
}
|
||||
}
|
||||
|
||||
int INA226_ReadVoltage(uint32_t deviceId) {
|
||||
FILE_LOG(logDEBUG1, (" Reading voltage\n"));
|
||||
LOG(logDEBUG1, (" Reading voltage\n"));
|
||||
uint32_t regval = I2C_Read(deviceId, INA226_BUS_VOLTAGE_REG);
|
||||
FILE_LOG(logDEBUG1, (" bus voltage reg: 0x%08x\n", regval));
|
||||
LOG(logDEBUG1, (" bus voltage reg: 0x%08x\n", regval));
|
||||
|
||||
// value in uV
|
||||
int voltageuV = 0;
|
||||
ConvertToDifferentRange(0, INA226_BUS_VOLTAGE_MX_STPS,
|
||||
INA226_BUS_VOLTAGE_VMIN_UV, INA226_BUS_VOLTAGE_VMAX_UV,
|
||||
regval, &voltageuV);
|
||||
FILE_LOG(logDEBUG1, (" voltage: 0x%d uV\n", voltageuV));
|
||||
LOG(logDEBUG1, (" voltage: 0x%d uV\n", voltageuV));
|
||||
|
||||
// value in mV
|
||||
int voltagemV = voltageuV / 1000;
|
||||
FILE_LOG(logDEBUG1, (" voltage: %d mV\n", voltagemV));
|
||||
FILE_LOG(logINFO, ("Voltage via I2C (Device: 0x%x): %d mV\n", deviceId, voltagemV));
|
||||
LOG(logDEBUG1, (" voltage: %d mV\n", voltagemV));
|
||||
LOG(logINFO, ("Voltage via I2C (Device: 0x%x): %d mV\n", deviceId, voltagemV));
|
||||
|
||||
return voltagemV;
|
||||
}
|
||||
|
||||
int INA226_ReadCurrent(uint32_t deviceId) {
|
||||
FILE_LOG(logDEBUG1, (" Reading current\n"));
|
||||
LOG(logDEBUG1, (" Reading current\n"));
|
||||
|
||||
// read shunt voltage register
|
||||
FILE_LOG(logDEBUG1, (" Reading shunt voltage reg\n"));
|
||||
LOG(logDEBUG1, (" Reading shunt voltage reg\n"));
|
||||
uint32_t shuntVoltageRegVal = I2C_Read(deviceId, INA226_SHUNT_VOLTAGE_REG);
|
||||
FILE_LOG(logDEBUG1, (" shunt voltage reg: %d\n", shuntVoltageRegVal));
|
||||
LOG(logDEBUG1, (" shunt voltage reg: %d\n", shuntVoltageRegVal));
|
||||
|
||||
// read it once more as this error has occured once
|
||||
if (shuntVoltageRegVal == 0xFFFF) {
|
||||
FILE_LOG(logDEBUG1, (" Reading shunt voltage reg again\n"));
|
||||
LOG(logDEBUG1, (" Reading shunt voltage reg again\n"));
|
||||
shuntVoltageRegVal = I2C_Read(deviceId, INA226_SHUNT_VOLTAGE_REG);
|
||||
FILE_LOG(logDEBUG1, (" shunt voltage reg: %d\n", shuntVoltageRegVal));
|
||||
LOG(logDEBUG1, (" shunt voltage reg: %d\n", shuntVoltageRegVal));
|
||||
}
|
||||
// value for current
|
||||
int retval = INA226_getConvertedCurrentUnits(shuntVoltageRegVal, INA226_Calibration_Register_Value);
|
||||
FILE_LOG(logDEBUG1, (" current unit value: %d\n", retval));
|
||||
LOG(logDEBUG1, (" current unit value: %d\n", retval));
|
||||
|
||||
|
||||
// reading directly the current reg
|
||||
FILE_LOG(logDEBUG1, (" Reading current reg\n"));
|
||||
LOG(logDEBUG1, (" Reading current reg\n"));
|
||||
int cuurentRegVal = I2C_Read(deviceId, INA226_CURRENT_REG);
|
||||
FILE_LOG(logDEBUG1, (" current reg: %d\n", cuurentRegVal));
|
||||
LOG(logDEBUG1, (" current reg: %d\n", cuurentRegVal));
|
||||
// read it once more as this error has occured once
|
||||
if (cuurentRegVal >= 0xFFF0) {
|
||||
FILE_LOG(logDEBUG1, (" Reading current reg again\n"));
|
||||
LOG(logDEBUG1, (" Reading current reg again\n"));
|
||||
cuurentRegVal = I2C_Read(deviceId, INA226_CURRENT_REG);
|
||||
FILE_LOG(logDEBUG1, (" current reg: %d\n", cuurentRegVal));
|
||||
LOG(logDEBUG1, (" current reg: %d\n", cuurentRegVal));
|
||||
}
|
||||
|
||||
// should be the same
|
||||
FILE_LOG(logDEBUG1, (" ===============current reg: %d, current unit cal:%d=================================\n", cuurentRegVal, retval));
|
||||
LOG(logDEBUG1, (" ===============current reg: %d, current unit cal:%d=================================\n", cuurentRegVal, retval));
|
||||
// current in uA
|
||||
int currentuA = cuurentRegVal * INA226_CURRENT_IMIN_UA;
|
||||
FILE_LOG(logDEBUG1, (" current: %d uA\n", currentuA));
|
||||
LOG(logDEBUG1, (" current: %d uA\n", currentuA));
|
||||
|
||||
// current in mA
|
||||
int currentmA = (currentuA / 1000.00) + 0.5;
|
||||
FILE_LOG(logDEBUG1, (" current: %d mA\n", currentmA));
|
||||
LOG(logDEBUG1, (" current: %d mA\n", currentmA));
|
||||
|
||||
FILE_LOG(logINFO, ("Current via I2C (Device: 0x%x): %d mA\n", deviceId, currentmA));
|
||||
LOG(logINFO, ("Current via I2C (Device: 0x%x): %d mA\n", deviceId, currentmA));
|
||||
|
||||
return currentmA;
|
||||
}
|
||||
|
||||
@@ -92,12 +92,12 @@ int LTC2620_DacToVoltage(int dacval, int* voltage) {
|
||||
}
|
||||
|
||||
void LTC2620_SetSingle(int cmd, int data, int dacaddr) {
|
||||
FILE_LOG(logDEBUG2, ("(Single) dac addr:%d, dac value:%d, cmd:%d\n", dacaddr, data, cmd));
|
||||
LOG(logDEBUG2, ("(Single) dac addr:%d, dac value:%d, cmd:%d\n", dacaddr, data, cmd));
|
||||
|
||||
uint32_t codata = (((data << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK) |
|
||||
((dacaddr << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) |
|
||||
cmd);
|
||||
FILE_LOG(logDEBUG2, ("codata: 0x%x\n", codata));
|
||||
LOG(logDEBUG2, ("codata: 0x%x\n", codata));
|
||||
|
||||
serializeToSPI (LTC2620_Reg, codata, LTC2620_CsMask, LTC2620_NUMBITS,
|
||||
LTC2620_ClkMask, LTC2620_DigMask, LTC2620_DigOffset, 0);
|
||||
@@ -114,24 +114,24 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
uint32_t valw = 0;
|
||||
int ichip = 0;
|
||||
|
||||
FILE_LOG(logDEBUG2, ("(Daisy) desired chip index:%d, nchip:%d, dac ch:%d, val:%d, cmd:0x%x \n",
|
||||
LOG(logDEBUG2, ("(Daisy) desired chip index:%d, nchip:%d, dac ch:%d, val:%d, cmd:0x%x \n",
|
||||
chipIndex, nchip, dacaddr, data, cmd));
|
||||
|
||||
// data to be bit banged
|
||||
uint32_t codata = (((data << LTC2620_DAC_DATA_OFST) & LTC2620_DAC_DATA_MSK) |
|
||||
((dacaddr << LTC2620_DAC_ADDR_OFST) & LTC2620_DAC_ADDR_MSK) |
|
||||
cmd);
|
||||
FILE_LOG(logDEBUG2, ("codata: 0x%x\n", codata));
|
||||
LOG(logDEBUG2, ("codata: 0x%x\n", codata));
|
||||
|
||||
// select all chips (ctb daisy chain; others 1 chip)
|
||||
FILE_LOG(logDEBUG2, ("Selecting LTC2620\n"));
|
||||
LOG(logDEBUG2, ("Selecting LTC2620\n"));
|
||||
SPIChipSelect (&valw, LTC2620_Reg, LTC2620_CsMask, LTC2620_ClkMask, LTC2620_DigMask, 0);
|
||||
|
||||
// send same data to all
|
||||
if (chipIndex < 0) {
|
||||
FILE_LOG(logDEBUG2, ("Send same data to all\n"));
|
||||
LOG(logDEBUG2, ("Send same data to all\n"));
|
||||
for (ichip = 0; ichip < nchip; ++ichip) {
|
||||
FILE_LOG(logDEBUG2, ("Send data (0x%x) to ichip %d\n", codata, ichip));
|
||||
LOG(logDEBUG2, ("Send data (0x%x) to ichip %d\n", codata, ichip));
|
||||
LTC2620_SendDaisyData(&valw, codata);
|
||||
}
|
||||
}
|
||||
@@ -140,40 +140,40 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
else {
|
||||
// send nothing to subsequent ichips (daisy chain) (if any chips after desired chip)
|
||||
for (ichip = chipIndex + 1; ichip < nchip; ++ichip) {
|
||||
FILE_LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip));
|
||||
LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip));
|
||||
LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL);
|
||||
}
|
||||
|
||||
// send data to desired chip
|
||||
FILE_LOG(logDEBUG2, ("Send data (0x%x) to ichip %d\n", codata, chipIndex));
|
||||
LOG(logDEBUG2, ("Send data (0x%x) to ichip %d\n", codata, chipIndex));
|
||||
LTC2620_SendDaisyData(&valw, codata);
|
||||
|
||||
// send nothing to preceding ichips (daisy chain) (if any chips in front of desired chip)
|
||||
for (ichip = 0; ichip < chipIndex; ++ichip) {
|
||||
FILE_LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip));
|
||||
LOG(logDEBUG2, ("Send nothing to ichip %d\n", ichip));
|
||||
LTC2620_SendDaisyData(&valw, LTC2620_DAC_CMD_NO_OPRTN_VAL);
|
||||
}
|
||||
}
|
||||
|
||||
// deselect all chips (ctb daisy chain; others 1 chip)
|
||||
FILE_LOG(logDEBUG2, ("Deselecting LTC2620\n"));
|
||||
LOG(logDEBUG2, ("Deselecting LTC2620\n"));
|
||||
SPIChipDeselect(&valw, LTC2620_Reg, LTC2620_CsMask, LTC2620_ClkMask, LTC2620_DigMask, 0);
|
||||
}
|
||||
|
||||
void LTC2620_Set(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
FILE_LOG(logDEBUG1, ("cmd:0x%x, data:%d, dacaddr:%d, chipIndex:%d\n", cmd, data, dacaddr, chipIndex));
|
||||
FILE_LOG(logDEBUG2, (" ================================================\n"));
|
||||
LOG(logDEBUG1, ("cmd:0x%x, data:%d, dacaddr:%d, chipIndex:%d\n", cmd, data, dacaddr, chipIndex));
|
||||
LOG(logDEBUG2, (" ================================================\n"));
|
||||
// ctb
|
||||
if (LTC2620_Ndac > LTC2620_NUMCHANNELS)
|
||||
LTC2620_SetDaisy(cmd, data, dacaddr, chipIndex);
|
||||
// others
|
||||
else
|
||||
LTC2620_SetSingle(cmd, data, dacaddr);
|
||||
FILE_LOG(logDEBUG2, (" ================================================\n"));
|
||||
LOG(logDEBUG2, (" ================================================\n"));
|
||||
}
|
||||
|
||||
void LTC2620_Configure(){
|
||||
FILE_LOG(logINFOBLUE, ("Configuring LTC2620\n"));
|
||||
LOG(logINFOBLUE, ("Configuring LTC2620\n"));
|
||||
|
||||
// dac channel - all channels
|
||||
int addr = (LTC2620_DAC_ADDR_MSK >> LTC2620_DAC_ADDR_OFST);
|
||||
@@ -189,7 +189,7 @@ void LTC2620_Configure(){
|
||||
}
|
||||
|
||||
void LTC2620_SetDAC (int dacnum, int data) {
|
||||
FILE_LOG(logDEBUG1, ("Setting dac %d to %d\n", dacnum, data));
|
||||
LOG(logDEBUG1, ("Setting dac %d to %d\n", dacnum, data));
|
||||
// LTC2620 index
|
||||
int ichip = dacnum / LTC2620_NUMCHANNELS;
|
||||
|
||||
@@ -202,19 +202,19 @@ void LTC2620_SetDAC (int dacnum, int data) {
|
||||
// power down mode, value is ignored
|
||||
if (data == LTC2620_PWR_DOWN_VAL) {
|
||||
cmd = LTC2620_DAC_CMD_PWR_DWN_VAL;
|
||||
FILE_LOG(logDEBUG1, ("POWER DOWN\n"));
|
||||
LOG(logDEBUG1, ("POWER DOWN\n"));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1,("Write to Input Register and Update\n"));
|
||||
LOG(logDEBUG1,("Write to Input Register and Update\n"));
|
||||
}
|
||||
|
||||
LTC2620_Set(cmd, data, addr, ichip);
|
||||
}
|
||||
|
||||
int LTC2620_SetDACValue (int dacnum, int val, int mV, int* dacval) {
|
||||
FILE_LOG(logDEBUG1, ("dacnum:%d, val:%d, ismV:%d\n", dacnum, val, mV));
|
||||
LOG(logDEBUG1, ("dacnum:%d, val:%d, ismV:%d\n", dacnum, val, mV));
|
||||
// validate index
|
||||
if (dacnum < 0 || dacnum >= LTC2620_Ndac) {
|
||||
FILE_LOG(logERROR, ("Dac index %d is out of bounds (0 to %d)\n", dacnum, LTC2620_Ndac - 1));
|
||||
LOG(logERROR, ("Dac index %d is out of bounds (0 to %d)\n", dacnum, LTC2620_Ndac - 1));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -240,13 +240,13 @@ int LTC2620_SetDACValue (int dacnum, int val, int mV, int* dacval) {
|
||||
|
||||
// conversion out of bounds
|
||||
if (ret == FAIL) {
|
||||
FILE_LOG(logERROR, ("Setting Dac %d %s is out of bounds\n", dacnum, (mV ? "mV" : "dac units")));
|
||||
LOG(logERROR, ("Setting Dac %d %s is out of bounds\n", dacnum, (mV ? "mV" : "dac units")));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// set
|
||||
if ( (*dacval >= 0) || (*dacval == LTC2620_PWR_DOWN_VAL)) {
|
||||
FILE_LOG(logINFO, ("Setting DAC %d: %d dac (%d mV)\n",dacnum, *dacval, dacmV));
|
||||
LOG(logINFO, ("Setting DAC %d: %d dac (%d mV)\n",dacnum, *dacval, dacmV));
|
||||
LTC2620_SetDAC(dacnum, *dacval);
|
||||
}
|
||||
return OK;
|
||||
|
||||
@@ -17,7 +17,7 @@ char LTC2620_D_DriverFileName[MAX_STR_LENGTH];
|
||||
int LTC2620_D_NumDacs = 0;
|
||||
|
||||
void LTC2620_D_SetDefines(int hardMaxV, char* driverfname, int numdacs) {
|
||||
FILE_LOG(logINFOBLUE, ("Configuring DACs (LTC2620) to %s (numdacs:%d, hard max: %dmV)\n", driverfname, numdacs, hardMaxV));
|
||||
LOG(logINFOBLUE, ("Configuring DACs (LTC2620) to %s (numdacs:%d, hard max: %dmV)\n", driverfname, numdacs, hardMaxV));
|
||||
LTC2620_D_HardMaxVoltage = hardMaxV;
|
||||
memset(LTC2620_D_DriverFileName, 0, MAX_STR_LENGTH);
|
||||
strcpy(LTC2620_D_DriverFileName, driverfname);
|
||||
@@ -40,10 +40,10 @@ int LTC2620_D_DacToVoltage(int dacval, int* voltage) {
|
||||
|
||||
|
||||
int LTC2620_D_SetDACValue (int dacnum, int val, int mV, char* dacname, int* dacval) {
|
||||
FILE_LOG(logDEBUG1, ("dacnum:%d, val:%d, ismV:%d\n", dacnum, val, mV));
|
||||
LOG(logDEBUG1, ("dacnum:%d, val:%d, ismV:%d\n", dacnum, val, mV));
|
||||
// validate index
|
||||
if (dacnum < 0 || dacnum >= LTC2620_D_NumDacs) {
|
||||
FILE_LOG(logERROR, ("Dac index %d is out of bounds (0 to %d)\n", dacnum, LTC2620_D_NumDacs - 1));
|
||||
LOG(logERROR, ("Dac index %d is out of bounds (0 to %d)\n", dacnum, LTC2620_D_NumDacs - 1));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
@@ -64,22 +64,22 @@ int LTC2620_D_SetDACValue (int dacnum, int val, int mV, char* dacname, int* dacv
|
||||
|
||||
// conversion out of bounds
|
||||
if (ret == FAIL) {
|
||||
FILE_LOG(logERROR, ("Setting Dac %d %s is out of bounds\n", dacnum, (mV ? "mV" : "dac units")));
|
||||
LOG(logERROR, ("Setting Dac %d %s is out of bounds\n", dacnum, (mV ? "mV" : "dac units")));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// set
|
||||
if ( (*dacval >= 0) || (*dacval == LTC2620_D_PWR_DOWN_VAL)) {
|
||||
FILE_LOG(logINFO, ("Setting DAC %2d [%-12s] : %d dac (%d mV)\n",dacnum, dacname, *dacval, dacmV));
|
||||
LOG(logINFO, ("Setting DAC %2d [%-12s] : %d dac (%d mV)\n",dacnum, dacname, *dacval, dacmV));
|
||||
|
||||
char fname[MAX_STR_LENGTH];
|
||||
sprintf(fname, "%s%d", LTC2620_D_DriverFileName, dacnum);
|
||||
FILE_LOG(logDEBUG1, ("fname %s\n",fname));
|
||||
LOG(logDEBUG1, ("fname %s\n",fname));
|
||||
|
||||
//open file
|
||||
FILE* fd=fopen(fname,"w");
|
||||
if (fd==NULL) {
|
||||
FILE_LOG(logERROR, ("Could not open file %s for writing to set dac %d\n", fname, dacnum));
|
||||
LOG(logERROR, ("Could not open file %s for writing to set dac %d\n", fname, dacnum));
|
||||
return FAIL;
|
||||
}
|
||||
//convert to string, add 0 and write to file
|
||||
|
||||
@@ -26,7 +26,7 @@ int MAX1932_MaxVoltage = 0;
|
||||
|
||||
void MAX1932_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk, uint32_t dmsk, int dofst,
|
||||
int minMV, int maxMV) {
|
||||
FILE_LOG(logINFOBLUE, ("Configuring High Voltage\n"));
|
||||
LOG(logINFOBLUE, ("Configuring High Voltage\n"));
|
||||
MAX1932_Reg = reg;
|
||||
MAX1932_CsMask = cmsk;
|
||||
MAX1932_ClkMask = clkmsk;
|
||||
@@ -44,7 +44,7 @@ void MAX1932_Disable() {
|
||||
}
|
||||
|
||||
int MAX1932_Set (int val) {
|
||||
FILE_LOG(logDEBUG1, ("Setting high voltage to %d\n", val));
|
||||
LOG(logDEBUG1, ("Setting high voltage to %d\n", val));
|
||||
if (val < 0)
|
||||
return FAIL;
|
||||
|
||||
@@ -69,7 +69,7 @@ int MAX1932_Set (int val) {
|
||||
dacvalue &= MAX1932_HV_DATA_MSK;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO, ("\t%dV (dacval %d)\n", val, dacvalue));
|
||||
LOG(logINFO, ("\t%dV (dacval %d)\n", val, dacvalue));
|
||||
serializeToSPI(MAX1932_Reg, dacvalue, MAX1932_CsMask, MAX1932_HV_NUMBITS,
|
||||
MAX1932_ClkMask, MAX1932_DigMask, MAX1932_DigOffset, 0);
|
||||
return OK;
|
||||
|
||||
@@ -54,7 +54,7 @@ void createUDPPacketHeader(char* buffer, uint16_t id) {
|
||||
}
|
||||
|
||||
int fillUDPPacket(char* buffer) {
|
||||
FILE_LOG(logDEBUG2, ("Analog (databytes:%d, offset:%d)\n Digital (databytes:%d offset:%d)\n",
|
||||
LOG(logDEBUG2, ("Analog (databytes:%d, offset:%d)\n Digital (databytes:%d offset:%d)\n",
|
||||
analogDataBytes, analogOffset, digitalDataBytes, digitalOffset));
|
||||
// reached end of data for one frame
|
||||
if (analogOffset >= analogDataBytes && digitalOffset >= digitalDataBytes) {
|
||||
@@ -76,7 +76,7 @@ int fillUDPPacket(char* buffer) {
|
||||
// increment and copy udp packet number (starts at 0)
|
||||
++udpPacketNumber;
|
||||
header->packetNumber = udpPacketNumber;
|
||||
FILE_LOG(logDEBUG2, ("Creating packet number %d (fnum:%lld)\n", udpPacketNumber, (long long int) udpFrameNumber));
|
||||
LOG(logDEBUG2, ("Creating packet number %d (fnum:%lld)\n", udpPacketNumber, (long long int) udpFrameNumber));
|
||||
|
||||
int freeBytes = UDP_PACKET_DATA_BYTES;
|
||||
|
||||
@@ -111,7 +111,7 @@ int fillUDPPacket(char* buffer) {
|
||||
// pad data
|
||||
if (freeBytes) {
|
||||
memset(buffer + sizeof(sls_detector_header) + analogBytes + digitalBytes, 0, freeBytes);
|
||||
FILE_LOG(logDEBUG1, ("Padding %d bytes for fnum:%lld pnum:%d\n", freeBytes, (long long int)udpFrameNumber, udpPacketNumber));
|
||||
LOG(logDEBUG1, ("Padding %d bytes for fnum:%lld pnum:%d\n", freeBytes, (long long int)udpFrameNumber, udpPacketNumber));
|
||||
}
|
||||
|
||||
return UDP_PACKET_DATA_BYTES + sizeof(sls_detector_header);
|
||||
|
||||
@@ -44,7 +44,7 @@ int64_t get64BitReg(int aLSB, int aMSB){
|
||||
vMSB=bus_r(aMSB);
|
||||
v64=vMSB;
|
||||
v64=(v64<<32) | vLSB;
|
||||
FILE_LOG(logDEBUG5, (" reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, (long long unsigned int)v64));
|
||||
LOG(logDEBUG5, (" reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, (long long unsigned int)v64));
|
||||
return v64;
|
||||
}
|
||||
|
||||
@@ -94,33 +94,33 @@ u_int32_t writeRegister16(u_int32_t offset, u_int32_t data) {
|
||||
int mapCSP0(void) {
|
||||
// if not mapped
|
||||
if (csp0base == 0) {
|
||||
FILE_LOG(logINFO, ("Mapping memory\n"));
|
||||
LOG(logINFO, ("Mapping memory\n"));
|
||||
#ifdef VIRTUAL
|
||||
csp0base = malloc(MEM_SIZE);
|
||||
if (csp0base == NULL) {
|
||||
FILE_LOG(logERROR, ("Could not allocate virtual memory.\n"));
|
||||
LOG(logERROR, ("Could not allocate virtual memory.\n"));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("memory allocated\n"));
|
||||
LOG(logINFO, ("memory allocated\n"));
|
||||
#else
|
||||
int fd;
|
||||
fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
if (fd == -1) {
|
||||
FILE_LOG(logERROR, ("Can't find /dev/mem\n"));
|
||||
LOG(logERROR, ("Can't find /dev/mem\n"));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("/dev/mem opened\n"));
|
||||
LOG(logDEBUG1, ("/dev/mem opened\n"));
|
||||
csp0base = mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0);
|
||||
if (csp0base == MAP_FAILED) {
|
||||
FILE_LOG(logERROR, ("Can't map memmory area\n"));
|
||||
LOG(logERROR, ("Can't map memmory area\n"));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
FILE_LOG(logINFO, ("csp0base mapped from %p to %p\n",
|
||||
LOG(logINFO, ("csp0base mapped from %p to %p\n",
|
||||
csp0base, (csp0base + MEM_SIZE)));
|
||||
FILE_LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
||||
LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
||||
}else
|
||||
FILE_LOG(logINFO, ("Memory already mapped before\n"));
|
||||
LOG(logINFO, ("Memory already mapped before\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int outputMax,
|
||||
int inputValue, int* outputValue) {
|
||||
FILE_LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n",
|
||||
LOG(logDEBUG1, (" Input Value: %d (Input:(%d - %d), Output:(%d - %d))\n",
|
||||
inputValue, inputMin, inputMax, outputMin, outputMax));
|
||||
|
||||
// validate within bounds
|
||||
@@ -16,7 +16,7 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int outpu
|
||||
bigger = inputMin;
|
||||
}
|
||||
if ((inputValue < smaller) || (inputValue > bigger)) {
|
||||
FILE_LOG(logERROR, ("Input Value is outside bounds (%d to %d): %d\n", smaller, bigger, inputValue));
|
||||
LOG(logERROR, ("Input Value is outside bounds (%d to %d): %d\n", smaller, bigger, inputValue));
|
||||
*outputValue = -1;
|
||||
return FAIL;
|
||||
}
|
||||
@@ -30,7 +30,7 @@ int ConvertToDifferentRange(int inputMin, int inputMax, int outputMin, int outpu
|
||||
}
|
||||
*outputValue = value;
|
||||
|
||||
FILE_LOG(logDEBUG1, (" Converted Output Value: %d\n", *outputValue));
|
||||
LOG(logDEBUG1, (" Converted Output Value: %d\n", *outputValue));
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <unistd.h> // usleep
|
||||
|
||||
void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t clkmask, uint32_t digoutmask, int convBit) {
|
||||
FILE_LOG(logDEBUG2, ("SPI chip select. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x convbit:%d\n",
|
||||
LOG(logDEBUG2, ("SPI chip select. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x convbit:%d\n",
|
||||
*valw, addr, csmask, clkmask, digoutmask, convBit));
|
||||
|
||||
// start point
|
||||
@@ -18,7 +18,7 @@ void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t cl
|
||||
(*valw) = ((bus_r(addr) | csmask | clkmask) &(~digoutmask));
|
||||
}
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("startpoint. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("startpoint. valw:0x%08x\n", *valw));
|
||||
|
||||
// needed for the slow adcs for apprx 10 ns before and after rising of convbit (usleep val is vague assumption)
|
||||
if (convBit)
|
||||
@@ -27,12 +27,12 @@ void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t cl
|
||||
// chip sel bar down
|
||||
(*valw) &= ~csmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("chip sel bar down. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("chip sel bar down. valw:0x%08x\n", *valw));
|
||||
}
|
||||
|
||||
|
||||
void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t clkmask, uint32_t digoutmask, int convBit) {
|
||||
FILE_LOG(logDEBUG2, ("SPI chip deselect. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x convbit:%d\n",
|
||||
LOG(logDEBUG2, ("SPI chip deselect. valw:0x%08x addr:0x%x csmask:0x%x, clkmask:0x%x digmask:0x%x convbit:%d\n",
|
||||
*valw, addr, csmask, clkmask, digoutmask, convBit));
|
||||
|
||||
// needed for the slow adcs for apprx 20 ns before and after rising of convbit (usleep val is vague assumption)
|
||||
@@ -42,7 +42,7 @@ void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t
|
||||
// chip sel bar up
|
||||
(*valw) |= csmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("chip sel bar up. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("chip sel bar up. valw:0x%08x\n", *valw));
|
||||
|
||||
// needed for the slow adcs for apprx 10 ns before and after rising of convbit (usleep val is vague assumption)
|
||||
if (convBit)
|
||||
@@ -51,7 +51,7 @@ void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t
|
||||
//clk down
|
||||
(*valw) &= ~clkmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
|
||||
// stop point = start point of course
|
||||
(*valw) &= ~digoutmask;
|
||||
@@ -62,11 +62,11 @@ void SPIChipDeselect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t
|
||||
(*valw) |= csmask;
|
||||
}
|
||||
bus_w (addr, (*valw)); //FIXME: for ctb slow adcs, might need to set it to low again
|
||||
FILE_LOG(logDEBUG2, ("stop point. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("stop point. valw:0x%08x\n", *valw));
|
||||
}
|
||||
|
||||
void sendDataToSPI (uint32_t* valw, uint32_t addr, uint32_t val, int numbitstosend, uint32_t clkmask, uint32_t digoutmask, int digofset) {
|
||||
FILE_LOG(logDEBUG2, ("SPI send data. valw:0x%08x addr:0x%x val:0x%x, numbitstosend:%d, clkmask:0x%x digmask:0x%x digofst:%d\n",
|
||||
LOG(logDEBUG2, ("SPI send data. valw:0x%08x addr:0x%x val:0x%x, numbitstosend:%d, clkmask:0x%x digmask:0x%x digofst:%d\n",
|
||||
*valw, addr, val, numbitstosend, clkmask, digoutmask, digofset));
|
||||
|
||||
int i = 0;
|
||||
@@ -75,23 +75,23 @@ void sendDataToSPI (uint32_t* valw, uint32_t addr, uint32_t val, int numbitstose
|
||||
// clk down
|
||||
(*valw) &= ~clkmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
|
||||
// write data (i)
|
||||
(*valw) = (((*valw) & ~digoutmask) + // unset bit
|
||||
(((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("write data %d. valw:0x%08x\n", i, *valw));
|
||||
LOG(logDEBUG2, ("write data %d. valw:0x%08x\n", i, *valw));
|
||||
|
||||
// clk up
|
||||
(*valw) |= clkmask ;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("clk up. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("clk up. valw:0x%08x\n", *valw));
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t receiveDataFromSPI (uint32_t* valw, uint32_t addr, int numbitstoreceive, uint32_t clkmask, uint32_t readaddr) {
|
||||
FILE_LOG(logDEBUG2, ("SPI send data. valw:0x%08x addr:0x%x numbitstoreceive:%d, clkmask:0x%x readaddr:0x%x \n",
|
||||
LOG(logDEBUG2, ("SPI send data. valw:0x%08x addr:0x%x numbitstoreceive:%d, clkmask:0x%x readaddr:0x%x \n",
|
||||
*valw, addr, numbitstoreceive, clkmask, readaddr));
|
||||
|
||||
uint32_t retval = 0;
|
||||
@@ -102,18 +102,18 @@ uint32_t receiveDataFromSPI (uint32_t* valw, uint32_t addr, int numbitstoreceive
|
||||
// clk down
|
||||
(*valw) &= ~clkmask;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("clk down. valw:0x%08x\n", *valw));
|
||||
|
||||
// read data (i)
|
||||
retval |= ((bus_r(readaddr) & 0x1) << (numbitstoreceive - 1 - i));
|
||||
FILE_LOG(logDEBUG2, ("read data %d. retval:0x%08x\n", i, retval));
|
||||
LOG(logDEBUG2, ("read data %d. retval:0x%08x\n", i, retval));
|
||||
|
||||
usleep(20);
|
||||
|
||||
// clk up
|
||||
(*valw) |= clkmask ;
|
||||
bus_w (addr, (*valw));
|
||||
FILE_LOG(logDEBUG2, ("clk up. valw:0x%08x\n", *valw));
|
||||
LOG(logDEBUG2, ("clk up. valw:0x%08x\n", *valw));
|
||||
|
||||
usleep(20);
|
||||
}
|
||||
@@ -123,9 +123,9 @@ uint32_t receiveDataFromSPI (uint32_t* valw, uint32_t addr, int numbitstoreceive
|
||||
|
||||
void serializeToSPI(uint32_t addr, uint32_t val, uint32_t csmask, int numbitstosend, uint32_t clkmask, uint32_t digoutmask, int digofset, int convBit) {
|
||||
if (numbitstosend == 16) {
|
||||
FILE_LOG(logDEBUG2, ("Writing to SPI Register: 0x%04x\n", val));
|
||||
LOG(logDEBUG2, ("Writing to SPI Register: 0x%04x\n", val));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG2, ("Writing to SPI Register: 0x%08x\n", val));
|
||||
LOG(logDEBUG2, ("Writing to SPI Register: 0x%08x\n", val));
|
||||
}
|
||||
uint32_t valw;
|
||||
|
||||
@@ -148,9 +148,9 @@ uint32_t serializeFromSPI(uint32_t addr, uint32_t csmask, int numbitstoreceive,
|
||||
//SPIChipDeselect(&valw, addr, csmask, clkmask, digoutmask, convBit); // moving this before bringin up earlier changes temp of slow adc
|
||||
|
||||
if (numbitstoreceive == 16) {
|
||||
FILE_LOG(logDEBUG2, ("Read From SPI Register: 0x%04x\n", retval));
|
||||
LOG(logDEBUG2, ("Read From SPI Register: 0x%04x\n", retval));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG2, ("Read From SPI Register: 0x%08x\n", retval));
|
||||
LOG(logDEBUG2, ("Read From SPI Register: 0x%08x\n", retval));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ int bindSocket(unsigned short int port_number) {
|
||||
if (myport == port_number) {
|
||||
sprintf(mess, "Cannot create %s socket with port %d. Already in use before.\n",
|
||||
(isControlServer ? "control":"stop"), port_number);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
// port ok
|
||||
else {
|
||||
@@ -66,7 +66,7 @@ int bindSocket(unsigned short int port_number) {
|
||||
if (socketDescriptor < 0) {
|
||||
sprintf(mess, "Cannot create %s socket with port %d\n",
|
||||
(isControlServer ? "control":"stop"), port_number);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
// socket success
|
||||
else {
|
||||
@@ -82,7 +82,7 @@ int bindSocket(unsigned short int port_number) {
|
||||
if(bind(socketDescriptor,(struct sockaddr *) &addressS,sizeof(addressS)) < 0){
|
||||
sprintf(mess, "Cannot bind %s socket to port %d.\n",
|
||||
(isControlServer ? "control":"stop"), port_number);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
// bind socket ok
|
||||
else {
|
||||
@@ -100,7 +100,7 @@ int bindSocket(unsigned short int port_number) {
|
||||
// success
|
||||
myport = port_number;
|
||||
ret = OK;
|
||||
FILE_LOG(logDEBUG1, ("%s socket bound: isock=%d, port=%d, fd=%d\n",
|
||||
LOG(logDEBUG1, ("%s socket bound: isock=%d, port=%d, fd=%d\n",
|
||||
(isControlServer ? "Control":"Stop"), isock, port_number, socketDescriptor));
|
||||
|
||||
}
|
||||
@@ -108,7 +108,7 @@ int bindSocket(unsigned short int port_number) {
|
||||
else {
|
||||
sprintf(mess, "Cannot bind %s socket to port %d.\n",
|
||||
(isControlServer ? "control":"stop"), port_number);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,81 +141,81 @@ int acceptConnection(int socketDescriptor) {
|
||||
|
||||
// timeout
|
||||
if (result == 0) {
|
||||
FILE_LOG(logDEBUG3, ("%s socket select() timed out!\n",
|
||||
LOG(logDEBUG3, ("%s socket select() timed out!\n",
|
||||
(isControlServer ? "control":"stop"), myport));
|
||||
}
|
||||
|
||||
// error (not signal caught)
|
||||
else if (result < 0 && errno != EINTR) {
|
||||
FILE_LOG(logERROR, ("%s socket select() error: %s\n",
|
||||
LOG(logERROR, ("%s socket select() error: %s\n",
|
||||
(isControlServer ? "control":"stop"), myport, strerror(errno)));
|
||||
}
|
||||
|
||||
// activity in descriptor set
|
||||
else if (result > 0) {
|
||||
FILE_LOG(logDEBUG3, ("%s select returned!\n", (isControlServer ? "control":"stop")));
|
||||
LOG(logDEBUG3, ("%s select returned!\n", (isControlServer ? "control":"stop")));
|
||||
|
||||
// loop through the file descriptor set
|
||||
for (j = 0; j < maxfd + 1; ++j) {
|
||||
|
||||
// checks if file descriptor part of set
|
||||
if (FD_ISSET(j, &tempset)) {
|
||||
FILE_LOG(logDEBUG3, ("fd %d is set\n",j));
|
||||
LOG(logDEBUG3, ("fd %d is set\n",j));
|
||||
|
||||
// clear the temporary set
|
||||
FD_CLR(j, &tempset);
|
||||
|
||||
// accept connection (if error)
|
||||
if ((file_des = accept(j,(struct sockaddr *) &addressC, &address_length)) < 0) {
|
||||
FILE_LOG(logERROR, ("%s socket accept() error. Connection refused.\n",
|
||||
LOG(logERROR, ("%s socket accept() error. Connection refused.\n",
|
||||
"Error Number: %d, Message: %s\n",
|
||||
(isControlServer ? "control":"stop"),
|
||||
myport, errno, strerror(errno)));
|
||||
switch(errno) {
|
||||
case EWOULDBLOCK:
|
||||
FILE_LOG(logERROR, ("ewouldblock eagain"));
|
||||
LOG(logERROR, ("ewouldblock eagain"));
|
||||
break;
|
||||
case EBADF:
|
||||
FILE_LOG(logERROR, ("ebadf\n"));
|
||||
LOG(logERROR, ("ebadf\n"));
|
||||
break;
|
||||
case ECONNABORTED:
|
||||
FILE_LOG(logERROR, ("econnaborted\n"));
|
||||
LOG(logERROR, ("econnaborted\n"));
|
||||
break;
|
||||
case EFAULT:
|
||||
FILE_LOG(logERROR, ("efault\n"));
|
||||
LOG(logERROR, ("efault\n"));
|
||||
break;
|
||||
case EINTR:
|
||||
FILE_LOG(logERROR, ("eintr\n"));
|
||||
LOG(logERROR, ("eintr\n"));
|
||||
break;
|
||||
case EINVAL:
|
||||
FILE_LOG(logERROR, ("einval\n"));
|
||||
LOG(logERROR, ("einval\n"));
|
||||
break;
|
||||
case EMFILE:
|
||||
FILE_LOG(logERROR, ("emfile\n"));
|
||||
LOG(logERROR, ("emfile\n"));
|
||||
break;
|
||||
case ENFILE:
|
||||
FILE_LOG(logERROR, ("enfile\n"));
|
||||
LOG(logERROR, ("enfile\n"));
|
||||
break;
|
||||
case ENOTSOCK:
|
||||
FILE_LOG(logERROR, ("enotsock\n"));
|
||||
LOG(logERROR, ("enotsock\n"));
|
||||
break;
|
||||
case EOPNOTSUPP:
|
||||
FILE_LOG(logERROR, ("eOPNOTSUPP\n"));
|
||||
LOG(logERROR, ("eOPNOTSUPP\n"));
|
||||
break;
|
||||
case ENOBUFS:
|
||||
FILE_LOG(logERROR, ("ENOBUFS\n"));
|
||||
LOG(logERROR, ("ENOBUFS\n"));
|
||||
break;
|
||||
case ENOMEM:
|
||||
FILE_LOG(logERROR, ("ENOMEM\n"));
|
||||
LOG(logERROR, ("ENOMEM\n"));
|
||||
break;
|
||||
case ENOSR:
|
||||
FILE_LOG(logERROR, ("ENOSR\n"));
|
||||
LOG(logERROR, ("ENOSR\n"));
|
||||
break;
|
||||
case EPROTO:
|
||||
FILE_LOG(logERROR, ("EPROTO\n"));
|
||||
LOG(logERROR, ("EPROTO\n"));
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR, ("unknown error\n"));
|
||||
LOG(logERROR, ("unknown error\n"));
|
||||
}
|
||||
}
|
||||
// accept success
|
||||
@@ -223,7 +223,7 @@ int acceptConnection(int socketDescriptor) {
|
||||
char buf[INET_ADDRSTRLEN] = "";
|
||||
memset(buf, 0, INET_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &(addressC.sin_addr), buf, INET_ADDRSTRLEN);
|
||||
FILE_LOG(logDEBUG3, ("%s socket accepted connection, fd= %d\n",
|
||||
LOG(logDEBUG3, ("%s socket accepted connection, fd= %d\n",
|
||||
(isControlServer ? "control":"stop"), file_des));
|
||||
|
||||
getIpAddressFromString(buf, &dummyClientIP);
|
||||
@@ -255,7 +255,7 @@ void exitServer(int socketDescriptor) {
|
||||
if (socketDescriptor >= 0) {
|
||||
close(socketDescriptor);
|
||||
}
|
||||
FILE_LOG(logINFO, ("Closing %s server\n", (isControlServer ? "control":"stop")));
|
||||
LOG(logINFO, ("Closing %s server\n", (isControlServer ? "control":"stop")));
|
||||
FD_CLR(socketDescriptor, &readset);
|
||||
isock--;
|
||||
fflush(stdout);
|
||||
@@ -332,18 +332,18 @@ int sendDataOnly(int file_des, void* buf,int length) {
|
||||
int rc = write(file_des, (char*)((char*)buf + bytesSent), bytesToSend);
|
||||
// error
|
||||
if (rc < 0) {
|
||||
FILE_LOG(logERROR, ("Could not write to %s socket. Possible socket crash\n",
|
||||
LOG(logERROR, ("Could not write to %s socket. Possible socket crash\n",
|
||||
(isControlServer ? "control":"stop")));
|
||||
return bytesSent;
|
||||
}
|
||||
// also error, wrote nothing, buffer blocked up, too fast sending for client
|
||||
if (rc == 0) {
|
||||
FILE_LOG(logERROR, ("Could not write to %s socket. Buffer full. Retry: %d\n",
|
||||
LOG(logERROR, ("Could not write to %s socket. Buffer full. Retry: %d\n",
|
||||
(isControlServer ? "control":"stop"), retry));
|
||||
++retry;
|
||||
// wrote nothing for many loops
|
||||
if (retry >= CPU_RSND_PCKT_LOOP) {
|
||||
FILE_LOG(logERROR, ("Could not write to %s socket. Buffer full! Too fast! No more.\n",
|
||||
LOG(logERROR, ("Could not write to %s socket. Buffer full! Too fast! No more.\n",
|
||||
(isControlServer ? "control":"stop")));
|
||||
return bytesSent;
|
||||
}
|
||||
@@ -353,7 +353,7 @@ int sendDataOnly(int file_des, void* buf,int length) {
|
||||
else {
|
||||
retry = 0;
|
||||
if (rc != bytesToSend) {
|
||||
FILE_LOG(logWARNING, ("Only partial write to %s socket. Expected to write %d bytes, wrote %d\n",
|
||||
LOG(logWARNING, ("Only partial write to %s socket. Expected to write %d bytes, wrote %d\n",
|
||||
(isControlServer ? "control":"stop"), bytesToSend, rc));
|
||||
}
|
||||
}
|
||||
@@ -370,7 +370,7 @@ int receiveDataOnly(int file_des, void* buf,int length) {
|
||||
int nreceiving;
|
||||
int nreceived;
|
||||
if (file_des<0) return -1;
|
||||
FILE_LOG(logDEBUG3, ("want to receive %d Bytes to %s server\n",
|
||||
LOG(logDEBUG3, ("want to receive %d Bytes to %s server\n",
|
||||
length, (isControlServer ? "control":"stop")));
|
||||
|
||||
while(length > 0) {
|
||||
@@ -459,7 +459,7 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
}
|
||||
ts += n;
|
||||
#endif
|
||||
FILE_LOG(logDEBUG1, ("module of size %d sent register %x\n", ts, myMod->reg));
|
||||
LOG(logDEBUG1, ("module of size %d sent register %x\n", ts, myMod->reg));
|
||||
return ts;
|
||||
}
|
||||
|
||||
@@ -467,70 +467,70 @@ int sendModule(int file_des, sls_detector_module *myMod) {
|
||||
|
||||
int receiveModule(int file_des, sls_detector_module* myMod) {
|
||||
enum TLogLevel level = logDEBUG1;
|
||||
FILE_LOG(level, ("Receiving Module\n"));
|
||||
LOG(level, ("Receiving Module\n"));
|
||||
int ts = 0, n = 0;
|
||||
int nDacs = myMod->ndac;
|
||||
#ifdef EIGERD
|
||||
int nChans = myMod->nchan; // can be zero for no trimbits
|
||||
FILE_LOG(level, ("nChans: %d\n",nChans));
|
||||
LOG(level, ("nChans: %d\n",nChans));
|
||||
#endif
|
||||
n = receiveData(file_des,&(myMod->serialnumber), sizeof(myMod->serialnumber), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
FILE_LOG(level, ("serialno received. %d bytes. serialno: %d\n", n,
|
||||
LOG(level, ("serialno received. %d bytes. serialno: %d\n", n,
|
||||
myMod->serialnumber));
|
||||
n = receiveData(file_des, &(myMod->nchan), sizeof(myMod->nchan), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
FILE_LOG(level,
|
||||
LOG(level,
|
||||
("nchan received. %d bytes. nchan: %d\n", n, myMod->nchan));
|
||||
n = receiveData(file_des, &(myMod->nchip), sizeof(myMod->nchip), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
FILE_LOG(level,
|
||||
LOG(level,
|
||||
("nchip received. %d bytes. nchip: %d\n", n, myMod->nchip));
|
||||
n = receiveData(file_des, &(myMod->ndac), sizeof(myMod->ndac), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
FILE_LOG(level,
|
||||
LOG(level,
|
||||
("ndac received. %d bytes. ndac: %d\n", n, myMod->ndac));
|
||||
n = receiveData(file_des, &(myMod->reg), sizeof(myMod->reg), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
FILE_LOG(level, ("reg received. %d bytes. reg: %d\n", n, myMod->reg));
|
||||
LOG(level, ("reg received. %d bytes. reg: %d\n", n, myMod->reg));
|
||||
n = receiveData(file_des, &(myMod->iodelay), sizeof(myMod->iodelay),
|
||||
INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
FILE_LOG(level, ("iodelay received. %d bytes. iodelay: %d\n", n,
|
||||
LOG(level, ("iodelay received. %d bytes. iodelay: %d\n", n,
|
||||
myMod->iodelay));
|
||||
n = receiveData(file_des, &(myMod->tau), sizeof(myMod->tau), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
FILE_LOG(level, ("tau received. %d bytes. tau: %d\n", n, myMod->tau));
|
||||
LOG(level, ("tau received. %d bytes. tau: %d\n", n, myMod->tau));
|
||||
n = receiveData(file_des, &(myMod->eV), sizeof(myMod->eV), INT32);
|
||||
if (!n) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
FILE_LOG(level, ("eV received. %d bytes. eV: %d\n", n, myMod->eV));
|
||||
LOG(level, ("eV received. %d bytes. eV: %d\n", n, myMod->eV));
|
||||
// dacs
|
||||
if (nDacs != (myMod->ndac)) {
|
||||
FILE_LOG(logERROR, ("received wrong number of dacs. "
|
||||
LOG(logERROR, ("received wrong number of dacs. "
|
||||
"Expected %d, got %d\n",
|
||||
nDacs, myMod->ndac));
|
||||
return 0;
|
||||
@@ -540,23 +540,23 @@ int receiveModule(int file_des, sls_detector_module* myMod) {
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
FILE_LOG(level, ("dacs received. %d bytes.\n", n));
|
||||
LOG(level, ("dacs received. %d bytes.\n", n));
|
||||
// channels
|
||||
#ifdef EIGERD
|
||||
if (((myMod->nchan) != 0 ) && // no trimbits
|
||||
(nChans != (myMod->nchan))) { // with trimbits
|
||||
FILE_LOG(logERROR, ("received wrong number of channels. "
|
||||
LOG(logERROR, ("received wrong number of channels. "
|
||||
"Expected %d, got %d\n", nChans, (myMod->nchan)));
|
||||
return 0;
|
||||
}
|
||||
n = receiveData(file_des, myMod->chanregs, sizeof(int) * (myMod->nchan), INT32);
|
||||
FILE_LOG(level, ("chanregs received. %d bytes.\n", n));
|
||||
LOG(level, ("chanregs received. %d bytes.\n", n));
|
||||
if (!n && myMod->nchan != 0){
|
||||
return -1;
|
||||
}
|
||||
ts += n;
|
||||
#endif
|
||||
FILE_LOG(level, ("received module of size %d register %x\n",ts,myMod->reg));
|
||||
LOG(level, ("received module of size %d register %x\n",ts,myMod->reg));
|
||||
return ts;
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ void Server_LockedError() {
|
||||
char buf[INET_ADDRSTRLEN] = "";
|
||||
getIpAddressinString(buf, dummyClientIP);
|
||||
sprintf(mess,"Detector locked by %s\n", buf);
|
||||
FILE_LOG(logWARNING, (mess));
|
||||
LOG(logWARNING, (mess));
|
||||
}
|
||||
|
||||
|
||||
@@ -592,7 +592,7 @@ int Server_SendResult(int fileDes, intType itype, int update, void* retval, int
|
||||
sendData(fileDes, mess, MAX_STR_LENGTH, OTHER);
|
||||
// debugging feature. should not happen.
|
||||
else
|
||||
FILE_LOG(logERROR, ("No error message provided for this failure in %s "
|
||||
LOG(logERROR, ("No error message provided for this failure in %s "
|
||||
"server. Will mess up TCP.\n",
|
||||
(isControlServer ? "control":"stop")));
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ int setUDPDestinationDetails(int index, const char* ip, unsigned short int port)
|
||||
sprintf(sport, "%d", udpDestinationPort[index]);
|
||||
int err = getaddrinfo(udpDestinationIp[index], sport, &hints, &udpServerAddrInfo[index]);
|
||||
if (err != 0) {
|
||||
FILE_LOG(logERROR, ("Failed to resolve remote socket address %s at port %d. "
|
||||
LOG(logERROR, ("Failed to resolve remote socket address %s at port %d. "
|
||||
"(Error code:%d, %s)\n", udpDestinationIp[index], udpDestinationPort[index], err, gai_strerror(err)));
|
||||
return FAIL;
|
||||
}
|
||||
if (udpServerAddrInfo[index] == NULL) {
|
||||
FILE_LOG(logERROR, ("Failed to resolve remote socket address %s at port %d "
|
||||
LOG(logERROR, ("Failed to resolve remote socket address %s at port %d "
|
||||
"(getaddrinfo returned NULL)\n", udpDestinationIp[index], udpDestinationPort[index]));
|
||||
udpServerAddrInfo[index] = 0;
|
||||
return FAIL;
|
||||
@@ -61,14 +61,14 @@ int setUDPDestinationDetails(int index, const char* ip, unsigned short int port)
|
||||
}
|
||||
|
||||
int createUDPSocket(int index) {
|
||||
FILE_LOG(logDEBUG2, ("Creating UDP Socket %d\n", index));
|
||||
LOG(logDEBUG2, ("Creating UDP Socket %d\n", index));
|
||||
if (!strlen(udpDestinationIp[index])) {
|
||||
FILE_LOG(logERROR, ("No destination UDP ip specified.\n"));
|
||||
LOG(logERROR, ("No destination UDP ip specified.\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (udpSockfd[index] != -1) {
|
||||
FILE_LOG(logERROR, ("Strange that Udp socket was still open. Closing it to create a new one\n"));
|
||||
LOG(logERROR, ("Strange that Udp socket was still open. Closing it to create a new one\n"));
|
||||
close(udpSockfd[index]);
|
||||
udpSockfd[index] = -1;
|
||||
}
|
||||
@@ -76,20 +76,20 @@ int createUDPSocket(int index) {
|
||||
// Creating socket file descriptor
|
||||
udpSockfd[index] = socket(udpServerAddrInfo[index]->ai_family, udpServerAddrInfo[index]->ai_socktype, udpServerAddrInfo[index]->ai_protocol);
|
||||
if (udpSockfd[index] == -1 ) {
|
||||
FILE_LOG(logERROR, ("UDP socket at port %d failed. (Error code:%d, %s)\n",
|
||||
LOG(logERROR, ("UDP socket at port %d failed. (Error code:%d, %s)\n",
|
||||
udpDestinationPort[index], errno, gai_strerror(errno)));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Udp client socket created for server (port %d, ip:%s)\n",
|
||||
LOG(logINFO, ("Udp client socket created for server (port %d, ip:%s)\n",
|
||||
udpDestinationPort[index], udpDestinationIp[index]));
|
||||
|
||||
// connecting allows to use "send/write" instead of "sendto", avoiding checking for server address for each packet
|
||||
// using write without a connect will end in segv
|
||||
if (connect(udpSockfd[index],udpServerAddrInfo[index]->ai_addr, udpServerAddrInfo[index]->ai_addrlen)==-1) {
|
||||
FILE_LOG(logERROR, ("Could not connect to UDP server at ip:%s, port:%d. (Error code:%d, %s)\n",
|
||||
LOG(logERROR, ("Could not connect to UDP server at ip:%s, port:%d. (Error code:%d, %s)\n",
|
||||
udpDestinationIp[index], udpDestinationPort[index], errno, gai_strerror(errno)));
|
||||
}
|
||||
FILE_LOG(logINFO, ("Udp client socket connected\n",
|
||||
LOG(logINFO, ("Udp client socket connected\n",
|
||||
udpDestinationPort[index], udpDestinationIp[index]));
|
||||
return OK;
|
||||
}
|
||||
@@ -98,17 +98,17 @@ int sendUDPPacket(int index, const char* buf, int length) {
|
||||
int n = write(udpSockfd[index], buf, length);
|
||||
// udp sends atomically, no need to handle partial data
|
||||
if (n == -1) {
|
||||
FILE_LOG(logERROR, ("Could not send udp packet for socket %d. (Error code:%d, %s)\n",
|
||||
LOG(logERROR, ("Could not send udp packet for socket %d. (Error code:%d, %s)\n",
|
||||
index, n, errno, gai_strerror(errno)));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG2, ("%d bytes sent\n", n));
|
||||
LOG(logDEBUG2, ("%d bytes sent\n", n));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
void closeUDPSocket(int index) {
|
||||
if (udpSockfd[index] != -1) {
|
||||
FILE_LOG(logINFO, ("Udp client socket closed\n"));
|
||||
LOG(logINFO, ("Udp client socket closed\n"));
|
||||
close(udpSockfd[index]);
|
||||
udpSockfd[index] = -1;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ int64_t get64BitReg(int aLSB, int aMSB){
|
||||
vMSB=bus_r(aMSB);
|
||||
v64=vMSB;
|
||||
v64=(v64<<32) | vLSB;
|
||||
FILE_LOG(logDEBUG5, (" reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, (long long unsigned int)v64));
|
||||
LOG(logDEBUG5, (" reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, (long long unsigned int)v64));
|
||||
return v64;
|
||||
}
|
||||
|
||||
@@ -94,32 +94,32 @@ int mapCSP0(void) {
|
||||
for (i = 0; i < 2; ++i) {
|
||||
// if not mapped
|
||||
if (*cspbases[i] == 0) {
|
||||
FILE_LOG(logINFO, ("Mapping memory for %s\n", names[i]));
|
||||
LOG(logINFO, ("Mapping memory for %s\n", names[i]));
|
||||
#ifdef VIRTUAL
|
||||
*cspbases[i] = malloc(MEM_SIZE);
|
||||
if (*cspbases[i] == NULL) {
|
||||
FILE_LOG(logERROR, ("Could not allocate virtual memory for %s.\n", names[i]));
|
||||
LOG(logERROR, ("Could not allocate virtual memory for %s.\n", names[i]));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("memory allocated for %s\n", names[i]));
|
||||
LOG(logINFO, ("memory allocated for %s\n", names[i]));
|
||||
#else
|
||||
int fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||
if (fd == -1) {
|
||||
FILE_LOG(logERROR, ("Can't find /dev/mem for %s\n", names[i]));
|
||||
LOG(logERROR, ("Can't find /dev/mem for %s\n", names[i]));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("/dev/mem opened for %s, (CSP:0x%x)\n", names[i], csps[i]));
|
||||
LOG(logDEBUG1, ("/dev/mem opened for %s, (CSP:0x%x)\n", names[i], csps[i]));
|
||||
*cspbases[i] = (u_int32_t*)mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, csps[i]);
|
||||
if (*cspbases[i] == MAP_FAILED) {
|
||||
FILE_LOG(logERROR, ("Can't map memmory area for %s\n", names[i]));
|
||||
LOG(logERROR, ("Can't map memmory area for %s\n", names[i]));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
FILE_LOG(logINFO, ("%s mapped from %p to %p,(CSP:0x%x) \n",
|
||||
LOG(logINFO, ("%s mapped from %p to %p,(CSP:0x%x) \n",
|
||||
names[i], *cspbases[i], *cspbases[i]+MEM_SIZE, csps[i]));
|
||||
//FILE_LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
||||
//LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
||||
} else
|
||||
FILE_LOG(logINFO, ("Memory %s already mapped before\n", names[i]));
|
||||
LOG(logINFO, ("Memory %s already mapped before\n", names[i]));
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ void defineGPIOpins(){
|
||||
//define their direction
|
||||
system("echo in > /sys/class/gpio/gpio7/direction");
|
||||
system("echo out > /sys/class/gpio/gpio9/direction");
|
||||
FILE_LOG(logINFO, ("gpio pins defined\n"));
|
||||
LOG(logINFO, ("gpio pins defined\n"));
|
||||
gpioDefined = 1;
|
||||
}else FILE_LOG(logDEBUG1, ("gpio pins already defined earlier\n"));
|
||||
}else LOG(logDEBUG1, ("gpio pins already defined earlier\n"));
|
||||
}
|
||||
|
||||
void FPGAdontTouchFlash(){
|
||||
@@ -38,23 +38,23 @@ void FPGATouchFlash(){
|
||||
}
|
||||
|
||||
void resetFPGA(){
|
||||
FILE_LOG(logINFOBLUE, ("Reseting FPGA\n"));
|
||||
LOG(logINFOBLUE, ("Reseting FPGA\n"));
|
||||
FPGAdontTouchFlash();
|
||||
FPGATouchFlash();
|
||||
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||
}
|
||||
|
||||
void eraseFlash(){
|
||||
FILE_LOG(logDEBUG1, ("Erasing Flash\n"));
|
||||
LOG(logDEBUG1, ("Erasing Flash\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"flash_eraseall %s",mtdvalue);
|
||||
system(command);
|
||||
FILE_LOG(logINFO, ("Flash erased\n"));
|
||||
LOG(logINFO, ("Flash erased\n"));
|
||||
}
|
||||
|
||||
int startWritingFPGAprogram(FILE** filefp){
|
||||
FILE_LOG(logDEBUG1, ("Start Writing of FPGA program\n"));
|
||||
LOG(logDEBUG1, ("Start Writing of FPGA program\n"));
|
||||
|
||||
//getting the drive
|
||||
//root:/> cat /proc/mtd
|
||||
@@ -67,11 +67,11 @@ int startWritingFPGAprogram(FILE** filefp){
|
||||
memset(output, 0, 255);
|
||||
FILE* fp = popen("awk \'$4== \"\\\"bitfile(spi)\\\"\" {print $1}\' /proc/mtd", "r");
|
||||
if (fp == NULL) {
|
||||
FILE_LOG(logERROR, ("popen returned NULL. Need that to get mtd drive.\n"));
|
||||
LOG(logERROR, ("popen returned NULL. Need that to get mtd drive.\n"));
|
||||
return 1;
|
||||
}
|
||||
if (fgets(output, sizeof(output), fp) == NULL) {
|
||||
FILE_LOG(logERROR, ("fgets returned NULL. Need that to get mtd drive.\n"));
|
||||
LOG(logERROR, ("fgets returned NULL. Need that to get mtd drive.\n"));
|
||||
return 1;
|
||||
}
|
||||
pclose(fp);
|
||||
@@ -79,27 +79,27 @@ int startWritingFPGAprogram(FILE** filefp){
|
||||
strcpy(mtdvalue,"/dev/");
|
||||
char* pch = strtok(output,":");
|
||||
if(pch == NULL){
|
||||
FILE_LOG(logERROR, ("Could not get mtd value\n"));
|
||||
LOG(logERROR, ("Could not get mtd value\n"));
|
||||
return 1;
|
||||
}
|
||||
strcat(mtdvalue,pch);
|
||||
FILE_LOG(logINFO, ("Flash drive found: %s\n", mtdvalue));
|
||||
LOG(logINFO, ("Flash drive found: %s\n", mtdvalue));
|
||||
|
||||
FPGAdontTouchFlash();
|
||||
|
||||
//writing the program to flash
|
||||
*filefp = fopen(mtdvalue, "w");
|
||||
if(*filefp == NULL){
|
||||
FILE_LOG(logERROR, ("Unable to open %s in write mode\n", mtdvalue));
|
||||
LOG(logERROR, ("Unable to open %s in write mode\n", mtdvalue));
|
||||
return 1;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Flash ready for writing\n"));
|
||||
LOG(logINFO, ("Flash ready for writing\n"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stopWritingFPGAprogram(FILE* filefp){
|
||||
FILE_LOG(logDEBUG1, ("Stopping of writing FPGA program\n"));
|
||||
LOG(logDEBUG1, ("Stopping of writing FPGA program\n"));
|
||||
|
||||
int wait = 0;
|
||||
if(filefp!= NULL){
|
||||
@@ -111,7 +111,7 @@ void stopWritingFPGAprogram(FILE* filefp){
|
||||
FPGATouchFlash();
|
||||
|
||||
if(wait){
|
||||
FILE_LOG(logDEBUG1, ("Waiting for FPGA to program from flash\n"));
|
||||
LOG(logDEBUG1, ("Waiting for FPGA to program from flash\n"));
|
||||
//waiting for success or done
|
||||
char output[255];
|
||||
int res=0;
|
||||
@@ -120,22 +120,22 @@ void stopWritingFPGAprogram(FILE* filefp){
|
||||
fgets(output, sizeof(output), sysFile);
|
||||
pclose(sysFile);
|
||||
sscanf(output,"%d",&res);
|
||||
FILE_LOG(logDEBUG1, ("gpi07 returned %d\n", res));
|
||||
LOG(logDEBUG1, ("gpi07 returned %d\n", res));
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO, ("FPGA has picked up the program from flash\n"));
|
||||
LOG(logINFO, ("FPGA has picked up the program from flash\n"));
|
||||
}
|
||||
|
||||
int writeFPGAProgram(char* fpgasrc, uint64_t fsize, FILE* filefp){
|
||||
FILE_LOG(logDEBUG1, ("Writing of FPGA Program\n"
|
||||
LOG(logDEBUG1, ("Writing of FPGA Program\n"
|
||||
"\taddress of fpgasrc:%p\n"
|
||||
"\tfsize:%llu\n\tpointer:%p\n",
|
||||
(void *)fpgasrc, (long long unsigned int)fsize, (void*)filefp));
|
||||
|
||||
if(fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp )!= fsize){
|
||||
FILE_LOG(logERROR, ("Could not write FPGA source to flash (size:%llu)\n", (long long unsigned int)fsize));
|
||||
LOG(logERROR, ("Could not write FPGA source to flash (size:%llu)\n", (long long unsigned int)fsize));
|
||||
return 1;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("program written to flash\n"));
|
||||
LOG(logDEBUG1, ("program written to flash\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ char mtdvalue[MTDSIZE] = {0};
|
||||
#define MICROCONTROLLER_FILE "/dev/ttyAL0"
|
||||
|
||||
void NotifyServerStartSuccess() {
|
||||
FILE_LOG(logINFOBLUE, ("Server started successfully\n"));
|
||||
LOG(logINFOBLUE, ("Server started successfully\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"echo r > %s",MICROCONTROLLER_FILE);
|
||||
@@ -26,17 +26,17 @@ void CreateNotificationForCriticalTasks() {
|
||||
if (fd == NULL) {
|
||||
fd = fopen(NOTIFICATION_FILE, "w");
|
||||
if (fd == NULL) {
|
||||
FILE_LOG(logERROR, ("Could not create notication file: %s\n", NOTIFICATION_FILE));
|
||||
LOG(logERROR, ("Could not create notication file: %s\n", NOTIFICATION_FILE));
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logINFOBLUE, ("Created notification file: %s\n", NOTIFICATION_FILE));
|
||||
LOG(logINFOBLUE, ("Created notification file: %s\n", NOTIFICATION_FILE));
|
||||
}
|
||||
fclose(fd);
|
||||
NotifyCriticalTaskDone();
|
||||
}
|
||||
|
||||
void NotifyCriticalTask() {
|
||||
FILE_LOG(logINFO, ("\tNotifying Critical Task Ongoing\n"));
|
||||
LOG(logINFO, ("\tNotifying Critical Task Ongoing\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"echo 1 > %s",NOTIFICATION_FILE);
|
||||
@@ -44,7 +44,7 @@ void NotifyCriticalTask() {
|
||||
}
|
||||
|
||||
void NotifyCriticalTaskDone() {
|
||||
FILE_LOG(logINFO, ("\tNotifying Critical Task Done\n"));
|
||||
LOG(logINFO, ("\tNotifying Critical Task Done\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"echo 0 > %s",NOTIFICATION_FILE);
|
||||
@@ -52,7 +52,7 @@ void NotifyCriticalTaskDone() {
|
||||
}
|
||||
|
||||
void rebootControllerAndFPGA() {
|
||||
FILE_LOG(logDEBUG1, ("Reseting FPGA...\n"));
|
||||
LOG(logDEBUG1, ("Reseting FPGA...\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"echo z > %s",MICROCONTROLLER_FILE);
|
||||
@@ -60,7 +60,7 @@ void rebootControllerAndFPGA() {
|
||||
}
|
||||
|
||||
int findFlash(char* mess) {
|
||||
FILE_LOG(logDEBUG1, ("Finding flash drive...\n"));
|
||||
LOG(logDEBUG1, ("Finding flash drive...\n"));
|
||||
//getting the drive
|
||||
// # cat /proc/mtd
|
||||
// dev: size erasesize name
|
||||
@@ -75,12 +75,12 @@ int findFlash(char* mess) {
|
||||
FILE* fp = popen("awk \'$5== \"Application\" {print $1}\' /proc/mtd", "r");
|
||||
if (fp == NULL) {
|
||||
strcpy(mess, "popen returned NULL. Need that to get mtd drive.\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
return RO_TRIGGER_IN_FALLING_EDGE;
|
||||
}
|
||||
if (fgets(output, sizeof(output), fp) == NULL) {
|
||||
strcpy(mess, "fgets returned NULL. Need that to get mtd drive.\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
pclose(fp);
|
||||
@@ -89,21 +89,21 @@ int findFlash(char* mess) {
|
||||
char* pch = strtok(output, ":");
|
||||
if (pch == NULL){
|
||||
strcpy (mess, "Could not get mtd value\n");
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
strcat(mtdvalue, pch);
|
||||
FILE_LOG(logINFO, ("\tFlash drive found: %s\n", mtdvalue));
|
||||
LOG(logINFO, ("\tFlash drive found: %s\n", mtdvalue));
|
||||
return OK;
|
||||
}
|
||||
|
||||
void eraseFlash() {
|
||||
FILE_LOG(logDEBUG1, ("Erasing Flash...\n"));
|
||||
LOG(logDEBUG1, ("Erasing Flash...\n"));
|
||||
char command[255];
|
||||
memset(command, 0, 255);
|
||||
sprintf(command,"flash_erase %s 0 0",mtdvalue);
|
||||
system(command);
|
||||
FILE_LOG(logINFO, ("\tFlash erased\n"));
|
||||
LOG(logINFO, ("\tFlash erased\n"));
|
||||
}
|
||||
|
||||
int eraseAndWriteToFlash(char* mess, char* fpgasrc, uint64_t fsize) {
|
||||
@@ -118,10 +118,10 @@ int eraseAndWriteToFlash(char* mess, char* fpgasrc, uint64_t fsize) {
|
||||
if(filefp == NULL){
|
||||
NotifyCriticalTaskDone();
|
||||
sprintf (mess, "Unable to open %s in write mode\n", mtdvalue);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("\tFlash ready for writing\n"));
|
||||
LOG(logINFO, ("\tFlash ready for writing\n"));
|
||||
|
||||
// write to flash
|
||||
if (writeFPGAProgram(mess, fpgasrc, fsize, filefp) == FAIL) {
|
||||
@@ -136,7 +136,7 @@ int eraseAndWriteToFlash(char* mess, char* fpgasrc, uint64_t fsize) {
|
||||
}
|
||||
|
||||
int writeFPGAProgram(char* mess, char* fpgasrc, uint64_t fsize, FILE* filefp) {
|
||||
FILE_LOG(logDEBUG1, ("Writing to flash...\n"
|
||||
LOG(logDEBUG1, ("Writing to flash...\n"
|
||||
"\taddress of fpgasrc:%p\n"
|
||||
"\tfsize:%lu\n\tpointer:%p\n",
|
||||
(void *)fpgasrc, fsize, (void*)filefp));
|
||||
@@ -144,9 +144,9 @@ int writeFPGAProgram(char* mess, char* fpgasrc, uint64_t fsize, FILE* filefp) {
|
||||
uint64_t retval = fwrite((void*)fpgasrc , sizeof(char) , fsize , filefp);
|
||||
if (retval != fsize) {
|
||||
sprintf (mess, "Could not write FPGA source to flash (size:%llu), write %llu\n", (long long unsigned int) fsize, (long long unsigned int)retval);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
LOG(logERROR, (mess));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("\tProgram written to flash\n"));
|
||||
LOG(logINFO, ("\tProgram written to flash\n"));
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ int loadDefaultPattern(char* fname) {
|
||||
if(fd == NULL) {
|
||||
sprintf(initErrorMessage, "Could not open pattern file [%s].\n", fname);
|
||||
initError = FAIL;
|
||||
FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFOBLUE, ("Reading default pattern file %s\n", fname));
|
||||
LOG(logINFOBLUE, ("Reading default pattern file %s\n", fname));
|
||||
|
||||
|
||||
// Initialization
|
||||
@@ -43,17 +43,17 @@ int loadDefaultPattern(char* fname) {
|
||||
|
||||
// ignore comments
|
||||
if (line[0] == '#') {
|
||||
FILE_LOG(logDEBUG1, ("Ignoring Comment\n"));
|
||||
LOG(logDEBUG1, ("Ignoring Comment\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
// ignore empty lines
|
||||
if (strlen(line) <= 1) {
|
||||
FILE_LOG(logDEBUG1, ("Ignoring Empty line\n"));
|
||||
LOG(logDEBUG1, ("Ignoring Empty line\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Command to process: (size:%d) %.*s\n",
|
||||
LOG(logDEBUG1, ("Command to process: (size:%d) %.*s\n",
|
||||
strlen(line), strlen(line) -1, line));
|
||||
memset(command, 0, LZ);
|
||||
|
||||
@@ -259,9 +259,9 @@ int loadDefaultPattern(char* fname) {
|
||||
|
||||
if (strlen(initErrorMessage)) {
|
||||
initError = FAIL;
|
||||
FILE_LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||
} else {
|
||||
FILE_LOG(logINFOBLUE, ("Successfully read default pattern file\n"));
|
||||
LOG(logINFOBLUE, ("Successfully read default pattern file\n"));
|
||||
}
|
||||
return initError;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ int main(int argc, char *argv[]){
|
||||
#elif MOENCHD
|
||||
version = APIMOENCH;
|
||||
#endif
|
||||
FILE_LOG(logINFO, ("SLS Detector Server %s (0x%x)\n", GITBRANCH, version));
|
||||
LOG(logINFO, ("SLS Detector Server %s (0x%x)\n", GITBRANCH, version));
|
||||
}
|
||||
|
||||
int portno = DEFAULT_PORTNO;
|
||||
@@ -62,39 +62,39 @@ int main(int argc, char *argv[]){
|
||||
int i;
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if(!strcasecmp(argv[i],"-stopserver")) {
|
||||
FILE_LOG(logINFO, ("Detected stop server\n"));
|
||||
LOG(logINFO, ("Detected stop server\n"));
|
||||
isControlServer = 0;
|
||||
}
|
||||
else if(!strcasecmp(argv[i],"-devel")){
|
||||
FILE_LOG(logINFO, ("Detected developer mode\n"));
|
||||
LOG(logINFO, ("Detected developer mode\n"));
|
||||
debugflag = 1;
|
||||
}
|
||||
else if(!strcasecmp(argv[i],"-nomodule")){
|
||||
FILE_LOG(logINFO, ("Detected No Module mode\n"));
|
||||
LOG(logINFO, ("Detected No Module mode\n"));
|
||||
checkModuleFlag = 0;
|
||||
}
|
||||
else if(!strcasecmp(argv[i],"-port")){
|
||||
if ((i + 1) >= argc) {
|
||||
FILE_LOG(logERROR, ("no port value given. Exiting.\n"));
|
||||
LOG(logERROR, ("no port value given. Exiting.\n"));
|
||||
return -1;
|
||||
}
|
||||
if (sscanf(argv[i + 1], "%d", &portno) == 0) {
|
||||
FILE_LOG(logERROR, ("cannot decode port value %s. Exiting.\n", argv[i + 1]));
|
||||
LOG(logERROR, ("cannot decode port value %s. Exiting.\n", argv[i + 1]));
|
||||
return -1;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Detected port: %d\n", portno));
|
||||
LOG(logINFO, ("Detected port: %d\n", portno));
|
||||
}
|
||||
#ifdef GOTTHARDD
|
||||
else if(!strcasecmp(argv[i],"-phaseshift")){
|
||||
if ((i + 1) >= argc) {
|
||||
FILE_LOG(logERROR, ("no phase shift value given. Exiting.\n"));
|
||||
LOG(logERROR, ("no phase shift value given. Exiting.\n"));
|
||||
return -1;
|
||||
}
|
||||
if (sscanf(argv[i + 1], "%d", &phaseShift) == 0) {
|
||||
FILE_LOG(logERROR, ("cannot decode phase shift value %s. Exiting.\n", argv[i + 1]));
|
||||
LOG(logERROR, ("cannot decode phase shift value %s. Exiting.\n", argv[i + 1]));
|
||||
return -1;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Detected phase shift of %d\n", phaseShift));
|
||||
LOG(logINFO, ("Detected phase shift of %d\n", phaseShift));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -105,19 +105,19 @@ int main(int argc, char *argv[]){
|
||||
memset(cmd, 0, 100);
|
||||
#endif
|
||||
if (isControlServer) {
|
||||
FILE_LOG(logINFO, ("Opening control server on port %d \n", portno));
|
||||
LOG(logINFO, ("Opening control server on port %d \n", portno));
|
||||
#ifdef STOP_SERVER
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < argc; ++i)
|
||||
sprintf(cmd, "%s %s", cmd, argv[i]);
|
||||
sprintf(cmd,"%s -stopserver -port %d &", cmd, portno + 1);
|
||||
FILE_LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
|
||||
LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
|
||||
system(cmd);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
FILE_LOG(logINFO,("Opening stop server on port %d \n", portno));
|
||||
LOG(logINFO,("Opening stop server on port %d \n", portno));
|
||||
}
|
||||
|
||||
init_detector();
|
||||
@@ -132,9 +132,9 @@ int main(int argc, char *argv[]){
|
||||
function_table();
|
||||
|
||||
if (isControlServer) {
|
||||
FILE_LOG(logINFOBLUE, ("Control Server Ready...\n\n"));
|
||||
LOG(logINFOBLUE, ("Control Server Ready...\n\n"));
|
||||
} else {
|
||||
FILE_LOG(logINFO, ("Stop Server Ready...\n\n"));
|
||||
LOG(logINFO, ("Stop Server Ready...\n\n"));
|
||||
}
|
||||
|
||||
// waits for connection
|
||||
@@ -149,7 +149,7 @@ int main(int argc, char *argv[]){
|
||||
exitServer(sockfd);
|
||||
|
||||
if (retval == REBOOT) {
|
||||
FILE_LOG(logINFORED,("Rebooting!\n"));
|
||||
LOG(logINFORED,("Rebooting!\n"));
|
||||
fflush(stdout);
|
||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||
rebootNiosControllerAndFPGA();
|
||||
@@ -157,6 +157,6 @@ int main(int argc, char *argv[]){
|
||||
system("reboot");
|
||||
#endif
|
||||
}
|
||||
FILE_LOG(logINFO,("Goodbye!\n"));
|
||||
LOG(logINFO,("Goodbye!\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -46,7 +46,7 @@ void CmdProxy::Call(const std::string &command,
|
||||
bool CmdProxy::ReplaceIfDepreciated(std::string &command) {
|
||||
auto d_it = depreciated_functions.find(command);
|
||||
if (d_it != depreciated_functions.end()) {
|
||||
FILE_LOG(logWARNING)
|
||||
LOG(logWARNING)
|
||||
<< command
|
||||
<< " is depreciated and will be removed. Please migrate to: "
|
||||
<< d_it->second;
|
||||
|
||||
@@ -128,20 +128,20 @@ class SharedMemory {
|
||||
fd = shm_open(name.c_str(), O_CREAT | O_TRUNC | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
|
||||
if (fd < 0) {
|
||||
std::string msg = "Create shared memory " + name + " failed: " + strerror(errno);
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
|
||||
if (ftruncate(fd, sizeof(T)) < 0) {
|
||||
std::string msg = "Create shared memory " + name + " failed at ftruncate: " + strerror(errno);
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
close(fd);
|
||||
RemoveSharedMemory();
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
|
||||
shared_struct = MapSharedMemory();
|
||||
FILE_LOG(logINFO) << "Shared memory created " << name;
|
||||
LOG(logINFO) << "Shared memory created " << name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +153,7 @@ class SharedMemory {
|
||||
fd = shm_open(name.c_str(), O_RDWR, 0);
|
||||
if (fd < 0) {
|
||||
std::string msg = "Open existing shared memory " + name + " failed: " + strerror(errno);
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ class SharedMemory {
|
||||
if (shared_struct != nullptr) {
|
||||
if (munmap(shared_struct, shmSize) < 0) {
|
||||
std::string msg = "Unmapping shared memory " + name + " failed: " + strerror(errno);
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
close(fd);
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
@@ -186,10 +186,10 @@ class SharedMemory {
|
||||
if (errno == ENOENT)
|
||||
return;
|
||||
std::string msg = "Free Shared Memory " + name + " Failed: " + strerror(errno);
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
FILE_LOG(logINFO) << "Shared memory deleted " << name;
|
||||
LOG(logINFO) << "Shared memory deleted " << name;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,7 +238,7 @@ class SharedMemory {
|
||||
std::string temp = ss.str();
|
||||
if (temp.length() > NAME_MAX_LENGTH) {
|
||||
std::string msg = "Shared memory initialization failed. " + temp + " has " + std::to_string(temp.length()) + " characters. \n" + "Maximum is " + std::to_string(NAME_MAX_LENGTH) + ". Change the environment variable " + SHM_ENV_NAME;
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
return temp;
|
||||
@@ -254,7 +254,7 @@ class SharedMemory {
|
||||
void *addr = mmap(nullptr, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (addr == MAP_FAILED) {
|
||||
std::string msg = "Mapping shared memory " + name + " failed: " + strerror(errno);
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
close(fd);
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ class SharedMemory {
|
||||
// could not fstat
|
||||
if (fstat(fd, &sb) < 0) {
|
||||
std::string msg = "Could not verify existing shared memory " + name + " size match " + "(could not fstat): " + strerror(errno);
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
close(fd);
|
||||
throw SharedMemoryError(msg);
|
||||
}
|
||||
@@ -282,7 +282,7 @@ class SharedMemory {
|
||||
auto sz = static_cast<size_t>(sb.st_size);
|
||||
if (sz != expectedSize) {
|
||||
std::string msg = "Existing shared memory " + name + " size does not match" + "Expected " + std::to_string(expectedSize) + ", found " + std::to_string(sz);
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
throw SharedMemoryError(msg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,8 +33,8 @@ BinaryFile::~BinaryFile() {
|
||||
|
||||
void BinaryFile::PrintMembers(TLogLevel level) {
|
||||
File::PrintMembers(level);
|
||||
FILE_LOG(logINFO) << "Max Frames Per File: " << *maxFramesPerFile;
|
||||
FILE_LOG(logINFO) << "Number of Frames in File: " << numFramesInFile;
|
||||
LOG(logINFO) << "Max Frames Per File: " << *maxFramesPerFile;
|
||||
LOG(logINFO) << "Number of Frames in File: " << numFramesInFile;
|
||||
}
|
||||
|
||||
slsDetectorDefs::fileFormat BinaryFile::GetFileType() {
|
||||
@@ -52,7 +52,7 @@ void BinaryFile::CreateFile() {
|
||||
BinaryFileStatic::CreateDataFile(filefd, *overWriteEnable, currentFileName);
|
||||
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;
|
||||
LOG(logINFO) << "[" << *udpPortNumber << "]: Binary File created: " << currentFileName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ void BinaryFile::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
|
||||
masterFileName = BinaryFileStatic::CreateMasterFileName(*filePath,
|
||||
*fileNamePrefix, *fileIndex);
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "Master File: " << masterFileName;
|
||||
LOG(logINFO) << "Master File: " << masterFileName;
|
||||
}
|
||||
attr.version = BINARY_WRITER_VERSION;
|
||||
BinaryFileStatic::CreateMasterDataFile(masterfd, masterFileName,
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <syscall.h>
|
||||
#include <vector>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using sls::RuntimeError;
|
||||
using sls::SocketError;
|
||||
@@ -24,9 +25,9 @@ ClientInterface::~ClientInterface() {
|
||||
killTcpThread = true;
|
||||
// shut down tcp sockets
|
||||
if (server.get() != nullptr) {
|
||||
FILE_LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
|
||||
LOG(logINFO) << "Shutting down TCP Socket on port " << portNumber;
|
||||
server->shutDownSocket();
|
||||
FILE_LOG(logDEBUG) << "TCP Socket closed on port " << portNumber;
|
||||
LOG(logDEBUG) << "TCP Socket closed on port " << portNumber;
|
||||
}
|
||||
// shut down tcp thread
|
||||
tcpThread->join();
|
||||
@@ -68,12 +69,12 @@ void ClientInterface::registerCallBackRawDataModifyReady(
|
||||
}
|
||||
|
||||
void ClientInterface::startTCPServer() {
|
||||
FILE_LOG(logINFOBLUE) << "Created [ TCP server Tid: " << syscall(SYS_gettid) << "]";
|
||||
FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port "
|
||||
LOG(logINFOBLUE) << "Created [ TCP server Tid: " << syscall(SYS_gettid) << "]";
|
||||
LOG(logINFO) << "SLS Receiver starting TCP Server on port "
|
||||
<< portNumber << '\n';
|
||||
server = sls::make_unique<sls::ServerSocket>(portNumber);
|
||||
while (true) {
|
||||
FILE_LOG(logDEBUG1) << "Start accept loop";
|
||||
LOG(logDEBUG1) << "Start accept loop";
|
||||
try {
|
||||
auto socket = server->accept();
|
||||
try {
|
||||
@@ -91,7 +92,7 @@ void ClientInterface::startTCPServer() {
|
||||
break;
|
||||
}
|
||||
} catch (const RuntimeError &e) {
|
||||
FILE_LOG(logERROR) << "Accept failed";
|
||||
LOG(logERROR) << "Accept failed";
|
||||
}
|
||||
// destructor to kill this thread
|
||||
if (killTcpThread) {
|
||||
@@ -102,7 +103,7 @@ void ClientInterface::startTCPServer() {
|
||||
if (receiver) {
|
||||
receiver->shutDownUDPSockets();
|
||||
}
|
||||
FILE_LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) << "]";
|
||||
LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) << "]";
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
@@ -177,7 +178,7 @@ int ClientInterface::functionTable(){
|
||||
flist[F_RECEIVER_SET_NUM_COUNTERS] = &ClientInterface::set_num_counters;
|
||||
|
||||
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
|
||||
FILE_LOG(logDEBUG1) << "function fnum: " << i << " (" <<
|
||||
LOG(logDEBUG1) << "function fnum: " << i << " (" <<
|
||||
getFunctionNameFromEnum((enum detFuncs)i) << ") located at " << flist[i];
|
||||
}
|
||||
|
||||
@@ -191,11 +192,11 @@ int ClientInterface::decodeFunction(Interface &socket) {
|
||||
throw RuntimeError("Unrecognized Function enum " +
|
||||
std::to_string(fnum) + "\n");
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1) << "calling function fnum: " << fnum << " ("
|
||||
LOG(logDEBUG1) << "calling function fnum: " << fnum << " ("
|
||||
<< getFunctionNameFromEnum((enum detFuncs)fnum)
|
||||
<< ")";
|
||||
ret = (this->*flist[fnum])(socket);
|
||||
FILE_LOG(logDEBUG1)
|
||||
LOG(logDEBUG1)
|
||||
<< "Function " << getFunctionNameFromEnum((enum detFuncs)fnum)
|
||||
<< " finished";
|
||||
}
|
||||
@@ -248,7 +249,7 @@ int ClientInterface::exec_command(Interface &socket) {
|
||||
char cmd[MAX_STR_LENGTH]{};
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
socket.Receive(cmd);
|
||||
FILE_LOG(logINFO) << "Executing command (" << cmd << ")";
|
||||
LOG(logINFO) << "Executing command (" << cmd << ")";
|
||||
const size_t tempsize = 256;
|
||||
std::array<char, tempsize> temp{};
|
||||
std::string sresult;
|
||||
@@ -261,20 +262,20 @@ int ClientInterface::exec_command(Interface &socket) {
|
||||
sresult += temp.data();
|
||||
}
|
||||
strncpy(retval, sresult.c_str(), MAX_STR_LENGTH);
|
||||
FILE_LOG(logINFO) << "Result of cmd (" << cmd << "):\n" << retval;
|
||||
LOG(logINFO) << "Result of cmd (" << cmd << "):\n" << retval;
|
||||
}
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::exit_server(Interface &socket) {
|
||||
FILE_LOG(logINFO) << "Closing server";
|
||||
LOG(logINFO) << "Closing server";
|
||||
socket.Send(OK);
|
||||
return GOODBYE;
|
||||
}
|
||||
|
||||
int ClientInterface::lock_receiver(Interface &socket) {
|
||||
auto lock = socket.Receive<int>();
|
||||
FILE_LOG(logDEBUG1) << "Locking Server to " << lock;
|
||||
LOG(logDEBUG1) << "Locking Server to " << lock;
|
||||
if (lock >= 0) {
|
||||
if (!lockedByClient || (server->getLockedBy() == server->getThisClient())) {
|
||||
lockedByClient = lock;
|
||||
@@ -297,7 +298,7 @@ int ClientInterface::set_port(Interface &socket) {
|
||||
throw RuntimeError("Port Number: " + std::to_string(p_number) +
|
||||
" is too low (<1024)");
|
||||
|
||||
FILE_LOG(logINFO) << "TCP port set to " << p_number << std::endl;
|
||||
LOG(logINFO) << "TCP port set to " << p_number << std::endl;
|
||||
auto new_server = sls::make_unique<sls::ServerSocket>(p_number);
|
||||
new_server->setLockedBy(server->getLockedBy());
|
||||
new_server->setLastClient(server->getThisClient());
|
||||
@@ -490,7 +491,7 @@ int ClientInterface::set_roi(Interface &socket) {
|
||||
static_assert(sizeof(ROI) == 2 * sizeof(int), "ROI not packed");
|
||||
ROI arg;
|
||||
socket.Receive(arg);
|
||||
FILE_LOG(logDEBUG1) << "Set ROI: [" << arg.xmin << ", " << arg.xmax << "]";
|
||||
LOG(logDEBUG1) << "Set ROI: [" << arg.xmin << ", " << arg.xmax << "]";
|
||||
|
||||
if (myDetectorType != GOTTHARD)
|
||||
functionNotImplemented();
|
||||
@@ -506,14 +507,14 @@ int ClientInterface::set_roi(Interface &socket) {
|
||||
|
||||
int ClientInterface::set_num_frames(Interface &socket) {
|
||||
auto value = socket.Receive<int64_t>();
|
||||
FILE_LOG(logDEBUG1) << "Setting num frames to " << value;
|
||||
LOG(logDEBUG1) << "Setting num frames to " << value;
|
||||
impl()->setNumberOfFrames(value);
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
int ClientInterface::set_num_analog_samples(Interface &socket) {
|
||||
auto value = socket.Receive<int>();
|
||||
FILE_LOG(logDEBUG1) << "Setting num analog samples to " << value;
|
||||
LOG(logDEBUG1) << "Setting num analog samples to " << value;
|
||||
if (myDetectorType != CHIPTESTBOARD && myDetectorType != MOENCH) {
|
||||
functionNotImplemented();
|
||||
}
|
||||
@@ -528,7 +529,7 @@ int ClientInterface::set_num_analog_samples(Interface &socket) {
|
||||
|
||||
int ClientInterface::set_num_digital_samples(Interface &socket) {
|
||||
auto value = socket.Receive<int>();
|
||||
FILE_LOG(logDEBUG1) << "Setting num digital samples to " << value;
|
||||
LOG(logDEBUG1) << "Setting num digital samples to " << value;
|
||||
if (myDetectorType != CHIPTESTBOARD) {
|
||||
functionNotImplemented();
|
||||
}
|
||||
@@ -542,21 +543,21 @@ int ClientInterface::set_num_digital_samples(Interface &socket) {
|
||||
|
||||
int ClientInterface::set_exptime(Interface &socket) {
|
||||
auto value = socket.Receive<int64_t>();
|
||||
FILE_LOG(logDEBUG1) << "Setting exptime to " << value << "ns";
|
||||
LOG(logDEBUG1) << "Setting exptime to " << value << "ns";
|
||||
impl()->setAcquisitionTime(value);
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
int ClientInterface::set_period(Interface &socket) {
|
||||
auto value = socket.Receive<int64_t>();
|
||||
FILE_LOG(logDEBUG1) << "Setting period to " << value << "ns";
|
||||
LOG(logDEBUG1) << "Setting period to " << value << "ns";
|
||||
impl()->setAcquisitionPeriod(value);
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
int ClientInterface::set_subexptime(Interface &socket) {
|
||||
auto value = socket.Receive<int64_t>();
|
||||
FILE_LOG(logDEBUG1) << "Setting period to " << value << "ns";
|
||||
LOG(logDEBUG1) << "Setting period to " << value << "ns";
|
||||
uint64_t subdeadtime = impl()->getSubPeriod() - impl()->getSubExpTime();
|
||||
impl()->setSubExpTime(value);
|
||||
impl()->setSubPeriod(impl()->getSubExpTime() + subdeadtime);
|
||||
@@ -565,9 +566,9 @@ int ClientInterface::set_subexptime(Interface &socket) {
|
||||
|
||||
int ClientInterface::set_subdeadtime(Interface &socket) {
|
||||
auto value = socket.Receive<int64_t>();
|
||||
FILE_LOG(logDEBUG1) << "Setting sub deadtime to " << value << "ns";
|
||||
LOG(logDEBUG1) << "Setting sub deadtime to " << value << "ns";
|
||||
impl()->setSubPeriod(value + impl()->getSubExpTime());
|
||||
FILE_LOG(logDEBUG1) << "Setting sub period to " << impl()->getSubPeriod() << "ns";
|
||||
LOG(logDEBUG1) << "Setting sub period to " << impl()->getSubPeriod() << "ns";
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
@@ -575,7 +576,7 @@ int ClientInterface::set_dynamic_range(Interface &socket) {
|
||||
auto dr = socket.Receive<int>();
|
||||
if (dr >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting dynamic range: " << dr;
|
||||
LOG(logDEBUG1) << "Setting dynamic range: " << dr;
|
||||
bool exists = false;
|
||||
switch(myDetectorType) {
|
||||
case EIGER:
|
||||
@@ -607,7 +608,7 @@ int ClientInterface::set_dynamic_range(Interface &socket) {
|
||||
}
|
||||
int retval = impl()->getDynamicRange();
|
||||
validate(dr, retval, "set dynamic range", DEC);
|
||||
FILE_LOG(logDEBUG1) << "dynamic range: " << retval;
|
||||
LOG(logDEBUG1) << "dynamic range: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -615,7 +616,7 @@ int ClientInterface::set_streaming_frequency(Interface &socket) {
|
||||
auto index = socket.Receive<int>();
|
||||
if (index >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting streaming frequency: " << index;
|
||||
LOG(logDEBUG1) << "Setting streaming frequency: " << index;
|
||||
impl()->setStreamingFrequency(index);
|
||||
}
|
||||
int retval = impl()->getStreamingFrequency();
|
||||
@@ -625,13 +626,13 @@ int ClientInterface::set_streaming_frequency(Interface &socket) {
|
||||
|
||||
int ClientInterface::get_status(Interface &socket) {
|
||||
auto retval = impl()->getStatus();
|
||||
FILE_LOG(logDEBUG1) << "Status:" << sls::ToString(retval);
|
||||
LOG(logDEBUG1) << "Status:" << sls::ToString(retval);
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::start_receiver(Interface &socket) {
|
||||
if (impl()->getStatus() == IDLE) {
|
||||
FILE_LOG(logDEBUG1) << "Starting Receiver";
|
||||
LOG(logDEBUG1) << "Starting Receiver";
|
||||
impl()->startReceiver();
|
||||
}
|
||||
return socket.Send(OK);
|
||||
@@ -640,7 +641,7 @@ int ClientInterface::start_receiver(Interface &socket) {
|
||||
int ClientInterface::stop_receiver(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
if (impl()->getStatus() == RUNNING) {
|
||||
FILE_LOG(logDEBUG1) << "Stopping Receiver";
|
||||
LOG(logDEBUG1) << "Stopping Receiver";
|
||||
impl()->setStoppedFlag(static_cast<bool>(arg));
|
||||
impl()->stopReceiver();
|
||||
}
|
||||
@@ -658,7 +659,7 @@ int ClientInterface::set_file_dir(Interface &socket) {
|
||||
socket.Receive(fPath);
|
||||
|
||||
if (strlen(fPath) != 0) {
|
||||
FILE_LOG(logDEBUG1) << "Setting file path: " << fPath;
|
||||
LOG(logDEBUG1) << "Setting file path: " << fPath;
|
||||
if(fPath[0] != '/')
|
||||
throw RuntimeError("Receiver path needs to be absolute path");
|
||||
impl()->setFilePath(fPath);
|
||||
@@ -668,7 +669,7 @@ int ClientInterface::set_file_dir(Interface &socket) {
|
||||
if ((s.empty()) || (strlen(fPath) && strcasecmp(fPath, retval)))
|
||||
throw RuntimeError("Receiver file path does not exist");
|
||||
else
|
||||
FILE_LOG(logDEBUG1) << "file path:" << retval;
|
||||
LOG(logDEBUG1) << "file path:" << retval;
|
||||
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
@@ -678,7 +679,7 @@ int ClientInterface::set_file_name(Interface &socket) {
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
socket.Receive(fName);
|
||||
if (strlen(fName) != 0) {
|
||||
FILE_LOG(logDEBUG1) << "Setting file name: " << fName;
|
||||
LOG(logDEBUG1) << "Setting file name: " << fName;
|
||||
impl()->setFileName(fName);
|
||||
}
|
||||
std::string s = impl()->getFileName();
|
||||
@@ -686,7 +687,7 @@ int ClientInterface::set_file_name(Interface &socket) {
|
||||
throw RuntimeError("file name is empty");
|
||||
|
||||
sls::strcpy_safe(retval, s.c_str());
|
||||
FILE_LOG(logDEBUG1) << "file name:" << retval;
|
||||
LOG(logDEBUG1) << "file name:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -694,24 +695,24 @@ int ClientInterface::set_file_index(Interface &socket) {
|
||||
auto index = socket.Receive<int64_t>();
|
||||
if (index >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting file index: " << index;
|
||||
LOG(logDEBUG1) << "Setting file index: " << index;
|
||||
impl()->setFileIndex(index);
|
||||
}
|
||||
int64_t retval = impl()->getFileIndex();
|
||||
validate(index, retval, "set file index", DEC);
|
||||
FILE_LOG(logDEBUG1) << "file index:" << retval;
|
||||
LOG(logDEBUG1) << "file index:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::get_frame_index(Interface &socket) {
|
||||
uint64_t retval = impl()->getAcquisitionIndex();
|
||||
FILE_LOG(logDEBUG1) << "frame index:" << retval;
|
||||
LOG(logDEBUG1) << "frame index:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::get_missing_packets(Interface &socket) {
|
||||
std::vector<uint64_t> m = impl()->getNumMissingPackets();
|
||||
FILE_LOG(logDEBUG1) << "missing packets:" << sls::ToString(m);
|
||||
LOG(logDEBUG1) << "missing packets:" << sls::ToString(m);
|
||||
int retvalsize = m.size();
|
||||
uint64_t retval[retvalsize];
|
||||
std::copy(std::begin(m), std::end(m), retval);
|
||||
@@ -723,7 +724,7 @@ int ClientInterface::get_missing_packets(Interface &socket) {
|
||||
|
||||
int ClientInterface::get_frames_caught(Interface &socket) {
|
||||
int64_t retval = impl()->getFramesCaught();
|
||||
FILE_LOG(logDEBUG1) << "frames caught:" << retval;
|
||||
LOG(logDEBUG1) << "frames caught:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -731,12 +732,12 @@ int ClientInterface::enable_file_write(Interface &socket) {
|
||||
auto enable = socket.Receive<int>();
|
||||
if (enable >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting File write enable:" << enable;
|
||||
LOG(logDEBUG1) << "Setting File write enable:" << enable;
|
||||
impl()->setFileWriteEnable(enable);
|
||||
}
|
||||
int retval = impl()->getFileWriteEnable();
|
||||
validate(enable, retval, "set file write enable", DEC);
|
||||
FILE_LOG(logDEBUG1) << "file write enable:" << retval;
|
||||
LOG(logDEBUG1) << "file write enable:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -744,12 +745,12 @@ int ClientInterface::enable_master_file_write(Interface &socket) {
|
||||
auto enable = socket.Receive<int>();
|
||||
if (enable >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting Master File write enable:" << enable;
|
||||
LOG(logDEBUG1) << "Setting Master File write enable:" << enable;
|
||||
impl()->setMasterFileWriteEnable(enable);
|
||||
}
|
||||
int retval = impl()->getMasterFileWriteEnable();
|
||||
validate(enable, retval, "set master file write enable", DEC);
|
||||
FILE_LOG(logDEBUG1) << "master file write enable:" << retval;
|
||||
LOG(logDEBUG1) << "master file write enable:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -757,12 +758,12 @@ int ClientInterface::enable_overwrite(Interface &socket) {
|
||||
auto index = socket.Receive<int>();
|
||||
if (index >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting File overwrite enable:" << index;
|
||||
LOG(logDEBUG1) << "Setting File overwrite enable:" << index;
|
||||
impl()->setOverwriteEnable(index);
|
||||
}
|
||||
int retval = impl()->getOverwriteEnable();
|
||||
validate(index, retval, "set file overwrite enable", DEC);
|
||||
FILE_LOG(logDEBUG1) << "file overwrite enable:" << retval;
|
||||
LOG(logDEBUG1) << "file overwrite enable:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -774,7 +775,7 @@ int ClientInterface::enable_tengiga(Interface &socket) {
|
||||
|
||||
if (val >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting 10GbE:" << val;
|
||||
LOG(logDEBUG1) << "Setting 10GbE:" << val;
|
||||
try {
|
||||
impl()->setTenGigaEnable(val);
|
||||
} catch(const RuntimeError &e) {
|
||||
@@ -783,7 +784,7 @@ int ClientInterface::enable_tengiga(Interface &socket) {
|
||||
}
|
||||
int retval = impl()->getTenGigaEnable();
|
||||
validate(val, retval, "set 10GbE", DEC);
|
||||
FILE_LOG(logDEBUG1) << "10Gbe:" << retval;
|
||||
LOG(logDEBUG1) << "10Gbe:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -791,7 +792,7 @@ int ClientInterface::set_fifo_depth(Interface &socket) {
|
||||
auto value = socket.Receive<int>();
|
||||
if (value >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting fifo depth:" << value;
|
||||
LOG(logDEBUG1) << "Setting fifo depth:" << value;
|
||||
try {
|
||||
impl()->setFifoDepth(value);
|
||||
} catch(const RuntimeError &e) {
|
||||
@@ -800,7 +801,7 @@ int ClientInterface::set_fifo_depth(Interface &socket) {
|
||||
}
|
||||
int retval = impl()->getFifoDepth();
|
||||
validate(value, retval, std::string("set fifo depth"), DEC);
|
||||
FILE_LOG(logDEBUG1) << "fifo depth:" << retval;
|
||||
LOG(logDEBUG1) << "fifo depth:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -811,12 +812,12 @@ int ClientInterface::set_activate(Interface &socket) {
|
||||
|
||||
if (enable >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting activate:" << enable;
|
||||
LOG(logDEBUG1) << "Setting activate:" << enable;
|
||||
impl()->setActivate(static_cast<bool>(enable));
|
||||
}
|
||||
auto retval = static_cast<int>(impl()->getActivate());
|
||||
validate(enable, retval, "set activate", DEC);
|
||||
FILE_LOG(logDEBUG1) << "Activate: " << retval;
|
||||
LOG(logDEBUG1) << "Activate: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -824,7 +825,7 @@ int ClientInterface::set_data_stream_enable(Interface &socket) {
|
||||
auto index = socket.Receive<int>();
|
||||
if (index >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting data stream enable:" << index;
|
||||
LOG(logDEBUG1) << "Setting data stream enable:" << index;
|
||||
try {
|
||||
impl()->setDataStreamEnable(index);
|
||||
} catch(const RuntimeError &e) {
|
||||
@@ -833,7 +834,7 @@ int ClientInterface::set_data_stream_enable(Interface &socket) {
|
||||
}
|
||||
auto retval = static_cast<int>(impl()->getDataStreamEnable());
|
||||
validate(index, retval, "set data stream enable", DEC);
|
||||
FILE_LOG(logDEBUG1) << "data streaming enable:" << retval;
|
||||
LOG(logDEBUG1) << "data streaming enable:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -841,12 +842,12 @@ int ClientInterface::set_streaming_timer(Interface &socket) {
|
||||
auto index = socket.Receive<int>();
|
||||
if (index >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting streaming timer:" << index;
|
||||
LOG(logDEBUG1) << "Setting streaming timer:" << index;
|
||||
impl()->setStreamingTimer(index);
|
||||
}
|
||||
int retval = impl()->getStreamingTimer();
|
||||
validate(index, retval, "set data stream timer", DEC);
|
||||
FILE_LOG(logDEBUG1) << "Streaming timer:" << retval;
|
||||
LOG(logDEBUG1) << "Streaming timer:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -858,12 +859,12 @@ int ClientInterface::set_flipped_data(Interface &socket) {
|
||||
|
||||
if (arg >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting flipped data:" << arg;
|
||||
LOG(logDEBUG1) << "Setting flipped data:" << arg;
|
||||
impl()->setFlippedDataX(arg);
|
||||
}
|
||||
int retval = impl()->getFlippedDataX();
|
||||
validate(arg, retval, std::string("set flipped data"), DEC);
|
||||
FILE_LOG(logDEBUG1) << "Flipped Data:" << retval;
|
||||
LOG(logDEBUG1) << "Flipped Data:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -872,12 +873,12 @@ int ClientInterface::set_file_format(Interface &socket) {
|
||||
socket.Receive(f);
|
||||
if (f >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting file format:" << f;
|
||||
LOG(logDEBUG1) << "Setting file format:" << f;
|
||||
impl()->setFileFormat(f);
|
||||
}
|
||||
auto retval = impl()->getFileFormat();
|
||||
validate(f, retval, "set file format", DEC);
|
||||
FILE_LOG(logDEBUG1) << "File Format: " << retval;
|
||||
LOG(logDEBUG1) << "File Format: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -885,12 +886,12 @@ int ClientInterface::set_detector_posid(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
if (arg >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting detector position id:" << arg;
|
||||
LOG(logDEBUG1) << "Setting detector position id:" << arg;
|
||||
impl()->setDetectorPositionId(arg);
|
||||
}
|
||||
auto retval = impl()->getDetectorPositionId();
|
||||
validate(arg, retval, "set detector position id", DEC);
|
||||
FILE_LOG(logDEBUG1) << "Position Id:" << retval;
|
||||
LOG(logDEBUG1) << "Position Id:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -899,13 +900,13 @@ int ClientInterface::set_multi_detector_size(Interface &socket) {
|
||||
socket.Receive(arg);
|
||||
if ((arg[0] > 0) && (arg[1] > 0)) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1)
|
||||
LOG(logDEBUG1)
|
||||
<< "Setting multi detector size:" << arg[0] << "," << arg[1];
|
||||
impl()->setMultiDetectorSize(arg);
|
||||
}
|
||||
int *temp = impl()->getMultiDetectorSize(); // TODO! return by value!
|
||||
int retval = temp[0] * temp[1];
|
||||
FILE_LOG(logDEBUG1) << "Multi Detector Size:" << retval;
|
||||
LOG(logDEBUG1) << "Multi Detector Size:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -913,12 +914,12 @@ int ClientInterface::set_streaming_port(Interface &socket) {
|
||||
auto port = socket.Receive<int>();
|
||||
if (port >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting streaming port:" << port;
|
||||
LOG(logDEBUG1) << "Setting streaming port:" << port;
|
||||
impl()->setStreamingPort(port);
|
||||
}
|
||||
int retval = impl()->getStreamingPort();
|
||||
validate(port, retval, "set streaming port", DEC);
|
||||
FILE_LOG(logDEBUG1) << "streaming port:" << retval;
|
||||
LOG(logDEBUG1) << "streaming port:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -926,7 +927,7 @@ int ClientInterface::set_streaming_source_ip(Interface &socket) {
|
||||
sls::IpAddr arg;
|
||||
socket.Receive(arg);
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting streaming source ip:" << arg;
|
||||
LOG(logDEBUG1) << "Setting streaming source ip:" << arg;
|
||||
impl()->setStreamingSourceIP(arg);
|
||||
sls::IpAddr retval = impl()->getStreamingSourceIP();
|
||||
if (retval != arg) {
|
||||
@@ -942,12 +943,12 @@ int ClientInterface::set_silent_mode(Interface &socket) {
|
||||
auto value = socket.Receive<int>();
|
||||
if (value >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting silent mode:" << value;
|
||||
LOG(logDEBUG1) << "Setting silent mode:" << value;
|
||||
impl()->setSilentMode(value);
|
||||
}
|
||||
auto retval = static_cast<int>(impl()->getSilentMode());
|
||||
validate(value, retval, "set silent mode", DEC);
|
||||
FILE_LOG(logDEBUG1) << "silent mode:" << retval;
|
||||
LOG(logDEBUG1) << "silent mode:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -958,7 +959,7 @@ int ClientInterface::enable_gap_pixels(Interface &socket) {
|
||||
|
||||
if (enable >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting gap pixels enable:" << enable;
|
||||
LOG(logDEBUG1) << "Setting gap pixels enable:" << enable;
|
||||
try {
|
||||
impl()->setGapPixelsEnable(static_cast<bool>(enable));
|
||||
} catch(const RuntimeError &e) {
|
||||
@@ -967,7 +968,7 @@ int ClientInterface::enable_gap_pixels(Interface &socket) {
|
||||
}
|
||||
auto retval = static_cast<int>(impl()->getGapPixelsEnable());
|
||||
validate(enable, retval, "set gap pixels enable", DEC);
|
||||
FILE_LOG(logDEBUG1) << "Gap Pixels Enable: " << retval;
|
||||
LOG(logDEBUG1) << "Gap Pixels Enable: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -977,7 +978,7 @@ int ClientInterface::restream_stop(Interface &socket) {
|
||||
throw RuntimeError(
|
||||
"Could not restream stop packet as data Streaming is disabled");
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1) << "Restreaming stop";
|
||||
LOG(logDEBUG1) << "Restreaming stop";
|
||||
impl()->restreamStop();
|
||||
}
|
||||
return socket.Send(OK);
|
||||
@@ -988,17 +989,17 @@ int ClientInterface::set_additional_json_header(Interface &socket) {
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
socket.Receive(arg);
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting additional json header: " << arg;
|
||||
LOG(logDEBUG1) << "Setting additional json header: " << arg;
|
||||
impl()->setAdditionalJsonHeader(arg);
|
||||
sls::strcpy_safe(retval, impl()->getAdditionalJsonHeader().c_str());
|
||||
FILE_LOG(logDEBUG1) << "additional json header:" << retval;
|
||||
LOG(logDEBUG1) << "additional json header:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::get_additional_json_header(Interface &socket) {
|
||||
char retval[MAX_STR_LENGTH]{};
|
||||
sls::strcpy_safe(retval, impl()->getAdditionalJsonHeader().c_str());
|
||||
FILE_LOG(logDEBUG1) << "additional json header:" << retval;
|
||||
LOG(logDEBUG1) << "additional json header:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -1006,7 +1007,7 @@ int ClientInterface::set_udp_socket_buffer_size(Interface &socket) {
|
||||
auto index = socket.Receive<int64_t>();
|
||||
if (index >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
|
||||
LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
|
||||
impl()->setUDPSocketBufferSize(index);
|
||||
}
|
||||
int64_t retval = impl()->getUDPSocketBufferSize();
|
||||
@@ -1014,14 +1015,14 @@ int ClientInterface::set_udp_socket_buffer_size(Interface &socket) {
|
||||
validate(index, retval,
|
||||
"set udp socket buffer size (No CAP_NET_ADMIN privileges?)",
|
||||
DEC);
|
||||
FILE_LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval;
|
||||
LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::get_real_udp_socket_buffer_size(
|
||||
Interface &socket) {
|
||||
auto size = impl()->getActualUDPSocketBufferSize();
|
||||
FILE_LOG(logDEBUG1) << "Actual UDP socket size :" << size;
|
||||
LOG(logDEBUG1) << "Actual UDP socket size :" << size;
|
||||
return socket.sendResult(size);
|
||||
}
|
||||
|
||||
@@ -1029,18 +1030,18 @@ int ClientInterface::set_frames_per_file(Interface &socket) {
|
||||
auto index = socket.Receive<int>();
|
||||
if (index >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting frames per file: " << index;
|
||||
LOG(logDEBUG1) << "Setting frames per file: " << index;
|
||||
impl()->setFramesPerFile(index);
|
||||
}
|
||||
auto retval = static_cast<int>(impl()->getFramesPerFile());
|
||||
validate(index, retval, "set frames per file", DEC);
|
||||
FILE_LOG(logDEBUG1) << "frames per file:" << retval;
|
||||
LOG(logDEBUG1) << "frames per file:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::check_version_compatibility(Interface &socket) {
|
||||
auto arg = socket.Receive<int64_t>();
|
||||
FILE_LOG(logDEBUG1) << "Checking versioning compatibility with value "
|
||||
LOG(logDEBUG1) << "Checking versioning compatibility with value "
|
||||
<< arg;
|
||||
int64_t client_requiredVersion = arg;
|
||||
int64_t rx_apiVersion = APIRECEIVER;
|
||||
@@ -1061,7 +1062,7 @@ int ClientInterface::check_version_compatibility(Interface &socket) {
|
||||
<< ").\n Please update the receiver";
|
||||
throw RuntimeError(os.str());
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Compatibility with Client: Successful";
|
||||
LOG(logINFO) << "Compatibility with Client: Successful";
|
||||
}
|
||||
return socket.Send(OK);
|
||||
}
|
||||
@@ -1070,12 +1071,12 @@ int ClientInterface::set_discard_policy(Interface &socket) {
|
||||
auto index = socket.Receive<int>();
|
||||
if (index >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting frames discard policy: " << index;
|
||||
LOG(logDEBUG1) << "Setting frames discard policy: " << index;
|
||||
impl()->setFrameDiscardPolicy(static_cast<frameDiscardPolicy>(index));
|
||||
}
|
||||
int retval = impl()->getFrameDiscardPolicy();
|
||||
validate(index, retval, "set discard policy", DEC);
|
||||
FILE_LOG(logDEBUG1) << "frame discard policy:" << retval;
|
||||
LOG(logDEBUG1) << "frame discard policy:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -1083,12 +1084,12 @@ int ClientInterface::set_padding_enable(Interface &socket) {
|
||||
auto index = socket.Receive<int>();
|
||||
if (index >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting frames padding enable: " << index;
|
||||
LOG(logDEBUG1) << "Setting frames padding enable: " << index;
|
||||
impl()->setFramePaddingEnable(static_cast<bool>(index));
|
||||
}
|
||||
auto retval = static_cast<int>(impl()->getFramePaddingEnable());
|
||||
validate(index, retval, "set frame padding enable", DEC);
|
||||
FILE_LOG(logDEBUG1) << "Frame Padding Enable:" << retval;
|
||||
LOG(logDEBUG1) << "Frame Padding Enable:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -1100,12 +1101,12 @@ int ClientInterface::set_deactivated_padding_enable(
|
||||
|
||||
if (enable >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting deactivated padding enable: " << enable;
|
||||
LOG(logDEBUG1) << "Setting deactivated padding enable: " << enable;
|
||||
impl()->setDeactivatedPadding(enable > 0);
|
||||
}
|
||||
auto retval = static_cast<int>(impl()->getDeactivatedPadding());
|
||||
validate(enable, retval, "set deactivated padding enable", DEC);
|
||||
FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval;
|
||||
LOG(logDEBUG1) << "Deactivated Padding Enable: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -1117,7 +1118,7 @@ int ClientInterface::set_readout_mode(Interface &socket) {
|
||||
|
||||
if (arg >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting readout mode: " << arg;
|
||||
LOG(logDEBUG1) << "Setting readout mode: " << arg;
|
||||
try {
|
||||
impl()->setReadoutMode(arg);
|
||||
} catch(const RuntimeError &e) {
|
||||
@@ -1127,14 +1128,14 @@ int ClientInterface::set_readout_mode(Interface &socket) {
|
||||
auto retval = impl()->getReadoutMode();
|
||||
validate(static_cast<int>(arg), static_cast<int>(retval),
|
||||
"set readout mode", DEC);
|
||||
FILE_LOG(logDEBUG1) << "Readout mode: " << retval;
|
||||
LOG(logDEBUG1) << "Readout mode: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::set_adc_mask(Interface &socket) {
|
||||
auto arg = socket.Receive<uint32_t>();
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting 1Gb ADC enable mask: " << arg;
|
||||
LOG(logDEBUG1) << "Setting 1Gb ADC enable mask: " << arg;
|
||||
try {
|
||||
impl()->setADCEnableMask(arg);
|
||||
} catch(const RuntimeError &e) {
|
||||
@@ -1147,18 +1148,18 @@ int ClientInterface::set_adc_mask(Interface &socket) {
|
||||
<< " but read 0x" << std::hex << retval;
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "1Gb ADC enable mask retval: " << retval;
|
||||
LOG(logDEBUG1) << "1Gb ADC enable mask retval: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::set_dbit_list(Interface &socket) {
|
||||
sls::FixedCapacityContainer<int, MAX_RX_DBIT> args;
|
||||
socket.Receive(args);
|
||||
FILE_LOG(logDEBUG1) << "Setting DBIT list";
|
||||
LOG(logDEBUG1) << "Setting DBIT list";
|
||||
for (auto &it : args) {
|
||||
FILE_LOG(logDEBUG1) << it << " ";
|
||||
LOG(logDEBUG1) << it << " ";
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "\n";
|
||||
LOG(logDEBUG1) << "\n";
|
||||
verifyIdle(socket);
|
||||
impl()->setDbitList(args);
|
||||
return socket.Send(OK);
|
||||
@@ -1167,7 +1168,7 @@ int ClientInterface::set_dbit_list(Interface &socket) {
|
||||
int ClientInterface::get_dbit_list(Interface &socket) {
|
||||
sls::FixedCapacityContainer<int, MAX_RX_DBIT> retval;
|
||||
retval = impl()->getDbitList();
|
||||
FILE_LOG(logDEBUG1) << "Dbit list size retval:" << retval.size();
|
||||
LOG(logDEBUG1) << "Dbit list size retval:" << retval.size();
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -1175,12 +1176,12 @@ int ClientInterface::set_dbit_offset(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
if (arg >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting Dbit offset: " << arg;
|
||||
LOG(logDEBUG1) << "Setting Dbit offset: " << arg;
|
||||
impl()->setDbitOffset(arg);
|
||||
}
|
||||
int retval = impl()->getDbitOffset();
|
||||
validate(arg, retval, "set dbit offset", DEC);
|
||||
FILE_LOG(logDEBUG1) << "Dbit offset retval: " << retval;
|
||||
LOG(logDEBUG1) << "Dbit offset retval: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -1188,7 +1189,7 @@ int ClientInterface::set_quad_type(Interface &socket) {
|
||||
auto quadEnable = socket.Receive<int>();
|
||||
if (quadEnable >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting quad:" << quadEnable;
|
||||
LOG(logDEBUG1) << "Setting quad:" << quadEnable;
|
||||
try {
|
||||
impl()->setQuad(quadEnable == 0 ? false : true);
|
||||
} catch(const RuntimeError &e) {
|
||||
@@ -1197,7 +1198,7 @@ int ClientInterface::set_quad_type(Interface &socket) {
|
||||
}
|
||||
int retval = impl()->getQuad() ? 1 : 0;
|
||||
validate(quadEnable, retval, "set quad", DEC);
|
||||
FILE_LOG(logDEBUG1) << "quad retval:" << retval;
|
||||
LOG(logDEBUG1) << "quad retval:" << retval;
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
@@ -1205,12 +1206,12 @@ int ClientInterface::set_read_n_lines(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
if (arg >= 0) {
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting Read N Lines:" << arg;
|
||||
LOG(logDEBUG1) << "Setting Read N Lines:" << arg;
|
||||
impl()->setReadNLines(arg);
|
||||
}
|
||||
int retval = impl()->getReadNLines();
|
||||
validate(arg, retval, "set read n lines", DEC);
|
||||
FILE_LOG(logDEBUG1) << "read n lines retval:" << retval;
|
||||
LOG(logDEBUG1) << "read n lines retval:" << retval;
|
||||
return socket.Send(OK);
|
||||
}
|
||||
|
||||
@@ -1218,7 +1219,7 @@ int ClientInterface::set_read_n_lines(Interface &socket) {
|
||||
int ClientInterface::set_udp_ip(Interface &socket) {
|
||||
auto arg = socket.Receive<sls::IpAddr>();
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logINFO) << "Received UDP IP: " << arg;
|
||||
LOG(logINFO) << "Received UDP IP: " << arg;
|
||||
// getting eth
|
||||
std::string eth = sls::IpToInterfaceName(arg.str());
|
||||
if (eth == "none") {
|
||||
@@ -1226,7 +1227,7 @@ int ClientInterface::set_udp_ip(Interface &socket) {
|
||||
}
|
||||
if (eth.find('.') != std::string::npos) {
|
||||
eth = "";
|
||||
FILE_LOG(logERROR) << "Failed to get udp ethernet interface from IP " << arg << ". Got " << eth;
|
||||
LOG(logERROR) << "Failed to get udp ethernet interface from IP " << arg << ". Got " << eth;
|
||||
}
|
||||
impl()->setEthernetInterface(eth);
|
||||
if (myDetectorType == EIGER) {
|
||||
@@ -1237,7 +1238,7 @@ int ClientInterface::set_udp_ip(Interface &socket) {
|
||||
if (retval == 0) {
|
||||
throw RuntimeError("Failed to get udp mac adddress to listen to\n");
|
||||
}
|
||||
FILE_LOG(logINFO) << "Receiver MAC Address: " << retval;
|
||||
LOG(logINFO) << "Receiver MAC Address: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
@@ -1248,7 +1249,7 @@ int ClientInterface::set_udp_ip2(Interface &socket) {
|
||||
if (myDetectorType != JUNGFRAU) {
|
||||
throw RuntimeError("UDP Destination IP2 not implemented for this detector");
|
||||
}
|
||||
FILE_LOG(logINFO) << "Received UDP IP2: " << arg;
|
||||
LOG(logINFO) << "Received UDP IP2: " << arg;
|
||||
// getting eth
|
||||
std::string eth = sls::IpToInterfaceName(arg.str());
|
||||
if (eth == "none") {
|
||||
@@ -1256,7 +1257,7 @@ int ClientInterface::set_udp_ip2(Interface &socket) {
|
||||
}
|
||||
if (eth.find('.') != std::string::npos) {
|
||||
eth = "";
|
||||
FILE_LOG(logERROR) << "Failed to get udp ethernet interface2 from IP " << arg << ". Got " << eth;
|
||||
LOG(logERROR) << "Failed to get udp ethernet interface2 from IP " << arg << ". Got " << eth;
|
||||
}
|
||||
impl()->setEthernetInterface2(eth);
|
||||
|
||||
@@ -1265,14 +1266,14 @@ int ClientInterface::set_udp_ip2(Interface &socket) {
|
||||
if (retval == 0) {
|
||||
throw RuntimeError("Failed to get udp mac adddress2 to listen to\n");
|
||||
}
|
||||
FILE_LOG(logINFO) << "Receiver MAC Address2: " << retval;
|
||||
LOG(logINFO) << "Receiver MAC Address2: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::set_udp_port(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting UDP Port:" << arg;
|
||||
LOG(logDEBUG1) << "Setting UDP Port:" << arg;
|
||||
impl()->setUDPPortNumber(arg);
|
||||
return socket.Send(OK);
|
||||
}
|
||||
@@ -1283,7 +1284,7 @@ int ClientInterface::set_udp_port2(Interface &socket) {
|
||||
if (myDetectorType != JUNGFRAU && myDetectorType != EIGER) {
|
||||
throw RuntimeError("UDP Destination Port2 not implemented for this detector");
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Setting UDP Port:" << arg;
|
||||
LOG(logDEBUG1) << "Setting UDP Port:" << arg;
|
||||
impl()->setUDPPortNumber2(arg);
|
||||
return socket.Send(OK);
|
||||
}
|
||||
@@ -1295,7 +1296,7 @@ int ClientInterface::set_num_interfaces(Interface &socket) {
|
||||
if (myDetectorType != JUNGFRAU) {
|
||||
throw RuntimeError("Number of interfaces not implemented for this detector");
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Setting Number of UDP Interfaces:" << arg;
|
||||
LOG(logDEBUG1) << "Setting Number of UDP Interfaces:" << arg;
|
||||
try {
|
||||
impl()->setNumberofUDPInterfaces(arg);
|
||||
} catch(const RuntimeError &e) {
|
||||
@@ -1307,7 +1308,7 @@ int ClientInterface::set_num_interfaces(Interface &socket) {
|
||||
int ClientInterface::set_adc_mask_10g(Interface &socket) {
|
||||
auto arg = socket.Receive<uint32_t>();
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting 10Gb ADC enable mask: " << arg;
|
||||
LOG(logDEBUG1) << "Setting 10Gb ADC enable mask: " << arg;
|
||||
try {
|
||||
impl()->setTenGigaADCEnableMask(arg);
|
||||
} catch(const RuntimeError &e) {
|
||||
@@ -1320,14 +1321,14 @@ int ClientInterface::set_adc_mask_10g(Interface &socket) {
|
||||
<< " but read 0x" << std::hex << retval;
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "10Gb ADC enable mask retval: " << retval;
|
||||
LOG(logDEBUG1) << "10Gb ADC enable mask retval: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::set_num_counters(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
verifyIdle(socket);
|
||||
FILE_LOG(logDEBUG1) << "Setting counters: " << arg;
|
||||
LOG(logDEBUG1) << "Setting counters: " << arg;
|
||||
impl()->setNumberofCounters(arg);
|
||||
return socket.Send(OK);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
||||
rawDataModifyReadyCallBack(nullptr),
|
||||
pRawDataReady(nullptr)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "DataProcessor " << ind << " created";
|
||||
LOG(logDEBUG) << "DataProcessor " << ind << " created";
|
||||
memset((void*)&timerBegin, 0, sizeof(timespec));
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
||||
startedFlag = true;
|
||||
firstIndex = fnum;
|
||||
|
||||
FILE_LOG(logDEBUG1) << index << " First Index:" << firstIndex;
|
||||
LOG(logDEBUG1) << index << " First Index:" << firstIndex;
|
||||
}
|
||||
|
||||
|
||||
@@ -232,12 +232,12 @@ void DataProcessor::EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
|
||||
void DataProcessor::ThreadExecution() {
|
||||
char* buffer=nullptr;
|
||||
fifo->PopAddress(buffer);
|
||||
FILE_LOG(logDEBUG5) << "DataProcessor " << index << ", "
|
||||
LOG(logDEBUG5) << "DataProcessor " << index << ", "
|
||||
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
|
||||
|
||||
//check dummy
|
||||
auto numBytes = (uint32_t)(*((uint32_t*)buffer));
|
||||
FILE_LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
|
||||
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
|
||||
if (numBytes == DUMMY_PACKET_VALUE) {
|
||||
StopProcessing(buffer);
|
||||
return;
|
||||
@@ -254,7 +254,7 @@ void DataProcessor::ThreadExecution() {
|
||||
|
||||
|
||||
void DataProcessor::StopProcessing(char* buf) {
|
||||
FILE_LOG(logDEBUG1) << "DataProcessing " << index << ": Dummy";
|
||||
LOG(logDEBUG1) << "DataProcessing " << index << ": Dummy";
|
||||
|
||||
//stream or free
|
||||
if (*dataStreamEnable)
|
||||
@@ -265,7 +265,7 @@ void DataProcessor::StopProcessing(char* buf) {
|
||||
if (file != nullptr)
|
||||
file->CloseCurrentFile();
|
||||
StopRunning();
|
||||
FILE_LOG(logDEBUG1) << index << ": Processing Completed";
|
||||
LOG(logDEBUG1) << index << ": Processing Completed";
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
numFramesCaught++;
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
|
||||
LOG(logDEBUG1) << "DataProcessing " << index << ": fnum:" << fnum;
|
||||
|
||||
if (!startedFlag) {
|
||||
RecordFirstIndex(fnum);
|
||||
@@ -367,7 +367,7 @@ bool DataProcessor::CheckTimer() {
|
||||
struct timespec end;
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
|
||||
FILE_LOG(logDEBUG1) << index << " Timer elapsed time:" <<
|
||||
LOG(logDEBUG1) << index << " Timer elapsed time:" <<
|
||||
(( end.tv_sec - timerBegin.tv_sec ) + ( end.tv_nsec - timerBegin.tv_nsec ) / 1000000000.0)
|
||||
<< " seconds";
|
||||
//still less than streaming timer, keep waiting
|
||||
@@ -412,7 +412,7 @@ void DataProcessor::registerCallBackRawDataModifyReady(void (*func)(char* ,
|
||||
}
|
||||
|
||||
void DataProcessor::PadMissingPackets(char* buf) {
|
||||
FILE_LOG(logDEBUG) << index << ": Padding Missing Packets";
|
||||
LOG(logDEBUG) << index << ": Padding Missing Packets";
|
||||
|
||||
uint32_t pperFrame = generalData->packetsPerFrame;
|
||||
auto* header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
|
||||
@@ -422,7 +422,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
|
||||
uint32_t dsize = generalData->dataSize;
|
||||
uint32_t fifohsize = generalData->fifoBufferHeaderSize;
|
||||
uint32_t corrected_dsize = dsize - ((pperFrame * dsize) - generalData->imageSize);
|
||||
FILE_LOG(logDEBUG1) << "bitmask: " << pmask.to_string();
|
||||
LOG(logDEBUG1) << "bitmask: " << pmask.to_string();
|
||||
|
||||
for (unsigned int pnum = 0; pnum < pperFrame; ++pnum) {
|
||||
|
||||
@@ -434,7 +434,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
|
||||
if (nmissing == 0u)
|
||||
break;
|
||||
|
||||
FILE_LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << std::endl;
|
||||
LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << std::endl;
|
||||
|
||||
// missing packet
|
||||
switch(myDetectorType) {
|
||||
@@ -468,7 +468,7 @@ void DataProcessor::RearrangeDbitData(char* buf) {
|
||||
|
||||
// no digital data
|
||||
if (ctbDigitalDataBytes == 0) {
|
||||
FILE_LOG(logWARNING) << "No digital data for call back, yet dbitlist is not empty.";
|
||||
LOG(logWARNING) << "No digital data for call back, yet dbitlist is not empty.";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
|
||||
numDet[0] = nd[0];
|
||||
numDet[1] = nd[1];
|
||||
|
||||
FILE_LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
||||
LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ void DataStreamer::RecordFirstIndex(uint64_t fnum) {
|
||||
startedFlag = true;
|
||||
firstIndex = fnum;
|
||||
|
||||
FILE_LOG(logDEBUG1) << index << " First Index: " << firstIndex;
|
||||
LOG(logDEBUG1) << index << " First Index: " << firstIndex;
|
||||
}
|
||||
|
||||
void DataStreamer::SetGeneralData(GeneralData* g) {
|
||||
@@ -114,10 +114,10 @@ void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const sls::IpAdd
|
||||
try {
|
||||
zmqSocket = new ZmqSocket(portnum, (ip != 0? sip.c_str(): nullptr));
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create Zmq socket on port " << portnum << " for Streamer " << index;
|
||||
LOG(logERROR) << "Could not create Zmq socket on port " << portnum << " for Streamer " << index;
|
||||
throw;
|
||||
}
|
||||
FILE_LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress();
|
||||
LOG(logINFO) << index << " Streamer: Zmq Server started at " << zmqSocket->GetZmqServerAddress();
|
||||
}
|
||||
|
||||
|
||||
@@ -132,13 +132,13 @@ void DataStreamer::CloseZmqSocket() {
|
||||
void DataStreamer::ThreadExecution() {
|
||||
char* buffer=nullptr;
|
||||
fifo->PopAddressToStream(buffer);
|
||||
FILE_LOG(logDEBUG5) << "DataStreamer " << index << ", "
|
||||
LOG(logDEBUG5) << "DataStreamer " << index << ", "
|
||||
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
|
||||
|
||||
|
||||
//check dummy
|
||||
uint32_t numBytes = (uint32_t)(*((uint32_t*)buffer));
|
||||
FILE_LOG(logDEBUG1) << "DataStreamer " << index << ", Numbytes:" << numBytes;
|
||||
LOG(logDEBUG1) << "DataStreamer " << index << ", Numbytes:" << numBytes;
|
||||
if (numBytes == DUMMY_PACKET_VALUE) {
|
||||
StopProcessing(buffer);
|
||||
return;
|
||||
@@ -154,17 +154,17 @@ void DataStreamer::ThreadExecution() {
|
||||
|
||||
|
||||
void DataStreamer::StopProcessing(char* buf) {
|
||||
FILE_LOG(logDEBUG1) << "DataStreamer " << index << ": Dummy";
|
||||
LOG(logDEBUG1) << "DataStreamer " << index << ": Dummy";
|
||||
|
||||
sls_receiver_header* header = (sls_receiver_header*) (buf);
|
||||
//send dummy header and data
|
||||
if (!SendHeader(header, 0, 0, 0, true)) {
|
||||
FILE_LOG(logERROR) << "Could not send zmq dummy header for streamer " << index;
|
||||
LOG(logERROR) << "Could not send zmq dummy header for streamer " << index;
|
||||
}
|
||||
|
||||
fifo->FreeAddress(buf);
|
||||
StopRunning();
|
||||
FILE_LOG(logDEBUG1) << index << ": Streaming Completed";
|
||||
LOG(logDEBUG1) << index << ": Streaming Completed";
|
||||
}
|
||||
|
||||
/** buf includes only the standard header */
|
||||
@@ -172,7 +172,7 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
|
||||
sls_receiver_header* header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
|
||||
uint64_t fnum = header->detHeader.frameNumber;
|
||||
FILE_LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
|
||||
LOG(logDEBUG1) << "DataStreamer " << index << ": fnum:" << fnum;
|
||||
|
||||
if (!startedFlag) {
|
||||
RecordFirstIndex(fnum);
|
||||
@@ -187,14 +187,14 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
|
||||
if (!SendHeader(header, generalData->imageSizeComplete,
|
||||
generalData->nPixelsXComplete, generalData->nPixelsYComplete, false)) {
|
||||
FILE_LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index;
|
||||
LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index;
|
||||
}
|
||||
memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured),
|
||||
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
|
||||
(uint32_t)(*((uint32_t*)buf)) );
|
||||
|
||||
if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete)) {
|
||||
FILE_LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index;
|
||||
LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,11 +204,11 @@ void DataStreamer::ProcessAnImage(char* buf) {
|
||||
|
||||
if (!SendHeader(header, (uint32_t)(*((uint32_t*)buf)),
|
||||
generalData->nPixelsX, generalData->nPixelsY, false)) {// new size possibly from callback
|
||||
FILE_LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index;
|
||||
LOG(logERROR) << "Could not send zmq header for fnum " << fnum << " and streamer " << index;
|
||||
}
|
||||
if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
|
||||
(uint32_t)(*((uint32_t*)buf)) )) {// new size possibly from callback
|
||||
FILE_LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index;
|
||||
LOG(logERROR) << "Could not send zmq data for fnum " << fnum << " and streamer " << index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
|
||||
index(ind),
|
||||
@@ -22,20 +22,20 @@ Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):
|
||||
fifoDepth(depth),
|
||||
status_fifoBound(0),
|
||||
status_fifoFree(depth){
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
CreateFifos(fifoItemSize);
|
||||
}
|
||||
|
||||
|
||||
Fifo::~Fifo() {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
DestroyFifos();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Fifo::CreateFifos(uint32_t fifoItemSize) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
|
||||
//destroy if not already
|
||||
DestroyFifos();
|
||||
@@ -55,7 +55,7 @@ void Fifo::CreateFifos(uint32_t fifoItemSize) {
|
||||
for (size_t i = 0; i < mem_len; i += pagesize) {
|
||||
strcpy(memory + i, "memory");
|
||||
}
|
||||
FILE_LOG(logDEBUG) << "Memory Allocated " << index << ": " << (double)mem_len/(double)(1024 * 1024) << " MB";
|
||||
LOG(logDEBUG) << "Memory Allocated " << index << ": " << (double)mem_len/(double)(1024 * 1024) << " MB";
|
||||
|
||||
{ //push free addresses into fifoFree fifo
|
||||
char* buffer = memory;
|
||||
@@ -65,12 +65,12 @@ void Fifo::CreateFifos(uint32_t fifoItemSize) {
|
||||
buffer += fifoItemSize;
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Fifo " << index << " reconstructed Depth (rx_fifodepth): " << fifoFree->getDataValue();
|
||||
LOG(logINFO) << "Fifo " << index << " reconstructed Depth (rx_fifodepth): " << fifoFree->getDataValue();
|
||||
}
|
||||
|
||||
|
||||
void Fifo::DestroyFifos(){
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
|
||||
if(memory) {
|
||||
free(memory);
|
||||
|
||||
@@ -43,7 +43,7 @@ void File::resetSubFileIndex(){
|
||||
}
|
||||
|
||||
void File::PrintMembers(TLogLevel level) {
|
||||
FILE_LOG(level) << "\nGeneral Writer Variables:" << std::endl
|
||||
LOG(level) << "\nGeneral Writer Variables:" << std::endl
|
||||
<< "Index: " << index << std::endl
|
||||
<< "Max Frames Per File: " << *maxFramesPerFile << std::endl
|
||||
<< "Number of Detectors in x dir: " << numDetX << std::endl
|
||||
|
||||
@@ -119,7 +119,7 @@ class File : private virtual slsDetectorDefs {
|
||||
* @param ny number of pixels in y direction
|
||||
*/
|
||||
virtual void SetNumberofPixels(uint32_t nx, uint32_t ny) {
|
||||
FILE_LOG(logERROR) << "This is a generic function SetNumberofPixels that "
|
||||
LOG(logERROR) << "This is a generic function SetNumberofPixels that "
|
||||
"should be overloaded by a derived class";
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class File : private virtual slsDetectorDefs {
|
||||
* @param numf number of images caught
|
||||
*/
|
||||
virtual void EndofAcquisition(bool anyPacketsCaught, uint64_t numf) {
|
||||
FILE_LOG(logERROR) << "This is a generic function EndofAcquisition that "
|
||||
LOG(logERROR) << "This is a generic function EndofAcquisition that "
|
||||
"should be overloaded by a derived class";
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
* @param i ROI
|
||||
*/
|
||||
virtual void SetROI(slsDetectorDefs::ROI i) {
|
||||
FILE_LOG(logERROR) << "SetROI is a generic function that should be overloaded by a derived class";
|
||||
LOG(logERROR) << "SetROI is a generic function that should be overloaded by a derived class";
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
* @returns adc configured
|
||||
*/
|
||||
virtual int GetAdcConfigured(int index, slsDetectorDefs::ROI i) const{
|
||||
FILE_LOG(logERROR) << "GetAdcConfigured is a generic function that should be overloaded by a derived class";
|
||||
LOG(logERROR) << "GetAdcConfigured is a generic function that should be overloaded by a derived class";
|
||||
return 0;
|
||||
};
|
||||
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
* @param tgEnable true if 10GbE is enabled, else false
|
||||
*/
|
||||
virtual void SetDynamicRange(int dr, bool tgEnable) {
|
||||
FILE_LOG(logERROR) << "SetDynamicRange is a generic function that should be overloaded by a derived class";
|
||||
LOG(logERROR) << "SetDynamicRange is a generic function that should be overloaded by a derived class";
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
* @param dr dynamic range
|
||||
*/
|
||||
virtual void SetTenGigaEnable(bool tgEnable, int dr) {
|
||||
FILE_LOG(logERROR) << "SetTenGigaEnable is a generic function that should be overloaded by a derived class";
|
||||
LOG(logERROR) << "SetTenGigaEnable is a generic function that should be overloaded by a derived class";
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
* @param q quad enable
|
||||
*/
|
||||
virtual void SetGapPixelsEnable(bool b, int dr, bool q) {
|
||||
FILE_LOG(logERROR) << "SetGapPixelsEnable is a generic function that should be overloaded by a derived class";
|
||||
LOG(logERROR) << "SetGapPixelsEnable is a generic function that should be overloaded by a derived class";
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
* @returns true or false for odd starting packet number
|
||||
*/
|
||||
virtual bool SetOddStartingPacket(int index, char* packetData) {
|
||||
FILE_LOG(logERROR) << "SetOddStartingPacket is a generic function that should be overloaded by a derived class";
|
||||
LOG(logERROR) << "SetOddStartingPacket is a generic function that should be overloaded by a derived class";
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -202,7 +202,7 @@ public:
|
||||
* @returns analog data bytes
|
||||
*/
|
||||
virtual int setImageSize(uint32_t a, uint32_t as, uint32_t ds, bool t, slsDetectorDefs::readoutMode) {
|
||||
FILE_LOG(logERROR) << "setImageSize is a generic function that should be overloaded by a derived class";
|
||||
LOG(logERROR) << "setImageSize is a generic function that should be overloaded by a derived class";
|
||||
return 0;
|
||||
};
|
||||
|
||||
@@ -211,7 +211,7 @@ public:
|
||||
* @param n number of interfaces
|
||||
*/
|
||||
virtual void SetNumberofInterfaces(const int n) {
|
||||
FILE_LOG(logERROR) << "SetNumberofInterfaces is a generic function that should be overloaded by a derived class";
|
||||
LOG(logERROR) << "SetNumberofInterfaces is a generic function that should be overloaded by a derived class";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,36 +220,36 @@ public:
|
||||
* @param dr dynamic range
|
||||
*/
|
||||
virtual void SetNumberofCounters(const int n, const int dr) {
|
||||
FILE_LOG(logERROR) << "SetNumberofCounters is a generic function that should be overloaded by a derived class";
|
||||
LOG(logERROR) << "SetNumberofCounters is a generic function that should be overloaded by a derived class";
|
||||
}
|
||||
|
||||
/**
|
||||
* Print all variables
|
||||
*/
|
||||
virtual void Print(TLogLevel level = logDEBUG1) const {
|
||||
FILE_LOG(level) << "\n\nDetector Data Variables:";
|
||||
FILE_LOG(level) << "myDetectorType: " << sls::ToString(myDetectorType);
|
||||
FILE_LOG(level) << "Pixels X: " << nPixelsX;
|
||||
FILE_LOG(level) << "Pixels Y: " << nPixelsY;
|
||||
FILE_LOG(level) << "Header Size in Packet: " << headerSizeinPacket;
|
||||
FILE_LOG(level) << "Data Size: " << dataSize;
|
||||
FILE_LOG(level) << "Packet Size: " << packetSize;
|
||||
FILE_LOG(level) << "Packets per Frame: " << packetsPerFrame;
|
||||
FILE_LOG(level) << "Image Size: " << imageSize;
|
||||
FILE_LOG(level) << "Frame Index Mask: " << frameIndexMask;
|
||||
FILE_LOG(level) << "Frame Index Offset: " << frameIndexOffset;
|
||||
FILE_LOG(level) << "Packet Index Mask: " << packetIndexMask;
|
||||
FILE_LOG(level) << "Packet Index Offset: " << packetIndexOffset;
|
||||
FILE_LOG(level) << "Max Frames Per File: " << maxFramesPerFile;
|
||||
FILE_LOG(level) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize;
|
||||
FILE_LOG(level) << "Default Fifo Depth: " << defaultFifoDepth;
|
||||
FILE_LOG(level) << "Threads Per Receiver: " << threadsPerReceiver;
|
||||
FILE_LOG(level) << "Header Packet Size: " << headerPacketSize;
|
||||
FILE_LOG(level) << "Complete Pixels X: " << nPixelsXComplete;
|
||||
FILE_LOG(level) << "Complete Pixels Y: " << nPixelsYComplete;
|
||||
FILE_LOG(level) << "Complete Image Size: " << imageSizeComplete;
|
||||
FILE_LOG(level) << "Standard Header: " << standardheader;
|
||||
FILE_LOG(level) << "UDP Socket Buffer Size: " << defaultUdpSocketBufferSize;
|
||||
LOG(level) << "\n\nDetector Data Variables:";
|
||||
LOG(level) << "myDetectorType: " << sls::ToString(myDetectorType);
|
||||
LOG(level) << "Pixels X: " << nPixelsX;
|
||||
LOG(level) << "Pixels Y: " << nPixelsY;
|
||||
LOG(level) << "Header Size in Packet: " << headerSizeinPacket;
|
||||
LOG(level) << "Data Size: " << dataSize;
|
||||
LOG(level) << "Packet Size: " << packetSize;
|
||||
LOG(level) << "Packets per Frame: " << packetsPerFrame;
|
||||
LOG(level) << "Image Size: " << imageSize;
|
||||
LOG(level) << "Frame Index Mask: " << frameIndexMask;
|
||||
LOG(level) << "Frame Index Offset: " << frameIndexOffset;
|
||||
LOG(level) << "Packet Index Mask: " << packetIndexMask;
|
||||
LOG(level) << "Packet Index Offset: " << packetIndexOffset;
|
||||
LOG(level) << "Max Frames Per File: " << maxFramesPerFile;
|
||||
LOG(level) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize;
|
||||
LOG(level) << "Default Fifo Depth: " << defaultFifoDepth;
|
||||
LOG(level) << "Threads Per Receiver: " << threadsPerReceiver;
|
||||
LOG(level) << "Header Packet Size: " << headerPacketSize;
|
||||
LOG(level) << "Complete Pixels X: " << nPixelsXComplete;
|
||||
LOG(level) << "Complete Pixels Y: " << nPixelsYComplete;
|
||||
LOG(level) << "Complete Image Size: " << imageSizeComplete;
|
||||
LOG(level) << "Standard Header: " << standardheader;
|
||||
LOG(level) << "UDP Socket Buffer Size: " << defaultUdpSocketBufferSize;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -362,12 +362,12 @@ private:
|
||||
adc = ((((i.xmax) + (i.xmin))/2)/
|
||||
(nChan * nChipsPerAdc));
|
||||
if((adc < 0) || (adc > 4)) {
|
||||
FILE_LOG(logWARNING) << index << ": Deleting ROI. "
|
||||
LOG(logWARNING) << index << ": Deleting ROI. "
|
||||
"Adc value should be between 0 and 4";
|
||||
adc = -1;
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Adc Configured: " << adc;
|
||||
LOG(logINFO) << "Adc Configured: " << adc;
|
||||
return adc;
|
||||
};
|
||||
|
||||
@@ -571,14 +571,14 @@ public:
|
||||
}
|
||||
ncounters = n;
|
||||
nPixelsX = NCHAN * ncounters;
|
||||
FILE_LOG(logINFO) << "nPixelsX: " << nPixelsX;
|
||||
LOG(logINFO) << "nPixelsX: " << nPixelsX;
|
||||
imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit
|
||||
((dr > 8) ? 2 : // 16 bit
|
||||
((dr > 4) ? 0.5 : // 4 bit
|
||||
0.125))); // 1 bit
|
||||
dataSize = imageSize / packetsPerFrame;
|
||||
packetSize = headerSizeinPacket + dataSize;
|
||||
FILE_LOG(logINFO) << "PacketSize: " << packetSize;
|
||||
LOG(logINFO) << "PacketSize: " << packetSize;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -593,7 +593,7 @@ public:
|
||||
0.125))); // 1 bit
|
||||
dataSize = imageSize / packetsPerFrame;
|
||||
packetSize = headerSizeinPacket + dataSize;
|
||||
FILE_LOG(logINFO) << "PacketSize: " << packetSize;
|
||||
LOG(logINFO) << "PacketSize: " << packetSize;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -677,7 +677,7 @@ public:
|
||||
}
|
||||
}
|
||||
adatabytes = nachans * NUM_BYTES_PER_ANALOG_CHANNEL * as;
|
||||
FILE_LOG(logDEBUG1) << " Number of Analog Channels:" << nachans
|
||||
LOG(logDEBUG1) << " Number of Analog Channels:" << nachans
|
||||
<< " Databytes: " << adatabytes;
|
||||
}
|
||||
// digital channels
|
||||
@@ -685,10 +685,10 @@ public:
|
||||
f == slsDetectorDefs::ANALOG_AND_DIGITAL) {
|
||||
ndchans = NCHAN_DIGITAL;
|
||||
ddatabytes = (sizeof(uint64_t) * ds);
|
||||
FILE_LOG(logDEBUG1) << "Number of Digital Channels:" << ndchans
|
||||
LOG(logDEBUG1) << "Number of Digital Channels:" << ndchans
|
||||
<< " Databytes: " << ddatabytes;
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Total Number of Channels:" << nachans + ndchans
|
||||
LOG(logDEBUG1) << "Total Number of Channels:" << nachans + ndchans
|
||||
<< " Databytes: " << adatabytes + ddatabytes;
|
||||
|
||||
nPixelsX = nachans + ndchans;
|
||||
@@ -761,7 +761,7 @@ public:
|
||||
nrows = 2;
|
||||
}
|
||||
nPixelsY = as / 25 * nrows;
|
||||
FILE_LOG(logINFO) << "Number of Pixels: [" << nPixelsX << ", " << nPixelsY << "]";
|
||||
LOG(logINFO) << "Number of Pixels: [" << nPixelsX << ", " << nPixelsY << "]";
|
||||
|
||||
|
||||
// 10G
|
||||
@@ -777,7 +777,7 @@ public:
|
||||
packetSize = headerSizeinPacket + dataSize;
|
||||
packetsPerFrame = ceil((double)imageSize / (double)dataSize);
|
||||
|
||||
FILE_LOG(logDEBUG) << "Databytes: " << imageSize;
|
||||
LOG(logDEBUG) << "Databytes: " << imageSize;
|
||||
|
||||
return imageSize;
|
||||
}
|
||||
|
||||
@@ -96,13 +96,13 @@ void HDF5File::PrintMembers(TLogLevel level) {
|
||||
File::PrintMembers();
|
||||
UpdateDataType();
|
||||
if (datatype == PredType::STD_U8LE) {
|
||||
FILE_LOG(level) << "Data Type: 4 or 8";
|
||||
LOG(level) << "Data Type: 4 or 8";
|
||||
} else if (datatype == PredType::STD_U16LE) {
|
||||
FILE_LOG(level) << "Data Type: 16";
|
||||
LOG(level) << "Data Type: 16";
|
||||
} else if (datatype == PredType::STD_U32LE) {
|
||||
FILE_LOG(level) << "Data Type: 32";
|
||||
LOG(level) << "Data Type: 32";
|
||||
} else {
|
||||
FILE_LOG(logERROR) << "unknown data type";
|
||||
LOG(logERROR) << "unknown data type";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ void HDF5File::CreateFile() {
|
||||
parameterNames, parameterDataTypes);
|
||||
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName;
|
||||
LOG(logINFO) << *udpPortNumber << ": HDF5 File created: " << currentFileName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ void HDF5File::WriteToFile(char* buffer, int buffersize, uint64_t fnum, uint32_t
|
||||
HDF5FileStatic::ExtendDataset(index, dataspace, dataset,
|
||||
dataspace_para, dataset_para, *numImages);
|
||||
if (!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << index << " Extending HDF5 dataset by " <<
|
||||
LOG(logINFO) << index << " Extending HDF5 dataset by " <<
|
||||
extNumImages << ", Total x Dimension: " << (extNumImages + *numImages);
|
||||
}
|
||||
extNumImages += *numImages;
|
||||
@@ -241,7 +241,7 @@ void HDF5File::CreateMasterFile(bool mfwenable, masterAttributes& attr) {
|
||||
masterFileName = HDF5FileStatic::CreateMasterFileName(*filePath,
|
||||
*fileNamePrefix, *fileIndex);
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "Master File: " << masterFileName;
|
||||
LOG(logINFO) << "Master File: " << masterFileName;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
attr.version = HDF5_WRITER_VERSION;
|
||||
@@ -277,7 +277,7 @@ void HDF5File::CreateVirtualFile(uint64_t numf) {
|
||||
|
||||
std::string vname = HDF5FileStatic::CreateVirtualFileName(*filePath, *fileNamePrefix, *fileIndex);
|
||||
if(!(*silentMode)) {
|
||||
FILE_LOG(logINFO) << "Virtual File: " << vname;
|
||||
LOG(logINFO) << "Virtual File: " << vname;
|
||||
}
|
||||
HDF5FileStatic::CreateVirtualDataFile(vname,
|
||||
virtualfd, masterFileName,
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
fd = 0;
|
||||
}
|
||||
} catch(const Exception& error) {
|
||||
FILE_LOG(logERROR) << "Could not close HDF5 handles of index " << ind;
|
||||
LOG(logERROR) << "Could not close HDF5 handles of index " << ind;
|
||||
error.printErrorStack();
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public:
|
||||
fd = 0;
|
||||
}
|
||||
} catch(const Exception& error) {
|
||||
FILE_LOG(logERROR) << "Could not close master HDF5 handles";
|
||||
LOG(logERROR) << "Could not close master HDF5 handles";
|
||||
error.printErrorStack();
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
{
|
||||
if(fd) {
|
||||
if (H5Fclose(fd) < 0 ) {
|
||||
FILE_LOG(logERROR) << "Could not close virtual HDF5 handles";
|
||||
LOG(logERROR) << "Could not close virtual HDF5 handles";
|
||||
}
|
||||
fd = 0;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
memspace.close();
|
||||
}
|
||||
catch(const Exception& error){
|
||||
FILE_LOG(logERROR) << "Could not write to file in object " << ind;
|
||||
LOG(logERROR) << "Could not write to file in object " << ind;
|
||||
error.printErrorStack();
|
||||
throw RuntimeError("Could not write to file in object " + std::to_string(ind));
|
||||
}
|
||||
@@ -659,7 +659,7 @@ public:
|
||||
std::string srcFileName = HDF5FileStatic::CreateFileName(fpath, fnameprefix, findex,
|
||||
j, dindex, numunits, i);
|
||||
|
||||
FILE_LOG(logERROR) << srcFileName;
|
||||
LOG(logERROR) << srcFileName;
|
||||
// find relative path
|
||||
std::string relative_srcFileName = srcFileName;
|
||||
{
|
||||
@@ -774,17 +774,17 @@ public:
|
||||
throw RuntimeError("Invalid rank. Options: 2 or 3");
|
||||
}
|
||||
if (datatype == PredType::STD_U16LE) {
|
||||
FILE_LOG(logINFO) << "datatype:16";
|
||||
LOG(logINFO) << "datatype:16";
|
||||
} else if (datatype == PredType::STD_U32LE) {
|
||||
FILE_LOG(logINFO) << "datatype:32";
|
||||
LOG(logINFO) << "datatype:32";
|
||||
} else if (datatype == PredType::STD_U64LE) {
|
||||
FILE_LOG(logINFO) << "datatype:64";
|
||||
LOG(logINFO) << "datatype:64";
|
||||
} else if (datatype == PredType::STD_U8LE) {
|
||||
FILE_LOG(logINFO) << "datatype:8";
|
||||
LOG(logINFO) << "datatype:8";
|
||||
} else {
|
||||
throw RuntimeError("Unknown datatype:" + std::to_string(datatype));
|
||||
}
|
||||
FILE_LOG(logINFO) << "owenable:" << (owenable?1:0) << std::endl
|
||||
LOG(logINFO) << "owenable:" << (owenable?1:0) << std::endl
|
||||
<< "oldFileName:" << oldFileName << std::endl
|
||||
<< "oldDatasetName:" << oldDatasetName << std::endl
|
||||
<< "newFileName:" << newFileName << std::endl
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -56,7 +56,7 @@ Listener::Listener(int ind, detectorType dtype, Fifo* f, std::atomic<runStatus>*
|
||||
numFramesStatistic(0),
|
||||
oddStartingPacket(true)
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Listener " << ind << " created";
|
||||
LOG(logDEBUG) << "Listener " << ind << " created";
|
||||
}
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ void Listener::RecordFirstIndex(uint64_t fnum) {
|
||||
|
||||
if(!(*silentMode)) {
|
||||
if (!index) {
|
||||
FILE_LOG(logINFOBLUE) << index <<
|
||||
LOG(logINFOBLUE) << index <<
|
||||
" First Index: " << firstIndex;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ void Listener::CreateUDPSockets() {
|
||||
(*eth) = "";
|
||||
}
|
||||
if (!(*eth).length()) {
|
||||
FILE_LOG(logWARNING) << "eth is empty. Listening to all";
|
||||
LOG(logWARNING) << "eth is empty. Listening to all";
|
||||
}
|
||||
|
||||
ShutDownUDPSocket();
|
||||
@@ -169,7 +169,7 @@ void Listener::CreateUDPSockets() {
|
||||
udpSocket = sls::make_unique<SELECTED_SOCKET>(*udpPortNumber, genericSocket::UDP,
|
||||
generalData->packetSize, ((*eth).length() ? (*eth).c_str() : nullptr), generalData->headerPacketSize,
|
||||
*udpSocketBufferSize);
|
||||
FILE_LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
||||
LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
||||
} catch (...) {
|
||||
throw sls::RuntimeError("Could not create UDP socket on port "+ std::to_string(*udpPortNumber));
|
||||
}
|
||||
@@ -187,7 +187,7 @@ void Listener::ShutDownUDPSocket() {
|
||||
if(udpSocket){
|
||||
udpSocketAlive = false;
|
||||
udpSocket->ShutDownSocket();
|
||||
FILE_LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber;
|
||||
LOG(logINFO) << "Shut down of UDP port " << *udpPortNumber;
|
||||
fflush(stdout);
|
||||
// wait only if the threads have started as it is the threads that
|
||||
//give a post to semaphore(at stopListening)
|
||||
@@ -199,7 +199,7 @@ void Listener::ShutDownUDPSocket() {
|
||||
|
||||
|
||||
void Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) {
|
||||
FILE_LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port " << *udpPortNumber;
|
||||
LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port " << *udpPortNumber;
|
||||
|
||||
if (!(*activated)) {
|
||||
*actualUDPSocketBufferSize = (s*2);
|
||||
@@ -243,12 +243,12 @@ void Listener::ThreadExecution() {
|
||||
int rc = 0;
|
||||
|
||||
fifo->GetNewAddress(buffer);
|
||||
FILE_LOG(logDEBUG5) << "Listener " << index << ", "
|
||||
LOG(logDEBUG5) << "Listener " << index << ", "
|
||||
"pop 0x" << std::hex << (void*)(buffer) << std::dec << ":" << buffer;
|
||||
|
||||
//udpsocket doesnt exist
|
||||
if (*activated && !udpSocketAlive && !carryOverFlag) {
|
||||
//FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
|
||||
//LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
|
||||
(*((uint32_t*)buffer)) = 0;
|
||||
StopListening(buffer);
|
||||
return;
|
||||
@@ -272,7 +272,7 @@ void Listener::ThreadExecution() {
|
||||
|
||||
// discarding image
|
||||
else if (rc < 0) {
|
||||
FILE_LOG(logDEBUG) << index << " discarding fnum:" << currentFrameIndex;
|
||||
LOG(logDEBUG) << index << " discarding fnum:" << currentFrameIndex;
|
||||
fifo->FreeAddress(buffer);
|
||||
currentFrameIndex++;
|
||||
return;
|
||||
@@ -303,8 +303,8 @@ void Listener::StopListening(char* buf) {
|
||||
StopRunning();
|
||||
|
||||
sem_post(&semaphore_socket);
|
||||
FILE_LOG(logDEBUG1) << index << ": Listening Packets (" << *udpPortNumber << ") : " << numPacketsCaught;
|
||||
FILE_LOG(logDEBUG1) << index << ": Listening Completed";
|
||||
LOG(logDEBUG1) << index << ": Listening Packets (" << *udpPortNumber << ") : " << numPacketsCaught;
|
||||
LOG(logDEBUG1) << index << ": Listening Completed";
|
||||
}
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
|
||||
//look for carry over
|
||||
if (carryOverFlag) {
|
||||
FILE_LOG(logDEBUG3) << index << "carry flag";
|
||||
LOG(logDEBUG3) << index << "carry flag";
|
||||
//check if its the current image packet
|
||||
// -------------------------- new header ----------------------------------------------------------------------
|
||||
if (standardheader) {
|
||||
@@ -371,7 +371,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
if (fnum != currentFrameIndex) {
|
||||
if (fnum < currentFrameIndex) {
|
||||
FILE_LOG(logERROR) << "(Weird), With carry flag: Frame number " <<
|
||||
LOG(logERROR) << "(Weird), With carry flag: Frame number " <<
|
||||
fnum << " less than current frame number " << currentFrameIndex;
|
||||
carryOverFlag = false;
|
||||
return 0;
|
||||
@@ -492,7 +492,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
|
||||
// Eiger Firmware in a weird state
|
||||
if (myDetectorType == EIGER && fnum == 0) {
|
||||
FILE_LOG(logERROR) << "[" << *udpPortNumber << "]: Got Frame Number "
|
||||
LOG(logERROR) << "[" << *udpPortNumber << "]: Got Frame Number "
|
||||
"Zero from Firmware. Discarding Packet";
|
||||
numPacketsCaught--;
|
||||
return 0;
|
||||
@@ -500,14 +500,14 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
|
||||
lastCaughtFrameIndex = fnum;
|
||||
|
||||
FILE_LOG(logDEBUG5) << "Listening " << index << ": currentfindex:" << currentFrameIndex <<
|
||||
LOG(logDEBUG5) << "Listening " << index << ": currentfindex:" << currentFrameIndex <<
|
||||
", fnum:" << fnum << ", pnum:" << pnum << ", numpackets:" << numpackets;
|
||||
|
||||
if (!startedFlag)
|
||||
RecordFirstIndex(fnum);
|
||||
|
||||
if (pnum >= pperFrame ) {
|
||||
FILE_LOG(logERROR) << "Bad packet " << pnum <<
|
||||
LOG(logERROR) << "Bad packet " << pnum <<
|
||||
"(fnum: " << fnum << "), throwing away. "
|
||||
"Packets caught so far: " << numpackets;
|
||||
return 0; // bad packet
|
||||
@@ -587,7 +587,7 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
|
||||
|
||||
void Listener::PrintFifoStatistics() {
|
||||
FILE_LOG(logDEBUG1) << "numFramesStatistic:" << numFramesStatistic << " numPacketsStatistic:" << numPacketsStatistic;
|
||||
LOG(logDEBUG1) << "numFramesStatistic:" << numFramesStatistic << " numPacketsStatistic:" << numPacketsStatistic;
|
||||
|
||||
//calculate packet loss
|
||||
int64_t loss = (numFramesStatistic*(generalData->packetsPerFrame)) - numPacketsStatistic;
|
||||
@@ -595,7 +595,7 @@ void Listener::PrintFifoStatistics() {
|
||||
numFramesStatistic = 0;
|
||||
|
||||
const auto color = loss ? logINFORED : logINFOGREEN;
|
||||
FILE_LOG(color) << "[" << *udpPortNumber << "]: "
|
||||
LOG(color) << "[" << *udpPortNumber << "]: "
|
||||
"Packet_Loss:" << loss <<
|
||||
" Used_Fifo_Max_Level:" << fifo->GetMaxLevelForFifoBound() <<
|
||||
" \tFree_Slots_Min_Level:" << fifo->GetMinLevelForFifoFree() <<
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <sys/wait.h> //wait
|
||||
#include <syscall.h> //tid
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
/** Define Colors to print data call back in different colors for different recievers */
|
||||
@@ -45,7 +46,7 @@ void printHelp() {
|
||||
* \returns ignored
|
||||
*/
|
||||
int StartAcq(std::string filepath, std::string filename, uint64_t fileindex, uint32_t datasize, void*p){
|
||||
FILE_LOG(logINFOBLUE) << "#### StartAcq: filepath:" << filepath << " filename:" << filename << " fileindex:" << fileindex << " datasize:" << datasize << " ####";
|
||||
LOG(logINFOBLUE) << "#### StartAcq: filepath:" << filepath << " filename:" << filename << " fileindex:" << fileindex << " datasize:" << datasize << " ####";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ int StartAcq(std::string filepath, std::string filename, uint64_t fileindex, uin
|
||||
* @param p pointer to object
|
||||
*/
|
||||
void AcquisitionFinished(uint64_t frames, void*p){
|
||||
FILE_LOG(logINFOBLUE) << "#### AcquisitionFinished: frames:" << frames << " ####";
|
||||
LOG(logINFOBLUE) << "#### AcquisitionFinished: frames:" << frames << " ####";
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +195,7 @@ int main(int argc, char *argv[]) {
|
||||
try {
|
||||
receiver = sls::make_unique<Receiver>(startTCPPort + i);
|
||||
} catch (...) {
|
||||
FILE_LOG(logINFOBLUE) << "Exiting Child Process [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFOBLUE) << "Exiting Child Process [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
throw;
|
||||
}
|
||||
/** - register callbacks. remember to set file write enable to 0 (using the client)
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <syscall.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
Receiver::~Receiver() = default;
|
||||
|
||||
@@ -63,7 +64,7 @@ Receiver::Receiver(int argc, char *argv[]):
|
||||
|
||||
case 'v':
|
||||
std::cout << "SLS Receiver Version: " << GITBRANCH << " (0x" << std::hex << APIRECEIVER << ")" << std::endl;
|
||||
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
case 'h':
|
||||
@@ -84,7 +85,7 @@ Receiver::Receiver(int argc, char *argv[]):
|
||||
// set effective id if provided
|
||||
if (userid != static_cast<uid_t>(-1)) {
|
||||
if (geteuid() == userid) {
|
||||
FILE_LOG(logINFO) << "Process already has the same Effective UID " << userid;
|
||||
LOG(logINFO) << "Process already has the same Effective UID " << userid;
|
||||
} else {
|
||||
if (seteuid(userid) != 0) {
|
||||
std::ostringstream oss;
|
||||
@@ -96,7 +97,7 @@ Receiver::Receiver(int argc, char *argv[]):
|
||||
oss << "Could not set Effective UID to " << userid << ". Got " << geteuid();
|
||||
throw sls::RuntimeError(oss.str());
|
||||
}
|
||||
FILE_LOG(logINFO) << "Process Effective UID changed to " << userid;
|
||||
LOG(logINFO) << "Process Effective UID changed to " << userid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
#include "container_utils.h"
|
||||
|
||||
#include <csignal> //SIGINT
|
||||
#include <syscall.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
sem_t semaphore;
|
||||
@@ -19,7 +20,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
sem_init(&semaphore,1,0);
|
||||
|
||||
FILE_LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
|
||||
// Catch signal SIGINT to close files and call destructors properly
|
||||
struct sigaction sa;
|
||||
@@ -27,7 +28,7 @@ int main(int argc, char *argv[]) {
|
||||
sa.sa_handler=sigInterruptHandler; // handler function
|
||||
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation of handler
|
||||
if (sigaction(SIGINT, &sa, nullptr) == -1) {
|
||||
FILE_LOG(logERROR) << "Could not set handler function for SIGINT";
|
||||
LOG(logERROR) << "Could not set handler function for SIGINT";
|
||||
}
|
||||
|
||||
|
||||
@@ -38,22 +39,22 @@ int main(int argc, char *argv[]) {
|
||||
asa.sa_handler=SIG_IGN; // handler function
|
||||
sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler
|
||||
if (sigaction(SIGPIPE, &asa, nullptr) == -1) {
|
||||
FILE_LOG(logERROR) << "Could not set handler function for SIGPIPE";
|
||||
LOG(logERROR) << "Could not set handler function for SIGPIPE";
|
||||
}
|
||||
|
||||
std::unique_ptr<Receiver> receiver = nullptr;
|
||||
try {
|
||||
receiver = sls::make_unique<Receiver>(argc, argv);
|
||||
} catch (...) {
|
||||
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
throw;
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
||||
LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
||||
sem_wait(&semaphore);
|
||||
sem_destroy(&semaphore);
|
||||
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
FILE_LOG(logINFO) << "Exiting Receiver";
|
||||
LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
LOG(logINFO) << "Exiting Receiver";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
|
||||
#include "ThreadObject.h"
|
||||
#include "container_utils.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <syscall.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
ThreadObject::ThreadObject(int threadIndex, std::string threadType)
|
||||
: index(threadIndex), type(threadType) {
|
||||
FILE_LOG(logDEBUG) << type << " thread created: " << index;
|
||||
LOG(logDEBUG) << type << " thread created: " << index;
|
||||
|
||||
sem_init(&semaphore,1,0);
|
||||
|
||||
@@ -38,8 +38,8 @@ ThreadObject::~ThreadObject() {
|
||||
|
||||
|
||||
void ThreadObject::RunningThread() {
|
||||
FILE_LOG(logINFOBLUE) << "Created [ " << type << "Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]";
|
||||
FILE_LOG(logDEBUG) << type << " thread " << index << " created successfully.";
|
||||
LOG(logINFOBLUE) << "Created [ " << type << "Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]";
|
||||
LOG(logDEBUG) << type << " thread " << index << " created successfully.";
|
||||
|
||||
while(true) {
|
||||
while(IsRunning()) {
|
||||
@@ -52,8 +52,8 @@ void ThreadObject::RunningThread() {
|
||||
}
|
||||
}
|
||||
|
||||
FILE_LOG(logDEBUG) << type << " thread with index " << index << " destroyed successfully.";
|
||||
FILE_LOG(logINFOBLUE) << "Exiting [ " << type << " Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]";
|
||||
LOG(logDEBUG) << type << " thread with index " << index << " destroyed successfully.";
|
||||
LOG(logINFOBLUE) << "Exiting [ " << type << " Thread " << index << ", Tid: " << syscall(SYS_gettid) << "]";
|
||||
}
|
||||
|
||||
|
||||
@@ -67,10 +67,10 @@ void ThreadObject::SetThreadPriority(int priority) {
|
||||
param.sched_priority = priority;
|
||||
if (pthread_setschedparam(threadObject->native_handle(), SCHED_FIFO, ¶m) == EPERM) {
|
||||
if (index == 0) {
|
||||
FILE_LOG(logWARNING) << "Could not prioritize " << type << " thread. "
|
||||
LOG(logWARNING) << "Could not prioritize " << type << " thread. "
|
||||
"(No Root Privileges?)";
|
||||
}
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Priorities set - " << type << ": " << priority;
|
||||
LOG(logINFO) << "Priorities set - " << type << ": " << priority;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class UdpRxSocket {
|
||||
if (current < buffer_size) {
|
||||
setBufferSize(buffer_size);
|
||||
if (getBufferSize() / 2 < buffer_size) {
|
||||
FILE_LOG(logWARNING)
|
||||
LOG(logWARNING)
|
||||
<< "Could not set buffer size. Got: "
|
||||
<< getBufferSize() / 2 << " instead of " << buffer_size;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ class UdpRxSocket {
|
||||
constexpr ssize_t eiger_header_packet =
|
||||
40; // only detector that has this
|
||||
if (r == eiger_header_packet) {
|
||||
FILE_LOG(logWARNING) << "Got header pkg";
|
||||
LOG(logWARNING) << "Got header pkg";
|
||||
r = recvfrom(fd, dst, packet_size, 0, nullptr, nullptr);
|
||||
}
|
||||
return r;
|
||||
|
||||
@@ -204,17 +204,17 @@ public:
|
||||
// get host info into res
|
||||
int errcode = getaddrinfo (hostname, NULL, &hints, res);
|
||||
if (errcode != 0) {
|
||||
FILE_LOG(logERROR) << "Error: Could not convert hostname " << hostname << " to internet address (zmq):"
|
||||
LOG(logERROR) << "Error: Could not convert hostname " << hostname << " to internet address (zmq):"
|
||||
<< gai_strerror(errcode);
|
||||
} else {
|
||||
if (*res == NULL) {
|
||||
FILE_LOG(logERROR) << "Could not convert hostname " << hostname << " to internet address (zmq): "
|
||||
LOG(logERROR) << "Could not convert hostname " << hostname << " to internet address (zmq): "
|
||||
"gettaddrinfo returned null";
|
||||
} else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
FILE_LOG(logERROR) << "Could not convert hostname to internet address";
|
||||
LOG(logERROR) << "Could not convert hostname to internet address";
|
||||
return 1;
|
||||
};
|
||||
|
||||
@@ -232,7 +232,7 @@ public:
|
||||
freeaddrinfo(res);
|
||||
return 0;
|
||||
}
|
||||
FILE_LOG(logERROR) << "Could not convert internet address to ip string";
|
||||
LOG(logERROR) << "Could not convert internet address to ip string";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ public:
|
||||
int length = zmq_msg_recv (&message, sockfd.socketDescriptor, 0);
|
||||
if (length == -1) {
|
||||
PrintError ();
|
||||
FILE_LOG(logERROR) << "Could not read header for socket " << index;
|
||||
LOG(logERROR) << "Could not read header for socket " << index;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
else
|
||||
@@ -449,7 +449,7 @@ public:
|
||||
Document& document, bool& dummy, uint32_t version)
|
||||
{
|
||||
if ( document.Parse( buff, length).HasParseError() ) {
|
||||
FILE_LOG(logERROR) << index << " Could not parse. len:" << length << ": Message:" << buff;
|
||||
LOG(logERROR) << index << " Could not parse. len:" << length << ": Message:" << buff;
|
||||
fflush ( stdout );
|
||||
// char* buf = (char*) zmq_msg_data (&message);
|
||||
for ( int i= 0; i < length; ++i ) {
|
||||
@@ -461,7 +461,7 @@ public:
|
||||
}
|
||||
|
||||
if (document["jsonversion"].GetUint() != version) {
|
||||
FILE_LOG(logERROR) << "version mismatch. required " << version << ", got " << document["jsonversion"].GetUint();
|
||||
LOG(logERROR) << "version mismatch. required " << version << ", got " << document["jsonversion"].GetUint();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ public:
|
||||
}
|
||||
//incorrect size (larger)
|
||||
else {
|
||||
FILE_LOG(logERROR) << "Received weird packet size " << length << " for socket " << index;
|
||||
LOG(logERROR) << "Received weird packet size " << length << " for socket " << index;
|
||||
memset(buf,0xFF,size);
|
||||
}
|
||||
|
||||
@@ -520,52 +520,52 @@ public:
|
||||
void PrintError () {
|
||||
switch (errno) {
|
||||
case EINVAL:
|
||||
FILE_LOG(logERROR) << "The socket type/option or value/endpoint supplied is invalid (zmq)";
|
||||
LOG(logERROR) << "The socket type/option or value/endpoint supplied is invalid (zmq)";
|
||||
break;
|
||||
case EAGAIN:
|
||||
FILE_LOG(logERROR) << "Non-blocking mode was requested and the message cannot be sent/available at the moment (zmq)";
|
||||
LOG(logERROR) << "Non-blocking mode was requested and the message cannot be sent/available at the moment (zmq)";
|
||||
break;
|
||||
case ENOTSUP:
|
||||
FILE_LOG(logERROR) << "The zmq_send()/zmq_msg_recv() operation is not supported by this socket type (zmq)";
|
||||
LOG(logERROR) << "The zmq_send()/zmq_msg_recv() operation is not supported by this socket type (zmq)";
|
||||
break;
|
||||
case EFSM:
|
||||
FILE_LOG(logERROR) << "The zmq_send()/zmq_msg_recv() unavailable now as socket in inappropriate state (eg. ZMQ_REP). Look up messaging patterns (zmq)";
|
||||
LOG(logERROR) << "The zmq_send()/zmq_msg_recv() unavailable now as socket in inappropriate state (eg. ZMQ_REP). Look up messaging patterns (zmq)";
|
||||
break;
|
||||
case EFAULT:
|
||||
FILE_LOG(logERROR) << "The provided context/message is invalid (zmq)";
|
||||
LOG(logERROR) << "The provided context/message is invalid (zmq)";
|
||||
break;
|
||||
case EMFILE:
|
||||
FILE_LOG(logERROR) << "The limit on the total number of open ØMQ sockets has been reached (zmq)";
|
||||
LOG(logERROR) << "The limit on the total number of open ØMQ sockets has been reached (zmq)";
|
||||
break;
|
||||
case EPROTONOSUPPORT:
|
||||
FILE_LOG(logERROR) << "The requested transport protocol is not supported (zmq)";
|
||||
LOG(logERROR) << "The requested transport protocol is not supported (zmq)";
|
||||
break;
|
||||
case ENOCOMPATPROTO:
|
||||
FILE_LOG(logERROR) << "The requested transport protocol is not compatible with the socket type (zmq)";
|
||||
LOG(logERROR) << "The requested transport protocol is not compatible with the socket type (zmq)";
|
||||
break;
|
||||
case EADDRINUSE:
|
||||
FILE_LOG(logERROR) << "The requested address is already in use (zmq)";
|
||||
LOG(logERROR) << "The requested address is already in use (zmq)";
|
||||
break;
|
||||
case EADDRNOTAVAIL:
|
||||
FILE_LOG(logERROR) << "The requested address was not local (zmq)";
|
||||
LOG(logERROR) << "The requested address was not local (zmq)";
|
||||
break;
|
||||
case ENODEV:
|
||||
FILE_LOG(logERROR) << "The requested address specifies a nonexistent interface (zmq)";
|
||||
LOG(logERROR) << "The requested address specifies a nonexistent interface (zmq)";
|
||||
break;
|
||||
case ETERM:
|
||||
FILE_LOG(logERROR) << "The ØMQ context associated with the specified socket was terminated (zmq)";
|
||||
LOG(logERROR) << "The ØMQ context associated with the specified socket was terminated (zmq)";
|
||||
break;
|
||||
case ENOTSOCK:
|
||||
FILE_LOG(logERROR) << "The provided socket was invalid (zmq)";
|
||||
LOG(logERROR) << "The provided socket was invalid (zmq)";
|
||||
break;
|
||||
case EINTR:
|
||||
FILE_LOG(logERROR) << "The operation was interrupted by delivery of a signal (zmq)";
|
||||
LOG(logERROR) << "The operation was interrupted by delivery of a signal (zmq)";
|
||||
break;
|
||||
case EMTHREAD:
|
||||
FILE_LOG(logERROR) << "No I/O thread is available to accomplish the task (zmq)";
|
||||
LOG(logERROR) << "No I/O thread is available to accomplish the task (zmq)";
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR) << "Unknown socket error (zmq)";
|
||||
LOG(logERROR) << "Unknown socket error (zmq)";
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
sockfd.fd = socket(AF_INET, getProtocol(),0); //tcp
|
||||
|
||||
if (sockfd.fd < 0) {
|
||||
FILE_LOG(logERROR) << "Can not create socket";
|
||||
LOG(logERROR) << "Can not create socket";
|
||||
sockfd.fd =-1;
|
||||
throw SocketError("Can not create socket");
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
int val=1;
|
||||
if (setsockopt(sockfd.fd,SOL_SOCKET,SO_REUSEADDR,
|
||||
&val,sizeof(int)) == -1) {
|
||||
FILE_LOG(logERROR) << "setsockopt REUSEADDR failed";
|
||||
LOG(logERROR) << "setsockopt REUSEADDR failed";
|
||||
sockfd.fd =-1;
|
||||
throw SocketError("setsockopt REUSEADDR failed");
|
||||
}
|
||||
@@ -188,33 +188,33 @@ public:
|
||||
|
||||
// confirm if sufficient
|
||||
if (getsockopt(sockfd.fd, SOL_SOCKET, SO_RCVBUF, &ret_size, &optlen) == -1) {
|
||||
FILE_LOG(logWARNING) << "[Port " << port_number << "] "
|
||||
LOG(logWARNING) << "[Port " << port_number << "] "
|
||||
"Could not get rx socket receive buffer size";
|
||||
} else if (ret_size >= real_size) {
|
||||
actual_udp_socket_buffer_size = ret_size;
|
||||
FILE_LOG(logINFO) << "[Port " << port_number << "] "
|
||||
LOG(logINFO) << "[Port " << port_number << "] "
|
||||
"UDP rx socket real buffer size is sufficient (" << ret_size << ")";
|
||||
}
|
||||
|
||||
// not sufficient, enhance size
|
||||
else {
|
||||
FILE_LOG(logINFO) << "[Port " << port_number << "] UDP rx socket real buffer size to be modified from " << ret_size << " to " << real_size;
|
||||
LOG(logINFO) << "[Port " << port_number << "] UDP rx socket real buffer size to be modified from " << ret_size << " to " << real_size;
|
||||
// set buffer size (could not set)
|
||||
if (setsockopt(sockfd.fd, SOL_SOCKET, SO_RCVBUF,
|
||||
&desired_size, optlen) == -1) {
|
||||
FILE_LOG(logWARNING) << "[Port " << port_number << "] "
|
||||
LOG(logWARNING) << "[Port " << port_number << "] "
|
||||
"Could not set rx socket buffer size to "
|
||||
<< desired_size << ". (No Root Privileges?)";
|
||||
}
|
||||
// confirm size
|
||||
else if (getsockopt(sockfd.fd, SOL_SOCKET, SO_RCVBUF,
|
||||
&ret_size, &optlen) == -1) {
|
||||
FILE_LOG(logWARNING) << "[Port " << port_number << "] "
|
||||
LOG(logWARNING) << "[Port " << port_number << "] "
|
||||
"Could not get rx socket buffer size";
|
||||
}
|
||||
else if (ret_size >= real_size) {
|
||||
actual_udp_socket_buffer_size = ret_size;
|
||||
FILE_LOG(logINFO) << "[Port " << port_number << "] "
|
||||
LOG(logINFO) << "[Port " << port_number << "] "
|
||||
"UDP rx socket buffer size modified to " << ret_size;
|
||||
}
|
||||
// buffer size too large
|
||||
@@ -227,14 +227,14 @@ public:
|
||||
getsockopt(sockfd.fd, SOL_SOCKET, SO_RCVBUF,
|
||||
&ret_size, &optlen);
|
||||
if (ret == -1) {
|
||||
FILE_LOG(logWARNING) << "[Port " << port_number << "] "
|
||||
LOG(logWARNING) << "[Port " << port_number << "] "
|
||||
"Could not force rx socket buffer size to "
|
||||
<< desired_size << ".\n Real size: " << ret_size <<
|
||||
". (No Root Privileges?)\n"
|
||||
" To remove this warning: set rx_udpsocksize from client to <= " <<
|
||||
(ret_size/2) << " (Real size:" << ret_size << ").";
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "[Port " << port_number << "] "
|
||||
LOG(logINFO) << "[Port " << port_number << "] "
|
||||
"UDP rx socket buffer size (force) modified to " << ret_size;
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public:
|
||||
|
||||
|
||||
if(bind(sockfd.fd,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
||||
FILE_LOG(logERROR) << "Can not bind socket. Please check if another process is running.";
|
||||
LOG(logERROR) << "Can not bind socket. Please check if another process is running.";
|
||||
sockfd.fd =-1;
|
||||
throw SocketError("Can not bind socket. Please check if another process is running.");
|
||||
}
|
||||
@@ -312,7 +312,7 @@ public:
|
||||
case UDP:
|
||||
return SOCK_DGRAM;
|
||||
default:
|
||||
FILE_LOG(logERROR) << "unknown protocol: " << p;
|
||||
LOG(logERROR) << "unknown protocol: " << p;
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
@@ -364,70 +364,70 @@ public:
|
||||
if(is_a_server && protocol==TCP){ //server tcp; the server will wait for the clients connection
|
||||
if (sockfd.fd>0) {
|
||||
if ((sockfd.newfd = accept(sockfd.fd,(struct sockaddr *) &clientAddress, &clientAddress_length)) < 0) {
|
||||
FILE_LOG(logERROR) << "with server accept, connection refused";
|
||||
LOG(logERROR) << "with server accept, connection refused";
|
||||
switch(errno) {
|
||||
case EWOULDBLOCK:
|
||||
FILE_LOG(logERROR) << "ewouldblock eagain";
|
||||
LOG(logERROR) << "ewouldblock eagain";
|
||||
break;
|
||||
case EBADF:
|
||||
FILE_LOG(logERROR) << "ebadf";
|
||||
LOG(logERROR) << "ebadf";
|
||||
break;
|
||||
case ECONNABORTED:
|
||||
FILE_LOG(logERROR) << "econnaborted";
|
||||
LOG(logERROR) << "econnaborted";
|
||||
break;
|
||||
case EFAULT:
|
||||
FILE_LOG(logERROR) << "efault";
|
||||
LOG(logERROR) << "efault";
|
||||
break;
|
||||
case EINTR:
|
||||
FILE_LOG(logERROR) << "eintr";
|
||||
LOG(logERROR) << "eintr";
|
||||
break;
|
||||
case EINVAL:
|
||||
FILE_LOG(logERROR) << "einval";
|
||||
LOG(logERROR) << "einval";
|
||||
break;
|
||||
case EMFILE:
|
||||
FILE_LOG(logERROR) << "emfile";
|
||||
LOG(logERROR) << "emfile";
|
||||
break;
|
||||
case ENFILE:
|
||||
FILE_LOG(logERROR) << "enfile";
|
||||
LOG(logERROR) << "enfile";
|
||||
break;
|
||||
case ENOTSOCK:
|
||||
FILE_LOG(logERROR) << "enotsock";
|
||||
LOG(logERROR) << "enotsock";
|
||||
break;
|
||||
case EOPNOTSUPP:
|
||||
FILE_LOG(logERROR) << "eOPNOTSUPP";
|
||||
LOG(logERROR) << "eOPNOTSUPP";
|
||||
break;
|
||||
case ENOBUFS:
|
||||
FILE_LOG(logERROR) << "ENOBUFS";
|
||||
LOG(logERROR) << "ENOBUFS";
|
||||
break;
|
||||
case ENOMEM:
|
||||
FILE_LOG(logERROR) << "ENOMEM";
|
||||
LOG(logERROR) << "ENOMEM";
|
||||
break;
|
||||
case ENOSR:
|
||||
FILE_LOG(logERROR) << "ENOSR";
|
||||
LOG(logERROR) << "ENOSR";
|
||||
break;
|
||||
case EPROTO:
|
||||
FILE_LOG(logERROR) << "EPROTO";
|
||||
LOG(logERROR) << "EPROTO";
|
||||
break;
|
||||
default:
|
||||
FILE_LOG(logERROR) << "unknown error";
|
||||
LOG(logERROR) << "unknown error";
|
||||
}
|
||||
}
|
||||
else{
|
||||
inet_ntop(AF_INET, &(clientAddress.sin_addr), dummyClientIP, INET_ADDRSTRLEN);
|
||||
FILE_LOG(logDEBUG1) << "client connected " << sockfd.newfd;
|
||||
LOG(logDEBUG1) << "client connected " << sockfd.newfd;
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "fd " << sockfd.newfd;
|
||||
LOG(logDEBUG1) << "fd " << sockfd.newfd;
|
||||
return sockfd.newfd;
|
||||
} else {
|
||||
if (sockfd.fd<=0)
|
||||
sockfd.fd = socket(AF_INET, getProtocol(),0);
|
||||
// SetTimeOut(10);
|
||||
if (sockfd.fd < 0){
|
||||
FILE_LOG(logERROR) << "Can not create socket";
|
||||
LOG(logERROR) << "Can not create socket";
|
||||
} else {
|
||||
if(connect(sockfd.fd,(struct sockaddr *) &serverAddress,sizeof(serverAddress))<0){
|
||||
FILE_LOG(logERROR) << "Can not connect to socket";
|
||||
LOG(logERROR) << "Can not connect to socket";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -465,13 +465,13 @@ public:
|
||||
tout.tv_usec = 0;
|
||||
if(::setsockopt(sockfd.fd, SOL_SOCKET, SO_RCVTIMEO,
|
||||
&tout, sizeof(struct timeval)) <0) {
|
||||
FILE_LOG(logERROR) << "setsockopt SO_RCVTIMEO " << 0;
|
||||
LOG(logERROR) << "setsockopt SO_RCVTIMEO " << 0;
|
||||
}
|
||||
tout.tv_sec = ts;
|
||||
tout.tv_usec = 0;
|
||||
if(::setsockopt(sockfd.fd, SOL_SOCKET, SO_SNDTIMEO,
|
||||
&tout, sizeof(struct timeval)) < 0) {
|
||||
FILE_LOG(logERROR) << "setsockopt SO_SNDTIMEO " << ts;
|
||||
LOG(logERROR) << "setsockopt SO_SNDTIMEO " << ts;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
@@ -609,17 +609,17 @@ public:
|
||||
// get host info into res
|
||||
int errcode = getaddrinfo (hostname, NULL, &hints, res);
|
||||
if (errcode != 0) {
|
||||
FILE_LOG(logERROR) << "Could not convert hostname (" << hostname << ") to internet address (zmq):" <<
|
||||
LOG(logERROR) << "Could not convert hostname (" << hostname << ") to internet address (zmq):" <<
|
||||
gai_strerror(errcode);
|
||||
} else {
|
||||
if (*res == NULL) {
|
||||
FILE_LOG(logERROR) << "Could not converthostname (" << hostname << ") to internet address (zmq):"
|
||||
LOG(logERROR) << "Could not converthostname (" << hostname << ") to internet address (zmq):"
|
||||
"gettaddrinfo returned null";
|
||||
} else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
FILE_LOG(logERROR) << "Could not convert hostname to internet address";
|
||||
LOG(logERROR) << "Could not convert hostname to internet address";
|
||||
return 1;
|
||||
};
|
||||
|
||||
@@ -637,7 +637,7 @@ public:
|
||||
freeaddrinfo(res);
|
||||
return 0;
|
||||
}
|
||||
FILE_LOG(logERROR) << "Could not convert internet address to ip string";
|
||||
LOG(logERROR) << "Could not convert internet address to ip string";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ public:
|
||||
continue;
|
||||
if(nsent != nsending){
|
||||
if(nsent && (nsent != -1)) {
|
||||
FILE_LOG(logERROR) << "Incomplete Packet size " << nsent;
|
||||
LOG(logERROR) << "Incomplete Packet size " << nsent;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -710,7 +710,7 @@ public:
|
||||
break;
|
||||
//incomplete packets or header packets ignored and read buffer again
|
||||
if(nsent != packet_size && nsent != header_packet_size) {
|
||||
FILE_LOG(logERROR) << portno << ": Incomplete Packet size " << nsent;
|
||||
LOG(logERROR) << portno << ": Incomplete Packet size " << nsent;
|
||||
}
|
||||
}
|
||||
//nsent = 1040;
|
||||
@@ -720,7 +720,7 @@ public:
|
||||
default:
|
||||
;
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "sent " << total_sent << " Bytes";
|
||||
LOG(logDEBUG1) << "sent " << total_sent << " Bytes";
|
||||
return total_sent;
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ public:
|
||||
* @returns size of data sent
|
||||
*/
|
||||
int SendDataOnly(void *buf, int length) {
|
||||
FILE_LOG(logDEBUG1) << "want to send " << length << " Bytes";
|
||||
LOG(logDEBUG1) << "want to send " << length << " Bytes";
|
||||
if (buf==NULL) return -1;
|
||||
|
||||
total_sent=0;
|
||||
@@ -746,7 +746,7 @@ public:
|
||||
nsending = (length>packet_size) ? packet_size:length;
|
||||
nsent = write(tcpfd,(char*)buf+total_sent,nsending);
|
||||
if(is_a_server && nsent < 0) {
|
||||
FILE_LOG(logERROR) << "Could not write to socket. Possible client socket crash";
|
||||
LOG(logERROR) << "Could not write to socket. Possible client socket crash";
|
||||
break;
|
||||
}
|
||||
if(!nsent) break;
|
||||
@@ -768,7 +768,7 @@ public:
|
||||
default:
|
||||
;
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "sent "<< total_sent << " Bytes";
|
||||
LOG(logDEBUG1) << "sent "<< total_sent << " Bytes";
|
||||
return total_sent;
|
||||
}
|
||||
|
||||
|
||||
248
slsSupportLib/include/logger.h
Executable file → Normal file
248
slsSupportLib/include/logger.h
Executable file → Normal file
@@ -1,30 +1,19 @@
|
||||
#pragma once
|
||||
/*Utility to log to console*/
|
||||
|
||||
#include <ansi.h>
|
||||
#include "ansi.h" //Colors
|
||||
#include <sys/time.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
|
||||
enum TLogLevel {logERROR, logWARNING, logINFOBLUE, logINFOGREEN, logINFORED, logINFO,
|
||||
logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5};
|
||||
|
||||
|
||||
#ifdef FIFODEBUG
|
||||
#define FILELOG_MAX_LEVEL logDEBUG5
|
||||
#elif VERYVERBOSE
|
||||
#define FILELOG_MAX_LEVEL logDEBUG4
|
||||
#elif VERBOSE
|
||||
#define FILELOG_MAX_LEVEL logDEBUG
|
||||
// Compiler should optimize away anything below this value
|
||||
#ifndef LOG_MAX_REPORTING_LEVEL
|
||||
#define LOG_MAX_REPORTING_LEVEL logINFO
|
||||
#endif
|
||||
|
||||
#ifndef FILELOG_MAX_LEVEL
|
||||
#define FILELOG_MAX_LEVEL logINFO
|
||||
// #define FILELOG_MAX_LEVEL logDEBUG5
|
||||
#endif
|
||||
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
#define MYCONCAT(x,y)
|
||||
#define __AT__ std::string(__FILE__) + std::string("::") + std::string(__func__) + std::string("(): ")
|
||||
#define __SHORT_FORM_OF_FILE__ \
|
||||
(strrchr(__FILE__,'/') \
|
||||
@@ -34,159 +23,72 @@
|
||||
#define __SHORT_AT__ std::string(__SHORT_FORM_OF_FILE__) + std::string("::") + std::string(__func__) + std::string("(): ")
|
||||
|
||||
|
||||
namespace sls {
|
||||
class Logger {
|
||||
std::ostringstream os;
|
||||
TLogLevel level = LOG_MAX_REPORTING_LEVEL;
|
||||
|
||||
|
||||
inline std::string NowTime();
|
||||
// 1 normal debug, 3 function names, 5 fifodebug
|
||||
enum TLogLevel {logERROR, logWARNING, logINFOBLUE, logINFOGREEN, logINFORED, logINFO,
|
||||
logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4, logDEBUG5};
|
||||
|
||||
template <typename T> class Log{
|
||||
public:
|
||||
Log();
|
||||
virtual ~Log();
|
||||
std::ostringstream& Get(TLogLevel level = logINFO);
|
||||
static TLogLevel& ReportingLevel();
|
||||
static std::string ToString(TLogLevel level);
|
||||
static TLogLevel FromString(const std::string& level);
|
||||
protected:
|
||||
std::ostringstream os;
|
||||
TLogLevel lev;
|
||||
private:
|
||||
Log(const Log&);
|
||||
Log& operator =(const Log&);
|
||||
};
|
||||
|
||||
|
||||
class Output2FILE {
|
||||
public:
|
||||
static FILE*& Stream();
|
||||
static void Output(const std::string& msg);
|
||||
static void Output(const std::string& msg, TLogLevel level);
|
||||
};
|
||||
|
||||
|
||||
#define FILELOG_DECLSPEC
|
||||
|
||||
class FILELOG_DECLSPEC FILELog : public Log<Output2FILE> {};
|
||||
|
||||
|
||||
#define FILE_LOG(level) \
|
||||
if (level > FILELOG_MAX_LEVEL) ; \
|
||||
else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \
|
||||
else FILELog().Get(level)
|
||||
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
inline std::string NowTime()
|
||||
{
|
||||
char buffer[12];
|
||||
const int buffer_len = sizeof(buffer);
|
||||
time_t t;
|
||||
time(&t);
|
||||
tm r;
|
||||
strftime(buffer, buffer_len, "%X", localtime_r(&t, &r));
|
||||
buffer[buffer_len - 1] = 0;
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
char result[100];
|
||||
const int result_len = sizeof(result);
|
||||
snprintf(result, result_len, "%s.%03ld", buffer, (long)tv.tv_usec / 1000);
|
||||
result[result_len - 1] = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
template <typename T> Log<T>::Log():lev(logDEBUG){}
|
||||
|
||||
template <typename T> std::ostringstream& Log<T>::Get(TLogLevel level)
|
||||
{
|
||||
lev = level;
|
||||
os << "- " << NowTime();
|
||||
os << " " << ToString(level) << ": ";
|
||||
if (level > logDEBUG)
|
||||
os << std::string(level - logDEBUG, ' ');
|
||||
return os;
|
||||
}
|
||||
|
||||
template <typename T> Log<T>::~Log()
|
||||
{
|
||||
os << std::endl;
|
||||
T::Output( os.str(),lev); // T::Output( os.str());
|
||||
}
|
||||
|
||||
template <typename T> TLogLevel& Log<T>::ReportingLevel()
|
||||
{
|
||||
static TLogLevel reportingLevel = logDEBUG5;
|
||||
return reportingLevel;
|
||||
}
|
||||
|
||||
template <typename T> std::string Log<T>::ToString(TLogLevel level)
|
||||
{
|
||||
static const char* const buffer[] = {
|
||||
"ERROR", "WARNING", "INFO", "INFO", "INFO", "INFO",
|
||||
"DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4","DEBUG5"};
|
||||
return buffer[level];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
TLogLevel Log<T>::FromString(const std::string& level)
|
||||
{
|
||||
if (level == "DEBUG5")
|
||||
return logDEBUG5;
|
||||
if (level == "DEBUG4")
|
||||
return logDEBUG4;
|
||||
if (level == "DEBUG3")
|
||||
return logDEBUG3;
|
||||
if (level == "DEBUG2")
|
||||
return logDEBUG2;
|
||||
if (level == "DEBUG1")
|
||||
return logDEBUG1;
|
||||
if (level == "DEBUG")
|
||||
return logDEBUG;
|
||||
if (level == "INFO")
|
||||
return logINFO;
|
||||
if (level == "WARNING")
|
||||
return logWARNING;
|
||||
if (level == "ERROR")
|
||||
return logERROR;
|
||||
Log<T>().Get(logWARNING) << "Unknown logging level '" << level << "'. Using INFO level as default.";
|
||||
return logINFO;
|
||||
}
|
||||
|
||||
|
||||
inline FILE*& Output2FILE::Stream()
|
||||
{
|
||||
static FILE* pStream = stderr;
|
||||
return pStream;
|
||||
}
|
||||
|
||||
inline void Output2FILE::Output(const std::string& msg)
|
||||
{
|
||||
FILE* pStream = Stream();
|
||||
if (!pStream)
|
||||
return;
|
||||
fprintf(pStream, "%s", msg.c_str());
|
||||
fflush(pStream);
|
||||
}
|
||||
|
||||
inline void Output2FILE::Output(const std::string& msg, TLogLevel level)
|
||||
{
|
||||
FILE* pStream = Stream();
|
||||
if (!pStream)
|
||||
return;
|
||||
bool out = true;
|
||||
switch(level){
|
||||
case logERROR: cprintf(RED BOLD,"%s",msg.c_str()); break;
|
||||
case logWARNING: cprintf(YELLOW BOLD,"%s",msg.c_str()); break;
|
||||
case logINFO: cprintf(RESET,"%s",msg.c_str()); break;
|
||||
case logINFOBLUE: cprintf(BLUE,"%s",msg.c_str()); break;
|
||||
case logINFORED: cprintf(RED,"%s",msg.c_str()); break;
|
||||
case logINFOGREEN: cprintf(GREEN,"%s",msg.c_str()); break;
|
||||
default: fprintf(pStream,"%s",msg.c_str()); out = false; break;
|
||||
public:
|
||||
Logger() = default;
|
||||
explicit Logger(TLogLevel level) : level(level){};
|
||||
~Logger() {
|
||||
// output in the destructor to allow for << syntax
|
||||
os << RESET << '\n';
|
||||
std::clog << os.str() << std::flush; // Single write
|
||||
}
|
||||
fflush(out ? stdout : pStream);
|
||||
}
|
||||
|
||||
#include "logger2.h"
|
||||
static TLogLevel &ReportingLevel() { // singelton eeh
|
||||
static TLogLevel reportingLevel = logINFO;
|
||||
return reportingLevel;
|
||||
}
|
||||
|
||||
// Danger this buffer need as many elements as TLogLevel
|
||||
static const char *Color(TLogLevel level) noexcept {
|
||||
static const char *const colors[] = {
|
||||
RED BOLD, YELLOW BOLD, BLUE, GREEN, RED, RESET,
|
||||
RESET, RESET, RESET, RESET, RESET, RESET};
|
||||
return colors[level];
|
||||
}
|
||||
|
||||
// Danger this buffer need as many elements as TLogLevel
|
||||
static std::string ToString(TLogLevel level) {
|
||||
static const char *const buffer[] = {
|
||||
"ERROR", "WARNING", "INFO", "INFO", "INFO", "INFO",
|
||||
"DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4", "DEBUG5"};
|
||||
return buffer[level];
|
||||
}
|
||||
|
||||
std::ostringstream &Get() {
|
||||
os << Color(level) << "- " << Timestamp() << " " << ToString(level)
|
||||
<< ": ";
|
||||
return os;
|
||||
}
|
||||
|
||||
static std::string Timestamp() {
|
||||
constexpr size_t buffer_len = 12;
|
||||
char buffer[buffer_len];
|
||||
time_t t;
|
||||
::time(&t);
|
||||
tm r;
|
||||
strftime(buffer, buffer_len, "%X", localtime_r(&t, &r));
|
||||
buffer[buffer_len - 1] = '\0';
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
constexpr size_t result_len = 100;
|
||||
char result[result_len];
|
||||
snprintf(result, result_len, "%s.%03ld", buffer,
|
||||
(long)tv.tv_usec / 1000);
|
||||
result[result_len - 1] = '\0';
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
#define LOG(level) \
|
||||
if (level > LOG_MAX_REPORTING_LEVEL) \
|
||||
; \
|
||||
else if (level > sls::Logger::ReportingLevel()) \
|
||||
; \
|
||||
else \
|
||||
sls::Logger(level).Get()
|
||||
|
||||
} // namespace sls
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
#pragma once
|
||||
/*Utility to log to console*/
|
||||
|
||||
#include "ansi.h" //Colors
|
||||
// #include "logger.h" //for enum, to be removed
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
// Compiler should optimize away anything below this value
|
||||
#ifndef LOG_MAX_REPORTING_LEVEL
|
||||
#define LOG_MAX_REPORTING_LEVEL logINFO
|
||||
#endif
|
||||
|
||||
namespace sls {
|
||||
class Logger {
|
||||
std::ostringstream os;
|
||||
TLogLevel level = LOG_MAX_REPORTING_LEVEL;
|
||||
|
||||
public:
|
||||
Logger() = default;
|
||||
explicit Logger(TLogLevel level) : level(level){};
|
||||
~Logger() {
|
||||
// output in the destructor to allow for << syntax
|
||||
os << RESET << '\n';
|
||||
std::clog << os.str() << std::flush; // Single write
|
||||
}
|
||||
|
||||
static TLogLevel &ReportingLevel() { // singelton eeh
|
||||
static TLogLevel reportingLevel = logINFO;
|
||||
return reportingLevel;
|
||||
}
|
||||
|
||||
// Danger this buffer need as many elements as TLogLevel
|
||||
static const char *Color(TLogLevel level) noexcept {
|
||||
static const char *const colors[] = {
|
||||
RED BOLD, YELLOW BOLD, BLUE, GREEN, RED, RESET,
|
||||
RESET, RESET, RESET, RESET, RESET, RESET};
|
||||
return colors[level];
|
||||
}
|
||||
|
||||
// Danger this buffer need as many elements as TLogLevel
|
||||
static std::string ToString(TLogLevel level) {
|
||||
static const char *const buffer[] = {
|
||||
"ERROR", "WARNING", "INFO", "INFO", "INFO", "INFO",
|
||||
"DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4", "DEBUG5"};
|
||||
return buffer[level];
|
||||
}
|
||||
|
||||
std::ostringstream &Get() {
|
||||
os << Color(level) << "- " << Timestamp() << " " << ToString(level)
|
||||
<< ": ";
|
||||
return os;
|
||||
}
|
||||
|
||||
std::string Timestamp() {
|
||||
constexpr size_t buffer_len = 12;
|
||||
char buffer[buffer_len];
|
||||
time_t t;
|
||||
::time(&t);
|
||||
tm r;
|
||||
strftime(buffer, buffer_len, "%X", localtime_r(&t, &r));
|
||||
buffer[buffer_len - 1] = '\0';
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
constexpr size_t result_len = 100;
|
||||
char result[result_len];
|
||||
snprintf(result, result_len, "%s.%03ld", buffer,
|
||||
(long)tv.tv_usec / 1000);
|
||||
result[result_len - 1] = '\0';
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
#define LOG(level) \
|
||||
if (level > LOG_MAX_REPORTING_LEVEL) \
|
||||
; \
|
||||
else if (level > sls::Logger::ReportingLevel()) \
|
||||
; \
|
||||
else \
|
||||
sls::Logger(level).Get()
|
||||
|
||||
} // namespace sls
|
||||
@@ -9,13 +9,13 @@ namespace sls{
|
||||
struct RuntimeError : public std::runtime_error {
|
||||
public:
|
||||
RuntimeError(): runtime_error("SLS Detector Package Failed") {
|
||||
FILE_LOG(logERROR) << "SLS Detector Package Failed";
|
||||
LOG(logERROR) << "SLS Detector Package Failed";
|
||||
}
|
||||
RuntimeError(const std::string& msg): runtime_error(msg) {
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
}
|
||||
RuntimeError(const char* msg): runtime_error(msg) {
|
||||
FILE_LOG(logERROR) << msg;
|
||||
LOG(logERROR) << msg;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ int DataSocket::setTimeOut(int t_seconds) {
|
||||
// Receive timeout indefinet
|
||||
if (::setsockopt(getSocketId(), SOL_SOCKET, SO_RCVTIMEO, &t,
|
||||
sizeof(struct timeval)) < 0) {
|
||||
FILE_LOG(logERROR) << "setsockopt SO_RCVTIMEO " << 0;
|
||||
LOG(logERROR) << "setsockopt SO_RCVTIMEO " << 0;
|
||||
}
|
||||
|
||||
t.tv_sec = t_seconds;
|
||||
@@ -115,7 +115,7 @@ int DataSocket::setTimeOut(int t_seconds) {
|
||||
// Sending timeout in seconds
|
||||
if (::setsockopt(getSocketId(), SOL_SOCKET, SO_SNDTIMEO, &t,
|
||||
sizeof(struct timeval)) < 0) {
|
||||
FILE_LOG(logERROR) << "setsockopt SO_SNDTIMEO " << t_seconds;
|
||||
LOG(logERROR) << "setsockopt SO_SNDTIMEO " << t_seconds;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ int ServerInterface::sendResult(int ret, void *retval, int retvalSize,
|
||||
if (mess != nullptr) {
|
||||
write(mess, MAX_STR_LENGTH);
|
||||
} else {
|
||||
FILE_LOG(logERROR) << "No error message provided for this "
|
||||
LOG(logERROR) << "No error message provided for this "
|
||||
"failure. Will mess up TCP\n";
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -46,7 +46,7 @@ int readDataFile(std::string fname, short int *data, int nch) {
|
||||
iline=readDataFile(infile, data, nch, 0);
|
||||
infile.close();
|
||||
} else {
|
||||
FILE_LOG(logERROR) << "Could not read file " << fname;
|
||||
LOG(logERROR) << "Could not read file " << fname;
|
||||
return -1;
|
||||
}
|
||||
return iline;
|
||||
@@ -73,7 +73,7 @@ int writeDataFile(std::string fname,int nch, short int *data) {
|
||||
outfile.close();
|
||||
return slsDetectorDefs::OK;
|
||||
} else {
|
||||
FILE_LOG(logERROR) << "Could not open file " << fname << "for writing";
|
||||
LOG(logERROR) << "Could not open file " << fname << "for writing";
|
||||
return slsDetectorDefs::FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <sys/prctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include "network_utils.h"
|
||||
|
||||
namespace sls {
|
||||
|
||||
Reference in New Issue
Block a user