#include <Simulator.h>
Public Member Functions | |
UdpSimulator (int rocid, int syncscale=2, int period0=0, int period1=0, int ctrlport=0) | |
Constructor. | |
virtual | ~UdpSimulator () |
bool | initNewSockets () |
void | dispatchNewSockets (int tmout=1000) |
void | OnRawData (int number, const char *buf, int len, struct sockaddr *, socklen_t) |
int | checkCtrlOperationAllowed (roc::UdpMessageFull *pkt, in_addr_t src_ip, int src_port) |
void | mainLoop () |
uint32_t | PutReg (int nodekind, uint32_t addr, uint32_t val, uint8_t *rawdata) |
uint32_t | GetReg (int nodekind, uint32_t addr, uint32_t *retVal, void *rawdata=0, int *rawdatasize=0) |
uint32_t | NOper (int nodekind, uint32_t num, uint32_t *oper) |
void | fillRareSyncData (uint8_t *target, uint16_t numOfDatas) |
void | makeSysMessage (uint8_t typ, uint32_t arg=0) |
void | processDataRequest (roc::UdpDataRequestFull *pkt) |
void | setLostRates (double recv=0., double send=0.) |
Private Member Functions | |
uint32_t & | syncMDelay () |
uint32_t & | gpioConfig () |
bool | doRecvLost () |
bool | doSendLost () |
void | resetSimulator () |
bool | sendDataPacket (uint32_t pktid) |
Private Attributes | |
uint32_t | nxRegister [NX_REG_SIZE] |
uint32_t | gpioRegs [GPIO_REG_SIZE] |
int | s_data |
int | s_ctrl |
long double | clockScrewUp |
uint64_t | nextTimeHit |
unsigned | nextHitCounter |
uint64_t | nextEventNumber |
uint64_t | nextTimeNoise |
uint64_t | nextTimeSync |
uint64_t | nextTimeAUX0 |
bool | nextAUX0Falling |
uint64_t | periodAUX0 |
uint64_t | nextTimeAUX1 |
bool | nextAUX1Falling |
uint64_t | periodAUX1 |
uint32_t | lastEpoch |
uint64_t | nextSyncEvent |
double | recvLostRate |
double | sendLostRate |
unsigned | recvLostCounter |
unsigned | sendLostCounter |
uint64_t | totalSendCounter |
uint64_t | totalSendLosts |
uint64_t | totalRecvCounter |
uint64_t | totalRecvLosts |
uint32_t | recvDataSize |
uint32_t | sendDataSize |
uint32_t | takeDataSize |
roc::BoardStatistic | fStat |
SysCore Simulator class
The UdpSimulator class is implemented to simulate the behavior of the ROC Board. You can use and test the roc::Board class and the DAQ analysis system without having an actual ROC at your hands.
Definition at line 137 of file Simulator.h.
UdpSimulator::UdpSimulator | ( | int | rocid, | |
int | syncscale = 2 , |
|||
int | period0 = 0 , |
|||
int | period1 = 0 , |
|||
int | ctrlport = 0 | |||
) |
Constructor.
Definition at line 100 of file Simulator.cxx.
References base::AUX0, base::AUX1, sc_data::cmdListPtr, sc_data::cmdsList, sc_data::control_retry_buf_rawsize, sc_data::controlIp, sc_data::controlLocked, sc_data::controlPort, sc_config::ctrlPort, sc_data::daqState, sc_data::data_taking_on, sc_config::dataPort, sc_config::flushTimeout, fStat, gC, gD, get_clock(), gpioConfig(), gpioRegs, sc_data::headid, sc_data::high_water, sc_data::last_req_pkt_id, sc_data::lastControlPacketId, sc_data::lastMasterPacketId, sc_data::lastMasterTime, sc_data::lockedTime, sc_data::low_water, sc_data::master_retry_buf_rawsize, sc_data::masterConnected, sc_data::masterDataPort, sc_data::masterIp, sc_data::masterPort, nxRegister, periodAUX0, periodAUX1, recvDataSize, sc_data::resend_size, resetSimulator(), ROC_CMD_LST_PUT, ROC_CMD_LST_SIZE, sc_config::rocNumber, s_ctrl, s_data, sc_data::send_limit, sendDataSize, setLostRates(), base::SYNC_S0, syncMDelay(), and takeDataSize.
UdpSimulator::~UdpSimulator | ( | ) | [virtual] |
Definition at line 198 of file Simulator.cxx.
int UdpSimulator::checkCtrlOperationAllowed | ( | roc::UdpMessageFull * | pkt, | |
in_addr_t | src_ip, | |||
int | src_port | |||
) |
Definition at line 335 of file Simulator.cxx.
References roc::UdpMessage::address, sc_data::controlConnected, sc_data::controlIp, sc_data::controlLocked, sc_data::controlPort, gD, get_clock(), IpToStr(), sc_data::lastControlPacketId, sc_data::lastControlTime, sc_data::lastMasterPacketId, sc_data::lastMasterTime, sc_data::masterConnected, sc_data::masterIp, sc_data::masterPort, ROC_PEEK, ROC_POKE, roc::UdpMessage::tag, and roc::UdpMessage::value.
Referenced by OnRawData().
void UdpSimulator::dispatchNewSockets | ( | int | tmout = 1000 |
) |
Definition at line 297 of file Simulator.cxx.
References OnRawData(), s_ctrl, and s_data.
Referenced by mainLoop().
bool UdpSimulator::doRecvLost | ( | ) | [private] |
Definition at line 227 of file Simulator.cxx.
References recvLostCounter, recvLostRate, totalRecvCounter, and totalRecvLosts.
Referenced by OnRawData().
bool UdpSimulator::doSendLost | ( | ) | [private] |
Definition at line 245 of file Simulator.cxx.
References sendLostCounter, sendLostRate, totalSendCounter, and totalSendLosts.
Referenced by OnRawData(), and sendDataPacket().
void UdpSimulator::fillRareSyncData | ( | uint8_t * | target, | |
uint16_t | numOfDatas | |||
) |
This is generator of rare hits with sync messages
Definition at line 804 of file Simulator.cxx.
References base::AUX0, base::AUX1, clockScrewUp, roc::Message::copyto(), roc::formatEth2, gpioConfig(), lastEpoch, roc::MSG_AUX, roc::MSG_EPOCH, roc::MSG_HIT, roc::MSG_SYNC, nextAUX0Falling, nextAUX1Falling, nextEventNumber, nextHitCounter, nextSyncEvent, nextTimeAUX0, nextTimeAUX1, nextTimeHit, nextTimeNoise, nextTimeSync, periodAUX0, periodAUX1, roc::Message::reset(), roc::Message::setAuxChNum(), roc::Message::setAuxEpochLSB(), roc::Message::setAuxFalling(), roc::Message::setAuxOverflow(), roc::Message::setAuxTs(), roc::Message::setEpochNumber(), roc::Message::setMessageType(), roc::Message::setNxAdcValue(), roc::Message::setNxChNum(), roc::Message::setNxLastEpoch(), roc::Message::setNxNumber(), roc::Message::setNxTs(), roc::Message::setSyncChNum(), roc::Message::setSyncData(), roc::Message::setSyncEpochLSB(), roc::Message::setSyncStFlag(), roc::Message::setSyncTs(), base::SYNC_S0, and syncMDelay().
Referenced by mainLoop().
uint32_t UdpSimulator::GetReg | ( | int | nodekind, | |
uint32_t | addr, | |||
uint32_t * | retVal, | |||
void * | rawdata = 0 , |
|||
int * | rawdatasize = 0 | |||
) |
Definition at line 545 of file Simulator.cxx.
References sc_data::cmdsList, sc_data::daqState, roc::BoardStatistic::daqState, sc_config::dataPort, roc::BoardStatistic::dataRate, roc::BoardStatistic::dispPerf, roc::BoardStatistic::frameRate, fStat, gC, gD, base::GPIO_CONFIG, GPIO_REG_SIZE, gpioRegs, sc_data::high_water, sc_data::low_water, roc::BoardStatistic::nopRate, NX_REG_SIZE, nxRegister, roc::BoardStatistic::recvRate, ROC_BUILD_TIME, ROC_CMD_LST_MEM, ROC_ETH_DATAPORT, ROC_ETH_HIGHWATER, ROC_ETH_HWV, ROC_ETH_LOWWATER, ROC_ETH_STATBLOCK, ROC_ETH_SWV, ROC_FPGA_TYPE, ROC_HWV, ROC_NX_HWV, ROC_NX_I2C_DATA, ROC_NX_I2C_ERROR, ROC_NX_I2C_SLAVEADDR, ROC_ROCID, ROC_SVN_REVISION, ROC_TYPE, sc_config::rocNumber, roc::BoardStatistic::sendPerf, roc::BoardStatistic::sendRate, and roc::BoardStatistic::takePerf.
Referenced by NOper(), and OnRawData().
uint32_t& UdpSimulator::gpioConfig | ( | ) | [inline, private] |
Definition at line 143 of file Simulator.h.
References gpioRegs.
Referenced by fillRareSyncData(), and UdpSimulator().
bool UdpSimulator::initNewSockets | ( | ) |
Definition at line 274 of file Simulator.cxx.
References sc_config::ctrlPort, sc_config::dataPort, gC, s_ctrl, s_data, and StartUdp().
Referenced by main().
void UdpSimulator::mainLoop | ( | ) |
Definition at line 1032 of file Simulator.cxx.
References sc_data::buf, sc_data::cmdListPtr, sc_data::cmdsList, sc_data::controlConnected, sc_data::controlLocked, sc_data::daqState, sc_data::data_taking_on, roc::BoardStatistic::dataRate, dispatchNewSockets(), fillRareSyncData(), sc_config::flushTimeout, fStat, gC, gD, get_clock(), sc_data::headid, sc_data::high_water, sc_data::lastControlTime, sc_data::lastFlushTime, sc_data::lastMasterTime, sc_data::lockedTime, sc_data::masterConnected, roc::UdpDataPacketFull::msgs, sc_data::next_send_id, NODE_MASTER, roc::UdpDataPacket::nummsg, roc::UdpDataPacket::pktid, PutReg(), recvDataSize, roc::BoardStatistic::recvRate, sc_data::resend_indx, sc_data::resend_size, ROC_CMD_LST_ADDRMASK, ROC_CMD_LST_PUT, ROC_CMD_LST_SIZE, sc_data::send_limit, sendDataPacket(), sendDataSize, roc::BoardStatistic::sendRate, takeDataSize, totalRecvCounter, totalRecvLosts, totalSendCounter, and totalSendLosts.
Referenced by main().
void UdpSimulator::makeSysMessage | ( | uint8_t | typ, | |
uint32_t | arg = 0 | |||
) |
Definition at line 927 of file Simulator.cxx.
References sc_data::buf, roc::Message::copyto(), roc::formatEth2, gD, sc_data::headid, roc::MSG_SYS, roc::UdpDataPacketFull::msgs, roc::UdpDataPacket::nummsg, roc::UdpDataPacket::pktid, roc::Message::setMessageType(), roc::Message::setSysMesData(), and roc::Message::setSysMesType().
Referenced by PutReg().
uint32_t UdpSimulator::NOper | ( | int | nodekind, | |
uint32_t | num, | |||
uint32_t * | oper | |||
) |
Definition at line 778 of file Simulator.cxx.
References GetReg(), NOPER_GET, NOPER_PUT, and PutReg().
Referenced by OnRawData().
void UdpSimulator::OnRawData | ( | int | number, | |
const char * | buf, | |||
int | len, | |||
struct sockaddr * | sa_from, | |||
socklen_t | sa_len | |||
) |
Definition at line 417 of file Simulator.cxx.
References roc::UdpMessage::address, checkCtrlOperationAllowed(), sc_data::control_retry_buf, sc_data::control_retry_buf_rawsize, sc_data::controlLocked, doRecvLost(), doSendLost(), roc::UdpDataRequest::frontpktid, gD, get_clock(), GetReg(), roc::UdpMessage::id, sc_data::lastControlPacketId, sc_data::lastMasterPacketId, sc_data::lastMasterTime, sc_data::lockedTime, sc_data::master_retry_buf, sc_data::master_retry_buf_rawsize, sc_data::masterDataAddr, NODE_CONTROL, NODE_FORBIDDEN, NODE_MASTER, NODE_SKIP, NOper(), roc::UdpDataRequest::numresend, roc::UdpDataRequest::password, roc::UdpMessage::password, processDataRequest(), PutReg(), roc::UdpMessageFull::rawdata, recvDataSize, roc::UdpDataRequest::reqpktid, roc::UdpDataRequestFull::resend, ROC_NOPER, ROC_PEEK, ROC_POKE, s_ctrl, sendDataSize, roc::UdpMessage::tag, roc::UdpDataRequest::tailpktid, and roc::UdpMessage::value.
Referenced by dispatchNewSockets().
void UdpSimulator::processDataRequest | ( | roc::UdpDataRequestFull * | pkt | ) |
Definition at line 952 of file Simulator.cxx.
References sc_data::buf, sc_data::daqState, sc_data::data_taking_on, roc::UdpDataRequest::frontpktid, gD, sc_data::last_req_pkt_id, sc_data::low_water, roc::UdpDataRequest::numresend, roc::UdpDataRequest::reqpktid, roc::UdpDataRequestFull::resend, sc_data::resend_indx, RESEND_MAX_SIZE, sc_data::resend_size, sc_data::send_limit, and roc::UdpDataRequest::tailpktid.
Referenced by OnRawData().
uint32_t UdpSimulator::PutReg | ( | int | nodekind, | |
uint32_t | addr, | |||
uint32_t | val, | |||
uint8_t * | rawdata | |||
) |
Definition at line 625 of file Simulator.cxx.
References sc_data::buf, sc_data::cmdListPtr, sc_data::cmdsList, sc_data::controlConnected, sc_data::controlIp, sc_data::controlLocked, sc_data::controlPort, sc_data::daqState, sc_data::data_taking_on, sc_data::droppkt_id, sc_config::flushTimeout, gC, gD, get_clock(), base::GPIO_CONFIG, GPIO_REG_SIZE, gpioRegs, sc_data::headid, sc_data::high_water, sc_data::last_req_pkt_id, sc_data::lastControlPacketId, sc_data::lastFlushTime, sc_data::lastMasterPacketId, sc_data::low_water, makeSysMessage(), sc_data::masterConnected, sc_data::masterDataPort, sc_data::masterIp, sc_data::masterPort, sc_data::next_send_id, NODE_CONTROL, NODE_MASTER, NX_REG_SIZE, nxRegister, sc_data::resend_size, resetSimulator(), ROC_ADDSYSMSG, ROC_CMD_LST_ACTIVE, ROC_CMD_LST_MEM, ROC_CMD_LST_NR, ROC_CMD_LST_NUMBER, ROC_CMD_LST_SIZE, ROC_ETH_BUFFER_FLUSH_TIMER, ROC_ETH_CONSOLE_CMD, ROC_ETH_CONSOLE_OUTPUT, ROC_ETH_DLM, ROC_ETH_HIGHWATER, ROC_ETH_LOWWATER, ROC_ETH_MASTER_DATAPORT, ROC_ETH_MASTER_LOGIN, ROC_ETH_MASTER_LOGOUT, ROC_ETH_OCM, ROC_ETH_START_DAQ, ROC_ETH_STOP_DAQ, ROC_ETH_SUSPEND_DAQ, ROC_NX_FIFO_RESET, ROC_NX_HWV, ROC_NX_I2C_DATA, ROC_NX_I2C_REGISTER, ROC_NX_I2C_REGRESET, ROC_NX_I2C_RESET, ROC_NX_I2C_SLAVEADDR, ROC_NX_I2C_SWITCH, ROC_NX_NXACTIVE, ROC_ROCID, sc_config::rocNumber, sc_data::send_limit, sendLostRate, roc::SYSMSG_DAQ_FINISH, roc::SYSMSG_DAQ_START, roc::SYSMSG_USER, totalRecvCounter, totalRecvLosts, totalSendCounter, and totalSendLosts.
Referenced by mainLoop(), NOper(), and OnRawData().
void UdpSimulator::resetSimulator | ( | ) | [private] |
Definition at line 205 of file Simulator.cxx.
References clockScrewUp, gC, lastEpoch, nextAUX0Falling, nextAUX1Falling, nextEventNumber, nextHitCounter, nextSyncEvent, nextTimeAUX0, nextTimeAUX1, nextTimeHit, nextTimeNoise, nextTimeSync, periodAUX0, periodAUX1, and sc_config::rocNumber.
Referenced by PutReg(), and UdpSimulator().
bool UdpSimulator::sendDataPacket | ( | uint32_t | pktid | ) | [private] |
Definition at line 976 of file Simulator.cxx.
References sc_data::buf, doSendLost(), sc_data::droppkt_id, gD, sc_data::last_req_pkt_id, sc_data::masterDataAddr, s_data, and sendDataSize.
Referenced by mainLoop().
void UdpSimulator::setLostRates | ( | double | recv = 0. , |
|
double | send = 0. | |||
) |
Definition at line 262 of file Simulator.cxx.
References recvLostCounter, recvLostRate, sendLostCounter, sendLostRate, totalRecvCounter, totalRecvLosts, totalSendCounter, and totalSendLosts.
Referenced by main(), and UdpSimulator().
uint32_t& UdpSimulator::syncMDelay | ( | ) | [inline, private] |
Definition at line 142 of file Simulator.h.
References base::GPIO_SYNCM_SCALEDOWN, and gpioRegs.
Referenced by fillRareSyncData(), and UdpSimulator().
long double UdpSimulator::clockScrewUp [private] |
Definition at line 148 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
roc::BoardStatistic UdpSimulator::fStat [private] |
Definition at line 176 of file Simulator.h.
Referenced by GetReg(), mainLoop(), and UdpSimulator().
uint32_t UdpSimulator::gpioRegs[GPIO_REG_SIZE] [private] |
Definition at line 140 of file Simulator.h.
Referenced by GetReg(), gpioConfig(), PutReg(), syncMDelay(), and UdpSimulator().
uint32_t UdpSimulator::lastEpoch [private] |
Definition at line 160 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
bool UdpSimulator::nextAUX0Falling [private] |
Definition at line 155 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
bool UdpSimulator::nextAUX1Falling [private] |
Definition at line 158 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
uint64_t UdpSimulator::nextEventNumber [private] |
Definition at line 151 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
unsigned UdpSimulator::nextHitCounter [private] |
Definition at line 150 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
uint64_t UdpSimulator::nextSyncEvent [private] |
Definition at line 161 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
uint64_t UdpSimulator::nextTimeAUX0 [private] |
Definition at line 154 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
uint64_t UdpSimulator::nextTimeAUX1 [private] |
Definition at line 157 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
uint64_t UdpSimulator::nextTimeHit [private] |
Definition at line 149 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
uint64_t UdpSimulator::nextTimeNoise [private] |
Definition at line 152 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
uint64_t UdpSimulator::nextTimeSync [private] |
Definition at line 153 of file Simulator.h.
Referenced by fillRareSyncData(), and resetSimulator().
uint32_t UdpSimulator::nxRegister[NX_REG_SIZE] [private] |
Definition at line 139 of file Simulator.h.
Referenced by GetReg(), PutReg(), and UdpSimulator().
uint64_t UdpSimulator::periodAUX0 [private] |
Definition at line 156 of file Simulator.h.
Referenced by fillRareSyncData(), resetSimulator(), and UdpSimulator().
uint64_t UdpSimulator::periodAUX1 [private] |
Definition at line 159 of file Simulator.h.
Referenced by fillRareSyncData(), resetSimulator(), and UdpSimulator().
uint32_t UdpSimulator::recvDataSize [private] |
Definition at line 173 of file Simulator.h.
Referenced by mainLoop(), OnRawData(), and UdpSimulator().
unsigned UdpSimulator::recvLostCounter [private] |
Definition at line 167 of file Simulator.h.
Referenced by doRecvLost(), and setLostRates().
double UdpSimulator::recvLostRate [private] |
Definition at line 164 of file Simulator.h.
Referenced by doRecvLost(), and setLostRates().
int UdpSimulator::s_ctrl [private] |
Definition at line 146 of file Simulator.h.
Referenced by dispatchNewSockets(), initNewSockets(), OnRawData(), UdpSimulator(), and ~UdpSimulator().
int UdpSimulator::s_data [private] |
Definition at line 145 of file Simulator.h.
Referenced by dispatchNewSockets(), initNewSockets(), sendDataPacket(), UdpSimulator(), and ~UdpSimulator().
uint32_t UdpSimulator::sendDataSize [private] |
Definition at line 174 of file Simulator.h.
Referenced by mainLoop(), OnRawData(), sendDataPacket(), and UdpSimulator().
unsigned UdpSimulator::sendLostCounter [private] |
Definition at line 168 of file Simulator.h.
Referenced by doSendLost(), and setLostRates().
double UdpSimulator::sendLostRate [private] |
Definition at line 165 of file Simulator.h.
Referenced by doSendLost(), PutReg(), and setLostRates().
uint32_t UdpSimulator::takeDataSize [private] |
Definition at line 175 of file Simulator.h.
Referenced by mainLoop(), and UdpSimulator().
uint64_t UdpSimulator::totalRecvCounter [private] |
Definition at line 171 of file Simulator.h.
Referenced by doRecvLost(), mainLoop(), PutReg(), and setLostRates().
uint64_t UdpSimulator::totalRecvLosts [private] |
Definition at line 171 of file Simulator.h.
Referenced by doRecvLost(), mainLoop(), PutReg(), and setLostRates().
uint64_t UdpSimulator::totalSendCounter [private] |
Definition at line 170 of file Simulator.h.
Referenced by doSendLost(), mainLoop(), PutReg(), and setLostRates().
uint64_t UdpSimulator::totalSendLosts [private] |
Definition at line 170 of file Simulator.h.
Referenced by doSendLost(), mainLoop(), PutReg(), and setLostRates().