📄 gatevc.cc
字号:
if(needPosting()) { gateDebug1(2,"gateVcData::vcPostEvent() posting event (event_data at %p)\n", (void *)event_data); if(event_data->isAtomic()) {#if DEBUG_EVENT_DATA if(pv->fieldType() == DBF_ENUM) { heading("gateVcData::vcPostEvent",name()); dumpdd(99,"event_data",name(),event_data); }#elif DEBUG_GDD heading("gateVcData::vcPostEvent(1)",name()); dumpdd(1,"event_data",name(),event_data);#endif postEvent(select_mask,*event_data);#ifdef RATE_STATS mrg->post_event_count++;#endif } else { // no more than 4 events per second // if(++event_count<4)#if DEBUG_EVENT_DATA && 0 if(pv->fieldType() == DBF_ENUM) { heading("gateVcData::vcPostEvent",name()); dumpdd(99,"event_data",name(),event_data); }#endif#if DEBUG_GDD heading("gateVcData::vcPostEvent(2)",name()); dumpdd(1,"event_data",name(),event_data);#endif postEvent(select_mask,*event_data);#ifdef RATE_STATS mrg->post_event_count++;#endif } }}void gateVcData::vcData(){ // pv_data just appeared - don't really care gateDebug1(10,"gateVcData::vcData() name=%s\n",name());}void gateVcData::vcDelete(void){ gateDebug1(10,"gateVcData::vcDelete() name=%s\n",name());}caStatus gateVcData::interestRegister(void){ gateDebug1(10,"gateVcData::interestRegister() name=%s\n",name()); // supposed to post the value shortly after this is called? markInterested(); return S_casApp_success;}void gateVcData::interestDelete(void){ gateDebug1(10,"gateVcData::interestDelete() name=%s\n",name()); markNotInterested();}caStatus gateVcData::read(const casCtx& ctx, gdd& dd){ gateDebug1(10,"gateVcData::read() name=%s\n",name()); static const aitString str = "Not Supported by Gateway";#if DEBUG_GDD || DEBUG_ENUM heading("gateVcData::read",name()); dumpdd(1,"dd(incoming)",name(),&dd);#endif#if DEBUG_RTYP heading("gateVcData::read",name()); fflush(stderr); printf(" gddAppType: %d \n",(int)dd.applicationType()); fflush(stdout);#endif#if DEBUG_TIMESTAMP heading("gateVcData::read",name());#endif#if DEBUG_DELAY if(!strncmp("Xorbit",name(),6)) { printf("%s gateVcData::read: %s state=%d appType=%d\n", timeStamp(),name(), getState(),dd.applicationType()); }#endif // Branch on application type unsigned at=dd.applicationType(); switch(at) { case gddAppType_ackt: case gddAppType_acks: // Not useful and not monitorable so data would be out-of-date#if 0 fprintf(stderr,"%s gateVcData::read(): " "Got unsupported app type %d for %s\n", timeStamp(),at,name()); fflush(stderr);#endif#if DEBUG_DELAY if(!strncmp("Xorbit",name(),6)) { printf(" S_casApp_noSupport\n"); }#endif return S_casApp_noSupport; case gddAppType_class: // Would require supporting DBR_CLASS_NAME#if DEBUG_RTYP fflush(stderr); printf(" gddAppType_class (%d):\n",(int)at); dumpdd(1,"dd(incoming)",name(),&dd);#endif dd.put(str);#if DEBUG_RTYP dumpdd(1,"dd(outgoing)",name(),&dd); printf(" gddAppType(outgoing): %d \n",(int)dd.applicationType()); fflush(stdout);#endif#if DEBUG_DELAY if(!strncmp("Xorbit",name(),6)) { printf(" S_casApp_noSupport\n"); }#endif return S_casApp_noSupport; case gddAppType_dbr_stsack_string: if((event_data && !(event_data->applicationType()==gddAppType_dbr_stsack_string)) || !pv->alhMonitored()) { // Only start monitoring alh data if it is requested pv->markAlhGetPending(); pv->alhMonitor(); } if(!ready() || pv->alhGetPending()) { // Specify async return if alh data not ready gateDebug0(10,"gateVcData::read() alh data not ready\n"); // the read will complete when the data is available alhRio.add(*(new gateAsyncR(ctx,dd,&alhRio))); return S_casApp_asyncCompletion; } else if(pending_write) { // Pending write in progress, don't read now return S_casApp_postponeAsyncIO; } else { // Copy the current state into the dd copyState(dd); } return S_casApp_success; default: if(!ready()) { // Specify async return if PV not ready gateDebug0(10,"gateVcData::read() pv not ready\n"); // the read will complete when the connection is complete rio.add(*(new gateAsyncR(ctx,dd,&rio)));#if DEBUG_GDD fflush(stderr); printf("gateVcData::read: return S_casApp_asyncCompletion\n"); fflush(stdout);#endif#if DEBUG_DELAY if(!strncmp("Xorbit",name(),6)) { printf(" S_casApp_asyncCompletion (%s %s)\n", ready()?"Ready":"Not Ready", pv->alhGetPending()?"alhGetPending":"No alhGetPending"); }#endif return S_casApp_asyncCompletion; } else if(pending_write) { // Pending write in progress, don't read now#if DEBUG_GDD fflush(stderr); printf("gateVcData::read: return S_casApp_postponeAsyncIO\n"); fflush(stdout);#endif#if DEBUG_DELAY if(!strncmp("Xorbit",name(),6)) { printf(" S_casApp_asyncCompletion (Pending write)\n"); }#endif return S_casApp_postponeAsyncIO; } else { // Copy the current state into the dd copyState(dd);#if DEBUG_GDD fflush(stderr); printf("gateVcData::read: return S_casApp_success\n"); fflush(stdout);#endif#if DEBUG_TIMESTAMP { TS_STAMP ts; dd.getTimeStamp(&ts); fprintf(stderr,"gateVcData::read %s %u %u\n", name(),ts.secPastEpoch,ts.nsec);#if 0 dd.dump();#endif }#endif#if DEBUG_DELAY if(!strncmp("Xorbit",name(),6)) { printf(" S_casApp_success\n"); }#endif return S_casApp_success; } }}// This is the virtual write function defined in casPV. It should no// longer be called if casChannel::write is implemented.caStatus gateVcData::write(const casCtx& ctx, const gdd& dd){ fprintf(stderr,"Virtual gateVcData::write called for %s.\n" " This is an error!\n",name()); return S_casApp_noSupport;}// This is a non-virtual-function write that allows passing a pointer// to the gateChannel. Currently chan is not used.caStatus gateVcData::write(const casCtx& ctx, const gdd& dd, gateChan &/*chan*/){ int docallback=GATE_DOCALLBACK; gateDebug1(10,"gateVcData::write() name=%s\n",name());#if DEBUG_GDD || DEBUG_SLIDER heading("gateVcData::write",name()); dumpdd(1,"dd(incoming)",name(),&dd);#endif // Branch on application type unsigned at=dd.applicationType(); switch(at) { case gddAppType_class: // Would require supporting DBR_CLASS_NAME case gddAppType_dbr_stsack_string: // Cannot be written#if 0 fprintf(stderr,"%s gateVcData::write: " "Got unsupported app type %d for %s\n", timeStamp(),at,name()); fflush(stderr);#endif return S_casApp_noSupport; case gddAppType_ackt: case gddAppType_acks: docallback = GATE_NOCALLBACK; // Fall through default: if(global_resources->isReadOnly()) return S_casApp_success; if(!ready()) { // Handle async return if PV not ready gateDebug0(10,"gateVcData::write() pv not ready\n"); wio.add(*(new gateAsyncW(ctx,dd,&wio)));#if DEBUG_GDD || DEBUG_SLIDER fflush(stderr); printf("S_casApp_asyncCompletion\n"); fflush(stdout);#endif return S_casApp_asyncCompletion; } else if(pending_write) { // Pending write already in progress#if DEBUG_GDD || DEBUG_SLIDER fflush(stderr); printf("S_casApp_postponeAsyncIO\n"); fflush(stdout);#endif return S_casApp_postponeAsyncIO; } else { caStatus stat = pv->put(&dd, docallback); if(stat != S_casApp_success) return stat; if(docallback) { // Start a pending write#if DEBUG_GDD || DEBUG_SLIDER fflush(stderr); printf("pending_write\n"); fflush(stdout);#endif pending_write = new gatePendingWrite(*this,ctx,dd); if(!pending_write) return S_casApp_noMemory; else return S_casApp_asyncCompletion; } else { return S_casApp_success; } } }}caStatus gateVcData::putCB(int putStatus){ gateDebug2(10,"gateVcData::putCB() status=%d name=%s\n",status,name()); // If the pending_write is gone, do nothing if(!pending_write) return putStatus; if(putStatus == ECA_NORMAL) pending_write->postIOCompletion(S_casApp_success); else if(putStatus == ECA_DISCONNCHID || putStatus == ECA_DISCONN) // IOC disconnected has a meaningful code pending_write->postIOCompletion(S_casApp_canceledAsyncIO); else // KE: There is no S_casApp code for failure, return -1 for now // (J. Hill suggestion) pending_write->postIOCompletion((unsigned long)-1); // Set the pending_write pointer to NULL indicating the pending // write is finished. (The gatePendingWrite instantiation will be // deleted by CAS) pending_write=NULL; return putStatus;}aitEnum gateVcData::bestExternalType(void) const{ gateDebug0(10,"gateVcData::bestExternalType()\n"); if(pv) return pv->nativeType(); else return aitEnumFloat64; // this sucks - potential problem area}unsigned gateVcData::maxDimension(void) const{ unsigned dim; // This information could be asked for very early, before the data // gdd is ready. if(pv_data) { dim=pv_data->dimension(); } else { if(maximumElements()>1) dim=1; else dim=0; } gateDebug2(10,"gateVcData::maxDimension() %s %d\n",name(),(int)dim); return dim;}#if NODEBUGaitIndex gateVcData::maxBound(unsigned /*dim*/) const#elseaitIndex gateVcData::maxBound(unsigned dim) const#endif{ gateDebug3(10,"gateVcData::maxBound(%u) %s %d\n", dim,name(),(int)maximumElements()); return maximumElements();}aitIndex gateVcData::maximumElements(void) const{ return pv?pv->maxElements():0;}void gateVcData::removeEntry(void){#if DEBUG_ACCESS printf("gateVcData::removeEntry %s asentry=%p\n", getName(),asentry);#endif // Replace the pointer in the gateVcData asentry=NULL; // Loop over gateVcChan's and delete the client tsDLIter<gateVcChan> iter=chan_list.firstIter(); while(iter.valid()) { iter->deleteAsClient(); iter++; }}void gateVcData::resetEntry(gateAsEntry *asentryIn){#if DEBUG_ACCESS printf("gateVcData::resetEntry %s asentry=%p asentryIn=%p\n", getName(),asentry,asentryIn);#endif // Replace the pointer in the gateVcData asentry=asentryIn; // Loop over gateVcChan's tsDLIter<gateVcChan> iter=chan_list.firstIter(); while(iter.valid()) { iter->resetAsClient(asentry); iter++; }}void gateVcData::setReadAccess(aitBool b){ read_access=b; postAccessRights();}void gateVcData::setWriteAccess(aitBool b){ if(global_resources->isReadOnly()) write_access=aitFalse; else write_access=b; postAccessRights();}// Loops over all channels and calls their postAccessRights eventvoid gateVcData::postAccessRights(void){ gateDebug0(5,"gateVcData::postAccessRights() posting access rights\n"); tsDLIter<gateVcChan> iter=chan_list.firstIter(); while(iter.valid()) { iter->postAccessRightsEvent(); iter++; }}/* **************************** Emacs Editing Sequences ***************** *//* Local Variables: *//* tab-width: 4 *//* c-basic-offset: 4 *//* c-comment-only-line-offset: 0 *//* c-file-offsets: ((substatement-open . 0) (label . 0)) *//* End: */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -