int BiaxialFiber3d::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { // // get tag and material info from an ID // static ID idData(3); int dbTag = this->getDbTag(); if (theChannel.recvID(dbTag, commitTag, idData) < 0) { opserr << "BiaxialFiber3d::recvSelf() - failed to recv ID data\n"; return -1; } this->setTag(idData(0)); // // get area and position datafrom a vector // static Vector dData(4); if (theChannel.recvVector(dbTag, commitTag, dData) < 0) { opserr << "BiaxialFiber3d::recvSelf() - failed to recv Vector data\n"; return -2; } area = dData(0); as[0] = dData(1); as[1] = dData(2); R = dData(3); // // now we do the material stuff // int matClassTag = idData(1); // if we have a material, check it is of correct type if (theMaterial != 0) { if (matClassTag != theMaterial->getClassTag()) { delete theMaterial; theMaterial = 0; } } // if no material we need to get one, // NOTE: not an else if in case deleted in if above if (theMaterial == 0) { theMaterial = theBroker.getNewNDMaterial(matClassTag); if (theMaterial == 0) { opserr << "BiaxialFiber3d::recvSelf() - " << "failed to get a UniaxialMaterial of type "<< matClassTag << endln; return -3; } } // set the materials dbTag and invoke recvSelf on the material theMaterial->setDbTag(idData(2)); // now invoke recvSelf on the material if (theMaterial->recvSelf(commitTag, theChannel, theBroker) < 0) { opserr << "BiaxialFiber3d::recvSelf() - the material failed in recvSelf()\n"; return -4; } return 0; }
int TrussSection::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int res; int dataTag = this->getDbTag(); // truss creates a Vector, receives the Vector and then sets the // internal data with the data in the Vector static Vector data(11); res = theChannel.recvVector(dataTag, commitTag, data); if (res < 0) { opserr << "WARNING TrussSection::recvSelf() - failed to receive Vector\n"; return -1; } this->setTag((int)data(0)); dimension = (int)data(1); numDOF = (int)data(2); rho = data(5); doRayleighDamping = (int)data(6); cMass = (int)data(7); initialDisp = new double[dimension]; for (int i=0; i<dimension; i++) initialDisp[i] = 0.0; int initial = 0; for (int i=0; i<dimension; i++) { if (data(8+i) != 0.0) { initial = 1; } } if (initial != 0) { for (int i=0; i<dimension; i++) { initialDisp[i] = data(8+i); } } // truss now receives the tags of it's two external nodes res = theChannel.recvID(dataTag, commitTag, connectedExternalNodes); if (res < 0) { opserr << "WARNING TrussSection::recvSelf() - " << this->getTag() << " failed to receive ID\n"; return -2; } // finally truss creates a new section object of the correct type, // sets its database tag and asks this new object to recveive itself. int sectClass = (int)data(3); int sectDb = (int)data(4); // Get new section if null if (theSection == 0) theSection = theBroker.getNewSection(sectClass); // Check that section is of right type else if (theSection->getClassTag() != sectClass) { delete theSection; theSection = theBroker.getNewSection(sectClass); } // Check if either allocation failed if (theSection == 0) { opserr << "WARNING TrussSection::recvSelf() - " << this->getTag() << " failed to get a blank Section of type " << sectClass << endln; return -3; } theSection->setDbTag(sectDb); // note: we set the dbTag before we receive the Section res = theSection->recvSelf(commitTag, theChannel, theBroker); if (res < 0) { opserr << "WARNING TrussSection::recvSelf() - " << this->getTag() << " failed to receive its Section\n"; return -3; } return 0; }
int MP_Joint2D::sendSelf(int commitTag, Channel &theChannel) { Vector data(15); int dataTag = this->getDbTag(); data(0) = this->getTag(); data(1) = nodeRetained; data(2) = nodeConstrained; data(3) = MainDOF; data(4) = AuxDOF; data(5) = FixedEnd; if (constrDOF == 0) data(6) = 0; else data(6) = constrDOF->Size(); if (retainDOF == 0) data(7) = 0; else data(7) = retainDOF->Size(); if (constraint == 0) data(8) = 0; else data(8) = constraint->noRows(); if (constraint == 0) data(9) = 0; else data(9) = constraint->noCols(); // need two database tags for ID objects if (constrDOF != 0 && dbTag1 == 0) dbTag1 = theChannel.getDbTag(); if (retainDOF != 0 && dbTag2 == 0) dbTag2 = theChannel.getDbTag(); if (constraint != 0 && dbTag3 == 0) dbTag3 = theChannel.getDbTag(); data(10) = dbTag1; data(11) = dbTag2; data(12) = dbTag3; data(13) = LargeDisplacement; data(14) = Length0; // now send the data vector int result = theChannel.sendVector(dataTag, commitTag, data); if (result < 0) { opserr << "WARNING MP_Joint2D::sendSelf - error sending ID data\n"; return result; } // send constrDOF if (constrDOF != 0 && constrDOF->Size() != 0) { int result = theChannel.sendID(dbTag1, commitTag, *constrDOF); if (result < 0) { opserr << "WARNING MP_Joint2D::sendSelf "; opserr << "- error sending constrained DOF data\n"; return result; } } // send retainDOF if (retainDOF != 0 && retainDOF->Size() != 0) { int result = theChannel.sendID(dbTag2, commitTag, *retainDOF); if (result < 0) { opserr << "WARNING MP_Joint2D::sendSelf "; opserr << "- error sending retained DOF data\n"; return result; } } // send constraint matrix if (constraint != 0 && constraint->noRows() != 0) { int result = theChannel.sendMatrix(dbTag3, commitTag, *constraint); if (result < 0) { opserr << "WARNING MP_Joint2D::sendSelf "; opserr << "- error sending constraint Matrix data\n"; return result; } } return 0; }
int ReinforceConcretePlaneStress::sendSelf(int commitTag, Channel &theChannel) { int res = 0; int dataTag = this->getDbTag(); // Packs its data into a Vector and sends this to theChannel static Vector data(9); data(0) = this->getTag(); data(1) = rho; data(2) = angle1; data(3) = angle2; data(4) = rou1; data(5) = rou2; data(6) = fpc; data(7) = fy; data(8) = E0; res += theChannel.sendVector(dataTag, commitTag, data); if (res < 0) { opserr << "WARNING ReinforceConcretePlaneStress::sendSelf() - " << this->getTag() << " failed to send Vector\n"; return res; } // Now sends the IDs of its materials int matDbTag; static ID idData(8); // NOTE: to ensure that the material has a database // tag if sending to a database channel. for (int i=0; i<4; i++) { idData(i) = theMaterial[i]->getClassTag(); matDbTag = theMaterial[i]->getDbTag(); if (matDbTag == 0) { matDbTag = theChannel.getDbTag(); if (matDbTag != 0) theMaterial[i]->setDbTag(matDbTag); } idData(i+4) = matDbTag; } res += theChannel.sendID(dataTag, commitTag, idData); if (res < 0) { opserr << "WARNING ReinforceConcretePlaneStress::sendSelf() - " << this->getTag() << " failed to send ID\n"; return res; } // Finally, quad asks its material objects to send themselves for (int i = 0; i < 4; i++) { res += theMaterial[i]->sendSelf(commitTag, theChannel); if (res < 0) { opserr << "ReinforceConcretePlaneStress::sendSelf() - " << this->getTag() << " failed to send its Material\n"; return res; } } return res; }
spSoundInstance SoundPlayer::play(Resource *ressound_, bool looping, unsigned int fadeInMS, unsigned int fadeOutMS, float primaryVolume, bool pause, Channel *continueChannel) { ResSound *ressound = safeCast<ResSound*>(ressound_); spSoundInstance s = new SoundInstance(); s->_player = this; if ( primaryVolume < 0.f ) { primaryVolume = _volume; } if (!ressound || !ressound->getSound()) return s; //printf("PlayResSound:\n"); Channel *channel = continueChannel; if (!channel) channel = SoundSystem::instance->getFreeChannel(); if (!channel) return s; sound_desc desc; desc.sound = ressound->getSound(); desc.cbDone = _onSoundDone; desc.cbAboutEnd = _onSoundAboutDone; desc.cbUserData = s.get(); desc.looping = looping; desc.id = ressound->getName(); desc.volume = primaryVolume; desc.paused = pause; s->_desc = desc; s->_channel = channel; s->_startTime = getTime(); s->_startFadeIn = 0; s->_fadeInMS = fadeInMS; if (looping) s->_startFadeOut = 0; else s->_startFadeOut = desc.sound->getDuration() - fadeOutMS; s->_fadeOutMS = fadeOutMS; s->_volume = primaryVolume; s->_state = SoundInstance::Normal; if (fadeInMS) { s->_state = SoundInstance::FadingIn; desc.volume = 0.0f; } _sounds.push_back(s); if (continueChannel) channel->continuePlay(desc); else channel->play(desc); return s; }
void ChannelSelector::buttonClicked(Button* button) { //checkChannelSelectors(); if (button == paramsButton) { // make sure param buttons are visible allButton->setState(true); desiredOffset = parameterOffset; startTimer(20); return; } else if (button == audioButton) { // make sure audio buttons are visible if (audioButton->getState()) { allButton->setState(false); desiredOffset = audioOffset; startTimer(20); } else { paramsButton->setToggleState(true, dontSendNotification); } return; } else if (button == recordButton) { // make sure record buttons are visible; if (recordButton->getState()) { allButton->setState(true); desiredOffset = recordOffset; startTimer(20); } else { paramsButton->setToggleState(true, dontSendNotification); } return; } else if (button == allButton) { // select all active buttons if (offsetLR == recordOffset) { for (int i = 0; i < recordButtonsManager.getNumButtons(); ++i) { recordButtonsManager.getButtonAt (i)->setToggleState (true, sendNotification); } } else if (offsetLR == parameterOffset) { for (int i = 0; i < parameterButtonsManager.getNumButtons(); ++i) { parameterButtonsManager.getButtonAt (i)->setToggleState (true, sendNotification); } } else if (offsetLR == audioOffset) { // do nothing--> button is disabled } } else if (button == noneButton) { // deselect all active buttons if (offsetLR == recordOffset) { for (int i = 0; i < recordButtonsManager.getNumButtons(); ++i) { recordButtonsManager.getButtonAt (i)->setToggleState (false, sendNotification); } } else if (offsetLR == parameterOffset) { for (int i = 0; i < parameterButtonsManager.getNumButtons(); ++i) { parameterButtonsManager.getButtonAt (i)->setToggleState (false, sendNotification); } } else if (offsetLR == audioOffset) { for (int i = 0; i < audioButtonsManager.getNumButtons(); ++i) { audioButtonsManager.getButtonAt (i)->setToggleState (false, sendNotification); } } if (radioStatus) // if radio buttons are active { // send a message to parent GenericEditor* editor = (GenericEditor*) getParentComponent(); editor->channelChanged (-1, false); } } else { ChannelSelectorButton* b = (ChannelSelectorButton*)button; if (b->getType() == AUDIO) { // get audio node, and inform it of the change GenericEditor* editor = (GenericEditor*)getParentComponent(); Channel* ch = editor->getChannel(b->getChannel() - 1); //int channelNum = editor->getStartChannel() + b->getChannel() - 1; bool status = b->getToggleState(); std::cout << "Requesting audio monitor for channel " << ch->nodeIndex + 1 << std::endl; if (acquisitionIsActive) // use setParameter to change parameter safely { AccessClass::getProcessorGraph()-> getAudioNode()->setChannelStatus(ch, status); } else // change parameter directly { ch->isMonitored = status; } } else if (b->getType() == RECORD) { // get record node, and inform it of the change GenericEditor* editor = (GenericEditor*)getParentComponent(); Channel* ch = editor->getChannel(b->getChannel() - 1); //int channelNum = editor->getStartChannel() + b->getChannel() - 1; bool status = b->getToggleState(); if (acquisitionIsActive) // use setParameter to change parameter safely { AccessClass::getProcessorGraph()-> getRecordNode()-> setChannelStatus(ch, status); } else // change parameter directly { //std::cout << "Setting record status for channel " << b->getChannel() << std::endl; ch->setRecordState(status); } AccessClass::getGraphViewer()->repaint(); } else // parameter type { GenericEditor* editor = (GenericEditor*) getParentComponent(); editor->channelChanged (b->getChannel() - 1, b->getToggleState()); // do nothing if (radioStatus) // if radio buttons are active { // send a message to parent GenericEditor* editor = (GenericEditor*) getParentComponent(); editor->channelChanged (b->getChannel(), b->getToggleState()); } } } refreshParameterColors(); }
bool Window::processEvent( const Event& event ) { switch( event.type ) { case Event::WINDOW_HIDE: setPixelViewport( PixelViewport( 0, 0, 0, 0 )); break; case Event::WINDOW_SHOW: case Event::WINDOW_RESIZE: setPixelViewport( PixelViewport( event.resize.x, event.resize.y, event.resize.w, event.resize.h )); break; case Event::KEY_PRESS: case Event::KEY_RELEASE: if( event.key.key == KC_VOID ) return true; // ignore // else fall through case Event::WINDOW_EXPOSE: case Event::WINDOW_CLOSE: case Event::STATISTIC: case Event::MAGELLAN_AXIS: case Event::MAGELLAN_BUTTON: break; case Event::WINDOW_POINTER_GRAB: _grabbedChannels = _getEventChannels( event.pointer ); break; case Event::WINDOW_POINTER_UNGRAB: _grabbedChannels.clear(); break; case Event::WINDOW_POINTER_MOTION: case Event::WINDOW_POINTER_BUTTON_PRESS: case Event::WINDOW_POINTER_BUTTON_RELEASE: case Event::WINDOW_POINTER_WHEEL: { const Channels& channels = _getEventChannels( event.pointer ); for( Channels::const_iterator i = channels.begin(); i != channels.end(); ++i ) { Channel* channel = *i; Event channelEvent = event; switch( event.type ) { case Event::WINDOW_POINTER_MOTION: channelEvent.type = Event::CHANNEL_POINTER_MOTION; break; case Event::WINDOW_POINTER_BUTTON_PRESS: channelEvent.type = Event::CHANNEL_POINTER_BUTTON_PRESS; break; case Event::WINDOW_POINTER_BUTTON_RELEASE: channelEvent.type = Event::CHANNEL_POINTER_BUTTON_RELEASE; break; case Event::WINDOW_POINTER_WHEEL: channelEvent.type = Event::CHANNEL_POINTER_WHEEL; break; default: LBWARN << "Unhandled window event of type " << event.type << std::endl; LBUNIMPLEMENTED; } // convert y to GL notation (Channel PVP uses GL coordinates) const PixelViewport& pvp = getPixelViewport(); const int32_t y = pvp.h - event.pointer.y; const PixelViewport& channelPVP = channel->getNativePixelViewport(); channelEvent.originator = channel->getID(); channelEvent.serial = channel->getSerial(); channelEvent.pointer.x -= channelPVP.x; channelEvent.pointer.y = channelPVP.h - y + channelPVP.y; channel->processEvent( channelEvent ); } break; } case Event::WINDOW_SCREENSAVER: switch( getIAttribute( IATTR_HINT_SCREENSAVER )) { case OFF: return true; // screen saver stays inactive case ON: return false; // screen saver becomes active default: // AUTO if( getDrawableConfig().doublebuffered && getIAttribute( IATTR_HINT_DRAWABLE ) == WINDOW ) { return true; // screen saver stays inactive } return false; } case Event::UNKNOWN: // unknown window-system native event, which was not handled return false; default: LBWARN << "Unhandled window event of type " << event.type << std::endl; LBUNIMPLEMENTED; } Config* config = getConfig(); ConfigEvent configEvent; configEvent.data = event; config->sendEvent( configEvent ); return true; }
int PySimple1::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int res = 0; static Vector data(39); res = theChannel.recvVector(this->getDbTag(), cTag, data); if (res < 0) { opserr << "PySimple1::recvSelf() - failed to receive data\n"; CNF_tang = 0; this->setTag(0); } else { this->setTag((int)data(0)); soilType = (int)data(1); pult = data(2); y50 = data(3); drag = data(4); dashpot = data(5); yref = data(6); np = data(7); Elast = data(8); nd = data(9); NFkrig = data(10); CNFpinr = data(11); CNFpinl = data(12); CNFyinr = data(13); CNFyinl = data(14); CNF_p = data(15); CNF_y = data(16); CNF_tang = data(17); CDrag_pin = data(18); CDrag_yin = data(19); CDrag_p = data(20); CDrag_y = data(21); CDrag_tang= data(22); CClose_yleft = data(23); CClose_yright= data(24); CClose_p = data(25); CClose_y = data(26); CClose_tang = data(27); CGap_y = data(28); CGap_p = data(29); CGap_tang = data(30); CFar_y = data(31); CFar_p = data(32); CFar_tang = data(33); Cy = data(34); Cp = data(35); Ctangent = data(36); TyRate = data(37); initialTangent = data(38); // set the trial quantities this->revertToLastCommit(); } return res; }
int NormElementRecorder::sendSelf(int commitTag, Channel &theChannel) { addColumnInfo = 1; if (theChannel.isDatastore() == 1) { opserr << "NormElementRecorder::sendSelf() - does not send data to a datastore\n"; return -1; } initializationDone = false; // // into an ID, place & send (*eleID) size, numArgs and length of all responseArgs // static ID idData(7); if (eleID != 0) idData(0) = eleID->Size(); else idData(0) = 0; idData(1) = numArgs; int msgLength = 0; for (int i=0; i<numArgs; i++) msgLength += strlen(responseArgs[i])+1; idData(2) = msgLength; if (theOutputHandler != 0) { idData(3) = theOutputHandler->getClassTag(); } else idData(3) = 0; if (echoTimeFlag == true) idData(4) = 1; else idData(4) = 0; idData(5) = this->getTag(); idData(6) = numDOF; if (theChannel.sendID(0, commitTag, idData) < 0) { opserr << "NormElementRecorder::sendSelf() - failed to send idData\n"; return -1; } static Vector dData(2); dData(0) = deltaT; dData(1) = nextTimeStampToRecord; if (theChannel.sendVector(0, commitTag, dData) < 0) { opserr << "NormElementRecorder::sendSelf() - failed to send dData\n"; return -1; } // // send the eleID // if (eleID != 0) if (theChannel.sendID(0, commitTag, *eleID) < 0) { opserr << "NormElementRecorder::sendSelf() - failed to send idData\n"; return -1; } // send dof if (dof != 0) if (theChannel.sendID(0, commitTag, *dof) < 0) { opserr << "ElementRecorder::sendSelf() - failed to send dof\n"; return -1; } // // create a single char array holding all strings // will use string terminating character to differentiate strings on other side // if (msgLength == 0) { opserr << "NormElementRecorder::sendSelf() - no data to send!!\n"; return -1; } char *allResponseArgs = new char[msgLength]; if (allResponseArgs == 0) { opserr << "NormElementRecorder::sendSelf() - out of memory\n"; return -1; } char *currentLoc = allResponseArgs; for (int j=0; j<numArgs; j++) { strcpy(currentLoc, responseArgs[j]); currentLoc += strlen(responseArgs[j]); currentLoc++; } // // send this single char array // Message theMessage(allResponseArgs, msgLength); if (theChannel.sendMsg(0, commitTag, theMessage) < 0) { opserr << "NormElementRecorder::sendSelf() - failed to send message\n"; return -1; } // // invoke sendSelf() on the output handler // if (theOutputHandler == 0 || theOutputHandler->sendSelf(commitTag, theChannel) < 0) { opserr << "NormElementRecorder::sendSelf() - failed to send the DataOutputHandler\n"; return -1; } // // clean up & return success // delete [] allResponseArgs; return 0; }
void RGBColor::addValue(const Channel & channel, double addvalue) { if (channel.isPrimaryColorChannel()) { double nowvalue = this->getValue(channel); this->setValue(channel, nowvalue + addvalue); } };
bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) { int priority = GetPriority(sound); // Seeks a channel used which sound is stopped. for (auto it : mChannels) { if (it.second->IsPlaying()) continue; if (it.second->GetSoundType() != sound) continue; it.second->SetPriority(priority); channel = it.first; bAlreadyLoaded = it.second->IsLoaded(); return true; } // just add a new channel if we dont have any if (mChannels.size() == 0) { Channel *chn = new Channel(); // check if we channel ready to play music, if not report error if (chn->IsReady()) { chn->SetPriority(priority); mChannels[1] = chn; channel = 1; bAlreadyLoaded = false; return true; } delete chn; GetLogger()->Error("Could not open channel to play sound!"); return false; } // Seeks a channel completely free. if (mChannels.size() < 64) { auto it = mChannels.end(); it--; int i = (*it).first; while (++i) { if (mChannels.find(i) == mChannels.end()) { Channel *chn = new Channel(); // check if channel is ready to play music, if not destroy it and seek free one if (chn->IsReady()) { chn->SetPriority(priority); mChannels[++i] = chn; channel = i; bAlreadyLoaded = false; return true; } delete chn; GetLogger()->Warn("Could not open additional channel to play sound!"); } } } int lowerOrEqual = -1; for (auto it : mChannels) { if (it.second->GetPriority() < priority) { GetLogger()->Debug("Sound channel with lower priority will be reused."); channel = it.first; return true; } if (it.second->GetPriority() <= priority) lowerOrEqual = it.first; } if (lowerOrEqual != -1) { channel = lowerOrEqual; GetLogger()->Debug("Sound channel with lower or equal priority will be reused."); return true; } GetLogger()->Warn("Could not find free buffer to use.\n"); return false; }
int ParallelMaterial::recvSelf(int cTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int res = 0; static ID data(3); int dbTag = this->getDbTag(); res = theChannel.recvID(dbTag, cTag, data); if (res < 0) { opserr << "ParallelMaterial::recvSelf() - failed to receive data\n"; return res; } this->setTag(int(data(0))); int numMaterialsSent = int(data(1)); if (numMaterials != numMaterialsSent) { numMaterials = numMaterialsSent; if (theModels != 0) { for (int i=0; i<numMaterials; i++) delete theModels[i]; delete [] theModels; } theModels = new UniaxialMaterial *[numMaterials]; if (theModels == 0) { opserr << "FATAL ParallelMaterial::recvSelf() - ran out of memory"; opserr << " for array of size: " << numMaterials << "\n"; return -2; } for (int i=0; i<numMaterials; i++) theModels[i] = 0; } if (data(2) == 1) { theFactors = new Vector(numMaterials); res = theChannel.recvVector(dbTag, cTag, *theFactors); if (res < 0) { opserr << "ParallelMaterial::recvSelf() - failed to receive factors\n"; return res; } } // create and receive an ID for the classTags and dbTags of the local // MaterialModel objects ID classTags(numMaterials*2); res = theChannel.recvID(dbTag, cTag, classTags); if (res < 0) { opserr << "ParallelMaterial::recvSelf() - failed to receive classTags\n"; return res; } // now for each of the MaterialModel objects, create a new object // and invoke recvSelf() on it for (int i=0; i<numMaterials; i++) { int matClassTag = classTags(i); if (theModels[i] == 0 || theModels[i]->getClassTag() != matClassTag) { if (theModels[i] == 0) delete theModels[i]; UniaxialMaterial *theMaterialModel = theBroker.getNewUniaxialMaterial(matClassTag); if (theMaterialModel != 0) { theModels[i] = theMaterialModel; theMaterialModel->setDbTag(classTags(i+numMaterials)); } else { opserr << "FATAL ParallelMaterial::recvSelf() "; opserr << " could not get a UniaxialMaterial \n"; exit(-1); } } theModels[i]->recvSelf(cTag, theChannel, theBroker); } return 0; }
void ServiceProcess::HandleReadEvent() { Channel* ch = GetIPCChannel(); ch->HandleReadEvent(); }
int ElastomericBearingBoucWen2d::recvSelf(int commitTag, Channel &rChannel, FEM_ObjectBroker &theBroker) { // delete material memory for (int i=0; i<2; i++) if (theMaterials[i] != 0) delete theMaterials[i]; // receive element parameters static Vector data(21); rChannel.recvVector(0, commitTag, data); this->setTag((int)data(0)); k0 = data(1); qYield = data(2); k2 = data(3); k3 = data(4); mu = data(5); eta = data(6); beta = data(7); gamma = data(8); A = data(9); shearDistI = data(10); addRayleigh = (int)data(11); mass = data(12); maxIter = (int)data(13); tol = data(14); alphaM = data(17); betaK = data(18); betaK0 = data(19); betaKc = data(20); // receive the two end nodes rChannel.recvID(0, commitTag, connectedExternalNodes); // receive the material class tags ID matClassTags(2); rChannel.recvID(0, commitTag, matClassTags); // receive the material models for (int i=0; i<2; i++) { theMaterials[i] = theBroker.getNewUniaxialMaterial(matClassTags(i)); if (theMaterials[i] == 0) { opserr << "ElastomericBearingBoucWen2d::recvSelf() - " << "failed to get blank uniaxial material.\n"; return -2; } theMaterials[i]->recvSelf(commitTag, rChannel, theBroker); } // receive remaining data if ((int)data(15) == 3) { x.resize(3); rChannel.recvVector(0, commitTag, x); } if ((int)data(16) == 3) { y.resize(3); rChannel.recvVector(0, commitTag, y); } onP0 = false; // initialize initial stiffness matrix kbInit.Zero(); kbInit(0,0) = theMaterials[0]->getInitialTangent(); kbInit(1,1) = A*k0 + k2; kbInit(2,2) = theMaterials[1]->getInitialTangent(); // initialize other variables this->revertToStart(); return 0; }
bool msgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { if(msg == WM_SIZE) { updateBounds(hwnd); } if(msg == WM_PAINT) { updateBounds(hwnd); updateGraph(hwnd); } if(msg == WM_DESTROY) { //SendMessage(GetParent(hwnd), WM_GRAPH_CHANGED, 0, 0); bClosed = true; } if(msg == WM_CREATE) { updateGraph(hwnd); } if(msg == WM_LBUTTONDBLCLK) { // POINT point; //GetCursorPos(&point); int xPos = LOWORD(lParam); int yPos = HIWORD(lParam); RECT rect; GetClientRect(hwnd, &rect); if((xPos >= rect.left) && (xPos <= rect.right) && (yPos >= rect.top) && (yPos <= rect.bottom)) { float x = toGraphX(xPos); float y = toGraphY(rect.bottom - yPos); for(int i = 0; i < mChannels.size(); i++) { Channel* c = &mChannels[i]; c->insertKey(x); } } updateGraph(hwnd); } if((msg == WM_MOUSEMOVE) && mLocked) { if(wParam != MK_LBUTTON) { mLocked = false; } else { POINT point; point.x = LOWORD(lParam); point.y = HIWORD(lParam); /* //GetCursorPos(&point); RECT rect; GetClientRect(hwnd, &rect); float x = (float)(point.x - rect.left) / (float)(rect.right - rect.left); float y = 1.0f - (float)(point.y - rect.top) / (float)(rect.bottom - rect.top); float dx = x - mOldX; float dy = y - mOldY; */ RECT rc; GetClientRect(hwnd, &rc); float x = toGraphX(point.x); float y = toGraphY(rc.bottom - point.y); Channel* c = &mChannels[mLockedChannel]; c->moveKey(x,y,mXTreshold, ymin, ymax); mOldX = x; mOldY = y; } updateGraph(hwnd); } if((msg == WM_LBUTTONDOWN) & !mLocked) { POINT point; //GetCursorPos(&point); point.x = LOWORD(lParam); point.y = HIWORD(lParam); RECT rc; GetClientRect(hwnd, &rc); // float x = (float)(point.x - rect.left) / (float)(rect.right - rect.left); // float y = 1.0f - (float)(point.y - rect.top) / (float)(rect.bottom - rect.top); float x = toGraphX(point.x); float y = toGraphY(rc.bottom - point.y); for(int i = 0; i < mChannels.size(); i++) { Channel* c = &mChannels[i]; if(c->lockKey(x, y, mXTreshold, mYTreshold)) { mLockedChannel = i; mLocked = true; mOldX = x; mOldY = y; break; } } } return false; }
int NormElementRecorder::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { addColumnInfo = 1; if (theChannel.isDatastore() == 1) { opserr << "NormElementRecorder::recvSelf() - does not recv data to a datastore\n"; return -1; } if (responseArgs != 0) { for (int i=0; i<numArgs; i++) delete [] responseArgs[i]; delete [] responseArgs; } // // into an ID of size 2 recv eleID size and length of all responseArgs // static ID idData(7); if (theChannel.recvID(0, commitTag, idData) < 0) { opserr << "NormElementRecorder::recvSelf() - failed to recv idData\n"; return -1; } int eleSize = idData(0); numArgs = idData(1); int msgLength = idData(2); this->setTag(idData(5)); if (idData(4) == 1) echoTimeFlag = true; else echoTimeFlag = false; numEle = eleSize; numDOF = idData(6); static Vector dData(2); if (theChannel.recvVector(0, commitTag, dData) < 0) { opserr << "NormElementRecorder::sendSelf() - failed to send dData\n"; return -1; } deltaT = dData(0); nextTimeStampToRecord = dData(1); // // resize & recv the eleID // if (eleSize != 0) { eleID = new ID(eleSize); if (eleID == 0) { opserr << "NormElementRecorder::recvSelf() - failed to recv idData\n"; return -1; } if (theChannel.recvID(0, commitTag, *eleID) < 0) { opserr << "NormElementRecorder::recvSelf() - failed to recv idData\n"; return -1; } } // // resize & recv the dof // if (numDOF != 0) { dof = new ID(numDOF); if (dof == 0) { opserr << "ElementRecorder::recvSelf() - failed to create dof\n"; return -1; } if (theChannel.recvID(0, commitTag, *dof) < 0) { opserr << "ElementRecorder::recvSelf() - failed to recv dof\n"; return -1; } } // // recv the single char array of element response args // if (msgLength == 0) { opserr << "NormElementRecorder::recvSelf() - 0 sized string for responses\n"; return -1; } char *allResponseArgs = new char[msgLength]; if (allResponseArgs == 0) { opserr << "NormElementRecorder::recvSelf() - out of memory\n"; return -1; } Message theMessage(allResponseArgs, msgLength); if (theChannel.recvMsg(0, commitTag, theMessage) < 0) { opserr << "NormElementRecorder::recvSelf() - failed to recv message\n"; return -1; } // // now break this single array into many // responseArgs = new char *[numArgs]; if (responseArgs == 0) { opserr << "NormElementRecorder::recvSelf() - out of memory\n"; return -1; } char *currentLoc = allResponseArgs; for (int j=0; j<numArgs; j++) { int argLength = strlen(currentLoc)+1; responseArgs[j] = new char[argLength]; if (responseArgs[j] == 0) { opserr << "NormElementRecorder::recvSelf() - out of memory\n"; return -1; } strcpy(responseArgs[j], currentLoc); currentLoc += argLength; } // // create a new handler object and invoke recvSelf() on it // if (theOutputHandler != 0) delete theOutputHandler; theOutputHandler = theBroker.getPtrNewStream(idData(3)); if (theOutputHandler == 0) { opserr << "NodeRecorder::sendSelf() - failed to get a data output handler\n"; return -1; } if (theOutputHandler->recvSelf(commitTag, theChannel, theBroker) < 0) { opserr << "NodeRecorder::sendSelf() - failed to send the DataOutputHandler\n"; return -1; } // // clean up & return success // delete [] allResponseArgs; return 0; }
void setColourFromChannel(Channel &channel) override { shared_ptr<PixelCache> pixels; mColours.clear(); for (auto half : mHalves) { try { pixels = PixelCache::pixelCache.at(half->getId()); } catch (std::out_of_range e) { float radius = mSideLength / 2.0f; auto freshHalf = HalfTriangle::create(vec2(0), half->mSideLength, half->mOrientation, half->mRotation, half->mSide); PixelCache::pixelCache.emplace(freshHalf->getId(), PixelCache::create(*freshHalf.get(), radius)); assert(freshHalf->getId() == half->getId()); pixels = PixelCache::pixelCache.at(half->getId()); } auto *channelData = channel.getData(); uint32_t pixelSum = 0; float nPixels = 0; for (auto &offset : pixels->mInsidePositions) { ivec2 pos = ivec2(mOffset.x, mOffset.y) + offset; if (channel.getBounds().contains(pos)) { pixelSum += uint32_t(channelData[pos.x + pos.y * channel.getRowBytes()]); nPixels++; } } float v = pixelSum / 255.0f / nPixels; float d = cols.size(); v = std::floor(v * d) / d; half->mColour = Color(v, v, v); int index = size_t(std::floor(v * d)); if (glm::distance(vec2(413, 366), this->mCenter) > 130 && glm::distance(vec2(737,370), this->mCenter) > 130) { int rmax = 6; auto r = glm::linearRand(0, rmax); if (r == 0) { if (index == 0) index++; else if (index == 1) index--; else index-= 2; } else if (r == rmax) { if (index + 1 == cols.size() - 1) index+= 1; else if (index == cols.size() - 1) index--; else index+= 2; } else if (r == 1) { if (index == 0) index++; else index--; } else if (r == rmax - 1) { if (index == cols.size() - 1) index--; else index++; } } half->mColour = cols[index]; half->mColourIndex = index; } }
int SingleFPSimple2d::recvSelf(int commitTag, Channel &rChannel, FEM_ObjectBroker &theBroker) { // delete material memory for (int i=0; i<2; i++) if (theMaterials[i] != 0) delete theMaterials[i]; // receive element parameters static Vector data(15); rChannel.recvVector(0, commitTag, data); this->setTag((int)data(0)); Reff = data(1); kInit = data(2); shearDistI = data(3); addRayleigh = (int)data(4); mass = data(5); maxIter = (int)data(6); tol = data(7); kFactUplift = data(8); alphaM = data(11); betaK = data(12); betaK0 = data(13); betaKc = data(14); // receive the two end nodes rChannel.recvID(0, commitTag, connectedExternalNodes); // receive the friction model class tag ID frnClassTag(1); rChannel.recvID(0, commitTag, frnClassTag); // receive the friction model theFrnMdl = theBroker.getNewFrictionModel(frnClassTag(0)); if (theFrnMdl == 0) { opserr << "SingleFPSimple2d::recvSelf() - " << "failed to get blank friction model.\n"; return -1; } theFrnMdl->recvSelf(commitTag, rChannel, theBroker); // receive the material class tags ID matClassTags(2); rChannel.recvID(0, commitTag, matClassTags); // receive the material models for (int i=0; i<2; i++) { theMaterials[i] = theBroker.getNewUniaxialMaterial(matClassTags(i)); if (theMaterials[i] == 0) { opserr << "SingleFPSimple2d::recvSelf() - " << "failed to get blank uniaxial material.\n"; return -2; } theMaterials[i]->recvSelf(commitTag, rChannel, theBroker); } // receive remaining data if ((int)data(9) == 3) { x.resize(3); rChannel.recvVector(0, commitTag, x); } if ((int)data(10) == 3) { y.resize(3); rChannel.recvVector(0, commitTag, y); } onP0 = false; // initialize initial stiffness matrix kbInit.Zero(); kbInit(0,0) = theMaterials[0]->getInitialTangent(); kbInit(1,1) = kInit; kbInit(2,2) = theMaterials[1]->getInitialTangent(); // initialize other variables this->revertToStart(); return 0; }
// ---------------------------------------------------------------------------- // bool HttpRestServices::query_scenes( CString& response, LPCSTR data ) { if ( !studio.getVenue() || !studio.getVenue()->isRunning() ) return false; JsonBuilder json( response ); json.startArray(); ScenePtrArray scenes = studio.getVenue()->getScenes(); std::sort( scenes.begin(), scenes.end(), CompareObjectNumber ); Scene* default_scene = studio.getVenue()->getDefaultScene(); UID active_uid = studio.getVenue()->getCurrentSceneUID(); for ( ScenePtrArray::iterator it=scenes.begin(); it != scenes.end(); it++ ) { Scene* scene = (*it); json.startObject(); json.add( "id", scene->getUID() ); json.add( "number", scene->getSceneNumber() ); json.add( "name", scene->getName() ); json.add( "bpm_rating", scene->getBPMRating() ); json.add( "description", scene->getDescription() ); json.add( "is_default", (scene == default_scene) ); json.add( "is_running", (active_uid == scene->getUID()) ); json.addArray<Acts>( "acts", scene->getActs() ); json.startArray( "actors" ); ActorPtrArray actors = scene->getActors(); for ( ActorPtrArray::iterator it=actors.begin(); it != actors.end(); ++it ) { Fixture* fixture = NULL; json.startObject(); json.add( "id", (*it)->getActorUID() ); json.add( "is_group", (*it)->isGroup() ); if ( (*it)->isGroup() ) { fixture = studio.getVenue()->getGroupRepresentative( (*it)->getActorUID() ); } else { fixture = studio.getVenue()->getFixture( (*it)->getActorUID() ); json.add( "address", (int)fixture->getAddress() ); } json.startArray( "channels" ); if ( fixture != NULL ) { for ( channel_t channel=0; channel < fixture->getNumChannels(); channel++ ) { Channel* ch = fixture->getChannel( channel ); BYTE value = (*it)->getChannelValue( fixture->mapChannel( channel ) ); ChannelValueRange* range = ch->getRange( value ); LPCSTR range_name = range ? range->getName() : ""; json.startObject(); json.add( "channel", (int)channel ); json.add( "name", ch->getName() ); json.add( "value", value ); json.add( "range_name", range_name ); json.endObject(); } } json.endArray( "channels" ); json.endObject(); } json.endArray( "actors" ); json.startArray( "animations" ); for ( size_t a=0; a < scene->getNumAnimations(); a++ ) { AbstractAnimation* animation = scene->getAnimation( a ); json.startObject(); json.add( "class_name", animation->getClassName() ); json.add( "name", animation->getName() ); json.add( "number", animation->getNumber() ); json.addArray<UIDArray>( "actors", animation->getActors() ); // Add common signal data AnimationSignal& signal = animation->signal(); json.startObject( "signal" ); json.add( "sample_rate_ms", signal.getSampleRateMS() ); json.add( "input_type", signal.getInputType() ); json.add( "input_low", signal.getInputLow() ); json.add( "input_high", signal.getInputHigh() ); json.add( "sample_decay_ms", signal.getSampleDecayMS() ); json.add( "scale_factor", signal.getScaleFactor() ); json.add( "max_threshold", signal.getMaxThreshold() ); json.add( "apply_to", signal.getApplyTo() ); json.endObject(); // Add animation specific data CString json_anim_name = JsonObject::encodeJsonString( animation->getClassName() ); json.startObject( json_anim_name ); if ( !strcmp( animation->getClassName(), SceneStrobeAnimator::className ) ) { SceneStrobeAnimator* ssa = (SceneStrobeAnimator*)animation; json.add( "strobe_neg_color", ssa->getStrobeNegColor() ); json.add( "strobe_pos_ms", ssa->getStrobePosMS() ); json.add( "strobe_neg_ms", ssa->getStrobeNegMS() ); } else if ( !strcmp( animation->getClassName(), ScenePatternDimmer::className ) ) { ScenePatternDimmer* spd = (ScenePatternDimmer*)animation; json.add( "dimmer_pattern", spd->getDimmerPattern() ); } else if ( !strcmp( animation->getClassName(), SceneSoundLevel::className ) ) { SceneSoundLevel* ssl = (SceneSoundLevel*)animation; json.add( "fade_what", ssl->getFadeWhat() ); } else if ( !strcmp( animation->getClassName(), SceneColorFader::className ) ) { SceneColorFader* scs = (SceneColorFader*)animation; json.add( "fader_effect", scs->getFaderEffect() ); json.add( "strobe_neg_color", scs->getStrobeNegColor() ); json.add( "strobe_pos_ms", scs->getStrobePosMS() ); json.add( "strobe_neg_ms", scs->getStrobeNegMS() ); json.addColorArray<RGBWAArray>( "color_progression", scs->getCustomColors() ); } else if ( !strcmp( animation->getClassName(), ScenePixelAnimator::className ) ) { ScenePixelAnimator* spa = (ScenePixelAnimator*)animation; json.add( "pixel_effect", spa->getEffect() ); json.add( "generations", spa->getGenerations() ); json.add( "pixels", spa->getPixels() ); json.add( "increment", spa->getIncrement() ); json.add( "fade", spa->isFadeColors() ); json.add( "combine", spa->getCombineFixtures() ); json.add( "pixel_off_color", spa->getEmptyColor() ); json.addColorArray<RGBWAArray>( "color_progression", spa->getCustomColors() ); } else if ( !strcmp( animation->getClassName(), SceneChannelFilter::className ) ) { SceneChannelFilter* scf = (SceneChannelFilter*)animation; json.add( "filter", scf->getFilter() ); json.add( "channel", scf->getChannel() ); json.add( "step", scf->getStep() ); json.add( "amplitude", scf->getAmplitude() ); json.add( "offset", scf->getOffset() ); } else if ( !strcmp( animation->getClassName(), SceneMovementAnimator::className ) ) { SceneMovementAnimator* sma = (SceneMovementAnimator*)animation; MovementAnimation& movement = sma->movement(); json.add( "movement_type", movement.m_movement_type ); json.add( "tilt_start_angle", movement.m_tilt_start ); json.add( "tilt_end_angle", movement.m_tilt_end ); json.add( "pan_start_angle", movement.m_pan_start ); json.add( "pan_end_angle", movement.m_pan_end ); json.add( "pan_increment", movement.m_pan_increment ); json.add( "speed", movement.m_speed ); json.add( "home_wait_periods", movement.m_home_wait_periods ); json.add( "dest_wait_periods", movement.m_dest_wait_periods ); json.add( "group_size", movement.m_group_size ); json.add( "positions", movement.m_positions ); json.add( "alternate_groups", movement.m_alternate_groups ); json.add( "blackout_return", movement.m_backout_home_return ); json.add( "run_once", movement.m_run_once ); json.add( "home_x", movement.m_home_x ); json.add( "home_y", movement.m_home_y ); json.add( "height", movement.m_height ); json.add( "fixture_spacing", movement.m_fixture_spacing ); json.add( "radius", movement.m_radius ); json.add( "head_number", movement.m_head_number ); json.startArray( "coordinates" ); for ( size_t index=0; index < movement.m_coordinates.size(); index++ ) { json.startObject(); json.add( "pan", movement.m_coordinates[index].m_pan ); json.add( "tilt", movement.m_coordinates[index].m_tilt ); json.endObject(); } json.endArray( "coordinates" ); } else if ( !strcmp( animation->getClassName(), SceneChannelAnimator::className ) ) { SceneChannelAnimator* sca = (SceneChannelAnimator*)animation; ChannelAnimationArray& chan_anims = sca->channelAnimations(); json.startArray( "channel_animations" ); for ( ChannelAnimationArray::iterator it=chan_anims.begin(); it != chan_anims.end(); ++it ) { json.startObject(); json.add( "actor_uid", (*it).getActorUID() ); json.add( "channel", (*it).getChannel() ); json.add( "style", (*it).getAnimationStyle() ); json.addArray<ChannelValueArray>( "values", (*it).getChannelValues() ); json.endObject(); } json.endArray( "channel_animations" ); } json.endObject( json_anim_name ); json.endObject(); } json.endArray( "animations" ); json.endObject(); } json.endArray(); return true; }
// ----------------------------------- void PCPStream::readHostAtoms(AtomStream &atom, int numc, BroadcastState &bcs, ChanHit &hit, bool flg) { // ChanHit hit; hit.init(); GnuID chanID = bcs.chanID; //use default bool busy = false; unsigned int ipNum = 0; for (int i = 0; i < numc; i++) { int c, d; ID4 id = atom.read(c, d); if (id == PCP_HOST_IP) { unsigned int ip = atom.readInt(); hit.rhost[ipNum].ip = ip; } else if (id == PCP_HOST_PORT) { int port = atom.readShort(); hit.rhost[ipNum++].port = port; if (ipNum > 1) ipNum = 1; } else if (id == PCP_HOST_NUML) { hit.numListeners = atom.readInt(); if (hit.numListeners > 10) hit.numListeners = 10; } else if (id == PCP_HOST_NUMR) { hit.numRelays = atom.readInt(); if (hit.numRelays > 100) hit.numRelays = 100; } else if (id == PCP_HOST_UPTIME) hit.upTime = atom.readInt(); else if (id == PCP_HOST_OLDPOS) hit.oldestPos = atom.readInt(); else if (id == PCP_HOST_NEWPOS) hit.newestPos = atom.readInt(); else if (id == PCP_HOST_VERSION) hit.version = atom.readInt(); else if (id == PCP_HOST_VERSION_VP) hit.version_vp = atom.readInt(); else if (id == PCP_HOST_VERSION_EX_PREFIX) atom.readBytes(hit.version_ex_prefix, 2); else if (id == PCP_HOST_VERSION_EX_NUMBER) { hit.version_ex_number = atom.readShort(); } else if (id == PCP_HOST_FLAGS1) { int fl1 = atom.readChar(); hit.recv = (fl1 & PCP_HOST_FLAGS1_RECV) != 0; hit.relay = (fl1 & PCP_HOST_FLAGS1_RELAY) != 0; hit.direct = (fl1 & PCP_HOST_FLAGS1_DIRECT) != 0; hit.cin = (fl1 & PCP_HOST_FLAGS1_CIN) != 0; hit.tracker = (fl1 & PCP_HOST_FLAGS1_TRACKER) != 0; hit.firewalled = (fl1 & PCP_HOST_FLAGS1_PUSH) != 0; } else if (id == PCP_HOST_ID) atom.readBytes(hit.sessionID.id, 16); else if (id == PCP_HOST_CHANID) atom.readBytes(chanID.id, 16); else if (id == PCP_HOST_UPHOST_IP) hit.uphost.ip = atom.readInt(); else if (id == PCP_HOST_UPHOST_PORT) hit.uphost.port = atom.readInt(); else if (id == PCP_HOST_UPHOST_HOPS) hit.uphostHops = atom.readInt(); else if (id == PCP_HOST_CLAP_PP) { //JP-MOD hit.clap_pp = atom.readInt(); if (hit.clap_pp & 1) { Channel *c = chanMgr->findChannelByID(chanID); if (c && c->isBroadcasting()) { String sjis; sjis = c->info.name; #ifdef _WIN32 sjis.convertTo(String::T_SJIS); #endif peercastApp->notifyMessage(ServMgr::NT_APPLAUSE, sjis); } } } else { LOG_DEBUG("PCP skip: %s,%d,%d", id.getString().str(), c, d); atom.skip(c, d); } } hit.host = hit.rhost[0]; hit.chanID = chanID; hit.numHops = bcs.numHops; hit.servent_id = bcs.servent_id; if (flg && (bcs.ttl != 0)) { // LOG_DEBUG("readHostAtoms HITLISTLOCK ON-------------"); chanMgr->hitlistlock.on(); if (hit.recv) chanMgr->addHit(hit); else chanMgr->delHit(hit); // LOG_DEBUG("readHostAtoms HITLISTLOCK OFF-------------"); chanMgr->hitlistlock.off(); } if (hit.numHops == 1) { Servent *sv = servMgr->findServentByServentID(hit.servent_id); if (sv && sv->getHost().ip == hit.host.ip) { // LOG_DEBUG("set servent's waitPort = %d", hit.host.port); sv->waitPort = hit.host.port; //hit.lastSendSeq = sv->serventHit.lastSendSeq; sv->serventHit = hit; } } }
bool BeforeMode(User* source, User* dest, Channel* channel, std::string ¶m, bool adding) { /* nick!ident@host -> nick!ident@host * nick!ident@host#chan -> nick!ident@host#chan * nick@host#chan -> nick!*@host#chan * nick!ident#chan -> nick!ident@*#chan * nick#chan -> nick!*@*#chan */ if ((channel) && !param.empty()) { BanRedirectList* redirects; std::string mask[4]; enum { NICK, IDENT, HOST, CHAN } current = NICK; std::string::iterator start_pos = param.begin(); if (param.length() >= 2 && param[1] == ':') return true; if (param.find('#') == std::string::npos) return true; ListModeBase* banlm = static_cast<ListModeBase*>(*ban); unsigned int maxbans = banlm->GetLimit(channel); ListModeBase::ModeList* list = banlm->GetList(channel); if ((list) && (adding) && (maxbans <= list->size())) { source->WriteNumeric(ERR_BANLISTFULL, "%s :Channel ban list for %s is full (maximum entries for this channel is %u)", channel->name.c_str(), channel->name.c_str(), maxbans); return false; } for(std::string::iterator curr = start_pos; curr != param.end(); curr++) { switch(*curr) { case '!': if (current != NICK) break; mask[current].assign(start_pos, curr); current = IDENT; start_pos = curr+1; break; case '@': if (current != IDENT) break; mask[current].assign(start_pos, curr); current = HOST; start_pos = curr+1; break; case '#': if (current == CHAN) break; mask[current].assign(start_pos, curr); current = CHAN; start_pos = curr; break; } } if(mask[current].empty()) { mask[current].assign(start_pos, param.end()); } /* nick@host wants to be changed to *!nick@host rather than nick!*@host... */ if(mask[NICK].length() && mask[HOST].length() && mask[IDENT].empty()) { /* std::string::swap() is fast - it runs in constant time */ mask[NICK].swap(mask[IDENT]); } if (!mask[NICK].empty() && mask[IDENT].empty() && mask[HOST].empty()) { if (mask[NICK].find('.') != std::string::npos || mask[NICK].find(':') != std::string::npos) { mask[NICK].swap(mask[HOST]); } } for(int i = 0; i < 3; i++) { if(mask[i].empty()) { mask[i].assign("*"); } } param.assign(mask[NICK]).append(1, '!').append(mask[IDENT]).append(1, '@').append(mask[HOST]); if(mask[CHAN].length()) { if (adding && IS_LOCAL(source)) { if (!ServerInstance->IsChannel(mask[CHAN])) { source->WriteNumeric(ERR_NOSUCHCHANNEL, "%s :Invalid channel name in redirection (%s)", channel->name.c_str(), mask[CHAN].c_str()); return false; } Channel *c = ServerInstance->FindChan(mask[CHAN]); if (!c) { source->WriteNumeric(690, ":Target channel %s must exist to be set as a redirect.", mask[CHAN].c_str()); return false; } else if (adding && c->GetPrefixValue(source) < OP_VALUE) { source->WriteNumeric(690, ":You must be opped on %s to set it as a redirect.", mask[CHAN].c_str()); return false; } if (assign(channel->name) == mask[CHAN]) { source->WriteNumeric(690, "%s :You cannot set a ban redirection to the channel the ban is on", channel->name.c_str()); return false; } } if(adding) { /* It's a properly valid redirecting ban, and we're adding it */ redirects = extItem.get(channel); if (!redirects) { redirects = new BanRedirectList; extItem.set(channel, redirects); } /* Here 'param' doesn't have the channel on it yet */ redirects->push_back(BanRedirectEntry(mask[CHAN], param)); /* Now it does */ param.append(mask[CHAN]); } else { /* Removing a ban, if there's no extensible there are no redirecting bans and we're fine. */ redirects = extItem.get(channel); if (redirects) { /* But there were, so we need to remove the matching one if there is one */ for(BanRedirectList::iterator redir = redirects->begin(); redir != redirects->end(); redir++) { /* Ugly as f**k */ if((irc::string(redir->targetchan.c_str()) == irc::string(mask[CHAN].c_str())) && (irc::string(redir->banmask.c_str()) == irc::string(param.c_str()))) { redirects->erase(redir); if(redirects->empty()) { extItem.unset(channel); } break; } } } /* Append the channel so the default +b handler can remove the entry too */ param.append(mask[CHAN]); } } } return true; }
// ------------------------------------------ void PCPStream::readChanAtoms(AtomStream &atom, int numc, BroadcastState &bcs) { /* Channel *ch=NULL; ChanHitList *chl=NULL; ChanInfo newInfo; ch = chanMgr->findChannelByID(bcs.chanID); chl = chanMgr->findHitListByID(bcs.chanID); if (ch) newInfo = ch->info; else if (chl) newInfo = chl->info;*/ Channel *ch = NULL; ChanHitList *chl = NULL; ChanInfo newInfo, chaInfo; ch = this->parent; if (ch) { newInfo = ch->info; chaInfo = ch->info; } for (int i = 0; i < numc; i++) { int c, d; ID4 id = atom.read(c, d); if ((id == PCP_CHAN_PKT) && (ch)) { readPktAtoms(ch, atom, c, bcs); } else if (id == PCP_CHAN_INFO) { newInfo.readInfoAtoms(atom, c); } else if (id == PCP_CHAN_TRACK) { newInfo.readTrackAtoms(atom, c); } else if (id == PCP_CHAN_BCID) { atom.readBytes(newInfo.bcID.id, 16); } else if (id == PCP_CHAN_KEY) // depreciated { atom.readBytes(newInfo.bcID.id, 16); newInfo.bcID.id[0] = 0; // clear flags } else if (id == PCP_CHAN_ID) { atom.readBytes(newInfo.id.id, 16); ch = chanMgr->findChannelByID(newInfo.id); chl = chanMgr->findHitListByID(newInfo.id); } else { LOG_DEBUG("PCP skip: %s,%d,%d", id.getString().str(), c, d); atom.skip(c, d); } } chl = chanMgr->findHitList(newInfo); if (!chl) chl = chanMgr->addHitList(newInfo); if (chl) { chl->info.update(newInfo); if (!servMgr->chanLog.isEmpty()) { //if (chl->numListeners()) { try { FileStream file; file.openWriteAppend(servMgr->chanLog.cstr()); XML::Node *rn = new XML::Node("update time=\"%d\"", sys->getTime()); XML::Node *n = chl->info.createChannelXML(); n->add(chl->createXML(false)); n->add(chl->info.createTrackXML()); rn->add(n); rn->write(file, 0); delete rn; file.close(); } catch (StreamException &e) { LOG_ERROR("Unable to update channel log: %s", e.msg); } } } } if (ch && !ch->isBroadcasting()) ch->updateInfo(newInfo); }
int ReinforceConcretePlaneStress::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int res = 0; int dataTag = this->getDbTag(); // Quad creates a Vector, receives the Vector and then sets the // internal data with the data in the Vector static Vector data(9); res += theChannel.recvVector(dataTag, commitTag, data); if (res < 0) { opserr << "WARNING ReinforceConcretePlaneStress::recvSelf() - failed to receive Vector\n"; return res; } this->setTag((int)data(0)); rho = data(1); angle1 = data(2); angle2 = data(3); rou1 = data(4); rou2 = data(5); fpc = data(6); fy = data(7); E0 = data(8); static ID idData(8); // now receives the tags of its materials res += theChannel.recvID(dataTag, commitTag, idData); if (res < 0) { opserr << "WARNING ReinforceConcretePlaneStress::recvSelf() - " << this->getTag() << " failed to receive ID\n"; return res; } if (theMaterial == 0) { // Allocate new materials theMaterial = new UniaxialMaterial *[4]; if (theMaterial == 0) { opserr << "ReinforceConcretePlaneStress::recvSelf() - Could not allocate UniaxialMaterial* array\n"; return -1; } for (int i = 0; i < 4; i++) { int matClassTag = idData(i); int matDbTag = idData(i+4); // Allocate new material with the sent class tag theMaterial[i] = theBroker.getNewUniaxialMaterial(matClassTag); if (theMaterial[i] == 0) { opserr << "ReinforceConcretePlaneStress::recvSelf() - Broker could not create NDMaterial of class type " << matClassTag << endln; return -1; } // Now receive materials into the newly allocated space theMaterial[i]->setDbTag(matDbTag); res += theMaterial[i]->recvSelf(commitTag, theChannel, theBroker); if (res < 0) { opserr << "ReinforceConcretePlaneStress::recvSelf() - material " << i << "failed to recv itself\n"; return res; } } } // materials exist , ensure materials of correct type and recvSelf on them else { for (int i = 0; i < 4; i++) { int matClassTag = idData(i); int matDbTag = idData(i+4); // Check that material is of the right type; if not, // delete it and create a new one of the right type if (theMaterial[i]->getClassTag() != matClassTag) { delete theMaterial[i]; theMaterial[i] = theBroker.getNewUniaxialMaterial(matClassTag); if (theMaterial[i] == 0) { opserr << "ReinforceConcretePlaneStress::recvSelf() - material " << i << "failed to create\n"; return -1; } } // Receive the material theMaterial[i]->setDbTag(matDbTag); res += theMaterial[i]->recvSelf(commitTag, theChannel, theBroker); if (res < 0) { opserr << "ReinforceConcretePlaneStress::recvSelf() - material " << i << "failed to recv itself\n"; return res; } } } return res; }
// ------------------------------------------ int PCPStream::procAtom(AtomStream &atom, ID4 id, int numc, int dlen, BroadcastState &bcs) { int r = 0; ChanHit hit; int rBan = 0; if (id == PCP_CHAN) { readChanAtoms(atom, numc, bcs); } else if (id == PCP_ROOT) { if (servMgr->isRoot) throw StreamException("Unauthorized root message"); else readRootAtoms(atom, numc, bcs); } else if (id == PCP_HOST) { readHostAtoms(atom, numc, bcs, hit); Channel *ch = chanMgr->findChannelByID(hit.chanID); if (ch && (ch->isBroadcasting() || servMgr->vpDebug)) { if (servMgr->autoPort0Kick && (hit.numHops == 1) && (hit.firewalled || (!hit.relay && !hit.numRelays))) { char tmp[32]; hit.host.IPtoStr(tmp); LOG_DEBUG("host that can't relay is disconnect: %s", tmp); rBan = PCP_ERROR_BANNED; } if (servMgr->allowOnlyVP && (hit.numHops == 1) && !hit.version_vp) { char tmp[32]; hit.host.IPtoStr(tmp); LOG_DEBUG("host that is not VP is disconnect: %s", tmp); rBan = PCP_ERROR_BANNED; } } } else if ((id == PCP_MESG_ASCII) || (id == PCP_MESG)) // PCP_MESG_ASCII to be depreciated { String msg; atom.readString(msg.data, sizeof(msg.data), dlen); LOG_DEBUG("PCP got text: %s", msg.cstr()); } else if (id == PCP_BCST) { r = readBroadcastAtoms(atom, numc, bcs); } else if (id == PCP_HELO) { atom.skip(numc, dlen); atom.writeParent(PCP_OLEH, 1); atom.writeBytes(PCP_HELO_SESSIONID, servMgr->sessionID.id, 16); } else if (id == PCP_PUSH) { readPushAtoms(atom, numc, bcs); } else if (id == PCP_OK) { atom.readInt(); } else if (id == PCP_QUIT) { r = atom.readInt(); if (!r) r = PCP_ERROR_QUIT; } else if (id == PCP_ATOM) { for (int i = 0; i < numc; i++) { int nc, nd; ID4 aid = atom.read(nc, nd); int ar = procAtom(atom, aid, nc, nd, bcs); if (ar) r = ar; } } else { LOG_CHANNEL("PCP skip: %s", id.getString().str()); atom.skip(numc, dlen); } if (!r) r = rBan; return r; }
int TrussSection::sendSelf(int commitTag, Channel &theChannel) { int res; // note: we don't check for dataTag == 0 for Element // objects as that is taken care of in a commit by the Domain // object - don't want to have to do the check if sending data int dataTag = this->getDbTag(); // truss packs it's data into a Vector and sends this to theChannel // along with it's dbTag and the commitTag passed in the arguments static Vector data(11); data(0) = this->getTag(); data(1) = dimension; data(2) = numDOF; data(5) = rho; data(6) = doRayleighDamping; data(7) = cMass; data(3) = theSection->getClassTag(); int matDbTag = theSection->getDbTag(); // NOTE: we do have to ensure that the Section has a database // tag if we are sending to a database channel. if (matDbTag == 0) { matDbTag = theChannel.getDbTag(); if (matDbTag != 0) theSection->setDbTag(matDbTag); } data(4) = matDbTag; if (initialDisp != 0) { for (int i=0; i<dimension; i++) { data[8+i] = initialDisp[i]; } } res = theChannel.sendVector(dataTag, commitTag, data); if (res < 0) { opserr << "WARNING TrussSection::sendSelf() - " << this->getTag() << " failed to send Vector\n"; return -1; } // truss then sends the tags of it's two end nodes res = theChannel.sendID(dataTag, commitTag, connectedExternalNodes); if (res < 0) { opserr << "WARNING TrussSection::sendSelf() - " << this->getTag() << " failed to send ID\n"; return -2; } // finally truss asks it's Section object to send itself res = theSection->sendSelf(commitTag, theChannel); if (res < 0) { opserr << "WARNING TrussSection::sendSelf() - " << this->getTag() << " failed to send its Section\n"; return -3; } return 0; }
/** Handle /INVITE */ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, User *user) { ModResult MOD_RESULT; if (parameters.size() == 2 || parameters.size() == 3) { User* u; if (IS_LOCAL(user)) u = ServerInstance->FindNickOnly(parameters[0]); else u = ServerInstance->FindNick(parameters[0]); Channel* c = ServerInstance->FindChan(parameters[1]); time_t timeout = 0; if (parameters.size() == 3) { if (IS_LOCAL(user)) timeout = ServerInstance->Time() + InspIRCd::Duration(parameters[1]); else timeout = ConvToInt(parameters[2]); } if ((!c) || (!u) || (u->registered != REG_ALL)) { user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel",user->nick.c_str(), c ? parameters[0].c_str() : parameters[1].c_str()); return CMD_FAILURE; } if ((IS_LOCAL(user)) && (!c->HasUser(user))) { user->WriteNumeric(ERR_NOTONCHANNEL, "%s %s :You're not on that channel!",user->nick.c_str(), c->name.c_str()); return CMD_FAILURE; } if (c->HasUser(u)) { user->WriteNumeric(ERR_USERONCHANNEL, "%s %s %s :is already on channel",user->nick.c_str(),u->nick.c_str(),c->name.c_str()); return CMD_FAILURE; } FIRST_MOD_RESULT(OnUserPreInvite, MOD_RESULT, (user,u,c,timeout)); if (MOD_RESULT == MOD_RES_DENY) { return CMD_FAILURE; } else if (MOD_RESULT == MOD_RES_PASSTHRU) { if (IS_LOCAL(user)) { unsigned int rank = c->GetPrefixValue(user); if (rank < HALFOP_VALUE) { // Check whether halfop mode is available and phrase error message accordingly ModeHandler* mh = ServerInstance->Modes->FindMode('h', MODETYPE_CHANNEL); user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must be a channel %soperator", user->nick.c_str(), c->name.c_str(), (mh && mh->name == "halfop" ? "half-" : "")); return CMD_FAILURE; } } } if (IS_LOCAL(u)) { Invitation::Create(c, IS_LOCAL(u), timeout); u->WriteFrom(user,"INVITE %s :%s",u->nick.c_str(),c->name.c_str()); } if (IS_LOCAL(user)) user->WriteNumeric(RPL_INVITING, "%s %s %s",user->nick.c_str(),u->nick.c_str(),c->name.c_str()); if (ServerInstance->Config->AnnounceInvites != ServerConfig::INVITE_ANNOUNCE_NONE) { char prefix; switch (ServerInstance->Config->AnnounceInvites) { case ServerConfig::INVITE_ANNOUNCE_OPS: { prefix = '@'; break; } case ServerConfig::INVITE_ANNOUNCE_DYNAMIC: { PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h'); prefix = (mh && mh->name == "halfop" ? mh->GetPrefix() : '@'); break; } default: { prefix = 0; break; } } c->WriteAllExceptSender(user, true, prefix, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str()); } FOREACH_MOD(OnUserInvite, (user,u,c,timeout)); } else if (IS_LOCAL(user)) { // pinched from ircu - invite with not enough parameters shows channels // youve been invited to but haven't joined yet. InviteList& il = IS_LOCAL(user)->GetInviteList(); for (InviteList::const_iterator i = il.begin(); i != il.end(); ++i) { user->WriteNumeric(RPL_INVITELIST, "%s :%s",user->nick.c_str(), (*i)->chan->name.c_str()); } user->WriteNumeric(RPL_ENDOFINVITELIST, "%s :End of INVITE list",user->nick.c_str()); } return CMD_SUCCESS; }
CmdResult HandleRMB(const std::vector<std::string>& parameters, User *user, bool neworder) { User* target; Channel* channel; std::string reason; std::string protectkey; std::string founderkey; bool hasnokicks; /* Set these to the parameters needed, the new version of this module switches it's parameters around * supplying a new command with the new order while keeping the old /remove with the older order. * /remove <nick> <channel> [reason ...] * /fpart <channel> <nick> [reason ...] */ const std::string& channame = parameters[neworder ? 0 : 1]; const std::string& username = parameters[neworder ? 1 : 0]; /* Look up the user we're meant to be removing from the channel */ target = ServerInstance->FindNick(username); /* And the channel we're meant to be removing them from */ channel = ServerInstance->FindChan(channame); /* Fix by brain - someone needs to learn to validate their input! */ if ((!target) || (target->registered != REG_ALL) || (!channel)) { user->WriteNumeric(ERR_NOSUCHNICK, "%s %s :No such nick/channel", user->nick.c_str(), !channel ? channame.c_str() : username.c_str()); return CMD_FAILURE; } if (!channel->HasUser(target)) { user->WriteServ( "NOTICE %s :*** The user %s is not on channel %s", user->nick.c_str(), target->nick.c_str(), channel->name.c_str()); return CMD_FAILURE; } int ulevel = channel->GetPrefixValue(user); int tlevel = channel->GetPrefixValue(target); hasnokicks = (ServerInstance->Modules->Find("m_nokicks.so") && channel->IsModeSet('Q')); if (ServerInstance->ULine(target->server)) { user->WriteNumeric(482, "%s %s :Only a u-line may remove a u-line from a channel.", user->nick.c_str(), channame.c_str()); return CMD_FAILURE; } /* We support the +Q channel mode via. the m_nokicks module, if the module is loaded and the mode is set then disallow the /remove */ if ((!IS_LOCAL(user)) || (!supportnokicks || !hasnokicks)) { /* We'll let everyone remove their level and below, eg: * ops can remove ops, halfops, voices, and those with no mode (no moders actually are set to 1) * a ulined target will get a higher level than it's possible for a /remover to get..so they're safe. * Nobody may remove a founder. */ if ((!IS_LOCAL(user)) || ((ulevel > VOICE_VALUE) && (ulevel >= tlevel) && (tlevel != 50000))) { // REMOVE/FPART will be sent to the target's server and it will reply with a PART (or do nothing if it doesn't understand the command) if (!IS_LOCAL(target)) return CMD_SUCCESS; std::string reasonparam; /* If a reason is given, use it */ if(parameters.size() > 2) reasonparam = parameters[2]; else reasonparam = "No reason given"; /* Build up the part reason string. */ reason = "Removed by " + user->nick + ": " + reasonparam; channel->WriteChannelWithServ(ServerInstance->Config->ServerName, "NOTICE %s :%s removed %s from the channel", channel->name.c_str(), user->nick.c_str(), target->nick.c_str()); target->WriteNotice("*** " + user->nick + " removed you from " + channel->name + " with the message: " + reasonparam); channel->PartUser(target, reason); } else { user->WriteServ( "NOTICE %s :*** You do not have access to /remove %s from %s", user->nick.c_str(), target->nick.c_str(), channel->name.c_str()); return CMD_FAILURE; } } else { /* m_nokicks.so was loaded and +Q was set, block! */ user->WriteServ( "484 %s %s :Can't remove user %s from channel (+Q set)", user->nick.c_str(), channel->name.c_str(), target->nick.c_str()); return CMD_FAILURE; } return CMD_SUCCESS; }
void RecordNode::setParameter(int parameterIndex, float newValue) { //editor->updateParameterButtons(parameterIndex); // 0 = stop recording // 1 = start recording // 2 = toggle individual channel (0.0f = OFF, anything else = ON) if (parameterIndex == 1) { // std::cout << "START RECORDING." << std::endl; if (newDirectoryNeeded) { createNewDirectory(); recordingNumber = 0; experimentNumber = 1; settingsNeeded = true; EVERY_ENGINE->directoryChanged(); } else { recordingNumber++; // increment recording number within this directory } if (!rootFolder.exists()) { rootFolder.createDirectory(); } if (settingsNeeded) { String settingsFileName = rootFolder.getFullPathName() + File::separator + "settings" + ((experimentNumber > 1) ? "_" + String(experimentNumber) : String::empty) + ".xml"; AccessClass::getEditorViewport()->saveState(File(settingsFileName), m_lastSettingsText); settingsNeeded = false; } m_recordThread->setFileComponents(rootFolder, experimentNumber, recordingNumber); channelMap.clear(); int totChans = channelPointers.size(); OwnedArray<RecordProcessorInfo> procInfo; Array<int> chanProcessorMap; Array<int> chanOrderinProc; int lastProcessor = -1; int procIndex = -1; int chanProcOrder = 0; for (int ch = 0; ch < totChans; ++ch) { Channel* chan = channelPointers[ch]; if (chan->getRecordState()) { channelMap.add(ch); //This is bassed on the assumption that all channels from the same processor are added contiguously //If this behaviour changes, this check should be most thorough if (chan->nodeId != lastProcessor) { lastProcessor = chan->nodeId; RecordProcessorInfo* pi = new RecordProcessorInfo(); pi->processorId = chan->nodeId; procInfo.add(pi); procIndex++; chanProcOrder = 0; } procInfo.getLast()->recordedChannels.add(channelMap.size()-1); chanProcessorMap.add(procIndex); chanOrderinProc.add(chanProcOrder); chanProcOrder++; } } std::cout << "Num Recording Processors: " << procInfo.size() << std::endl; int numRecordedChannels = channelMap.size(); //WARNING: If at some point we record at more that one recordEngine at once, we should change this, as using OwnedArrays only works for the first EVERY_ENGINE->setChannelMapping(channelMap, chanProcessorMap, chanOrderinProc, procInfo); m_recordThread->setChannelMap(channelMap); m_dataQueue->setChannels(numRecordedChannels); m_eventQueue->reset(); m_spikeQueue->reset(); m_recordThread->setFirstBlockFlag(false); setFirstBlock = false; m_recordThread->startThread(); isRecording = true; hasRecorded = true; } else if (parameterIndex == 0) { std::cout << "STOP RECORDING." << std::endl; if (isRecording) { isRecording = false; // close the writing thread. m_recordThread->signalThreadShouldExit(); m_recordThread->waitForThreadToExit(2000); while (m_recordThread->isThreadRunning()) { std::cerr << "RecordEngine timeout" << std::endl; if (AlertWindow::showOkCancelBox(AlertWindow::WarningIcon, "Record Thread timeout", "The recording thread is taking too long to close.\nThis could mean there is still data waiting to be written in the buffer, but it normally " "shouldn't take this long.\nYou can either wait a bit more or forcefully close the thread. Note that data might be lost or corrupted" "if forcibly closing the thread.", "Stop the thread", "Wait a bit more")) { m_recordThread->stopThread(100); m_recordThread->forceCloseFiles(); } else { m_recordThread->waitForThreadToExit(2000); } } } } else if (parameterIndex == 2) { if (isProcessing) { std::cout << "Toggling channel " << currentChannel << std::endl; if (isRecording) { //Toggling channels while recording isn't allowed. Code shouldn't reach here. //In case it does, display an error and exit. CoreServices::sendStatusMessage("Toggling record channels while recording is not allowed"); std::cout << "ERROR: Wrong code section reached\n Toggling record channels while recording is not allowed." << std::endl; return; } if (newValue == 0.0f) { channelPointers[currentChannel]->setRecordState(false); } else { channelPointers[currentChannel]->setRecordState(true); } } } }
int MP_Joint2D::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { int dataTag = this->getDbTag(); Vector data(15); int result = theChannel.recvVector(dataTag, commitTag, data); if (result < 0) { opserr << "WARNING MP_Joint2D::recvSelf - error receiving ID data\n"; return result; } this->setTag( (int) data(0)); nodeRetained = (int) data(1); nodeConstrained = (int) data(2); MainDOF = (int) data(3); AuxDOF = (int) data(4); FixedEnd = (int) data(5); int constrDOFsize = (int) data(6); int retainDOFsize = (int) data(7); int numRows = (int) data(8); int numCols = (int) data(9); dbTag1 = (int) data(10); dbTag2 = (int) data(11); dbTag3 = (int) data(12); LargeDisplacement = (int) data(13); Length0 = data(14); // receive constrDOF ID if (constrDOFsize != 0) { constrDOF = new ID(constrDOFsize); int result = theChannel.recvID(dbTag1, commitTag, *constrDOF); if (result < 0) { opserr << "WARNING MP_Joint2D::recvSelf "; opserr << "- error receiving constrained data\n"; return result; } } // receive retainDOF ID if (retainDOFsize != 0) { retainDOF = new ID(retainDOFsize); int result = theChannel.recvID(dbTag2, commitTag, *retainDOF); if (result < 0) { opserr << "WARNING MP_Joint2D::recvSelf "; opserr << "- error receiving retained data\n"; return result; } } // receive the constraint matrix if (numRows != 0 && numCols != 0) { constraint = new Matrix(numRows,numCols); int result = theChannel.recvMatrix(dbTag3, commitTag, *constraint); if (result < 0) { opserr << "WARNING MP_Joint2D::recvSelf "; opserr << "- error receiving Matrix data\n"; return result; } } return 0; }
int DispBeamColumn2dWithSensitivity::recvSelf(int commitTag, Channel &theChannel, FEM_ObjectBroker &theBroker) { // // receive the integer data containing tag, numSections and coord transformation info // int dbTag = this->getDbTag(); int i; static ID idData(7); // one bigger than needed so no clash with section ID if (theChannel.recvID(dbTag, commitTag, idData) < 0) { opserr << "DispBeamColumn2dWithSensitivity::recvSelf() - failed to recv ID data\n"; return -1; } this->setTag(idData(0)); connectedExternalNodes(0) = idData(1); connectedExternalNodes(1) = idData(2); int crdTransfClassTag = idData(4); int crdTransfDbTag = idData(5); if (idData(6) == 1) { // recv damping coefficients static Vector dData(4); if (theChannel.recvVector(dbTag, commitTag, dData) < 0) { opserr << "DispBeamColumn2d::sendSelf() - failed to recv double data\n"; return -1; } alphaM = dData(0); betaK = dData(1); betaK0 = dData(2); betaKc = dData(3); } // create a new crdTransf object if one needed if (crdTransf == 0 || crdTransf->getClassTag() != crdTransfClassTag) { if (crdTransf != 0) delete crdTransf; crdTransf = theBroker.getNewCrdTransf(crdTransfClassTag); if (crdTransf == 0) { opserr << "DispBeamColumn2dWithSensitivity::recvSelf() - failed to obtain a CrdTrans object with classTag " << crdTransfClassTag << endln; return -2; } } crdTransf->setDbTag(crdTransfDbTag); // invoke recvSelf on the crdTransf object if (crdTransf->recvSelf(commitTag, theChannel, theBroker) < 0) { opserr << "DispBeamColumn2dWithSensitivity::sendSelf() - failed to recv crdTranf\n"; return -3; } // // recv an ID for the sections containing each sections dbTag and classTag // ID idSections(2*idData(3)); int loc = 0; if (theChannel.recvID(dbTag, commitTag, idSections) < 0) { opserr << "DispBeamColumn2dWithSensitivity::recvSelf() - failed to recv ID data\n"; return -1; } // // now receive the sections // if (numSections != idData(3)) { // // we do not have correct number of sections, must delete the old and create // new ones before can recvSelf on the sections // // delete the old if (numSections != 0) { for (int i=0; i<numSections; i++) delete theSections[i]; delete [] theSections; } // create a new array to hold pointers theSections = new SectionForceDeformation *[idData(3)]; if (theSections == 0) { opserr << "DispBeamColumn2dWithSensitivity::recvSelf() - out of memory creating sections array of size " << idData(3) << endln; return -1; } // create a section and recvSelf on it numSections = idData(3); loc = 0; for (i=0; i<numSections; i++) { int sectClassTag = idSections(loc); int sectDbTag = idSections(loc+1); loc += 2; theSections[i] = theBroker.getNewSection(sectClassTag); if (theSections[i] == 0) { opserr << "DispBeamColumn2dWithSensitivity::recvSelf() - Broker could not create Section of class type " << sectClassTag << endln; exit(-1); } theSections[i]->setDbTag(sectDbTag); if (theSections[i]->recvSelf(commitTag, theChannel, theBroker) < 0) { opserr << "DispBeamColumn2dWithSensitivity::recvSelf() - section " << i << " failed to recv itself\n"; return -1; } } } else { // // for each existing section, check it is of correct type // (if not delete old & create a new one) then recvSelf on it // loc = 0; for (i=0; i<numSections; i++) { int sectClassTag = idSections(loc); int sectDbTag = idSections(loc+1); loc += 2; // check of correct type if (theSections[i]->getClassTag() != sectClassTag) { // delete the old section[i] and create a new one delete theSections[i]; theSections[i] = theBroker.getNewSection(sectClassTag); if (theSections[i] == 0) { opserr << "DispBeamColumn2dWithSensitivity::recvSelf() - Broker could not create Section of class type " << sectClassTag << endln; exit(-1); } } // recvSelf on it theSections[i]->setDbTag(sectDbTag); if (theSections[i]->recvSelf(commitTag, theChannel, theBroker) < 0) { opserr << "DispBeamColumn2dWithSensitivity::recvSelf() - section " << i << " failed to recv itself\n"; return -1; } } } return 0; }