Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket 8406 #5

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions adsApp/src/ADSPortDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,37 +329,43 @@ asynStatus ADSPortDriver::ADSConnect(asynUser *pasynUser) {
status = static_cast<asynStatus>(
adsConnection->resolve_variables(ads_read_vars));

if (status) {
if (status && lastReadError != status) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic not quite right here. Need two 'if' statements to return status regardless.

if (ads_read_vars.size()) {
        status = static_cast<asynStatus>(
            adsConnection->resolve_variables(ads_read_vars));

        if (status) {
            if (lastReadError!= status){
 LOG_ERR_ASYN(pasynUser,
                         "Could not resolve ADS read variable names (%i): %s",
                         status, ads_errors[status].c_str());
            lastReadError = status;
            }
           
            return status;
        }
        lastReadError = 0;
    }

Also applies to further 'if' statements, for write and sumread.

LOG_ERR_ASYN(pasynUser,
"Could not resolve ADS read variable names (%i): %s",
status, ads_errors[status].c_str());
lastReadError = status;
return status;
}
lastReadError = 0;
}

if (ads_write_vars.size()) {
status = static_cast<asynStatus>(
adsConnection->resolve_variables(ads_write_vars));

if (status) {
if (status && lastWriteError != status) {
LOG_ERR_ASYN(pasynUser,
"Could not resolve ADS write variable names(%i): %s",
status, ads_errors[status].c_str());
lastWriteError = status;
return status;
}
lastWriteError = 0;
}

LOG_WARN_ASYN(pasynUser, "Resolved %lu read and %lu write variable names",
ads_read_vars.size(), ads_write_vars.size());

// initialize sum-read buffers
status = static_cast<asynStatus>(SumRead.initialize());
if (status) {
if (status && lastSumReadError != status) {
LOG_ERR_ASYN(pasynUser,
"Error initializing sum-read request buffers (%i): %s",
status, ads_errors[status].c_str());
lastSumReadError = status;
return status;
}

lastSumReadError = 0;
LOG_WARN_ASYN(pasynUser, "Initialized sum-read request buffers");

status = doSumRead();
Expand Down Expand Up @@ -976,3 +982,5 @@ WriteResult ADSPortDriver::stringWrite(DeviceVariable &deviceVar,

return result;
}


3 changes: 3 additions & 0 deletions adsApp/src/ADSPortDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class ADSPortDriver : public Autoparam::Driver {
uint32_t const adsFunctionTimeout;
const std::shared_ptr<Connection> adsConnection;
const std::chrono::milliseconds sumReadPeriod;
long lastReadError;
long lastWriteError;
long lastSumReadError;

SumReadRequest SumRead;

Expand Down
9 changes: 7 additions & 2 deletions adsApp/src/epics-ads/SumReadRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,15 @@ int SumReadRequest::initialize() {
for (size_t i_var = 0; i_var < chunk->variables.size(); i_var++) {
std::shared_ptr<ADSVariable> var = chunk->variables[i_var];
if (var->addr->is_resolved() == false) {
LOG_ERR("variable name is not resolved: '%s'",
var->addr->get_var_name().c_str());
std::string name = var->addr->get_var_name();
if (name !=last) {
LOG_ERR("variable name is not resolved: '%s'",
name.c_str());
last = var->addr->get_var_name();
}
return EPICSADS_NOT_RESOLVED;
}
last = "";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to reset last variable here? Could be done in the header file?


chunk->sum_read_request_buffer[i_var] = {
var->addr->get_index_group(), var->addr->get_index_offset(),
Expand Down
2 changes: 2 additions & 0 deletions adsApp/src/epics-ads/SumReadRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <memory>
#include <cstdint>
#include <utility>
#include <string>

#ifdef USE_TC_ADS
#include <windows.h>
Expand Down Expand Up @@ -48,6 +49,7 @@ class SumReadRequest {
/* Helper method returns a vector of chunks from chunks_by_ads_port_map */
std::shared_ptr<std::vector<std::shared_ptr<ReadRequestChunk>>>
get_chunks();
std::string last;

public:
/* Number of chunks, i.e. the number of sub-requests needed to sum-read all
Expand Down
8 changes: 4 additions & 4 deletions adsApp/src/err.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
LOG_MSG_ASYN(asyn_user, ASYN_TRACE_ERROR, "ERROR", format, ##__VA_ARGS__)

#define LOG_WARN_ASYN(asyn_user, format, ...) \
LOG_MSG_ASYN(asyn_user, ASYN_TRACE_WARNING, "WARNING", format, ##__VA_ARGS__)
//LOG_MSG_ASYN(asyn_user, ASYN_TRACE_WARNING, "WARNING", format, ##__VA_ARGS__)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would rather keep these messages in case useful. Different case to above where repeated messages were lost.


#define LOG_TRACE_ASYN(asyn_user, format, ...) \
LOG_MSG_ASYN(asyn_user, ASYN_TRACE_FLOW, "TRACE", format, ##__VA_ARGS__)
//LOG_MSG_ASYN(asyn_user, ASYN_TRACE_FLOW, "TRACE", format, ##__VA_ARGS__)

/* Error logging macros for use when asyn_user is not available */
#define LOG_MSG(log_level_str, format, ...) \
Expand All @@ -45,10 +45,10 @@
LOG_MSG("ERROR", format, ##__VA_ARGS__)

#define LOG_WARN(format, ...) \
LOG_MSG("WARNING", format, ##__VA_ARGS__)
//LOG_MSG("WARNING", format, ##__VA_ARGS__)

#define LOG_TRACE(format, ...) \
LOG_MSG("TRACE", format, ##__VA_ARGS__)
//LOG_MSG("TRACE", format, ##__VA_ARGS__)

/* EPICS ADS specific return codes */
#define EPICSADS_BASE 1000
Expand Down