diff --git a/MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h b/MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h index 630989389acd38b371eccdb1efa960fb68caa004..167e5f43924f6e42d38c80d25758caf2f2b80ab2 100644 --- a/MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h +++ b/MAC/APL/RTCCommon/include/APL/RTCCommon/RegisterState.h @@ -100,14 +100,13 @@ namespace LOFAR { void read (int i = -1) { tran(IDLE, READ, i); } void check (int i = -1) { tran(IDLE, CHECK, i); } - void write_force (int i = -1) { tran(IDLE, WRITE, i); } void unmodified (int i = -1) { tran(CHECK, IDLE, i); } - void write (int i = -1) { tran(CHECK, WRITE, i); } void read_schedule(int i = -1) { tran(WRITE, READ, i); } void read_ack (int i = -1) { tran(READ, DONE, i); } void write_ack (int i = -1) { tran(WRITE, DONE, i); } void read_error (int i = -1) { tran(READ, READ_ERROR, i); } void write_error (int i = -1) { tran(WRITE, WRITE_ERROR, i); } + void write (int i = -1); void clear(int i = -1); void reset(int i = -1); diff --git a/MAC/APL/RTCCommon/src/RegisterState.cc b/MAC/APL/RTCCommon/src/RegisterState.cc index 77209b73b57ffe1ccb207baf7ee784caa9e0c15d..4c81c0ada7d6b04d7a4eecbf864e0c48c1466916 100644 --- a/MAC/APL/RTCCommon/src/RegisterState.cc +++ b/MAC/APL/RTCCommon/src/RegisterState.cc @@ -95,6 +95,8 @@ void RegisterState::tran(State source, State target, int i) m_state(j) = target; } else if (target != m_state(j)) { LOG_ERROR_STR("tran(" << source << ", " << target << ") failed, current state = " << m_state(j)); + // for some reason the LOG_ERROR doesn't work in this file so cerr is sometimes used like below + //cerr << "tran(" << source << ", " << target << ") failed, current state = " << m_state(j) << endl; } } } @@ -127,6 +129,34 @@ void RegisterState::clear(int i) } } +// transition from IDLE or CHECK -> WRITE +void RegisterState::write(int i) +{ + int lb = 0, ub = 0; + if (i < 0) { + lb = 0; + ub = m_state.extent(blitz::firstDim); + } else { + ASSERT(i >= 0 && i < m_state.extent(blitz::firstDim)); + lb = i; + ub = i + 1; + } + + for (int j = lb; j < ub; j++) { + if (IDLE == m_state(j)) { + m_state(j) = WRITE; + } else if (CHECK == m_state(j)) { + m_state(j) = WRITE; + } else if (WRITE == m_state(j)) { + // already in write state + } else { + LOG_ERROR_STR("tran to " << WRITE << " from " << m_state(j) << " failed"); + // for some reason the LOG_ERROR doesn't work in this file so cerr is sometimes used like below + //cerr << "tran to " << WRITE << " from " << m_state(j) << " failed" << endl; + } + } +} + void RegisterState::reset(int i) { if (i < 0) {