void LOW_devDS2406::readMemUniversal( const uint16_t inStartAddr, byteVec_t &outBytes, const uint16_t inMaxLen, const owCommand_t inCommand) const { if ( inStartAddr >= inMaxLen ) throw devDS2406_error( "Illegal address to read", __FILE__, __LINE__); if ( inStartAddr+outBytes.size() > inMaxLen ) throw devDS2406_error( "Too many bytes to read", __FILE__, __LINE__); linkLock lock( *this); byteVec_t sendBytes = byteVec_t( 3); sendBytes[0] = inCommand; sendBytes[1] = inStartAddr&0xff; sendBytes[2] = inStartAddr>>8; cmd_MatchROM(); getLink().writeData( sendBytes); getLink().readData( outBytes); if ( inStartAddr+outBytes.size() == inMaxLen ) { // read to end of mem => CRC16 checksumm is available uint16_t expectedCrc16 = 0x0000; expectedCrc16 |= (getLink().readDataByte() ^ 0xff); // NOTE: CRC bytzes are sent _inverted_! expectedCrc16 |= (getLink().readDataByte() ^ 0xff) << 8; // NOTE: CRC bytzes are sent _inverted_! if ( LOW_helper_CRC::calcCRC16( outBytes, LOW_helper_CRC::calcCRC16( sendBytes)) != expectedCrc16 ) throw LOW_helper_CRC::crc_error( "DS2406 - CRC error in read operation", __FILE__, __LINE__); } //getLink().resetBus(); }
lString16 ReaderViewNative::getLink( int x, int y, int r ) { int step = 5; int n = r / step; r = n * step; if ( r==0 ) return getLink(x, y); lString16 link; for ( int xx = -r; xx<=r; xx+=step ) { link = getLink( x+xx, y-r ); if ( !link.empty() ) return link; link = getLink( x+xx, y+r ); if ( !link.empty() ) return link; } for ( int yy = -r + step; yy<=r - step; yy+=step ) { link = getLink( x+r, y+yy ); if ( !link.empty() ) return link; link = getLink( x-r, y+yy ); if ( !link.empty() ) return link; } return lString16::empty_str; }
LOW_devDS2406::channelInfo_t LOW_devDS2406::getChannel(const CRCtype_t inCRCtype, const chanSelect_t inChanSelect, const interleaveMode_t inInterleaveMode, const toggleMode_t inToggleMode, const initialMode_t inInitialMode, const activityLatchReset_t inALR) { // locking done by initializer if ( inChanSelect == noneSelect ) throw devDS2406_error( "At least one channel must be selected", __FILE__, __LINE__); if ( ! getHasPioB() && ( inChanSelect==chanBSelect || inChanSelect==chanBothSelect ) ) throw devDS2406_error( "Channel B selected, but device has only PIO A", __FILE__, __LINE__); if ( inChanSelect!=chanBothSelect && inInterleaveMode ) throw devDS2406_error( "Interleave mode only available when selected both channels", __FILE__, __LINE__); byteVec_t outBytes = byteVec_t( 3 ); outBytes[0] = ChannelAccess_COMMAND; outBytes[1] = (inCRCtype & 0x03) | ((inChanSelect&0x3) <<2 ) | ((static_cast<uint8_t>(inInterleaveMode))<<4) | ((static_cast<uint8_t>(inToggleMode))<<5) | ((static_cast<uint8_t>(inInitialMode))<<6) | ((static_cast<int8_t>(inALR))<<7); outBytes[2] = 0xff; // reserved, 0xff sent as specified cmd_MatchROM(); getLink().writeData( outBytes ); uint8_t infoByte = getLink().readDataByte(); LOW_devDS2406::channelInfo_t channelInfo; channelInfo.channelFFQ_pioA = (infoByte>>0)&0x01; channelInfo.channelFFQ_pioB = (infoByte>>1)&0x01; channelInfo.sensedLevel_pioA = (infoByte>>2)&0x01; channelInfo.sensedLevel_pioB = (infoByte>>3)&0x01; channelInfo.activityLatch_pioA = (infoByte>>4)&0x01; channelInfo.activityLatch_pioB = (infoByte>>5)&0x01; channelInfo.hasPioB = (infoByte>>6)&0x01; channelInfo.isExternalPowered = (infoByte>>7)&0x01; // if (inCRCtype==CRCtype_t::CRC_after1Byte ) // { // vector<uint8_t> crc(2); // getLink().readData(crc); // uint16_t expectedCrc16 =0; // expectedCrc16 |= (crc[0] ^ 0xff); // NOTE: CRC bytzes are sent _inverted_! // expectedCrc16 |= (crc[1] ^ 0xff) << 8; // NOTE: CRC bytzes are sent _inverted_! // if ( LOW_helper_CRC::calcCRC16( &infoByte,1 , expectedCrc16) != expectedCrc16 ) // throw LOW_helper_CRC::crc_error( "CRC error in read operation", __FILE__, __LINE__); // } return channelInfo; }
bool LOW_devDS2408::ReadPIO(uint8_t & value) { linkLock lock( *this); cmd_MatchROM(); getLink().writeData(static_cast<uint8_t>(W1_F29_FUNC_CHANN_ACCESS_READ)); value = getLink().readDataByte(); value =~value; return true; }
/** Populate the About tab of the Help panel. */ void HelpFrame::setAboutContent() { myHelpPanel->programImageA->SetBitmap(Icon::getBitmap(Icon::iCrowd3)); string message = "<html>" "<center><h1>" + Tools::wx2str(PROGRAM_NAME) + "</h1></center><br>" "<center><b>" "Version " + Tools::wx2str(PROGRAM_VERSION) + "</b></center><br><br>" "Copyright (c) Dennis Damico, [email protected]<br>" + getLink(Tools::wx2str(PROJECT_URL)) + "<br><br>" "This is open source software under the BSD License:<br>" + getLink("http://www.opensource.org/licenses/bsd-license") + "<br>" "</html>"; if ( ! myHelpPanel->aboutHtml->SetPage(Tools::str2wx(message))) { Tools::log(_T("An error occurred while trying to write the About panel.")); } }
void MEMAppendListObject(MemoryList *list, void *object) { if (!list->tail) { setFirstObject(list, object); return; } auto link = getLink(list, object); auto tail = getLink(list, list->tail); tail->next = object; link->prev = list->tail; link->next = nullptr; list->count++; }
void ControlPort::registerCallback(const ICallbackPtr& functor){ /* Check if port is connected */ if(getLink()){ ControlLinkPtr link = boost::static_pointer_cast<ControlLink>(getLink()); link->bindPort(this); } if(functor){ LOG_DEBUG("Registering callback"); m_Callbacks->push_back(functor); } }
void MEMPrependListObject(MemoryList *list, void *object) { if (!list->head) { setFirstObject(list, object); return; } auto link = getLink(list, object); auto head = getLink(list, list->head); head->prev = object; link->prev = nullptr; link->next = list->head; list->head = object; list->count++; }
void UniformVector::associate() { Uniform::associate(); // Doesn't have link if (!hasLink()) return; // Find the link transformable = Scout<Transformable>::search(findRoot(this), getLink()); if (transformable == NULL) { NodeException e(tag); e << "[UniformVector] Could not find node '" << getLink() << "'."; throw e; } }
void ControlPort::push(float value){ ControlLinkPtr link = boost::static_pointer_cast<ControlLink>(getLink()); if (NULL != link) { link->pushControlData(value); } }
/** Populate the Documentation tab of the Help panel. */ void HelpFrame::setDocContent() { myHelpPanel->programImageD->SetBitmap(Icon::getBitmap(Icon::iCrowd3)); string message = "<html>" "<center><h1><b>" + Tools::wx2str(PROGRAM_NAME) + "</b></h1></center><br>" "<center><b>Documentation</b></center><br><br>" "o " + getLink("User Guide", "http://crowd3.sourceforge.net/crowd3.html") + "<br>" "o " + getLink("Installation, Program Notes, Licenses", "http://crowd3.sourceforge.net/about.html") + "<br>" "o " + getLink("Revision history", "http://crowd3.sourceforge.net/revisions.html") + "<br>" "<br><br>" "Comments, suggestions, and defect reports are always welcome. " "Email to [email protected]." "</html>"; if ( ! myHelpPanel->docHtml->SetPage(Tools::str2wx(message))) { Tools::log(_T("An error occurred while trying to write the Doc panel.")); } }
bool Property::isLinkedWith(const Property* dest, bool transitive) const { // true if dest is the object itself if (this == dest) return true; // check for direct links bool linkedDirectly = (getLink(dest) != 0); if (linkedDirectly) return true; // recursive search for indirect links if (transitive) { if (linkCheckVisited_) return false; else { linkCheckVisited_ = true; for (size_t i=0; i<links_.size(); ++i) { if (links_[i]->getDestinationProperty()->isLinkedWith(dest, true)) { linkCheckVisited_ = false; return true; } } linkCheckVisited_ = false; } } return false; }
BaseCache::Slab * BaseCache::ConstructSlab(Slab *slab, void *pages, size_t byteCount, ObjectLink *(*getLink)(void *parent, void *object), void *parent) { printf("BaseCache::ConstructSlab(%p, %p, %lu, %p, %p)\n", slab, pages, byteCount, getLink, parent); slab->pages = pages; slab->count = slab->size = byteCount / fObjectSize; slab->free = NULL; size_t spareBytes = byteCount - (slab->size * fObjectSize); size_t cycle = fCacheColorCycle; if (cycle > spareBytes) cycle = 0; else fCacheColorCycle += kCacheColorPeriod; printf(" %lu objects, %lu spare bytes, cycle %lu\n", slab->size, spareBytes, cycle); uint8_t *data = ((uint8_t *)pages) + cycle; for (size_t i = 0; i < slab->size; i++) { if (fConstructor) fConstructor(fCookie, data); SListPush(slab->free, getLink(parent, data)); data += fObjectSize; } return slab; }
void MEMRemoveListObject(MemoryList *list, void *object) { void *head = nullptr; if (!object) { return; } if (list->head == object && list->tail == object) { // Clear list list->head = nullptr; list->tail = nullptr; list->count = 0; return; } if (list->head == object) { // Remove from head list->head = MEMGetNextListObject(list, list->head); getLink(list, list->tail)->prev = nullptr; list->count--; return; } if (list->tail == object) { // Remove from tail list->tail = MEMGetPrevListObject(list, list->tail); getLink(list, list->tail)->next = nullptr; list->count--; return; } do { head = MEMGetNextListObject(list, head); } while (head && head != object); if (head == object) { // Remove from middle of list auto link = getLink(list, object); auto next = link->next; auto prev = link->prev; getLink(list, prev)->next = next; getLink(list, next)->prev = prev; list->count--; } }
void MESegment::send(MEVehicle* veh, MESegment* next, SUMOTime time) { assert(isInvalid(next) || time >= myBlockTimes[veh->getQueIndex()]); MSLink* link = getLink(veh); if (link != 0) { link->removeApproaching(veh); } MEVehicle* lc = removeCar(veh, time, next); // new leaderCar myBlockTimes[veh->getQueIndex()] = time; if (!isInvalid(next)) { myBlockTimes[veh->getQueIndex()] += next->getTimeHeadway(free(), veh->getVehicleType().getLengthWithGap()); } if (lc != 0) { lc->setEventTime(MAX2(lc->getEventTime(), myBlockTimes[veh->getQueIndex()])); MSGlobals::gMesoNet->addLeaderCar(lc, getLink(lc)); } }
void MEMRemoveListObject(MemoryList *list, void *object) { void *head = nullptr; if (!object) { return; } if (list->head == object && list->tail == object) { // Clear list list->head = nullptr; list->tail = nullptr; list->count = 0; return; } if (list->head == object) { // Remove from head list->head = MEMGetNextListObject(list, list->head); list->count--; return; } if (list->tail == object) { // Remove from tail list->tail = MEMGetPrevListObject(list, list->tail); list->count--; return; } do { MEMGetNextListObject(list, head); } while (head && head != object); if (head == object) { // Remove from middle of list auto link = getLink(list, object); auto before = link->next; auto after = link->prev; getLink(list, before)->next = after; getLink(list, after)->prev = before; list->count--; } }
void * MEMGetPrevListObject(MemoryList *list, void *object) { if (!object) { return list->tail; } return getLink(list, object)->prev; }
void * MEMGetNextListObject(MemoryList *list, void *object) { if (!object) { return list->head; } return getLink(list, object)->next; }
SUMOTime MESegment::getTLSPenalty(const MEVehicle* veh) const { const MSLink* link = getLink(veh, myTLSPenalty); if (link != 0 && link->isTLSControlled()) { // only apply to the last segment of a tls-controlled edge return link->getMesoTLSPenalty(); } else { return 0; } }
float ControlPort::pop(){ ControlLinkPtr link = boost::static_pointer_cast<ControlLink>(getLink()); if (NULL == link) { return 0.0; } return link->getNextControlData(); }
void setFirstObject(MemoryList *list, void *object) { auto link = getLink(list, object); list->head = object; list->tail = object; link->next = nullptr; link->prev = nullptr; list->count = 1; }
void Node::disconnect(const spNode& child) { if(!isInitialised_) throw std::logic_error("Node::disconnect"); if(!child) throw std::invalid_argument("Node::disconnect"); auto l = getLink(child->getID()); child->parents_.removeOne(id_); removeLink(l); changed(); }
Link DBWorker::getLinkFromTabHistory(int tabHistoryId) { QSqlQuery query = prepare("SELECT link_id FROM tab_history WHERE id = ?;"); query.bindValue(0, tabHistoryId); if (execute(query)) { if (query.first()) { return getLink(query.value(0).toInt()); } } return Link(); }
void function(const Eigen::Ref<const Eigen::VectorXd> &x, Eigen::Ref<Eigen::VectorXd> out) const override { unsigned int idx = 0; Eigen::VectorXd j1 = offset_; for (unsigned int i = 0; i < links_; ++i) { const Eigen::VectorXd j2 = getLink(x, i); out[idx++] = (j1 - j2).norm() - length_; j1 = j2; } }
//===================================================================================== // // public methods // bool LOW_devDS2408::WritePIO(uint8_t piobyte) { linkLock lock( *this); cmd_MatchROM(); vector<uint8_t> writedata; writedata.push_back(static_cast<uint8_t>(W1_F29_FUNC_CHANN_ACCESS_WRITE)); uint8_t invertedpiobyte = ~piobyte; writedata.push_back(invertedpiobyte); writedata.push_back(piobyte); getLink().writeData(writedata); if (getLink().readDataByte() != 0xAA) return false; uint8_t newstate = getLink().readDataByte(); if (newstate!=invertedpiobyte) return false; return true; }
void LOW_devDS2406::cmd_WriteStatus( const uint8_t inStartAddr, const byteVec_t &inWriteBytes) const { if ( inStartAddr+inWriteBytes.size() > 8 ) throw devDS2406_error( "Too many bytes to write", __FILE__, __LINE__); if ( inStartAddr==0x05 || inStartAddr==0x06 ) throw devDS2406_error( "Address not writeable", __FILE__, __LINE__); // not yet supported registers if ( /*inStartAddr>=0x00 &&*/ inStartAddr<=0x04 ) throw devDS2406_error( "Access to address not supported in this version", __FILE__, __LINE__); linkLock lock( *this); // only address 7 remains, i.e. address must be 7 and length of inWriteBytes is 1 byteVec_t sendBytes = byteVec_t( 4); sendBytes[0] = WriteStatus_COMMAND; sendBytes[1] = inStartAddr&0xff; sendBytes[2] = inStartAddr>>8; sendBytes[3] = inWriteBytes[0]; cmd_MatchROM(); getLink().writeData( sendBytes); uint16_t expectedCrc16 = 0x0000; expectedCrc16 |= (getLink().readDataByte() ^ 0xff); // NOTE: CRC bytzes are sent _inverted_! expectedCrc16 |= (getLink().readDataByte() ^ 0xff) << 8; // NOTE: CRC bytzes are sent _inverted_! if ( LOW_helper_CRC::calcCRC16( sendBytes) != expectedCrc16 ) throw LOW_helper_CRC::crc_error( "CRC error in write operation", __FILE__, __LINE__); //getLink().writeData( static_cast<uint8_t>(0xff)); // skip validation byte //uint8_t validationByte = getLink().readDataByte(); //getLink().resetBus(); }
bool LOW_devDS2408::WriteControlStatus(uint8_t status) { linkLock lock( *this); vector<uint8_t> writedata; writedata.push_back(static_cast<uint8_t>(W1_F29_FUNC_WRITE_COND_SEARCH_REG)); writedata.push_back(static_cast<uint8_t>(W1_F29_REG_CONTROL_AND_STATUS)); writedata.push_back(static_cast<uint8_t>(0x00)); writedata.push_back(static_cast<uint8_t>(status)); cmd_MatchROM(); getLink().writeData(writedata); return true; }
int pioReadData(PIODataset* pioDataset, int timerangeIndex, PIODatatype pioDatatype, void** buffer) { ERROR_SWITCH_INIT herr_t read_err; link_t link = {0, 0}; hsize_t position[1] = {-1}; hsize_t number[1] = {-1}; hid_t dataspaceForData = -1; hid_t bufferDataspaceForData = -1; size_t new_buffer_size = -1; if (getLink(*pioDataset, timerangeIndex, &link)<0) return -1; // if (link.number == 0) return 0; // realloc internal buffer if necessary new_buffer_size = link.number*pioGetSize(pioDatatype); if (new_buffer_size > pioDataset->buffer_size) { pioDataset->buffer = realloc(pioDataset->buffer, new_buffer_size); if (pioDataset->buffer == NULL) { pioDataset->buffer_size = 0; return -1; } pioDataset->buffer_size = new_buffer_size; } // read dataset position[0] = (hsize_t)(link.position); number[0] = (hsize_t)(link.number); dataspaceForData = H5Dget_space(pioDataset->identifier); H5Sselect_hyperslab(dataspaceForData, H5S_SELECT_SET, position, NULL, number, NULL); bufferDataspaceForData = H5Screate_simple(1, number, NULL); ERROR_SWITCH_OFF read_err = H5Dread(pioDataset->identifier, pioDatatype.identifier, bufferDataspaceForData, dataspaceForData, H5P_DEFAULT, pioDataset->buffer); ERROR_SWITCH_ON H5Sclose(bufferDataspaceForData); H5Sclose(dataspaceForData); if (read_err < 0) return -1; *buffer = pioDataset->buffer; return link.number; }
void MEMInsertListObject(MemoryList *list, void *before, void *object) { if (!before) { // Insert at end MEMAppendListObject(list, object); return; } if (list->head == before) { // Insert before head MEMPrependListObject(list, object); return; } // Insert to middle of list auto link = getLink(list, object); auto other = getLink(list, before); link->prev = other->prev; link->next = before; other->prev = object; list->count++; }
bool MESegment::isOpen(const MEVehicle* veh) const { if (myTLSPenalty) { // XXX should limited control take precedence over tls penalty? return true; } const MSLink* link = getLink(veh); return (link == 0 || link->havePriority() || limitedControlOverride(link) || link->opened(veh->getEventTime(), veh->getSpeed(), veh->estimateLeaveSpeed(link), veh->getVehicleType().getLengthWithGap(), veh->getImpatience(), veh->getVehicleType().getCarFollowModel().getMaxDecel(), veh->getWaitingTime())); }